@@ -29,24 +29,24 @@ 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 | - if($output->error != '0') $this->stop($output->message); |
|
| 49 | + if ($output->error != '0') $this->stop($output->message); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -61,26 +61,26 @@ discard block |
||
| 61 | 61 | $callback = Context::get('callback'); |
| 62 | 62 | $module_srl = $this->module_srl; |
| 63 | 63 | $upload_target_srl = intval(Context::get('uploadTargetSrl')); |
| 64 | - if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
| 64 | + if (!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
| 65 | 65 | |
| 66 | 66 | // Exit a session if there is neither upload permission nor information |
| 67 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
| 67 | + if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
| 68 | 68 | // Extract from session information if upload_target_srl is not specified |
| 69 | - if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
| 69 | + if (!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
| 70 | 70 | // Create if upload_target_srl is not defined in the session information |
| 71 | - if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
| 71 | + if (!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
| 72 | 72 | // Delete and then attempt to re-upload if file_srl is requested |
| 73 | 73 | $file_srl = Context::get('file_srl'); |
| 74 | - if($file_srl) $this->deleteFile($file_srl); |
|
| 74 | + if ($file_srl) $this->deleteFile($file_srl); |
|
| 75 | 75 | |
| 76 | 76 | $file_info = Context::get('Filedata'); |
| 77 | 77 | // An error appears if not a normally uploaded file |
| 78 | - if(is_uploaded_file($file_info['tmp_name'])) { |
|
| 78 | + if (is_uploaded_file($file_info['tmp_name'])) { |
|
| 79 | 79 | $output = $this->insertFile($file_info, $module_srl, $upload_target_srl); |
| 80 | - Context::set('uploaded_fileinfo',$output); |
|
| 80 | + Context::set('uploaded_fileinfo', $output); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - Context::set('layout','none'); |
|
| 83 | + Context::set('layout', 'none'); |
|
| 84 | 84 | |
| 85 | 85 | $this->setTemplatePath($this->module_path.'tpl'); |
| 86 | 86 | $this->setTemplateFile('iframe'); |
@@ -97,24 +97,24 @@ discard block |
||
| 97 | 97 | $width = Context::get('width'); |
| 98 | 98 | $height = Context::get('height'); |
| 99 | 99 | |
| 100 | - if(!$file_srl || !$width) |
|
| 100 | + if (!$file_srl || !$width) |
|
| 101 | 101 | { |
| 102 | - return new Object(-1,'msg_invalid_request'); |
|
| 102 | + return new Object(-1, 'msg_invalid_request'); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | $oFileModel = getModel('file'); |
| 106 | 106 | $fileInfo = $oFileModel->getFile($file_srl); |
| 107 | - if(!$fileInfo || $fileInfo->direct_download != 'Y') |
|
| 107 | + if (!$fileInfo || $fileInfo->direct_download != 'Y') |
|
| 108 | 108 | { |
| 109 | - return new Object(-1,'msg_invalid_request'); |
|
| 109 | + return new Object(-1, 'msg_invalid_request'); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | $source_src = $fileInfo->uploaded_filename; |
| 113 | - $output_src = $source_src . '.resized' . strrchr($source_src,'.'); |
|
| 113 | + $output_src = $source_src.'.resized'.strrchr($source_src, '.'); |
|
| 114 | 114 | |
| 115 | - if(!$height) $height = $width-1; |
|
| 115 | + if (!$height) $height = $width - 1; |
|
| 116 | 116 | |
| 117 | - if(FileHandler::createImageFile($source_src,$output_src,$width,$height,'','ratio')) |
|
| 117 | + if (FileHandler::createImageFile($source_src, $output_src, $width, $height, '', 'ratio')) |
|
| 118 | 118 | { |
| 119 | 119 | $output = new stdClass(); |
| 120 | 120 | $output->info = getimagesize($output_src); |
@@ -122,10 +122,10 @@ discard block |
||
| 122 | 122 | } |
| 123 | 123 | else |
| 124 | 124 | { |
| 125 | - return new Object(-1,'msg_invalid_request'); |
|
| 125 | + return new Object(-1, 'msg_invalid_request'); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $this->add('resized_info',$output); |
|
| 128 | + $this->add('resized_info', $output); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | { |
| 164 | 164 | $oFileModel = getModel('file'); |
| 165 | 165 | |
| 166 | - if(isset($this->grant->access) && $this->grant->access !== true) return new Object(-1, 'msg_not_permitted'); |
|
| 166 | + if (isset($this->grant->access) && $this->grant->access !== true) return new Object(-1, 'msg_not_permitted'); |
|
| 167 | 167 | |
| 168 | 168 | $file_srl = Context::get('file_srl'); |
| 169 | 169 | $sid = Context::get('sid'); |
@@ -172,26 +172,26 @@ discard block |
||
| 172 | 172 | $columnList = array('file_srl', 'sid', 'isvalid', 'source_filename', 'module_srl', 'uploaded_filename', 'file_size', 'member_srl', 'upload_target_srl', 'upload_target_type'); |
| 173 | 173 | $file_obj = $oFileModel->getFile($file_srl, $columnList); |
| 174 | 174 | // If the requested file information is incorrect, an error that file cannot be found appears |
| 175 | - if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) return $this->stop('msg_file_not_found'); |
|
| 175 | + if ($file_obj->file_srl != $file_srl || $file_obj->sid != $sid) return $this->stop('msg_file_not_found'); |
|
| 176 | 176 | // Notify that file download is not allowed when standing-by(Only a top-administrator is permitted) |
| 177 | - if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') return $this->stop('msg_not_permitted_download'); |
|
| 177 | + if ($logged_info->is_admin != 'Y' && $file_obj->isvalid != 'Y') return $this->stop('msg_not_permitted_download'); |
|
| 178 | 178 | // File name |
| 179 | 179 | $filename = $file_obj->source_filename; |
| 180 | 180 | $file_module_config = $oFileModel->getFileModuleConfig($file_obj->module_srl); |
| 181 | 181 | // Not allow the file outlink |
| 182 | - if($file_module_config->allow_outlink == 'N') |
|
| 182 | + if ($file_module_config->allow_outlink == 'N') |
|
| 183 | 183 | { |
| 184 | 184 | // Handles extension to allow outlink |
| 185 | - if($file_module_config->allow_outlink_format) |
|
| 185 | + if ($file_module_config->allow_outlink_format) |
|
| 186 | 186 | { |
| 187 | 187 | $allow_outlink_format_array = array(); |
| 188 | 188 | $allow_outlink_format_array = explode(',', $file_module_config->allow_outlink_format); |
| 189 | - if(!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format; |
|
| 189 | + if (!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format; |
|
| 190 | 190 | |
| 191 | - foreach($allow_outlink_format_array as $val) |
|
| 191 | + foreach ($allow_outlink_format_array as $val) |
|
| 192 | 192 | { |
| 193 | 193 | $val = trim($val); |
| 194 | - if(preg_match("/\.{$val}$/i", $filename)) |
|
| 194 | + if (preg_match("/\.{$val}$/i", $filename)) |
|
| 195 | 195 | { |
| 196 | 196 | $file_module_config->allow_outlink = 'Y'; |
| 197 | 197 | break; |
@@ -199,21 +199,21 @@ discard block |
||
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | // Sites that outlink is allowed |
| 202 | - if($file_module_config->allow_outlink != 'Y') |
|
| 202 | + if ($file_module_config->allow_outlink != 'Y') |
|
| 203 | 203 | { |
| 204 | 204 | $referer = parse_url($_SERVER["HTTP_REFERER"]); |
| 205 | - if($referer['host'] != $_SERVER['HTTP_HOST']) |
|
| 205 | + if ($referer['host'] != $_SERVER['HTTP_HOST']) |
|
| 206 | 206 | { |
| 207 | - if($file_module_config->allow_outlink_site) |
|
| 207 | + if ($file_module_config->allow_outlink_site) |
|
| 208 | 208 | { |
| 209 | 209 | $allow_outlink_site_array = array(); |
| 210 | 210 | $allow_outlink_site_array = explode("\n", $file_module_config->allow_outlink_site); |
| 211 | - if(!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site; |
|
| 211 | + if (!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site; |
|
| 212 | 212 | |
| 213 | - foreach($allow_outlink_site_array as $val) |
|
| 213 | + foreach ($allow_outlink_site_array as $val) |
|
| 214 | 214 | { |
| 215 | 215 | $site = parse_url(trim($val)); |
| 216 | - if($site['host'] == $referer['host']) |
|
| 216 | + if ($site['host'] == $referer['host']) |
|
| 217 | 217 | { |
| 218 | 218 | $file_module_config->allow_outlink = 'Y'; |
| 219 | 219 | break; |
@@ -223,49 +223,49 @@ discard block |
||
| 223 | 223 | } |
| 224 | 224 | else $file_module_config->allow_outlink = 'Y'; |
| 225 | 225 | } |
| 226 | - if($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink'); |
|
| 226 | + if ($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink'); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | // Check if a permission for file download is granted |
| 230 | 230 | $downloadGrantCount = 0; |
| 231 | - if(is_array($file_module_config->download_grant)) |
|
| 231 | + if (is_array($file_module_config->download_grant)) |
|
| 232 | 232 | { |
| 233 | - foreach($file_module_config->download_grant AS $value) |
|
| 234 | - if($value) $downloadGrantCount++; |
|
| 233 | + foreach ($file_module_config->download_grant AS $value) |
|
| 234 | + if ($value) $downloadGrantCount++; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - if(is_array($file_module_config->download_grant) && $downloadGrantCount>0) |
|
| 237 | + if (is_array($file_module_config->download_grant) && $downloadGrantCount > 0) |
|
| 238 | 238 | { |
| 239 | - if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download'); |
|
| 239 | + if (!Context::get('is_logged')) return $this->stop('msg_not_permitted_download'); |
|
| 240 | 240 | $logged_info = Context::get('logged_info'); |
| 241 | - if($logged_info->is_admin != 'Y') |
|
| 241 | + if ($logged_info->is_admin != 'Y') |
|
| 242 | 242 | { |
| 243 | - $oModuleModel =& getModel('module'); |
|
| 243 | + $oModuleModel = & getModel('module'); |
|
| 244 | 244 | $columnList = array('module_srl', 'site_srl'); |
| 245 | 245 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($file_obj->module_srl, $columnList); |
| 246 | 246 | |
| 247 | - if(!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl)) |
|
| 247 | + if (!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl)) |
|
| 248 | 248 | { |
| 249 | - $oMemberModel =& getModel('member'); |
|
| 249 | + $oMemberModel = & getModel('member'); |
|
| 250 | 250 | $member_groups = $oMemberModel->getMemberGroups($logged_info->member_srl, $module_info->site_srl); |
| 251 | 251 | |
| 252 | 252 | $is_permitted = false; |
| 253 | - for($i=0;$i<count($file_module_config->download_grant);$i++) |
|
| 253 | + for ($i = 0; $i < count($file_module_config->download_grant); $i++) |
|
| 254 | 254 | { |
| 255 | 255 | $group_srl = $file_module_config->download_grant[$i]; |
| 256 | - if($member_groups[$group_srl]) |
|
| 256 | + if ($member_groups[$group_srl]) |
|
| 257 | 257 | { |
| 258 | 258 | $is_permitted = true; |
| 259 | 259 | break; |
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | - if(!$is_permitted) return $this->stop('msg_not_permitted_download'); |
|
| 262 | + if (!$is_permitted) return $this->stop('msg_not_permitted_download'); |
|
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | } |
| 266 | 266 | // Call a trigger (before) |
| 267 | 267 | $output = ModuleHandler::triggerCall('file.downloadFile', 'before', $file_obj); |
| 268 | - if(!$output->toBool()) return $this->stop(($output->message)?$output->message:'msg_not_permitted_download'); |
|
| 268 | + if (!$output->toBool()) return $this->stop(($output->message) ? $output->message : 'msg_not_permitted_download'); |
|
| 269 | 269 | |
| 270 | 270 | |
| 271 | 271 | // 다운로드 후 (가상) |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | |
| 279 | 279 | $random = new Password(); |
| 280 | 280 | $file_key = $_SESSION['__XE_FILE_KEY__'][$file_srl] = $random->createSecureSalt(32, 'hex'); |
| 281 | - header('Location: '.getNotEncodedUrl('', 'act', 'procFileOutput','file_srl',$file_srl,'file_key',$file_key)); |
|
| 281 | + header('Location: '.getNotEncodedUrl('', 'act', 'procFileOutput', 'file_srl', $file_srl, 'file_key', $file_key)); |
|
| 282 | 282 | Context::close(); |
| 283 | 283 | exit(); |
| 284 | 284 | |
@@ -289,18 +289,18 @@ discard block |
||
| 289 | 289 | $oFileModel = getModel('file'); |
| 290 | 290 | $file_srl = Context::get('file_srl'); |
| 291 | 291 | $file_key = Context::get('file_key'); |
| 292 | - if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true; |
|
| 292 | + if (strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true; |
|
| 293 | 293 | |
| 294 | - if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__'; |
|
| 294 | + if ($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__'; |
|
| 295 | 295 | else $session_key = '__XE_FILE_KEY__'; |
| 296 | 296 | $columnList = array('source_filename', 'uploaded_filename', 'file_size'); |
| 297 | 297 | $file_obj = $oFileModel->getFile($file_srl, $columnList); |
| 298 | 298 | |
| 299 | 299 | $uploaded_filename = $file_obj->uploaded_filename; |
| 300 | 300 | |
| 301 | - if(!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found'); |
|
| 301 | + if (!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found'); |
|
| 302 | 302 | |
| 303 | - if(!$file_key || $_SESSION[$session_key][$file_srl] != $file_key) |
|
| 303 | + if (!$file_key || $_SESSION[$session_key][$file_srl] != $file_key) |
|
| 304 | 304 | { |
| 305 | 305 | unset($_SESSION[$session_key][$file_srl]); |
| 306 | 306 | return $this->stop('msg_invalid_request'); |
@@ -308,15 +308,15 @@ discard block |
||
| 308 | 308 | |
| 309 | 309 | $file_size = $file_obj->file_size; |
| 310 | 310 | $filename = $file_obj->source_filename; |
| 311 | - if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE || strpos($_SERVER['HTTP_USER_AGENT'], 'Edge') !== FALSE || (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== FALSE && strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== FALSE && strpos($_SERVER['HTTP_USER_AGENT'], 'rv:') !== FALSE)) |
|
| 311 | + if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE || strpos($_SERVER['HTTP_USER_AGENT'], 'Edge') !== FALSE || (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== FALSE && strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== FALSE && strpos($_SERVER['HTTP_USER_AGENT'], 'rv:') !== FALSE)) |
|
| 312 | 312 | { |
| 313 | 313 | $filename = rawurlencode($filename); |
| 314 | 314 | $filename = preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1); |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - if($is_android) |
|
| 317 | + if ($is_android) |
|
| 318 | 318 | { |
| 319 | - if($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
| 319 | + if ($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | unset($_SESSION[$session_key][$file_srl]); |
@@ -324,21 +324,21 @@ discard block |
||
| 324 | 324 | Context::close(); |
| 325 | 325 | |
| 326 | 326 | $fp = fopen($uploaded_filename, 'rb'); |
| 327 | - if(!$fp) return $this->stop('msg_file_not_found'); |
|
| 327 | + if (!$fp) return $this->stop('msg_file_not_found'); |
|
| 328 | 328 | |
| 329 | 329 | header("Cache-Control: "); |
| 330 | 330 | header("Pragma: "); |
| 331 | 331 | header("Content-Type: application/octet-stream"); |
| 332 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
| 332 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
| 333 | 333 | |
| 334 | - header("Content-Length: " .(string)($file_size)); |
|
| 334 | + header("Content-Length: ".(string) ($file_size)); |
|
| 335 | 335 | header('Content-Disposition: attachment; filename="'.$filename.'"'); |
| 336 | 336 | header("Content-Transfer-Encoding: binary\n"); |
| 337 | 337 | |
| 338 | 338 | // if file size is lager than 10MB, use fread function (#18675748) |
| 339 | - if(filesize($uploaded_filename) > 1024 * 1024) |
|
| 339 | + if (filesize($uploaded_filename) > 1024 * 1024) |
|
| 340 | 340 | { |
| 341 | - while(!feof($fp)) echo fread($fp, 1024); |
|
| 341 | + while (!feof($fp)) echo fread($fp, 1024); |
|
| 342 | 342 | fclose($fp); |
| 343 | 343 | } |
| 344 | 344 | else |
@@ -360,36 +360,36 @@ discard block |
||
| 360 | 360 | $editor_sequence = Context::get('editor_sequence'); |
| 361 | 361 | $file_srl = Context::get('file_srl'); |
| 362 | 362 | $file_srls = Context::get('file_srls'); |
| 363 | - if($file_srls) $file_srl = $file_srls; |
|
| 363 | + if ($file_srls) $file_srl = $file_srls; |
|
| 364 | 364 | // Exit a session if there is neither upload permission nor information |
| 365 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
| 365 | + if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
| 366 | 366 | |
| 367 | 367 | $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
| 368 | 368 | |
| 369 | 369 | $logged_info = Context::get('logged_info'); |
| 370 | 370 | $oFileModel = getModel('file'); |
| 371 | 371 | |
| 372 | - $srls = explode(',',$file_srl); |
|
| 373 | - if(!count($srls)) return; |
|
| 372 | + $srls = explode(',', $file_srl); |
|
| 373 | + if (!count($srls)) return; |
|
| 374 | 374 | |
| 375 | - for($i=0;$i<count($srls);$i++) |
|
| 375 | + for ($i = 0; $i < count($srls); $i++) |
|
| 376 | 376 | { |
| 377 | - $srl = (int)$srls[$i]; |
|
| 378 | - if(!$srl) continue; |
|
| 377 | + $srl = (int) $srls[$i]; |
|
| 378 | + if (!$srl) continue; |
|
| 379 | 379 | |
| 380 | 380 | $args = new stdClass; |
| 381 | 381 | $args->file_srl = $srl; |
| 382 | 382 | $output = executeQuery('file.getFile', $args); |
| 383 | - if(!$output->toBool()) continue; |
|
| 383 | + if (!$output->toBool()) continue; |
|
| 384 | 384 | |
| 385 | 385 | $file_info = $output->data; |
| 386 | - if(!$file_info) continue; |
|
| 386 | + if (!$file_info) continue; |
|
| 387 | 387 | |
| 388 | 388 | $file_grant = $oFileModel->getFileGrant($file_info, $logged_info); |
| 389 | 389 | |
| 390 | - if(!$file_grant->is_deletable) continue; |
|
| 390 | + if (!$file_grant->is_deletable) continue; |
|
| 391 | 391 | |
| 392 | - if($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl); |
|
| 392 | + if ($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl); |
|
| 393 | 393 | } |
| 394 | 394 | } |
| 395 | 395 | |
@@ -400,23 +400,23 @@ discard block |
||
| 400 | 400 | */ |
| 401 | 401 | function procFileGetList() |
| 402 | 402 | { |
| 403 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
| 403 | + if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted'); |
|
| 404 | 404 | $fileSrls = Context::get('file_srls'); |
| 405 | - if($fileSrls) $fileSrlList = explode(',', $fileSrls); |
|
| 405 | + if ($fileSrls) $fileSrlList = explode(',', $fileSrls); |
|
| 406 | 406 | |
| 407 | 407 | global $lang; |
| 408 | - if(count($fileSrlList) > 0) |
|
| 408 | + if (count($fileSrlList) > 0) |
|
| 409 | 409 | { |
| 410 | 410 | $oFileModel = getModel('file'); |
| 411 | 411 | $fileList = $oFileModel->getFile($fileSrlList); |
| 412 | - if(!is_array($fileList)) $fileList = array($fileList); |
|
| 412 | + if (!is_array($fileList)) $fileList = array($fileList); |
|
| 413 | 413 | |
| 414 | - if(is_array($fileList)) |
|
| 414 | + if (is_array($fileList)) |
|
| 415 | 415 | { |
| 416 | - foreach($fileList AS $key=>$value) |
|
| 416 | + foreach ($fileList AS $key=>$value) |
|
| 417 | 417 | { |
| 418 | 418 | $value->human_file_size = FileHandler::filesize($value->file_size); |
| 419 | - if($value->isvalid=='Y') $value->validName = $lang->is_valid; |
|
| 419 | + if ($value->isvalid == 'Y') $value->validName = $lang->is_valid; |
|
| 420 | 420 | else $value->validName = $lang->is_stand_by; |
| 421 | 421 | } |
| 422 | 422 | } |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | function triggerCheckAttached(&$obj) |
| 439 | 439 | { |
| 440 | 440 | $document_srl = $obj->document_srl; |
| 441 | - if(!$document_srl) return new Object(); |
|
| 441 | + if (!$document_srl) return new Object(); |
|
| 442 | 442 | // Get numbers of attachments |
| 443 | 443 | $oFileModel = getModel('file'); |
| 444 | 444 | $obj->uploaded_count = $oFileModel->getFilesCount($document_srl); |
@@ -455,10 +455,10 @@ discard block |
||
| 455 | 455 | function triggerAttachFiles(&$obj) |
| 456 | 456 | { |
| 457 | 457 | $document_srl = $obj->document_srl; |
| 458 | - if(!$document_srl) return new Object(); |
|
| 458 | + if (!$document_srl) return new Object(); |
|
| 459 | 459 | |
| 460 | 460 | $output = $this->setFilesValid($document_srl); |
| 461 | - if(!$output->toBool()) return $output; |
|
| 461 | + if (!$output->toBool()) return $output; |
|
| 462 | 462 | |
| 463 | 463 | return new Object(); |
| 464 | 464 | } |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | function triggerDeleteAttached(&$obj) |
| 473 | 473 | { |
| 474 | 474 | $document_srl = $obj->document_srl; |
| 475 | - if(!$document_srl) return new Object(); |
|
| 475 | + if (!$document_srl) return new Object(); |
|
| 476 | 476 | |
| 477 | 477 | $output = $this->deleteFiles($document_srl); |
| 478 | 478 | return $output; |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | function triggerCommentCheckAttached(&$obj) |
| 488 | 488 | { |
| 489 | 489 | $comment_srl = $obj->comment_srl; |
| 490 | - if(!$comment_srl) return new Object(); |
|
| 490 | + if (!$comment_srl) return new Object(); |
|
| 491 | 491 | // Get numbers of attachments |
| 492 | 492 | $oFileModel = getModel('file'); |
| 493 | 493 | $obj->uploaded_count = $oFileModel->getFilesCount($comment_srl); |
@@ -505,10 +505,10 @@ discard block |
||
| 505 | 505 | { |
| 506 | 506 | $comment_srl = $obj->comment_srl; |
| 507 | 507 | $uploaded_count = $obj->uploaded_count; |
| 508 | - if(!$comment_srl || !$uploaded_count) return new Object(); |
|
| 508 | + if (!$comment_srl || !$uploaded_count) return new Object(); |
|
| 509 | 509 | |
| 510 | 510 | $output = $this->setFilesValid($comment_srl); |
| 511 | - if(!$output->toBool()) return $output; |
|
| 511 | + if (!$output->toBool()) return $output; |
|
| 512 | 512 | |
| 513 | 513 | return new Object(); |
| 514 | 514 | } |
@@ -522,9 +522,9 @@ discard block |
||
| 522 | 522 | function triggerCommentDeleteAttached(&$obj) |
| 523 | 523 | { |
| 524 | 524 | $comment_srl = $obj->comment_srl; |
| 525 | - if(!$comment_srl) return new Object(); |
|
| 525 | + if (!$comment_srl) return new Object(); |
|
| 526 | 526 | |
| 527 | - if($obj->isMoveToTrash) return new Object(); |
|
| 527 | + if ($obj->isMoveToTrash) return new Object(); |
|
| 528 | 528 | |
| 529 | 529 | $output = $this->deleteFiles($comment_srl); |
| 530 | 530 | return $output; |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | function triggerDeleteModuleFiles(&$obj) |
| 540 | 540 | { |
| 541 | 541 | $module_srl = $obj->module_srl; |
| 542 | - if(!$module_srl) return new Object(); |
|
| 542 | + if (!$module_srl) return new Object(); |
|
| 543 | 543 | |
| 544 | 544 | $oFileController = getAdminController('file'); |
| 545 | 545 | return $oFileController->deleteModuleFiles($module_srl); |
@@ -552,9 +552,9 @@ discard block |
||
| 552 | 552 | * @param int $upload_target_srl |
| 553 | 553 | * @return void |
| 554 | 554 | */ |
| 555 | - function setUploadInfo($editor_sequence, $upload_target_srl=0) |
|
| 555 | + function setUploadInfo($editor_sequence, $upload_target_srl = 0) |
|
| 556 | 556 | { |
| 557 | - if(!isset($_SESSION['upload_info'][$editor_sequence])) |
|
| 557 | + if (!isset($_SESSION['upload_info'][$editor_sequence])) |
|
| 558 | 558 | { |
| 559 | 559 | $_SESSION['upload_info'][$editor_sequence] = new stdClass(); |
| 560 | 560 | } |
@@ -614,36 +614,36 @@ discard block |
||
| 614 | 614 | $trigger_obj->module_srl = $module_srl; |
| 615 | 615 | $trigger_obj->upload_target_srl = $upload_target_srl; |
| 616 | 616 | $output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj); |
| 617 | - if(!$output->toBool()) return $output; |
|
| 617 | + if (!$output->toBool()) return $output; |
|
| 618 | 618 | |
| 619 | 619 | // A workaround for Firefox upload bug |
| 620 | - if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match)) |
|
| 620 | + if (preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match)) |
|
| 621 | 621 | { |
| 622 | 622 | $file_info['name'] = base64_decode(strtr($match[1], ':', '/')); |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | - if(!$manual_insert) |
|
| 625 | + if (!$manual_insert) |
|
| 626 | 626 | { |
| 627 | 627 | // Get the file configurations |
| 628 | 628 | $logged_info = Context::get('logged_info'); |
| 629 | - if($logged_info->is_admin != 'Y') |
|
| 629 | + if ($logged_info->is_admin != 'Y') |
|
| 630 | 630 | { |
| 631 | 631 | $oFileModel = getModel('file'); |
| 632 | 632 | $config = $oFileModel->getFileConfig($module_srl); |
| 633 | 633 | |
| 634 | 634 | // check file type |
| 635 | - if(isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*') |
|
| 635 | + if (isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*') |
|
| 636 | 636 | { |
| 637 | 637 | $filetypes = explode(';', $config->allowed_filetypes); |
| 638 | 638 | $ext = array(); |
| 639 | - foreach($filetypes as $item) { |
|
| 639 | + foreach ($filetypes as $item) { |
|
| 640 | 640 | $item = explode('.', $item); |
| 641 | 641 | $ext[] = strtolower($item[1]); |
| 642 | 642 | } |
| 643 | 643 | $uploaded_ext = explode('.', $file_info['name']); |
| 644 | 644 | $uploaded_ext = strtolower(array_pop($uploaded_ext)); |
| 645 | 645 | |
| 646 | - if(!in_array($uploaded_ext, $ext)) |
|
| 646 | + if (!in_array($uploaded_ext, $ext)) |
|
| 647 | 647 | { |
| 648 | 648 | return $this->stop('msg_not_allowed_filetype'); |
| 649 | 649 | } |
@@ -652,63 +652,63 @@ discard block |
||
| 652 | 652 | $allowed_filesize = $config->allowed_filesize * 1024 * 1024; |
| 653 | 653 | $allowed_attach_size = $config->allowed_attach_size * 1024 * 1024; |
| 654 | 654 | // An error appears if file size exceeds a limit |
| 655 | - if($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-1, 'msg_exceeds_limit_size'); |
|
| 655 | + if ($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-1, 'msg_exceeds_limit_size'); |
|
| 656 | 656 | // Get total file size of all attachements (from DB) |
| 657 | 657 | $size_args = new stdClass; |
| 658 | 658 | $size_args->upload_target_srl = $upload_target_srl; |
| 659 | 659 | $output = executeQuery('file.getAttachedFileSize', $size_args); |
| 660 | - $attached_size = (int)$output->data->attached_size + filesize($file_info['tmp_name']); |
|
| 661 | - if($attached_size > $allowed_attach_size) return new Object(-1, 'msg_exceeds_limit_size'); |
|
| 660 | + $attached_size = (int) $output->data->attached_size + filesize($file_info['tmp_name']); |
|
| 661 | + if ($attached_size > $allowed_attach_size) return new Object(-1, 'msg_exceeds_limit_size'); |
|
| 662 | 662 | } |
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | // https://github.com/xpressengine/xe-core/issues/1713 |
| 666 | - $file_info['name'] = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x',$file_info['name']); |
|
| 666 | + $file_info['name'] = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x', $file_info['name']); |
|
| 667 | 667 | $file_info['name'] = removeHackTag($file_info['name']); |
| 668 | - $file_info['name'] = str_replace(array('<','>'),array('%3C','%3E'),$file_info['name']); |
|
| 668 | + $file_info['name'] = str_replace(array('<', '>'), array('%3C', '%3E'), $file_info['name']); |
|
| 669 | 669 | |
| 670 | 670 | // Get random number generator |
| 671 | 671 | $random = new Password(); |
| 672 | 672 | |
| 673 | 673 | // Set upload path by checking if the attachement is an image or other kinds of file |
| 674 | - if(preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|swf|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_info['name'])) |
|
| 674 | + if (preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|swf|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_info['name'])) |
|
| 675 | 675 | { |
| 676 | - $path = sprintf("./files/attach/images/%s/%s", $module_srl,getNumberingPath($upload_target_srl,3)); |
|
| 676 | + $path = sprintf("./files/attach/images/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3)); |
|
| 677 | 677 | |
| 678 | 678 | // special character to '_' |
| 679 | 679 | // change to random file name. because window php bug. window php is not recognize unicode character file name - by cherryfilter |
| 680 | - $ext = substr(strrchr($file_info['name'],'.'),1); |
|
| 680 | + $ext = substr(strrchr($file_info['name'], '.'), 1); |
|
| 681 | 681 | //$_filename = preg_replace('/[#$&*?+%"\']/', '_', $file_info['name']); |
| 682 | 682 | $_filename = $random->createSecureSalt(32, 'hex').'.'.$ext; |
| 683 | 683 | $filename = $path.$_filename; |
| 684 | 684 | $idx = 1; |
| 685 | - while(file_exists($filename)) |
|
| 685 | + while (file_exists($filename)) |
|
| 686 | 686 | { |
| 687 | - $filename = $path.preg_replace('/\.([a-z0-9]+)$/i','_'.$idx.'.$1',$_filename); |
|
| 687 | + $filename = $path.preg_replace('/\.([a-z0-9]+)$/i', '_'.$idx.'.$1', $_filename); |
|
| 688 | 688 | $idx++; |
| 689 | 689 | } |
| 690 | 690 | $direct_download = 'Y'; |
| 691 | 691 | } |
| 692 | 692 | else |
| 693 | 693 | { |
| 694 | - $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3)); |
|
| 694 | + $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3)); |
|
| 695 | 695 | $filename = $path.$random->createSecureSalt(32, 'hex'); |
| 696 | 696 | $direct_download = 'N'; |
| 697 | 697 | } |
| 698 | 698 | // Create a directory |
| 699 | - if(!FileHandler::makeDir($path)) return new Object(-1,'msg_not_permitted_create'); |
|
| 699 | + if (!FileHandler::makeDir($path)) return new Object(-1, 'msg_not_permitted_create'); |
|
| 700 | 700 | |
| 701 | 701 | // Check uploaded file |
| 702 | - if(!checkUploadedFile($file_info['tmp_name'])) return new Object(-1,'msg_file_upload_error'); |
|
| 702 | + if (!checkUploadedFile($file_info['tmp_name'])) return new Object(-1, 'msg_file_upload_error'); |
|
| 703 | 703 | |
| 704 | 704 | // Get random number generator |
| 705 | 705 | $random = new Password(); |
| 706 | 706 | |
| 707 | 707 | // Move the file |
| 708 | - if($manual_insert) |
|
| 708 | + if ($manual_insert) |
|
| 709 | 709 | { |
| 710 | 710 | @copy($file_info['tmp_name'], $filename); |
| 711 | - if(!file_exists($filename)) |
|
| 711 | + if (!file_exists($filename)) |
|
| 712 | 712 | { |
| 713 | 713 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
| 714 | 714 | @copy($file_info['tmp_name'], $filename); |
@@ -716,10 +716,10 @@ discard block |
||
| 716 | 716 | } |
| 717 | 717 | else |
| 718 | 718 | { |
| 719 | - if(!@move_uploaded_file($file_info['tmp_name'], $filename)) |
|
| 719 | + if (!@move_uploaded_file($file_info['tmp_name'], $filename)) |
|
| 720 | 720 | { |
| 721 | 721 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
| 722 | - if(!@move_uploaded_file($file_info['tmp_name'], $filename)) return new Object(-1,'msg_file_upload_error'); |
|
| 722 | + if (!@move_uploaded_file($file_info['tmp_name'], $filename)) return new Object(-1, 'msg_file_upload_error'); |
|
| 723 | 723 | } |
| 724 | 724 | } |
| 725 | 725 | // Get member information |
@@ -740,10 +740,10 @@ discard block |
||
| 740 | 740 | $args->sid = $random->createSecureSalt(32, 'hex'); |
| 741 | 741 | |
| 742 | 742 | $output = executeQuery('file.insertFile', $args); |
| 743 | - if(!$output->toBool()) return $output; |
|
| 743 | + if (!$output->toBool()) return $output; |
|
| 744 | 744 | // Call a trigger (after) |
| 745 | 745 | $trigger_output = ModuleHandler::triggerCall('file.insertFile', 'after', $args); |
| 746 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
| 746 | + if (!$trigger_output->toBool()) return $trigger_output; |
|
| 747 | 747 | |
| 748 | 748 | $_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true; |
| 749 | 749 | |
@@ -786,18 +786,18 @@ discard block |
||
| 786 | 786 | */ |
| 787 | 787 | function deleteFile($file_srl) |
| 788 | 788 | { |
| 789 | - if(!$file_srl) return; |
|
| 789 | + if (!$file_srl) return; |
|
| 790 | 790 | |
| 791 | 791 | $srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl); |
| 792 | - if(!count($srls)) return; |
|
| 792 | + if (!count($srls)) return; |
|
| 793 | 793 | |
| 794 | 794 | $oDocumentController = getController('document'); |
| 795 | 795 | $documentSrlList = array(); |
| 796 | 796 | |
| 797 | - foreach($srls as $srl) |
|
| 797 | + foreach ($srls as $srl) |
|
| 798 | 798 | { |
| 799 | - $srl = (int)$srl; |
|
| 800 | - if(!$srl) |
|
| 799 | + $srl = (int) $srl; |
|
| 800 | + if (!$srl) |
|
| 801 | 801 | { |
| 802 | 802 | continue; |
| 803 | 803 | } |
@@ -806,14 +806,14 @@ discard block |
||
| 806 | 806 | $args->file_srl = $srl; |
| 807 | 807 | $output = executeQuery('file.getFile', $args); |
| 808 | 808 | |
| 809 | - if(!$output->toBool() || !$output->data) |
|
| 809 | + if (!$output->toBool() || !$output->data) |
|
| 810 | 810 | { |
| 811 | 811 | continue; |
| 812 | 812 | } |
| 813 | 813 | |
| 814 | 814 | $file_info = $output->data; |
| 815 | 815 | |
| 816 | - if($file_info->upload_target_srl) |
|
| 816 | + if ($file_info->upload_target_srl) |
|
| 817 | 817 | { |
| 818 | 818 | $documentSrlList[] = $file_info->upload_target_srl; |
| 819 | 819 | } |
@@ -824,15 +824,15 @@ discard block |
||
| 824 | 824 | // Call a trigger (before) |
| 825 | 825 | $trigger_obj = $output->data; |
| 826 | 826 | $output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj); |
| 827 | - if(!$output->toBool()) return $output; |
|
| 827 | + if (!$output->toBool()) return $output; |
|
| 828 | 828 | |
| 829 | 829 | // Remove from the DB |
| 830 | 830 | $output = executeQuery('file.deleteFile', $args); |
| 831 | - if(!$output->toBool()) return $output; |
|
| 831 | + if (!$output->toBool()) return $output; |
|
| 832 | 832 | |
| 833 | 833 | // Call a trigger (after) |
| 834 | 834 | $trigger_output = ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj); |
| 835 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
| 835 | + if (!$trigger_output->toBool()) return $trigger_output; |
|
| 836 | 836 | |
| 837 | 837 | // If successfully deleted, remove the file |
| 838 | 838 | FileHandler::removeFile($uploaded_filename); |
@@ -856,28 +856,28 @@ discard block |
||
| 856 | 856 | $columnList = array('file_srl', 'uploaded_filename', 'module_srl'); |
| 857 | 857 | $file_list = $oFileModel->getFiles($upload_target_srl, $columnList); |
| 858 | 858 | // Success returned if no attachement exists |
| 859 | - if(!is_array($file_list)||!count($file_list)) return new Object(); |
|
| 859 | + if (!is_array($file_list) || !count($file_list)) return new Object(); |
|
| 860 | 860 | |
| 861 | 861 | // Delete the file |
| 862 | 862 | $path = array(); |
| 863 | 863 | $file_count = count($file_list); |
| 864 | - for($i=0;$i<$file_count;$i++) |
|
| 864 | + for ($i = 0; $i < $file_count; $i++) |
|
| 865 | 865 | { |
| 866 | 866 | $this->deleteFile($file_list[$i]->file_srl); |
| 867 | 867 | |
| 868 | 868 | $uploaded_filename = $file_list[$i]->uploaded_filename; |
| 869 | 869 | $path_info = pathinfo($uploaded_filename); |
| 870 | - if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
| 870 | + if (!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
| 871 | 871 | } |
| 872 | 872 | |
| 873 | 873 | // Remove from the DB |
| 874 | 874 | $args = new stdClass(); |
| 875 | 875 | $args->upload_target_srl = $upload_target_srl; |
| 876 | 876 | $output = executeQuery('file.deleteFiles', $args); |
| 877 | - if(!$output->toBool()) return $output; |
|
| 877 | + if (!$output->toBool()) return $output; |
|
| 878 | 878 | |
| 879 | 879 | // Remove a file directory of the document |
| 880 | - for($i=0, $c=count($path); $i<$c; $i++) |
|
| 880 | + for ($i = 0, $c = count($path); $i < $c; $i++) |
|
| 881 | 881 | { |
| 882 | 882 | FileHandler::removeBlankDir($path[$i]); |
| 883 | 883 | } |
@@ -895,23 +895,23 @@ discard block |
||
| 895 | 895 | */ |
| 896 | 896 | function moveFile($source_srl, $target_module_srl, $target_srl) |
| 897 | 897 | { |
| 898 | - if($source_srl == $target_srl) return; |
|
| 898 | + if ($source_srl == $target_srl) return; |
|
| 899 | 899 | |
| 900 | 900 | $oFileModel = getModel('file'); |
| 901 | 901 | $file_list = $oFileModel->getFiles($source_srl); |
| 902 | - if(!$file_list) return; |
|
| 902 | + if (!$file_list) return; |
|
| 903 | 903 | |
| 904 | 904 | $file_count = count($file_list); |
| 905 | 905 | |
| 906 | - for($i=0;$i<$file_count;$i++) |
|
| 906 | + for ($i = 0; $i < $file_count; $i++) |
|
| 907 | 907 | { |
| 908 | 908 | unset($file_info); |
| 909 | 909 | $file_info = $file_list[$i]; |
| 910 | 910 | $old_file = $file_info->uploaded_filename; |
| 911 | 911 | // Determine the file path by checking if the file is an image or other kinds |
| 912 | - if(preg_match("/\.(jpg|jpeg|gif|png|wmv|wma|mpg|mpeg|avi|swf|flv|mp1|mp2|mp3|mp4|asf|wav|asx|mid|midi|asf|mov|moov|qt|rm|ram|ra|rmm|m4v)$/i", $file_info->source_filename)) |
|
| 912 | + if (preg_match("/\.(jpg|jpeg|gif|png|wmv|wma|mpg|mpeg|avi|swf|flv|mp1|mp2|mp3|mp4|asf|wav|asx|mid|midi|asf|mov|moov|qt|rm|ram|ra|rmm|m4v)$/i", $file_info->source_filename)) |
|
| 913 | 913 | { |
| 914 | - $path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl); |
|
| 914 | + $path = sprintf("./files/attach/images/%s/%s/", $target_module_srl, $target_srl); |
|
| 915 | 915 | $new_file = $path.$file_info->source_filename; |
| 916 | 916 | } |
| 917 | 917 | else |
@@ -921,7 +921,7 @@ discard block |
||
| 921 | 921 | $new_file = $path.$random->createSecureSalt(32, 'hex'); |
| 922 | 922 | } |
| 923 | 923 | // Pass if a target document to move is same |
| 924 | - if($old_file == $new_file) continue; |
|
| 924 | + if ($old_file == $new_file) continue; |
|
| 925 | 925 | // Create a directory |
| 926 | 926 | FileHandler::makeDir($path); |
| 927 | 927 | // Move the file |
@@ -941,18 +941,18 @@ discard block |
||
| 941 | 941 | $vars = Context::getRequestVars(); |
| 942 | 942 | $logged_info = Context::get('logged_info'); |
| 943 | 943 | |
| 944 | - if(!$vars->editor_sequence) return new Object(-1, 'msg_invalid_request'); |
|
| 944 | + if (!$vars->editor_sequence) return new Object(-1, 'msg_invalid_request'); |
|
| 945 | 945 | |
| 946 | 946 | $upload_target_srl = $_SESSION['upload_info'][$vars->editor_sequence]->upload_target_srl; |
| 947 | 947 | |
| 948 | 948 | $oFileModel = getModel('file'); |
| 949 | 949 | $file_info = $oFileModel->getFile($vars->file_srl); |
| 950 | 950 | |
| 951 | - if(!$file_info) return new Object(-1, 'msg_not_founded'); |
|
| 951 | + if (!$file_info) return new Object(-1, 'msg_not_founded'); |
|
| 952 | 952 | |
| 953 | - if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted'); |
|
| 953 | + if (!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted'); |
|
| 954 | 954 | |
| 955 | - $args = new stdClass(); |
|
| 955 | + $args = new stdClass(); |
|
| 956 | 956 | $args->file_srl = $vars->file_srl; |
| 957 | 957 | $args->upload_target_srl = $upload_target_srl; |
| 958 | 958 | |
@@ -961,7 +961,7 @@ discard block |
||
| 961 | 961 | |
| 962 | 962 | $args->cover_image = 'N'; |
| 963 | 963 | $output = executeQuery('file.updateClearCoverImage', $args); |
| 964 | - if(!$output->toBool()) |
|
| 964 | + if (!$output->toBool()) |
|
| 965 | 965 | { |
| 966 | 966 | $oDB->rollback(); |
| 967 | 967 | return $output; |
@@ -969,7 +969,7 @@ discard block |
||
| 969 | 969 | |
| 970 | 970 | $args->cover_image = 'Y'; |
| 971 | 971 | $output = executeQuery('file.updateCoverImage', $args); |
| 972 | - if(!$output->toBool()) |
|
| 972 | + if (!$output->toBool()) |
|
| 973 | 973 | { |
| 974 | 974 | $oDB->rollback(); |
| 975 | 975 | return $output; |
@@ -1001,9 +1001,9 @@ discard block |
||
| 1001 | 1001 | $fileConfig = $oModuleModel->getModulePartConfig('file', $obj->originModuleSrl); |
| 1002 | 1002 | |
| 1003 | 1003 | $oModuleController = getController('module'); |
| 1004 | - if(is_array($obj->moduleSrlList)) |
|
| 1004 | + if (is_array($obj->moduleSrlList)) |
|
| 1005 | 1005 | { |
| 1006 | - foreach($obj->moduleSrlList AS $key=>$moduleSrl) |
|
| 1006 | + foreach ($obj->moduleSrlList AS $key=>$moduleSrl) |
|
| 1007 | 1007 | { |
| 1008 | 1008 | $oModuleController->insertModulePartConfig('file', $moduleSrl, $fileConfig); |
| 1009 | 1009 | } |