@@ -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 | self::clearStatCache($filename); |
160 | 160 | self::invalidateOpcache($filename); |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | */ |
195 | 195 | function moveFile($source, $target) |
196 | 196 | { |
197 | - if(($source = self::exists($source)) !== FALSE) |
|
197 | + if (($source = self::exists($source)) !== FALSE) |
|
198 | 198 | { |
199 | 199 | self::removeFile($target); |
200 | 200 | return self::rename($source, $target); |
@@ -232,35 +232,35 @@ discard block |
||
232 | 232 | $path = self::getRealPath($path); |
233 | 233 | $output = array(); |
234 | 234 | |
235 | - if(substr($path, -1) != '/') |
|
235 | + if (substr($path, -1) != '/') |
|
236 | 236 | { |
237 | 237 | $path .= '/'; |
238 | 238 | } |
239 | 239 | |
240 | - if(!is_dir($path)) |
|
240 | + if (!is_dir($path)) |
|
241 | 241 | { |
242 | 242 | return $output; |
243 | 243 | } |
244 | 244 | |
245 | 245 | $files = scandir($path); |
246 | - foreach($files as $file) |
|
246 | + foreach ($files as $file) |
|
247 | 247 | { |
248 | - if($file{0} == '.' || ($filter && !preg_match($filter, $file))) |
|
248 | + if ($file{0} == '.' || ($filter && !preg_match($filter, $file))) |
|
249 | 249 | { |
250 | 250 | continue; |
251 | 251 | } |
252 | 252 | |
253 | - if($to_lower) |
|
253 | + if ($to_lower) |
|
254 | 254 | { |
255 | 255 | $file = strtolower($file); |
256 | 256 | } |
257 | 257 | |
258 | - if($filter) |
|
258 | + if ($filter) |
|
259 | 259 | { |
260 | 260 | $file = preg_replace($filter, '$1', $file); |
261 | 261 | } |
262 | 262 | |
263 | - if($concat_prefix) |
|
263 | + if ($concat_prefix) |
|
264 | 264 | { |
265 | 265 | $file = sprintf('%s%s', str_replace(_XE_PATH_, '', $path), $file); |
266 | 266 | } |
@@ -281,12 +281,12 @@ discard block |
||
281 | 281 | */ |
282 | 282 | function makeDir($path_string) |
283 | 283 | { |
284 | - if(self::exists($path_string) !== FALSE) |
|
284 | + if (self::exists($path_string) !== FALSE) |
|
285 | 285 | { |
286 | 286 | return TRUE; |
287 | 287 | } |
288 | 288 | |
289 | - if(!ini_get('safe_mode')) |
|
289 | + if (!ini_get('safe_mode')) |
|
290 | 290 | { |
291 | 291 | @mkdir($path_string, 0755, TRUE); |
292 | 292 | @chmod($path_string, 0755); |
@@ -297,35 +297,35 @@ discard block |
||
297 | 297 | static $oFtp = NULL; |
298 | 298 | |
299 | 299 | $ftp_info = Context::getFTPInfo(); |
300 | - if($oFtp == NULL) |
|
300 | + if ($oFtp == NULL) |
|
301 | 301 | { |
302 | - if(!Context::isFTPRegisted()) |
|
302 | + if (!Context::isFTPRegisted()) |
|
303 | 303 | { |
304 | 304 | return; |
305 | 305 | } |
306 | 306 | |
307 | - require_once(_XE_PATH_ . 'libs/ftp.class.php'); |
|
307 | + require_once(_XE_PATH_.'libs/ftp.class.php'); |
|
308 | 308 | $oFtp = new ftp(); |
309 | - if(!$ftp_info->ftp_host) |
|
309 | + if (!$ftp_info->ftp_host) |
|
310 | 310 | { |
311 | 311 | $ftp_info->ftp_host = "127.0.0.1"; |
312 | 312 | } |
313 | - if(!$ftp_info->ftp_port) |
|
313 | + if (!$ftp_info->ftp_port) |
|
314 | 314 | { |
315 | 315 | $ftp_info->ftp_port = 21; |
316 | 316 | } |
317 | - if(!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) |
|
317 | + if (!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) |
|
318 | 318 | { |
319 | 319 | return; |
320 | 320 | } |
321 | - if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
321 | + if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
322 | 322 | { |
323 | 323 | $oFtp->ftp_quit(); |
324 | 324 | return; |
325 | 325 | } |
326 | 326 | } |
327 | 327 | |
328 | - if(!($ftp_path = $ftp_info->ftp_root_path)) |
|
328 | + if (!($ftp_path = $ftp_info->ftp_root_path)) |
|
329 | 329 | { |
330 | 330 | $ftp_path = DIRECTORY_SEPARATOR; |
331 | 331 | } |
@@ -334,19 +334,19 @@ discard block |
||
334 | 334 | $path_list = explode(DIRECTORY_SEPARATOR, $path_string); |
335 | 335 | |
336 | 336 | $path = _XE_PATH_; |
337 | - for($i = 0, $c = count($path_list); $i < $c; $i++) |
|
337 | + for ($i = 0, $c = count($path_list); $i < $c; $i++) |
|
338 | 338 | { |
339 | - if(!$path_list[$i]) |
|
339 | + if (!$path_list[$i]) |
|
340 | 340 | { |
341 | 341 | continue; |
342 | 342 | } |
343 | 343 | |
344 | - $path .= $path_list[$i] . DIRECTORY_SEPARATOR; |
|
345 | - $ftp_path .= $path_list[$i] . DIRECTORY_SEPARATOR; |
|
346 | - if(!is_dir($path)) |
|
344 | + $path .= $path_list[$i].DIRECTORY_SEPARATOR; |
|
345 | + $ftp_path .= $path_list[$i].DIRECTORY_SEPARATOR; |
|
346 | + if (!is_dir($path)) |
|
347 | 347 | { |
348 | 348 | $oFtp->ftp_mkdir($ftp_path); |
349 | - $oFtp->ftp_site("CHMOD 777 " . $ftp_path); |
|
349 | + $oFtp->ftp_site("CHMOD 777 ".$ftp_path); |
|
350 | 350 | } |
351 | 351 | } |
352 | 352 | } |
@@ -362,23 +362,23 @@ discard block |
||
362 | 362 | */ |
363 | 363 | function removeDir($path) |
364 | 364 | { |
365 | - if(($path = self::isDir($path)) === FALSE) |
|
365 | + if (($path = self::isDir($path)) === FALSE) |
|
366 | 366 | { |
367 | 367 | return; |
368 | 368 | } |
369 | 369 | |
370 | - if(self::isDir($path)) |
|
370 | + if (self::isDir($path)) |
|
371 | 371 | { |
372 | 372 | $files = array_diff(scandir($path), array('..', '.')); |
373 | 373 | |
374 | - foreach($files as $file) |
|
374 | + foreach ($files as $file) |
|
375 | 375 | { |
376 | - if(($target = self::getRealPath($path . DIRECTORY_SEPARATOR . $file)) === FALSE) |
|
376 | + if (($target = self::getRealPath($path.DIRECTORY_SEPARATOR.$file)) === FALSE) |
|
377 | 377 | { |
378 | 378 | continue; |
379 | 379 | } |
380 | 380 | |
381 | - if(is_dir($target)) |
|
381 | + if (is_dir($target)) |
|
382 | 382 | { |
383 | 383 | self::removeDir($target); |
384 | 384 | } |
@@ -403,22 +403,22 @@ discard block |
||
403 | 403 | */ |
404 | 404 | function removeBlankDir($path) |
405 | 405 | { |
406 | - if(($path = self::isDir($path)) === FALSE) |
|
406 | + if (($path = self::isDir($path)) === FALSE) |
|
407 | 407 | { |
408 | 408 | return; |
409 | 409 | } |
410 | 410 | |
411 | 411 | $files = array_diff(scandir($path), array('..', '.')); |
412 | 412 | |
413 | - if(count($files) < 1) |
|
413 | + if (count($files) < 1) |
|
414 | 414 | { |
415 | 415 | rmdir($path); |
416 | 416 | return; |
417 | 417 | } |
418 | 418 | |
419 | - foreach($files as $file) |
|
419 | + foreach ($files as $file) |
|
420 | 420 | { |
421 | - if(($target = self::isDir($path . DIRECTORY_SEPARATOR . $file)) === FALSE) |
|
421 | + if (($target = self::isDir($path.DIRECTORY_SEPARATOR.$file)) === FALSE) |
|
422 | 422 | { |
423 | 423 | continue; |
424 | 424 | } |
@@ -437,23 +437,23 @@ discard block |
||
437 | 437 | */ |
438 | 438 | function removeFilesInDir($path) |
439 | 439 | { |
440 | - if(($path = self::getRealPath($path)) === FALSE) |
|
440 | + if (($path = self::getRealPath($path)) === FALSE) |
|
441 | 441 | { |
442 | 442 | return; |
443 | 443 | } |
444 | 444 | |
445 | - if(is_dir($path)) |
|
445 | + if (is_dir($path)) |
|
446 | 446 | { |
447 | 447 | $files = array_diff(scandir($path), array('..', '.')); |
448 | 448 | |
449 | - foreach($files as $file) |
|
449 | + foreach ($files as $file) |
|
450 | 450 | { |
451 | - if(($target = self::getRealPath($path . DIRECTORY_SEPARATOR . $file)) === FALSE) |
|
451 | + if (($target = self::getRealPath($path.DIRECTORY_SEPARATOR.$file)) === FALSE) |
|
452 | 452 | { |
453 | 453 | continue; |
454 | 454 | } |
455 | 455 | |
456 | - if(is_dir($target)) |
|
456 | + if (is_dir($target)) |
|
457 | 457 | { |
458 | 458 | self::removeFilesInDir($target); |
459 | 459 | } |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | } |
466 | 466 | else |
467 | 467 | { |
468 | - if(self::exists($path)) unlink($path); |
|
468 | + if (self::exists($path)) unlink($path); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | } |
@@ -479,22 +479,22 @@ discard block |
||
479 | 479 | */ |
480 | 480 | function filesize($size) |
481 | 481 | { |
482 | - if(!$size) |
|
482 | + if (!$size) |
|
483 | 483 | { |
484 | 484 | return '0Byte'; |
485 | 485 | } |
486 | 486 | |
487 | - if($size === 1) |
|
487 | + if ($size === 1) |
|
488 | 488 | { |
489 | 489 | return '1Byte'; |
490 | 490 | } |
491 | 491 | |
492 | - if($size < 1024) |
|
492 | + if ($size < 1024) |
|
493 | 493 | { |
494 | - return $size . 'Bytes'; |
|
494 | + return $size.'Bytes'; |
|
495 | 495 | } |
496 | 496 | |
497 | - if($size >= 1024 && $size < 1024 * 1024) |
|
497 | + if ($size >= 1024 && $size < 1024 * 1024) |
|
498 | 498 | { |
499 | 499 | return sprintf("%0.1fKB", $size / 1024); |
500 | 500 | } |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | */ |
520 | 520 | function getRemoteResource($url, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array(), $request_config = array()) |
521 | 521 | { |
522 | - require_once(_XE_PATH_ . 'libs/idna_convert/idna_convert.class.php'); |
|
522 | + require_once(_XE_PATH_.'libs/idna_convert/idna_convert.class.php'); |
|
523 | 523 | $IDN = new idna_convert(array('idn_version' => 2008)); |
524 | 524 | $url = $IDN->encode($url); |
525 | 525 | |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | require_once('HTTP/Request.php'); |
530 | 530 | |
531 | 531 | $parsed_url = parse_url(__PROXY_SERVER__); |
532 | - if($parsed_url["host"] && $parsed_url["path"]) |
|
532 | + if ($parsed_url["host"] && $parsed_url["path"]) |
|
533 | 533 | { |
534 | 534 | // Old style proxy server support (POST payload to proxy script) |
535 | 535 | $oRequest = new HTTP_Request(__PROXY_SERVER__); |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | $oRequest = new HTTP_Request($url); |
542 | 542 | |
543 | 543 | // New style proxy server support (Use HTTP_Request2 native config format) |
544 | - if($parsed_url['host']) |
|
544 | + if ($parsed_url['host']) |
|
545 | 545 | { |
546 | 546 | $request_config['proxy_host'] = $parsed_url['host']; |
547 | 547 | $request_config['proxy_port'] = $parsed_url['port'] ? $parsed_url['port'] : ''; |
@@ -550,13 +550,13 @@ discard block |
||
550 | 550 | $request_config['proxy_type'] = $parsed_url['scheme'] ? $parsed_url['scheme'] : 'http'; |
551 | 551 | } |
552 | 552 | |
553 | - if(count($request_config) && method_exists($oRequest, 'setConfig')) |
|
553 | + if (count($request_config) && method_exists($oRequest, 'setConfig')) |
|
554 | 554 | { |
555 | - foreach($request_config as $key=>$val) |
|
555 | + foreach ($request_config as $key=>$val) |
|
556 | 556 | { |
557 | - if($key === 'observers') |
|
557 | + if ($key === 'observers') |
|
558 | 558 | { |
559 | - foreach($val as $observer) |
|
559 | + foreach ($val as $observer) |
|
560 | 560 | { |
561 | 561 | $oRequest->attach($observer); |
562 | 562 | } |
@@ -567,58 +567,58 @@ discard block |
||
567 | 567 | } |
568 | 568 | } |
569 | 569 | } |
570 | - if(method_exists($oRequest, 'setConfig')) |
|
570 | + if (method_exists($oRequest, 'setConfig')) |
|
571 | 571 | { |
572 | - if(extension_loaded('curl')) |
|
572 | + if (extension_loaded('curl')) |
|
573 | 573 | { |
574 | 574 | $oRequest->setConfig('adapter', 'curl'); |
575 | 575 | } |
576 | - elseif(version_compare(PHP_VERSION, '5.6', '<')) |
|
576 | + elseif (version_compare(PHP_VERSION, '5.6', '<')) |
|
577 | 577 | { |
578 | 578 | $oRequest->setConfig('ssl_verify_host', false); |
579 | 579 | } |
580 | - if(file_exists(_XE_PATH_ . 'libs/cacert/cacert.pem')) |
|
580 | + if (file_exists(_XE_PATH_.'libs/cacert/cacert.pem')) |
|
581 | 581 | { |
582 | - $oRequest->setConfig('ssl_cafile', _XE_PATH_ . 'libs/cacert/cacert.pem'); |
|
582 | + $oRequest->setConfig('ssl_cafile', _XE_PATH_.'libs/cacert/cacert.pem'); |
|
583 | 583 | } |
584 | 584 | } |
585 | 585 | |
586 | - if(count($headers) > 0) |
|
586 | + if (count($headers) > 0) |
|
587 | 587 | { |
588 | - foreach($headers as $key => $val) |
|
588 | + foreach ($headers as $key => $val) |
|
589 | 589 | { |
590 | 590 | $oRequest->addHeader($key, $val); |
591 | 591 | } |
592 | 592 | } |
593 | 593 | $host = parse_url($url, PHP_URL_HOST); |
594 | - if($cookies[$host]) |
|
594 | + if ($cookies[$host]) |
|
595 | 595 | { |
596 | - foreach($cookies[$host] as $key => $val) |
|
596 | + foreach ($cookies[$host] as $key => $val) |
|
597 | 597 | { |
598 | 598 | $oRequest->addCookie($key, $val); |
599 | 599 | } |
600 | 600 | } |
601 | - if(count($post_data) > 0) |
|
601 | + if (count($post_data) > 0) |
|
602 | 602 | { |
603 | - foreach($post_data as $key => $val) |
|
603 | + foreach ($post_data as $key => $val) |
|
604 | 604 | { |
605 | 605 | $oRequest->addPostData($key, $val); |
606 | 606 | } |
607 | 607 | } |
608 | - if(!$content_type) |
|
608 | + if (!$content_type) |
|
609 | 609 | $oRequest->addHeader('Content-Type', 'text/html'); |
610 | 610 | else |
611 | 611 | $oRequest->addHeader('Content-Type', $content_type); |
612 | 612 | $oRequest->setMethod($method); |
613 | - if($body) |
|
613 | + if ($body) |
|
614 | 614 | $oRequest->setBody($body); |
615 | 615 | } |
616 | 616 | |
617 | - if(method_exists($oRequest, 'setConfig')) |
|
617 | + if (method_exists($oRequest, 'setConfig')) |
|
618 | 618 | { |
619 | 619 | $oRequest->setConfig('timeout', $timeout); |
620 | 620 | } |
621 | - elseif(property_exists($oRequest, '_timeout')) |
|
621 | + elseif (property_exists($oRequest, '_timeout')) |
|
622 | 622 | { |
623 | 623 | $oRequest->_timeout = $timeout; |
624 | 624 | } |
@@ -628,25 +628,25 @@ discard block |
||
628 | 628 | $code = $oRequest->getResponseCode(); |
629 | 629 | $header = $oRequest->getResponseHeader(); |
630 | 630 | $response = $oRequest->getResponseBody(); |
631 | - if($c = $oRequest->getResponseCookies()) |
|
631 | + if ($c = $oRequest->getResponseCookies()) |
|
632 | 632 | { |
633 | - foreach($c as $k => $v) |
|
633 | + foreach ($c as $k => $v) |
|
634 | 634 | { |
635 | 635 | $cookies[$host][$v['name']] = $v['value']; |
636 | 636 | } |
637 | 637 | } |
638 | 638 | |
639 | - if($code > 300 && $code < 399 && $header['location']) |
|
639 | + if ($code > 300 && $code < 399 && $header['location']) |
|
640 | 640 | { |
641 | 641 | return self::getRemoteResource($header['location'], $body, $timeout, $method, $content_type, $headers, $cookies, $post_data); |
642 | 642 | } |
643 | 643 | |
644 | - if($code != 200) |
|
644 | + if ($code != 200) |
|
645 | 645 | { |
646 | 646 | return; |
647 | 647 | } |
648 | 648 | |
649 | - if(isset($request_config['store_body']) && !$request_config['store_body']) |
|
649 | + if (isset($request_config['store_body']) && !$request_config['store_body']) |
|
650 | 650 | { |
651 | 651 | return TRUE; |
652 | 652 | } |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | return $response; |
656 | 656 | } |
657 | 657 | } |
658 | - catch(Exception $e) |
|
658 | + catch (Exception $e) |
|
659 | 659 | { |
660 | 660 | return NULL; |
661 | 661 | } |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | self::clearStatCache($target_filename); |
690 | 690 | self::invalidateOpcache($target_filename); |
691 | 691 | } |
692 | - catch(Exception $e) |
|
692 | + catch (Exception $e) |
|
693 | 693 | { |
694 | 694 | return FALSE; |
695 | 695 | } |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | function returnBytes($val) |
707 | 707 | { |
708 | 708 | $unit = strtoupper(substr($val, -1)); |
709 | - $val = (float)$val; |
|
709 | + $val = (float) $val; |
|
710 | 710 | |
711 | 711 | switch ($unit) |
712 | 712 | { |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | function checkMemoryLoadImage(&$imageInfo) |
728 | 728 | { |
729 | 729 | $memoryLimit = self::returnBytes(ini_get('memory_limit')); |
730 | - if($memoryLimit == -1) |
|
730 | + if ($memoryLimit == -1) |
|
731 | 731 | { |
732 | 732 | return true; |
733 | 733 | } |
@@ -735,14 +735,14 @@ discard block |
||
735 | 735 | $K64 = 65536; |
736 | 736 | $TWEAKFACTOR = 2.0; |
737 | 737 | $channels = $imageInfo['channels']; |
738 | - if(!$channels) |
|
738 | + if (!$channels) |
|
739 | 739 | { |
740 | 740 | $channels = 6; //for png |
741 | 741 | } |
742 | 742 | |
743 | - $memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $channels / 8 + $K64 ) * $TWEAKFACTOR); |
|
743 | + $memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $channels / 8 + $K64) * $TWEAKFACTOR); |
|
744 | 744 | $availableMemory = self::returnBytes(ini_get('memory_limit')) - memory_get_usage(); |
745 | - if($availableMemory < $memoryNeeded) |
|
745 | + if ($availableMemory < $memoryNeeded) |
|
746 | 746 | { |
747 | 747 | return FALSE; |
748 | 748 | } |
@@ -771,30 +771,30 @@ discard block |
||
771 | 771 | } |
772 | 772 | |
773 | 773 | $target_file = self::getRealPath($target_file); |
774 | - if(!$resize_width) |
|
774 | + if (!$resize_width) |
|
775 | 775 | { |
776 | 776 | $resize_width = 100; |
777 | 777 | } |
778 | 778 | |
779 | - if(!$resize_height) |
|
779 | + if (!$resize_height) |
|
780 | 780 | { |
781 | 781 | $resize_height = $resize_width; |
782 | 782 | } |
783 | 783 | |
784 | 784 | // retrieve source image's information |
785 | 785 | $imageInfo = getimagesize($source_file); |
786 | - if(!self::checkMemoryLoadImage($imageInfo)) |
|
786 | + if (!self::checkMemoryLoadImage($imageInfo)) |
|
787 | 787 | { |
788 | 788 | return FALSE; |
789 | 789 | } |
790 | 790 | |
791 | 791 | list($width, $height, $type, $attrs) = $imageInfo; |
792 | - if($width < 1 || $height < 1) |
|
792 | + if ($width < 1 || $height < 1) |
|
793 | 793 | { |
794 | 794 | return; |
795 | 795 | } |
796 | 796 | |
797 | - switch($type) |
|
797 | + switch ($type) |
|
798 | 798 | { |
799 | 799 | case '1' : |
800 | 800 | $type = 'gif'; |
@@ -812,7 +812,7 @@ discard block |
||
812 | 812 | return; |
813 | 813 | } |
814 | 814 | |
815 | - if(!$target_type) |
|
815 | + if (!$target_type) |
|
816 | 816 | { |
817 | 817 | $target_type = $type; |
818 | 818 | } |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | $height_per = ($resize_height > 0 && $height >= $resize_height) ? $resize_height / $height : 1; |
824 | 824 | |
825 | 825 | $per = NULL; |
826 | - if($thumbnail_type == 'ratio') |
|
826 | + if ($thumbnail_type == 'ratio') |
|
827 | 827 | { |
828 | 828 | $per = ($width_per > $height_per) ? $height_per : $width_per; |
829 | 829 | $resize_width = $width * $per; |
@@ -836,30 +836,30 @@ discard block |
||
836 | 836 | |
837 | 837 | // create temporary image with target size |
838 | 838 | $thumb = NULL; |
839 | - if(function_exists('imagecreateTRUEcolor')) |
|
839 | + if (function_exists('imagecreateTRUEcolor')) |
|
840 | 840 | { |
841 | 841 | $thumb = imagecreateTRUEcolor($resize_width, $resize_height); |
842 | 842 | } |
843 | - else if(function_exists('imagecreate')) |
|
843 | + else if (function_exists('imagecreate')) |
|
844 | 844 | { |
845 | 845 | $thumb = imagecreate($resize_width, $resize_height); |
846 | 846 | } |
847 | 847 | |
848 | - if(!$thumb) |
|
848 | + if (!$thumb) |
|
849 | 849 | { |
850 | 850 | return FALSE; |
851 | 851 | } |
852 | 852 | |
853 | - if(function_exists('imagecolorallocatealpha') && $target_type == 'png' && $thumbnail_transparent) |
|
853 | + if (function_exists('imagecolorallocatealpha') && $target_type == 'png' && $thumbnail_transparent) |
|
854 | 854 | { |
855 | 855 | imagefill($thumb, 0, 0, imagecolorallocatealpha($thumb, 0, 0, 0, 127)); |
856 | 856 | |
857 | - if(function_exists('imagesavealpha')) |
|
857 | + if (function_exists('imagesavealpha')) |
|
858 | 858 | { |
859 | 859 | imagesavealpha($thumb, TRUE); |
860 | 860 | } |
861 | 861 | |
862 | - if(function_exists('imagealphablending')) |
|
862 | + if (function_exists('imagealphablending')) |
|
863 | 863 | { |
864 | 864 | imagealphablending($thumb, TRUE); |
865 | 865 | } |
@@ -871,37 +871,37 @@ discard block |
||
871 | 871 | |
872 | 872 | // create temporary image having original type |
873 | 873 | $source = NULL; |
874 | - switch($type) |
|
874 | + switch ($type) |
|
875 | 875 | { |
876 | 876 | case 'gif' : |
877 | - if(function_exists('imagecreatefromgif')) |
|
877 | + if (function_exists('imagecreatefromgif')) |
|
878 | 878 | { |
879 | 879 | $source = @imagecreatefromgif($source_file); |
880 | 880 | } |
881 | 881 | break; |
882 | 882 | case 'jpeg' : |
883 | 883 | case 'jpg' : |
884 | - if(function_exists('imagecreatefromjpeg')) |
|
884 | + if (function_exists('imagecreatefromjpeg')) |
|
885 | 885 | { |
886 | 886 | $source = @imagecreatefromjpeg($source_file); |
887 | 887 | } |
888 | 888 | break; |
889 | 889 | case 'png' : |
890 | - if(function_exists('imagecreatefrompng')) |
|
890 | + if (function_exists('imagecreatefrompng')) |
|
891 | 891 | { |
892 | 892 | $source = @imagecreatefrompng($source_file); |
893 | 893 | } |
894 | 894 | break; |
895 | 895 | case 'wbmp' : |
896 | 896 | case 'bmp' : |
897 | - if(function_exists('imagecreatefromwbmp')) |
|
897 | + if (function_exists('imagecreatefromwbmp')) |
|
898 | 898 | { |
899 | 899 | $source = @imagecreatefromwbmp($source_file); |
900 | 900 | } |
901 | 901 | break; |
902 | 902 | } |
903 | 903 | |
904 | - if(!$source) |
|
904 | + if (!$source) |
|
905 | 905 | { |
906 | 906 | imagedestroy($thumb); |
907 | 907 | return FALSE; |
@@ -913,13 +913,13 @@ discard block |
||
913 | 913 | |
914 | 914 | $x = 0; |
915 | 915 | $y = 0; |
916 | - if($thumbnail_type == 'crop') |
|
916 | + if ($thumbnail_type == 'crop') |
|
917 | 917 | { |
918 | 918 | $x = (int) ($resize_width / 2 - $new_width / 2); |
919 | 919 | $y = (int) ($resize_height / 2 - $new_height / 2); |
920 | 920 | } |
921 | 921 | |
922 | - if(function_exists('imagecopyresampled')) |
|
922 | + if (function_exists('imagecopyresampled')) |
|
923 | 923 | { |
924 | 924 | imagecopyresampled($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height); |
925 | 925 | } |
@@ -933,30 +933,30 @@ discard block |
||
933 | 933 | |
934 | 934 | // write into the file |
935 | 935 | $output = NULL; |
936 | - switch($target_type) |
|
936 | + switch ($target_type) |
|
937 | 937 | { |
938 | 938 | case 'gif' : |
939 | - if(function_exists('imagegif')) |
|
939 | + if (function_exists('imagegif')) |
|
940 | 940 | { |
941 | 941 | $output = imagegif($thumb, $target_file); |
942 | 942 | } |
943 | 943 | break; |
944 | 944 | case 'jpeg' : |
945 | 945 | case 'jpg' : |
946 | - if(function_exists('imagejpeg')) |
|
946 | + if (function_exists('imagejpeg')) |
|
947 | 947 | { |
948 | 948 | $output = imagejpeg($thumb, $target_file, 100); |
949 | 949 | } |
950 | 950 | break; |
951 | 951 | case 'png' : |
952 | - if(function_exists('imagepng')) |
|
952 | + if (function_exists('imagepng')) |
|
953 | 953 | { |
954 | 954 | $output = imagepng($thumb, $target_file, 9); |
955 | 955 | } |
956 | 956 | break; |
957 | 957 | case 'wbmp' : |
958 | 958 | case 'bmp' : |
959 | - if(function_exists('imagewbmp')) |
|
959 | + if (function_exists('imagewbmp')) |
|
960 | 960 | { |
961 | 961 | $output = imagewbmp($thumb, $target_file, 100); |
962 | 962 | } |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | imagedestroy($thumb); |
967 | 967 | imagedestroy($source); |
968 | 968 | |
969 | - if(!$output) |
|
969 | + if (!$output) |
|
970 | 970 | { |
971 | 971 | return FALSE; |
972 | 972 | } |
@@ -984,12 +984,12 @@ discard block |
||
984 | 984 | */ |
985 | 985 | function readIniFile($filename) |
986 | 986 | { |
987 | - if(($filename = self::exists($filename)) === FALSE) |
|
987 | + if (($filename = self::exists($filename)) === FALSE) |
|
988 | 988 | { |
989 | 989 | return FALSE; |
990 | 990 | } |
991 | 991 | $arr = parse_ini_file($filename, TRUE); |
992 | - if(is_array($arr) && count($arr) > 0) |
|
992 | + if (is_array($arr) && count($arr) > 0) |
|
993 | 993 | { |
994 | 994 | return $arr; |
995 | 995 | } |
@@ -1015,7 +1015,7 @@ discard block |
||
1015 | 1015 | */ |
1016 | 1016 | function writeIniFile($filename, $arr) |
1017 | 1017 | { |
1018 | - if(!is_array($arr) || count($arr) == 0) |
|
1018 | + if (!is_array($arr) || count($arr) == 0) |
|
1019 | 1019 | { |
1020 | 1020 | return FALSE; |
1021 | 1021 | } |
@@ -1032,19 +1032,19 @@ discard block |
||
1032 | 1032 | function _makeIniBuff($arr) |
1033 | 1033 | { |
1034 | 1034 | $return = array(); |
1035 | - foreach($arr as $key => $val) |
|
1035 | + foreach ($arr as $key => $val) |
|
1036 | 1036 | { |
1037 | 1037 | // section |
1038 | - if(is_array($val)) |
|
1038 | + if (is_array($val)) |
|
1039 | 1039 | { |
1040 | 1040 | $return[] = sprintf("[%s]", $key); |
1041 | - foreach($val as $k => $v) |
|
1041 | + foreach ($val as $k => $v) |
|
1042 | 1042 | { |
1043 | 1043 | $return[] = sprintf("%s=\"%s\"", $k, $v); |
1044 | 1044 | } |
1045 | 1045 | // value |
1046 | 1046 | } |
1047 | - else if(is_object($val)) |
|
1047 | + else if (is_object($val)) |
|
1048 | 1048 | { |
1049 | 1049 | continue; |
1050 | 1050 | } |
@@ -1119,15 +1119,15 @@ discard block |
||
1119 | 1119 | function isWritableDir($path) |
1120 | 1120 | { |
1121 | 1121 | $path = self::getRealPath($path); |
1122 | - if(is_dir($path)==FALSE) |
|
1122 | + if (is_dir($path) == FALSE) |
|
1123 | 1123 | { |
1124 | 1124 | return FALSE; |
1125 | 1125 | } |
1126 | 1126 | |
1127 | - $checkFile = $path . '/_CheckWritableDir'; |
|
1127 | + $checkFile = $path.'/_CheckWritableDir'; |
|
1128 | 1128 | |
1129 | 1129 | $fp = fopen($checkFile, 'w'); |
1130 | - if(!is_resource($fp)) |
|
1130 | + if (!is_resource($fp)) |
|
1131 | 1131 | { |
1132 | 1132 | return FALSE; |
1133 | 1133 | } |
@@ -1145,7 +1145,7 @@ discard block |
||
1145 | 1145 | **/ |
1146 | 1146 | static public function clearStatCache($target, $include = false) |
1147 | 1147 | { |
1148 | - if(is_array($target)) |
|
1148 | + if (is_array($target)) |
|
1149 | 1149 | { |
1150 | 1150 | array_map('self::clearStatCache', $target); |
1151 | 1151 | return; |
@@ -1153,7 +1153,7 @@ discard block |
||
1153 | 1153 | |
1154 | 1154 | $target = self::getRealPath($target); |
1155 | 1155 | |
1156 | - if($include && self::isDir($target)) |
|
1156 | + if ($include && self::isDir($target)) |
|
1157 | 1157 | { |
1158 | 1158 | self::clearStatCache(self::readDir($target, '', false, true), $include); |
1159 | 1159 | } |
@@ -1171,27 +1171,27 @@ discard block |
||
1171 | 1171 | { |
1172 | 1172 | static $opcache = null; |
1173 | 1173 | |
1174 | - if($opcache === null) |
|
1174 | + if ($opcache === null) |
|
1175 | 1175 | { |
1176 | 1176 | $opcache = (function_exists('opcache_get_status') && function_exists('opcache_invalidate')); |
1177 | 1177 | } |
1178 | 1178 | |
1179 | - if($opcache === false) |
|
1179 | + if ($opcache === false) |
|
1180 | 1180 | { |
1181 | 1181 | return; |
1182 | 1182 | } |
1183 | 1183 | |
1184 | - if(is_array($target)) |
|
1184 | + if (is_array($target)) |
|
1185 | 1185 | { |
1186 | 1186 | array_map('self::invalidateOpcache', $target); |
1187 | 1187 | return; |
1188 | 1188 | } |
1189 | 1189 | |
1190 | - if(substr($target, -4) === '.php') |
|
1190 | + if (substr($target, -4) === '.php') |
|
1191 | 1191 | { |
1192 | 1192 | opcache_invalidate(self::getRealPath($target), $force); |
1193 | 1193 | } |
1194 | - else if($path = self::isDir($target)) |
|
1194 | + else if ($path = self::isDir($target)) |
|
1195 | 1195 | { |
1196 | 1196 | self::invalidateOpcache(self::readDir($path, '', false, true)); |
1197 | 1197 | } |