@@ -12,7 +12,8 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class gd { |
|
15 | +class gd |
|
16 | +{ |
|
16 | 17 | |
17 | 18 | /** GD resource |
18 | 19 | * @var resource */ |
@@ -40,23 +41,24 @@ discard block |
||
40 | 41 | * @param mixed $image |
41 | 42 | * @return array */ |
42 | 43 | |
43 | - protected function build_image($image) { |
|
44 | + protected function build_image($image) |
|
45 | + { |
|
44 | 46 | |
45 | - if ($image instanceof gd) { |
|
47 | + if ($image instanceof gd) { |
|
46 | 48 | $width = $image->get_width(); |
47 | 49 | $height = $image->get_height(); |
48 | 50 | $image = $image->get_image(); |
49 | 51 | |
50 | - } elseif (is_resource($image) && (get_resource_type($image) == "gd")) { |
|
52 | + } elseif (is_resource($image) && (get_resource_type($image) == "gd")) { |
|
51 | 53 | $width = @imagesx($image); |
52 | 54 | $height = @imagesy($image); |
53 | 55 | |
54 | - } elseif (is_array($image)) { |
|
56 | + } elseif (is_array($image)) { |
|
55 | 57 | list($key, $width) = each($image); |
56 | 58 | list($key, $height) = each($image); |
57 | 59 | $image = imagecreatetruecolor($width, $height); |
58 | 60 | |
59 | - } elseif (false !== (list($width, $height, $type) = @getimagesize($image))) { |
|
61 | + } elseif (false !== (list($width, $height, $type) = @getimagesize($image))) { |
|
60 | 62 | $image = |
61 | 63 | ($type == IMAGETYPE_GIF) ? @imagecreatefromgif($image) : ( |
62 | 64 | ($type == IMAGETYPE_WBMP) ? @imagecreatefromwbmp($image) : ( |
@@ -66,8 +68,9 @@ discard block |
||
66 | 68 | ($type == IMAGETYPE_XBM) ? @imagecreatefromxbm($image) : false |
67 | 69 | ))))); |
68 | 70 | |
69 | - if ($type == IMAGETYPE_PNG) |
|
70 | - imagealphablending($image, false); |
|
71 | + if ($type == IMAGETYPE_PNG) { |
|
72 | + imagealphablending($image, false); |
|
73 | + } |
|
71 | 74 | } |
72 | 75 | |
73 | 76 | $return = ( |
@@ -81,8 +84,9 @@ discard block |
||
81 | 84 | ? array($image, $width, $height) |
82 | 85 | : false; |
83 | 86 | |
84 | - if (($return !== false) && isset($type)) |
|
85 | - $this->type = $type; |
|
87 | + if (($return !== false) && isset($type)) { |
|
88 | + $this->type = $type; |
|
89 | + } |
|
86 | 90 | |
87 | 91 | return $return; |
88 | 92 | } |
@@ -98,20 +102,22 @@ discard block |
||
98 | 102 | * @param integer $bigger_size |
99 | 103 | * @return gd */ |
100 | 104 | |
101 | - public function __construct($image, $bigger_size=null) { |
|
105 | + public function __construct($image, $bigger_size=null) |
|
106 | + { |
|
102 | 107 | $this->image = $this->width = $this->height = null; |
103 | 108 | |
104 | 109 | $image_details = $this->build_image($image); |
105 | 110 | |
106 | - if ($image_details !== false) |
|
107 | - list($this->image, $this->width, $this->height) = $image_details; |
|
108 | - else |
|
109 | - $this->init_error = true; |
|
111 | + if ($image_details !== false) { |
|
112 | + list($this->image, $this->width, $this->height) = $image_details; |
|
113 | + } else { |
|
114 | + $this->init_error = true; |
|
115 | + } |
|
110 | 116 | |
111 | 117 | if (!is_null($this->image) && |
112 | 118 | !is_null($bigger_size) && |
113 | 119 | (preg_match('/^[1-9][0-9]*$/', $bigger_size) !== false) |
114 | - ) { |
|
120 | + ) { |
|
115 | 121 | $image = $this->image; |
116 | 122 | list($width, $height) = $this->get_prop_size($bigger_size); |
117 | 123 | $this->image = imagecreatetruecolor($width, $height); |
@@ -126,21 +132,24 @@ discard block |
||
126 | 132 | /** Returns the GD resource |
127 | 133 | * @return resource */ |
128 | 134 | |
129 | - public function get_image() { |
|
135 | + public function get_image() |
|
136 | + { |
|
130 | 137 | return $this->image; |
131 | 138 | } |
132 | 139 | |
133 | 140 | /** Returns the image width |
134 | 141 | * @return integer */ |
135 | 142 | |
136 | - public function get_width() { |
|
143 | + public function get_width() |
|
144 | + { |
|
137 | 145 | return $this->width; |
138 | 146 | } |
139 | 147 | |
140 | 148 | /** Returns the image height |
141 | 149 | * @return integer */ |
142 | 150 | |
143 | - public function get_height() { |
|
151 | + public function get_height() |
|
152 | + { |
|
144 | 153 | return $this->height; |
145 | 154 | } |
146 | 155 | |
@@ -148,9 +157,12 @@ discard block |
||
148 | 157 | * @param integer $resized_height |
149 | 158 | * @return integer */ |
150 | 159 | |
151 | - public function get_prop_width($resized_height) { |
|
160 | + public function get_prop_width($resized_height) |
|
161 | + { |
|
152 | 162 | $width = intval(($this->width * $resized_height) / $this->height); |
153 | - if (!$width) $width = 1; |
|
163 | + if (!$width) { |
|
164 | + $width = 1; |
|
165 | + } |
|
154 | 166 | return $width; |
155 | 167 | } |
156 | 168 | |
@@ -158,9 +170,12 @@ discard block |
||
158 | 170 | * @param integer $resized_width |
159 | 171 | * @return integer */ |
160 | 172 | |
161 | - public function get_prop_height($resized_width) { |
|
173 | + public function get_prop_height($resized_width) |
|
174 | + { |
|
162 | 175 | $height = intval(($this->height * $resized_width) / $this->width); |
163 | - if (!$height) $height = 1; |
|
176 | + if (!$height) { |
|
177 | + $height = 1; |
|
178 | + } |
|
164 | 179 | return $height; |
165 | 180 | } |
166 | 181 | |
@@ -170,18 +185,20 @@ discard block |
||
170 | 185 | * @param integer $bigger_size |
171 | 186 | * @return array */ |
172 | 187 | |
173 | - public function get_prop_size($bigger_size) { |
|
188 | + public function get_prop_size($bigger_size) |
|
189 | + { |
|
174 | 190 | |
175 | - if ($this->width > $this->height) { |
|
191 | + if ($this->width > $this->height) { |
|
176 | 192 | $width = $bigger_size; |
177 | 193 | $height = $this->get_prop_height($width); |
178 | 194 | |
179 | - } elseif ($this->height > $this->width) { |
|
195 | + } elseif ($this->height > $this->width) { |
|
180 | 196 | $height = $bigger_size; |
181 | 197 | $width = $this->get_prop_width($height); |
182 | 198 | |
183 | - } else |
|
184 | - $width = $height = $bigger_size; |
|
199 | + } else { |
|
200 | + $width = $height = $bigger_size; |
|
201 | + } |
|
185 | 202 | |
186 | 203 | return array($width, $height); |
187 | 204 | } |
@@ -191,9 +208,14 @@ discard block |
||
191 | 208 | * @param integer $height |
192 | 209 | * @return bool */ |
193 | 210 | |
194 | - public function resize($width, $height) { |
|
195 | - if (!$width) $width = 1; |
|
196 | - if (!$height) $height = 1; |
|
211 | + public function resize($width, $height) |
|
212 | + { |
|
213 | + if (!$width) { |
|
214 | + $width = 1; |
|
215 | + } |
|
216 | + if (!$height) { |
|
217 | + $height = 1; |
|
218 | + } |
|
197 | 219 | return ( |
198 | 220 | (false !== ($img = new gd(array($width, $height)))) && |
199 | 221 | $img->imagecopyresampled($this) && |
@@ -208,19 +230,20 @@ discard block |
||
208 | 230 | * @param mixed $src |
209 | 231 | * @return bool */ |
210 | 232 | |
211 | - public function resize_crop($src) { |
|
233 | + public function resize_crop($src) |
|
234 | + { |
|
212 | 235 | $image_details = $this->build_image($src); |
213 | 236 | |
214 | - if ($image_details !== false) { |
|
237 | + if ($image_details !== false) { |
|
215 | 238 | list($src, $src_width, $src_height) = $image_details; |
216 | 239 | |
217 | - if (($src_width / $src_height) > ($this->width / $this->height)) { |
|
240 | + if (($src_width / $src_height) > ($this->width / $this->height)) { |
|
218 | 241 | $src_w = $this->get_prop_width($src_height); |
219 | 242 | $src_h = $src_height; |
220 | 243 | $src_x = intval(($src_width - $src_w) / 2); |
221 | 244 | $src_y = 0; |
222 | 245 | |
223 | - } else { |
|
246 | + } else { |
|
224 | 247 | $src_w = $src_width; |
225 | 248 | $src_h = $this->get_prop_height($src_width); |
226 | 249 | $src_x = 0; |
@@ -229,8 +252,9 @@ discard block |
||
229 | 252 | |
230 | 253 | return imagecopyresampled($this->image, $src, 0, 0, $src_x, $src_y, $this->width, $this->height, $src_w, $src_h); |
231 | 254 | |
232 | - } else |
|
233 | - return false; |
|
255 | + } else { |
|
256 | + return false; |
|
257 | + } |
|
234 | 258 | } |
235 | 259 | |
236 | 260 | /** Resize image to fit in given resolution. Returns TRUE on success or FALSE on failure |
@@ -238,15 +262,22 @@ discard block |
||
238 | 262 | * @param integer $height |
239 | 263 | * @return bool */ |
240 | 264 | |
241 | - public function resize_fit($width, $height) { |
|
242 | - if ((!$width && !$height) || (($width == $this->width) && ($height == $this->height))) |
|
243 | - return true; |
|
244 | - if (!$width || (($height / $width) < ($this->height / $this->width))) |
|
245 | - $width = intval(($this->width * $height) / $this->height); |
|
246 | - elseif (!$height || (($width / $height) < ($this->width / $this->height))) |
|
247 | - $height = intval(($this->height * $width) / $this->width); |
|
248 | - if (!$width) $width = 1; |
|
249 | - if (!$height) $height = 1; |
|
265 | + public function resize_fit($width, $height) |
|
266 | + { |
|
267 | + if ((!$width && !$height) || (($width == $this->width) && ($height == $this->height))) { |
|
268 | + return true; |
|
269 | + } |
|
270 | + if (!$width || (($height / $width) < ($this->height / $this->width))) { |
|
271 | + $width = intval(($this->width * $height) / $this->height); |
|
272 | + } elseif (!$height || (($width / $height) < ($this->width / $this->height))) { |
|
273 | + $height = intval(($this->height * $width) / $this->width); |
|
274 | + } |
|
275 | + if (!$width) { |
|
276 | + $width = 1; |
|
277 | + } |
|
278 | + if (!$height) { |
|
279 | + $height = 1; |
|
280 | + } |
|
250 | 281 | return $this->resize($width, $height); |
251 | 282 | } |
252 | 283 | |
@@ -257,7 +288,8 @@ discard block |
||
257 | 288 | * @param integer $height |
258 | 289 | * @return bool */ |
259 | 290 | |
260 | - public function resize_overflow($width, $height) { |
|
291 | + public function resize_overflow($width, $height) |
|
292 | + { |
|
261 | 293 | |
262 | 294 | $big = (($this->width / $this->height) > ($width / $height)) |
263 | 295 | ? ($this->width * $height) / $this->height |
@@ -266,7 +298,7 @@ discard block |
||
266 | 298 | |
267 | 299 | $return = ($img = new gd($this->image, $big)); |
268 | 300 | |
269 | - if ($return) { |
|
301 | + if ($return) { |
|
270 | 302 | $this->image = $img->get_image(); |
271 | 303 | $this->width = $img->get_width(); |
272 | 304 | $this->height = $img->get_height(); |
@@ -275,7 +307,8 @@ discard block |
||
275 | 307 | return $return; |
276 | 308 | } |
277 | 309 | |
278 | - public function gd_color() { |
|
310 | + public function gd_color() |
|
311 | + { |
|
279 | 312 | $args = func_get_args(); |
280 | 313 | |
281 | 314 | $expr_rgb = '/^rgb\(\s*(\d{1,3})\s*\,\s*(\d{1,3})\s*\,\s*(\d{1,3})\s*\)$/i'; |
@@ -283,22 +316,23 @@ discard block |
||
283 | 316 | $expr_hex2 = '/^\#?([0-9a-f])([0-9a-f])([0-9a-f])$/i'; |
284 | 317 | $expr_byte = '/^([01]?\d?\d|2[0-4]\d|25[0-5])$/'; |
285 | 318 | |
286 | - if (!isset($args[0])) |
|
287 | - return false; |
|
319 | + if (!isset($args[0])) { |
|
320 | + return false; |
|
321 | + } |
|
288 | 322 | |
289 | - if (count($args[0]) == 3) { |
|
323 | + if (count($args[0]) == 3) { |
|
290 | 324 | list($r, $g, $b) = $args[0]; |
291 | 325 | |
292 | - } elseif (preg_match($expr_rgb, $args[0])) { |
|
326 | + } elseif (preg_match($expr_rgb, $args[0])) { |
|
293 | 327 | list($r, $g, $b) = explode(" ", preg_replace($expr_rgb, "$1 $2 $3", $args[0])); |
294 | 328 | |
295 | - } elseif (preg_match($expr_hex1, $args[0])) { |
|
329 | + } elseif (preg_match($expr_hex1, $args[0])) { |
|
296 | 330 | list($r, $g, $b) = explode(" ", preg_replace($expr_hex1, "$1 $2 $3", $args[0])); |
297 | 331 | $r = hexdec($r); |
298 | 332 | $g = hexdec($g); |
299 | 333 | $b = hexdec($b); |
300 | 334 | |
301 | - } elseif (preg_match($expr_hex2, $args[0])) { |
|
335 | + } elseif (preg_match($expr_hex2, $args[0])) { |
|
302 | 336 | list($r, $g, $b) = explode(" ", preg_replace($expr_hex2, "$1$1 $2$2 $3$3", $args[0])); |
303 | 337 | $r = hexdec($r); |
304 | 338 | $g = hexdec($g); |
@@ -308,16 +342,18 @@ discard block |
||
308 | 342 | preg_match($expr_byte, $args[0]) && |
309 | 343 | preg_match($expr_byte, $args[1]) && |
310 | 344 | preg_match($expr_byte, $args[2]) |
311 | - ) { |
|
345 | + ) { |
|
312 | 346 | list($r, $g, $b) = $args; |
313 | 347 | |
314 | - } else |
|
315 | - return false; |
|
348 | + } else { |
|
349 | + return false; |
|
350 | + } |
|
316 | 351 | |
317 | 352 | return imagecolorallocate($this->image, $r, $g, $b); |
318 | 353 | } |
319 | 354 | |
320 | - public function fill_color($color) { |
|
355 | + public function fill_color($color) |
|
356 | + { |
|
321 | 357 | return $this->imagefilledrectangle(0, 0, $this->width - 1, $this->height - 1, $color); |
322 | 358 | } |
323 | 359 | |
@@ -330,20 +366,29 @@ discard block |
||
330 | 366 | $src_x=0, $src_y=0, |
331 | 367 | $dst_w=null, $dst_h=null, |
332 | 368 | $src_w=null, $src_h=null |
333 | - ) { |
|
369 | + ) { |
|
334 | 370 | $image_details = $this->build_image($src); |
335 | 371 | |
336 | - if ($image_details !== false) { |
|
372 | + if ($image_details !== false) { |
|
337 | 373 | list($src, $src_width, $src_height) = $image_details; |
338 | 374 | |
339 | - if (is_null($dst_w)) $dst_w = $this->width - $dst_x; |
|
340 | - if (is_null($dst_h)) $dst_h = $this->height - $dst_y; |
|
341 | - if (is_null($src_w)) $src_w = $src_width - $src_x; |
|
342 | - if (is_null($src_h)) $src_h = $src_height - $src_y; |
|
375 | + if (is_null($dst_w)) { |
|
376 | + $dst_w = $this->width - $dst_x; |
|
377 | + } |
|
378 | + if (is_null($dst_h)) { |
|
379 | + $dst_h = $this->height - $dst_y; |
|
380 | + } |
|
381 | + if (is_null($src_w)) { |
|
382 | + $src_w = $src_width - $src_x; |
|
383 | + } |
|
384 | + if (is_null($src_h)) { |
|
385 | + $src_h = $src_height - $src_y; |
|
386 | + } |
|
343 | 387 | return imagecopy($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h); |
344 | 388 | |
345 | - } else |
|
346 | - return false; |
|
389 | + } else { |
|
390 | + return false; |
|
391 | + } |
|
347 | 392 | } |
348 | 393 | |
349 | 394 | public function imagecopyresampled( |
@@ -352,16 +397,24 @@ discard block |
||
352 | 397 | $src_x=0, $src_y=0, |
353 | 398 | $dst_w=null, $dst_h=null, |
354 | 399 | $src_w=null, $src_h=null |
355 | - ) { |
|
400 | + ) { |
|
356 | 401 | $image_details = $this->build_image($src); |
357 | 402 | |
358 | - if ($image_details !== false) { |
|
403 | + if ($image_details !== false) { |
|
359 | 404 | list($src, $src_width, $src_height) = $image_details; |
360 | 405 | |
361 | - if (is_null($dst_w)) $dst_w = $this->width - $dst_x; |
|
362 | - if (is_null($dst_h)) $dst_h = $this->height - $dst_y; |
|
363 | - if (is_null($src_w)) $src_w = $src_width - $src_x; |
|
364 | - if (is_null($src_h)) $src_h = $src_height - $src_y; |
|
406 | + if (is_null($dst_w)) { |
|
407 | + $dst_w = $this->width - $dst_x; |
|
408 | + } |
|
409 | + if (is_null($dst_h)) { |
|
410 | + $dst_h = $this->height - $dst_y; |
|
411 | + } |
|
412 | + if (is_null($src_w)) { |
|
413 | + $src_w = $src_width - $src_x; |
|
414 | + } |
|
415 | + if (is_null($src_h)) { |
|
416 | + $src_h = $src_height - $src_y; |
|
417 | + } |
|
365 | 418 | imagealphablending($this->image, false); |
366 | 419 | imagesavealpha($this->image,true); |
367 | 420 | |
@@ -372,7 +425,7 @@ discard block |
||
372 | 425 | |
373 | 426 | $transindex = imagecolortransparent($src); |
374 | 427 | $palletsize = imagecolorstotal($src); |
375 | - if($transindex >= 0 && $transindex < $palletsize) { |
|
428 | + if($transindex >= 0 && $transindex < $palletsize) { |
|
376 | 429 | $transcol = imagecolorsforindex($src, $transindex); |
377 | 430 | |
378 | 431 | /*** end gif transparent fix ***/ |
@@ -381,44 +434,56 @@ discard block |
||
381 | 434 | imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transindex); |
382 | 435 | imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); |
383 | 436 | imagecolortransparent($this->image, $transindex); |
384 | - for($y=0; $y<$dst_h; ++$y) |
|
385 | - for($x=0; $x<$dst_w; ++$x) |
|
386 | - if(((imagecolorat($this->image, $x, $y)>>24) & 0x7F) >= 100) imagesetpixel($this->image, $x, $y, $transindex); |
|
437 | + for($y=0; $y<$dst_h; ++$y) { |
|
438 | + for($x=0; |
|
439 | + } |
|
440 | + $x<$dst_w; ++$x) { |
|
441 | + if(((imagecolorat($this->image, $x, $y)>>24) & 0x7F) >= 100) imagesetpixel($this->image, $x, $y, $transindex); |
|
442 | + } |
|
387 | 443 | imagetruecolortopalette($this->image, true, 255); |
388 | - } |
|
389 | - else { |
|
444 | + } else { |
|
390 | 445 | $transparent = imagecolorallocatealpha($this->image, 255, 255, 255, 127); |
391 | 446 | imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transparent); |
392 | 447 | imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); |
393 | 448 | } |
394 | 449 | return $this->image; |
395 | 450 | |
396 | - } else |
|
397 | - return false; |
|
451 | + } else { |
|
452 | + return false; |
|
453 | + } |
|
398 | 454 | } |
399 | 455 | |
400 | - public function imagefilledrectangle($x1, $y1, $x2, $y2, $color) { |
|
456 | + public function imagefilledrectangle($x1, $y1, $x2, $y2, $color) |
|
457 | + { |
|
401 | 458 | $color = $this->gd_color($color); |
402 | - if ($color === false) return false; |
|
459 | + if ($color === false) { |
|
460 | + return false; |
|
461 | + } |
|
403 | 462 | return imagefilledrectangle($this->image, $x1, $y1, $x2, $y2, $color); |
404 | 463 | } |
405 | 464 | |
406 | - public function imagepng($filename=null, $quality=null, $filters=null) { |
|
407 | - if (is_null($filename) && !headers_sent()) |
|
408 | - header("Content-Type: image/png"); |
|
465 | + public function imagepng($filename=null, $quality=null, $filters=null) |
|
466 | + { |
|
467 | + if (is_null($filename) && !headers_sent()) { |
|
468 | + header("Content-Type: image/png"); |
|
469 | + } |
|
409 | 470 | @imagesavealpha($this->image, true); |
410 | 471 | return imagepng($this->image, $filename, $quality, $filters); |
411 | 472 | } |
412 | 473 | |
413 | - public function imagejpeg($filename=null, $quality=75) { |
|
414 | - if (is_null($filename) && !headers_sent()) |
|
415 | - header("Content-Type: image/jpeg"); |
|
474 | + public function imagejpeg($filename=null, $quality=75) |
|
475 | + { |
|
476 | + if (is_null($filename) && !headers_sent()) { |
|
477 | + header("Content-Type: image/jpeg"); |
|
478 | + } |
|
416 | 479 | return imagejpeg($this->image, $filename, $quality); |
417 | 480 | } |
418 | 481 | |
419 | - public function imagegif($filename=null) { |
|
420 | - if (is_null($filename) && !headers_sent()) |
|
421 | - header("Content-Type: image/gif"); |
|
482 | + public function imagegif($filename=null) |
|
483 | + { |
|
484 | + if (is_null($filename) && !headers_sent()) { |
|
485 | + header("Content-Type: image/gif"); |
|
486 | + } |
|
422 | 487 | @imagesavealpha($this->image, true); |
423 | 488 | return imagegif($this->image, $filename); |
424 | 489 | } |
@@ -23,11 +23,13 @@ |
||
23 | 23 | |
24 | 24 | foreach ($files as $file) { |
25 | 25 | $fmtime = filemtime($file); |
26 | - if (!isset($mtime) || ($fmtime > $mtime)) |
|
27 | - $mtime = $fmtime; |
|
28 | -} |
|
26 | + if (!isset($mtime) || ($fmtime > $mtime)) { |
|
27 | + $mtime = $fmtime; |
|
28 | + } |
|
29 | + } |
|
29 | 30 | |
30 | 31 | httpCache::checkMTime($mtime); |
31 | 32 | header("Content-Type: text/javascript"); |
32 | -foreach ($files as $file) |
|
33 | +foreach ($files as $file) { |
|
33 | 34 | require $file; |
35 | +} |
@@ -37,15 +37,18 @@ discard block |
||
37 | 37 | "sv" => "svenska" |
38 | 38 | ); |
39 | 39 | $_langISO6391 = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2); |
40 | -if (!empty($_langFiles[$_langISO6391])) $install_language = $_langFiles[$_langISO6391]; |
|
40 | +if (!empty($_langFiles[$_langISO6391])) { |
|
41 | + $install_language = $_langFiles[$_langISO6391]; |
|
42 | +} |
|
41 | 43 | |
42 | 44 | |
43 | 45 | if (isset($_POST['language']) && !stristr($_POST['language'],"..")) { |
44 | 46 | $install_language = $_POST['language']; |
45 | 47 | } else { |
46 | - if (isset($_GET['language']) && !stristr($_GET['language'],"..")) |
|
47 | - $install_language = $_GET['language']; |
|
48 | -} |
|
48 | + if (isset($_GET['language']) && !stristr($_GET['language'],"..")) { |
|
49 | + $install_language = $_GET['language']; |
|
50 | + } |
|
51 | + } |
|
49 | 52 | # load language file |
50 | 53 | require_once("lang/english.inc.php"); // As fallback |
51 | 54 | require_once("lang/".$install_language.".inc.php"); |
@@ -55,12 +58,13 @@ discard block |
||
55 | 58 | if (isset($_POST['managerlanguage']) && !stristr($_POST['managerlanguage'],"..")) { |
56 | 59 | $manager_language = $_POST['managerlanguage']; |
57 | 60 | } else { |
58 | - if (isset($_GET['managerlanguage']) && !stristr($_GET['managerlanguage'],"..")) |
|
59 | - $manager_language = $_GET['managerlanguage']; |
|
60 | -} |
|
61 | + if (isset($_GET['managerlanguage']) && !stristr($_GET['managerlanguage'],"..")) { |
|
62 | + $manager_language = $_GET['managerlanguage']; |
|
63 | + } |
|
64 | + } |
|
61 | 65 | |
62 | -foreach($_lang as $k=>$v) |
|
63 | -{ |
|
64 | - if(strpos($v,'[+MGR_DIR+]')!==false) |
|
65 | - $_lang[$k] = str_replace('[+MGR_DIR+]', MGR_DIR, $v); |
|
66 | -} |
|
66 | +foreach($_lang as $k=>$v) { |
|
67 | + if(strpos($v,'[+MGR_DIR+]')!==false) { |
|
68 | + $_lang[$k] = str_replace('[+MGR_DIR+]', MGR_DIR, $v); |
|
69 | + } |
|
70 | + } |
@@ -189,16 +189,18 @@ discard block |
||
189 | 189 | } |
190 | 190 | } |
191 | 191 | |
192 | -switch($installMode){ |
|
192 | +switch($installMode) { |
|
193 | 193 | case 0: |
194 | 194 | case 2: |
195 | 195 | $database_collation = isset($_POST['database_collation']) ? $_POST['database_collation'] : 'utf8_general_ci'; |
196 | 196 | $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
197 | 197 | $_POST['database_connection_charset'] = $database_charset; |
198 | - if(empty($_SESSION['databaseloginpassword'])) |
|
199 | - $_SESSION['databaseloginpassword'] = $_POST['databaseloginpassword']; |
|
200 | - if(empty($_SESSION['databaseloginname'])) |
|
201 | - $_SESSION['databaseloginname'] = $_POST['databaseloginname']; |
|
198 | + if(empty($_SESSION['databaseloginpassword'])) { |
|
199 | + $_SESSION['databaseloginpassword'] = $_POST['databaseloginpassword']; |
|
200 | + } |
|
201 | + if(empty($_SESSION['databaseloginname'])) { |
|
202 | + $_SESSION['databaseloginname'] = $_POST['databaseloginname']; |
|
203 | + } |
|
202 | 204 | break; |
203 | 205 | case 1: |
204 | 206 | include $base_path . MGR_DIR . '/includes/config.inc.php'; |
@@ -212,7 +214,9 @@ discard block |
||
212 | 214 | } |
213 | 215 | } |
214 | 216 | } |
215 | - if (empty ($database_collation)) $database_collation = 'utf8_general_ci'; |
|
217 | + if (empty ($database_collation)) { |
|
218 | + $database_collation = 'utf8_general_ci'; |
|
219 | + } |
|
216 | 220 | |
217 | 221 | $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
218 | 222 | if (!isset ($database_connection_charset) || empty ($database_connection_charset)) { |
@@ -221,7 +225,9 @@ discard block |
||
221 | 225 | |
222 | 226 | if (!isset ($database_connection_method) || empty ($database_connection_method)) { |
223 | 227 | $database_connection_method = 'SET CHARACTER SET'; |
224 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_connection_charset); |
|
228 | + if (function_exists('mysqli_set_charset')) { |
|
229 | + mysqli_set_charset($conn, $database_connection_charset); |
|
230 | + } |
|
225 | 231 | } |
226 | 232 | if ($database_connection_method != 'SET NAMES' && $database_connection_charset != $database_charset) { |
227 | 233 | $database_connection_method = 'SET NAMES'; |
@@ -4,7 +4,9 @@ discard block |
||
4 | 4 | if (is_file($base_path . 'assets/cache/siteManager.php')) { |
5 | 5 | include_once($base_path . 'assets/cache/siteManager.php'); |
6 | 6 | } |
7 | -if(!defined('MGR_DIR')) define('MGR_DIR', 'manager'); |
|
7 | +if(!defined('MGR_DIR')) { |
|
8 | + define('MGR_DIR', 'manager'); |
|
9 | +} |
|
8 | 10 | |
9 | 11 | require_once('../'.MGR_DIR.'/includes/version.inc.php'); |
10 | 12 | |
@@ -19,12 +21,12 @@ discard block |
||
19 | 21 | $mt = &$moduleTemplates; |
20 | 22 | if(is_dir($templatePath) && is_readable($templatePath)) { |
21 | 23 | $d = dir($templatePath); |
22 | - while (false !== ($tplfile = $d->read())) |
|
23 | - { |
|
24 | - if(substr($tplfile, -4) != '.tpl') continue; |
|
24 | + while (false !== ($tplfile = $d->read())) { |
|
25 | + if(substr($tplfile, -4) != '.tpl') { |
|
26 | + continue; |
|
27 | + } |
|
25 | 28 | $params = parse_docblock($templatePath, $tplfile); |
26 | - if(is_array($params) && (count($params)>0)) |
|
27 | - { |
|
29 | + if(is_array($params) && (count($params)>0)) { |
|
28 | 30 | $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}"; |
29 | 31 | $mt[] = array |
30 | 32 | ( |
@@ -48,7 +50,9 @@ discard block |
||
48 | 50 | if(is_dir($tvPath) && is_readable($tvPath)) { |
49 | 51 | $d = dir($tvPath); |
50 | 52 | while (false !== ($tplfile = $d->read())) { |
51 | - if(substr($tplfile, -4) != '.tpl') continue; |
|
53 | + if(substr($tplfile, -4) != '.tpl') { |
|
54 | + continue; |
|
55 | + } |
|
52 | 56 | $params = parse_docblock($tvPath, $tplfile); |
53 | 57 | if(is_array($params) && (count($params)>0)) { |
54 | 58 | $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}"; |
@@ -241,7 +245,8 @@ discard block |
||
241 | 245 | // setup callback function |
242 | 246 | $callBackFnc = "clean_up"; |
243 | 247 | |
244 | -function clean_up($sqlParser) { |
|
248 | +function clean_up($sqlParser) |
|
249 | +{ |
|
245 | 250 | $ids = array(); |
246 | 251 | |
247 | 252 | // secure web documents - privateweb |
@@ -254,9 +259,10 @@ discard block |
||
254 | 259 | $ds = mysqli_query($sqlParser->conn,$sql); |
255 | 260 | if(!$ds) { |
256 | 261 | echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn); |
257 | - } |
|
258 | - else { |
|
259 | - while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"]; |
|
262 | + } else { |
|
263 | + while($r = mysqli_fetch_assoc($ds)) { |
|
264 | + $ids[]=$r["id"]; |
|
265 | + } |
|
260 | 266 | if(count($ids)>0) { |
261 | 267 | mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 1 WHERE id IN (".implode(", ",$ids).")"); |
262 | 268 | unset($ids); |
@@ -273,9 +279,10 @@ discard block |
||
273 | 279 | $ds = mysqli_query($sqlParser->conn,$sql); |
274 | 280 | if(!$ds) { |
275 | 281 | echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn); |
276 | - } |
|
277 | - else { |
|
278 | - while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"]; |
|
282 | + } else { |
|
283 | + while($r = mysqli_fetch_assoc($ds)) { |
|
284 | + $ids[]=$r["id"]; |
|
285 | + } |
|
279 | 286 | if(count($ids)>0) { |
280 | 287 | mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 1 WHERE id IN (".implode(", ",$ids).")"); |
281 | 288 | unset($ids); |
@@ -283,7 +290,8 @@ discard block |
||
283 | 290 | } |
284 | 291 | } |
285 | 292 | |
286 | -function parse_docblock($element_dir, $filename) { |
|
293 | +function parse_docblock($element_dir, $filename) |
|
294 | +{ |
|
287 | 295 | $params = array(); |
288 | 296 | $fullpath = $element_dir . '/' . $filename; |
289 | 297 | if(is_readable($fullpath)) { |
@@ -12,7 +12,8 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class image_imagick extends image { |
|
15 | +class image_imagick extends image |
|
16 | +{ |
|
16 | 17 | |
17 | 18 | static $MIMES = array( |
18 | 19 | //'tif' => "image/tiff" |
@@ -21,9 +22,15 @@ discard block |
||
21 | 22 | |
22 | 23 | // ABSTRACT PUBLIC METHODS |
23 | 24 | |
24 | - public function resize($width, $height) {// |
|
25 | - if (!$width) $width = 1; |
|
26 | - if (!$height) $height = 1; |
|
25 | + public function resize($width, $height) |
|
26 | + { |
|
27 | +// |
|
28 | + if (!$width) { |
|
29 | + $width = 1; |
|
30 | + } |
|
31 | + if (!$height) { |
|
32 | + $height = 1; |
|
33 | + } |
|
27 | 34 | try { |
28 | 35 | $this->image->scaleImage($width, $height); |
29 | 36 | } catch (Exception $e) { |
@@ -34,9 +41,15 @@ discard block |
||
34 | 41 | return true; |
35 | 42 | } |
36 | 43 | |
37 | - public function resizeFit($width, $height, $background=false) {// |
|
38 | - if (!$width) $width = 1; |
|
39 | - if (!$height) $height = 1; |
|
44 | + public function resizeFit($width, $height, $background=false) |
|
45 | + { |
|
46 | +// |
|
47 | + if (!$width) { |
|
48 | + $width = 1; |
|
49 | + } |
|
50 | + if (!$height) { |
|
51 | + $height = 1; |
|
52 | + } |
|
40 | 53 | |
41 | 54 | try { |
42 | 55 | $this->image->scaleImage($width, $height, true); |
@@ -65,43 +78,58 @@ discard block |
||
65 | 78 | } |
66 | 79 | } |
67 | 80 | |
68 | - public function resizeCrop($width, $height, $offset=false) { |
|
69 | - if (!$width) $width = 1; |
|
70 | - if (!$height) $height = 1; |
|
81 | + public function resizeCrop($width, $height, $offset=false) |
|
82 | + { |
|
83 | + if (!$width) { |
|
84 | + $width = 1; |
|
85 | + } |
|
86 | + if (!$height) { |
|
87 | + $height = 1; |
|
88 | + } |
|
71 | 89 | |
72 | 90 | if (($this->width / $this->height) > ($width / $height)) { |
73 | 91 | $h = $height; |
74 | 92 | $w = ($this->width * $h) / $this->height; |
75 | 93 | $y = 0; |
76 | 94 | if ($offset !== false) { |
77 | - if ($offset > 0) |
|
78 | - $offset = -$offset; |
|
79 | - if (($w + $offset) <= $width) |
|
80 | - $offset = $width - $w; |
|
95 | + if ($offset > 0) { |
|
96 | + $offset = -$offset; |
|
97 | + } |
|
98 | + if (($w + $offset) <= $width) { |
|
99 | + $offset = $width - $w; |
|
100 | + } |
|
81 | 101 | $x = $offset; |
82 | - } else |
|
83 | - $x = ($width - $w) / 2; |
|
102 | + } else { |
|
103 | + $x = ($width - $w) / 2; |
|
104 | + } |
|
84 | 105 | |
85 | 106 | } else { |
86 | 107 | $w = $width; |
87 | 108 | $h = ($this->height * $w) / $this->width; |
88 | 109 | $x = 0; |
89 | 110 | if ($offset !== false) { |
90 | - if ($offset > 0) |
|
91 | - $offset = -$offset; |
|
92 | - if (($h + $offset) <= $height) |
|
93 | - $offset = $height - $h; |
|
111 | + if ($offset > 0) { |
|
112 | + $offset = -$offset; |
|
113 | + } |
|
114 | + if (($h + $offset) <= $height) { |
|
115 | + $offset = $height - $h; |
|
116 | + } |
|
94 | 117 | $y = $offset; |
95 | - } else |
|
96 | - $y = ($height - $h) / 2; |
|
118 | + } else { |
|
119 | + $y = ($height - $h) / 2; |
|
120 | + } |
|
97 | 121 | } |
98 | 122 | |
99 | 123 | $x = round($x); |
100 | 124 | $y = round($y); |
101 | 125 | $w = round($w); |
102 | 126 | $h = round($h); |
103 | - if (!$w) $w = 1; |
|
104 | - if (!$h) $h = 1; |
|
127 | + if (!$w) { |
|
128 | + $w = 1; |
|
129 | + } |
|
130 | + if (!$h) { |
|
131 | + $h = 1; |
|
132 | + } |
|
105 | 133 | |
106 | 134 | try { |
107 | 135 | $this->image->scaleImage($w, $h); |
@@ -115,7 +143,8 @@ discard block |
||
115 | 143 | return true; |
116 | 144 | } |
117 | 145 | |
118 | - public function rotate($angle, $background="#000000") { |
|
146 | + public function rotate($angle, $background="#000000") |
|
147 | + { |
|
119 | 148 | try { |
120 | 149 | $this->image->rotateImage(new ImagickPixel($background), $angle); |
121 | 150 | $size = $this->image->getImageGeometry(); |
@@ -127,7 +156,8 @@ discard block |
||
127 | 156 | return true; |
128 | 157 | } |
129 | 158 | |
130 | - public function flipHorizontal() { |
|
159 | + public function flipHorizontal() |
|
160 | + { |
|
131 | 161 | try { |
132 | 162 | $this->image->flopImage(); |
133 | 163 | } catch (Exception $e) { |
@@ -136,7 +166,8 @@ discard block |
||
136 | 166 | return true; |
137 | 167 | } |
138 | 168 | |
139 | - public function flipVertical() { |
|
169 | + public function flipVertical() |
|
170 | + { |
|
140 | 171 | try { |
141 | 172 | $this->image->flipImage(); |
142 | 173 | } catch (Exception $e) { |
@@ -145,7 +176,8 @@ discard block |
||
145 | 176 | return true; |
146 | 177 | } |
147 | 178 | |
148 | - public function watermark($file, $left=false, $top=false) { |
|
179 | + public function watermark($file, $left=false, $top=false) |
|
180 | + { |
|
149 | 181 | try { |
150 | 182 | $wm = new Imagick($file); |
151 | 183 | $size = $wm->getImageGeometry(); |
@@ -167,8 +199,9 @@ discard block |
||
167 | 199 | if ((($x + $w) > $this->width) || |
168 | 200 | (($y + $h) > $this->height) || |
169 | 201 | ($x < 0) || ($y < 0) |
170 | - ) |
|
171 | - return false; |
|
202 | + ) { |
|
203 | + return false; |
|
204 | + } |
|
172 | 205 | |
173 | 206 | try { |
174 | 207 | $this->image->compositeImage($wm, Imagick::COMPOSITE_DEFAULT, $x, $y); |
@@ -181,7 +214,8 @@ discard block |
||
181 | 214 | |
182 | 215 | // ABSTRACT PROTECTED METHODS |
183 | 216 | |
184 | - protected function getBlankImage($width, $height) { |
|
217 | + protected function getBlankImage($width, $height) |
|
218 | + { |
|
185 | 219 | try { |
186 | 220 | $img = new Imagick(); |
187 | 221 | $img->newImage($width, $height, "none"); |
@@ -192,7 +226,8 @@ discard block |
||
192 | 226 | return $img; |
193 | 227 | } |
194 | 228 | |
195 | - protected function getImage($image, &$width, &$height) { |
|
229 | + protected function getImage($image, &$width, &$height) |
|
230 | + { |
|
196 | 231 | |
197 | 232 | if (is_object($image) && ($image instanceof image_imagick)) { |
198 | 233 | try { |
@@ -227,18 +262,21 @@ discard block |
||
227 | 262 | $height = $size['height']; |
228 | 263 | return $image; |
229 | 264 | |
230 | - } else |
|
231 | - return false; |
|
265 | + } else { |
|
266 | + return false; |
|
267 | + } |
|
232 | 268 | } |
233 | 269 | |
234 | 270 | |
235 | 271 | // PSEUDO-ABSTRACT STATIC METHODS |
236 | 272 | |
237 | - static function available() { |
|
273 | + static function available() |
|
274 | + { |
|
238 | 275 | return class_exists("Imagick"); |
239 | 276 | } |
240 | 277 | |
241 | - static function checkImage($file) { |
|
278 | + static function checkImage($file) |
|
279 | + { |
|
242 | 280 | try { |
243 | 281 | new Imagick($file); |
244 | 282 | } catch (Exception $e) { |
@@ -250,7 +288,8 @@ discard block |
||
250 | 288 | |
251 | 289 | // INHERIT METHODS |
252 | 290 | |
253 | - public function output($type="jpeg", array $options=array()) { |
|
291 | + public function output($type="jpeg", array $options=array()) |
|
292 | + { |
|
254 | 293 | $type = strtolower($type); |
255 | 294 | try { |
256 | 295 | $this->image->setImageFormat($type); |
@@ -258,8 +297,9 @@ discard block |
||
258 | 297 | return false; |
259 | 298 | } |
260 | 299 | $method = "optimize_$type"; |
261 | - if (method_exists($this, $method) && !$this->$method($options)) |
|
262 | - return false; |
|
300 | + if (method_exists($this, $method) && !$this->$method($options)) { |
|
301 | + return false; |
|
302 | + } |
|
263 | 303 | |
264 | 304 | if (!isset($options['file'])) { |
265 | 305 | if (!headers_sent()) { |
@@ -289,7 +329,8 @@ discard block |
||
289 | 329 | |
290 | 330 | // OWN METHODS |
291 | 331 | |
292 | - protected function optimize_jpeg(array $options=array()) { |
|
332 | + protected function optimize_jpeg(array $options=array()) |
|
333 | + { |
|
293 | 334 | $quality = isset($options['quality']) ? $options['quality'] : self::DEFAULT_JPEG_QUALITY; |
294 | 335 | try { |
295 | 336 | $this->image->setImageCompression(Imagick::COMPRESSION_JPEG); |
@@ -12,7 +12,8 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class image_gmagick extends image { |
|
15 | +class image_gmagick extends image |
|
16 | +{ |
|
16 | 17 | |
17 | 18 | static $MIMES = array( |
18 | 19 | //'tif' => "image/tiff" |
@@ -21,9 +22,15 @@ discard block |
||
21 | 22 | |
22 | 23 | // ABSTRACT PUBLIC METHODS |
23 | 24 | |
24 | - public function resize($width, $height) {// |
|
25 | - if (!$width) $width = 1; |
|
26 | - if (!$height) $height = 1; |
|
25 | + public function resize($width, $height) |
|
26 | + { |
|
27 | +// |
|
28 | + if (!$width) { |
|
29 | + $width = 1; |
|
30 | + } |
|
31 | + if (!$height) { |
|
32 | + $height = 1; |
|
33 | + } |
|
27 | 34 | try { |
28 | 35 | $this->image->scaleImage($width, $height); |
29 | 36 | } catch (Exception $e) { |
@@ -34,9 +41,15 @@ discard block |
||
34 | 41 | return true; |
35 | 42 | } |
36 | 43 | |
37 | - public function resizeFit($width, $height, $background=false) {// |
|
38 | - if (!$width) $width = 1; |
|
39 | - if (!$height) $height = 1; |
|
44 | + public function resizeFit($width, $height, $background=false) |
|
45 | + { |
|
46 | +// |
|
47 | + if (!$width) { |
|
48 | + $width = 1; |
|
49 | + } |
|
50 | + if (!$height) { |
|
51 | + $height = 1; |
|
52 | + } |
|
40 | 53 | |
41 | 54 | try { |
42 | 55 | $this->image->scaleImage($width, $height, true); |
@@ -69,43 +82,58 @@ discard block |
||
69 | 82 | } |
70 | 83 | } |
71 | 84 | |
72 | - public function resizeCrop($width, $height, $offset=false) { |
|
73 | - if (!$width) $width = 1; |
|
74 | - if (!$height) $height = 1; |
|
85 | + public function resizeCrop($width, $height, $offset=false) |
|
86 | + { |
|
87 | + if (!$width) { |
|
88 | + $width = 1; |
|
89 | + } |
|
90 | + if (!$height) { |
|
91 | + $height = 1; |
|
92 | + } |
|
75 | 93 | |
76 | 94 | if (($this->width / $this->height) > ($width / $height)) { |
77 | 95 | $h = $height; |
78 | 96 | $w = ($this->width * $h) / $this->height; |
79 | 97 | $y = 0; |
80 | 98 | if ($offset !== false) { |
81 | - if ($offset > 0) |
|
82 | - $offset = -$offset; |
|
83 | - if (($w + $offset) <= $width) |
|
84 | - $offset = $width - $w; |
|
99 | + if ($offset > 0) { |
|
100 | + $offset = -$offset; |
|
101 | + } |
|
102 | + if (($w + $offset) <= $width) { |
|
103 | + $offset = $width - $w; |
|
104 | + } |
|
85 | 105 | $x = $offset; |
86 | - } else |
|
87 | - $x = ($width - $w) / 2; |
|
106 | + } else { |
|
107 | + $x = ($width - $w) / 2; |
|
108 | + } |
|
88 | 109 | |
89 | 110 | } else { |
90 | 111 | $w = $width; |
91 | 112 | $h = ($this->height * $w) / $this->width; |
92 | 113 | $x = 0; |
93 | 114 | if ($offset !== false) { |
94 | - if ($offset > 0) |
|
95 | - $offset = -$offset; |
|
96 | - if (($h + $offset) <= $height) |
|
97 | - $offset = $height - $h; |
|
115 | + if ($offset > 0) { |
|
116 | + $offset = -$offset; |
|
117 | + } |
|
118 | + if (($h + $offset) <= $height) { |
|
119 | + $offset = $height - $h; |
|
120 | + } |
|
98 | 121 | $y = $offset; |
99 | - } else |
|
100 | - $y = ($height - $h) / 2; |
|
122 | + } else { |
|
123 | + $y = ($height - $h) / 2; |
|
124 | + } |
|
101 | 125 | } |
102 | 126 | |
103 | 127 | $x = round($x); |
104 | 128 | $y = round($y); |
105 | 129 | $w = round($w); |
106 | 130 | $h = round($h); |
107 | - if (!$w) $w = 1; |
|
108 | - if (!$h) $h = 1; |
|
131 | + if (!$w) { |
|
132 | + $w = 1; |
|
133 | + } |
|
134 | + if (!$h) { |
|
135 | + $h = 1; |
|
136 | + } |
|
109 | 137 | |
110 | 138 | try { |
111 | 139 | $this->image->scaleImage($w, $h); |
@@ -119,7 +147,8 @@ discard block |
||
119 | 147 | return true; |
120 | 148 | } |
121 | 149 | |
122 | - public function rotate($angle, $background="#000000") { |
|
150 | + public function rotate($angle, $background="#000000") |
|
151 | + { |
|
123 | 152 | try { |
124 | 153 | $this->image->rotateImage($background, $angle); |
125 | 154 | $w = $this->image->getImageWidth(); |
@@ -132,7 +161,8 @@ discard block |
||
132 | 161 | return true; |
133 | 162 | } |
134 | 163 | |
135 | - public function flipHorizontal() { |
|
164 | + public function flipHorizontal() |
|
165 | + { |
|
136 | 166 | try { |
137 | 167 | $this->image->flopImage(); |
138 | 168 | } catch (Exception $e) { |
@@ -141,7 +171,8 @@ discard block |
||
141 | 171 | return true; |
142 | 172 | } |
143 | 173 | |
144 | - public function flipVertical() { |
|
174 | + public function flipVertical() |
|
175 | + { |
|
145 | 176 | try { |
146 | 177 | $this->image->flipImage(); |
147 | 178 | } catch (Exception $e) { |
@@ -150,7 +181,8 @@ discard block |
||
150 | 181 | return true; |
151 | 182 | } |
152 | 183 | |
153 | - public function watermark($file, $left=false, $top=false) { |
|
184 | + public function watermark($file, $left=false, $top=false) |
|
185 | + { |
|
154 | 186 | try { |
155 | 187 | $wm = new Gmagick($file); |
156 | 188 | $w = $wm->getImageWidth(); |
@@ -171,8 +203,9 @@ discard block |
||
171 | 203 | if ((($x + $w) > $this->width) || |
172 | 204 | (($y + $h) > $this->height) || |
173 | 205 | ($x < 0) || ($y < 0) |
174 | - ) |
|
175 | - return false; |
|
206 | + ) { |
|
207 | + return false; |
|
208 | + } |
|
176 | 209 | |
177 | 210 | try { |
178 | 211 | $this->image->compositeImage($wm, 1, $x, $y); |
@@ -185,7 +218,8 @@ discard block |
||
185 | 218 | |
186 | 219 | // ABSTRACT PROTECTED METHODS |
187 | 220 | |
188 | - protected function getBlankImage($width, $height) { |
|
221 | + protected function getBlankImage($width, $height) |
|
222 | + { |
|
189 | 223 | try { |
190 | 224 | $img = new Gmagick(); |
191 | 225 | $img->newImage($width, $height, "none"); |
@@ -195,7 +229,8 @@ discard block |
||
195 | 229 | return $img; |
196 | 230 | } |
197 | 231 | |
198 | - protected function getImage($image, &$width, &$height) { |
|
232 | + protected function getImage($image, &$width, &$height) |
|
233 | + { |
|
199 | 234 | |
200 | 235 | if (is_object($image) && ($image instanceof image_gmagick)) { |
201 | 236 | $width = $image->width; |
@@ -225,18 +260,21 @@ discard block |
||
225 | 260 | $height = $h; |
226 | 261 | return $image; |
227 | 262 | |
228 | - } else |
|
229 | - return false; |
|
263 | + } else { |
|
264 | + return false; |
|
265 | + } |
|
230 | 266 | } |
231 | 267 | |
232 | 268 | |
233 | 269 | // PSEUDO-ABSTRACT STATIC METHODS |
234 | 270 | |
235 | - static function available() { |
|
271 | + static function available() |
|
272 | + { |
|
236 | 273 | return class_exists("Gmagick"); |
237 | 274 | } |
238 | 275 | |
239 | - static function checkImage($file) { |
|
276 | + static function checkImage($file) |
|
277 | + { |
|
240 | 278 | try { |
241 | 279 | new Gmagick($file); |
242 | 280 | } catch (Exception $e) { |
@@ -248,7 +286,8 @@ discard block |
||
248 | 286 | |
249 | 287 | // INHERIT METHODS |
250 | 288 | |
251 | - public function output($type="jpeg", array $options=array()) { |
|
289 | + public function output($type="jpeg", array $options=array()) |
|
290 | + { |
|
252 | 291 | $type = strtolower($type); |
253 | 292 | try { |
254 | 293 | $this->image->setImageFormat($type); |
@@ -256,8 +295,9 @@ discard block |
||
256 | 295 | return false; |
257 | 296 | } |
258 | 297 | $method = "optimize_$type"; |
259 | - if (method_exists($this, $method) && !$this->$method($options)) |
|
260 | - return false; |
|
298 | + if (method_exists($this, $method) && !$this->$method($options)) { |
|
299 | + return false; |
|
300 | + } |
|
261 | 301 | |
262 | 302 | if (!isset($options['file'])) { |
263 | 303 | if (!headers_sent()) { |
@@ -287,7 +327,8 @@ discard block |
||
287 | 327 | |
288 | 328 | // OWN METHODS |
289 | 329 | |
290 | - protected function optimize_jpeg(array $options=array()) { |
|
330 | + protected function optimize_jpeg(array $options=array()) |
|
331 | + { |
|
291 | 332 | $quality = isset($options['quality']) ? $options['quality'] : self::DEFAULT_JPEG_QUALITY; |
292 | 333 | try { |
293 | 334 | $this->image->setCompressionQuality($quality); |
@@ -21,13 +21,17 @@ discard block |
||
21 | 21 | |
22 | 22 | public function __construct($uri = null) |
23 | 23 | { |
24 | - if ($uri) $this->load($uri); |
|
24 | + if ($uri) { |
|
25 | + $this->load($uri); |
|
26 | + } |
|
25 | 27 | } |
26 | 28 | |
27 | 29 | |
28 | 30 | public function load($uri) |
29 | 31 | { |
30 | - if ($this->handle) $this->close(); |
|
32 | + if ($this->handle) { |
|
33 | + $this->close(); |
|
34 | + } |
|
31 | 35 | |
32 | 36 | $this->uri = $uri; |
33 | 37 | $this->handle = fopen($uri, 'r'); |
@@ -36,15 +40,16 @@ discard block |
||
36 | 40 | |
37 | 41 | public function close() |
38 | 42 | { |
39 | - if (is_resource($this->handle)) fclose($this->handle); |
|
43 | + if (is_resource($this->handle)) { |
|
44 | + fclose($this->handle); |
|
45 | + } |
|
40 | 46 | } |
41 | 47 | |
42 | 48 | |
43 | 49 | public function getSize() |
44 | 50 | { |
45 | 51 | $this->strpos = 0; |
46 | - if ($this->getType()) |
|
47 | - { |
|
52 | + if ($this->getType()) { |
|
48 | 53 | return array_values($this->parseSize()); |
49 | 54 | } |
50 | 55 | |
@@ -56,10 +61,8 @@ discard block |
||
56 | 61 | { |
57 | 62 | $this->strpos = 0; |
58 | 63 | |
59 | - if (!$this->type) |
|
60 | - { |
|
61 | - switch ($this->getChars(2)) |
|
62 | - { |
|
64 | + if (!$this->type) { |
|
65 | + switch ($this->getChars(2)) { |
|
63 | 66 | case "BM": |
64 | 67 | return $this->type = 'bmp'; |
65 | 68 | case "GI": |
@@ -81,8 +84,7 @@ discard block |
||
81 | 84 | { |
82 | 85 | $this->strpos = 0; |
83 | 86 | |
84 | - switch ($this->type) |
|
85 | - { |
|
87 | + switch ($this->type) { |
|
86 | 88 | case 'png': |
87 | 89 | return $this->parseSizeForPNG(); |
88 | 90 | case 'gif': |
@@ -127,10 +129,8 @@ discard block |
||
127 | 129 | { |
128 | 130 | $state = null; |
129 | 131 | |
130 | - while (true) |
|
131 | - { |
|
132 | - switch ($state) |
|
133 | - { |
|
132 | + while (true) { |
|
133 | + switch ($state) { |
|
134 | 134 | default: |
135 | 135 | $this->getChars(2); |
136 | 136 | $state = 'started'; |
@@ -138,27 +138,22 @@ discard block |
||
138 | 138 | |
139 | 139 | case 'started': |
140 | 140 | $b = $this->getByte(); |
141 | - if ($b === false) return false; |
|
141 | + if ($b === false) { |
|
142 | + return false; |
|
143 | + } |
|
142 | 144 | |
143 | 145 | $state = $b == 0xFF ? 'sof' : 'started'; |
144 | 146 | break; |
145 | 147 | |
146 | 148 | case 'sof': |
147 | 149 | $b = $this->getByte(); |
148 | - if (in_array($b, range(0xe0, 0xef))) |
|
149 | - { |
|
150 | + if (in_array($b, range(0xe0, 0xef))) { |
|
150 | 151 | $state = 'skipframe'; |
151 | - } |
|
152 | - elseif (in_array($b, array_merge(range(0xC0,0xC3), range(0xC5,0xC7), range(0xC9,0xCB), range(0xCD,0xCF)))) |
|
153 | - { |
|
152 | + } elseif (in_array($b, array_merge(range(0xC0,0xC3), range(0xC5,0xC7), range(0xC9,0xCB), range(0xCD,0xCF)))) { |
|
154 | 153 | $state = 'readsize'; |
155 | - } |
|
156 | - elseif ($b == 0xFF) |
|
157 | - { |
|
154 | + } elseif ($b == 0xFF) { |
|
158 | 155 | $state = 'sof'; |
159 | - } |
|
160 | - else |
|
161 | - { |
|
156 | + } else { |
|
162 | 157 | $state = 'skipframe'; |
163 | 158 | } |
164 | 159 | break; |
@@ -187,21 +182,16 @@ discard block |
||
187 | 182 | $response = null; |
188 | 183 | |
189 | 184 | // do we need more data? |
190 | - if ($this->strpos + $n -1 >= strlen($this->str)) |
|
191 | - { |
|
185 | + if ($this->strpos + $n -1 >= strlen($this->str)) { |
|
192 | 186 | $end = ($this->strpos + $n); |
193 | 187 | |
194 | - while (strlen($this->str) < $end && $response !== false) |
|
195 | - { |
|
188 | + while (strlen($this->str) < $end && $response !== false) { |
|
196 | 189 | // read more from the file handle |
197 | 190 | $need = $end - ftell($this->handle); |
198 | 191 | |
199 | - if ($response = fread($this->handle, $need)) |
|
200 | - { |
|
192 | + if ($response = fread($this->handle, $need)) { |
|
201 | 193 | $this->str .= $response; |
202 | - } |
|
203 | - else |
|
204 | - { |
|
194 | + } else { |
|
205 | 195 | return false; |
206 | 196 | } |
207 | 197 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | -if(!$modx->hasPermission('view_eventlog')) { |
|
5 | +if(!$modx->hasPermission('view_eventlog')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | ?> |
@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | <?php |
20 | 20 | $rs = $modx->db->select('id, pagetitle, pub_date', $modx->getFullTableName('site_content'), "pub_date > " . time() . "", 'pub_date ASC'); |
21 | 21 | $limit = $modx->db->getRecordCount($rs); |
22 | - if($limit < 1) { |
|
22 | + if($limit < 1) { |
|
23 | 23 | ?> |
24 | 24 | <p><?= $_lang["no_docs_pending_publishing"] ?></p> |
25 | 25 | <?php |
26 | - } else { |
|
26 | + } else { |
|
27 | 27 | ?> |
28 | 28 | <div class="table-responsive"> |
29 | 29 | <table class="grid sortabletable" id="table-1"> |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | </thead> |
37 | 37 | <tbody> |
38 | 38 | <?php |
39 | - while($row = $modx->db->getRow($rs)) { |
|
39 | + while($row = $modx->db->getRow($rs)) { |
|
40 | 40 | ?> |
41 | 41 | <tr> |
42 | 42 | <td class="text-right"><?= $row['id'] ?></td> |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | <?php |
59 | 59 | $rs = $modx->db->select('id, pagetitle, unpub_date', $modx->getFullTableName('site_content'), "unpub_date > " . time() . "", 'unpub_date ASC'); |
60 | 60 | $limit = $modx->db->getRecordCount($rs); |
61 | - if($limit < 1) { |
|
61 | + if($limit < 1) { |
|
62 | 62 | ?> |
63 | 63 | <p><?= $_lang["no_docs_pending_unpublishing"] ?></p> |
64 | 64 | <?php |
65 | - } else { |
|
65 | + } else { |
|
66 | 66 | ?> |
67 | 67 | <div class="table-responsive"> |
68 | 68 | <table class="grid sortabletable" id="table-2"> |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | </thead> |
76 | 76 | <tbody> |
77 | 77 | <?php |
78 | - while($row = $modx->db->getRow($rs)) { |
|
78 | + while($row = $modx->db->getRow($rs)) { |
|
79 | 79 | ?> |
80 | 80 | <tr> |
81 | 81 | <td class="text-right"><?= $row['id'] ?></td> |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | <?php |
98 | 98 | $rs = $modx->db->select('id, pagetitle, pub_date, unpub_date', $modx->getFullTableName('site_content'), "pub_date > 0 OR unpub_date > 0", "pub_date DESC"); |
99 | 99 | $limit = $modx->db->getRecordCount($rs); |
100 | - if($limit < 1) { |
|
100 | + if($limit < 1) { |
|
101 | 101 | ?> |
102 | 102 | <p><?= $_lang["no_docs_pending_pubunpub"] ?></p> |
103 | 103 | <?php |
104 | - } else { |
|
104 | + } else { |
|
105 | 105 | ?> |
106 | 106 | <div class="table-responsive"> |
107 | 107 | <table class="grid sortabletable" id="table-3"> |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | </thead> |
116 | 116 | <tbody> |
117 | 117 | <?php |
118 | - while($row = $modx->db->getRow($rs)) { |
|
118 | + while($row = $modx->db->getRow($rs)) { |
|
119 | 119 | ?> |
120 | 120 | <tr> |
121 | 121 | <td class="text-right"><?= $row['id'] ?></td> |