@@ -3,43 +3,43 @@ |
||
| 3 | 3 | |
| 4 | 4 | class UploadFileFilter |
| 5 | 5 | { |
| 6 | - private static $_block_list = array ('exec', 'system', 'passthru', 'show_source', 'phpinfo', 'fopen', 'file_get_contents', 'file_put_contents', 'fwrite', 'proc_open', 'popen'); |
|
| 6 | + private static $_block_list = array('exec', 'system', 'passthru', 'show_source', 'phpinfo', 'fopen', 'file_get_contents', 'file_put_contents', 'fwrite', 'proc_open', 'popen'); |
|
| 7 | 7 | |
| 8 | 8 | public function check($file) |
| 9 | 9 | { |
| 10 | 10 | // TODO: 기능개선후 enable |
| 11 | 11 | |
| 12 | 12 | return TRUE; // disable |
| 13 | - if (! $file || ! FileHandler::exists($file)) return TRUE; |
|
| 14 | - return self::_check ( $file ); |
|
| 13 | + if (!$file || !FileHandler::exists($file)) return TRUE; |
|
| 14 | + return self::_check($file); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | private function _check($file) |
| 18 | 18 | { |
| 19 | - if (! ($fp = fopen ( $file, 'r' ))) return FALSE; |
|
| 19 | + if (!($fp = fopen($file, 'r'))) return FALSE; |
|
| 20 | 20 | |
| 21 | 21 | $has_php_tag = FALSE; |
| 22 | 22 | |
| 23 | - while ( ! feof ( $fp ) ) |
|
| 23 | + while (!feof($fp)) |
|
| 24 | 24 | { |
| 25 | - $content = fread ( $fp, 8192 ); |
|
| 25 | + $content = fread($fp, 8192); |
|
| 26 | 26 | if (FALSE === $has_php_tag) |
| 27 | 27 | { |
| 28 | - $has_php_tag = strpos ( $content, '<?' ); |
|
| 29 | - $has_php_tag |= strpos ( $content, '<%' ); |
|
| 30 | - $has_php_tag |= preg_match ( '/<script.*language=.?php.?.*>/', $content ); |
|
| 28 | + $has_php_tag = strpos($content, '<?'); |
|
| 29 | + $has_php_tag |= strpos($content, '<%'); |
|
| 30 | + $has_php_tag |= preg_match('/<script.*language=.?php.?.*>/', $content); |
|
| 31 | 31 | } |
| 32 | - foreach ( self::$_block_list as $v ) |
|
| 32 | + foreach (self::$_block_list as $v) |
|
| 33 | 33 | { |
| 34 | - if (FALSE !== $has_php_tag && FALSE !== strpos ( $content, $v )) |
|
| 34 | + if (FALSE !== $has_php_tag && FALSE !== strpos($content, $v)) |
|
| 35 | 35 | { |
| 36 | - fclose ( $fp ); |
|
| 36 | + fclose($fp); |
|
| 37 | 37 | return FALSE; |
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - fclose ( $fp ); |
|
| 42 | + fclose($fp); |
|
| 43 | 43 | |
| 44 | 44 | return TRUE; |
| 45 | 45 | } |
@@ -10,13 +10,17 @@ |
||
| 10 | 10 | // TODO: 기능개선후 enable |
| 11 | 11 | |
| 12 | 12 | return TRUE; // disable |
| 13 | - if (! $file || ! FileHandler::exists($file)) return TRUE; |
|
| 13 | + if (! $file || ! FileHandler::exists($file)) { |
|
| 14 | + return TRUE; |
|
| 15 | + } |
|
| 14 | 16 | return self::_check ( $file ); |
| 15 | 17 | } |
| 16 | 18 | |
| 17 | 19 | private function _check($file) |
| 18 | 20 | { |
| 19 | - if (! ($fp = fopen ( $file, 'r' ))) return FALSE; |
|
| 21 | + if (! ($fp = fopen ( $file, 'r' ))) { |
|
| 22 | + return FALSE; |
|
| 23 | + } |
|
| 20 | 24 | |
| 21 | 25 | $has_php_tag = FALSE; |
| 22 | 26 | |