@@ -29,30 +29,30 @@ discard block |
||
| 29 | 29 | $file_info = $_FILES['Filedata']; |
| 30 | 30 | |
| 31 | 31 | // An error appears if not a normally uploaded file |
| 32 | - if(!is_uploaded_file($file_info['tmp_name'])) exit(); |
|
| 32 | + if (!is_uploaded_file($file_info['tmp_name'])) exit(); |
|
| 33 | 33 | |
| 34 | 34 | // Basic variables setting |
| 35 | 35 | $oFileModel = getModel('file'); |
| 36 | 36 | $editor_sequence = Context::get('editor_sequence'); |
| 37 | 37 | $upload_target_srl = intval(Context::get('uploadTargetSrl')); |
| 38 | - if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
| 38 | + if (!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
| 39 | 39 | $module_srl = $this->module_srl; |
| 40 | 40 | // Exit a session if there is neither upload permission nor information |
| 41 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
| 41 | + if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
| 42 | 42 | // Extract from session information if upload_target_srl is not specified |
| 43 | - if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
| 43 | + if (!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
| 44 | 44 | // Create if upload_target_srl is not defined in the session information |
| 45 | - if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
| 45 | + if (!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
| 46 | 46 | |
| 47 | 47 | $output = $this->insertFile($file_info, $module_srl, $upload_target_srl); |
| 48 | 48 | Context::setResponseMethod('JSON'); |
| 49 | - $this->add('file_srl',$output->get('file_srl')); |
|
| 50 | - $this->add('file_size',$output->get('file_size')); |
|
| 51 | - $this->add('direct_download',$output->get('direct_download')); |
|
| 52 | - $this->add('source_filename',$output->get('source_filename')); |
|
| 53 | - $this->add('download_url',$output->get('uploaded_filename')); |
|
| 54 | - $this->add('upload_target_srl',$output->get('upload_target_srl')); |
|
| 55 | - if($output->error != '0') $this->stop($output->message); |
|
| 49 | + $this->add('file_srl', $output->get('file_srl')); |
|
| 50 | + $this->add('file_size', $output->get('file_size')); |
|
| 51 | + $this->add('direct_download', $output->get('direct_download')); |
|
| 52 | + $this->add('source_filename', $output->get('source_filename')); |
|
| 53 | + $this->add('download_url', $output->get('uploaded_filename')); |
|
| 54 | + $this->add('upload_target_srl', $output->get('upload_target_srl')); |
|
| 55 | + if ($output->error != '0') $this->stop($output->message); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -67,24 +67,24 @@ discard block |
||
| 67 | 67 | $callback = Context::get('callback'); |
| 68 | 68 | $module_srl = $this->module_srl; |
| 69 | 69 | $upload_target_srl = intval(Context::get('uploadTargetSrl')); |
| 70 | - if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
| 70 | + if (!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
| 71 | 71 | |
| 72 | 72 | // Exit a session if there is neither upload permission nor information |
| 73 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
| 73 | + if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
| 74 | 74 | // Extract from session information if upload_target_srl is not specified |
| 75 | - if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
| 75 | + if (!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
| 76 | 76 | // Create if upload_target_srl is not defined in the session information |
| 77 | - if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
| 77 | + if (!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
| 78 | 78 | |
| 79 | 79 | // Delete and then attempt to re-upload if file_srl is requested |
| 80 | 80 | $file_srl = Context::get('file_srl'); |
| 81 | - if($file_srl) |
|
| 81 | + if ($file_srl) |
|
| 82 | 82 | { |
| 83 | 83 | $oFileModel = getModel('file'); |
| 84 | 84 | $logged_info = Context::get('logged_info'); |
| 85 | 85 | $file_info = $oFileModel->getFile($file_srl); |
| 86 | 86 | $file_grant = $oFileModel->getFileGrant($file_info, $logged_info); |
| 87 | - if($file_info->file_srl == $file_srl && $file_grant->is_deletable) |
|
| 87 | + if ($file_info->file_srl == $file_srl && $file_grant->is_deletable) |
|
| 88 | 88 | { |
| 89 | 89 | $this->deleteFile($file_srl); |
| 90 | 90 | } |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | $file_info = Context::get('Filedata'); |
| 94 | 94 | // An error appears if not a normally uploaded file |
| 95 | - if(is_uploaded_file($file_info['tmp_name'])) { |
|
| 95 | + if (is_uploaded_file($file_info['tmp_name'])) { |
|
| 96 | 96 | $output = $this->insertFile($file_info, $module_srl, $upload_target_srl); |
| 97 | - Context::set('uploaded_fileinfo',$output); |
|
| 97 | + Context::set('uploaded_fileinfo', $output); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - Context::set('layout','none'); |
|
| 100 | + Context::set('layout', 'none'); |
|
| 101 | 101 | |
| 102 | 102 | $this->setTemplatePath($this->module_path.'tpl'); |
| 103 | 103 | $this->setTemplateFile('iframe'); |
@@ -114,24 +114,24 @@ discard block |
||
| 114 | 114 | $width = Context::get('width'); |
| 115 | 115 | $height = Context::get('height'); |
| 116 | 116 | |
| 117 | - if(!$file_srl || !$width) |
|
| 117 | + if (!$file_srl || !$width) |
|
| 118 | 118 | { |
| 119 | - return new Object(-1,'msg_invalid_request'); |
|
| 119 | + return new Object(-1, 'msg_invalid_request'); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | $oFileModel = getModel('file'); |
| 123 | 123 | $fileInfo = $oFileModel->getFile($file_srl); |
| 124 | - if(!$fileInfo || $fileInfo->direct_download != 'Y') |
|
| 124 | + if (!$fileInfo || $fileInfo->direct_download != 'Y') |
|
| 125 | 125 | { |
| 126 | - return new Object(-1,'msg_invalid_request'); |
|
| 126 | + return new Object(-1, 'msg_invalid_request'); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | $source_src = $fileInfo->uploaded_filename; |
| 130 | - $output_src = $source_src . '.resized' . strrchr($source_src,'.'); |
|
| 130 | + $output_src = $source_src.'.resized'.strrchr($source_src, '.'); |
|
| 131 | 131 | |
| 132 | - if(!$height) $height = $width-1; |
|
| 132 | + if (!$height) $height = $width - 1; |
|
| 133 | 133 | |
| 134 | - if(FileHandler::createImageFile($source_src,$output_src,$width,$height,'','ratio')) |
|
| 134 | + if (FileHandler::createImageFile($source_src, $output_src, $width, $height, '', 'ratio')) |
|
| 135 | 135 | { |
| 136 | 136 | $output = new stdClass(); |
| 137 | 137 | $output->info = getimagesize($output_src); |
@@ -139,10 +139,10 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | else |
| 141 | 141 | { |
| 142 | - return new Object(-1,'msg_invalid_request'); |
|
| 142 | + return new Object(-1, 'msg_invalid_request'); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - $this->add('resized_info',$output); |
|
| 145 | + $this->add('resized_info', $output); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | { |
| 181 | 181 | $oFileModel = getModel('file'); |
| 182 | 182 | |
| 183 | - if(isset($this->grant->access) && $this->grant->access !== true) return new Object(-1, 'msg_not_permitted'); |
|
| 183 | + if (isset($this->grant->access) && $this->grant->access !== true) return new Object(-1, 'msg_not_permitted'); |
|
| 184 | 184 | |
| 185 | 185 | $file_srl = Context::get('file_srl'); |
| 186 | 186 | $sid = Context::get('sid'); |
@@ -189,26 +189,26 @@ discard block |
||
| 189 | 189 | $columnList = array('file_srl', 'sid', 'isvalid', 'source_filename', 'module_srl', 'uploaded_filename', 'file_size', 'member_srl', 'upload_target_srl', 'upload_target_type'); |
| 190 | 190 | $file_obj = $oFileModel->getFile($file_srl, $columnList); |
| 191 | 191 | // If the requested file information is incorrect, an error that file cannot be found appears |
| 192 | - if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) return $this->stop('msg_file_not_found'); |
|
| 192 | + if ($file_obj->file_srl != $file_srl || $file_obj->sid != $sid) return $this->stop('msg_file_not_found'); |
|
| 193 | 193 | // Notify that file download is not allowed when standing-by(Only a top-administrator is permitted) |
| 194 | - if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') return $this->stop('msg_not_permitted_download'); |
|
| 194 | + if ($logged_info->is_admin != 'Y' && $file_obj->isvalid != 'Y') return $this->stop('msg_not_permitted_download'); |
|
| 195 | 195 | // File name |
| 196 | 196 | $filename = $file_obj->source_filename; |
| 197 | 197 | $file_module_config = $oFileModel->getFileModuleConfig($file_obj->module_srl); |
| 198 | 198 | // Not allow the file outlink |
| 199 | - if($file_module_config->allow_outlink == 'N') |
|
| 199 | + if ($file_module_config->allow_outlink == 'N') |
|
| 200 | 200 | { |
| 201 | 201 | // Handles extension to allow outlink |
| 202 | - if($file_module_config->allow_outlink_format) |
|
| 202 | + if ($file_module_config->allow_outlink_format) |
|
| 203 | 203 | { |
| 204 | 204 | $allow_outlink_format_array = array(); |
| 205 | 205 | $allow_outlink_format_array = explode(',', $file_module_config->allow_outlink_format); |
| 206 | - if(!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format; |
|
| 206 | + if (!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format; |
|
| 207 | 207 | |
| 208 | - foreach($allow_outlink_format_array as $val) |
|
| 208 | + foreach ($allow_outlink_format_array as $val) |
|
| 209 | 209 | { |
| 210 | 210 | $val = trim($val); |
| 211 | - if(preg_match("/\.{$val}$/i", $filename)) |
|
| 211 | + if (preg_match("/\.{$val}$/i", $filename)) |
|
| 212 | 212 | { |
| 213 | 213 | $file_module_config->allow_outlink = 'Y'; |
| 214 | 214 | break; |
@@ -216,21 +216,21 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | // Sites that outlink is allowed |
| 219 | - if($file_module_config->allow_outlink != 'Y') |
|
| 219 | + if ($file_module_config->allow_outlink != 'Y') |
|
| 220 | 220 | { |
| 221 | 221 | $referer = parse_url($_SERVER["HTTP_REFERER"]); |
| 222 | - if($referer['host'] != $_SERVER['HTTP_HOST']) |
|
| 222 | + if ($referer['host'] != $_SERVER['HTTP_HOST']) |
|
| 223 | 223 | { |
| 224 | - if($file_module_config->allow_outlink_site) |
|
| 224 | + if ($file_module_config->allow_outlink_site) |
|
| 225 | 225 | { |
| 226 | 226 | $allow_outlink_site_array = array(); |
| 227 | 227 | $allow_outlink_site_array = explode("\n", $file_module_config->allow_outlink_site); |
| 228 | - if(!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site; |
|
| 228 | + if (!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site; |
|
| 229 | 229 | |
| 230 | - foreach($allow_outlink_site_array as $val) |
|
| 230 | + foreach ($allow_outlink_site_array as $val) |
|
| 231 | 231 | { |
| 232 | 232 | $site = parse_url(trim($val)); |
| 233 | - if($site['host'] == $referer['host']) |
|
| 233 | + if ($site['host'] == $referer['host']) |
|
| 234 | 234 | { |
| 235 | 235 | $file_module_config->allow_outlink = 'Y'; |
| 236 | 236 | break; |
@@ -240,49 +240,49 @@ discard block |
||
| 240 | 240 | } |
| 241 | 241 | else $file_module_config->allow_outlink = 'Y'; |
| 242 | 242 | } |
| 243 | - if($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink'); |
|
| 243 | + if ($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink'); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | // Check if a permission for file download is granted |
| 247 | 247 | $downloadGrantCount = 0; |
| 248 | - if(is_array($file_module_config->download_grant)) |
|
| 248 | + if (is_array($file_module_config->download_grant)) |
|
| 249 | 249 | { |
| 250 | - foreach($file_module_config->download_grant AS $value) |
|
| 251 | - if($value) $downloadGrantCount++; |
|
| 250 | + foreach ($file_module_config->download_grant AS $value) |
|
| 251 | + if ($value) $downloadGrantCount++; |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - if(is_array($file_module_config->download_grant) && $downloadGrantCount>0) |
|
| 254 | + if (is_array($file_module_config->download_grant) && $downloadGrantCount > 0) |
|
| 255 | 255 | { |
| 256 | - if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download'); |
|
| 256 | + if (!Context::get('is_logged')) return $this->stop('msg_not_permitted_download'); |
|
| 257 | 257 | $logged_info = Context::get('logged_info'); |
| 258 | - if($logged_info->is_admin != 'Y') |
|
| 258 | + if ($logged_info->is_admin != 'Y') |
|
| 259 | 259 | { |
| 260 | - $oModuleModel =& getModel('module'); |
|
| 260 | + $oModuleModel = & getModel('module'); |
|
| 261 | 261 | $columnList = array('module_srl', 'site_srl'); |
| 262 | 262 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($file_obj->module_srl, $columnList); |
| 263 | 263 | |
| 264 | - if(!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl)) |
|
| 264 | + if (!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl)) |
|
| 265 | 265 | { |
| 266 | - $oMemberModel =& getModel('member'); |
|
| 266 | + $oMemberModel = & getModel('member'); |
|
| 267 | 267 | $member_groups = $oMemberModel->getMemberGroups($logged_info->member_srl, $module_info->site_srl); |
| 268 | 268 | |
| 269 | 269 | $is_permitted = false; |
| 270 | - for($i=0;$i<count($file_module_config->download_grant);$i++) |
|
| 270 | + for ($i = 0; $i < count($file_module_config->download_grant); $i++) |
|
| 271 | 271 | { |
| 272 | 272 | $group_srl = $file_module_config->download_grant[$i]; |
| 273 | - if($member_groups[$group_srl]) |
|
| 273 | + if ($member_groups[$group_srl]) |
|
| 274 | 274 | { |
| 275 | 275 | $is_permitted = true; |
| 276 | 276 | break; |
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | - if(!$is_permitted) return $this->stop('msg_not_permitted_download'); |
|
| 279 | + if (!$is_permitted) return $this->stop('msg_not_permitted_download'); |
|
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | // Call a trigger (before) |
| 284 | 284 | $output = ModuleHandler::triggerCall('file.downloadFile', 'before', $file_obj); |
| 285 | - if(!$output->toBool()) return $this->stop(($output->message)?$output->message:'msg_not_permitted_download'); |
|
| 285 | + if (!$output->toBool()) return $this->stop(($output->message) ? $output->message : 'msg_not_permitted_download'); |
|
| 286 | 286 | |
| 287 | 287 | |
| 288 | 288 | // 다운로드 후 (가상) |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | |
| 296 | 296 | $random = new Password(); |
| 297 | 297 | $file_key = $_SESSION['__XE_FILE_KEY__'][$file_srl] = $random->createSecureSalt(32, 'hex'); |
| 298 | - header('Location: '.getNotEncodedUrl('', 'act', 'procFileOutput','file_srl',$file_srl,'file_key',$file_key)); |
|
| 298 | + header('Location: '.getNotEncodedUrl('', 'act', 'procFileOutput', 'file_srl', $file_srl, 'file_key', $file_key)); |
|
| 299 | 299 | Context::close(); |
| 300 | 300 | exit(); |
| 301 | 301 | |
@@ -306,18 +306,18 @@ discard block |
||
| 306 | 306 | $oFileModel = getModel('file'); |
| 307 | 307 | $file_srl = Context::get('file_srl'); |
| 308 | 308 | $file_key = Context::get('file_key'); |
| 309 | - if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true; |
|
| 309 | + if (strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true; |
|
| 310 | 310 | |
| 311 | - if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__'; |
|
| 311 | + if ($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__'; |
|
| 312 | 312 | else $session_key = '__XE_FILE_KEY__'; |
| 313 | 313 | $columnList = array('source_filename', 'uploaded_filename', 'file_size'); |
| 314 | 314 | $file_obj = $oFileModel->getFile($file_srl, $columnList); |
| 315 | 315 | |
| 316 | 316 | $uploaded_filename = $file_obj->uploaded_filename; |
| 317 | 317 | |
| 318 | - if(!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found'); |
|
| 318 | + if (!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found'); |
|
| 319 | 319 | |
| 320 | - if(!$file_key || $_SESSION[$session_key][$file_srl] != $file_key) |
|
| 320 | + if (!$file_key || $_SESSION[$session_key][$file_srl] != $file_key) |
|
| 321 | 321 | { |
| 322 | 322 | unset($_SESSION[$session_key][$file_srl]); |
| 323 | 323 | return $this->stop('msg_invalid_request'); |
@@ -326,34 +326,34 @@ discard block |
||
| 326 | 326 | $file_size = $file_obj->file_size; |
| 327 | 327 | $filename = $file_obj->source_filename; |
| 328 | 328 | |
| 329 | - if(preg_match('#(?:Chrome|Edge)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 11) |
|
| 329 | + if (preg_match('#(?:Chrome|Edge)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 11) |
|
| 330 | 330 | { |
| 331 | - if($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT'])) |
|
| 331 | + if ($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT'])) |
|
| 332 | 332 | { |
| 333 | - $filename_param = 'filename="' . $filename . '"'; |
|
| 333 | + $filename_param = 'filename="'.$filename.'"'; |
|
| 334 | 334 | } |
| 335 | 335 | else |
| 336 | 336 | { |
| 337 | - $filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"'; |
|
| 337 | + $filename_param = "filename*=UTF-8''".rawurlencode($filename).'; filename="'.rawurlencode($filename).'"'; |
|
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | - elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6) |
|
| 340 | + elseif (preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6) |
|
| 341 | 341 | { |
| 342 | - $filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"'; |
|
| 342 | + $filename_param = "filename*=UTF-8''".rawurlencode($filename).'; filename="'.rawurlencode($filename).'"'; |
|
| 343 | 343 | } |
| 344 | - elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) |
|
| 344 | + elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) |
|
| 345 | 345 | { |
| 346 | 346 | $filename = rawurlencode($filename); |
| 347 | - $filename_param = 'filename="' . preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1) . '"'; |
|
| 347 | + $filename_param = 'filename="'.preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1).'"'; |
|
| 348 | 348 | } |
| 349 | 349 | else |
| 350 | 350 | { |
| 351 | - $filename_param = 'filename="' . $filename . '"'; |
|
| 351 | + $filename_param = 'filename="'.$filename.'"'; |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - if($is_android) |
|
| 354 | + if ($is_android) |
|
| 355 | 355 | { |
| 356 | - if($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
| 356 | + if ($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | unset($_SESSION[$session_key][$file_srl]); |
@@ -361,21 +361,21 @@ discard block |
||
| 361 | 361 | Context::close(); |
| 362 | 362 | |
| 363 | 363 | $fp = fopen($uploaded_filename, 'rb'); |
| 364 | - if(!$fp) return $this->stop('msg_file_not_found'); |
|
| 364 | + if (!$fp) return $this->stop('msg_file_not_found'); |
|
| 365 | 365 | |
| 366 | 366 | header("Cache-Control: "); |
| 367 | 367 | header("Pragma: "); |
| 368 | 368 | header("Content-Type: application/octet-stream"); |
| 369 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
| 369 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
| 370 | 370 | |
| 371 | - header("Content-Length: " .(string)($file_size)); |
|
| 372 | - header('Content-Disposition: attachment; ' . $filename_param); |
|
| 371 | + header("Content-Length: ".(string) ($file_size)); |
|
| 372 | + header('Content-Disposition: attachment; '.$filename_param); |
|
| 373 | 373 | header("Content-Transfer-Encoding: binary\n"); |
| 374 | 374 | |
| 375 | 375 | // if file size is lager than 10MB, use fread function (#18675748) |
| 376 | - if(filesize($uploaded_filename) > 1024 * 1024) |
|
| 376 | + if (filesize($uploaded_filename) > 1024 * 1024) |
|
| 377 | 377 | { |
| 378 | - while(!feof($fp)) echo fread($fp, 1024); |
|
| 378 | + while (!feof($fp)) echo fread($fp, 1024); |
|
| 379 | 379 | fclose($fp); |
| 380 | 380 | } |
| 381 | 381 | else |
@@ -397,36 +397,36 @@ discard block |
||
| 397 | 397 | $editor_sequence = Context::get('editor_sequence'); |
| 398 | 398 | $file_srl = Context::get('file_srl'); |
| 399 | 399 | $file_srls = Context::get('file_srls'); |
| 400 | - if($file_srls) $file_srl = $file_srls; |
|
| 400 | + if ($file_srls) $file_srl = $file_srls; |
|
| 401 | 401 | // Exit a session if there is neither upload permission nor information |
| 402 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
| 402 | + if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
| 403 | 403 | |
| 404 | 404 | $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
| 405 | 405 | |
| 406 | 406 | $logged_info = Context::get('logged_info'); |
| 407 | 407 | $oFileModel = getModel('file'); |
| 408 | 408 | |
| 409 | - $srls = explode(',',$file_srl); |
|
| 410 | - if(!count($srls)) return; |
|
| 409 | + $srls = explode(',', $file_srl); |
|
| 410 | + if (!count($srls)) return; |
|
| 411 | 411 | |
| 412 | - for($i=0;$i<count($srls);$i++) |
|
| 412 | + for ($i = 0; $i < count($srls); $i++) |
|
| 413 | 413 | { |
| 414 | - $srl = (int)$srls[$i]; |
|
| 415 | - if(!$srl) continue; |
|
| 414 | + $srl = (int) $srls[$i]; |
|
| 415 | + if (!$srl) continue; |
|
| 416 | 416 | |
| 417 | 417 | $args = new stdClass; |
| 418 | 418 | $args->file_srl = $srl; |
| 419 | 419 | $output = executeQuery('file.getFile', $args); |
| 420 | - if(!$output->toBool()) continue; |
|
| 420 | + if (!$output->toBool()) continue; |
|
| 421 | 421 | |
| 422 | 422 | $file_info = $output->data; |
| 423 | - if(!$file_info) continue; |
|
| 423 | + if (!$file_info) continue; |
|
| 424 | 424 | |
| 425 | 425 | $file_grant = $oFileModel->getFileGrant($file_info, $logged_info); |
| 426 | 426 | |
| 427 | - if(!$file_grant->is_deletable) continue; |
|
| 427 | + if (!$file_grant->is_deletable) continue; |
|
| 428 | 428 | |
| 429 | - if($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl); |
|
| 429 | + if ($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl); |
|
| 430 | 430 | } |
| 431 | 431 | } |
| 432 | 432 | |
@@ -437,32 +437,32 @@ discard block |
||
| 437 | 437 | */ |
| 438 | 438 | function procFileGetList() |
| 439 | 439 | { |
| 440 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
| 440 | + if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted'); |
|
| 441 | 441 | |
| 442 | 442 | $oModuleModel = getModel('module'); |
| 443 | 443 | |
| 444 | 444 | $logged_info = Context::get('logged_info'); |
| 445 | - if($logged_info->is_admin !== 'Y' && !$oModuleModel->isSiteAdmin($logged_info)) |
|
| 445 | + if ($logged_info->is_admin !== 'Y' && !$oModuleModel->isSiteAdmin($logged_info)) |
|
| 446 | 446 | { |
| 447 | 447 | return new Object(-1, 'msg_not_permitted'); |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | $fileSrls = Context::get('file_srls'); |
| 451 | - if($fileSrls) $fileSrlList = explode(',', $fileSrls); |
|
| 451 | + if ($fileSrls) $fileSrlList = explode(',', $fileSrls); |
|
| 452 | 452 | |
| 453 | 453 | global $lang; |
| 454 | - if(count($fileSrlList) > 0) |
|
| 454 | + if (count($fileSrlList) > 0) |
|
| 455 | 455 | { |
| 456 | 456 | $oFileModel = getModel('file'); |
| 457 | 457 | $fileList = $oFileModel->getFile($fileSrlList); |
| 458 | - if(!is_array($fileList)) $fileList = array($fileList); |
|
| 458 | + if (!is_array($fileList)) $fileList = array($fileList); |
|
| 459 | 459 | |
| 460 | - if(is_array($fileList)) |
|
| 460 | + if (is_array($fileList)) |
|
| 461 | 461 | { |
| 462 | - foreach($fileList AS $key=>$value) |
|
| 462 | + foreach ($fileList AS $key=>$value) |
|
| 463 | 463 | { |
| 464 | 464 | $value->human_file_size = FileHandler::filesize($value->file_size); |
| 465 | - if($value->isvalid=='Y') $value->validName = $lang->is_valid; |
|
| 465 | + if ($value->isvalid == 'Y') $value->validName = $lang->is_valid; |
|
| 466 | 466 | else $value->validName = $lang->is_stand_by; |
| 467 | 467 | } |
| 468 | 468 | } |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | function triggerCheckAttached(&$obj) |
| 485 | 485 | { |
| 486 | 486 | $document_srl = $obj->document_srl; |
| 487 | - if(!$document_srl) return new Object(); |
|
| 487 | + if (!$document_srl) return new Object(); |
|
| 488 | 488 | // Get numbers of attachments |
| 489 | 489 | $oFileModel = getModel('file'); |
| 490 | 490 | $obj->uploaded_count = $oFileModel->getFilesCount($document_srl); |
@@ -501,10 +501,10 @@ discard block |
||
| 501 | 501 | function triggerAttachFiles(&$obj) |
| 502 | 502 | { |
| 503 | 503 | $document_srl = $obj->document_srl; |
| 504 | - if(!$document_srl) return new Object(); |
|
| 504 | + if (!$document_srl) return new Object(); |
|
| 505 | 505 | |
| 506 | 506 | $output = $this->setFilesValid($document_srl); |
| 507 | - if(!$output->toBool()) return $output; |
|
| 507 | + if (!$output->toBool()) return $output; |
|
| 508 | 508 | |
| 509 | 509 | return new Object(); |
| 510 | 510 | } |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | function triggerDeleteAttached(&$obj) |
| 519 | 519 | { |
| 520 | 520 | $document_srl = $obj->document_srl; |
| 521 | - if(!$document_srl) return new Object(); |
|
| 521 | + if (!$document_srl) return new Object(); |
|
| 522 | 522 | |
| 523 | 523 | $output = $this->deleteFiles($document_srl); |
| 524 | 524 | return $output; |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | function triggerCommentCheckAttached(&$obj) |
| 534 | 534 | { |
| 535 | 535 | $comment_srl = $obj->comment_srl; |
| 536 | - if(!$comment_srl) return new Object(); |
|
| 536 | + if (!$comment_srl) return new Object(); |
|
| 537 | 537 | // Get numbers of attachments |
| 538 | 538 | $oFileModel = getModel('file'); |
| 539 | 539 | $obj->uploaded_count = $oFileModel->getFilesCount($comment_srl); |
@@ -551,10 +551,10 @@ discard block |
||
| 551 | 551 | { |
| 552 | 552 | $comment_srl = $obj->comment_srl; |
| 553 | 553 | $uploaded_count = $obj->uploaded_count; |
| 554 | - if(!$comment_srl || !$uploaded_count) return new Object(); |
|
| 554 | + if (!$comment_srl || !$uploaded_count) return new Object(); |
|
| 555 | 555 | |
| 556 | 556 | $output = $this->setFilesValid($comment_srl); |
| 557 | - if(!$output->toBool()) return $output; |
|
| 557 | + if (!$output->toBool()) return $output; |
|
| 558 | 558 | |
| 559 | 559 | return new Object(); |
| 560 | 560 | } |
@@ -568,9 +568,9 @@ discard block |
||
| 568 | 568 | function triggerCommentDeleteAttached(&$obj) |
| 569 | 569 | { |
| 570 | 570 | $comment_srl = $obj->comment_srl; |
| 571 | - if(!$comment_srl) return new Object(); |
|
| 571 | + if (!$comment_srl) return new Object(); |
|
| 572 | 572 | |
| 573 | - if($obj->isMoveToTrash) return new Object(); |
|
| 573 | + if ($obj->isMoveToTrash) return new Object(); |
|
| 574 | 574 | |
| 575 | 575 | $output = $this->deleteFiles($comment_srl); |
| 576 | 576 | return $output; |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | function triggerDeleteModuleFiles(&$obj) |
| 586 | 586 | { |
| 587 | 587 | $module_srl = $obj->module_srl; |
| 588 | - if(!$module_srl) return new Object(); |
|
| 588 | + if (!$module_srl) return new Object(); |
|
| 589 | 589 | |
| 590 | 590 | $oFileController = getAdminController('file'); |
| 591 | 591 | return $oFileController->deleteModuleFiles($module_srl); |
@@ -598,9 +598,9 @@ discard block |
||
| 598 | 598 | * @param int $upload_target_srl |
| 599 | 599 | * @return void |
| 600 | 600 | */ |
| 601 | - function setUploadInfo($editor_sequence, $upload_target_srl=0) |
|
| 601 | + function setUploadInfo($editor_sequence, $upload_target_srl = 0) |
|
| 602 | 602 | { |
| 603 | - if(!isset($_SESSION['upload_info'][$editor_sequence])) |
|
| 603 | + if (!isset($_SESSION['upload_info'][$editor_sequence])) |
|
| 604 | 604 | { |
| 605 | 605 | $_SESSION['upload_info'][$editor_sequence] = new stdClass(); |
| 606 | 606 | } |
@@ -660,36 +660,36 @@ discard block |
||
| 660 | 660 | $trigger_obj->module_srl = $module_srl; |
| 661 | 661 | $trigger_obj->upload_target_srl = $upload_target_srl; |
| 662 | 662 | $output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj); |
| 663 | - if(!$output->toBool()) return $output; |
|
| 663 | + if (!$output->toBool()) return $output; |
|
| 664 | 664 | |
| 665 | 665 | // A workaround for Firefox upload bug |
| 666 | - if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match)) |
|
| 666 | + if (preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match)) |
|
| 667 | 667 | { |
| 668 | 668 | $file_info['name'] = base64_decode(strtr($match[1], ':', '/')); |
| 669 | 669 | } |
| 670 | 670 | |
| 671 | - if(!$manual_insert) |
|
| 671 | + if (!$manual_insert) |
|
| 672 | 672 | { |
| 673 | 673 | // Get the file configurations |
| 674 | 674 | $logged_info = Context::get('logged_info'); |
| 675 | - if($logged_info->is_admin != 'Y') |
|
| 675 | + if ($logged_info->is_admin != 'Y') |
|
| 676 | 676 | { |
| 677 | 677 | $oFileModel = getModel('file'); |
| 678 | 678 | $config = $oFileModel->getFileConfig($module_srl); |
| 679 | 679 | |
| 680 | 680 | // check file type |
| 681 | - if(isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*') |
|
| 681 | + if (isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*') |
|
| 682 | 682 | { |
| 683 | 683 | $filetypes = explode(';', $config->allowed_filetypes); |
| 684 | 684 | $ext = array(); |
| 685 | - foreach($filetypes as $item) { |
|
| 685 | + foreach ($filetypes as $item) { |
|
| 686 | 686 | $item = explode('.', $item); |
| 687 | 687 | $ext[] = strtolower($item[1]); |
| 688 | 688 | } |
| 689 | 689 | $uploaded_ext = explode('.', $file_info['name']); |
| 690 | 690 | $uploaded_ext = strtolower(array_pop($uploaded_ext)); |
| 691 | 691 | |
| 692 | - if(!in_array($uploaded_ext, $ext)) |
|
| 692 | + if (!in_array($uploaded_ext, $ext)) |
|
| 693 | 693 | { |
| 694 | 694 | return $this->stop('msg_not_allowed_filetype'); |
| 695 | 695 | } |
@@ -698,63 +698,63 @@ discard block |
||
| 698 | 698 | $allowed_filesize = $config->allowed_filesize * 1024 * 1024; |
| 699 | 699 | $allowed_attach_size = $config->allowed_attach_size * 1024 * 1024; |
| 700 | 700 | // An error appears if file size exceeds a limit |
| 701 | - if($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-1, 'msg_exceeds_limit_size'); |
|
| 701 | + if ($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-1, 'msg_exceeds_limit_size'); |
|
| 702 | 702 | // Get total file size of all attachements (from DB) |
| 703 | 703 | $size_args = new stdClass; |
| 704 | 704 | $size_args->upload_target_srl = $upload_target_srl; |
| 705 | 705 | $output = executeQuery('file.getAttachedFileSize', $size_args); |
| 706 | - $attached_size = (int)$output->data->attached_size + filesize($file_info['tmp_name']); |
|
| 707 | - if($attached_size > $allowed_attach_size) return new Object(-1, 'msg_exceeds_limit_size'); |
|
| 706 | + $attached_size = (int) $output->data->attached_size + filesize($file_info['tmp_name']); |
|
| 707 | + if ($attached_size > $allowed_attach_size) return new Object(-1, 'msg_exceeds_limit_size'); |
|
| 708 | 708 | } |
| 709 | 709 | } |
| 710 | 710 | |
| 711 | 711 | // https://github.com/xpressengine/xe-core/issues/1713 |
| 712 | - $file_info['name'] = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x',$file_info['name']); |
|
| 712 | + $file_info['name'] = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x', $file_info['name']); |
|
| 713 | 713 | $file_info['name'] = removeHackTag($file_info['name']); |
| 714 | - $file_info['name'] = str_replace(array('<','>'),array('%3C','%3E'),$file_info['name']); |
|
| 714 | + $file_info['name'] = str_replace(array('<', '>'), array('%3C', '%3E'), $file_info['name']); |
|
| 715 | 715 | |
| 716 | 716 | // Get random number generator |
| 717 | 717 | $random = new Password(); |
| 718 | 718 | |
| 719 | 719 | // Set upload path by checking if the attachement is an image or other kinds of file |
| 720 | - if(preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_info['name'])) |
|
| 720 | + if (preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_info['name'])) |
|
| 721 | 721 | { |
| 722 | - $path = sprintf("./files/attach/images/%s/%s", $module_srl,getNumberingPath($upload_target_srl,3)); |
|
| 722 | + $path = sprintf("./files/attach/images/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3)); |
|
| 723 | 723 | |
| 724 | 724 | // special character to '_' |
| 725 | 725 | // change to random file name. because window php bug. window php is not recognize unicode character file name - by cherryfilter |
| 726 | - $ext = substr(strrchr($file_info['name'],'.'),1); |
|
| 726 | + $ext = substr(strrchr($file_info['name'], '.'), 1); |
|
| 727 | 727 | //$_filename = preg_replace('/[#$&*?+%"\']/', '_', $file_info['name']); |
| 728 | 728 | $_filename = $random->createSecureSalt(32, 'hex').'.'.$ext; |
| 729 | 729 | $filename = $path.$_filename; |
| 730 | 730 | $idx = 1; |
| 731 | - while(file_exists($filename)) |
|
| 731 | + while (file_exists($filename)) |
|
| 732 | 732 | { |
| 733 | - $filename = $path.preg_replace('/\.([a-z0-9]+)$/i','_'.$idx.'.$1',$_filename); |
|
| 733 | + $filename = $path.preg_replace('/\.([a-z0-9]+)$/i', '_'.$idx.'.$1', $_filename); |
|
| 734 | 734 | $idx++; |
| 735 | 735 | } |
| 736 | 736 | $direct_download = 'Y'; |
| 737 | 737 | } |
| 738 | 738 | else |
| 739 | 739 | { |
| 740 | - $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3)); |
|
| 740 | + $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3)); |
|
| 741 | 741 | $filename = $path.$random->createSecureSalt(32, 'hex'); |
| 742 | 742 | $direct_download = 'N'; |
| 743 | 743 | } |
| 744 | 744 | // Create a directory |
| 745 | - if(!FileHandler::makeDir($path)) return new Object(-1,'msg_not_permitted_create'); |
|
| 745 | + if (!FileHandler::makeDir($path)) return new Object(-1, 'msg_not_permitted_create'); |
|
| 746 | 746 | |
| 747 | 747 | // Check uploaded file |
| 748 | - if(!checkUploadedFile($file_info['tmp_name'])) return new Object(-1,'msg_file_upload_error'); |
|
| 748 | + if (!checkUploadedFile($file_info['tmp_name'])) return new Object(-1, 'msg_file_upload_error'); |
|
| 749 | 749 | |
| 750 | 750 | // Get random number generator |
| 751 | 751 | $random = new Password(); |
| 752 | 752 | |
| 753 | 753 | // Move the file |
| 754 | - if($manual_insert) |
|
| 754 | + if ($manual_insert) |
|
| 755 | 755 | { |
| 756 | 756 | @copy($file_info['tmp_name'], $filename); |
| 757 | - if(!file_exists($filename)) |
|
| 757 | + if (!file_exists($filename)) |
|
| 758 | 758 | { |
| 759 | 759 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
| 760 | 760 | @copy($file_info['tmp_name'], $filename); |
@@ -762,10 +762,10 @@ discard block |
||
| 762 | 762 | } |
| 763 | 763 | else |
| 764 | 764 | { |
| 765 | - if(!@move_uploaded_file($file_info['tmp_name'], $filename)) |
|
| 765 | + if (!@move_uploaded_file($file_info['tmp_name'], $filename)) |
|
| 766 | 766 | { |
| 767 | 767 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
| 768 | - if(!@move_uploaded_file($file_info['tmp_name'], $filename)) return new Object(-1,'msg_file_upload_error'); |
|
| 768 | + if (!@move_uploaded_file($file_info['tmp_name'], $filename)) return new Object(-1, 'msg_file_upload_error'); |
|
| 769 | 769 | } |
| 770 | 770 | } |
| 771 | 771 | // Get member information |
@@ -786,10 +786,10 @@ discard block |
||
| 786 | 786 | $args->sid = $random->createSecureSalt(32, 'hex'); |
| 787 | 787 | |
| 788 | 788 | $output = executeQuery('file.insertFile', $args); |
| 789 | - if(!$output->toBool()) return $output; |
|
| 789 | + if (!$output->toBool()) return $output; |
|
| 790 | 790 | // Call a trigger (after) |
| 791 | 791 | $trigger_output = ModuleHandler::triggerCall('file.insertFile', 'after', $args); |
| 792 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
| 792 | + if (!$trigger_output->toBool()) return $trigger_output; |
|
| 793 | 793 | |
| 794 | 794 | $_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true; |
| 795 | 795 | |
@@ -832,18 +832,18 @@ discard block |
||
| 832 | 832 | */ |
| 833 | 833 | function deleteFile($file_srl) |
| 834 | 834 | { |
| 835 | - if(!$file_srl) return; |
|
| 835 | + if (!$file_srl) return; |
|
| 836 | 836 | |
| 837 | 837 | $srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl); |
| 838 | - if(!count($srls)) return; |
|
| 838 | + if (!count($srls)) return; |
|
| 839 | 839 | |
| 840 | 840 | $oDocumentController = getController('document'); |
| 841 | 841 | $documentSrlList = array(); |
| 842 | 842 | |
| 843 | - foreach($srls as $srl) |
|
| 843 | + foreach ($srls as $srl) |
|
| 844 | 844 | { |
| 845 | - $srl = (int)$srl; |
|
| 846 | - if(!$srl) |
|
| 845 | + $srl = (int) $srl; |
|
| 846 | + if (!$srl) |
|
| 847 | 847 | { |
| 848 | 848 | continue; |
| 849 | 849 | } |
@@ -852,14 +852,14 @@ discard block |
||
| 852 | 852 | $args->file_srl = $srl; |
| 853 | 853 | $output = executeQuery('file.getFile', $args); |
| 854 | 854 | |
| 855 | - if(!$output->toBool() || !$output->data) |
|
| 855 | + if (!$output->toBool() || !$output->data) |
|
| 856 | 856 | { |
| 857 | 857 | continue; |
| 858 | 858 | } |
| 859 | 859 | |
| 860 | 860 | $file_info = $output->data; |
| 861 | 861 | |
| 862 | - if($file_info->upload_target_srl) |
|
| 862 | + if ($file_info->upload_target_srl) |
|
| 863 | 863 | { |
| 864 | 864 | $documentSrlList[] = $file_info->upload_target_srl; |
| 865 | 865 | } |
@@ -870,15 +870,15 @@ discard block |
||
| 870 | 870 | // Call a trigger (before) |
| 871 | 871 | $trigger_obj = $output->data; |
| 872 | 872 | $output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj); |
| 873 | - if(!$output->toBool()) return $output; |
|
| 873 | + if (!$output->toBool()) return $output; |
|
| 874 | 874 | |
| 875 | 875 | // Remove from the DB |
| 876 | 876 | $output = executeQuery('file.deleteFile', $args); |
| 877 | - if(!$output->toBool()) return $output; |
|
| 877 | + if (!$output->toBool()) return $output; |
|
| 878 | 878 | |
| 879 | 879 | // Call a trigger (after) |
| 880 | 880 | $trigger_output = ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj); |
| 881 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
| 881 | + if (!$trigger_output->toBool()) return $trigger_output; |
|
| 882 | 882 | |
| 883 | 883 | // If successfully deleted, remove the file |
| 884 | 884 | FileHandler::removeFile($uploaded_filename); |
@@ -902,28 +902,28 @@ discard block |
||
| 902 | 902 | $columnList = array('file_srl', 'uploaded_filename', 'module_srl'); |
| 903 | 903 | $file_list = $oFileModel->getFiles($upload_target_srl, $columnList); |
| 904 | 904 | // Success returned if no attachement exists |
| 905 | - if(!is_array($file_list)||!count($file_list)) return new Object(); |
|
| 905 | + if (!is_array($file_list) || !count($file_list)) return new Object(); |
|
| 906 | 906 | |
| 907 | 907 | // Delete the file |
| 908 | 908 | $path = array(); |
| 909 | 909 | $file_count = count($file_list); |
| 910 | - for($i=0;$i<$file_count;$i++) |
|
| 910 | + for ($i = 0; $i < $file_count; $i++) |
|
| 911 | 911 | { |
| 912 | 912 | $this->deleteFile($file_list[$i]->file_srl); |
| 913 | 913 | |
| 914 | 914 | $uploaded_filename = $file_list[$i]->uploaded_filename; |
| 915 | 915 | $path_info = pathinfo($uploaded_filename); |
| 916 | - if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
| 916 | + if (!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
| 917 | 917 | } |
| 918 | 918 | |
| 919 | 919 | // Remove from the DB |
| 920 | 920 | $args = new stdClass(); |
| 921 | 921 | $args->upload_target_srl = $upload_target_srl; |
| 922 | 922 | $output = executeQuery('file.deleteFiles', $args); |
| 923 | - if(!$output->toBool()) return $output; |
|
| 923 | + if (!$output->toBool()) return $output; |
|
| 924 | 924 | |
| 925 | 925 | // Remove a file directory of the document |
| 926 | - for($i=0, $c=count($path); $i<$c; $i++) |
|
| 926 | + for ($i = 0, $c = count($path); $i < $c; $i++) |
|
| 927 | 927 | { |
| 928 | 928 | FileHandler::removeBlankDir($path[$i]); |
| 929 | 929 | } |
@@ -941,23 +941,23 @@ discard block |
||
| 941 | 941 | */ |
| 942 | 942 | function moveFile($source_srl, $target_module_srl, $target_srl) |
| 943 | 943 | { |
| 944 | - if($source_srl == $target_srl) return; |
|
| 944 | + if ($source_srl == $target_srl) return; |
|
| 945 | 945 | |
| 946 | 946 | $oFileModel = getModel('file'); |
| 947 | 947 | $file_list = $oFileModel->getFiles($source_srl); |
| 948 | - if(!$file_list) return; |
|
| 948 | + if (!$file_list) return; |
|
| 949 | 949 | |
| 950 | 950 | $file_count = count($file_list); |
| 951 | 951 | |
| 952 | - for($i=0;$i<$file_count;$i++) |
|
| 952 | + for ($i = 0; $i < $file_count; $i++) |
|
| 953 | 953 | { |
| 954 | 954 | unset($file_info); |
| 955 | 955 | $file_info = $file_list[$i]; |
| 956 | 956 | $old_file = $file_info->uploaded_filename; |
| 957 | 957 | // Determine the file path by checking if the file is an image or other kinds |
| 958 | - if(preg_match("/\.(asf|asf|asx|avi|flv|gif|jpeg|jpg|m4a|m4v|mid|midi|moov|mov|mp1|mp2|mp3|mp4|mpeg|mpg|ogg|png|qt|ra|ram|rm|rmm|wav|webm|webp|wma|wmv)$/i", $file_info->source_filename)) |
|
| 958 | + if (preg_match("/\.(asf|asf|asx|avi|flv|gif|jpeg|jpg|m4a|m4v|mid|midi|moov|mov|mp1|mp2|mp3|mp4|mpeg|mpg|ogg|png|qt|ra|ram|rm|rmm|wav|webm|webp|wma|wmv)$/i", $file_info->source_filename)) |
|
| 959 | 959 | { |
| 960 | - $path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl); |
|
| 960 | + $path = sprintf("./files/attach/images/%s/%s/", $target_module_srl, $target_srl); |
|
| 961 | 961 | $new_file = $path.$file_info->source_filename; |
| 962 | 962 | } |
| 963 | 963 | else |
@@ -967,7 +967,7 @@ discard block |
||
| 967 | 967 | $new_file = $path.$random->createSecureSalt(32, 'hex'); |
| 968 | 968 | } |
| 969 | 969 | // Pass if a target document to move is same |
| 970 | - if($old_file == $new_file) continue; |
|
| 970 | + if ($old_file == $new_file) continue; |
|
| 971 | 971 | // Create a directory |
| 972 | 972 | FileHandler::makeDir($path); |
| 973 | 973 | // Move the file |
@@ -987,18 +987,18 @@ discard block |
||
| 987 | 987 | $vars = Context::getRequestVars(); |
| 988 | 988 | $logged_info = Context::get('logged_info'); |
| 989 | 989 | |
| 990 | - if(!$vars->editor_sequence) return new Object(-1, 'msg_invalid_request'); |
|
| 990 | + if (!$vars->editor_sequence) return new Object(-1, 'msg_invalid_request'); |
|
| 991 | 991 | |
| 992 | 992 | $upload_target_srl = $_SESSION['upload_info'][$vars->editor_sequence]->upload_target_srl; |
| 993 | 993 | |
| 994 | 994 | $oFileModel = getModel('file'); |
| 995 | 995 | $file_info = $oFileModel->getFile($vars->file_srl); |
| 996 | 996 | |
| 997 | - if(!$file_info) return new Object(-1, 'msg_not_founded'); |
|
| 997 | + if (!$file_info) return new Object(-1, 'msg_not_founded'); |
|
| 998 | 998 | |
| 999 | - if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted'); |
|
| 999 | + if (!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted'); |
|
| 1000 | 1000 | |
| 1001 | - $args = new stdClass(); |
|
| 1001 | + $args = new stdClass(); |
|
| 1002 | 1002 | $args->file_srl = $vars->file_srl; |
| 1003 | 1003 | $args->upload_target_srl = $upload_target_srl; |
| 1004 | 1004 | |
@@ -1007,18 +1007,18 @@ discard block |
||
| 1007 | 1007 | |
| 1008 | 1008 | $args->cover_image = 'N'; |
| 1009 | 1009 | $output = executeQuery('file.updateClearCoverImage', $args); |
| 1010 | - if(!$output->toBool()) |
|
| 1010 | + if (!$output->toBool()) |
|
| 1011 | 1011 | { |
| 1012 | 1012 | $oDB->rollback(); |
| 1013 | 1013 | return $output; |
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | - if($file_info->cover_image != 'Y') |
|
| 1016 | + if ($file_info->cover_image != 'Y') |
|
| 1017 | 1017 | { |
| 1018 | 1018 | |
| 1019 | 1019 | $args->cover_image = 'Y'; |
| 1020 | 1020 | $output = executeQuery('file.updateCoverImage', $args); |
| 1021 | - if(!$output->toBool()) |
|
| 1021 | + if (!$output->toBool()) |
|
| 1022 | 1022 | { |
| 1023 | 1023 | $oDB->rollback(); |
| 1024 | 1024 | return $output; |
@@ -1028,7 +1028,7 @@ discard block |
||
| 1028 | 1028 | |
| 1029 | 1029 | $oDB->commit(); |
| 1030 | 1030 | |
| 1031 | - $this->add('is_cover',$args->cover_image); |
|
| 1031 | + $this->add('is_cover', $args->cover_image); |
|
| 1032 | 1032 | |
| 1033 | 1033 | // 썸네일 삭제 |
| 1034 | 1034 | $thumbnail_path = sprintf('files/thumbnails/%s', getNumberingPath($upload_target_srl, 3)); |
@@ -1054,9 +1054,9 @@ discard block |
||
| 1054 | 1054 | $fileConfig = $oModuleModel->getModulePartConfig('file', $obj->originModuleSrl); |
| 1055 | 1055 | |
| 1056 | 1056 | $oModuleController = getController('module'); |
| 1057 | - if(is_array($obj->moduleSrlList)) |
|
| 1057 | + if (is_array($obj->moduleSrlList)) |
|
| 1058 | 1058 | { |
| 1059 | - foreach($obj->moduleSrlList AS $key=>$moduleSrl) |
|
| 1059 | + foreach ($obj->moduleSrlList AS $key=>$moduleSrl) |
|
| 1060 | 1060 | { |
| 1061 | 1061 | $oModuleController->insertModulePartConfig('file', $moduleSrl, $fileConfig); |
| 1062 | 1062 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | function isSsl() |
| 56 | 56 | { |
| 57 | - if(!is_null(self::$isSSL)) |
|
| 57 | + if (!is_null(self::$isSSL)) |
|
| 58 | 58 | { |
| 59 | 59 | return self::$isSSL; |
| 60 | 60 | } |
@@ -88,30 +88,30 @@ discard block |
||
| 88 | 88 | * */ |
| 89 | 89 | function loadFile($args) |
| 90 | 90 | { |
| 91 | - if(!is_array($args)) |
|
| 91 | + if (!is_array($args)) |
|
| 92 | 92 | { |
| 93 | 93 | $args = array($args); |
| 94 | 94 | } |
| 95 | 95 | $file = $this->getFileInfo($args[0], $args[2], $args[1]); |
| 96 | 96 | |
| 97 | 97 | $availableExtension = array('css' => 1, 'js' => 1); |
| 98 | - if(!isset($availableExtension[$file->fileExtension])) |
|
| 98 | + if (!isset($availableExtension[$file->fileExtension])) |
|
| 99 | 99 | { |
| 100 | 100 | return; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | $file->index = (int) $args[3]; |
| 104 | 104 | |
| 105 | - if($file->fileExtension == 'css') |
|
| 105 | + if ($file->fileExtension == 'css') |
|
| 106 | 106 | { |
| 107 | 107 | $map = &$this->cssMap; |
| 108 | 108 | $mapIndex = &$this->cssMapIndex; |
| 109 | 109 | |
| 110 | 110 | $this->_arrangeCssIndex($pathInfo['dirname'], $file); |
| 111 | 111 | } |
| 112 | - else if($file->fileExtension == 'js') |
|
| 112 | + else if ($file->fileExtension == 'js') |
|
| 113 | 113 | { |
| 114 | - if($args[1] == 'body') |
|
| 114 | + if ($args[1] == 'body') |
|
| 115 | 115 | { |
| 116 | 116 | $map = &$this->jsBodyMap; |
| 117 | 117 | $mapIndex = &$this->jsBodyMapIndex; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | (is_null($file->index)) ? $file->index = 0 : $file->index = $file->index; |
| 127 | - if(!isset($mapIndex[$file->key]) || $mapIndex[$file->key] > $file->index) |
|
| 127 | + if (!isset($mapIndex[$file->key]) || $mapIndex[$file->key] > $file->index) |
|
| 128 | 128 | { |
| 129 | 129 | $this->unloadFile($args[0], $args[2], $args[1]); |
| 130 | 130 | $map[$file->index][$file->key] = $file; |
@@ -144,14 +144,14 @@ discard block |
||
| 144 | 144 | { |
| 145 | 145 | static $existsInfo = array(); |
| 146 | 146 | |
| 147 | - if(isset($existsInfo[$existsKey])) |
|
| 147 | + if (isset($existsInfo[$existsKey])) |
|
| 148 | 148 | { |
| 149 | 149 | return $existsInfo[$existsKey]; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | $fileName = preg_replace('/(?:[\/]{3,})(.*)/', '//$1', $fileName); |
| 153 | 153 | $url_info = parse_url($fileName); |
| 154 | - $pathInfo = pathinfo(str_replace('?' . $url_info['query'], '', $fileName)); |
|
| 154 | + $pathInfo = pathinfo(str_replace('?'.$url_info['query'], '', $fileName)); |
|
| 155 | 155 | |
| 156 | 156 | $file = new stdClass(); |
| 157 | 157 | $file->fileName = basename($url_info['path']); |
@@ -164,14 +164,14 @@ discard block |
||
| 164 | 164 | $file->keyName = implode('.', array($file->fileNameNoExt, $file->fileExtension)); |
| 165 | 165 | $file->cdnPath = $this->_normalizeFilePath($pathInfo['dirname']); |
| 166 | 166 | |
| 167 | - if(!$file->external) |
|
| 167 | + if (!$file->external) |
|
| 168 | 168 | { |
| 169 | - if(!__DEBUG__ && __XE_VERSION_STABLE__) |
|
| 169 | + if (!__DEBUG__ && __XE_VERSION_STABLE__) |
|
| 170 | 170 | { |
| 171 | 171 | // if no debug mode, load minifed file |
| 172 | 172 | $minifiedFileName = implode('.', array($file->fileNameNoExt, 'min', $file->fileExtension)); |
| 173 | 173 | $minifiedRealPath = implode('/', array($file->fileRealPath, $minifiedFileName)); |
| 174 | - if(file_exists($minifiedRealPath)) |
|
| 174 | + if (file_exists($minifiedRealPath)) |
|
| 175 | 175 | { |
| 176 | 176 | $file->fileName = $minifiedFileName; |
| 177 | 177 | } |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | else |
| 180 | 180 | { |
| 181 | 181 | // Remove .min |
| 182 | - if(file_exists(implode('/', array($file->fileRealPath, $file->keyName)))) |
|
| 182 | + if (file_exists(implode('/', array($file->fileRealPath, $file->keyName)))) |
|
| 183 | 183 | { |
| 184 | 184 | $file->fileName = $file->keyName; |
| 185 | 185 | } |
@@ -188,18 +188,18 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | $file->targetIe = $targetIe; |
| 190 | 190 | |
| 191 | - if($file->fileExtension == 'css') |
|
| 191 | + if ($file->fileExtension == 'css') |
|
| 192 | 192 | { |
| 193 | 193 | $file->media = $media; |
| 194 | - if(!$file->media) |
|
| 194 | + if (!$file->media) |
|
| 195 | 195 | { |
| 196 | 196 | $file->media = 'all'; |
| 197 | 197 | } |
| 198 | - $file->key = $file->filePath . $file->keyName . "\t" . $file->targetIe . "\t" . $file->media; |
|
| 198 | + $file->key = $file->filePath.$file->keyName."\t".$file->targetIe."\t".$file->media; |
|
| 199 | 199 | } |
| 200 | - else if($file->fileExtension == 'js') |
|
| 200 | + else if ($file->fileExtension == 'js') |
|
| 201 | 201 | { |
| 202 | - $file->key = $file->filePath . $file->keyName . "\t" . $file->targetIe; |
|
| 202 | + $file->key = $file->filePath.$file->keyName."\t".$file->targetIe; |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | return $file; |
@@ -217,9 +217,9 @@ discard block |
||
| 217 | 217 | { |
| 218 | 218 | $file = $this->getFileInfo($fileName, $targetIe, $media); |
| 219 | 219 | |
| 220 | - if($file->fileExtension == 'css') |
|
| 220 | + if ($file->fileExtension == 'css') |
|
| 221 | 221 | { |
| 222 | - if(isset($this->cssMapIndex[$file->key])) |
|
| 222 | + if (isset($this->cssMapIndex[$file->key])) |
|
| 223 | 223 | { |
| 224 | 224 | $index = $this->cssMapIndex[$file->key]; |
| 225 | 225 | unset($this->cssMap[$index][$file->key], $this->cssMapIndex[$file->key]); |
@@ -227,12 +227,12 @@ discard block |
||
| 227 | 227 | } |
| 228 | 228 | else |
| 229 | 229 | { |
| 230 | - if(isset($this->jsHeadMapIndex[$file->key])) |
|
| 230 | + if (isset($this->jsHeadMapIndex[$file->key])) |
|
| 231 | 231 | { |
| 232 | 232 | $index = $this->jsHeadMapIndex[$file->key]; |
| 233 | 233 | unset($this->jsHeadMap[$index][$file->key], $this->jsHeadMapIndex[$file->key]); |
| 234 | 234 | } |
| 235 | - if(isset($this->jsBodyMapIndex[$file->key])) |
|
| 235 | + if (isset($this->jsBodyMapIndex[$file->key])) |
|
| 236 | 236 | { |
| 237 | 237 | $index = $this->jsBodyMapIndex[$file->key]; |
| 238 | 238 | unset($this->jsBodyMap[$index][$file->key], $this->jsBodyMapIndex[$file->key]); |
@@ -248,13 +248,13 @@ discard block |
||
| 248 | 248 | */ |
| 249 | 249 | function unloadAllFiles($type = 'all') |
| 250 | 250 | { |
| 251 | - if($type == 'css' || $type == 'all') |
|
| 251 | + if ($type == 'css' || $type == 'all') |
|
| 252 | 252 | { |
| 253 | 253 | $this->cssMap = array(); |
| 254 | 254 | $this->cssMapIndex = array(); |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - if($type == 'js' || $type == 'all') |
|
| 257 | + if ($type == 'js' || $type == 'all') |
|
| 258 | 258 | { |
| 259 | 259 | $this->jsHeadMap = array(); |
| 260 | 260 | $this->jsBodyMap = array(); |
@@ -276,23 +276,23 @@ discard block |
||
| 276 | 276 | $this->_sortMap($map, $mapIndex); |
| 277 | 277 | |
| 278 | 278 | $result = array(); |
| 279 | - foreach($map as $indexedMap) |
|
| 279 | + foreach ($map as $indexedMap) |
|
| 280 | 280 | { |
| 281 | - foreach($indexedMap as $file) |
|
| 281 | + foreach ($indexedMap as $file) |
|
| 282 | 282 | { |
| 283 | 283 | $query = ''; |
| 284 | - if(!$file->external && is_readable($file->cdnPath . '/' . $file->fileName)) |
|
| 284 | + if (!$file->external && is_readable($file->cdnPath.'/'.$file->fileName)) |
|
| 285 | 285 | { |
| 286 | - $query = date('YmdHis', filemtime($file->cdnPath . '/' . $file->fileName)); |
|
| 286 | + $query = date('YmdHis', filemtime($file->cdnPath.'/'.$file->fileName)); |
|
| 287 | 287 | } |
| 288 | - if($file->query) |
|
| 288 | + if ($file->query) |
|
| 289 | 289 | { |
| 290 | - if($query) $query .= '&'; |
|
| 290 | + if ($query) $query .= '&'; |
|
| 291 | 291 | $query .= $file->query; |
| 292 | 292 | } |
| 293 | - $query = ($query) ? '?' . $query : ''; |
|
| 293 | + $query = ($query) ? '?'.$query : ''; |
|
| 294 | 294 | |
| 295 | - $fullFilePath = $file->filePath . '/' . $file->fileName . $query; |
|
| 295 | + $fullFilePath = $file->filePath.'/'.$file->fileName.$query; |
|
| 296 | 296 | $result[] = array( |
| 297 | 297 | 'file' => $fullFilePath, |
| 298 | 298 | 'media' => $file->media, |
@@ -313,9 +313,9 @@ discard block |
||
| 313 | 313 | function getJsFileList($type = 'head') |
| 314 | 314 | { |
| 315 | 315 | $ignore = array('modernizr.js', 'common.js', 'js_app.js', 'xml2json.js', 'xml_handler.js', 'xml_js_filter.js'); |
| 316 | - $pathCommonJs = getScriptPath() . 'common/js'; |
|
| 316 | + $pathCommonJs = getScriptPath().'common/js'; |
|
| 317 | 317 | |
| 318 | - if($type == 'head') |
|
| 318 | + if ($type == 'head') |
|
| 319 | 319 | { |
| 320 | 320 | $map = &$this->jsHeadMap; |
| 321 | 321 | $mapIndex = &$this->jsHeadMapIndex; |
@@ -329,31 +329,31 @@ discard block |
||
| 329 | 329 | $this->_sortMap($map, $mapIndex); |
| 330 | 330 | |
| 331 | 331 | $result = array(); |
| 332 | - foreach($map as $indexedMap) |
|
| 332 | + foreach ($map as $indexedMap) |
|
| 333 | 333 | { |
| 334 | - foreach($indexedMap as $file) |
|
| 334 | + foreach ($indexedMap as $file) |
|
| 335 | 335 | { |
| 336 | - if((!__DEBUG__ && __XE_VERSION_STABLE__) && $file->filePath === $pathCommonJs) |
|
| 336 | + if ((!__DEBUG__ && __XE_VERSION_STABLE__) && $file->filePath === $pathCommonJs) |
|
| 337 | 337 | { |
| 338 | - if(in_array($file->fileName, $ignore)) |
|
| 338 | + if (in_array($file->fileName, $ignore)) |
|
| 339 | 339 | { |
| 340 | 340 | continue; |
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | $query = ''; |
| 345 | - if(!$file->external && is_readable($file->cdnPath . '/' . $file->fileName)) |
|
| 345 | + if (!$file->external && is_readable($file->cdnPath.'/'.$file->fileName)) |
|
| 346 | 346 | { |
| 347 | - $query = date('YmdHis', filemtime($file->cdnPath . '/' . $file->fileName)); |
|
| 347 | + $query = date('YmdHis', filemtime($file->cdnPath.'/'.$file->fileName)); |
|
| 348 | 348 | } |
| 349 | - if($file->query) |
|
| 349 | + if ($file->query) |
|
| 350 | 350 | { |
| 351 | - if($query) $query .= '&'; |
|
| 351 | + if ($query) $query .= '&'; |
|
| 352 | 352 | $query .= $file->query; |
| 353 | 353 | } |
| 354 | - $query = ($query) ? '?' . $query : ''; |
|
| 354 | + $query = ($query) ? '?'.$query : ''; |
|
| 355 | 355 | |
| 356 | - $fullFilePath = $file->filePath . '/' . $file->fileName . $query; |
|
| 356 | + $fullFilePath = $file->filePath.'/'.$file->fileName.$query; |
|
| 357 | 357 | $result[] = array( |
| 358 | 358 | 'file' => $fullFilePath, |
| 359 | 359 | 'targetie' => $file->targetIe |
@@ -384,18 +384,18 @@ discard block |
||
| 384 | 384 | */ |
| 385 | 385 | function _normalizeFilePath($path) |
| 386 | 386 | { |
| 387 | - if(strpos($path, '://') === FALSE && $path{0} != '/' && $path{0} != '.') |
|
| 387 | + if (strpos($path, '://') === FALSE && $path{0} != '/' && $path{0} != '.') |
|
| 388 | 388 | { |
| 389 | - $path = './' . $path; |
|
| 389 | + $path = './'.$path; |
|
| 390 | 390 | } |
| 391 | - elseif(!strncmp($path, '//', 2)) |
|
| 391 | + elseif (!strncmp($path, '//', 2)) |
|
| 392 | 392 | { |
| 393 | 393 | return preg_replace('#^//+#', '//', $path); |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | $path = preg_replace('@/\./|(?<!:)\/\/@', '/', $path); |
| 397 | 397 | |
| 398 | - while(strpos($path, '/../')) |
|
| 398 | + while (strpos($path, '/../')) |
|
| 399 | 399 | { |
| 400 | 400 | $path = preg_replace('/\/([^\/]+)\/\.\.\//s', '/', $path, 1); |
| 401 | 401 | } |
@@ -414,20 +414,20 @@ discard block |
||
| 414 | 414 | $path = $this->_normalizeFilePath($path); |
| 415 | 415 | $script_path = getScriptPath(); |
| 416 | 416 | |
| 417 | - if(strpos($path, './') === 0) |
|
| 417 | + if (strpos($path, './') === 0) |
|
| 418 | 418 | { |
| 419 | - if($script_path == '/' || $script_path == '\\') |
|
| 419 | + if ($script_path == '/' || $script_path == '\\') |
|
| 420 | 420 | { |
| 421 | - $path = '/' . substr($path, 2); |
|
| 421 | + $path = '/'.substr($path, 2); |
|
| 422 | 422 | } |
| 423 | 423 | else |
| 424 | 424 | { |
| 425 | - $path = $script_path . substr($path, 2); |
|
| 425 | + $path = $script_path.substr($path, 2); |
|
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | - else if(strpos($file, '../') === 0) |
|
| 428 | + else if (strpos($file, '../') === 0) |
|
| 429 | 429 | { |
| 430 | - $path = $this->_normalizeFilePath($script_path . $path); |
|
| 430 | + $path = $this->_normalizeFilePath($script_path.$path); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | return $path; |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | */ |
| 443 | 443 | function _arrangeCssIndex($dirName, &$file) |
| 444 | 444 | { |
| 445 | - if($file->index !== 0) |
|
| 445 | + if ($file->index !== 0) |
|
| 446 | 446 | { |
| 447 | 447 | return; |
| 448 | 448 | } |