@@ -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,13 +548,13 @@ 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 | - if($key === 'observers') |
|
| 555 | + if ($key === 'observers') |
|
| 556 | 556 | { |
| 557 | - foreach($val as $observer) |
|
| 557 | + foreach ($val as $observer) |
|
| 558 | 558 | { |
| 559 | 559 | $oRequest->attach($observer); |
| 560 | 560 | } |
@@ -565,58 +565,58 @@ discard block |
||
| 565 | 565 | } |
| 566 | 566 | } |
| 567 | 567 | } |
| 568 | - if(method_exists($oRequest, 'setConfig')) |
|
| 568 | + if (method_exists($oRequest, 'setConfig')) |
|
| 569 | 569 | { |
| 570 | - if(extension_loaded('curl')) |
|
| 570 | + if (extension_loaded('curl')) |
|
| 571 | 571 | { |
| 572 | 572 | $oRequest->setConfig('adapter', 'curl'); |
| 573 | 573 | } |
| 574 | - elseif(version_compare(PHP_VERSION, '5.6', '<')) |
|
| 574 | + elseif (version_compare(PHP_VERSION, '5.6', '<')) |
|
| 575 | 575 | { |
| 576 | 576 | $oRequest->setConfig('ssl_verify_host', false); |
| 577 | 577 | } |
| 578 | - if(file_exists(_XE_PATH_ . 'libs/cacert/cacert.pem')) |
|
| 578 | + if (file_exists(_XE_PATH_.'libs/cacert/cacert.pem')) |
|
| 579 | 579 | { |
| 580 | - $oRequest->setConfig('ssl_cafile', _XE_PATH_ . 'libs/cacert/cacert.pem'); |
|
| 580 | + $oRequest->setConfig('ssl_cafile', _XE_PATH_.'libs/cacert/cacert.pem'); |
|
| 581 | 581 | } |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | - if(count($headers) > 0) |
|
| 584 | + if (count($headers) > 0) |
|
| 585 | 585 | { |
| 586 | - foreach($headers as $key => $val) |
|
| 586 | + foreach ($headers as $key => $val) |
|
| 587 | 587 | { |
| 588 | 588 | $oRequest->addHeader($key, $val); |
| 589 | 589 | } |
| 590 | 590 | } |
| 591 | 591 | $host = parse_url($url, PHP_URL_HOST); |
| 592 | - if($cookies[$host]) |
|
| 592 | + if ($cookies[$host]) |
|
| 593 | 593 | { |
| 594 | - foreach($cookies[$host] as $key => $val) |
|
| 594 | + foreach ($cookies[$host] as $key => $val) |
|
| 595 | 595 | { |
| 596 | 596 | $oRequest->addCookie($key, $val); |
| 597 | 597 | } |
| 598 | 598 | } |
| 599 | - if(count($post_data) > 0) |
|
| 599 | + if (count($post_data) > 0) |
|
| 600 | 600 | { |
| 601 | - foreach($post_data as $key => $val) |
|
| 601 | + foreach ($post_data as $key => $val) |
|
| 602 | 602 | { |
| 603 | 603 | $oRequest->addPostData($key, $val); |
| 604 | 604 | } |
| 605 | 605 | } |
| 606 | - if(!$content_type) |
|
| 606 | + if (!$content_type) |
|
| 607 | 607 | $oRequest->addHeader('Content-Type', 'text/html'); |
| 608 | 608 | else |
| 609 | 609 | $oRequest->addHeader('Content-Type', $content_type); |
| 610 | 610 | $oRequest->setMethod($method); |
| 611 | - if($body) |
|
| 611 | + if ($body) |
|
| 612 | 612 | $oRequest->setBody($body); |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | - if(method_exists($oRequest, 'setConfig')) |
|
| 615 | + if (method_exists($oRequest, 'setConfig')) |
|
| 616 | 616 | { |
| 617 | 617 | $oRequest->setConfig('timeout', $timeout); |
| 618 | 618 | } |
| 619 | - elseif(property_exists($oRequest, '_timeout')) |
|
| 619 | + elseif (property_exists($oRequest, '_timeout')) |
|
| 620 | 620 | { |
| 621 | 621 | $oRequest->_timeout = $timeout; |
| 622 | 622 | } |
@@ -626,25 +626,25 @@ discard block |
||
| 626 | 626 | $code = $oRequest->getResponseCode(); |
| 627 | 627 | $header = $oRequest->getResponseHeader(); |
| 628 | 628 | $response = $oRequest->getResponseBody(); |
| 629 | - if($c = $oRequest->getResponseCookies()) |
|
| 629 | + if ($c = $oRequest->getResponseCookies()) |
|
| 630 | 630 | { |
| 631 | - foreach($c as $k => $v) |
|
| 631 | + foreach ($c as $k => $v) |
|
| 632 | 632 | { |
| 633 | 633 | $cookies[$host][$v['name']] = $v['value']; |
| 634 | 634 | } |
| 635 | 635 | } |
| 636 | 636 | |
| 637 | - if($code > 300 && $code < 399 && $header['location']) |
|
| 637 | + if ($code > 300 && $code < 399 && $header['location']) |
|
| 638 | 638 | { |
| 639 | 639 | return self::getRemoteResource($header['location'], $body, $timeout, $method, $content_type, $headers, $cookies, $post_data); |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | - if($code != 200) |
|
| 642 | + if ($code != 200) |
|
| 643 | 643 | { |
| 644 | 644 | return; |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | - if(isset($request_config['store_body']) && !$request_config['store_body']) |
|
| 647 | + if (isset($request_config['store_body']) && !$request_config['store_body']) |
|
| 648 | 648 | { |
| 649 | 649 | return TRUE; |
| 650 | 650 | } |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | return $response; |
| 654 | 654 | } |
| 655 | 655 | } |
| 656 | - catch(Exception $e) |
|
| 656 | + catch (Exception $e) |
|
| 657 | 657 | { |
| 658 | 658 | return NULL; |
| 659 | 659 | } |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | { |
| 686 | 686 | $result = self::getRemoteResource($url, $body, $timeout, $method, $content_type, $headers, $cookies, $post_data, $request_config); |
| 687 | 687 | } |
| 688 | - catch(Exception $e) |
|
| 688 | + catch (Exception $e) |
|
| 689 | 689 | { |
| 690 | 690 | return FALSE; |
| 691 | 691 | } |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | function returnBytes($val) |
| 703 | 703 | { |
| 704 | 704 | $unit = strtoupper(substr($val, -1)); |
| 705 | - $val = (float)$val; |
|
| 705 | + $val = (float) $val; |
|
| 706 | 706 | |
| 707 | 707 | switch ($unit) |
| 708 | 708 | { |
@@ -725,13 +725,13 @@ discard block |
||
| 725 | 725 | $K64 = 65536; |
| 726 | 726 | $TWEAKFACTOR = 2.0; |
| 727 | 727 | $channels = $imageInfo['channels']; |
| 728 | - if(!$channels) |
|
| 728 | + if (!$channels) |
|
| 729 | 729 | { |
| 730 | 730 | $channels = 6; //for png |
| 731 | 731 | } |
| 732 | - $memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $channels / 8 + $K64 ) * $TWEAKFACTOR); |
|
| 732 | + $memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $channels / 8 + $K64) * $TWEAKFACTOR); |
|
| 733 | 733 | $availableMemory = self::returnBytes(ini_get('memory_limit')) - memory_get_usage(); |
| 734 | - if($availableMemory < $memoryNeeded) |
|
| 734 | + if ($availableMemory < $memoryNeeded) |
|
| 735 | 735 | { |
| 736 | 736 | return FALSE; |
| 737 | 737 | } |
@@ -758,30 +758,30 @@ discard block |
||
| 758 | 758 | } |
| 759 | 759 | |
| 760 | 760 | $target_file = self::getRealPath($target_file); |
| 761 | - if(!$resize_width) |
|
| 761 | + if (!$resize_width) |
|
| 762 | 762 | { |
| 763 | 763 | $resize_width = 100; |
| 764 | 764 | } |
| 765 | 765 | |
| 766 | - if(!$resize_height) |
|
| 766 | + if (!$resize_height) |
|
| 767 | 767 | { |
| 768 | 768 | $resize_height = $resize_width; |
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | // retrieve source image's information |
| 772 | 772 | $imageInfo = getimagesize($source_file); |
| 773 | - if(!self::checkMemoryLoadImage($imageInfo)) |
|
| 773 | + if (!self::checkMemoryLoadImage($imageInfo)) |
|
| 774 | 774 | { |
| 775 | 775 | return FALSE; |
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | list($width, $height, $type, $attrs) = $imageInfo; |
| 779 | - if($width < 1 || $height < 1) |
|
| 779 | + if ($width < 1 || $height < 1) |
|
| 780 | 780 | { |
| 781 | 781 | return; |
| 782 | 782 | } |
| 783 | 783 | |
| 784 | - switch($type) |
|
| 784 | + switch ($type) |
|
| 785 | 785 | { |
| 786 | 786 | case '1' : |
| 787 | 787 | $type = 'gif'; |
@@ -799,7 +799,7 @@ discard block |
||
| 799 | 799 | return; |
| 800 | 800 | } |
| 801 | 801 | |
| 802 | - if(!$target_type) |
|
| 802 | + if (!$target_type) |
|
| 803 | 803 | { |
| 804 | 804 | $target_type = $type; |
| 805 | 805 | } |
@@ -810,7 +810,7 @@ discard block |
||
| 810 | 810 | $height_per = ($resize_height > 0 && $height >= $resize_height) ? $resize_height / $height : 1; |
| 811 | 811 | |
| 812 | 812 | $per = NULL; |
| 813 | - if($thumbnail_type == 'ratio') |
|
| 813 | + if ($thumbnail_type == 'ratio') |
|
| 814 | 814 | { |
| 815 | 815 | $per = ($width_per > $height_per) ? $height_per : $width_per; |
| 816 | 816 | $resize_width = $width * $per; |
@@ -823,16 +823,16 @@ discard block |
||
| 823 | 823 | |
| 824 | 824 | // create temporary image with target size |
| 825 | 825 | $thumb = NULL; |
| 826 | - if(function_exists('imagecreateTRUEcolor')) |
|
| 826 | + if (function_exists('imagecreateTRUEcolor')) |
|
| 827 | 827 | { |
| 828 | 828 | $thumb = imagecreateTRUEcolor($resize_width, $resize_height); |
| 829 | 829 | } |
| 830 | - else if(function_exists('imagecreate')) |
|
| 830 | + else if (function_exists('imagecreate')) |
|
| 831 | 831 | { |
| 832 | 832 | $thumb = imagecreate($resize_width, $resize_height); |
| 833 | 833 | } |
| 834 | 834 | |
| 835 | - if(!$thumb) |
|
| 835 | + if (!$thumb) |
|
| 836 | 836 | { |
| 837 | 837 | return FALSE; |
| 838 | 838 | } |
@@ -841,37 +841,37 @@ discard block |
||
| 841 | 841 | |
| 842 | 842 | // create temporary image having original type |
| 843 | 843 | $source = NULL; |
| 844 | - switch($type) |
|
| 844 | + switch ($type) |
|
| 845 | 845 | { |
| 846 | 846 | case 'gif' : |
| 847 | - if(function_exists('imagecreatefromgif')) |
|
| 847 | + if (function_exists('imagecreatefromgif')) |
|
| 848 | 848 | { |
| 849 | 849 | $source = @imagecreatefromgif($source_file); |
| 850 | 850 | } |
| 851 | 851 | break; |
| 852 | 852 | case 'jpeg' : |
| 853 | 853 | case 'jpg' : |
| 854 | - if(function_exists('imagecreatefromjpeg')) |
|
| 854 | + if (function_exists('imagecreatefromjpeg')) |
|
| 855 | 855 | { |
| 856 | 856 | $source = @imagecreatefromjpeg($source_file); |
| 857 | 857 | } |
| 858 | 858 | break; |
| 859 | 859 | case 'png' : |
| 860 | - if(function_exists('imagecreatefrompng')) |
|
| 860 | + if (function_exists('imagecreatefrompng')) |
|
| 861 | 861 | { |
| 862 | 862 | $source = @imagecreatefrompng($source_file); |
| 863 | 863 | } |
| 864 | 864 | break; |
| 865 | 865 | case 'wbmp' : |
| 866 | 866 | case 'bmp' : |
| 867 | - if(function_exists('imagecreatefromwbmp')) |
|
| 867 | + if (function_exists('imagecreatefromwbmp')) |
|
| 868 | 868 | { |
| 869 | 869 | $source = @imagecreatefromwbmp($source_file); |
| 870 | 870 | } |
| 871 | 871 | break; |
| 872 | 872 | } |
| 873 | 873 | |
| 874 | - if(!$source) |
|
| 874 | + if (!$source) |
|
| 875 | 875 | { |
| 876 | 876 | imagedestroy($thumb); |
| 877 | 877 | return FALSE; |
@@ -883,13 +883,13 @@ discard block |
||
| 883 | 883 | |
| 884 | 884 | $x = 0; |
| 885 | 885 | $y = 0; |
| 886 | - if($thumbnail_type == 'crop') |
|
| 886 | + if ($thumbnail_type == 'crop') |
|
| 887 | 887 | { |
| 888 | 888 | $x = (int) ($resize_width / 2 - $new_width / 2); |
| 889 | 889 | $y = (int) ($resize_height / 2 - $new_height / 2); |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | - if(function_exists('imagecopyresampled')) |
|
| 892 | + if (function_exists('imagecopyresampled')) |
|
| 893 | 893 | { |
| 894 | 894 | imagecopyresampled($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height); |
| 895 | 895 | } |
@@ -903,30 +903,30 @@ discard block |
||
| 903 | 903 | |
| 904 | 904 | // write into the file |
| 905 | 905 | $output = NULL; |
| 906 | - switch($target_type) |
|
| 906 | + switch ($target_type) |
|
| 907 | 907 | { |
| 908 | 908 | case 'gif' : |
| 909 | - if(function_exists('imagegif')) |
|
| 909 | + if (function_exists('imagegif')) |
|
| 910 | 910 | { |
| 911 | 911 | $output = imagegif($thumb, $target_file); |
| 912 | 912 | } |
| 913 | 913 | break; |
| 914 | 914 | case 'jpeg' : |
| 915 | 915 | case 'jpg' : |
| 916 | - if(function_exists('imagejpeg')) |
|
| 916 | + if (function_exists('imagejpeg')) |
|
| 917 | 917 | { |
| 918 | 918 | $output = imagejpeg($thumb, $target_file, 100); |
| 919 | 919 | } |
| 920 | 920 | break; |
| 921 | 921 | case 'png' : |
| 922 | - if(function_exists('imagepng')) |
|
| 922 | + if (function_exists('imagepng')) |
|
| 923 | 923 | { |
| 924 | 924 | $output = imagepng($thumb, $target_file, 9); |
| 925 | 925 | } |
| 926 | 926 | break; |
| 927 | 927 | case 'wbmp' : |
| 928 | 928 | case 'bmp' : |
| 929 | - if(function_exists('imagewbmp')) |
|
| 929 | + if (function_exists('imagewbmp')) |
|
| 930 | 930 | { |
| 931 | 931 | $output = imagewbmp($thumb, $target_file, 100); |
| 932 | 932 | } |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | imagedestroy($thumb); |
| 937 | 937 | imagedestroy($source); |
| 938 | 938 | |
| 939 | - if(!$output) |
|
| 939 | + if (!$output) |
|
| 940 | 940 | { |
| 941 | 941 | return FALSE; |
| 942 | 942 | } |
@@ -954,12 +954,12 @@ discard block |
||
| 954 | 954 | */ |
| 955 | 955 | function readIniFile($filename) |
| 956 | 956 | { |
| 957 | - if(($filename = self::exists($filename)) === FALSE) |
|
| 957 | + if (($filename = self::exists($filename)) === FALSE) |
|
| 958 | 958 | { |
| 959 | 959 | return FALSE; |
| 960 | 960 | } |
| 961 | 961 | $arr = parse_ini_file($filename, TRUE); |
| 962 | - if(is_array($arr) && count($arr) > 0) |
|
| 962 | + if (is_array($arr) && count($arr) > 0) |
|
| 963 | 963 | { |
| 964 | 964 | return $arr; |
| 965 | 965 | } |
@@ -985,7 +985,7 @@ discard block |
||
| 985 | 985 | */ |
| 986 | 986 | function writeIniFile($filename, $arr) |
| 987 | 987 | { |
| 988 | - if(!is_array($arr) || count($arr) == 0) |
|
| 988 | + if (!is_array($arr) || count($arr) == 0) |
|
| 989 | 989 | { |
| 990 | 990 | return FALSE; |
| 991 | 991 | } |
@@ -1002,19 +1002,19 @@ discard block |
||
| 1002 | 1002 | function _makeIniBuff($arr) |
| 1003 | 1003 | { |
| 1004 | 1004 | $return = array(); |
| 1005 | - foreach($arr as $key => $val) |
|
| 1005 | + foreach ($arr as $key => $val) |
|
| 1006 | 1006 | { |
| 1007 | 1007 | // section |
| 1008 | - if(is_array($val)) |
|
| 1008 | + if (is_array($val)) |
|
| 1009 | 1009 | { |
| 1010 | 1010 | $return[] = sprintf("[%s]", $key); |
| 1011 | - foreach($val as $k => $v) |
|
| 1011 | + foreach ($val as $k => $v) |
|
| 1012 | 1012 | { |
| 1013 | 1013 | $return[] = sprintf("%s=\"%s\"", $k, $v); |
| 1014 | 1014 | } |
| 1015 | 1015 | // value |
| 1016 | 1016 | } |
| 1017 | - else if(is_object($val)) |
|
| 1017 | + else if (is_object($val)) |
|
| 1018 | 1018 | { |
| 1019 | 1019 | continue; |
| 1020 | 1020 | } |
@@ -1089,15 +1089,15 @@ discard block |
||
| 1089 | 1089 | function isWritableDir($path) |
| 1090 | 1090 | { |
| 1091 | 1091 | $path = self::getRealPath($path); |
| 1092 | - if(is_dir($path)==FALSE) |
|
| 1092 | + if (is_dir($path) == FALSE) |
|
| 1093 | 1093 | { |
| 1094 | 1094 | return FALSE; |
| 1095 | 1095 | } |
| 1096 | 1096 | |
| 1097 | - $checkFile = $path . '/_CheckWritableDir'; |
|
| 1097 | + $checkFile = $path.'/_CheckWritableDir'; |
|
| 1098 | 1098 | |
| 1099 | 1099 | $fp = fopen($checkFile, 'w'); |
| 1100 | - if(!is_resource($fp)) |
|
| 1100 | + if (!is_resource($fp)) |
|
| 1101 | 1101 | { |
| 1102 | 1102 | return FALSE; |
| 1103 | 1103 | } |