@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param string $target_dir Path of target dir |
35 | 35 | * @param string $filter Regex to filter files. If file matches this regex, the file is not copied. |
36 | 36 | * @param string $type If set as 'force'. Even if the file exists in target, the file is copied. |
37 | - * @return void |
|
37 | + * @return false|null |
|
38 | 38 | */ |
39 | 39 | function copyDir($source_dir, $target_dir, $filter = null, $type = null) |
40 | 40 | { |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * This function creates directories recursively, which means that if ancestors of the target directory does not exist, they will be created too. |
278 | 278 | * |
279 | 279 | * @param string $path_string Path of target directory |
280 | - * @return bool TRUE if success. It might return nothing when ftp is used and connection to the ftp address failed. |
|
280 | + * @return boolean|null TRUE if success. It might return nothing when ftp is used and connection to the ftp address failed. |
|
281 | 281 | */ |
282 | 282 | function makeDir($path_string) |
283 | 283 | { |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | * @param string $url The address of the target file |
668 | 668 | * @param string $target_filename The location to store |
669 | 669 | * @param string $body HTTP request body |
670 | - * @param string $timeout Connection timeout |
|
670 | + * @param integer $timeout Connection timeout |
|
671 | 671 | * @param string $method GET/POST |
672 | 672 | * @param string $content_type Content type header of HTTP request |
673 | 673 | * @param string[] $headers Headers key value array. |
@@ -700,8 +700,8 @@ discard block |
||
700 | 700 | * Convert size in string into numeric value |
701 | 701 | * |
702 | 702 | * @see self::filesize() |
703 | - * @param $val Size in string (ex., 10, 10K, 10M, 10G ) |
|
704 | - * @return int converted size |
|
703 | + * @param string $val Size in string (ex., 10, 10K, 10M, 10G ) |
|
704 | + * @return double converted size |
|
705 | 705 | */ |
706 | 706 | function returnBytes($val) |
707 | 707 | { |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | * @param string $target_type If $target_type is set (gif, jpg, png, bmp), result image will be saved as target type |
753 | 753 | * @param string $thumbnail_type Thumbnail type(crop, ratio) |
754 | 754 | * @param bool $thumbnail_transparent If $target_type is png, set background set transparent color |
755 | - * @return bool TRUE: success, FALSE: failed |
|
755 | + * @return null|boolean TRUE: success, FALSE: failed |
|
756 | 756 | */ |
757 | 757 | function createImageFile($source_file, $target_file, $resize_width = 0, $resize_height = 0, $target_type = '', $thumbnail_type = 'crop', $thumbnail_transparent = FALSE) |
758 | 758 | { |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | * Check file exists. |
1083 | 1083 | * |
1084 | 1084 | * @param string $filename Target file name |
1085 | - * @return bool Returns FALSE if the file does not exists, or Returns full path file(string). |
|
1085 | + * @return string|false Returns FALSE if the file does not exists, or Returns full path file(string). |
|
1086 | 1086 | */ |
1087 | 1087 | function exists($filename) |
1088 | 1088 | { |
@@ -1093,8 +1093,8 @@ discard block |
||
1093 | 1093 | /** |
1094 | 1094 | * Check it is dir |
1095 | 1095 | * |
1096 | - * @param string $dir Target dir path |
|
1097 | - * @return bool Returns FALSE if the dir is not dir, or Returns full path of dir(string). |
|
1096 | + * @param string $path |
|
1097 | + * @return string|false Returns FALSE if the dir is not dir, or Returns full path of dir(string). |
|
1098 | 1098 | */ |
1099 | 1099 | function isDir($path) |
1100 | 1100 | { |
@@ -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 | { |
@@ -729,13 +729,13 @@ discard block |
||
729 | 729 | $K64 = 65536; |
730 | 730 | $TWEAKFACTOR = 2.0; |
731 | 731 | $channels = $imageInfo['channels']; |
732 | - if(!$channels) |
|
732 | + if (!$channels) |
|
733 | 733 | { |
734 | 734 | $channels = 6; //for png |
735 | 735 | } |
736 | - $memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $channels / 8 + $K64 ) * $TWEAKFACTOR); |
|
736 | + $memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $channels / 8 + $K64) * $TWEAKFACTOR); |
|
737 | 737 | $availableMemory = self::returnBytes(ini_get('memory_limit')) - memory_get_usage(); |
738 | - if($availableMemory < $memoryNeeded) |
|
738 | + if ($availableMemory < $memoryNeeded) |
|
739 | 739 | { |
740 | 740 | return FALSE; |
741 | 741 | } |
@@ -763,30 +763,30 @@ discard block |
||
763 | 763 | } |
764 | 764 | |
765 | 765 | $target_file = self::getRealPath($target_file); |
766 | - if(!$resize_width) |
|
766 | + if (!$resize_width) |
|
767 | 767 | { |
768 | 768 | $resize_width = 100; |
769 | 769 | } |
770 | 770 | |
771 | - if(!$resize_height) |
|
771 | + if (!$resize_height) |
|
772 | 772 | { |
773 | 773 | $resize_height = $resize_width; |
774 | 774 | } |
775 | 775 | |
776 | 776 | // retrieve source image's information |
777 | 777 | $imageInfo = getimagesize($source_file); |
778 | - if(!self::checkMemoryLoadImage($imageInfo)) |
|
778 | + if (!self::checkMemoryLoadImage($imageInfo)) |
|
779 | 779 | { |
780 | 780 | return FALSE; |
781 | 781 | } |
782 | 782 | |
783 | 783 | list($width, $height, $type, $attrs) = $imageInfo; |
784 | - if($width < 1 || $height < 1) |
|
784 | + if ($width < 1 || $height < 1) |
|
785 | 785 | { |
786 | 786 | return; |
787 | 787 | } |
788 | 788 | |
789 | - switch($type) |
|
789 | + switch ($type) |
|
790 | 790 | { |
791 | 791 | case '1' : |
792 | 792 | $type = 'gif'; |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | return; |
805 | 805 | } |
806 | 806 | |
807 | - if(!$target_type) |
|
807 | + if (!$target_type) |
|
808 | 808 | { |
809 | 809 | $target_type = $type; |
810 | 810 | } |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | $height_per = ($resize_height > 0 && $height >= $resize_height) ? $resize_height / $height : 1; |
816 | 816 | |
817 | 817 | $per = NULL; |
818 | - if($thumbnail_type == 'ratio') |
|
818 | + if ($thumbnail_type == 'ratio') |
|
819 | 819 | { |
820 | 820 | $per = ($width_per > $height_per) ? $height_per : $width_per; |
821 | 821 | $resize_width = $width * $per; |
@@ -828,30 +828,30 @@ discard block |
||
828 | 828 | |
829 | 829 | // create temporary image with target size |
830 | 830 | $thumb = NULL; |
831 | - if(function_exists('imagecreateTRUEcolor')) |
|
831 | + if (function_exists('imagecreateTRUEcolor')) |
|
832 | 832 | { |
833 | 833 | $thumb = imagecreateTRUEcolor($resize_width, $resize_height); |
834 | 834 | } |
835 | - else if(function_exists('imagecreate')) |
|
835 | + else if (function_exists('imagecreate')) |
|
836 | 836 | { |
837 | 837 | $thumb = imagecreate($resize_width, $resize_height); |
838 | 838 | } |
839 | 839 | |
840 | - if(!$thumb) |
|
840 | + if (!$thumb) |
|
841 | 841 | { |
842 | 842 | return FALSE; |
843 | 843 | } |
844 | 844 | |
845 | - if(function_exists('imagecolorallocatealpha') && $target_type == 'png' && $thumbnail_transparent) |
|
845 | + if (function_exists('imagecolorallocatealpha') && $target_type == 'png' && $thumbnail_transparent) |
|
846 | 846 | { |
847 | 847 | imagefill($thumb, 0, 0, imagecolorallocatealpha($thumb, 0, 0, 0, 127)); |
848 | 848 | |
849 | - if(function_exists('imagesavealpha')) |
|
849 | + if (function_exists('imagesavealpha')) |
|
850 | 850 | { |
851 | 851 | imagesavealpha($thumb, TRUE); |
852 | 852 | } |
853 | 853 | |
854 | - if(function_exists('imagealphablending')) |
|
854 | + if (function_exists('imagealphablending')) |
|
855 | 855 | { |
856 | 856 | imagealphablending($thumb, TRUE); |
857 | 857 | } |
@@ -863,37 +863,37 @@ discard block |
||
863 | 863 | |
864 | 864 | // create temporary image having original type |
865 | 865 | $source = NULL; |
866 | - switch($type) |
|
866 | + switch ($type) |
|
867 | 867 | { |
868 | 868 | case 'gif' : |
869 | - if(function_exists('imagecreatefromgif')) |
|
869 | + if (function_exists('imagecreatefromgif')) |
|
870 | 870 | { |
871 | 871 | $source = @imagecreatefromgif($source_file); |
872 | 872 | } |
873 | 873 | break; |
874 | 874 | case 'jpeg' : |
875 | 875 | case 'jpg' : |
876 | - if(function_exists('imagecreatefromjpeg')) |
|
876 | + if (function_exists('imagecreatefromjpeg')) |
|
877 | 877 | { |
878 | 878 | $source = @imagecreatefromjpeg($source_file); |
879 | 879 | } |
880 | 880 | break; |
881 | 881 | case 'png' : |
882 | - if(function_exists('imagecreatefrompng')) |
|
882 | + if (function_exists('imagecreatefrompng')) |
|
883 | 883 | { |
884 | 884 | $source = @imagecreatefrompng($source_file); |
885 | 885 | } |
886 | 886 | break; |
887 | 887 | case 'wbmp' : |
888 | 888 | case 'bmp' : |
889 | - if(function_exists('imagecreatefromwbmp')) |
|
889 | + if (function_exists('imagecreatefromwbmp')) |
|
890 | 890 | { |
891 | 891 | $source = @imagecreatefromwbmp($source_file); |
892 | 892 | } |
893 | 893 | break; |
894 | 894 | } |
895 | 895 | |
896 | - if(!$source) |
|
896 | + if (!$source) |
|
897 | 897 | { |
898 | 898 | imagedestroy($thumb); |
899 | 899 | return FALSE; |
@@ -905,13 +905,13 @@ discard block |
||
905 | 905 | |
906 | 906 | $x = 0; |
907 | 907 | $y = 0; |
908 | - if($thumbnail_type == 'crop') |
|
908 | + if ($thumbnail_type == 'crop') |
|
909 | 909 | { |
910 | 910 | $x = (int) ($resize_width / 2 - $new_width / 2); |
911 | 911 | $y = (int) ($resize_height / 2 - $new_height / 2); |
912 | 912 | } |
913 | 913 | |
914 | - if(function_exists('imagecopyresampled')) |
|
914 | + if (function_exists('imagecopyresampled')) |
|
915 | 915 | { |
916 | 916 | imagecopyresampled($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height); |
917 | 917 | } |
@@ -925,30 +925,30 @@ discard block |
||
925 | 925 | |
926 | 926 | // write into the file |
927 | 927 | $output = NULL; |
928 | - switch($target_type) |
|
928 | + switch ($target_type) |
|
929 | 929 | { |
930 | 930 | case 'gif' : |
931 | - if(function_exists('imagegif')) |
|
931 | + if (function_exists('imagegif')) |
|
932 | 932 | { |
933 | 933 | $output = imagegif($thumb, $target_file); |
934 | 934 | } |
935 | 935 | break; |
936 | 936 | case 'jpeg' : |
937 | 937 | case 'jpg' : |
938 | - if(function_exists('imagejpeg')) |
|
938 | + if (function_exists('imagejpeg')) |
|
939 | 939 | { |
940 | 940 | $output = imagejpeg($thumb, $target_file, 100); |
941 | 941 | } |
942 | 942 | break; |
943 | 943 | case 'png' : |
944 | - if(function_exists('imagepng')) |
|
944 | + if (function_exists('imagepng')) |
|
945 | 945 | { |
946 | 946 | $output = imagepng($thumb, $target_file, 9); |
947 | 947 | } |
948 | 948 | break; |
949 | 949 | case 'wbmp' : |
950 | 950 | case 'bmp' : |
951 | - if(function_exists('imagewbmp')) |
|
951 | + if (function_exists('imagewbmp')) |
|
952 | 952 | { |
953 | 953 | $output = imagewbmp($thumb, $target_file, 100); |
954 | 954 | } |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | imagedestroy($thumb); |
959 | 959 | imagedestroy($source); |
960 | 960 | |
961 | - if(!$output) |
|
961 | + if (!$output) |
|
962 | 962 | { |
963 | 963 | return FALSE; |
964 | 964 | } |
@@ -976,12 +976,12 @@ discard block |
||
976 | 976 | */ |
977 | 977 | function readIniFile($filename) |
978 | 978 | { |
979 | - if(($filename = self::exists($filename)) === FALSE) |
|
979 | + if (($filename = self::exists($filename)) === FALSE) |
|
980 | 980 | { |
981 | 981 | return FALSE; |
982 | 982 | } |
983 | 983 | $arr = parse_ini_file($filename, TRUE); |
984 | - if(is_array($arr) && count($arr) > 0) |
|
984 | + if (is_array($arr) && count($arr) > 0) |
|
985 | 985 | { |
986 | 986 | return $arr; |
987 | 987 | } |
@@ -1007,7 +1007,7 @@ discard block |
||
1007 | 1007 | */ |
1008 | 1008 | function writeIniFile($filename, $arr) |
1009 | 1009 | { |
1010 | - if(!is_array($arr) || count($arr) == 0) |
|
1010 | + if (!is_array($arr) || count($arr) == 0) |
|
1011 | 1011 | { |
1012 | 1012 | return FALSE; |
1013 | 1013 | } |
@@ -1024,19 +1024,19 @@ discard block |
||
1024 | 1024 | function _makeIniBuff($arr) |
1025 | 1025 | { |
1026 | 1026 | $return = array(); |
1027 | - foreach($arr as $key => $val) |
|
1027 | + foreach ($arr as $key => $val) |
|
1028 | 1028 | { |
1029 | 1029 | // section |
1030 | - if(is_array($val)) |
|
1030 | + if (is_array($val)) |
|
1031 | 1031 | { |
1032 | 1032 | $return[] = sprintf("[%s]", $key); |
1033 | - foreach($val as $k => $v) |
|
1033 | + foreach ($val as $k => $v) |
|
1034 | 1034 | { |
1035 | 1035 | $return[] = sprintf("%s=\"%s\"", $k, $v); |
1036 | 1036 | } |
1037 | 1037 | // value |
1038 | 1038 | } |
1039 | - else if(is_object($val)) |
|
1039 | + else if (is_object($val)) |
|
1040 | 1040 | { |
1041 | 1041 | continue; |
1042 | 1042 | } |
@@ -1111,15 +1111,15 @@ discard block |
||
1111 | 1111 | function isWritableDir($path) |
1112 | 1112 | { |
1113 | 1113 | $path = self::getRealPath($path); |
1114 | - if(is_dir($path)==FALSE) |
|
1114 | + if (is_dir($path) == FALSE) |
|
1115 | 1115 | { |
1116 | 1116 | return FALSE; |
1117 | 1117 | } |
1118 | 1118 | |
1119 | - $checkFile = $path . '/_CheckWritableDir'; |
|
1119 | + $checkFile = $path.'/_CheckWritableDir'; |
|
1120 | 1120 | |
1121 | 1121 | $fp = fopen($checkFile, 'w'); |
1122 | - if(!is_resource($fp)) |
|
1122 | + if (!is_resource($fp)) |
|
1123 | 1123 | { |
1124 | 1124 | return FALSE; |
1125 | 1125 | } |
@@ -1137,7 +1137,7 @@ discard block |
||
1137 | 1137 | **/ |
1138 | 1138 | static public function clearStatCache($target, $include = false) |
1139 | 1139 | { |
1140 | - if(is_array($target)) |
|
1140 | + if (is_array($target)) |
|
1141 | 1141 | { |
1142 | 1142 | array_map('self::clearStatCache', $target); |
1143 | 1143 | return; |
@@ -1145,7 +1145,7 @@ discard block |
||
1145 | 1145 | |
1146 | 1146 | $target = self::getRealPath($target); |
1147 | 1147 | |
1148 | - if($include && self::isDir($target)) |
|
1148 | + if ($include && self::isDir($target)) |
|
1149 | 1149 | { |
1150 | 1150 | self::clearStatCache(self::readDir($target, '', false, true), $include); |
1151 | 1151 | } |
@@ -1163,27 +1163,27 @@ discard block |
||
1163 | 1163 | { |
1164 | 1164 | static $opcache = null; |
1165 | 1165 | |
1166 | - if($opcache === null) |
|
1166 | + if ($opcache === null) |
|
1167 | 1167 | { |
1168 | 1168 | $opcache = (function_exists('opcache_get_status') && function_exists('opcache_invalidate')); |
1169 | 1169 | } |
1170 | 1170 | |
1171 | - if($opcache === false) |
|
1171 | + if ($opcache === false) |
|
1172 | 1172 | { |
1173 | 1173 | return; |
1174 | 1174 | } |
1175 | 1175 | |
1176 | - if(is_array($target)) |
|
1176 | + if (is_array($target)) |
|
1177 | 1177 | { |
1178 | 1178 | array_map('self::invalidateOpcache', $target); |
1179 | 1179 | return; |
1180 | 1180 | } |
1181 | 1181 | |
1182 | - if(substr($target, -4) === '.php') |
|
1182 | + if (substr($target, -4) === '.php') |
|
1183 | 1183 | { |
1184 | 1184 | opcache_invalidate(self::getRealPath($target), $force); |
1185 | 1185 | } |
1186 | - else if($path = self::isDir($target)) |
|
1186 | + else if ($path = self::isDir($target)) |
|
1187 | 1187 | { |
1188 | 1188 | self::invalidateOpcache(self::readDir($path, '', false, true)); |
1189 | 1189 | } |
@@ -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 | { |
@@ -381,15 +379,13 @@ discard block |
||
381 | 379 | if(is_dir($target)) |
382 | 380 | { |
383 | 381 | self::removeDir($target); |
384 | - } |
|
385 | - else |
|
382 | + } else |
|
386 | 383 | { |
387 | 384 | unlink($target); |
388 | 385 | } |
389 | 386 | } |
390 | 387 | rmdir($path); |
391 | - } |
|
392 | - else |
|
388 | + } else |
|
393 | 389 | { |
394 | 390 | unlink($path); |
395 | 391 | } |
@@ -456,16 +452,16 @@ discard block |
||
456 | 452 | if(is_dir($target)) |
457 | 453 | { |
458 | 454 | self::removeFilesInDir($target); |
459 | - } |
|
460 | - else |
|
455 | + } else |
|
461 | 456 | { |
462 | 457 | unlink($target); |
463 | 458 | } |
464 | 459 | } |
465 | - } |
|
466 | - else |
|
460 | + } else |
|
467 | 461 | { |
468 | - if(self::exists($path)) unlink($path); |
|
462 | + if(self::exists($path)) { |
|
463 | + unlink($path); |
|
464 | + } |
|
469 | 465 | } |
470 | 466 | |
471 | 467 | } |
@@ -535,8 +531,7 @@ discard block |
||
535 | 531 | $oRequest = new HTTP_Request(__PROXY_SERVER__); |
536 | 532 | $oRequest->setMethod('POST'); |
537 | 533 | $oRequest->addPostData('arg', serialize(array('Destination' => $url, 'method' => $method, 'body' => $body, 'content_type' => $content_type, "headers" => $headers, "post_data" => $post_data))); |
538 | - } |
|
539 | - else |
|
534 | + } else |
|
540 | 535 | { |
541 | 536 | $oRequest = new HTTP_Request($url); |
542 | 537 | |
@@ -560,8 +555,7 @@ discard block |
||
560 | 555 | { |
561 | 556 | $oRequest->attach($observer); |
562 | 557 | } |
563 | - } |
|
564 | - else |
|
558 | + } else |
|
565 | 559 | { |
566 | 560 | $oRequest->setConfig($key, $val); |
567 | 561 | } |
@@ -572,8 +566,7 @@ discard block |
||
572 | 566 | if(extension_loaded('curl')) |
573 | 567 | { |
574 | 568 | $oRequest->setConfig('adapter', 'curl'); |
575 | - } |
|
576 | - elseif(version_compare(PHP_VERSION, '5.6', '<')) |
|
569 | + } elseif(version_compare(PHP_VERSION, '5.6', '<')) |
|
577 | 570 | { |
578 | 571 | $oRequest->setConfig('ssl_verify_host', false); |
579 | 572 | } |
@@ -605,20 +598,21 @@ discard block |
||
605 | 598 | $oRequest->addPostData($key, $val); |
606 | 599 | } |
607 | 600 | } |
608 | - if(!$content_type) |
|
609 | - $oRequest->addHeader('Content-Type', 'text/html'); |
|
610 | - else |
|
611 | - $oRequest->addHeader('Content-Type', $content_type); |
|
601 | + if(!$content_type) { |
|
602 | + $oRequest->addHeader('Content-Type', 'text/html'); |
|
603 | + } else { |
|
604 | + $oRequest->addHeader('Content-Type', $content_type); |
|
605 | + } |
|
612 | 606 | $oRequest->setMethod($method); |
613 | - if($body) |
|
614 | - $oRequest->setBody($body); |
|
607 | + if($body) { |
|
608 | + $oRequest->setBody($body); |
|
609 | + } |
|
615 | 610 | } |
616 | 611 | |
617 | 612 | if(method_exists($oRequest, 'setConfig')) |
618 | 613 | { |
619 | 614 | $oRequest->setConfig('timeout', $timeout); |
620 | - } |
|
621 | - elseif(property_exists($oRequest, '_timeout')) |
|
615 | + } elseif(property_exists($oRequest, '_timeout')) |
|
622 | 616 | { |
623 | 617 | $oRequest->_timeout = $timeout; |
624 | 618 | } |
@@ -649,13 +643,11 @@ discard block |
||
649 | 643 | if(isset($request_config['store_body']) && !$request_config['store_body']) |
650 | 644 | { |
651 | 645 | return TRUE; |
652 | - } |
|
653 | - else |
|
646 | + } else |
|
654 | 647 | { |
655 | 648 | return $response; |
656 | 649 | } |
657 | - } |
|
658 | - catch(Exception $e) |
|
650 | + } catch(Exception $e) |
|
659 | 651 | { |
660 | 652 | return NULL; |
661 | 653 | } |
@@ -688,8 +680,7 @@ discard block |
||
688 | 680 | $result = self::getRemoteResource($url, $body, $timeout, $method, $content_type, $headers, $cookies, $post_data, $request_config); |
689 | 681 | self::clearStatCache($target_filename); |
690 | 682 | self::invalidateOpcache($target_filename); |
691 | - } |
|
692 | - catch(Exception $e) |
|
683 | + } catch(Exception $e) |
|
693 | 684 | { |
694 | 685 | return FALSE; |
695 | 686 | } |
@@ -820,8 +811,7 @@ discard block |
||
820 | 811 | $per = ($width_per > $height_per) ? $height_per : $width_per; |
821 | 812 | $resize_width = $width * $per; |
822 | 813 | $resize_height = $height * $per; |
823 | - } |
|
824 | - else |
|
814 | + } else |
|
825 | 815 | { |
826 | 816 | $per = ($width_per < $height_per) ? $height_per : $width_per; |
827 | 817 | } |
@@ -831,8 +821,7 @@ discard block |
||
831 | 821 | if(function_exists('imagecreateTRUEcolor')) |
832 | 822 | { |
833 | 823 | $thumb = imagecreateTRUEcolor($resize_width, $resize_height); |
834 | - } |
|
835 | - else if(function_exists('imagecreate')) |
|
824 | + } else if(function_exists('imagecreate')) |
|
836 | 825 | { |
837 | 826 | $thumb = imagecreate($resize_width, $resize_height); |
838 | 827 | } |
@@ -855,8 +844,7 @@ discard block |
||
855 | 844 | { |
856 | 845 | imagealphablending($thumb, TRUE); |
857 | 846 | } |
858 | - } |
|
859 | - else |
|
847 | + } else |
|
860 | 848 | { |
861 | 849 | imagefilledrectangle($thumb, 0, 0, $resize_width - 1, $resize_height - 1, imagecolorallocate($thumb, 255, 255, 255)); |
862 | 850 | } |
@@ -914,8 +902,7 @@ discard block |
||
914 | 902 | if(function_exists('imagecopyresampled')) |
915 | 903 | { |
916 | 904 | imagecopyresampled($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height); |
917 | - } |
|
918 | - else |
|
905 | + } else |
|
919 | 906 | { |
920 | 907 | imagecopyresized($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height); |
921 | 908 | } |
@@ -984,8 +971,7 @@ discard block |
||
984 | 971 | if(is_array($arr) && count($arr) > 0) |
985 | 972 | { |
986 | 973 | return $arr; |
987 | - } |
|
988 | - else |
|
974 | + } else |
|
989 | 975 | { |
990 | 976 | return array(); |
991 | 977 | } |
@@ -1035,12 +1021,10 @@ discard block |
||
1035 | 1021 | $return[] = sprintf("%s=\"%s\"", $k, $v); |
1036 | 1022 | } |
1037 | 1023 | // value |
1038 | - } |
|
1039 | - else if(is_object($val)) |
|
1024 | + } else if(is_object($val)) |
|
1040 | 1025 | { |
1041 | 1026 | continue; |
1042 | - } |
|
1043 | - else |
|
1027 | + } else |
|
1044 | 1028 | { |
1045 | 1029 | $return[] = sprintf("%s=\"%s\"", $key, $val); |
1046 | 1030 | } |
@@ -1182,8 +1166,7 @@ discard block |
||
1182 | 1166 | if(substr($target, -4) === '.php') |
1183 | 1167 | { |
1184 | 1168 | opcache_invalidate(self::getRealPath($target), $force); |
1185 | - } |
|
1186 | - else if($path = self::isDir($target)) |
|
1169 | + } else if($path = self::isDir($target)) |
|
1187 | 1170 | { |
1188 | 1171 | self::invalidateOpcache(self::readDir($path, '', false, true)); |
1189 | 1172 | } |
@@ -26,29 +26,29 @@ discard block |
||
26 | 26 | $args = new stdClass(); |
27 | 27 | $args->module_srl = $module_srl; |
28 | 28 | $columnList = array('file_srl', 'uploaded_filename'); |
29 | - $output = executeQueryArray('file.getModuleFiles',$args, $columnList); |
|
30 | - if(!$output) return $output; |
|
29 | + $output = executeQueryArray('file.getModuleFiles', $args, $columnList); |
|
30 | + if (!$output) return $output; |
|
31 | 31 | $files = $output->data; |
32 | 32 | // Remove from the DB |
33 | 33 | $args->module_srl = $module_srl; |
34 | 34 | $output = executeQuery('file.deleteModuleFiles', $args); |
35 | - if(!$output->toBool()) return $output; |
|
35 | + if (!$output->toBool()) return $output; |
|
36 | 36 | // Remove the file |
37 | - FileHandler::removeDir( sprintf("./files/attach/images/%s/", $module_srl) ) ; |
|
38 | - FileHandler::removeDir( sprintf("./files/attach/binaries/%s/", $module_srl) ); |
|
37 | + FileHandler::removeDir(sprintf("./files/attach/images/%s/", $module_srl)); |
|
38 | + FileHandler::removeDir(sprintf("./files/attach/binaries/%s/", $module_srl)); |
|
39 | 39 | // Remove the file list obtained from the DB |
40 | 40 | $path = array(); |
41 | 41 | $cnt = count($files); |
42 | - for($i=0;$i<$cnt;$i++) |
|
42 | + for ($i = 0; $i < $cnt; $i++) |
|
43 | 43 | { |
44 | 44 | $uploaded_filename = $files[$i]->uploaded_filename; |
45 | 45 | FileHandler::removeFile($uploaded_filename); |
46 | 46 | |
47 | 47 | $path_info = pathinfo($uploaded_filename); |
48 | - if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
48 | + if (!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
49 | 49 | } |
50 | 50 | // Remove a file directory of the document |
51 | - for($i=0;$i<count($path);$i++) FileHandler::removeBlankDir($path[$i]); |
|
51 | + for ($i = 0; $i < count($path); $i++) FileHandler::removeBlankDir($path[$i]); |
|
52 | 52 | |
53 | 53 | return $output; |
54 | 54 | } |
@@ -62,23 +62,23 @@ discard block |
||
62 | 62 | { |
63 | 63 | // An error appears if no document is selected |
64 | 64 | $cart = Context::get('cart'); |
65 | - if(!$cart) return $this->stop('msg_file_cart_is_null'); |
|
66 | - if(!is_array($cart)) $file_srl_list= explode('|@|', $cart); |
|
65 | + if (!$cart) return $this->stop('msg_file_cart_is_null'); |
|
66 | + if (!is_array($cart)) $file_srl_list = explode('|@|', $cart); |
|
67 | 67 | else $file_srl_list = $cart; |
68 | 68 | $file_count = count($file_srl_list); |
69 | - if(!$file_count) return $this->stop('msg_file_cart_is_null'); |
|
69 | + if (!$file_count) return $this->stop('msg_file_cart_is_null'); |
|
70 | 70 | |
71 | 71 | $oFileController = getController('file'); |
72 | 72 | // Delete the post |
73 | - for($i=0;$i<$file_count;$i++) |
|
73 | + for ($i = 0; $i < $file_count; $i++) |
|
74 | 74 | { |
75 | 75 | $file_srl = trim($file_srl_list[$i]); |
76 | - if(!$file_srl) continue; |
|
76 | + if (!$file_srl) continue; |
|
77 | 77 | |
78 | 78 | $oFileController->deleteFile($file_srl); |
79 | 79 | } |
80 | 80 | |
81 | - $this->setMessage( sprintf(Context::getLang('msg_checked_file_is_deleted'), $file_count) ); |
|
81 | + $this->setMessage(sprintf(Context::getLang('msg_checked_file_is_deleted'), $file_count)); |
|
82 | 82 | |
83 | 83 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispFileAdminList'); |
84 | 84 | $this->setRedirectUrl($returnUrl); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $config->allow_thumbnail_transparent = Context::get('allow_thumbnail_transparent'); |
103 | 103 | // Create module Controller object |
104 | 104 | $oModuleController = getController('module'); |
105 | - $output = $oModuleController->insertModuleConfig('file',$config); |
|
105 | + $output = $oModuleController->insertModuleConfig('file', $config); |
|
106 | 106 | |
107 | 107 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispFileAdminConfig'); |
108 | 108 | return $this->setRedirectUrl($returnUrl, $output); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | // Get variables |
119 | 119 | $module_srl = Context::get('target_module_srl'); |
120 | 120 | // In order to configure multiple modules at once |
121 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
121 | + if (preg_match('/^([0-9,]+)$/', $module_srl)) $module_srl = explode(',', $module_srl); |
|
122 | 122 | else $module_srl = array($module_srl); |
123 | 123 | |
124 | 124 | $download_grant = Context::get('download_grant'); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $file_config->allowed_filetypes = str_replace(' ', '', Context::get('allowed_filetypes')); |
133 | 133 | $file_config->allow_thumbnail_transparent = Context::get('allow_thumbnail_transparent'); |
134 | 134 | |
135 | - if(!is_array($download_grant)) $file_config->download_grant = explode('|@|',$download_grant); |
|
135 | + if (!is_array($download_grant)) $file_config->download_grant = explode('|@|', $download_grant); |
|
136 | 136 | else $file_config->download_grant = $download_grant; |
137 | 137 | |
138 | 138 | //관리자가 허용한 첨부파일의 사이즈가 php.ini의 값보다 큰지 확인하기 - by ovclas |
@@ -142,15 +142,15 @@ discard block |
||
142 | 142 | $iniUploadMaxSize = FileHandler::returnbytes(ini_get('upload_max_filesize')); |
143 | 143 | $iniMinSzie = min($iniPostMaxSize, $iniUploadMaxSize); |
144 | 144 | |
145 | - if($userFileAllowSize > $iniMinSzie || $userAttachAllowSize > $iniMinSzie) |
|
145 | + if ($userFileAllowSize > $iniMinSzie || $userAttachAllowSize > $iniMinSzie) |
|
146 | 146 | return new BaseObject(-1, 'input size over than config in php.ini'); |
147 | 147 | |
148 | 148 | $oModuleController = getController('module'); |
149 | - for($i=0;$i<count($module_srl);$i++) |
|
149 | + for ($i = 0; $i < count($module_srl); $i++) |
|
150 | 150 | { |
151 | 151 | $srl = trim($module_srl[$i]); |
152 | - if(!$srl) continue; |
|
153 | - $oModuleController->insertModulePartConfig('file',$srl,$file_config); |
|
152 | + if (!$srl) continue; |
|
153 | + $oModuleController->insertModulePartConfig('file', $srl, $file_config); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | $this->setError(-1); |
@@ -167,16 +167,16 @@ discard block |
||
167 | 167 | */ |
168 | 168 | function procFileAdminAddCart() |
169 | 169 | { |
170 | - $file_srl = (int)Context::get('file_srl'); |
|
170 | + $file_srl = (int) Context::get('file_srl'); |
|
171 | 171 | //$fileSrlList = array(500, 502); |
172 | 172 | |
173 | 173 | $oFileModel = getModel('file'); |
174 | 174 | $output = $oFileModel->getFile($file_srl); |
175 | 175 | //$output = $oFileModel->getFile($fileSrlList); |
176 | 176 | |
177 | - if($output->file_srl) |
|
177 | + if ($output->file_srl) |
|
178 | 178 | { |
179 | - if($_SESSION['file_management'][$output->file_srl]) unset($_SESSION['file_management'][$output->file_srl]); |
|
179 | + if ($_SESSION['file_management'][$output->file_srl]) unset($_SESSION['file_management'][$output->file_srl]); |
|
180 | 180 | else $_SESSION['file_management'][$output->file_srl] = true; |
181 | 181 | } |
182 | 182 | } |
@@ -27,12 +27,16 @@ discard block |
||
27 | 27 | $args->module_srl = $module_srl; |
28 | 28 | $columnList = array('file_srl', 'uploaded_filename'); |
29 | 29 | $output = executeQueryArray('file.getModuleFiles',$args, $columnList); |
30 | - if(!$output) return $output; |
|
30 | + if(!$output) { |
|
31 | + return $output; |
|
32 | + } |
|
31 | 33 | $files = $output->data; |
32 | 34 | // Remove from the DB |
33 | 35 | $args->module_srl = $module_srl; |
34 | 36 | $output = executeQuery('file.deleteModuleFiles', $args); |
35 | - if(!$output->toBool()) return $output; |
|
37 | + if(!$output->toBool()) { |
|
38 | + return $output; |
|
39 | + } |
|
36 | 40 | // Remove the file |
37 | 41 | FileHandler::removeDir( sprintf("./files/attach/images/%s/", $module_srl) ) ; |
38 | 42 | FileHandler::removeDir( sprintf("./files/attach/binaries/%s/", $module_srl) ); |
@@ -45,10 +49,14 @@ discard block |
||
45 | 49 | FileHandler::removeFile($uploaded_filename); |
46 | 50 | |
47 | 51 | $path_info = pathinfo($uploaded_filename); |
48 | - if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
52 | + if(!in_array($path_info['dirname'], $path)) { |
|
53 | + $path[] = $path_info['dirname']; |
|
54 | + } |
|
49 | 55 | } |
50 | 56 | // Remove a file directory of the document |
51 | - for($i=0;$i<count($path);$i++) FileHandler::removeBlankDir($path[$i]); |
|
57 | + for($i=0;$i<count($path);$i++) { |
|
58 | + FileHandler::removeBlankDir($path[$i]); |
|
59 | + } |
|
52 | 60 | |
53 | 61 | return $output; |
54 | 62 | } |
@@ -62,18 +70,27 @@ discard block |
||
62 | 70 | { |
63 | 71 | // An error appears if no document is selected |
64 | 72 | $cart = Context::get('cart'); |
65 | - if(!$cart) return $this->stop('msg_file_cart_is_null'); |
|
66 | - if(!is_array($cart)) $file_srl_list= explode('|@|', $cart); |
|
67 | - else $file_srl_list = $cart; |
|
73 | + if(!$cart) { |
|
74 | + return $this->stop('msg_file_cart_is_null'); |
|
75 | + } |
|
76 | + if(!is_array($cart)) { |
|
77 | + $file_srl_list= explode('|@|', $cart); |
|
78 | + } else { |
|
79 | + $file_srl_list = $cart; |
|
80 | + } |
|
68 | 81 | $file_count = count($file_srl_list); |
69 | - if(!$file_count) return $this->stop('msg_file_cart_is_null'); |
|
82 | + if(!$file_count) { |
|
83 | + return $this->stop('msg_file_cart_is_null'); |
|
84 | + } |
|
70 | 85 | |
71 | 86 | $oFileController = getController('file'); |
72 | 87 | // Delete the post |
73 | 88 | for($i=0;$i<$file_count;$i++) |
74 | 89 | { |
75 | 90 | $file_srl = trim($file_srl_list[$i]); |
76 | - if(!$file_srl) continue; |
|
91 | + if(!$file_srl) { |
|
92 | + continue; |
|
93 | + } |
|
77 | 94 | |
78 | 95 | $oFileController->deleteFile($file_srl); |
79 | 96 | } |
@@ -118,8 +135,11 @@ discard block |
||
118 | 135 | // Get variables |
119 | 136 | $module_srl = Context::get('target_module_srl'); |
120 | 137 | // In order to configure multiple modules at once |
121 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
122 | - else $module_srl = array($module_srl); |
|
138 | + if(preg_match('/^([0-9,]+)$/',$module_srl)) { |
|
139 | + $module_srl = explode(',',$module_srl); |
|
140 | + } else { |
|
141 | + $module_srl = array($module_srl); |
|
142 | + } |
|
123 | 143 | |
124 | 144 | $download_grant = Context::get('download_grant'); |
125 | 145 | |
@@ -132,8 +152,11 @@ discard block |
||
132 | 152 | $file_config->allowed_filetypes = str_replace(' ', '', Context::get('allowed_filetypes')); |
133 | 153 | $file_config->allow_thumbnail_transparent = Context::get('allow_thumbnail_transparent'); |
134 | 154 | |
135 | - if(!is_array($download_grant)) $file_config->download_grant = explode('|@|',$download_grant); |
|
136 | - else $file_config->download_grant = $download_grant; |
|
155 | + if(!is_array($download_grant)) { |
|
156 | + $file_config->download_grant = explode('|@|',$download_grant); |
|
157 | + } else { |
|
158 | + $file_config->download_grant = $download_grant; |
|
159 | + } |
|
137 | 160 | |
138 | 161 | //관리자가 허용한 첨부파일의 사이즈가 php.ini의 값보다 큰지 확인하기 - by ovclas |
139 | 162 | $userFileAllowSize = FileHandler::returnbytes($file_config->allowed_filesize.'M'); |
@@ -142,14 +165,17 @@ discard block |
||
142 | 165 | $iniUploadMaxSize = FileHandler::returnbytes(ini_get('upload_max_filesize')); |
143 | 166 | $iniMinSzie = min($iniPostMaxSize, $iniUploadMaxSize); |
144 | 167 | |
145 | - if($userFileAllowSize > $iniMinSzie || $userAttachAllowSize > $iniMinSzie) |
|
146 | - return new BaseObject(-1, 'input size over than config in php.ini'); |
|
168 | + if($userFileAllowSize > $iniMinSzie || $userAttachAllowSize > $iniMinSzie) { |
|
169 | + return new BaseObject(-1, 'input size over than config in php.ini'); |
|
170 | + } |
|
147 | 171 | |
148 | 172 | $oModuleController = getController('module'); |
149 | 173 | for($i=0;$i<count($module_srl);$i++) |
150 | 174 | { |
151 | 175 | $srl = trim($module_srl[$i]); |
152 | - if(!$srl) continue; |
|
176 | + if(!$srl) { |
|
177 | + continue; |
|
178 | + } |
|
153 | 179 | $oModuleController->insertModulePartConfig('file',$srl,$file_config); |
154 | 180 | } |
155 | 181 | |
@@ -176,8 +202,11 @@ discard block |
||
176 | 202 | |
177 | 203 | if($output->file_srl) |
178 | 204 | { |
179 | - if($_SESSION['file_management'][$output->file_srl]) unset($_SESSION['file_management'][$output->file_srl]); |
|
180 | - else $_SESSION['file_management'][$output->file_srl] = true; |
|
205 | + if($_SESSION['file_management'][$output->file_srl]) { |
|
206 | + unset($_SESSION['file_management'][$output->file_srl]); |
|
207 | + } else { |
|
208 | + $_SESSION['file_management'][$output->file_srl] = true; |
|
209 | + } |
|
181 | 210 | } |
182 | 211 | } |
183 | 212 | } |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | $mid = Context::get('mid'); |
30 | 30 | $editor_sequence = Context::get('editor_sequence'); |
31 | 31 | $upload_target_srl = Context::get('upload_target_srl'); |
32 | - if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
32 | + if (!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
33 | 33 | |
34 | - if($upload_target_srl) |
|
34 | + if ($upload_target_srl) |
|
35 | 35 | { |
36 | 36 | $oDocumentModel = getModel('document'); |
37 | 37 | $oCommentModel = getModel('comment'); |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | $oDocument = $oDocumentModel->getDocument($upload_target_srl); |
41 | 41 | |
42 | 42 | // comment 권한 확인 |
43 | - if(!$oDocument->isExists()) |
|
43 | + if (!$oDocument->isExists()) |
|
44 | 44 | { |
45 | 45 | $oComment = $oCommentModel->getComment($upload_target_srl); |
46 | - if($oComment->isExists() && $oComment->isSecret() && !$oComment->isGranted()) |
|
46 | + if ($oComment->isExists() && $oComment->isSecret() && !$oComment->isGranted()) |
|
47 | 47 | { |
48 | 48 | return new BaseObject(-1, 'msg_not_permitted'); |
49 | 49 | } |
@@ -52,34 +52,34 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | // document 권한 확인 |
55 | - if($oDocument->isExists() && $oDocument->isSecret() && !$oDocument->isGranted()) |
|
55 | + if ($oDocument->isExists() && $oDocument->isSecret() && !$oDocument->isGranted()) |
|
56 | 56 | { |
57 | 57 | return new BaseObject(-1, 'msg_not_permitted'); |
58 | 58 | } |
59 | 59 | |
60 | 60 | // 모듈 권한 확인 |
61 | - if($oDocument->isExists()) |
|
61 | + if ($oDocument->isExists()) |
|
62 | 62 | { |
63 | 63 | $grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($oDocument->get('module_srl')), $logged_info); |
64 | - if(!$grant->access) |
|
64 | + if (!$grant->access) |
|
65 | 65 | { |
66 | 66 | return new BaseObject(-1, 'msg_not_permitted'); |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | 70 | $tmp_files = $this->getFiles($upload_target_srl); |
71 | - if(!$tmp_files) $tmp_files = array(); |
|
71 | + if (!$tmp_files) $tmp_files = array(); |
|
72 | 72 | |
73 | - foreach($tmp_files as $file_info) |
|
73 | + foreach ($tmp_files as $file_info) |
|
74 | 74 | { |
75 | - if(!$file_info->file_srl) continue; |
|
75 | + if (!$file_info->file_srl) continue; |
|
76 | 76 | |
77 | 77 | $obj = new stdClass; |
78 | 78 | $obj->file_srl = $file_info->file_srl; |
79 | 79 | $obj->source_filename = $file_info->source_filename; |
80 | 80 | $obj->file_size = $file_info->file_size; |
81 | 81 | $obj->disp_file_size = FileHandler::filesize($file_info->file_size); |
82 | - if($file_info->direct_download=='N') $obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid, $file_info->module_srl); |
|
82 | + if ($file_info->direct_download == 'N') $obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid, $file_info->module_srl); |
|
83 | 83 | else $obj->download_url = str_replace('./', '', $file_info->uploaded_filename); |
84 | 84 | $obj->direct_download = $file_info->direct_download; |
85 | 85 | $obj->cover_image = ($file_info->cover_image === 'Y') ? true : false; |
@@ -99,17 +99,17 @@ discard block |
||
99 | 99 | //$config = $oModuleModel->getModuleInfoByMid($mid); //perhaps config varialbles not used |
100 | 100 | |
101 | 101 | $file_config = $this->getUploadConfig(); |
102 | - $left_size = $file_config->allowed_attach_size*1024*1024 - $attached_size; |
|
102 | + $left_size = $file_config->allowed_attach_size * 1024 * 1024 - $attached_size; |
|
103 | 103 | // Settings of required information |
104 | 104 | $attached_size = FileHandler::filesize($attached_size); |
105 | - $allowed_attach_size = FileHandler::filesize($file_config->allowed_attach_size*1024*1024); |
|
106 | - $allowed_filesize = FileHandler::filesize($file_config->allowed_filesize*1024*1024); |
|
105 | + $allowed_attach_size = FileHandler::filesize($file_config->allowed_attach_size * 1024 * 1024); |
|
106 | + $allowed_filesize = FileHandler::filesize($file_config->allowed_filesize * 1024 * 1024); |
|
107 | 107 | $allowed_filetypes = $file_config->allowed_filetypes; |
108 | - $this->add("files",$files); |
|
109 | - $this->add("editor_sequence",$editor_sequence); |
|
110 | - $this->add("upload_target_srl",$upload_target_srl); |
|
111 | - $this->add("upload_status",$upload_status); |
|
112 | - $this->add("left_size",$left_size); |
|
108 | + $this->add("files", $files); |
|
109 | + $this->add("editor_sequence", $editor_sequence); |
|
110 | + $this->add("upload_target_srl", $upload_target_srl); |
|
111 | + $this->add("upload_status", $upload_status); |
|
112 | + $this->add("left_size", $left_size); |
|
113 | 113 | $this->add('attached_size', $attached_size); |
114 | 114 | $this->add('allowed_attach_size', $allowed_attach_size); |
115 | 115 | $this->add('allowed_filesize', $allowed_filesize); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $args = new stdClass(); |
128 | 128 | $args->upload_target_srl = $upload_target_srl; |
129 | 129 | $output = executeQuery('file.getFilesCount', $args); |
130 | - return (int)$output->data->count; |
|
130 | + return (int) $output->data->count; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @param string $sid |
138 | 138 | * @return string Returns a url |
139 | 139 | */ |
140 | - function getDownloadUrl($file_srl, $sid, $module_srl="") |
|
140 | + function getDownloadUrl($file_srl, $sid, $module_srl = "") |
|
141 | 141 | { |
142 | 142 | return sprintf('?module=%s&act=%s&file_srl=%s&sid=%s&module_srl=%s', 'file', 'procFileDownload', $file_srl, $sid, $module_srl); |
143 | 143 | } |
@@ -155,12 +155,12 @@ discard block |
||
155 | 155 | |
156 | 156 | $file_module_config = $oModuleModel->getModuleConfig('file'); |
157 | 157 | |
158 | - if($module_srl) $file_config = $oModuleModel->getModulePartConfig('file',$module_srl); |
|
159 | - if(!$file_config) $file_config = $file_module_config; |
|
158 | + if ($module_srl) $file_config = $oModuleModel->getModulePartConfig('file', $module_srl); |
|
159 | + if (!$file_config) $file_config = $file_module_config; |
|
160 | 160 | |
161 | 161 | $config = new stdClass(); |
162 | 162 | |
163 | - if($file_config) |
|
163 | + if ($file_config) |
|
164 | 164 | { |
165 | 165 | $config->allowed_filesize = $file_config->allowed_filesize; |
166 | 166 | $config->allowed_attach_size = $file_config->allowed_attach_size; |
@@ -172,32 +172,32 @@ discard block |
||
172 | 172 | $config->allow_thumbnail_transparent = $file_config->allow_thumbnail_transparent; |
173 | 173 | } |
174 | 174 | // Property for all files comes first than each property |
175 | - if(!$config->allowed_filesize) $config->allowed_filesize = $file_module_config->allowed_filesize; |
|
176 | - if(!$config->allowed_attach_size) $config->allowed_attach_size = $file_module_config->allowed_attach_size; |
|
177 | - if(!$config->allowed_filetypes) $config->allowed_filetypes = $file_module_config->allowed_filetypes; |
|
178 | - if(!$config->allow_outlink) $config->allow_outlink = $file_module_config->allow_outlink; |
|
179 | - if(!$config->allow_outlink_site) $config->allow_outlink_site = $file_module_config->allow_outlink_site; |
|
180 | - if(!$config->allow_outlink_format) $config->allow_outlink_format = $file_module_config->allow_outlink_format; |
|
181 | - if(!$config->download_grant) $config->download_grant = $file_module_config->download_grant; |
|
175 | + if (!$config->allowed_filesize) $config->allowed_filesize = $file_module_config->allowed_filesize; |
|
176 | + if (!$config->allowed_attach_size) $config->allowed_attach_size = $file_module_config->allowed_attach_size; |
|
177 | + if (!$config->allowed_filetypes) $config->allowed_filetypes = $file_module_config->allowed_filetypes; |
|
178 | + if (!$config->allow_outlink) $config->allow_outlink = $file_module_config->allow_outlink; |
|
179 | + if (!$config->allow_outlink_site) $config->allow_outlink_site = $file_module_config->allow_outlink_site; |
|
180 | + if (!$config->allow_outlink_format) $config->allow_outlink_format = $file_module_config->allow_outlink_format; |
|
181 | + if (!$config->download_grant) $config->download_grant = $file_module_config->download_grant; |
|
182 | 182 | // Default setting if not exists |
183 | - if(!$config->allowed_filesize) $config->allowed_filesize = '2'; |
|
184 | - if(!$config->allowed_attach_size) $config->allowed_attach_size = '3'; |
|
185 | - if(!$config->allowed_filetypes) $config->allowed_filetypes = '*.*'; |
|
186 | - if(!$config->allow_outlink) $config->allow_outlink = 'Y'; |
|
187 | - if(!$config->allow_thumbnail_transparent) $config->allow_thumbnail_transparent = 'N'; |
|
188 | - if(!$config->download_grant) $config->download_grant = array(); |
|
183 | + if (!$config->allowed_filesize) $config->allowed_filesize = '2'; |
|
184 | + if (!$config->allowed_attach_size) $config->allowed_attach_size = '3'; |
|
185 | + if (!$config->allowed_filetypes) $config->allowed_filetypes = '*.*'; |
|
186 | + if (!$config->allow_outlink) $config->allow_outlink = 'Y'; |
|
187 | + if (!$config->allow_thumbnail_transparent) $config->allow_thumbnail_transparent = 'N'; |
|
188 | + if (!$config->download_grant) $config->download_grant = array(); |
|
189 | 189 | |
190 | 190 | $size = ini_get('upload_max_filesize'); |
191 | 191 | $unit = strtolower($size[strlen($size) - 1]); |
192 | - $size = (float)$size; |
|
193 | - if($unit == 'g') $size *= 1024; |
|
194 | - if($unit == 'k') $size /= 1024; |
|
192 | + $size = (float) $size; |
|
193 | + if ($unit == 'g') $size *= 1024; |
|
194 | + if ($unit == 'k') $size /= 1024; |
|
195 | 195 | |
196 | - if($config->allowed_filesize > $size) |
|
196 | + if ($config->allowed_filesize > $size) |
|
197 | 197 | { |
198 | 198 | $config->allowed_filesize = $size; |
199 | 199 | } |
200 | - if($config->allowed_attach_size > $size) |
|
200 | + if ($config->allowed_attach_size > $size) |
|
201 | 201 | { |
202 | 202 | $config->allowed_attach_size = $size; |
203 | 203 | } |
@@ -217,10 +217,10 @@ discard block |
||
217 | 217 | $args = new stdClass(); |
218 | 218 | $args->file_srl = $file_srl; |
219 | 219 | $output = executeQueryArray('file.getFile', $args, $columnList); |
220 | - if(!$output->toBool()) return $output; |
|
220 | + if (!$output->toBool()) return $output; |
|
221 | 221 | |
222 | 222 | // old version compatibility |
223 | - if(count($output->data) == 1) |
|
223 | + if (count($output->data) == 1) |
|
224 | 224 | { |
225 | 225 | $file = $output->data[0]; |
226 | 226 | $file->download_url = $this->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl); |
@@ -231,9 +231,9 @@ discard block |
||
231 | 231 | { |
232 | 232 | $fileList = array(); |
233 | 233 | |
234 | - if(is_array($output->data)) |
|
234 | + if (is_array($output->data)) |
|
235 | 235 | { |
236 | - foreach($output->data as $key=>$value) |
|
236 | + foreach ($output->data as $key=>$value) |
|
237 | 237 | { |
238 | 238 | $file = $value; |
239 | 239 | $file->download_url = $this->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl); |
@@ -257,13 +257,13 @@ discard block |
||
257 | 257 | $args = new stdClass(); |
258 | 258 | $args->upload_target_srl = $upload_target_srl; |
259 | 259 | $args->sort_index = $sortIndex; |
260 | - if($ckValid) $args->isvalid = 'Y'; |
|
260 | + if ($ckValid) $args->isvalid = 'Y'; |
|
261 | 261 | $output = executeQueryArray('file.getFiles', $args, $columnList); |
262 | - if(!$output->data) return; |
|
262 | + if (!$output->data) return; |
|
263 | 263 | |
264 | 264 | $file_list = $output->data; |
265 | 265 | |
266 | - if($file_list && !is_array($file_list)) $file_list = array($file_list); |
|
266 | + if ($file_list && !is_array($file_list)) $file_list = array($file_list); |
|
267 | 267 | |
268 | 268 | foreach ($file_list as &$file) |
269 | 269 | { |
@@ -286,14 +286,14 @@ discard block |
||
286 | 286 | |
287 | 287 | $module_srl = Context::get('module_srl'); |
288 | 288 | // Get the current module if module_srl doesn't exist |
289 | - if(!$module_srl) |
|
289 | + if (!$module_srl) |
|
290 | 290 | { |
291 | 291 | $current_module_info = Context::get('current_module_info'); |
292 | 292 | $module_srl = $current_module_info->module_srl; |
293 | 293 | } |
294 | 294 | $file_config = $this->getFileConfig($module_srl); |
295 | 295 | |
296 | - if($logged_info->is_admin == 'Y') |
|
296 | + if ($logged_info->is_admin == 'Y') |
|
297 | 297 | { |
298 | 298 | $iniPostMaxSize = FileHandler::returnbytes(ini_get('post_max_size')); |
299 | 299 | $iniUploadMaxSize = FileHandler::returnbytes(ini_get('upload_max_filesize')); |
@@ -319,9 +319,9 @@ discard block |
||
319 | 319 | '%s : %s/ %s<br /> %s : %s (%s : %s)', |
320 | 320 | Context::getLang('allowed_attach_size'), |
321 | 321 | FileHandler::filesize($attached_size), |
322 | - FileHandler::filesize($file_config->allowed_attach_size*1024*1024), |
|
322 | + FileHandler::filesize($file_config->allowed_attach_size * 1024 * 1024), |
|
323 | 323 | Context::getLang('allowed_filesize'), |
324 | - FileHandler::filesize($file_config->allowed_filesize*1024*1024), |
|
324 | + FileHandler::filesize($file_config->allowed_filesize * 1024 * 1024), |
|
325 | 325 | Context::getLang('allowed_filetypes'), |
326 | 326 | $file_config->allowed_filetypes |
327 | 327 | ); |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | */ |
349 | 349 | function getFileGrant($file_info, $member_info) |
350 | 350 | { |
351 | - if(!$file_info) return null; |
|
351 | + if (!$file_info) return null; |
|
352 | 352 | |
353 | - if($_SESSION['__XE_UPLOADING_FILES_INFO__'][$file_info->file_srl]) |
|
353 | + if ($_SESSION['__XE_UPLOADING_FILES_INFO__'][$file_info->file_srl]) |
|
354 | 354 | { |
355 | 355 | $file_grant->is_deletable = true; |
356 | 356 | return $file_grant; |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | |
362 | 362 | $oDocumentModel = getModel('document'); |
363 | 363 | $oDocument = $oDocumentModel->getDocument($file_info->upload_target_srl); |
364 | - if($oDocument->isExists()) $document_grant = $oDocument->isGranted(); |
|
364 | + if ($oDocument->isExists()) $document_grant = $oDocument->isGranted(); |
|
365 | 365 | |
366 | 366 | $file_grant->is_deletable = ($document_grant || $member_info->is_admin == 'Y' || $member_info->member_srl == $file_info->member_srl || $grant->manager); |
367 | 367 |
@@ -29,7 +29,9 @@ discard block |
||
29 | 29 | $mid = Context::get('mid'); |
30 | 30 | $editor_sequence = Context::get('editor_sequence'); |
31 | 31 | $upload_target_srl = Context::get('upload_target_srl'); |
32 | - if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
32 | + if(!$upload_target_srl) { |
|
33 | + $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
34 | + } |
|
33 | 35 | |
34 | 36 | if($upload_target_srl) |
35 | 37 | { |
@@ -68,26 +70,32 @@ discard block |
||
68 | 70 | } |
69 | 71 | |
70 | 72 | $tmp_files = $this->getFiles($upload_target_srl); |
71 | - if(!$tmp_files) $tmp_files = array(); |
|
73 | + if(!$tmp_files) { |
|
74 | + $tmp_files = array(); |
|
75 | + } |
|
72 | 76 | |
73 | 77 | foreach($tmp_files as $file_info) |
74 | 78 | { |
75 | - if(!$file_info->file_srl) continue; |
|
79 | + if(!$file_info->file_srl) { |
|
80 | + continue; |
|
81 | + } |
|
76 | 82 | |
77 | 83 | $obj = new stdClass; |
78 | 84 | $obj->file_srl = $file_info->file_srl; |
79 | 85 | $obj->source_filename = $file_info->source_filename; |
80 | 86 | $obj->file_size = $file_info->file_size; |
81 | 87 | $obj->disp_file_size = FileHandler::filesize($file_info->file_size); |
82 | - if($file_info->direct_download=='N') $obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid, $file_info->module_srl); |
|
83 | - else $obj->download_url = str_replace('./', '', $file_info->uploaded_filename); |
|
88 | + if($file_info->direct_download=='N') { |
|
89 | + $obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid, $file_info->module_srl); |
|
90 | + } else { |
|
91 | + $obj->download_url = str_replace('./', '', $file_info->uploaded_filename); |
|
92 | + } |
|
84 | 93 | $obj->direct_download = $file_info->direct_download; |
85 | 94 | $obj->cover_image = ($file_info->cover_image === 'Y') ? true : false; |
86 | 95 | $files[] = $obj; |
87 | 96 | $attached_size += $file_info->file_size; |
88 | 97 | } |
89 | - } |
|
90 | - else |
|
98 | + } else |
|
91 | 99 | { |
92 | 100 | $upload_target_srl = 0; |
93 | 101 | $attached_size = 0; |
@@ -155,8 +163,12 @@ discard block |
||
155 | 163 | |
156 | 164 | $file_module_config = $oModuleModel->getModuleConfig('file'); |
157 | 165 | |
158 | - if($module_srl) $file_config = $oModuleModel->getModulePartConfig('file',$module_srl); |
|
159 | - if(!$file_config) $file_config = $file_module_config; |
|
166 | + if($module_srl) { |
|
167 | + $file_config = $oModuleModel->getModulePartConfig('file',$module_srl); |
|
168 | + } |
|
169 | + if(!$file_config) { |
|
170 | + $file_config = $file_module_config; |
|
171 | + } |
|
160 | 172 | |
161 | 173 | $config = new stdClass(); |
162 | 174 | |
@@ -172,26 +184,56 @@ discard block |
||
172 | 184 | $config->allow_thumbnail_transparent = $file_config->allow_thumbnail_transparent; |
173 | 185 | } |
174 | 186 | // Property for all files comes first than each property |
175 | - if(!$config->allowed_filesize) $config->allowed_filesize = $file_module_config->allowed_filesize; |
|
176 | - if(!$config->allowed_attach_size) $config->allowed_attach_size = $file_module_config->allowed_attach_size; |
|
177 | - if(!$config->allowed_filetypes) $config->allowed_filetypes = $file_module_config->allowed_filetypes; |
|
178 | - if(!$config->allow_outlink) $config->allow_outlink = $file_module_config->allow_outlink; |
|
179 | - if(!$config->allow_outlink_site) $config->allow_outlink_site = $file_module_config->allow_outlink_site; |
|
180 | - if(!$config->allow_outlink_format) $config->allow_outlink_format = $file_module_config->allow_outlink_format; |
|
181 | - if(!$config->download_grant) $config->download_grant = $file_module_config->download_grant; |
|
187 | + if(!$config->allowed_filesize) { |
|
188 | + $config->allowed_filesize = $file_module_config->allowed_filesize; |
|
189 | + } |
|
190 | + if(!$config->allowed_attach_size) { |
|
191 | + $config->allowed_attach_size = $file_module_config->allowed_attach_size; |
|
192 | + } |
|
193 | + if(!$config->allowed_filetypes) { |
|
194 | + $config->allowed_filetypes = $file_module_config->allowed_filetypes; |
|
195 | + } |
|
196 | + if(!$config->allow_outlink) { |
|
197 | + $config->allow_outlink = $file_module_config->allow_outlink; |
|
198 | + } |
|
199 | + if(!$config->allow_outlink_site) { |
|
200 | + $config->allow_outlink_site = $file_module_config->allow_outlink_site; |
|
201 | + } |
|
202 | + if(!$config->allow_outlink_format) { |
|
203 | + $config->allow_outlink_format = $file_module_config->allow_outlink_format; |
|
204 | + } |
|
205 | + if(!$config->download_grant) { |
|
206 | + $config->download_grant = $file_module_config->download_grant; |
|
207 | + } |
|
182 | 208 | // Default setting if not exists |
183 | - if(!$config->allowed_filesize) $config->allowed_filesize = '2'; |
|
184 | - if(!$config->allowed_attach_size) $config->allowed_attach_size = '3'; |
|
185 | - if(!$config->allowed_filetypes) $config->allowed_filetypes = '*.*'; |
|
186 | - if(!$config->allow_outlink) $config->allow_outlink = 'Y'; |
|
187 | - if(!$config->allow_thumbnail_transparent) $config->allow_thumbnail_transparent = 'N'; |
|
188 | - if(!$config->download_grant) $config->download_grant = array(); |
|
209 | + if(!$config->allowed_filesize) { |
|
210 | + $config->allowed_filesize = '2'; |
|
211 | + } |
|
212 | + if(!$config->allowed_attach_size) { |
|
213 | + $config->allowed_attach_size = '3'; |
|
214 | + } |
|
215 | + if(!$config->allowed_filetypes) { |
|
216 | + $config->allowed_filetypes = '*.*'; |
|
217 | + } |
|
218 | + if(!$config->allow_outlink) { |
|
219 | + $config->allow_outlink = 'Y'; |
|
220 | + } |
|
221 | + if(!$config->allow_thumbnail_transparent) { |
|
222 | + $config->allow_thumbnail_transparent = 'N'; |
|
223 | + } |
|
224 | + if(!$config->download_grant) { |
|
225 | + $config->download_grant = array(); |
|
226 | + } |
|
189 | 227 | |
190 | 228 | $size = ini_get('upload_max_filesize'); |
191 | 229 | $unit = strtolower($size[strlen($size) - 1]); |
192 | 230 | $size = (float)$size; |
193 | - if($unit == 'g') $size *= 1024; |
|
194 | - if($unit == 'k') $size /= 1024; |
|
231 | + if($unit == 'g') { |
|
232 | + $size *= 1024; |
|
233 | + } |
|
234 | + if($unit == 'k') { |
|
235 | + $size /= 1024; |
|
236 | + } |
|
195 | 237 | |
196 | 238 | if($config->allowed_filesize > $size) |
197 | 239 | { |
@@ -217,7 +259,9 @@ discard block |
||
217 | 259 | $args = new stdClass(); |
218 | 260 | $args->file_srl = $file_srl; |
219 | 261 | $output = executeQueryArray('file.getFile', $args, $columnList); |
220 | - if(!$output->toBool()) return $output; |
|
262 | + if(!$output->toBool()) { |
|
263 | + return $output; |
|
264 | + } |
|
221 | 265 | |
222 | 266 | // old version compatibility |
223 | 267 | if(count($output->data) == 1) |
@@ -226,8 +270,7 @@ discard block |
||
226 | 270 | $file->download_url = $this->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl); |
227 | 271 | |
228 | 272 | return $file; |
229 | - } |
|
230 | - else |
|
273 | + } else |
|
231 | 274 | { |
232 | 275 | $fileList = array(); |
233 | 276 | |
@@ -257,13 +300,19 @@ discard block |
||
257 | 300 | $args = new stdClass(); |
258 | 301 | $args->upload_target_srl = $upload_target_srl; |
259 | 302 | $args->sort_index = $sortIndex; |
260 | - if($ckValid) $args->isvalid = 'Y'; |
|
303 | + if($ckValid) { |
|
304 | + $args->isvalid = 'Y'; |
|
305 | + } |
|
261 | 306 | $output = executeQueryArray('file.getFiles', $args, $columnList); |
262 | - if(!$output->data) return; |
|
307 | + if(!$output->data) { |
|
308 | + return; |
|
309 | + } |
|
263 | 310 | |
264 | 311 | $file_list = $output->data; |
265 | 312 | |
266 | - if($file_list && !is_array($file_list)) $file_list = array($file_list); |
|
313 | + if($file_list && !is_array($file_list)) { |
|
314 | + $file_list = array($file_list); |
|
315 | + } |
|
267 | 316 | |
268 | 317 | foreach ($file_list as &$file) |
269 | 318 | { |
@@ -348,7 +397,9 @@ discard block |
||
348 | 397 | */ |
349 | 398 | function getFileGrant($file_info, $member_info) |
350 | 399 | { |
351 | - if(!$file_info) return null; |
|
400 | + if(!$file_info) { |
|
401 | + return null; |
|
402 | + } |
|
352 | 403 | |
353 | 404 | if($_SESSION['__XE_UPLOADING_FILES_INFO__'][$file_info->file_srl]) |
354 | 405 | { |
@@ -361,7 +412,9 @@ discard block |
||
361 | 412 | |
362 | 413 | $oDocumentModel = getModel('document'); |
363 | 414 | $oDocument = $oDocumentModel->getDocument($file_info->upload_target_srl); |
364 | - if($oDocument->isExists()) $document_grant = $oDocument->isGranted(); |
|
415 | + if($oDocument->isExists()) { |
|
416 | + $document_grant = $oDocument->isGranted(); |
|
417 | + } |
|
365 | 418 | |
366 | 419 | $file_grant->is_deletable = ($document_grant || $member_info->is_admin == 'Y' || $member_info->member_srl == $file_info->member_srl || $grant->manager); |
367 | 420 |