@@ -17,9 +17,9 @@ discard block |
||
17 | 17 | */ |
18 | 18 | function getRealPath($source) |
19 | 19 | { |
20 | - if(strlen($source) >= 2 && substr_compare($source, './', 0, 2) === 0) |
|
20 | + if (strlen($source) >= 2 && substr_compare($source, './', 0, 2) === 0) |
|
21 | 21 | { |
22 | - return _XE_PATH_ . substr($source, 2); |
|
22 | + return _XE_PATH_.substr($source, 2); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | return $source; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | { |
41 | 41 | $source_dir = self::getRealPath($source_dir); |
42 | 42 | $target_dir = self::getRealPath($target_dir); |
43 | - if(!is_dir($source_dir)) |
|
43 | + if (!is_dir($source_dir)) |
|
44 | 44 | { |
45 | 45 | return FALSE; |
46 | 46 | } |
@@ -48,44 +48,44 @@ discard block |
||
48 | 48 | // generate when no target exists |
49 | 49 | self::makeDir($target_dir); |
50 | 50 | |
51 | - if(substr($source_dir, -1) != DIRECTORY_SEPARATOR) |
|
51 | + if (substr($source_dir, -1) != DIRECTORY_SEPARATOR) |
|
52 | 52 | { |
53 | 53 | $source_dir .= DIRECTORY_SEPARATOR; |
54 | 54 | } |
55 | 55 | |
56 | - if(substr($target_dir, -1) != DIRECTORY_SEPARATOR) |
|
56 | + if (substr($target_dir, -1) != DIRECTORY_SEPARATOR) |
|
57 | 57 | { |
58 | 58 | $target_dir .= DIRECTORY_SEPARATOR; |
59 | 59 | } |
60 | 60 | |
61 | 61 | $oDir = dir($source_dir); |
62 | - while($file = $oDir->read()) |
|
62 | + while ($file = $oDir->read()) |
|
63 | 63 | { |
64 | - if($file{0} == '.') |
|
64 | + if ($file{0} == '.') |
|
65 | 65 | { |
66 | 66 | continue; |
67 | 67 | } |
68 | 68 | |
69 | - if($filter && preg_match($filter, $file)) |
|
69 | + if ($filter && preg_match($filter, $file)) |
|
70 | 70 | { |
71 | 71 | continue; |
72 | 72 | } |
73 | 73 | |
74 | - if(is_dir($source_dir . $file)) |
|
74 | + if (is_dir($source_dir.$file)) |
|
75 | 75 | { |
76 | - self::copyDir($source_dir . $file, $target_dir . $file, $type); |
|
76 | + self::copyDir($source_dir.$file, $target_dir.$file, $type); |
|
77 | 77 | } |
78 | 78 | else |
79 | 79 | { |
80 | - if($type == 'force') |
|
80 | + if ($type == 'force') |
|
81 | 81 | { |
82 | - @unlink($target_dir . $file); |
|
82 | + @unlink($target_dir.$file); |
|
83 | 83 | } |
84 | 84 | else |
85 | 85 | { |
86 | - if(!file_exists($target_dir . $file)) |
|
86 | + if (!file_exists($target_dir.$file)) |
|
87 | 87 | { |
88 | - @copy($source_dir . $file, $target_dir . $file); |
|
88 | + @copy($source_dir.$file, $target_dir.$file); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | } |
@@ -110,12 +110,12 @@ discard block |
||
110 | 110 | |
111 | 111 | self::makeDir($target_dir); |
112 | 112 | |
113 | - if($force == 'Y') |
|
113 | + if ($force == 'Y') |
|
114 | 114 | { |
115 | - @unlink($target_dir . DIRECTORY_SEPARATOR . $target); |
|
115 | + @unlink($target_dir.DIRECTORY_SEPARATOR.$target); |
|
116 | 116 | } |
117 | 117 | |
118 | - @copy($source, $target_dir . DIRECTORY_SEPARATOR . $target); |
|
118 | + @copy($source, $target_dir.DIRECTORY_SEPARATOR.$target); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | function readFile($filename) |
128 | 128 | { |
129 | - if(($filename = self::exists($filename)) === FALSE || filesize($filename) < 1) |
|
129 | + if (($filename = self::exists($filename)) === FALSE || filesize($filename) < 1) |
|
130 | 130 | { |
131 | 131 | return; |
132 | 132 | } |
@@ -149,12 +149,12 @@ discard block |
||
149 | 149 | self::makeDir($pathinfo['dirname']); |
150 | 150 | |
151 | 151 | $flags = 0; |
152 | - if(strtolower($mode) == 'a') |
|
152 | + if (strtolower($mode) == 'a') |
|
153 | 153 | { |
154 | 154 | $flags = FILE_APPEND; |
155 | 155 | } |
156 | 156 | |
157 | - @file_put_contents($filename, $buff, $flags|LOCK_EX); |
|
157 | + @file_put_contents($filename, $buff, $flags | LOCK_EX); |
|
158 | 158 | @chmod($filename, 0644); |
159 | 159 | } |
160 | 160 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | function moveFile($source, $target) |
194 | 194 | { |
195 | - if(($source = self::exists($source)) !== FALSE) |
|
195 | + if (($source = self::exists($source)) !== FALSE) |
|
196 | 196 | { |
197 | 197 | self::removeFile($target); |
198 | 198 | return self::rename($source, $target); |
@@ -230,35 +230,35 @@ discard block |
||
230 | 230 | $path = self::getRealPath($path); |
231 | 231 | $output = array(); |
232 | 232 | |
233 | - if(substr($path, -1) != '/') |
|
233 | + if (substr($path, -1) != '/') |
|
234 | 234 | { |
235 | 235 | $path .= '/'; |
236 | 236 | } |
237 | 237 | |
238 | - if(!is_dir($path)) |
|
238 | + if (!is_dir($path)) |
|
239 | 239 | { |
240 | 240 | return $output; |
241 | 241 | } |
242 | 242 | |
243 | 243 | $files = scandir($path); |
244 | - foreach($files as $file) |
|
244 | + foreach ($files as $file) |
|
245 | 245 | { |
246 | - if($file{0} == '.' || ($filter && !preg_match($filter, $file))) |
|
246 | + if ($file{0} == '.' || ($filter && !preg_match($filter, $file))) |
|
247 | 247 | { |
248 | 248 | continue; |
249 | 249 | } |
250 | 250 | |
251 | - if($to_lower) |
|
251 | + if ($to_lower) |
|
252 | 252 | { |
253 | 253 | $file = strtolower($file); |
254 | 254 | } |
255 | 255 | |
256 | - if($filter) |
|
256 | + if ($filter) |
|
257 | 257 | { |
258 | 258 | $file = preg_replace($filter, '$1', $file); |
259 | 259 | } |
260 | 260 | |
261 | - if($concat_prefix) |
|
261 | + if ($concat_prefix) |
|
262 | 262 | { |
263 | 263 | $file = sprintf('%s%s', str_replace(_XE_PATH_, '', $path), $file); |
264 | 264 | } |
@@ -279,12 +279,12 @@ discard block |
||
279 | 279 | */ |
280 | 280 | function makeDir($path_string) |
281 | 281 | { |
282 | - if(self::exists($path_string) !== FALSE) |
|
282 | + if (self::exists($path_string) !== FALSE) |
|
283 | 283 | { |
284 | 284 | return TRUE; |
285 | 285 | } |
286 | 286 | |
287 | - if(!ini_get('safe_mode')) |
|
287 | + if (!ini_get('safe_mode')) |
|
288 | 288 | { |
289 | 289 | @mkdir($path_string, 0755, TRUE); |
290 | 290 | @chmod($path_string, 0755); |
@@ -295,35 +295,35 @@ discard block |
||
295 | 295 | static $oFtp = NULL; |
296 | 296 | |
297 | 297 | $ftp_info = Context::getFTPInfo(); |
298 | - if($oFtp == NULL) |
|
298 | + if ($oFtp == NULL) |
|
299 | 299 | { |
300 | - if(!Context::isFTPRegisted()) |
|
300 | + if (!Context::isFTPRegisted()) |
|
301 | 301 | { |
302 | 302 | return; |
303 | 303 | } |
304 | 304 | |
305 | - require_once(_XE_PATH_ . 'libs/ftp.class.php'); |
|
305 | + require_once(_XE_PATH_.'libs/ftp.class.php'); |
|
306 | 306 | $oFtp = new ftp(); |
307 | - if(!$ftp_info->ftp_host) |
|
307 | + if (!$ftp_info->ftp_host) |
|
308 | 308 | { |
309 | 309 | $ftp_info->ftp_host = "127.0.0.1"; |
310 | 310 | } |
311 | - if(!$ftp_info->ftp_port) |
|
311 | + if (!$ftp_info->ftp_port) |
|
312 | 312 | { |
313 | 313 | $ftp_info->ftp_port = 21; |
314 | 314 | } |
315 | - if(!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) |
|
315 | + if (!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) |
|
316 | 316 | { |
317 | 317 | return; |
318 | 318 | } |
319 | - if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
319 | + if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
320 | 320 | { |
321 | 321 | $oFtp->ftp_quit(); |
322 | 322 | return; |
323 | 323 | } |
324 | 324 | } |
325 | 325 | |
326 | - if(!($ftp_path = $ftp_info->ftp_root_path)) |
|
326 | + if (!($ftp_path = $ftp_info->ftp_root_path)) |
|
327 | 327 | { |
328 | 328 | $ftp_path = DIRECTORY_SEPARATOR; |
329 | 329 | } |
@@ -332,19 +332,19 @@ discard block |
||
332 | 332 | $path_list = explode(DIRECTORY_SEPARATOR, $path_string); |
333 | 333 | |
334 | 334 | $path = _XE_PATH_; |
335 | - for($i = 0, $c = count($path_list); $i < $c; $i++) |
|
335 | + for ($i = 0, $c = count($path_list); $i < $c; $i++) |
|
336 | 336 | { |
337 | - if(!$path_list[$i]) |
|
337 | + if (!$path_list[$i]) |
|
338 | 338 | { |
339 | 339 | continue; |
340 | 340 | } |
341 | 341 | |
342 | - $path .= $path_list[$i] . DIRECTORY_SEPARATOR; |
|
343 | - $ftp_path .= $path_list[$i] . DIRECTORY_SEPARATOR; |
|
344 | - if(!is_dir($path)) |
|
342 | + $path .= $path_list[$i].DIRECTORY_SEPARATOR; |
|
343 | + $ftp_path .= $path_list[$i].DIRECTORY_SEPARATOR; |
|
344 | + if (!is_dir($path)) |
|
345 | 345 | { |
346 | 346 | $oFtp->ftp_mkdir($ftp_path); |
347 | - $oFtp->ftp_site("CHMOD 777 " . $ftp_path); |
|
347 | + $oFtp->ftp_site("CHMOD 777 ".$ftp_path); |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | } |
@@ -360,23 +360,23 @@ discard block |
||
360 | 360 | */ |
361 | 361 | function removeDir($path) |
362 | 362 | { |
363 | - if(($path = self::isDir($path)) === FALSE) |
|
363 | + if (($path = self::isDir($path)) === FALSE) |
|
364 | 364 | { |
365 | 365 | return; |
366 | 366 | } |
367 | 367 | |
368 | - if(self::isDir($path)) |
|
368 | + if (self::isDir($path)) |
|
369 | 369 | { |
370 | 370 | $files = array_diff(scandir($path), array('..', '.')); |
371 | 371 | |
372 | - foreach($files as $file) |
|
372 | + foreach ($files as $file) |
|
373 | 373 | { |
374 | - if(($target = self::getRealPath($path . DIRECTORY_SEPARATOR . $file)) === FALSE) |
|
374 | + if (($target = self::getRealPath($path.DIRECTORY_SEPARATOR.$file)) === FALSE) |
|
375 | 375 | { |
376 | 376 | continue; |
377 | 377 | } |
378 | 378 | |
379 | - if(is_dir($target)) |
|
379 | + if (is_dir($target)) |
|
380 | 380 | { |
381 | 381 | self::removeDir($target); |
382 | 382 | } |
@@ -401,22 +401,22 @@ discard block |
||
401 | 401 | */ |
402 | 402 | function removeBlankDir($path) |
403 | 403 | { |
404 | - if(($path = self::isDir($path)) === FALSE) |
|
404 | + if (($path = self::isDir($path)) === FALSE) |
|
405 | 405 | { |
406 | 406 | return; |
407 | 407 | } |
408 | 408 | |
409 | 409 | $files = array_diff(scandir($path), array('..', '.')); |
410 | 410 | |
411 | - if(count($files) < 1) |
|
411 | + if (count($files) < 1) |
|
412 | 412 | { |
413 | 413 | rmdir($path); |
414 | 414 | return; |
415 | 415 | } |
416 | 416 | |
417 | - foreach($files as $file) |
|
417 | + foreach ($files as $file) |
|
418 | 418 | { |
419 | - if(($target = self::isDir($path . DIRECTORY_SEPARATOR . $file)) === FALSE) |
|
419 | + if (($target = self::isDir($path.DIRECTORY_SEPARATOR.$file)) === FALSE) |
|
420 | 420 | { |
421 | 421 | continue; |
422 | 422 | } |
@@ -435,23 +435,23 @@ discard block |
||
435 | 435 | */ |
436 | 436 | function removeFilesInDir($path) |
437 | 437 | { |
438 | - if(($path = self::getRealPath($path)) === FALSE) |
|
438 | + if (($path = self::getRealPath($path)) === FALSE) |
|
439 | 439 | { |
440 | 440 | return; |
441 | 441 | } |
442 | 442 | |
443 | - if(is_dir($path)) |
|
443 | + if (is_dir($path)) |
|
444 | 444 | { |
445 | 445 | $files = array_diff(scandir($path), array('..', '.')); |
446 | 446 | |
447 | - foreach($files as $file) |
|
447 | + foreach ($files as $file) |
|
448 | 448 | { |
449 | - if(($target = self::getRealPath($path . DIRECTORY_SEPARATOR . $file)) === FALSE) |
|
449 | + if (($target = self::getRealPath($path.DIRECTORY_SEPARATOR.$file)) === FALSE) |
|
450 | 450 | { |
451 | 451 | continue; |
452 | 452 | } |
453 | 453 | |
454 | - if(is_dir($target)) |
|
454 | + if (is_dir($target)) |
|
455 | 455 | { |
456 | 456 | self::removeFilesInDir($target); |
457 | 457 | } |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | } |
464 | 464 | else |
465 | 465 | { |
466 | - if(self::exists($path)) unlink($path); |
|
466 | + if (self::exists($path)) unlink($path); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | } |
@@ -477,22 +477,22 @@ discard block |
||
477 | 477 | */ |
478 | 478 | function filesize($size) |
479 | 479 | { |
480 | - if(!$size) |
|
480 | + if (!$size) |
|
481 | 481 | { |
482 | 482 | return '0Byte'; |
483 | 483 | } |
484 | 484 | |
485 | - if($size === 1) |
|
485 | + if ($size === 1) |
|
486 | 486 | { |
487 | 487 | return '1Byte'; |
488 | 488 | } |
489 | 489 | |
490 | - if($size < 1024) |
|
490 | + if ($size < 1024) |
|
491 | 491 | { |
492 | - return $size . 'Bytes'; |
|
492 | + return $size.'Bytes'; |
|
493 | 493 | } |
494 | 494 | |
495 | - if($size >= 1024 && $size < 1024 * 1024) |
|
495 | + if ($size >= 1024 && $size < 1024 * 1024) |
|
496 | 496 | { |
497 | 497 | return sprintf("%0.1fKB", $size / 1024); |
498 | 498 | } |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | */ |
518 | 518 | function getRemoteResource($url, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array(), $request_config = array()) |
519 | 519 | { |
520 | - require_once(_XE_PATH_ . 'libs/idna_convert/idna_convert.class.php'); |
|
520 | + require_once(_XE_PATH_.'libs/idna_convert/idna_convert.class.php'); |
|
521 | 521 | $IDN = new idna_convert(array('idn_version' => 2008)); |
522 | 522 | $url = $IDN->encode($url); |
523 | 523 | |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | require_once('HTTP/Request.php'); |
528 | 528 | |
529 | 529 | $parsed_url = parse_url(__PROXY_SERVER__); |
530 | - if($parsed_url["host"] && $parsed_url["path"]) |
|
530 | + if ($parsed_url["host"] && $parsed_url["path"]) |
|
531 | 531 | { |
532 | 532 | // Old style proxy server support (POST payload to proxy script) |
533 | 533 | $oRequest = new HTTP_Request(__PROXY_SERVER__); |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | $oRequest = new HTTP_Request($url); |
540 | 540 | |
541 | 541 | // New style proxy server support (Use HTTP_Request2 native config format) |
542 | - if($parsed_url['host']) |
|
542 | + if ($parsed_url['host']) |
|
543 | 543 | { |
544 | 544 | $request_config['proxy_host'] = $parsed_url['host']; |
545 | 545 | $request_config['proxy_port'] = $parsed_url['port'] ? $parsed_url['port'] : ''; |
@@ -548,49 +548,49 @@ discard block |
||
548 | 548 | $request_config['proxy_type'] = $parsed_url['scheme'] ? $parsed_url['scheme'] : 'http'; |
549 | 549 | } |
550 | 550 | |
551 | - if(count($request_config) && method_exists($oRequest, 'setConfig')) |
|
551 | + if (count($request_config) && method_exists($oRequest, 'setConfig')) |
|
552 | 552 | { |
553 | - foreach($request_config as $key=>$val) |
|
553 | + foreach ($request_config as $key=>$val) |
|
554 | 554 | { |
555 | 555 | $oRequest->setConfig($key, $val); |
556 | 556 | } |
557 | 557 | } |
558 | 558 | |
559 | - if(count($headers) > 0) |
|
559 | + if (count($headers) > 0) |
|
560 | 560 | { |
561 | - foreach($headers as $key => $val) |
|
561 | + foreach ($headers as $key => $val) |
|
562 | 562 | { |
563 | 563 | $oRequest->addHeader($key, $val); |
564 | 564 | } |
565 | 565 | } |
566 | - if($cookies[$host]) |
|
566 | + if ($cookies[$host]) |
|
567 | 567 | { |
568 | - foreach($cookies[$host] as $key => $val) |
|
568 | + foreach ($cookies[$host] as $key => $val) |
|
569 | 569 | { |
570 | 570 | $oRequest->addCookie($key, $val); |
571 | 571 | } |
572 | 572 | } |
573 | - if(count($post_data) > 0) |
|
573 | + if (count($post_data) > 0) |
|
574 | 574 | { |
575 | - foreach($post_data as $key => $val) |
|
575 | + foreach ($post_data as $key => $val) |
|
576 | 576 | { |
577 | 577 | $oRequest->addPostData($key, $val); |
578 | 578 | } |
579 | 579 | } |
580 | - if(!$content_type) |
|
580 | + if (!$content_type) |
|
581 | 581 | $oRequest->addHeader('Content-Type', 'text/html'); |
582 | 582 | else |
583 | 583 | $oRequest->addHeader('Content-Type', $content_type); |
584 | 584 | $oRequest->setMethod($method); |
585 | - if($body) |
|
585 | + if ($body) |
|
586 | 586 | $oRequest->setBody($body); |
587 | 587 | } |
588 | 588 | |
589 | - if(method_exists($oRequest, 'setConfig')) |
|
589 | + if (method_exists($oRequest, 'setConfig')) |
|
590 | 590 | { |
591 | 591 | $oRequest->setConfig('timeout', $timeout); |
592 | 592 | } |
593 | - elseif(property_exists($oRequest, '_timeout')) |
|
593 | + elseif (property_exists($oRequest, '_timeout')) |
|
594 | 594 | { |
595 | 595 | $oRequest->_timeout = $timeout; |
596 | 596 | } |
@@ -600,25 +600,25 @@ discard block |
||
600 | 600 | $code = $oRequest->getResponseCode(); |
601 | 601 | $header = $oRequest->getResponseHeader(); |
602 | 602 | $response = $oRequest->getResponseBody(); |
603 | - if($c = $oRequest->getResponseCookies()) |
|
603 | + if ($c = $oRequest->getResponseCookies()) |
|
604 | 604 | { |
605 | - foreach($c as $k => $v) |
|
605 | + foreach ($c as $k => $v) |
|
606 | 606 | { |
607 | 607 | $cookies[$host][$v['name']] = $v['value']; |
608 | 608 | } |
609 | 609 | } |
610 | 610 | |
611 | - if($code > 300 && $code < 399 && $header['location']) |
|
611 | + if ($code > 300 && $code < 399 && $header['location']) |
|
612 | 612 | { |
613 | 613 | return self::getRemoteResource($header['location'], $body, $timeout, $method, $content_type, $headers, $cookies, $post_data); |
614 | 614 | } |
615 | 615 | |
616 | - if($code != 200) |
|
616 | + if ($code != 200) |
|
617 | 617 | return; |
618 | 618 | |
619 | 619 | return $response; |
620 | 620 | } |
621 | - catch(Exception $e) |
|
621 | + catch (Exception $e) |
|
622 | 622 | { |
623 | 623 | return NULL; |
624 | 624 | } |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | */ |
639 | 639 | function getRemoteFile($url, $target_filename, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array(), $request_config = array()) |
640 | 640 | { |
641 | - if(!($body = self::getRemoteResource($url, $body, $timeout, $method, $content_type, $headers,$cookies,$post_data,$request_config))) |
|
641 | + if (!($body = self::getRemoteResource($url, $body, $timeout, $method, $content_type, $headers, $cookies, $post_data, $request_config))) |
|
642 | 642 | { |
643 | 643 | return FALSE; |
644 | 644 | } |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | function returnBytes($val) |
658 | 658 | { |
659 | 659 | $unit = strtoupper(substr($val, -1)); |
660 | - $val = (float)$val; |
|
660 | + $val = (float) $val; |
|
661 | 661 | |
662 | 662 | switch ($unit) |
663 | 663 | { |
@@ -680,13 +680,13 @@ discard block |
||
680 | 680 | $K64 = 65536; |
681 | 681 | $TWEAKFACTOR = 2.0; |
682 | 682 | $channels = $imageInfo['channels']; |
683 | - if(!$channels) |
|
683 | + if (!$channels) |
|
684 | 684 | { |
685 | 685 | $channels = 6; //for png |
686 | 686 | } |
687 | - $memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $channels / 8 + $K64 ) * $TWEAKFACTOR); |
|
687 | + $memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $channels / 8 + $K64) * $TWEAKFACTOR); |
|
688 | 688 | $availableMemory = self::returnBytes(ini_get('memory_limit')) - memory_get_usage(); |
689 | - if($availableMemory < $memoryNeeded) |
|
689 | + if ($availableMemory < $memoryNeeded) |
|
690 | 690 | { |
691 | 691 | return FALSE; |
692 | 692 | } |
@@ -713,30 +713,30 @@ discard block |
||
713 | 713 | } |
714 | 714 | |
715 | 715 | $target_file = self::getRealPath($target_file); |
716 | - if(!$resize_width) |
|
716 | + if (!$resize_width) |
|
717 | 717 | { |
718 | 718 | $resize_width = 100; |
719 | 719 | } |
720 | 720 | |
721 | - if(!$resize_height) |
|
721 | + if (!$resize_height) |
|
722 | 722 | { |
723 | 723 | $resize_height = $resize_width; |
724 | 724 | } |
725 | 725 | |
726 | 726 | // retrieve source image's information |
727 | 727 | $imageInfo = getimagesize($source_file); |
728 | - if(!self::checkMemoryLoadImage($imageInfo)) |
|
728 | + if (!self::checkMemoryLoadImage($imageInfo)) |
|
729 | 729 | { |
730 | 730 | return FALSE; |
731 | 731 | } |
732 | 732 | |
733 | 733 | list($width, $height, $type, $attrs) = $imageInfo; |
734 | - if($width < 1 || $height < 1) |
|
734 | + if ($width < 1 || $height < 1) |
|
735 | 735 | { |
736 | 736 | return; |
737 | 737 | } |
738 | 738 | |
739 | - switch($type) |
|
739 | + switch ($type) |
|
740 | 740 | { |
741 | 741 | case '1' : |
742 | 742 | $type = 'gif'; |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | return; |
755 | 755 | } |
756 | 756 | |
757 | - if(!$target_type) |
|
757 | + if (!$target_type) |
|
758 | 758 | { |
759 | 759 | $target_type = $type; |
760 | 760 | } |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | $height_per = ($resize_height > 0 && $height >= $resize_height) ? $resize_height / $height : 1; |
766 | 766 | |
767 | 767 | $per = NULL; |
768 | - if($thumbnail_type == 'ratio') |
|
768 | + if ($thumbnail_type == 'ratio') |
|
769 | 769 | { |
770 | 770 | $per = ($width_per > $height_per) ? $height_per : $width_per; |
771 | 771 | $resize_width = $width * $per; |
@@ -778,16 +778,16 @@ discard block |
||
778 | 778 | |
779 | 779 | // create temporary image with target size |
780 | 780 | $thumb = NULL; |
781 | - if(function_exists('imagecreateTRUEcolor')) |
|
781 | + if (function_exists('imagecreateTRUEcolor')) |
|
782 | 782 | { |
783 | 783 | $thumb = imagecreateTRUEcolor($resize_width, $resize_height); |
784 | 784 | } |
785 | - else if(function_exists('imagecreate')) |
|
785 | + else if (function_exists('imagecreate')) |
|
786 | 786 | { |
787 | 787 | $thumb = imagecreate($resize_width, $resize_height); |
788 | 788 | } |
789 | 789 | |
790 | - if(!$thumb) |
|
790 | + if (!$thumb) |
|
791 | 791 | { |
792 | 792 | return FALSE; |
793 | 793 | } |
@@ -796,37 +796,37 @@ discard block |
||
796 | 796 | |
797 | 797 | // create temporary image having original type |
798 | 798 | $source = NULL; |
799 | - switch($type) |
|
799 | + switch ($type) |
|
800 | 800 | { |
801 | 801 | case 'gif' : |
802 | - if(function_exists('imagecreatefromgif')) |
|
802 | + if (function_exists('imagecreatefromgif')) |
|
803 | 803 | { |
804 | 804 | $source = @imagecreatefromgif($source_file); |
805 | 805 | } |
806 | 806 | break; |
807 | 807 | case 'jpeg' : |
808 | 808 | case 'jpg' : |
809 | - if(function_exists('imagecreatefromjpeg')) |
|
809 | + if (function_exists('imagecreatefromjpeg')) |
|
810 | 810 | { |
811 | 811 | $source = @imagecreatefromjpeg($source_file); |
812 | 812 | } |
813 | 813 | break; |
814 | 814 | case 'png' : |
815 | - if(function_exists('imagecreatefrompng')) |
|
815 | + if (function_exists('imagecreatefrompng')) |
|
816 | 816 | { |
817 | 817 | $source = @imagecreatefrompng($source_file); |
818 | 818 | } |
819 | 819 | break; |
820 | 820 | case 'wbmp' : |
821 | 821 | case 'bmp' : |
822 | - if(function_exists('imagecreatefromwbmp')) |
|
822 | + if (function_exists('imagecreatefromwbmp')) |
|
823 | 823 | { |
824 | 824 | $source = @imagecreatefromwbmp($source_file); |
825 | 825 | } |
826 | 826 | break; |
827 | 827 | } |
828 | 828 | |
829 | - if(!$source) |
|
829 | + if (!$source) |
|
830 | 830 | { |
831 | 831 | imagedestroy($thumb); |
832 | 832 | return FALSE; |
@@ -838,13 +838,13 @@ discard block |
||
838 | 838 | |
839 | 839 | $x = 0; |
840 | 840 | $y = 0; |
841 | - if($thumbnail_type == 'crop') |
|
841 | + if ($thumbnail_type == 'crop') |
|
842 | 842 | { |
843 | 843 | $x = (int) ($resize_width / 2 - $new_width / 2); |
844 | 844 | $y = (int) ($resize_height / 2 - $new_height / 2); |
845 | 845 | } |
846 | 846 | |
847 | - if(function_exists('imagecopyresampled')) |
|
847 | + if (function_exists('imagecopyresampled')) |
|
848 | 848 | { |
849 | 849 | imagecopyresampled($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height); |
850 | 850 | } |
@@ -858,30 +858,30 @@ discard block |
||
858 | 858 | |
859 | 859 | // write into the file |
860 | 860 | $output = NULL; |
861 | - switch($target_type) |
|
861 | + switch ($target_type) |
|
862 | 862 | { |
863 | 863 | case 'gif' : |
864 | - if(function_exists('imagegif')) |
|
864 | + if (function_exists('imagegif')) |
|
865 | 865 | { |
866 | 866 | $output = imagegif($thumb, $target_file); |
867 | 867 | } |
868 | 868 | break; |
869 | 869 | case 'jpeg' : |
870 | 870 | case 'jpg' : |
871 | - if(function_exists('imagejpeg')) |
|
871 | + if (function_exists('imagejpeg')) |
|
872 | 872 | { |
873 | 873 | $output = imagejpeg($thumb, $target_file, 100); |
874 | 874 | } |
875 | 875 | break; |
876 | 876 | case 'png' : |
877 | - if(function_exists('imagepng')) |
|
877 | + if (function_exists('imagepng')) |
|
878 | 878 | { |
879 | 879 | $output = imagepng($thumb, $target_file, 9); |
880 | 880 | } |
881 | 881 | break; |
882 | 882 | case 'wbmp' : |
883 | 883 | case 'bmp' : |
884 | - if(function_exists('imagewbmp')) |
|
884 | + if (function_exists('imagewbmp')) |
|
885 | 885 | { |
886 | 886 | $output = imagewbmp($thumb, $target_file, 100); |
887 | 887 | } |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | imagedestroy($thumb); |
892 | 892 | imagedestroy($source); |
893 | 893 | |
894 | - if(!$output) |
|
894 | + if (!$output) |
|
895 | 895 | { |
896 | 896 | return FALSE; |
897 | 897 | } |
@@ -909,12 +909,12 @@ discard block |
||
909 | 909 | */ |
910 | 910 | function readIniFile($filename) |
911 | 911 | { |
912 | - if(($filename = self::exists($filename)) === FALSE) |
|
912 | + if (($filename = self::exists($filename)) === FALSE) |
|
913 | 913 | { |
914 | 914 | return FALSE; |
915 | 915 | } |
916 | 916 | $arr = parse_ini_file($filename, TRUE); |
917 | - if(is_array($arr) && count($arr) > 0) |
|
917 | + if (is_array($arr) && count($arr) > 0) |
|
918 | 918 | { |
919 | 919 | return $arr; |
920 | 920 | } |
@@ -940,7 +940,7 @@ discard block |
||
940 | 940 | */ |
941 | 941 | function writeIniFile($filename, $arr) |
942 | 942 | { |
943 | - if(!is_array($arr) || count($arr) == 0) |
|
943 | + if (!is_array($arr) || count($arr) == 0) |
|
944 | 944 | { |
945 | 945 | return FALSE; |
946 | 946 | } |
@@ -957,19 +957,19 @@ discard block |
||
957 | 957 | function _makeIniBuff($arr) |
958 | 958 | { |
959 | 959 | $return = array(); |
960 | - foreach($arr as $key => $val) |
|
960 | + foreach ($arr as $key => $val) |
|
961 | 961 | { |
962 | 962 | // section |
963 | - if(is_array($val)) |
|
963 | + if (is_array($val)) |
|
964 | 964 | { |
965 | 965 | $return[] = sprintf("[%s]", $key); |
966 | - foreach($val as $k => $v) |
|
966 | + foreach ($val as $k => $v) |
|
967 | 967 | { |
968 | 968 | $return[] = sprintf("%s=\"%s\"", $k, $v); |
969 | 969 | } |
970 | 970 | // value |
971 | 971 | } |
972 | - else if(is_object($val)) |
|
972 | + else if (is_object($val)) |
|
973 | 973 | { |
974 | 974 | continue; |
975 | 975 | } |
@@ -1044,15 +1044,15 @@ discard block |
||
1044 | 1044 | function isWritableDir($path) |
1045 | 1045 | { |
1046 | 1046 | $path = self::getRealPath($path); |
1047 | - if(is_dir($path)==FALSE) |
|
1047 | + if (is_dir($path) == FALSE) |
|
1048 | 1048 | { |
1049 | 1049 | return FALSE; |
1050 | 1050 | } |
1051 | 1051 | |
1052 | - $checkFile = $path . '/_CheckWritableDir'; |
|
1052 | + $checkFile = $path.'/_CheckWritableDir'; |
|
1053 | 1053 | |
1054 | 1054 | $fp = fopen($checkFile, 'w'); |
1055 | - if(!is_resource($fp)) |
|
1055 | + if (!is_resource($fp)) |
|
1056 | 1056 | { |
1057 | 1057 | return FALSE; |
1058 | 1058 | } |