6 |
kaklik |
1 |
<?php
|
|
|
2 |
/*************************
|
|
|
3 |
Coppermine Photo Gallery
|
|
|
4 |
************************
|
|
|
5 |
Copyright (c) 2003-2005 Coppermine Dev Team
|
|
|
6 |
v1.1 originaly written by Gregory DEMAR
|
|
|
7 |
|
|
|
8 |
This program is free software; you can redistribute it and/or modify
|
|
|
9 |
it under the terms of the GNU General Public License as published by
|
|
|
10 |
the Free Software Foundation; either version 2 of the License, or
|
|
|
11 |
(at your option) any later version.
|
|
|
12 |
********************************************
|
|
|
13 |
Coppermine version: 1.3.3
|
|
|
14 |
$Source: /cvsroot/coppermine/stable/picEditor.php,v $
|
|
|
15 |
$Revision: 1.4 $
|
|
|
16 |
$Author: gaugau $
|
|
|
17 |
$Date: 2005/04/19 03:17:11 $
|
|
|
18 |
**********************************************/
|
|
|
19 |
|
|
|
20 |
// embedded images
|
|
|
21 |
function cornerleft()
|
|
|
22 |
{
|
|
|
23 |
header("Content-type: image/gif");
|
|
|
24 |
header("Content-length: 290");
|
|
|
25 |
echo base64_decode(
|
|
|
26 |
'R0lGODlhGQAZAMQAAP///+zu8d3h5tXb4dbW1s/V3czU2sXN1c'.
|
|
|
27 |
'PK0cPExMHCw7y+wLW1tbC2va6yuKurrJmZmf///wAAAAAAAAAA'.
|
|
|
28 |
'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BA'.
|
|
|
29 |
'UUABEALAAAAAAZABkAAAWfICCOZGmeaHoqysI8CZG4sEzHSZ6I'.
|
|
|
30 |
'CeJEEULg8AsOi0IgULRACgoNIOEZDQoGyoiIAUwECkUvuBvAZk'.
|
|
|
31 |
'UPI1F6ZBuyS0Ds6RxbzXCR0C4Ol+FKPAdVQmtGb4BxTVJ0jHiJ'.
|
|
|
32 |
'W2R8f4mBAGmFSAGIlXFzdlOPnXpffqKjcoNunYBMTqeskRFesL'.
|
|
|
33 |
'GXh6yVPKG5ugBCtb08vbYJxKjGx5ByyokhADs='.
|
|
|
34 |
'');
|
|
|
35 |
}
|
|
|
36 |
function cornerright()
|
|
|
37 |
{
|
|
|
38 |
header("Content-type: image/gif");
|
|
|
39 |
header("Content-length: 292");
|
|
|
40 |
echo base64_decode(
|
|
|
41 |
'R0lGODlhGQAZAMQAAP///+zv8t3h5tXc5NbW1s/V3dHS08XN1c'.
|
|
|
42 |
'PK0cLDw8HCw7y+wLW1ta+0u66yuKurrJmZmf///wAAAAAAAAAA'.
|
|
|
43 |
'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BA'.
|
|
|
44 |
'UUABEALAAAAAAZABkAAAWhYCSOZGlGCQCc7JmubSy+skzX5xAY'.
|
|
|
45 |
'Km4OAsLNJyrsIo8eMaJTiBhKH9AgciyiNSM10jgMZc2qFtuaih'.
|
|
|
46 |
'qF4JelPR+OSVg54Iw4jIknuWTmprdWeyNtXG9bXWsjYXZ4YjuC'.
|
|
|
47 |
'fWgCh2lCe4RdR4VwZIt3AXmMoHpyTAOUk2d/Z1elAQRVb7B2sm'.
|
|
|
48 |
'cILwm5CQYJDwwLu72/wb7ALyrIycrLzM3OyyEAOw=='.
|
|
|
49 |
'');
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
// image calls
|
|
|
53 |
if (isset($_GET['img'])) {
|
|
|
54 |
if ($_GET['img']=="left") {cornerleft();exit;}
|
|
|
55 |
}
|
|
|
56 |
if (isset($_GET['img'])) {
|
|
|
57 |
if ($_GET['img']=="right") {cornerright();exit;}
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
define('IN_COPPERMINE', true);
|
|
|
62 |
define('EDITPICS_PHP', true);
|
|
|
63 |
|
|
|
64 |
require('include/init.inc.php');
|
|
|
65 |
require('include/picmgmt.inc.php');
|
|
|
66 |
|
|
|
67 |
define('IMG_DIR', $CONFIG['fullpath'].'edit/');
|
|
|
68 |
|
|
|
69 |
if (!(GALLERY_ADMIN_MODE || USER_ADMIN_MODE)) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
|
|
|
70 |
|
|
|
71 |
|
|
|
72 |
if (isset($HTTP_GET_VARS['id'])) {
|
|
|
73 |
$pid = (int)$HTTP_GET_VARS['id'];
|
|
|
74 |
} elseif (isset($HTTP_POST_VARS['id'])) {
|
|
|
75 |
$pid = (int)$HTTP_POST_VARS['id'];
|
|
|
76 |
} else {
|
|
|
77 |
$pid = -1;
|
|
|
78 |
}
|
|
|
79 |
if ($pid > 0){
|
|
|
80 |
|
|
|
81 |
$result = db_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} WHERE pid = '$pid'");
|
|
|
82 |
$CURRENT_PIC = mysql_fetch_array($result);
|
|
|
83 |
mysql_free_result($result);
|
|
|
84 |
$pic_url = get_pic_url($CURRENT_PIC,'fullsize');
|
|
|
85 |
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
//Garbage collection run at an probability of 25% and delete all files older than one hour
|
|
|
89 |
if (rand(1,100) < 25){
|
|
|
90 |
$d = opendir(IMG_DIR);
|
|
|
91 |
|
|
|
92 |
while ($file = readdir($d)){
|
|
|
93 |
if (is_file(IMG_DIR.$file) && ((time() - filemtime(IMG_DIR.$file))/60) > 60 && $file !="index.html" ){
|
|
|
94 |
@unlink(IMG_DIR.$file);
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
}
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
//Include the proper class for image Object
|
|
|
101 |
if ($CONFIG['thumb_method']=="gd2"){
|
|
|
102 |
require("include/imageObjectGD.class.php");
|
|
|
103 |
}elseif ($CONFIG['thumb_method']=="im"){
|
|
|
104 |
require("include/imageObjectIM.class.php");
|
|
|
105 |
}else{
|
|
|
106 |
die ("Editor class for your resize method not implemented");
|
|
|
107 |
}
|
|
|
108 |
|
|
|
109 |
//////////////////////////////////Main script//////////////////////////////////////
|
|
|
110 |
// PREVENTING CACHING
|
|
|
111 |
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
|
|
|
112 |
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
|
|
113 |
// always modified
|
|
|
114 |
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
|
|
|
115 |
header("Cache-Control: post-check=0, pre-check=0", false);
|
|
|
116 |
header("Pragma: no-cache"); // HTTP/1.0
|
|
|
117 |
|
|
|
118 |
// PAGE INIT
|
|
|
119 |
if (!$img_dir) $img_dir = IMG_DIR;
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
if ($_GET['id']){
|
|
|
123 |
//Copy the Image file to the editing directory
|
|
|
124 |
if (copy($CONFIG['fullpath'].$CURRENT_PIC['filepath'].$CURRENT_PIC['filename'],$img_dir.$CURRENT_PIC['filename']))
|
|
|
125 |
$newimage = $CURRENT_PIC['filename'];
|
|
|
126 |
}else if(!isset($newimage)){
|
|
|
127 |
$newimage = $_POST['newimage'];
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
if ($newimage){
|
|
|
131 |
$imgObj = new imageObject($img_dir,$newimage);
|
|
|
132 |
if ($_POST['quality']){
|
|
|
133 |
$imgObj->quality = $_POST['quality'];
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
if ($imgObj->imgRes){
|
|
|
137 |
if ($_POST['clipval'] && $_POST['cropping']==true){
|
|
|
138 |
$imgObj = $imgObj->cropImage($_POST['clipval']);
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
if ($_POST['angle']<>0){
|
|
|
142 |
$imgObj = $imgObj->rotateImage($_POST['angle']);
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
|
|
|
146 |
}
|
|
|
147 |
$newimage = $imgObj->filename;
|
|
|
148 |
}// newimage
|
|
|
149 |
|
|
|
150 |
if(isset($_POST["save"])) {
|
|
|
151 |
|
|
|
152 |
$width=$imgObj->width;
|
|
|
153 |
$height=$imgObj->height;
|
|
|
154 |
$normal = $CONFIG['fullpath'] . $CURRENT_PIC['filepath'] . $CONFIG['normal_pfx'] . $CURRENT_PIC['filename'];
|
|
|
155 |
$thumbnail = $CONFIG['fullpath'] . $CURRENT_PIC['filepath'] . $CONFIG['thumb_pfx'] . $CURRENT_PIC['filename'];
|
|
|
156 |
$filesize = @filesize($img_dir.$newimage);
|
|
|
157 |
|
|
|
158 |
//Full image replace
|
|
|
159 |
copy($img_dir.$newimage,$CONFIG['fullpath'].$CURRENT_PIC['filepath'].$CURRENT_PIC['filename']) ;
|
|
|
160 |
|
|
|
161 |
// Normal image resized and replace, use the CPG resize method instead of the object resizeImage
|
|
|
162 |
// as using the object resizeImage will make the final display of image to be a thumbnail in the editor
|
|
|
163 |
|
|
|
164 |
if (max($width, $height) > $CONFIG['picture_width'] && $CONFIG['make_intermediate']) {
|
|
|
165 |
resize_image($img_dir.$newimage, $normal, $CONFIG['picture_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use']);
|
|
|
166 |
} else {
|
|
|
167 |
@unlink($normal);
|
|
|
168 |
}
|
|
|
169 |
|
|
|
170 |
//thumbnail resized and replace
|
|
|
171 |
resize_image($img_dir.$newimage, $thumbnail, $CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use']);
|
|
|
172 |
$total_filesize = $filesize + (file_exists($normal) ? filesize($normal) : 0) + filesize($thumbnail);
|
|
|
173 |
|
|
|
174 |
//Update the image size in the DB
|
|
|
175 |
db_query("UPDATE {$CONFIG['TABLE_PICTURES']}
|
|
|
176 |
SET pheight = $height,
|
|
|
177 |
pwidth = $width,
|
|
|
178 |
filesize = $filesize,
|
|
|
179 |
total_filesize = $total_filesize
|
|
|
180 |
WHERE pid = '$pid'");
|
|
|
181 |
|
|
|
182 |
$message = "Picture successfully saved - you can close this window now";
|
|
|
183 |
|
|
|
184 |
}
|
|
|
185 |
|
|
|
186 |
if(isset($_POST["save_thumb"])) {
|
|
|
187 |
|
|
|
188 |
$width=$imgObj->width;
|
|
|
189 |
$height=$imgObj->height;
|
|
|
190 |
$normal = $CONFIG['fullpath'] . $CURRENT_PIC['filepath'] . $CONFIG['normal_pfx'] . $CURRENT_PIC['filename'];
|
|
|
191 |
$thumbnail = $CONFIG['fullpath'] . $CURRENT_PIC['filepath'] . $CONFIG['thumb_pfx'] . $CURRENT_PIC['filename'];
|
|
|
192 |
$currentPic = $CONFIG['fullpath'] . $CURRENT_PIC['filepath'] . $CURRENT_PIC['filename'];
|
|
|
193 |
|
|
|
194 |
//Calculate the thumbnail dimensions
|
|
|
195 |
if ($CONFIG['thumb_use'] == 'ht') {
|
|
|
196 |
$ratio = $height / $CONFIG['thumb_width'] ;
|
|
|
197 |
} elseif ($CONFIG['thumb_use'] == 'wd') {
|
|
|
198 |
$ratio = $width / $CONFIG['thumb_width'] ;
|
|
|
199 |
} else {
|
|
|
200 |
$ratio = max($width, $height) / $CONFIG['thumb_width'] ;
|
|
|
201 |
}
|
|
|
202 |
$ratio = max($ratio, 1.0);
|
|
|
203 |
$dstWidth = (int)($width / $ratio);
|
|
|
204 |
$dstHeight = (int)($height / $ratio);
|
|
|
205 |
$imgObj->quality = (int)($_POST['quality']);
|
|
|
206 |
$imgObj = $imgObj->resizeImage($dstWidth,$dstHeight);
|
|
|
207 |
$newimage = $imgObj->filename;
|
|
|
208 |
|
|
|
209 |
copy($img_dir.$newimage,$CONFIG['fullpath'].$CURRENT_PIC['filepath'].$CONFIG['thumb_pfx'].$CURRENT_PIC['filename']) ;
|
|
|
210 |
|
|
|
211 |
$total_filesize = filesize($currentPic) + (file_exists($normal) ? filesize($normal) : 0) + filesize($thumbnail);
|
|
|
212 |
|
|
|
213 |
//Update the image size in the DB
|
|
|
214 |
db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET total_filesize = $total_filesize WHERE pid = '$pid'");
|
|
|
215 |
|
|
|
216 |
|
|
|
217 |
$message = "Thumbnail successfully saved - you can close this window now";
|
|
|
218 |
|
|
|
219 |
}
|
|
|
220 |
|
|
|
221 |
?>
|
|
|
222 |
<html>
|
|
|
223 |
<meta http-equiv="imagetoolbar" content="no" />
|
|
|
224 |
<head>
|
|
|
225 |
<title><?php echo $lang_editpics_php['crop_title'] ?></title>
|
|
|
226 |
<?php if($imgObj){?>
|
|
|
227 |
<script language="JavaScript1.2">
|
|
|
228 |
|
|
|
229 |
/****************************************************************************
|
|
|
230 |
DHTML library from DHTMLCentral.com
|
|
|
231 |
* Copyright (C) 2001 Thomas Brattli 2001
|
|
|
232 |
* This script was released at DHTMLCentral.com
|
|
|
233 |
* Visit for more great scripts!
|
|
|
234 |
* This may be used and changed freely as long as this msg is intact!
|
|
|
235 |
* We will also appreciate any links you could give us.
|
|
|
236 |
*
|
|
|
237 |
* Made by Thomas Brattli 2001
|
|
|
238 |
***************************************************************************/
|
|
|
239 |
//Browsercheck (needed) ***************
|
|
|
240 |
function lib_bwcheck(){
|
|
|
241 |
this.ver=navigator.appVersion
|
|
|
242 |
this.agent=navigator.userAgent
|
|
|
243 |
this.dom=document.getElementById?1:0
|
|
|
244 |
this.opera5=this.agent.indexOf("Opera 5")>-1
|
|
|
245 |
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
|
|
|
246 |
this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
|
|
|
247 |
this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
|
|
|
248 |
this.ie=this.ie4||this.ie5||this.ie6
|
|
|
249 |
this.mac=this.agent.indexOf("Mac")>-1
|
|
|
250 |
this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
|
|
|
251 |
this.ns4=(document.layers && !this.dom)?1:0;
|
|
|
252 |
this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5)
|
|
|
253 |
return this
|
|
|
254 |
}
|
|
|
255 |
bw=new lib_bwcheck() //Browsercheck object
|
|
|
256 |
|
|
|
257 |
//Debug function ******************
|
|
|
258 |
function lib_message(txt){alert(txt); return false}
|
|
|
259 |
|
|
|
260 |
//Lib objects ********************
|
|
|
261 |
function lib_obj(obj,nest){
|
|
|
262 |
if(!bw.bw) return lib_message('Old browser')
|
|
|
263 |
nest=(!nest) ? "":'document.'+nest+'.'
|
|
|
264 |
this.evnt=bw.dom? document.getElementById(obj):
|
|
|
265 |
bw.ie4?document.all[obj]:bw.ns4?eval(nest+"document.layers." +obj):0;
|
|
|
266 |
if(!this.evnt) return lib_message('The layer does not exist ('+obj+')'
|
|
|
267 |
+'- \nIf your using Netscape please check the nesting of your tags!')
|
|
|
268 |
this.css=bw.dom||bw.ie4?this.evnt.style:this.evnt;
|
|
|
269 |
this.ref=bw.dom||bw.ie4?document:this.css.document;
|
|
|
270 |
this.x=parseInt(this.css.left)||this.css.pixelLeft||this.evnt.offsetLeft||0;
|
|
|
271 |
this.y=parseInt(this.css.top)||this.css.pixelTop||this.evnt.offsetTop||0
|
|
|
272 |
this.w=this.evnt.offsetWidth||this.css.clip.width||
|
|
|
273 |
this.ref.width||this.css.pixelWidth||0;
|
|
|
274 |
this.h=this.evnt.offsetHeight||this.css.clip.height||
|
|
|
275 |
this.ref.height||this.css.pixelHeight||0
|
|
|
276 |
this.c=0 //Clip values
|
|
|
277 |
if((bw.dom || bw.ie4) && this.css.clip) {
|
|
|
278 |
this.c=this.css.clip; this.c=this.c.slice(5,this.c.length-1);
|
|
|
279 |
this.c=this.c.split(' ');
|
|
|
280 |
for(var i=0;i<4;i++){this.c[i]=parseInt(this.c[i])}
|
|
|
281 |
}
|
|
|
282 |
this.ct=this.css.clip.top||this.c[0]||0;
|
|
|
283 |
this.cr=this.css.clip.right||this.c[1]||this.w||0
|
|
|
284 |
this.cb=this.css.clip.bottom||this.c[2]||this.h||0;
|
|
|
285 |
this.cl=this.css.clip.left||this.c[3]||0
|
|
|
286 |
this.obj = obj + "Object"; eval(this.obj + "=this")
|
|
|
287 |
return this
|
|
|
288 |
}
|
|
|
289 |
|
|
|
290 |
//Moving object to **************
|
|
|
291 |
lib_obj.prototype.moveIt = function(x,y){
|
|
|
292 |
this.x=x;this.y=y; this.css.left=x;this.css.top=y
|
|
|
293 |
}
|
|
|
294 |
|
|
|
295 |
//Moving object by ***************
|
|
|
296 |
lib_obj.prototype.moveBy = function(x,y){
|
|
|
297 |
this.css.left=this.x+=x; this.css.top=this.y+=y
|
|
|
298 |
}
|
|
|
299 |
|
|
|
300 |
//Showing object ************
|
|
|
301 |
lib_obj.prototype.showIt = function(){this.css.visibility="visible"}
|
|
|
302 |
|
|
|
303 |
//Hiding object **********
|
|
|
304 |
lib_obj.prototype.hideIt = function(){this.css.visibility="hidden"}
|
|
|
305 |
|
|
|
306 |
//Changing backgroundcolor ***************
|
|
|
307 |
lib_obj.prototype.bg = function(color){
|
|
|
308 |
if(bw.opera) this.css.background=color
|
|
|
309 |
else if(bw.dom || bw.ie4) this.css.backgroundColor=color
|
|
|
310 |
else if(bw.ns4) this.css.bgColor=color
|
|
|
311 |
}
|
|
|
312 |
|
|
|
313 |
//Writing content to object ***
|
|
|
314 |
lib_obj.prototype.writeIt = function(text,startHTML,endHTML){
|
|
|
315 |
if(bw.ns4){
|
|
|
316 |
if(!startHTML){startHTML=""; endHTML=""}
|
|
|
317 |
this.ref.open("text/html");
|
|
|
318 |
this.ref.write(startHTML+text+endHTML);
|
|
|
319 |
this.ref.close()
|
|
|
320 |
}else this.evnt.innerHTML=text
|
|
|
321 |
}
|
|
|
322 |
|
|
|
323 |
//Clipping object to ******
|
|
|
324 |
lib_obj.prototype.clipTo = function(t,r,b,l,setwidth){
|
|
|
325 |
this.ct=t; this.cr=r; this.cb=b; this.cl=l
|
|
|
326 |
if(bw.ns4){
|
|
|
327 |
this.css.clip.top=t;this.css.clip.right=r
|
|
|
328 |
this.css.clip.bottom=b;this.css.clip.left=l
|
|
|
329 |
}else{
|
|
|
330 |
if(t<0)t=0;if(r<0)r=0;if(b<0)b=0;if(b<0)b=0
|
|
|
331 |
this.css.clip="rect("+t+","+r+","+b+","+l+")";
|
|
|
332 |
if(setwidth){this.css.pixelWidth=this.css.width=r;
|
|
|
333 |
this.css.pixelHeight=this.css.height=b}
|
|
|
334 |
}
|
|
|
335 |
}
|
|
|
336 |
|
|
|
337 |
//Clipping object by ******
|
|
|
338 |
lib_obj.prototype.clipBy = function(t,r,b,l,setwidth){
|
|
|
339 |
this.clipTo(this.ct+t,this.cr+r,this.cb+b,this.cl+l,setwidth)
|
|
|
340 |
}
|
|
|
341 |
|
|
|
342 |
//Clip animation ************
|
|
|
343 |
lib_obj.prototype.clipIt = function(t,r,b,l,step,fn,wh){
|
|
|
344 |
tstep=Math.max(Math.max(Math.abs((t-this.ct)/step),Math.abs((r-this.cr)/step)),
|
|
|
345 |
Math.max(Math.abs((b-this.cb)/step),Math.abs((l-this.cl)/step)))
|
|
|
346 |
if(!this.clipactive){
|
|
|
347 |
this.clipactive=true; if(!wh) wh=0; if(!fn) fn=0
|
|
|
348 |
this.clip(t,r,b,l,(t-this.ct)/tstep,(r-this.cr)/tstep,
|
|
|
349 |
(b-this.cb)/tstep,(l-this.cl)/tstep,tstep,0, fn,wh)
|
|
|
350 |
}
|
|
|
351 |
}
|
|
|
352 |
lib_obj.prototype.clip = function(t,r,b,l,ts,rs,bs,ls,tstep,astep,fn,wh){
|
|
|
353 |
if(astep<tstep){
|
|
|
354 |
if(wh) eval(wh);
|
|
|
355 |
astep++
|
|
|
356 |
this.clipBy(ts,rs,bs,ls,1);
|
|
|
357 |
setTimeout(this.obj+".clip("+t+","+r+","+b+","+l+","+ts+","+rs+","
|
|
|
358 |
+bs+","+ls+","+tstep+","+astep+",'"+fn+"','"+wh+"')",50)
|
|
|
359 |
}else{
|
|
|
360 |
this.clipactive=false; this.clipTo(t,r,b,l,1);
|
|
|
361 |
if(fn) eval(fn)
|
|
|
362 |
}
|
|
|
363 |
}
|
|
|
364 |
|
|
|
365 |
//Slide animation ***********
|
|
|
366 |
lib_obj.prototype.slideIt = function(endx,endy,inc,speed,fn,wh){
|
|
|
367 |
if(!this.slideactive){
|
|
|
368 |
var distx = endx - this.x;
|
|
|
369 |
var disty = endy - this.y
|
|
|
370 |
var num = Math.sqrt(Math.pow(distx,2)+Math.pow(disty,2))/inc
|
|
|
371 |
var dx = distx/num; var dy = disty/num
|
|
|
372 |
this.slideactive = 1;
|
|
|
373 |
if(!wh) wh=0; if(!fn) fn=0
|
|
|
374 |
this.slide(dx,dy,endx,endy,speed,fn,wh)
|
|
|
375 |
}
|
|
|
376 |
}
|
|
|
377 |
lib_obj.prototype.slide = function(dx,dy,endx,endy,speed,fn,wh) {
|
|
|
378 |
if(this.slideactive&&
|
|
|
379 |
(Math.floor(Math.abs(dx))<Math.floor(Math.abs(endx-this.x))||
|
|
|
380 |
Math.floor(Math.abs(dy))<Math.floor(Math.abs(endy-this.y)))){
|
|
|
381 |
this.moveBy(dx,dy);
|
|
|
382 |
if(wh) eval(wh)
|
|
|
383 |
setTimeout(this.obj+".slide("+dx+","+dy+","+endx+","+endy+","+speed+",'"
|
|
|
384 |
+fn+"','"+wh+"')",speed)
|
|
|
385 |
}else{
|
|
|
386 |
this.slideactive = 0;
|
|
|
387 |
this.moveIt(endx,endy);
|
|
|
388 |
if(fn) eval(fn)
|
|
|
389 |
}
|
|
|
390 |
}
|
|
|
391 |
|
|
|
392 |
//Circle animation ****************
|
|
|
393 |
lib_obj.prototype.circleIt = function(rad,ainc,a,enda,xc,yc,speed,fn) {
|
|
|
394 |
if((Math.abs(ainc)<Math.abs(enda-a))) {
|
|
|
395 |
a += ainc
|
|
|
396 |
var x = xc + rad*Math.cos(a*Math.PI/180)
|
|
|
397 |
var y = yc - rad*Math.sin(a*Math.PI/180)
|
|
|
398 |
this.moveIt(x,y)
|
|
|
399 |
setTimeout(this.obj+".circleIt("+rad+","+ainc+","+a+","+enda+","
|
|
|
400 |
+xc+","+yc+","+speed+",'"+fn+"')",speed)
|
|
|
401 |
}else if(fn&&fn!="undefined") eval(fn)
|
|
|
402 |
}
|
|
|
403 |
|
|
|
404 |
//Document size object ********
|
|
|
405 |
function lib_doc_size(){
|
|
|
406 |
this.x=0;this.x2=bw.ie && document.body.offsetWidth-20||innerWidth||0;
|
|
|
407 |
this.y=0;this.y2=bw.ie && document.body.offsetHeight-5||innerHeight||0;
|
|
|
408 |
if(!this.x2||!this.y2) return message('Document has no width or height')
|
|
|
409 |
this.x50=this.x2/2;this.y50=this.y2/2;
|
|
|
410 |
return this;
|
|
|
411 |
}
|
|
|
412 |
|
|
|
413 |
//Drag drop functions start *******************
|
|
|
414 |
dd_is_active=0; dd_obj=0; dd_mobj=0
|
|
|
415 |
function lib_dd(){
|
|
|
416 |
dd_is_active=1
|
|
|
417 |
if(bw.ns4){
|
|
|
418 |
document.captureEvents(Event.MOUSEMOVE|Event.MOUSEDOWN|Event.MOUSEUP)
|
|
|
419 |
}
|
|
|
420 |
document.onmousemove=lib_dd_move;
|
|
|
421 |
document.onmousedown=lib_dd_down
|
|
|
422 |
document.onmouseup=lib_dd_up
|
|
|
423 |
}
|
|
|
424 |
lib_obj.prototype.dragdrop = function(obj){
|
|
|
425 |
if(!dd_is_active) lib_dd()
|
|
|
426 |
this.evnt.onmouseover=new Function("lib_dd_over("+this.obj+")")
|
|
|
427 |
this.evnt.onmouseout=new Function("dd_mobj=0")
|
|
|
428 |
if(obj) this.ddobj=obj
|
|
|
429 |
}
|
|
|
430 |
lib_obj.prototype.nodragdrop = function(){
|
|
|
431 |
this.evnt.onmouseover=""; this.evnt.onmouseout=""
|
|
|
432 |
dd_obj=0; dd_mobj=0
|
|
|
433 |
}
|
|
|
434 |
//Drag drop event functions
|
|
|
435 |
function lib_dd_over(obj){dd_mobj=obj}
|
|
|
436 |
function lib_dd_up(e){dd_obj=0}
|
|
|
437 |
|
|
|
438 |
var MouseX = 0;
|
|
|
439 |
var MouseY = 0;
|
|
|
440 |
|
|
|
441 |
function lib_dd_down(e){ //Mousedown
|
|
|
442 |
|
|
|
443 |
if(dd_mobj){
|
|
|
444 |
x=(bw.ns4 || bw.ns6)?e.pageX:event.x||event.clientX
|
|
|
445 |
y=(bw.ns4 || bw.ns6)?e.pageY:event.y||event.clientY
|
|
|
446 |
dd_obj=dd_mobj
|
|
|
447 |
dd_obj.clX=x-dd_obj.x
|
|
|
448 |
dd_obj.clY=y-dd_obj.y
|
|
|
449 |
}
|
|
|
450 |
|
|
|
451 |
}
|
|
|
452 |
function lib_dd_move(e,y,rresize){ //Mousemove
|
|
|
453 |
x=(bw.ns4 || bw.ns6)?e.pageX:event.x||event.clientX
|
|
|
454 |
y=(bw.ns4 || bw.ns6)?e.pageY:event.y||event.clientY
|
|
|
455 |
if(dd_obj){
|
|
|
456 |
nx=x-dd_obj.clX; ny=y-dd_obj.clY
|
|
|
457 |
if(dd_obj.ddobj) dd_obj.ddobj.moveIt(nx,ny)
|
|
|
458 |
else dd_obj.moveIt(nx,ny)
|
|
|
459 |
}
|
|
|
460 |
if(!bw.ns4) return false
|
|
|
461 |
}
|
|
|
462 |
//Drag drop functions end *************
|
|
|
463 |
|
|
|
464 |
// page functions
|
|
|
465 |
function resetClip(){
|
|
|
466 |
newleft = (screen.width - <?php echo $imgObj->width?>)/2;
|
|
|
467 |
if (newleft<0)newleft = 0;
|
|
|
468 |
objimg.moveIt(newleft,100);
|
|
|
469 |
objimg.clipTo(0,<?php echo $imgObj->width?>,<?php echo $imgObj->height?>,0,1);
|
|
|
470 |
objlefttop.moveIt(newleft-2,97);
|
|
|
471 |
objrightbottom.moveIt(newleft+<?php echo $imgObj->width?>-23,100+<?php echo $imgObj->height?>-23);
|
|
|
472 |
document.mainform.clipval.value = "";
|
|
|
473 |
}
|
|
|
474 |
function libinit(){
|
|
|
475 |
page=new lib_doc_size();
|
|
|
476 |
|
|
|
477 |
objlefttop=new lib_obj('lefttopdiv');
|
|
|
478 |
objlefttop.dragdrop();
|
|
|
479 |
|
|
|
480 |
objrightbottom=new lib_obj('rightbottomdiv');
|
|
|
481 |
objrightbottom.dragdrop();
|
|
|
482 |
|
|
|
483 |
objimg=new lib_obj('imgdiv');
|
|
|
484 |
|
|
|
485 |
resetClip();
|
|
|
486 |
}
|
|
|
487 |
|
|
|
488 |
function showPreview(){
|
|
|
489 |
if (objlefttop.y < objimg.y+2 ){
|
|
|
490 |
objlefttop.y = objimg.y+2 ;
|
|
|
491 |
objlefttop.moveIt(objlefttop.x, objimg.y);
|
|
|
492 |
}
|
|
|
493 |
if (objlefttop.x < objimg.x ){
|
|
|
494 |
objlefttop.x = objimg.x ;
|
|
|
495 |
objlefttop.moveIt(objimg.x, objlefttop.y );
|
|
|
496 |
}
|
|
|
497 |
|
|
|
498 |
objimg.clipTo(objlefttop.y-objimg.y+2, objrightbottom.x-objimg.x+23 , objrightbottom.y-objimg.y+23, objlefttop.x-objimg.x+2,1);
|
|
|
499 |
document.mainform.clipval.value = objimg.ct + ',' + objimg.cr + ',' + objimg.cb + ',' + objimg.cl;
|
|
|
500 |
}
|
|
|
501 |
|
|
|
502 |
function showCorners(check){
|
|
|
503 |
if (check.checked){
|
|
|
504 |
objlefttop.showIt();
|
|
|
505 |
objrightbottom.showIt();
|
|
|
506 |
}else{
|
|
|
507 |
objlefttop.hideIt();
|
|
|
508 |
objrightbottom.hideIt();
|
|
|
509 |
resetClip();
|
|
|
510 |
}
|
|
|
511 |
}
|
|
|
512 |
|
|
|
513 |
</script>
|
|
|
514 |
<?php }?>
|
|
|
515 |
<style>
|
|
|
516 |
#lefttopdiv{
|
|
|
517 |
position:absolute;
|
|
|
518 |
background-image:url(<?php echo $PHP_SELF?>?img=left);
|
|
|
519 |
left:0px;
|
|
|
520 |
top:100px;
|
|
|
521 |
height:25px;
|
|
|
522 |
width:25px;
|
|
|
523 |
z-index:8;
|
|
|
524 |
cursor:move;
|
|
|
525 |
visibility:hidden;
|
|
|
526 |
}
|
|
|
527 |
#rightbottomdiv{
|
|
|
528 |
position:absolute;
|
|
|
529 |
background-image:url(<?php echo $PHP_SELF?>?img=right);
|
|
|
530 |
left:0px;
|
|
|
531 |
top:225px;
|
|
|
532 |
height:25px;
|
|
|
533 |
width:25px;
|
|
|
534 |
z-index:9;
|
|
|
535 |
cursor:move;
|
|
|
536 |
visibility:hidden;
|
|
|
537 |
}
|
|
|
538 |
#imgdiv{
|
|
|
539 |
position:absolute;
|
|
|
540 |
top:100px;
|
|
|
541 |
width:<?php echo $imgObj->width?>px;
|
|
|
542 |
height:<?php echo $imgObj->height?>px;
|
|
|
543 |
text-align:center;
|
|
|
544 |
margin-left:auto;
|
|
|
545 |
margin-right:auto;
|
|
|
546 |
z-index:0;
|
|
|
547 |
<?php if (!$imgObj->imgRes) print "visibility:hidden;\n";?>
|
|
|
548 |
}
|
|
|
549 |
</style>
|
|
|
550 |
<link rel="stylesheet" href="themes/<?php echo $CONFIG['theme'];?>/style.css" />
|
|
|
551 |
</head>
|
|
|
552 |
|
|
|
553 |
<body <?php if ($imgObj) print "onload=\"libinit()\"";?>>
|
|
|
554 |
|
|
|
555 |
<form name="mainform" method="POST" enctype="multipart/form-data" action="picEditor.php">
|
|
|
556 |
|
|
|
557 |
<input type="hidden" name="clipval" value="">
|
|
|
558 |
<input type="hidden" name="newimage" value="<?php print $newimage ; ?>">
|
|
|
559 |
<input type="hidden" name="img_dir" value="<?php print $img_dir ; ?>">
|
|
|
560 |
<input type="hidden" name="id" value="<?php print (isset($_GET['id']))?$_GET['id']:$_POST['id']; ?>">
|
|
|
561 |
|
|
|
562 |
<? starttable("100%", $lang_editpics_php['crop_title'], 3); ?>
|
|
|
563 |
<tr>
|
|
|
564 |
<td>
|
|
|
565 |
<table border="0" cellspacing="2" cellpadding="2" class="maintableb" width="100%" >
|
|
|
566 |
<tr>
|
|
|
567 |
<?php if ($CONFIG['thumb_method']='im' ||($CONFIG['thumb_method']='gd2' && function_exists("imagerotate"))){ ?>
|
|
|
568 |
|
|
|
569 |
|
|
|
570 |
<td>
|
|
|
571 |
<select name="angle" class="listbox">
|
|
|
572 |
<option value="0" selected>Rotate
|
|
|
573 |
<option value="90">-90°
|
|
|
574 |
<option value="180">180°
|
|
|
575 |
<option value="270">+90°
|
|
|
576 |
</select>
|
|
|
577 |
</td>
|
|
|
578 |
<!--
|
|
|
579 |
<td >
|
|
|
580 |
<input valign="bottom" type="checkbox" class="checkbox" name="mirror" value="true">
|
|
|
581 |
Mirror
|
|
|
582 |
</td>
|
|
|
583 |
|
|
|
584 |
|
|
|
585 |
<?php } ?>
|
|
|
586 |
|
|
|
587 |
<td>
|
|
|
588 |
<select name="rescale" class="listbox">
|
|
|
589 |
<option value="">Scale
|
|
|
590 |
<option value="0.1">10%<option value="0.11">11%<option value="0.12">12%<option value="0.13">13%<option value="0.14">14%<option value="0.15">15%<option value="0.16">16%<option value="0.17">17%<option value="0.18">18%<option value="0.19">19%<option value="0.2">20%<option value="0.21">21%<option value="0.22">22%<option value="0.23">23%<option value="0.24">24%<option value="0.25">25%<option value="0.26">26%<option value="0.27">27%<option value="0.28">28%<option value="0.29">29%<option value="0.3">30%<option value="0.31">31%<option value="0.32">32%<option value="0.33">33%<option value="0.34">34%<option value="0.35">35%<option value="0.36">36%<option value="0.37">37%<option value="0.38">38%<option value="0.39">39%<option value="0.4">40%<option value="0.41">41%<option value="0.42">42%<option value="0.43">43%<option value="0.44">44%<option value="0.45">45%<option value="0.46">46%<option value="0.47">47%<option value="0.48">48%<option value="0.49">49%<option value="0.5">50%<option value="0.51">51%<option value="0.52">52%<option value="0.53">53%<option value="0.54">54%<option value="0.55">55%<option value="0.56">56%<option value="0.57">57%<option value="0.58">58%<option value="0.59">59%<option value="0.6">60%<option value="0.61">61%<option value="0.62">62%<option value="0.63">63%<option value="0.64">64%<option value="0.65">65%<option value="0.66">66%<option value="0.67">67%<option value="0.68">68%<option value="0.69">69%<option value="0.7">70%<option value="0.71">71%<option value="0.72">72%<option value="0.73">73%<option value="0.74">74%<option value="0.75">75%<option value="0.76">76%<option value="0.77">77%<option value="0.78">78%<option value="0.79">79%<option value="0.8">80%<option value="0.81">81%<option value="0.82">82%<option value="0.83">83%<option value="0.84">84%<option value="0.85">85%<option value="0.86">86%<option value="0.87">87%<option value="0.88">88%<option value="0.89">89%<option value="0.9">90%<option value="0.91">91%<option value="0.92">92%<option value="0.93">93%<option value="0.94">94%<option value="0.95">95%<option value="0.96">96%<option value="0.97">97%<option value="0.98">98%<option value="0.99">99%<option value="1">100%<option value="1.01">101%<option value="1.02">102%<option value="1.03">103%<option value="1.04">104%<option value="1.05">105%<option value="1.06">106%<option value="1.07">107%<option value="1.08">108%<option value="1.09">109%<option value="1.1">110%<option value="1.11">111%<option value="1.12">112%<option value="1.13">113%<option value="1.14">114%<option value="1.15">115%<option value="1.16">116%<option value="1.17">117%<option value="1.18">118%<option value="1.19">119%<option value="1.2">120%<option value="1.21">121%<option value="1.22">122%<option value="1.23">123%<option value="1.24">124%<option value="1.25">125%<option value="1.26">126%<option value="1.27">127%<option value="1.28">128%<option value="1.29">129%<option value="1.3">130%<option value="1.31">131%<option value="1.32">132%<option value="1.33">133%<option value="1.34">134%<option value="1.35">135%<option value="1.36">136%<option value="1.37">137%<option value="1.38">138%<option value="1.39">139%<option value="1.4">140%<option value="1.41">141%<option value="1.42">142%<option value="1.43">143%<option value="1.44">144%<option value="1.45">145%<option value="1.46">146%<option value="1.47">147%<option value="1.48">148%<option value="1.49">149%<option value="1.5">150%<option value="1.51">151%<option value="1.52">152%<option value="1.53">153%<option value="1.54">154%<option value="1.55">155%<option value="1.56">156%<option value="1.57">157%<option value="1.58">158%<option value="1.59">159%<option value="1.6">160%<option value="1.61">161%<option value="1.62">162%<option value="1.63">163%<option value="1.64">164%<option value="1.65">165%<option value="1.66">166%<option value="1.67">167%<option value="1.68">168%<option value="1.69">169%<option value="1.7">170%<option value="1.71">171%<option value="1.72">172%<option value="1.73">173%<option value="1.74">174%<option value="1.75">175%<option value="1.76">176%<option value="1.77">177%<option value="1.78">178%<option value="1.79">179%<option value="1.8">180%<option value="1.81">181%<option value="1.82">182%<option value="1.83">183%<option value="1.84">184%<option value="1.85">185%<option value="1.86">186%<option value="1.87">187%<option value="1.88">188%<option value="1.89">189%<option value="1.9">190%<option value="1.91">191%<option value="1.92">192%<option value="1.93">193%<option value="1.94">194%<option value="1.95">195%<option value="1.96">196%<option value="1.97">197%<option value="1.98">198%<option value="1.99">199%<option value="2">200%</option>
|
|
|
591 |
</select>
|
|
|
592 |
</td>
|
|
|
593 |
<td>
|
|
|
594 |
OR
|
|
|
595 |
</td>
|
|
|
596 |
<td>
|
|
|
597 |
<select name="widthheight" class="listbox" >
|
|
|
598 |
<option value="width">New width
|
|
|
599 |
<option value="height">New height
|
|
|
600 |
</option>
|
|
|
601 |
</select>
|
|
|
602 |
</td>
|
|
|
603 |
<td>
|
|
|
604 |
<input type="text" size="3" name="newsize" class="textinput"> px
|
|
|
605 |
</td>
|
|
|
606 |
-->
|
|
|
607 |
|
|
|
608 |
|
|
|
609 |
|
|
|
610 |
<td>
|
|
|
611 |
<input type="checkbox" class="checkbox" name="cropping" value="true" onclick="showCorners(this)">
|
|
|
612 |
Enable clipping, apply to crop
|
|
|
613 |
</td>
|
|
|
614 |
<td title="Less quality creates a smaller file, default is 80%" >
|
|
|
615 |
<select id="quality" name="quality" class="listbox" >
|
|
|
616 |
<option value="80" selected>JPEG Output Quality
|
|
|
617 |
<option value="10">10<option value="11">11<option value="12">12<option value="13">13<option value="14">14<option value="15">15<option value="16">16<option value="17">17<option value="18">18<option value="19">19<option value="20">20<option value="21">21<option value="22">22<option value="23">23<option value="24">24<option value="25">25<option value="26">26<option value="27">27<option value="28">28<option value="29">29<option value="30">30<option value="31">31<option value="32">32<option value="33">33<option value="34">34<option value="35">35<option value="36">36<option value="37">37<option value="38">38<option value="39">39<option value="40">40<option value="41">41<option value="42">42<option value="43">43<option value="44">44<option value="45">45<option value="46">46<option value="47">47<option value="48">48<option value="49">49<option value="50">50<option value="51">51<option value="52">52<option value="53">53<option value="54">54<option value="55">55<option value="56">56<option value="57">57<option value="58">58<option value="59">59<option value="60">60<option value="61">61<option value="62">62<option value="63">63<option value="64">64<option value="65">65<option value="66">66<option value="67">67<option value="68">68<option value="69">69<option value="70">70<option value="71">71<option value="72">72<option value="73">73<option value="74">74<option value="75">75<option value="76">76<option value="77">77<option value="78">78<option value="79">79<option value="80">80<option value="81">81<option value="82">82<option value="83">83<option value="84">84<option value="85">85<option value="86">86<option value="87">87<option value="88">88<option value="89">89<option value="90">90<option value="91">91<option value="92">92<option value="93">93<option value="94">94<option value="95">95<option value="96">96<option value="97">97<option value="98">98<option value="99">99<option value="100">100</option>
|
|
|
618 |
|
|
|
619 |
</select>
|
|
|
620 |
</td>
|
|
|
621 |
<td><input type="submit" name="submit" class="button" value=" <?php echo $lang_editpics_php['preview'] ?> "></td>
|
|
|
622 |
<td><input type="submit" name="save" class="button" value=" <?php echo $lang_editpics_php['save'] ?> "></td>
|
|
|
623 |
<td><input type="submit" name="save_thumb" class="button" value=" <?php echo $lang_editpics_php['save_thumb'] ?> "></td>
|
|
|
624 |
</tr>
|
|
|
625 |
</table>
|
|
|
626 |
</td>
|
|
|
627 |
</tr>
|
|
|
628 |
<?php endtable(); ?>
|
|
|
629 |
|
|
|
630 |
<div id="lefttopdiv" onclick="showPreview(); return false;">
|
|
|
631 |
</div>
|
|
|
632 |
|
|
|
633 |
<div id="rightbottomdiv" onclick="showPreview(); return false;">
|
|
|
634 |
</div>
|
|
|
635 |
|
|
|
636 |
<?php if ($message){ ?>
|
|
|
637 |
<h1 align=center><?php echo $message?></h1>
|
|
|
638 |
<?php } ?>
|
|
|
639 |
|
|
|
640 |
<div id="imgdiv">
|
|
|
641 |
<?php if ($imgObj){ ?>
|
|
|
642 |
<IMG src="<?php echo $imgObj->directory.$imgObj->filename?>?<?php echo rand(); ?>" <?php echo $imgObj->string; ?> align="absmiddle">
|
|
|
643 |
<?php } ?>
|
|
|
644 |
</div>
|
|
|
645 |
|
|
|
646 |
</body>
|
|
|
647 |
</html>
|