@@ -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"]) |
|
| 530 | + if ($parsed_url["host"]) |
|
| 531 | 531 | { |
| 532 | 532 | $oRequest = new HTTP_Request(__PROXY_SERVER__); |
| 533 | 533 | $oRequest->setMethod('POST'); |
@@ -537,13 +537,13 @@ discard block |
||
| 537 | 537 | { |
| 538 | 538 | $oRequest = new HTTP_Request($url); |
| 539 | 539 | |
| 540 | - if(count($request_config) && method_exists($oRequest, 'setConfig')) |
|
| 540 | + if (count($request_config) && method_exists($oRequest, 'setConfig')) |
|
| 541 | 541 | { |
| 542 | - foreach($request_config as $key=>$val) |
|
| 542 | + foreach ($request_config as $key=>$val) |
|
| 543 | 543 | { |
| 544 | - if($key === 'observers') |
|
| 544 | + if ($key === 'observers') |
|
| 545 | 545 | { |
| 546 | - foreach($val as $observer) |
|
| 546 | + foreach ($val as $observer) |
|
| 547 | 547 | { |
| 548 | 548 | $oRequest->attach($observer); |
| 549 | 549 | } |
@@ -554,57 +554,57 @@ discard block |
||
| 554 | 554 | } |
| 555 | 555 | } |
| 556 | 556 | } |
| 557 | - if(method_exists($oRequest, 'setConfig')) |
|
| 557 | + if (method_exists($oRequest, 'setConfig')) |
|
| 558 | 558 | { |
| 559 | - if(extension_loaded('curl')) |
|
| 559 | + if (extension_loaded('curl')) |
|
| 560 | 560 | { |
| 561 | 561 | $oRequest->setConfig('adapter', 'curl'); |
| 562 | 562 | } |
| 563 | - elseif(version_compare(PHP_VERSION, '5.6', '<')) |
|
| 563 | + elseif (version_compare(PHP_VERSION, '5.6', '<')) |
|
| 564 | 564 | { |
| 565 | 565 | $oRequest->setConfig('ssl_verify_host', false); |
| 566 | 566 | } |
| 567 | - if(file_exists(_XE_PATH_ . 'libs/cacert/cacert.pem')) |
|
| 567 | + if (file_exists(_XE_PATH_.'libs/cacert/cacert.pem')) |
|
| 568 | 568 | { |
| 569 | - $oRequest->setConfig('ssl_cafile', _XE_PATH_ . 'libs/cacert/cacert.pem'); |
|
| 569 | + $oRequest->setConfig('ssl_cafile', _XE_PATH_.'libs/cacert/cacert.pem'); |
|
| 570 | 570 | } |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | - if(count($headers) > 0) |
|
| 573 | + if (count($headers) > 0) |
|
| 574 | 574 | { |
| 575 | - foreach($headers as $key => $val) |
|
| 575 | + foreach ($headers as $key => $val) |
|
| 576 | 576 | { |
| 577 | 577 | $oRequest->addHeader($key, $val); |
| 578 | 578 | } |
| 579 | 579 | } |
| 580 | - if($cookies[$host]) |
|
| 580 | + if ($cookies[$host]) |
|
| 581 | 581 | { |
| 582 | - foreach($cookies[$host] as $key => $val) |
|
| 582 | + foreach ($cookies[$host] as $key => $val) |
|
| 583 | 583 | { |
| 584 | 584 | $oRequest->addCookie($key, $val); |
| 585 | 585 | } |
| 586 | 586 | } |
| 587 | - if(count($post_data) > 0) |
|
| 587 | + if (count($post_data) > 0) |
|
| 588 | 588 | { |
| 589 | - foreach($post_data as $key => $val) |
|
| 589 | + foreach ($post_data as $key => $val) |
|
| 590 | 590 | { |
| 591 | 591 | $oRequest->addPostData($key, $val); |
| 592 | 592 | } |
| 593 | 593 | } |
| 594 | - if(!$content_type) |
|
| 594 | + if (!$content_type) |
|
| 595 | 595 | $oRequest->addHeader('Content-Type', 'text/html'); |
| 596 | 596 | else |
| 597 | 597 | $oRequest->addHeader('Content-Type', $content_type); |
| 598 | 598 | $oRequest->setMethod($method); |
| 599 | - if($body) |
|
| 599 | + if ($body) |
|
| 600 | 600 | $oRequest->setBody($body); |
| 601 | 601 | } |
| 602 | 602 | |
| 603 | - if(method_exists($oRequest, 'setConfig')) |
|
| 603 | + if (method_exists($oRequest, 'setConfig')) |
|
| 604 | 604 | { |
| 605 | 605 | $oRequest->setConfig('timeout', $timeout); |
| 606 | 606 | } |
| 607 | - elseif(property_exists($oRequest, '_timeout')) |
|
| 607 | + elseif (property_exists($oRequest, '_timeout')) |
|
| 608 | 608 | { |
| 609 | 609 | $oRequest->_timeout = $timeout; |
| 610 | 610 | } |
@@ -614,25 +614,25 @@ discard block |
||
| 614 | 614 | $code = $oRequest->getResponseCode(); |
| 615 | 615 | $header = $oRequest->getResponseHeader(); |
| 616 | 616 | $response = $oRequest->getResponseBody(); |
| 617 | - if($c = $oRequest->getResponseCookies()) |
|
| 617 | + if ($c = $oRequest->getResponseCookies()) |
|
| 618 | 618 | { |
| 619 | - foreach($c as $k => $v) |
|
| 619 | + foreach ($c as $k => $v) |
|
| 620 | 620 | { |
| 621 | 621 | $cookies[$host][$v['name']] = $v['value']; |
| 622 | 622 | } |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | - if($code > 300 && $code < 399 && $header['location']) |
|
| 625 | + if ($code > 300 && $code < 399 && $header['location']) |
|
| 626 | 626 | { |
| 627 | 627 | return self::getRemoteResource($header['location'], $body, $timeout, $method, $content_type, $headers, $cookies, $post_data); |
| 628 | 628 | } |
| 629 | 629 | |
| 630 | - if($code != 200) |
|
| 630 | + if ($code != 200) |
|
| 631 | 631 | { |
| 632 | 632 | return; |
| 633 | 633 | } |
| 634 | 634 | |
| 635 | - if(isset($request_config['store_body']) && !$request_config['store_body']) |
|
| 635 | + if (isset($request_config['store_body']) && !$request_config['store_body']) |
|
| 636 | 636 | { |
| 637 | 637 | return TRUE; |
| 638 | 638 | } |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | return $response; |
| 642 | 642 | } |
| 643 | 643 | } |
| 644 | - catch(Exception $e) |
|
| 644 | + catch (Exception $e) |
|
| 645 | 645 | { |
| 646 | 646 | return NULL; |
| 647 | 647 | } |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | { |
| 674 | 674 | $result = self::getRemoteResource($url, $body, $timeout, $method, $content_type, $headers, $cookies, $post_data, $request_config); |
| 675 | 675 | } |
| 676 | - catch(Exception $e) |
|
| 676 | + catch (Exception $e) |
|
| 677 | 677 | { |
| 678 | 678 | return FALSE; |
| 679 | 679 | } |
@@ -690,7 +690,7 @@ discard block |
||
| 690 | 690 | function returnBytes($val) |
| 691 | 691 | { |
| 692 | 692 | $unit = strtoupper(substr($val, -1)); |
| 693 | - $val = (float)$val; |
|
| 693 | + $val = (float) $val; |
|
| 694 | 694 | |
| 695 | 695 | switch ($unit) |
| 696 | 696 | { |
@@ -713,13 +713,13 @@ discard block |
||
| 713 | 713 | $K64 = 65536; |
| 714 | 714 | $TWEAKFACTOR = 2.0; |
| 715 | 715 | $channels = $imageInfo['channels']; |
| 716 | - if(!$channels) |
|
| 716 | + if (!$channels) |
|
| 717 | 717 | { |
| 718 | 718 | $channels = 6; //for png |
| 719 | 719 | } |
| 720 | - $memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $channels / 8 + $K64 ) * $TWEAKFACTOR); |
|
| 720 | + $memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $channels / 8 + $K64) * $TWEAKFACTOR); |
|
| 721 | 721 | $availableMemory = self::returnBytes(ini_get('memory_limit')) - memory_get_usage(); |
| 722 | - if($availableMemory < $memoryNeeded) |
|
| 722 | + if ($availableMemory < $memoryNeeded) |
|
| 723 | 723 | { |
| 724 | 724 | return FALSE; |
| 725 | 725 | } |
@@ -746,30 +746,30 @@ discard block |
||
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | $target_file = self::getRealPath($target_file); |
| 749 | - if(!$resize_width) |
|
| 749 | + if (!$resize_width) |
|
| 750 | 750 | { |
| 751 | 751 | $resize_width = 100; |
| 752 | 752 | } |
| 753 | 753 | |
| 754 | - if(!$resize_height) |
|
| 754 | + if (!$resize_height) |
|
| 755 | 755 | { |
| 756 | 756 | $resize_height = $resize_width; |
| 757 | 757 | } |
| 758 | 758 | |
| 759 | 759 | // retrieve source image's information |
| 760 | 760 | $imageInfo = getimagesize($source_file); |
| 761 | - if(!self::checkMemoryLoadImage($imageInfo)) |
|
| 761 | + if (!self::checkMemoryLoadImage($imageInfo)) |
|
| 762 | 762 | { |
| 763 | 763 | return FALSE; |
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | list($width, $height, $type, $attrs) = $imageInfo; |
| 767 | - if($width < 1 || $height < 1) |
|
| 767 | + if ($width < 1 || $height < 1) |
|
| 768 | 768 | { |
| 769 | 769 | return; |
| 770 | 770 | } |
| 771 | 771 | |
| 772 | - switch($type) |
|
| 772 | + switch ($type) |
|
| 773 | 773 | { |
| 774 | 774 | case '1' : |
| 775 | 775 | $type = 'gif'; |
@@ -787,7 +787,7 @@ discard block |
||
| 787 | 787 | return; |
| 788 | 788 | } |
| 789 | 789 | |
| 790 | - if(!$target_type) |
|
| 790 | + if (!$target_type) |
|
| 791 | 791 | { |
| 792 | 792 | $target_type = $type; |
| 793 | 793 | } |
@@ -798,7 +798,7 @@ discard block |
||
| 798 | 798 | $height_per = ($resize_height > 0 && $height >= $resize_height) ? $resize_height / $height : 1; |
| 799 | 799 | |
| 800 | 800 | $per = NULL; |
| 801 | - if($thumbnail_type == 'ratio') |
|
| 801 | + if ($thumbnail_type == 'ratio') |
|
| 802 | 802 | { |
| 803 | 803 | $per = ($width_per > $height_per) ? $height_per : $width_per; |
| 804 | 804 | $resize_width = $width * $per; |
@@ -811,16 +811,16 @@ discard block |
||
| 811 | 811 | |
| 812 | 812 | // create temporary image with target size |
| 813 | 813 | $thumb = NULL; |
| 814 | - if(function_exists('imagecreateTRUEcolor')) |
|
| 814 | + if (function_exists('imagecreateTRUEcolor')) |
|
| 815 | 815 | { |
| 816 | 816 | $thumb = imagecreateTRUEcolor($resize_width, $resize_height); |
| 817 | 817 | } |
| 818 | - else if(function_exists('imagecreate')) |
|
| 818 | + else if (function_exists('imagecreate')) |
|
| 819 | 819 | { |
| 820 | 820 | $thumb = imagecreate($resize_width, $resize_height); |
| 821 | 821 | } |
| 822 | 822 | |
| 823 | - if(!$thumb) |
|
| 823 | + if (!$thumb) |
|
| 824 | 824 | { |
| 825 | 825 | return FALSE; |
| 826 | 826 | } |
@@ -829,37 +829,37 @@ discard block |
||
| 829 | 829 | |
| 830 | 830 | // create temporary image having original type |
| 831 | 831 | $source = NULL; |
| 832 | - switch($type) |
|
| 832 | + switch ($type) |
|
| 833 | 833 | { |
| 834 | 834 | case 'gif' : |
| 835 | - if(function_exists('imagecreatefromgif')) |
|
| 835 | + if (function_exists('imagecreatefromgif')) |
|
| 836 | 836 | { |
| 837 | 837 | $source = @imagecreatefromgif($source_file); |
| 838 | 838 | } |
| 839 | 839 | break; |
| 840 | 840 | case 'jpeg' : |
| 841 | 841 | case 'jpg' : |
| 842 | - if(function_exists('imagecreatefromjpeg')) |
|
| 842 | + if (function_exists('imagecreatefromjpeg')) |
|
| 843 | 843 | { |
| 844 | 844 | $source = @imagecreatefromjpeg($source_file); |
| 845 | 845 | } |
| 846 | 846 | break; |
| 847 | 847 | case 'png' : |
| 848 | - if(function_exists('imagecreatefrompng')) |
|
| 848 | + if (function_exists('imagecreatefrompng')) |
|
| 849 | 849 | { |
| 850 | 850 | $source = @imagecreatefrompng($source_file); |
| 851 | 851 | } |
| 852 | 852 | break; |
| 853 | 853 | case 'wbmp' : |
| 854 | 854 | case 'bmp' : |
| 855 | - if(function_exists('imagecreatefromwbmp')) |
|
| 855 | + if (function_exists('imagecreatefromwbmp')) |
|
| 856 | 856 | { |
| 857 | 857 | $source = @imagecreatefromwbmp($source_file); |
| 858 | 858 | } |
| 859 | 859 | break; |
| 860 | 860 | } |
| 861 | 861 | |
| 862 | - if(!$source) |
|
| 862 | + if (!$source) |
|
| 863 | 863 | { |
| 864 | 864 | imagedestroy($thumb); |
| 865 | 865 | return FALSE; |
@@ -871,13 +871,13 @@ discard block |
||
| 871 | 871 | |
| 872 | 872 | $x = 0; |
| 873 | 873 | $y = 0; |
| 874 | - if($thumbnail_type == 'crop') |
|
| 874 | + if ($thumbnail_type == 'crop') |
|
| 875 | 875 | { |
| 876 | 876 | $x = (int) ($resize_width / 2 - $new_width / 2); |
| 877 | 877 | $y = (int) ($resize_height / 2 - $new_height / 2); |
| 878 | 878 | } |
| 879 | 879 | |
| 880 | - if(function_exists('imagecopyresampled')) |
|
| 880 | + if (function_exists('imagecopyresampled')) |
|
| 881 | 881 | { |
| 882 | 882 | imagecopyresampled($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height); |
| 883 | 883 | } |
@@ -891,30 +891,30 @@ discard block |
||
| 891 | 891 | |
| 892 | 892 | // write into the file |
| 893 | 893 | $output = NULL; |
| 894 | - switch($target_type) |
|
| 894 | + switch ($target_type) |
|
| 895 | 895 | { |
| 896 | 896 | case 'gif' : |
| 897 | - if(function_exists('imagegif')) |
|
| 897 | + if (function_exists('imagegif')) |
|
| 898 | 898 | { |
| 899 | 899 | $output = imagegif($thumb, $target_file); |
| 900 | 900 | } |
| 901 | 901 | break; |
| 902 | 902 | case 'jpeg' : |
| 903 | 903 | case 'jpg' : |
| 904 | - if(function_exists('imagejpeg')) |
|
| 904 | + if (function_exists('imagejpeg')) |
|
| 905 | 905 | { |
| 906 | 906 | $output = imagejpeg($thumb, $target_file, 100); |
| 907 | 907 | } |
| 908 | 908 | break; |
| 909 | 909 | case 'png' : |
| 910 | - if(function_exists('imagepng')) |
|
| 910 | + if (function_exists('imagepng')) |
|
| 911 | 911 | { |
| 912 | 912 | $output = imagepng($thumb, $target_file, 9); |
| 913 | 913 | } |
| 914 | 914 | break; |
| 915 | 915 | case 'wbmp' : |
| 916 | 916 | case 'bmp' : |
| 917 | - if(function_exists('imagewbmp')) |
|
| 917 | + if (function_exists('imagewbmp')) |
|
| 918 | 918 | { |
| 919 | 919 | $output = imagewbmp($thumb, $target_file, 100); |
| 920 | 920 | } |
@@ -924,7 +924,7 @@ discard block |
||
| 924 | 924 | imagedestroy($thumb); |
| 925 | 925 | imagedestroy($source); |
| 926 | 926 | |
| 927 | - if(!$output) |
|
| 927 | + if (!$output) |
|
| 928 | 928 | { |
| 929 | 929 | return FALSE; |
| 930 | 930 | } |
@@ -942,12 +942,12 @@ discard block |
||
| 942 | 942 | */ |
| 943 | 943 | function readIniFile($filename) |
| 944 | 944 | { |
| 945 | - if(($filename = self::exists($filename)) === FALSE) |
|
| 945 | + if (($filename = self::exists($filename)) === FALSE) |
|
| 946 | 946 | { |
| 947 | 947 | return FALSE; |
| 948 | 948 | } |
| 949 | 949 | $arr = parse_ini_file($filename, TRUE); |
| 950 | - if(is_array($arr) && count($arr) > 0) |
|
| 950 | + if (is_array($arr) && count($arr) > 0) |
|
| 951 | 951 | { |
| 952 | 952 | return $arr; |
| 953 | 953 | } |
@@ -973,7 +973,7 @@ discard block |
||
| 973 | 973 | */ |
| 974 | 974 | function writeIniFile($filename, $arr) |
| 975 | 975 | { |
| 976 | - if(!is_array($arr) || count($arr) == 0) |
|
| 976 | + if (!is_array($arr) || count($arr) == 0) |
|
| 977 | 977 | { |
| 978 | 978 | return FALSE; |
| 979 | 979 | } |
@@ -990,19 +990,19 @@ discard block |
||
| 990 | 990 | function _makeIniBuff($arr) |
| 991 | 991 | { |
| 992 | 992 | $return = array(); |
| 993 | - foreach($arr as $key => $val) |
|
| 993 | + foreach ($arr as $key => $val) |
|
| 994 | 994 | { |
| 995 | 995 | // section |
| 996 | - if(is_array($val)) |
|
| 996 | + if (is_array($val)) |
|
| 997 | 997 | { |
| 998 | 998 | $return[] = sprintf("[%s]", $key); |
| 999 | - foreach($val as $k => $v) |
|
| 999 | + foreach ($val as $k => $v) |
|
| 1000 | 1000 | { |
| 1001 | 1001 | $return[] = sprintf("%s=\"%s\"", $k, $v); |
| 1002 | 1002 | } |
| 1003 | 1003 | // value |
| 1004 | 1004 | } |
| 1005 | - else if(is_object($val)) |
|
| 1005 | + else if (is_object($val)) |
|
| 1006 | 1006 | { |
| 1007 | 1007 | continue; |
| 1008 | 1008 | } |
@@ -1077,15 +1077,15 @@ discard block |
||
| 1077 | 1077 | function isWritableDir($path) |
| 1078 | 1078 | { |
| 1079 | 1079 | $path = self::getRealPath($path); |
| 1080 | - if(is_dir($path)==FALSE) |
|
| 1080 | + if (is_dir($path) == FALSE) |
|
| 1081 | 1081 | { |
| 1082 | 1082 | return FALSE; |
| 1083 | 1083 | } |
| 1084 | 1084 | |
| 1085 | - $checkFile = $path . '/_CheckWritableDir'; |
|
| 1085 | + $checkFile = $path.'/_CheckWritableDir'; |
|
| 1086 | 1086 | |
| 1087 | 1087 | $fp = fopen($checkFile, 'w'); |
| 1088 | - if(!is_resource($fp)) |
|
| 1088 | + if (!is_resource($fp)) |
|
| 1089 | 1089 | { |
| 1090 | 1090 | return FALSE; |
| 1091 | 1091 | } |
@@ -74,14 +74,12 @@ discard block |
||
| 74 | 74 | if(is_dir($source_dir . $file)) |
| 75 | 75 | { |
| 76 | 76 | self::copyDir($source_dir . $file, $target_dir . $file, $type); |
| 77 | - } |
|
| 78 | - else |
|
| 77 | + } else |
|
| 79 | 78 | { |
| 80 | 79 | if($type == 'force') |
| 81 | 80 | { |
| 82 | 81 | @unlink($target_dir . $file); |
| 83 | - } |
|
| 84 | - else |
|
| 82 | + } else |
|
| 85 | 83 | { |
| 86 | 84 | if(!file_exists($target_dir . $file)) |
| 87 | 85 | { |
@@ -379,15 +377,13 @@ discard block |
||
| 379 | 377 | if(is_dir($target)) |
| 380 | 378 | { |
| 381 | 379 | self::removeDir($target); |
| 382 | - } |
|
| 383 | - else |
|
| 380 | + } else |
|
| 384 | 381 | { |
| 385 | 382 | unlink($target); |
| 386 | 383 | } |
| 387 | 384 | } |
| 388 | 385 | rmdir($path); |
| 389 | - } |
|
| 390 | - else |
|
| 386 | + } else |
|
| 391 | 387 | { |
| 392 | 388 | unlink($path); |
| 393 | 389 | } |
@@ -454,16 +450,16 @@ discard block |
||
| 454 | 450 | if(is_dir($target)) |
| 455 | 451 | { |
| 456 | 452 | self::removeFilesInDir($target); |
| 457 | - } |
|
| 458 | - else |
|
| 453 | + } else |
|
| 459 | 454 | { |
| 460 | 455 | unlink($target); |
| 461 | 456 | } |
| 462 | 457 | } |
| 463 | - } |
|
| 464 | - else |
|
| 458 | + } else |
|
| 465 | 459 | { |
| 466 | - if(self::exists($path)) unlink($path); |
|
| 460 | + if(self::exists($path)) { |
|
| 461 | + unlink($path); |
|
| 462 | + } |
|
| 467 | 463 | } |
| 468 | 464 | |
| 469 | 465 | } |
@@ -532,8 +528,7 @@ discard block |
||
| 532 | 528 | $oRequest = new HTTP_Request(__PROXY_SERVER__); |
| 533 | 529 | $oRequest->setMethod('POST'); |
| 534 | 530 | $oRequest->addPostData('arg', serialize(array('Destination' => $url, 'method' => $method, 'body' => $body, 'content_type' => $content_type, "headers" => $headers, "post_data" => $post_data))); |
| 535 | - } |
|
| 536 | - else |
|
| 531 | + } else |
|
| 537 | 532 | { |
| 538 | 533 | $oRequest = new HTTP_Request($url); |
| 539 | 534 | |
@@ -547,8 +542,7 @@ discard block |
||
| 547 | 542 | { |
| 548 | 543 | $oRequest->attach($observer); |
| 549 | 544 | } |
| 550 | - } |
|
| 551 | - else |
|
| 545 | + } else |
|
| 552 | 546 | { |
| 553 | 547 | $oRequest->setConfig($key, $val); |
| 554 | 548 | } |
@@ -559,8 +553,7 @@ discard block |
||
| 559 | 553 | if(extension_loaded('curl')) |
| 560 | 554 | { |
| 561 | 555 | $oRequest->setConfig('adapter', 'curl'); |
| 562 | - } |
|
| 563 | - elseif(version_compare(PHP_VERSION, '5.6', '<')) |
|
| 556 | + } elseif(version_compare(PHP_VERSION, '5.6', '<')) |
|
| 564 | 557 | { |
| 565 | 558 | $oRequest->setConfig('ssl_verify_host', false); |
| 566 | 559 | } |
@@ -591,20 +584,21 @@ discard block |
||
| 591 | 584 | $oRequest->addPostData($key, $val); |
| 592 | 585 | } |
| 593 | 586 | } |
| 594 | - if(!$content_type) |
|
| 595 | - $oRequest->addHeader('Content-Type', 'text/html'); |
|
| 596 | - else |
|
| 597 | - $oRequest->addHeader('Content-Type', $content_type); |
|
| 587 | + if(!$content_type) { |
|
| 588 | + $oRequest->addHeader('Content-Type', 'text/html'); |
|
| 589 | + } else { |
|
| 590 | + $oRequest->addHeader('Content-Type', $content_type); |
|
| 591 | + } |
|
| 598 | 592 | $oRequest->setMethod($method); |
| 599 | - if($body) |
|
| 600 | - $oRequest->setBody($body); |
|
| 593 | + if($body) { |
|
| 594 | + $oRequest->setBody($body); |
|
| 595 | + } |
|
| 601 | 596 | } |
| 602 | 597 | |
| 603 | 598 | if(method_exists($oRequest, 'setConfig')) |
| 604 | 599 | { |
| 605 | 600 | $oRequest->setConfig('timeout', $timeout); |
| 606 | - } |
|
| 607 | - elseif(property_exists($oRequest, '_timeout')) |
|
| 601 | + } elseif(property_exists($oRequest, '_timeout')) |
|
| 608 | 602 | { |
| 609 | 603 | $oRequest->_timeout = $timeout; |
| 610 | 604 | } |
@@ -635,13 +629,11 @@ discard block |
||
| 635 | 629 | if(isset($request_config['store_body']) && !$request_config['store_body']) |
| 636 | 630 | { |
| 637 | 631 | return TRUE; |
| 638 | - } |
|
| 639 | - else |
|
| 632 | + } else |
|
| 640 | 633 | { |
| 641 | 634 | return $response; |
| 642 | 635 | } |
| 643 | - } |
|
| 644 | - catch(Exception $e) |
|
| 636 | + } catch(Exception $e) |
|
| 645 | 637 | { |
| 646 | 638 | return NULL; |
| 647 | 639 | } |
@@ -672,8 +664,7 @@ discard block |
||
| 672 | 664 | try |
| 673 | 665 | { |
| 674 | 666 | $result = self::getRemoteResource($url, $body, $timeout, $method, $content_type, $headers, $cookies, $post_data, $request_config); |
| 675 | - } |
|
| 676 | - catch(Exception $e) |
|
| 667 | + } catch(Exception $e) |
|
| 677 | 668 | { |
| 678 | 669 | return FALSE; |
| 679 | 670 | } |
@@ -803,8 +794,7 @@ discard block |
||
| 803 | 794 | $per = ($width_per > $height_per) ? $height_per : $width_per; |
| 804 | 795 | $resize_width = $width * $per; |
| 805 | 796 | $resize_height = $height * $per; |
| 806 | - } |
|
| 807 | - else |
|
| 797 | + } else |
|
| 808 | 798 | { |
| 809 | 799 | $per = ($width_per < $height_per) ? $height_per : $width_per; |
| 810 | 800 | } |
@@ -814,8 +804,7 @@ discard block |
||
| 814 | 804 | if(function_exists('imagecreateTRUEcolor')) |
| 815 | 805 | { |
| 816 | 806 | $thumb = imagecreateTRUEcolor($resize_width, $resize_height); |
| 817 | - } |
|
| 818 | - else if(function_exists('imagecreate')) |
|
| 807 | + } else if(function_exists('imagecreate')) |
|
| 819 | 808 | { |
| 820 | 809 | $thumb = imagecreate($resize_width, $resize_height); |
| 821 | 810 | } |
@@ -880,8 +869,7 @@ discard block |
||
| 880 | 869 | if(function_exists('imagecopyresampled')) |
| 881 | 870 | { |
| 882 | 871 | imagecopyresampled($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height); |
| 883 | - } |
|
| 884 | - else |
|
| 872 | + } else |
|
| 885 | 873 | { |
| 886 | 874 | imagecopyresized($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height); |
| 887 | 875 | } |
@@ -950,8 +938,7 @@ discard block |
||
| 950 | 938 | if(is_array($arr) && count($arr) > 0) |
| 951 | 939 | { |
| 952 | 940 | return $arr; |
| 953 | - } |
|
| 954 | - else |
|
| 941 | + } else |
|
| 955 | 942 | { |
| 956 | 943 | return array(); |
| 957 | 944 | } |
@@ -1001,12 +988,10 @@ discard block |
||
| 1001 | 988 | $return[] = sprintf("%s=\"%s\"", $k, $v); |
| 1002 | 989 | } |
| 1003 | 990 | // value |
| 1004 | - } |
|
| 1005 | - else if(is_object($val)) |
|
| 991 | + } else if(is_object($val)) |
|
| 1006 | 992 | { |
| 1007 | 993 | continue; |
| 1008 | - } |
|
| 1009 | - else |
|
| 994 | + } else |
|
| 1010 | 995 | { |
| 1011 | 996 | $return[] = sprintf("%s=\"%s\"", $key, $val); |
| 1012 | 997 | } |