@@ -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'); |
@@ -309,34 +309,34 @@ discard block |
||
309 | 309 | $file_size = $file_obj->file_size; |
310 | 310 | $filename = $file_obj->source_filename; |
311 | 311 | |
312 | - if(preg_match('#(?:Chrome|Edge)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 11) |
|
312 | + if (preg_match('#(?:Chrome|Edge)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 11) |
|
313 | 313 | { |
314 | - if($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT'])) |
|
314 | + if ($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT'])) |
|
315 | 315 | { |
316 | - $filename_param = 'filename="' . $filename . '"'; |
|
316 | + $filename_param = 'filename="'.$filename.'"'; |
|
317 | 317 | } |
318 | 318 | else |
319 | 319 | { |
320 | - $filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"'; |
|
320 | + $filename_param = "filename*=UTF-8''".rawurlencode($filename).'; filename="'.rawurlencode($filename).'"'; |
|
321 | 321 | } |
322 | 322 | } |
323 | - elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6) |
|
323 | + elseif (preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6) |
|
324 | 324 | { |
325 | - $filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"'; |
|
325 | + $filename_param = "filename*=UTF-8''".rawurlencode($filename).'; filename="'.rawurlencode($filename).'"'; |
|
326 | 326 | } |
327 | - elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) |
|
327 | + elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) |
|
328 | 328 | { |
329 | 329 | $filename = rawurlencode($filename); |
330 | - $filename_param = 'filename="' . preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1) . '"'; |
|
330 | + $filename_param = 'filename="'.preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1).'"'; |
|
331 | 331 | } |
332 | 332 | else |
333 | 333 | { |
334 | - $filename_param = 'filename="' . $filename . '"'; |
|
334 | + $filename_param = 'filename="'.$filename.'"'; |
|
335 | 335 | } |
336 | 336 | |
337 | - if($is_android) |
|
337 | + if ($is_android) |
|
338 | 338 | { |
339 | - if($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
339 | + if ($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | unset($_SESSION[$session_key][$file_srl]); |
@@ -344,21 +344,21 @@ discard block |
||
344 | 344 | Context::close(); |
345 | 345 | |
346 | 346 | $fp = fopen($uploaded_filename, 'rb'); |
347 | - if(!$fp) return $this->stop('msg_file_not_found'); |
|
347 | + if (!$fp) return $this->stop('msg_file_not_found'); |
|
348 | 348 | |
349 | 349 | header("Cache-Control: "); |
350 | 350 | header("Pragma: "); |
351 | 351 | header("Content-Type: application/octet-stream"); |
352 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
352 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
353 | 353 | |
354 | - header("Content-Length: " .(string)($file_size)); |
|
355 | - header('Content-Disposition: attachment; ' . $filename_param); |
|
354 | + header("Content-Length: ".(string) ($file_size)); |
|
355 | + header('Content-Disposition: attachment; '.$filename_param); |
|
356 | 356 | header("Content-Transfer-Encoding: binary\n"); |
357 | 357 | |
358 | 358 | // if file size is lager than 10MB, use fread function (#18675748) |
359 | - if(filesize($uploaded_filename) > 1024 * 1024) |
|
359 | + if (filesize($uploaded_filename) > 1024 * 1024) |
|
360 | 360 | { |
361 | - while(!feof($fp)) echo fread($fp, 1024); |
|
361 | + while (!feof($fp)) echo fread($fp, 1024); |
|
362 | 362 | fclose($fp); |
363 | 363 | } |
364 | 364 | else |
@@ -380,36 +380,36 @@ discard block |
||
380 | 380 | $editor_sequence = Context::get('editor_sequence'); |
381 | 381 | $file_srl = Context::get('file_srl'); |
382 | 382 | $file_srls = Context::get('file_srls'); |
383 | - if($file_srls) $file_srl = $file_srls; |
|
383 | + if ($file_srls) $file_srl = $file_srls; |
|
384 | 384 | // Exit a session if there is neither upload permission nor information |
385 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
385 | + if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
386 | 386 | |
387 | 387 | $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
388 | 388 | |
389 | 389 | $logged_info = Context::get('logged_info'); |
390 | 390 | $oFileModel = getModel('file'); |
391 | 391 | |
392 | - $srls = explode(',',$file_srl); |
|
393 | - if(!count($srls)) return; |
|
392 | + $srls = explode(',', $file_srl); |
|
393 | + if (!count($srls)) return; |
|
394 | 394 | |
395 | - for($i=0;$i<count($srls);$i++) |
|
395 | + for ($i = 0; $i < count($srls); $i++) |
|
396 | 396 | { |
397 | - $srl = (int)$srls[$i]; |
|
398 | - if(!$srl) continue; |
|
397 | + $srl = (int) $srls[$i]; |
|
398 | + if (!$srl) continue; |
|
399 | 399 | |
400 | 400 | $args = new stdClass; |
401 | 401 | $args->file_srl = $srl; |
402 | 402 | $output = executeQuery('file.getFile', $args); |
403 | - if(!$output->toBool()) continue; |
|
403 | + if (!$output->toBool()) continue; |
|
404 | 404 | |
405 | 405 | $file_info = $output->data; |
406 | - if(!$file_info) continue; |
|
406 | + if (!$file_info) continue; |
|
407 | 407 | |
408 | 408 | $file_grant = $oFileModel->getFileGrant($file_info, $logged_info); |
409 | 409 | |
410 | - if(!$file_grant->is_deletable) continue; |
|
410 | + if (!$file_grant->is_deletable) continue; |
|
411 | 411 | |
412 | - if($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl); |
|
412 | + if ($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
@@ -420,23 +420,23 @@ discard block |
||
420 | 420 | */ |
421 | 421 | function procFileGetList() |
422 | 422 | { |
423 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
423 | + if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted'); |
|
424 | 424 | $fileSrls = Context::get('file_srls'); |
425 | - if($fileSrls) $fileSrlList = explode(',', $fileSrls); |
|
425 | + if ($fileSrls) $fileSrlList = explode(',', $fileSrls); |
|
426 | 426 | |
427 | 427 | global $lang; |
428 | - if(count($fileSrlList) > 0) |
|
428 | + if (count($fileSrlList) > 0) |
|
429 | 429 | { |
430 | 430 | $oFileModel = getModel('file'); |
431 | 431 | $fileList = $oFileModel->getFile($fileSrlList); |
432 | - if(!is_array($fileList)) $fileList = array($fileList); |
|
432 | + if (!is_array($fileList)) $fileList = array($fileList); |
|
433 | 433 | |
434 | - if(is_array($fileList)) |
|
434 | + if (is_array($fileList)) |
|
435 | 435 | { |
436 | - foreach($fileList AS $key=>$value) |
|
436 | + foreach ($fileList AS $key=>$value) |
|
437 | 437 | { |
438 | 438 | $value->human_file_size = FileHandler::filesize($value->file_size); |
439 | - if($value->isvalid=='Y') $value->validName = $lang->is_valid; |
|
439 | + if ($value->isvalid == 'Y') $value->validName = $lang->is_valid; |
|
440 | 440 | else $value->validName = $lang->is_stand_by; |
441 | 441 | } |
442 | 442 | } |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | function triggerCheckAttached(&$obj) |
459 | 459 | { |
460 | 460 | $document_srl = $obj->document_srl; |
461 | - if(!$document_srl) return new Object(); |
|
461 | + if (!$document_srl) return new Object(); |
|
462 | 462 | // Get numbers of attachments |
463 | 463 | $oFileModel = getModel('file'); |
464 | 464 | $obj->uploaded_count = $oFileModel->getFilesCount($document_srl); |
@@ -475,10 +475,10 @@ discard block |
||
475 | 475 | function triggerAttachFiles(&$obj) |
476 | 476 | { |
477 | 477 | $document_srl = $obj->document_srl; |
478 | - if(!$document_srl) return new Object(); |
|
478 | + if (!$document_srl) return new Object(); |
|
479 | 479 | |
480 | 480 | $output = $this->setFilesValid($document_srl); |
481 | - if(!$output->toBool()) return $output; |
|
481 | + if (!$output->toBool()) return $output; |
|
482 | 482 | |
483 | 483 | return new Object(); |
484 | 484 | } |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | function triggerDeleteAttached(&$obj) |
493 | 493 | { |
494 | 494 | $document_srl = $obj->document_srl; |
495 | - if(!$document_srl) return new Object(); |
|
495 | + if (!$document_srl) return new Object(); |
|
496 | 496 | |
497 | 497 | $output = $this->deleteFiles($document_srl); |
498 | 498 | return $output; |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | function triggerCommentCheckAttached(&$obj) |
508 | 508 | { |
509 | 509 | $comment_srl = $obj->comment_srl; |
510 | - if(!$comment_srl) return new Object(); |
|
510 | + if (!$comment_srl) return new Object(); |
|
511 | 511 | // Get numbers of attachments |
512 | 512 | $oFileModel = getModel('file'); |
513 | 513 | $obj->uploaded_count = $oFileModel->getFilesCount($comment_srl); |
@@ -525,10 +525,10 @@ discard block |
||
525 | 525 | { |
526 | 526 | $comment_srl = $obj->comment_srl; |
527 | 527 | $uploaded_count = $obj->uploaded_count; |
528 | - if(!$comment_srl || !$uploaded_count) return new Object(); |
|
528 | + if (!$comment_srl || !$uploaded_count) return new Object(); |
|
529 | 529 | |
530 | 530 | $output = $this->setFilesValid($comment_srl); |
531 | - if(!$output->toBool()) return $output; |
|
531 | + if (!$output->toBool()) return $output; |
|
532 | 532 | |
533 | 533 | return new Object(); |
534 | 534 | } |
@@ -542,9 +542,9 @@ discard block |
||
542 | 542 | function triggerCommentDeleteAttached(&$obj) |
543 | 543 | { |
544 | 544 | $comment_srl = $obj->comment_srl; |
545 | - if(!$comment_srl) return new Object(); |
|
545 | + if (!$comment_srl) return new Object(); |
|
546 | 546 | |
547 | - if($obj->isMoveToTrash) return new Object(); |
|
547 | + if ($obj->isMoveToTrash) return new Object(); |
|
548 | 548 | |
549 | 549 | $output = $this->deleteFiles($comment_srl); |
550 | 550 | return $output; |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | function triggerDeleteModuleFiles(&$obj) |
560 | 560 | { |
561 | 561 | $module_srl = $obj->module_srl; |
562 | - if(!$module_srl) return new Object(); |
|
562 | + if (!$module_srl) return new Object(); |
|
563 | 563 | |
564 | 564 | $oFileController = getAdminController('file'); |
565 | 565 | return $oFileController->deleteModuleFiles($module_srl); |
@@ -572,9 +572,9 @@ discard block |
||
572 | 572 | * @param int $upload_target_srl |
573 | 573 | * @return void |
574 | 574 | */ |
575 | - function setUploadInfo($editor_sequence, $upload_target_srl=0) |
|
575 | + function setUploadInfo($editor_sequence, $upload_target_srl = 0) |
|
576 | 576 | { |
577 | - if(!isset($_SESSION['upload_info'][$editor_sequence])) |
|
577 | + if (!isset($_SESSION['upload_info'][$editor_sequence])) |
|
578 | 578 | { |
579 | 579 | $_SESSION['upload_info'][$editor_sequence] = new stdClass(); |
580 | 580 | } |
@@ -634,36 +634,36 @@ discard block |
||
634 | 634 | $trigger_obj->module_srl = $module_srl; |
635 | 635 | $trigger_obj->upload_target_srl = $upload_target_srl; |
636 | 636 | $output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj); |
637 | - if(!$output->toBool()) return $output; |
|
637 | + if (!$output->toBool()) return $output; |
|
638 | 638 | |
639 | 639 | // A workaround for Firefox upload bug |
640 | - if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match)) |
|
640 | + if (preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match)) |
|
641 | 641 | { |
642 | 642 | $file_info['name'] = base64_decode(strtr($match[1], ':', '/')); |
643 | 643 | } |
644 | 644 | |
645 | - if(!$manual_insert) |
|
645 | + if (!$manual_insert) |
|
646 | 646 | { |
647 | 647 | // Get the file configurations |
648 | 648 | $logged_info = Context::get('logged_info'); |
649 | - if($logged_info->is_admin != 'Y') |
|
649 | + if ($logged_info->is_admin != 'Y') |
|
650 | 650 | { |
651 | 651 | $oFileModel = getModel('file'); |
652 | 652 | $config = $oFileModel->getFileConfig($module_srl); |
653 | 653 | |
654 | 654 | // check file type |
655 | - if(isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*') |
|
655 | + if (isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*') |
|
656 | 656 | { |
657 | 657 | $filetypes = explode(';', $config->allowed_filetypes); |
658 | 658 | $ext = array(); |
659 | - foreach($filetypes as $item) { |
|
659 | + foreach ($filetypes as $item) { |
|
660 | 660 | $item = explode('.', $item); |
661 | 661 | $ext[] = strtolower($item[1]); |
662 | 662 | } |
663 | 663 | $uploaded_ext = explode('.', $file_info['name']); |
664 | 664 | $uploaded_ext = strtolower(array_pop($uploaded_ext)); |
665 | 665 | |
666 | - if(!in_array($uploaded_ext, $ext)) |
|
666 | + if (!in_array($uploaded_ext, $ext)) |
|
667 | 667 | { |
668 | 668 | return $this->stop('msg_not_allowed_filetype'); |
669 | 669 | } |
@@ -672,63 +672,63 @@ discard block |
||
672 | 672 | $allowed_filesize = $config->allowed_filesize * 1024 * 1024; |
673 | 673 | $allowed_attach_size = $config->allowed_attach_size * 1024 * 1024; |
674 | 674 | // An error appears if file size exceeds a limit |
675 | - if($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-1, 'msg_exceeds_limit_size'); |
|
675 | + if ($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-1, 'msg_exceeds_limit_size'); |
|
676 | 676 | // Get total file size of all attachements (from DB) |
677 | 677 | $size_args = new stdClass; |
678 | 678 | $size_args->upload_target_srl = $upload_target_srl; |
679 | 679 | $output = executeQuery('file.getAttachedFileSize', $size_args); |
680 | - $attached_size = (int)$output->data->attached_size + filesize($file_info['tmp_name']); |
|
681 | - if($attached_size > $allowed_attach_size) return new Object(-1, 'msg_exceeds_limit_size'); |
|
680 | + $attached_size = (int) $output->data->attached_size + filesize($file_info['tmp_name']); |
|
681 | + if ($attached_size > $allowed_attach_size) return new Object(-1, 'msg_exceeds_limit_size'); |
|
682 | 682 | } |
683 | 683 | } |
684 | 684 | |
685 | 685 | // https://github.com/xpressengine/xe-core/issues/1713 |
686 | - $file_info['name'] = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x',$file_info['name']); |
|
686 | + $file_info['name'] = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x', $file_info['name']); |
|
687 | 687 | $file_info['name'] = removeHackTag($file_info['name']); |
688 | - $file_info['name'] = str_replace(array('<','>'),array('%3C','%3E'),$file_info['name']); |
|
688 | + $file_info['name'] = str_replace(array('<', '>'), array('%3C', '%3E'), $file_info['name']); |
|
689 | 689 | |
690 | 690 | // Get random number generator |
691 | 691 | $random = new Password(); |
692 | 692 | |
693 | 693 | // Set upload path by checking if the attachement is an image or other kinds of file |
694 | - 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'])) |
|
694 | + 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'])) |
|
695 | 695 | { |
696 | - $path = sprintf("./files/attach/images/%s/%s", $module_srl,getNumberingPath($upload_target_srl,3)); |
|
696 | + $path = sprintf("./files/attach/images/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3)); |
|
697 | 697 | |
698 | 698 | // special character to '_' |
699 | 699 | // change to random file name. because window php bug. window php is not recognize unicode character file name - by cherryfilter |
700 | - $ext = substr(strrchr($file_info['name'],'.'),1); |
|
700 | + $ext = substr(strrchr($file_info['name'], '.'), 1); |
|
701 | 701 | //$_filename = preg_replace('/[#$&*?+%"\']/', '_', $file_info['name']); |
702 | 702 | $_filename = $random->createSecureSalt(32, 'hex').'.'.$ext; |
703 | 703 | $filename = $path.$_filename; |
704 | 704 | $idx = 1; |
705 | - while(file_exists($filename)) |
|
705 | + while (file_exists($filename)) |
|
706 | 706 | { |
707 | - $filename = $path.preg_replace('/\.([a-z0-9]+)$/i','_'.$idx.'.$1',$_filename); |
|
707 | + $filename = $path.preg_replace('/\.([a-z0-9]+)$/i', '_'.$idx.'.$1', $_filename); |
|
708 | 708 | $idx++; |
709 | 709 | } |
710 | 710 | $direct_download = 'Y'; |
711 | 711 | } |
712 | 712 | else |
713 | 713 | { |
714 | - $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3)); |
|
714 | + $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3)); |
|
715 | 715 | $filename = $path.$random->createSecureSalt(32, 'hex'); |
716 | 716 | $direct_download = 'N'; |
717 | 717 | } |
718 | 718 | // Create a directory |
719 | - if(!FileHandler::makeDir($path)) return new Object(-1,'msg_not_permitted_create'); |
|
719 | + if (!FileHandler::makeDir($path)) return new Object(-1, 'msg_not_permitted_create'); |
|
720 | 720 | |
721 | 721 | // Check uploaded file |
722 | - if(!checkUploadedFile($file_info['tmp_name'])) return new Object(-1,'msg_file_upload_error'); |
|
722 | + if (!checkUploadedFile($file_info['tmp_name'])) return new Object(-1, 'msg_file_upload_error'); |
|
723 | 723 | |
724 | 724 | // Get random number generator |
725 | 725 | $random = new Password(); |
726 | 726 | |
727 | 727 | // Move the file |
728 | - if($manual_insert) |
|
728 | + if ($manual_insert) |
|
729 | 729 | { |
730 | 730 | @copy($file_info['tmp_name'], $filename); |
731 | - if(!file_exists($filename)) |
|
731 | + if (!file_exists($filename)) |
|
732 | 732 | { |
733 | 733 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
734 | 734 | @copy($file_info['tmp_name'], $filename); |
@@ -736,10 +736,10 @@ discard block |
||
736 | 736 | } |
737 | 737 | else |
738 | 738 | { |
739 | - if(!@move_uploaded_file($file_info['tmp_name'], $filename)) |
|
739 | + if (!@move_uploaded_file($file_info['tmp_name'], $filename)) |
|
740 | 740 | { |
741 | 741 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
742 | - if(!@move_uploaded_file($file_info['tmp_name'], $filename)) return new Object(-1,'msg_file_upload_error'); |
|
742 | + if (!@move_uploaded_file($file_info['tmp_name'], $filename)) return new Object(-1, 'msg_file_upload_error'); |
|
743 | 743 | } |
744 | 744 | } |
745 | 745 | // Get member information |
@@ -760,10 +760,10 @@ discard block |
||
760 | 760 | $args->sid = $random->createSecureSalt(32, 'hex'); |
761 | 761 | |
762 | 762 | $output = executeQuery('file.insertFile', $args); |
763 | - if(!$output->toBool()) return $output; |
|
763 | + if (!$output->toBool()) return $output; |
|
764 | 764 | // Call a trigger (after) |
765 | 765 | $trigger_output = ModuleHandler::triggerCall('file.insertFile', 'after', $args); |
766 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
766 | + if (!$trigger_output->toBool()) return $trigger_output; |
|
767 | 767 | |
768 | 768 | $_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true; |
769 | 769 | |
@@ -806,18 +806,18 @@ discard block |
||
806 | 806 | */ |
807 | 807 | function deleteFile($file_srl) |
808 | 808 | { |
809 | - if(!$file_srl) return; |
|
809 | + if (!$file_srl) return; |
|
810 | 810 | |
811 | 811 | $srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl); |
812 | - if(!count($srls)) return; |
|
812 | + if (!count($srls)) return; |
|
813 | 813 | |
814 | 814 | $oDocumentController = getController('document'); |
815 | 815 | $documentSrlList = array(); |
816 | 816 | |
817 | - foreach($srls as $srl) |
|
817 | + foreach ($srls as $srl) |
|
818 | 818 | { |
819 | - $srl = (int)$srl; |
|
820 | - if(!$srl) |
|
819 | + $srl = (int) $srl; |
|
820 | + if (!$srl) |
|
821 | 821 | { |
822 | 822 | continue; |
823 | 823 | } |
@@ -826,14 +826,14 @@ discard block |
||
826 | 826 | $args->file_srl = $srl; |
827 | 827 | $output = executeQuery('file.getFile', $args); |
828 | 828 | |
829 | - if(!$output->toBool() || !$output->data) |
|
829 | + if (!$output->toBool() || !$output->data) |
|
830 | 830 | { |
831 | 831 | continue; |
832 | 832 | } |
833 | 833 | |
834 | 834 | $file_info = $output->data; |
835 | 835 | |
836 | - if($file_info->upload_target_srl) |
|
836 | + if ($file_info->upload_target_srl) |
|
837 | 837 | { |
838 | 838 | $documentSrlList[] = $file_info->upload_target_srl; |
839 | 839 | } |
@@ -844,15 +844,15 @@ discard block |
||
844 | 844 | // Call a trigger (before) |
845 | 845 | $trigger_obj = $output->data; |
846 | 846 | $output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj); |
847 | - if(!$output->toBool()) return $output; |
|
847 | + if (!$output->toBool()) return $output; |
|
848 | 848 | |
849 | 849 | // Remove from the DB |
850 | 850 | $output = executeQuery('file.deleteFile', $args); |
851 | - if(!$output->toBool()) return $output; |
|
851 | + if (!$output->toBool()) return $output; |
|
852 | 852 | |
853 | 853 | // Call a trigger (after) |
854 | 854 | $trigger_output = ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj); |
855 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
855 | + if (!$trigger_output->toBool()) return $trigger_output; |
|
856 | 856 | |
857 | 857 | // If successfully deleted, remove the file |
858 | 858 | FileHandler::removeFile($uploaded_filename); |
@@ -876,28 +876,28 @@ discard block |
||
876 | 876 | $columnList = array('file_srl', 'uploaded_filename', 'module_srl'); |
877 | 877 | $file_list = $oFileModel->getFiles($upload_target_srl, $columnList); |
878 | 878 | // Success returned if no attachement exists |
879 | - if(!is_array($file_list)||!count($file_list)) return new Object(); |
|
879 | + if (!is_array($file_list) || !count($file_list)) return new Object(); |
|
880 | 880 | |
881 | 881 | // Delete the file |
882 | 882 | $path = array(); |
883 | 883 | $file_count = count($file_list); |
884 | - for($i=0;$i<$file_count;$i++) |
|
884 | + for ($i = 0; $i < $file_count; $i++) |
|
885 | 885 | { |
886 | 886 | $this->deleteFile($file_list[$i]->file_srl); |
887 | 887 | |
888 | 888 | $uploaded_filename = $file_list[$i]->uploaded_filename; |
889 | 889 | $path_info = pathinfo($uploaded_filename); |
890 | - if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
890 | + if (!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
891 | 891 | } |
892 | 892 | |
893 | 893 | // Remove from the DB |
894 | 894 | $args = new stdClass(); |
895 | 895 | $args->upload_target_srl = $upload_target_srl; |
896 | 896 | $output = executeQuery('file.deleteFiles', $args); |
897 | - if(!$output->toBool()) return $output; |
|
897 | + if (!$output->toBool()) return $output; |
|
898 | 898 | |
899 | 899 | // Remove a file directory of the document |
900 | - for($i=0, $c=count($path); $i<$c; $i++) |
|
900 | + for ($i = 0, $c = count($path); $i < $c; $i++) |
|
901 | 901 | { |
902 | 902 | FileHandler::removeBlankDir($path[$i]); |
903 | 903 | } |
@@ -915,23 +915,23 @@ discard block |
||
915 | 915 | */ |
916 | 916 | function moveFile($source_srl, $target_module_srl, $target_srl) |
917 | 917 | { |
918 | - if($source_srl == $target_srl) return; |
|
918 | + if ($source_srl == $target_srl) return; |
|
919 | 919 | |
920 | 920 | $oFileModel = getModel('file'); |
921 | 921 | $file_list = $oFileModel->getFiles($source_srl); |
922 | - if(!$file_list) return; |
|
922 | + if (!$file_list) return; |
|
923 | 923 | |
924 | 924 | $file_count = count($file_list); |
925 | 925 | |
926 | - for($i=0;$i<$file_count;$i++) |
|
926 | + for ($i = 0; $i < $file_count; $i++) |
|
927 | 927 | { |
928 | 928 | unset($file_info); |
929 | 929 | $file_info = $file_list[$i]; |
930 | 930 | $old_file = $file_info->uploaded_filename; |
931 | 931 | // Determine the file path by checking if the file is an image or other kinds |
932 | - 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)) |
|
932 | + 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)) |
|
933 | 933 | { |
934 | - $path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl); |
|
934 | + $path = sprintf("./files/attach/images/%s/%s/", $target_module_srl, $target_srl); |
|
935 | 935 | $new_file = $path.$file_info->source_filename; |
936 | 936 | } |
937 | 937 | else |
@@ -941,7 +941,7 @@ discard block |
||
941 | 941 | $new_file = $path.$random->createSecureSalt(32, 'hex'); |
942 | 942 | } |
943 | 943 | // Pass if a target document to move is same |
944 | - if($old_file == $new_file) continue; |
|
944 | + if ($old_file == $new_file) continue; |
|
945 | 945 | // Create a directory |
946 | 946 | FileHandler::makeDir($path); |
947 | 947 | // Move the file |
@@ -961,18 +961,18 @@ discard block |
||
961 | 961 | $vars = Context::getRequestVars(); |
962 | 962 | $logged_info = Context::get('logged_info'); |
963 | 963 | |
964 | - if(!$vars->editor_sequence) return new Object(-1, 'msg_invalid_request'); |
|
964 | + if (!$vars->editor_sequence) return new Object(-1, 'msg_invalid_request'); |
|
965 | 965 | |
966 | 966 | $upload_target_srl = $_SESSION['upload_info'][$vars->editor_sequence]->upload_target_srl; |
967 | 967 | |
968 | 968 | $oFileModel = getModel('file'); |
969 | 969 | $file_info = $oFileModel->getFile($vars->file_srl); |
970 | 970 | |
971 | - if(!$file_info) return new Object(-1, 'msg_not_founded'); |
|
971 | + if (!$file_info) return new Object(-1, 'msg_not_founded'); |
|
972 | 972 | |
973 | - if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted'); |
|
973 | + if (!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted'); |
|
974 | 974 | |
975 | - $args = new stdClass(); |
|
975 | + $args = new stdClass(); |
|
976 | 976 | $args->file_srl = $vars->file_srl; |
977 | 977 | $args->upload_target_srl = $upload_target_srl; |
978 | 978 | |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | |
982 | 982 | $args->cover_image = 'N'; |
983 | 983 | $output = executeQuery('file.updateClearCoverImage', $args); |
984 | - if(!$output->toBool()) |
|
984 | + if (!$output->toBool()) |
|
985 | 985 | { |
986 | 986 | $oDB->rollback(); |
987 | 987 | return $output; |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | |
990 | 990 | $args->cover_image = 'Y'; |
991 | 991 | $output = executeQuery('file.updateCoverImage', $args); |
992 | - if(!$output->toBool()) |
|
992 | + if (!$output->toBool()) |
|
993 | 993 | { |
994 | 994 | $oDB->rollback(); |
995 | 995 | return $output; |
@@ -1021,9 +1021,9 @@ discard block |
||
1021 | 1021 | $fileConfig = $oModuleModel->getModulePartConfig('file', $obj->originModuleSrl); |
1022 | 1022 | |
1023 | 1023 | $oModuleController = getController('module'); |
1024 | - if(is_array($obj->moduleSrlList)) |
|
1024 | + if (is_array($obj->moduleSrlList)) |
|
1025 | 1025 | { |
1026 | - foreach($obj->moduleSrlList AS $key=>$moduleSrl) |
|
1026 | + foreach ($obj->moduleSrlList AS $key=>$moduleSrl) |
|
1027 | 1027 | { |
1028 | 1028 | $oModuleController->insertModulePartConfig('file', $moduleSrl, $fileConfig); |
1029 | 1029 | } |
@@ -29,24 +29,36 @@ 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'])) { |
|
33 | + exit(); |
|
34 | + } |
|
33 | 35 | |
34 | 36 | // Basic variables setting |
35 | 37 | $oFileModel = getModel('file'); |
36 | 38 | $editor_sequence = Context::get('editor_sequence'); |
37 | 39 | $upload_target_srl = intval(Context::get('uploadTargetSrl')); |
38 | - if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
40 | + if(!$upload_target_srl) { |
|
41 | + $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
42 | + } |
|
39 | 43 | $module_srl = $this->module_srl; |
40 | 44 | // Exit a session if there is neither upload permission nor information |
41 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
45 | + if(!$_SESSION['upload_info'][$editor_sequence]->enabled) { |
|
46 | + exit(); |
|
47 | + } |
|
42 | 48 | // 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; |
|
49 | + if(!$upload_target_srl) { |
|
50 | + $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
51 | + } |
|
44 | 52 | // 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(); |
|
53 | + if(!$upload_target_srl) { |
|
54 | + $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
55 | + } |
|
46 | 56 | |
47 | 57 | $output = $this->insertFile($file_info, $module_srl, $upload_target_srl); |
48 | 58 | Context::setResponseMethod('JSON'); |
49 | - if($output->error != '0') $this->stop($output->message); |
|
59 | + if($output->error != '0') { |
|
60 | + $this->stop($output->message); |
|
61 | + } |
|
50 | 62 | } |
51 | 63 | |
52 | 64 | /** |
@@ -61,17 +73,27 @@ discard block |
||
61 | 73 | $callback = Context::get('callback'); |
62 | 74 | $module_srl = $this->module_srl; |
63 | 75 | $upload_target_srl = intval(Context::get('uploadTargetSrl')); |
64 | - if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
76 | + if(!$upload_target_srl) { |
|
77 | + $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
78 | + } |
|
65 | 79 | |
66 | 80 | // Exit a session if there is neither upload permission nor information |
67 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
81 | + if(!$_SESSION['upload_info'][$editor_sequence]->enabled) { |
|
82 | + exit(); |
|
83 | + } |
|
68 | 84 | // 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; |
|
85 | + if(!$upload_target_srl) { |
|
86 | + $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
87 | + } |
|
70 | 88 | // 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(); |
|
89 | + if(!$upload_target_srl) { |
|
90 | + $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
91 | + } |
|
72 | 92 | // Delete and then attempt to re-upload if file_srl is requested |
73 | 93 | $file_srl = Context::get('file_srl'); |
74 | - if($file_srl) $this->deleteFile($file_srl); |
|
94 | + if($file_srl) { |
|
95 | + $this->deleteFile($file_srl); |
|
96 | + } |
|
75 | 97 | |
76 | 98 | $file_info = Context::get('Filedata'); |
77 | 99 | // An error appears if not a normally uploaded file |
@@ -112,15 +134,16 @@ discard block |
||
112 | 134 | $source_src = $fileInfo->uploaded_filename; |
113 | 135 | $output_src = $source_src . '.resized' . strrchr($source_src,'.'); |
114 | 136 | |
115 | - if(!$height) $height = $width-1; |
|
137 | + if(!$height) { |
|
138 | + $height = $width-1; |
|
139 | + } |
|
116 | 140 | |
117 | 141 | if(FileHandler::createImageFile($source_src,$output_src,$width,$height,'','ratio')) |
118 | 142 | { |
119 | 143 | $output = new stdClass(); |
120 | 144 | $output->info = getimagesize($output_src); |
121 | 145 | $output->src = $output_src; |
122 | - } |
|
123 | - else |
|
146 | + } else |
|
124 | 147 | { |
125 | 148 | return new Object(-1,'msg_invalid_request'); |
126 | 149 | } |
@@ -163,7 +186,9 @@ discard block |
||
163 | 186 | { |
164 | 187 | $oFileModel = getModel('file'); |
165 | 188 | |
166 | - if(isset($this->grant->access) && $this->grant->access !== true) return new Object(-1, 'msg_not_permitted'); |
|
189 | + if(isset($this->grant->access) && $this->grant->access !== true) { |
|
190 | + return new Object(-1, 'msg_not_permitted'); |
|
191 | + } |
|
167 | 192 | |
168 | 193 | $file_srl = Context::get('file_srl'); |
169 | 194 | $sid = Context::get('sid'); |
@@ -172,9 +197,13 @@ discard block |
||
172 | 197 | $columnList = array('file_srl', 'sid', 'isvalid', 'source_filename', 'module_srl', 'uploaded_filename', 'file_size', 'member_srl', 'upload_target_srl', 'upload_target_type'); |
173 | 198 | $file_obj = $oFileModel->getFile($file_srl, $columnList); |
174 | 199 | // 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'); |
|
200 | + if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) { |
|
201 | + return $this->stop('msg_file_not_found'); |
|
202 | + } |
|
176 | 203 | // 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'); |
|
204 | + if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') { |
|
205 | + return $this->stop('msg_not_permitted_download'); |
|
206 | + } |
|
178 | 207 | // File name |
179 | 208 | $filename = $file_obj->source_filename; |
180 | 209 | $file_module_config = $oFileModel->getFileModuleConfig($file_obj->module_srl); |
@@ -186,7 +215,9 @@ discard block |
||
186 | 215 | { |
187 | 216 | $allow_outlink_format_array = array(); |
188 | 217 | $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; |
|
218 | + if(!is_array($allow_outlink_format_array)) { |
|
219 | + $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format; |
|
220 | + } |
|
190 | 221 | |
191 | 222 | foreach($allow_outlink_format_array as $val) |
192 | 223 | { |
@@ -208,7 +239,9 @@ discard block |
||
208 | 239 | { |
209 | 240 | $allow_outlink_site_array = array(); |
210 | 241 | $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; |
|
242 | + if(!is_array($allow_outlink_site_array)) { |
|
243 | + $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site; |
|
244 | + } |
|
212 | 245 | |
213 | 246 | foreach($allow_outlink_site_array as $val) |
214 | 247 | { |
@@ -220,23 +253,29 @@ discard block |
||
220 | 253 | } |
221 | 254 | } |
222 | 255 | } |
256 | + } else { |
|
257 | + $file_module_config->allow_outlink = 'Y'; |
|
223 | 258 | } |
224 | - else $file_module_config->allow_outlink = 'Y'; |
|
225 | 259 | } |
226 | - if($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink'); |
|
260 | + if($file_module_config->allow_outlink != 'Y') { |
|
261 | + return $this->stop('msg_not_allowed_outlink'); |
|
262 | + } |
|
227 | 263 | } |
228 | 264 | |
229 | 265 | // Check if a permission for file download is granted |
230 | 266 | $downloadGrantCount = 0; |
231 | 267 | if(is_array($file_module_config->download_grant)) |
232 | 268 | { |
233 | - foreach($file_module_config->download_grant AS $value) |
|
234 | - if($value) $downloadGrantCount++; |
|
269 | + foreach($file_module_config->download_grant AS $value) { |
|
270 | + if($value) $downloadGrantCount++; |
|
271 | + } |
|
235 | 272 | } |
236 | 273 | |
237 | 274 | if(is_array($file_module_config->download_grant) && $downloadGrantCount>0) |
238 | 275 | { |
239 | - if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download'); |
|
276 | + if(!Context::get('is_logged')) { |
|
277 | + return $this->stop('msg_not_permitted_download'); |
|
278 | + } |
|
240 | 279 | $logged_info = Context::get('logged_info'); |
241 | 280 | if($logged_info->is_admin != 'Y') |
242 | 281 | { |
@@ -259,13 +298,17 @@ discard block |
||
259 | 298 | break; |
260 | 299 | } |
261 | 300 | } |
262 | - if(!$is_permitted) return $this->stop('msg_not_permitted_download'); |
|
301 | + if(!$is_permitted) { |
|
302 | + return $this->stop('msg_not_permitted_download'); |
|
303 | + } |
|
263 | 304 | } |
264 | 305 | } |
265 | 306 | } |
266 | 307 | // Call a trigger (before) |
267 | 308 | $output = ModuleHandler::triggerCall('file.downloadFile', 'before', $file_obj); |
268 | - if(!$output->toBool()) return $this->stop(($output->message)?$output->message:'msg_not_permitted_download'); |
|
309 | + if(!$output->toBool()) { |
|
310 | + return $this->stop(($output->message)?$output->message:'msg_not_permitted_download'); |
|
311 | + } |
|
269 | 312 | |
270 | 313 | |
271 | 314 | // 다운로드 후 (가상) |
@@ -289,16 +332,23 @@ discard block |
||
289 | 332 | $oFileModel = getModel('file'); |
290 | 333 | $file_srl = Context::get('file_srl'); |
291 | 334 | $file_key = Context::get('file_key'); |
292 | - if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true; |
|
335 | + if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) { |
|
336 | + $is_android = true; |
|
337 | + } |
|
293 | 338 | |
294 | - if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__'; |
|
295 | - else $session_key = '__XE_FILE_KEY__'; |
|
339 | + if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) { |
|
340 | + $session_key = '__XE_FILE_KEY_AND__'; |
|
341 | + } else { |
|
342 | + $session_key = '__XE_FILE_KEY__'; |
|
343 | + } |
|
296 | 344 | $columnList = array('source_filename', 'uploaded_filename', 'file_size'); |
297 | 345 | $file_obj = $oFileModel->getFile($file_srl, $columnList); |
298 | 346 | |
299 | 347 | $uploaded_filename = $file_obj->uploaded_filename; |
300 | 348 | |
301 | - if(!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found'); |
|
349 | + if(!file_exists($uploaded_filename)) { |
|
350 | + return $this->stop('msg_file_not_found'); |
|
351 | + } |
|
302 | 352 | |
303 | 353 | if(!$file_key || $_SESSION[$session_key][$file_srl] != $file_key) |
304 | 354 | { |
@@ -314,29 +364,27 @@ discard block |
||
314 | 364 | if($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT'])) |
315 | 365 | { |
316 | 366 | $filename_param = 'filename="' . $filename . '"'; |
317 | - } |
|
318 | - else |
|
367 | + } else |
|
319 | 368 | { |
320 | 369 | $filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"'; |
321 | 370 | } |
322 | - } |
|
323 | - elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6) |
|
371 | + } elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6) |
|
324 | 372 | { |
325 | 373 | $filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"'; |
326 | - } |
|
327 | - elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) |
|
374 | + } elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) |
|
328 | 375 | { |
329 | 376 | $filename = rawurlencode($filename); |
330 | 377 | $filename_param = 'filename="' . preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1) . '"'; |
331 | - } |
|
332 | - else |
|
378 | + } else |
|
333 | 379 | { |
334 | 380 | $filename_param = 'filename="' . $filename . '"'; |
335 | 381 | } |
336 | 382 | |
337 | 383 | if($is_android) |
338 | 384 | { |
339 | - if($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
385 | + if($_SESSION['__XE_FILE_KEY__'][$file_srl]) { |
|
386 | + $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
387 | + } |
|
340 | 388 | } |
341 | 389 | |
342 | 390 | unset($_SESSION[$session_key][$file_srl]); |
@@ -344,7 +392,9 @@ discard block |
||
344 | 392 | Context::close(); |
345 | 393 | |
346 | 394 | $fp = fopen($uploaded_filename, 'rb'); |
347 | - if(!$fp) return $this->stop('msg_file_not_found'); |
|
395 | + if(!$fp) { |
|
396 | + return $this->stop('msg_file_not_found'); |
|
397 | + } |
|
348 | 398 | |
349 | 399 | header("Cache-Control: "); |
350 | 400 | header("Pragma: "); |
@@ -358,10 +408,11 @@ discard block |
||
358 | 408 | // if file size is lager than 10MB, use fread function (#18675748) |
359 | 409 | if(filesize($uploaded_filename) > 1024 * 1024) |
360 | 410 | { |
361 | - while(!feof($fp)) echo fread($fp, 1024); |
|
411 | + while(!feof($fp)) { |
|
412 | + echo fread($fp, 1024); |
|
413 | + } |
|
362 | 414 | fclose($fp); |
363 | - } |
|
364 | - else |
|
415 | + } else |
|
365 | 416 | { |
366 | 417 | fpassthru($fp); |
367 | 418 | } |
@@ -380,9 +431,13 @@ discard block |
||
380 | 431 | $editor_sequence = Context::get('editor_sequence'); |
381 | 432 | $file_srl = Context::get('file_srl'); |
382 | 433 | $file_srls = Context::get('file_srls'); |
383 | - if($file_srls) $file_srl = $file_srls; |
|
434 | + if($file_srls) { |
|
435 | + $file_srl = $file_srls; |
|
436 | + } |
|
384 | 437 | // Exit a session if there is neither upload permission nor information |
385 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
438 | + if(!$_SESSION['upload_info'][$editor_sequence]->enabled) { |
|
439 | + exit(); |
|
440 | + } |
|
386 | 441 | |
387 | 442 | $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
388 | 443 | |
@@ -390,26 +445,38 @@ discard block |
||
390 | 445 | $oFileModel = getModel('file'); |
391 | 446 | |
392 | 447 | $srls = explode(',',$file_srl); |
393 | - if(!count($srls)) return; |
|
448 | + if(!count($srls)) { |
|
449 | + return; |
|
450 | + } |
|
394 | 451 | |
395 | 452 | for($i=0;$i<count($srls);$i++) |
396 | 453 | { |
397 | 454 | $srl = (int)$srls[$i]; |
398 | - if(!$srl) continue; |
|
455 | + if(!$srl) { |
|
456 | + continue; |
|
457 | + } |
|
399 | 458 | |
400 | 459 | $args = new stdClass; |
401 | 460 | $args->file_srl = $srl; |
402 | 461 | $output = executeQuery('file.getFile', $args); |
403 | - if(!$output->toBool()) continue; |
|
462 | + if(!$output->toBool()) { |
|
463 | + continue; |
|
464 | + } |
|
404 | 465 | |
405 | 466 | $file_info = $output->data; |
406 | - if(!$file_info) continue; |
|
467 | + if(!$file_info) { |
|
468 | + continue; |
|
469 | + } |
|
407 | 470 | |
408 | 471 | $file_grant = $oFileModel->getFileGrant($file_info, $logged_info); |
409 | 472 | |
410 | - if(!$file_grant->is_deletable) continue; |
|
473 | + if(!$file_grant->is_deletable) { |
|
474 | + continue; |
|
475 | + } |
|
411 | 476 | |
412 | - if($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl); |
|
477 | + if($upload_target_srl && $file_srl) { |
|
478 | + $output = $this->deleteFile($file_srl); |
|
479 | + } |
|
413 | 480 | } |
414 | 481 | } |
415 | 482 | |
@@ -420,28 +487,36 @@ discard block |
||
420 | 487 | */ |
421 | 488 | function procFileGetList() |
422 | 489 | { |
423 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
490 | + if(!Context::get('is_logged')) { |
|
491 | + return new Object(-1,'msg_not_permitted'); |
|
492 | + } |
|
424 | 493 | $fileSrls = Context::get('file_srls'); |
425 | - if($fileSrls) $fileSrlList = explode(',', $fileSrls); |
|
494 | + if($fileSrls) { |
|
495 | + $fileSrlList = explode(',', $fileSrls); |
|
496 | + } |
|
426 | 497 | |
427 | 498 | global $lang; |
428 | 499 | if(count($fileSrlList) > 0) |
429 | 500 | { |
430 | 501 | $oFileModel = getModel('file'); |
431 | 502 | $fileList = $oFileModel->getFile($fileSrlList); |
432 | - if(!is_array($fileList)) $fileList = array($fileList); |
|
503 | + if(!is_array($fileList)) { |
|
504 | + $fileList = array($fileList); |
|
505 | + } |
|
433 | 506 | |
434 | 507 | if(is_array($fileList)) |
435 | 508 | { |
436 | 509 | foreach($fileList AS $key=>$value) |
437 | 510 | { |
438 | 511 | $value->human_file_size = FileHandler::filesize($value->file_size); |
439 | - if($value->isvalid=='Y') $value->validName = $lang->is_valid; |
|
440 | - else $value->validName = $lang->is_stand_by; |
|
512 | + if($value->isvalid=='Y') { |
|
513 | + $value->validName = $lang->is_valid; |
|
514 | + } else { |
|
515 | + $value->validName = $lang->is_stand_by; |
|
516 | + } |
|
441 | 517 | } |
442 | 518 | } |
443 | - } |
|
444 | - else |
|
519 | + } else |
|
445 | 520 | { |
446 | 521 | $fileList = array(); |
447 | 522 | $this->setMessage($lang->no_files); |
@@ -458,7 +533,9 @@ discard block |
||
458 | 533 | function triggerCheckAttached(&$obj) |
459 | 534 | { |
460 | 535 | $document_srl = $obj->document_srl; |
461 | - if(!$document_srl) return new Object(); |
|
536 | + if(!$document_srl) { |
|
537 | + return new Object(); |
|
538 | + } |
|
462 | 539 | // Get numbers of attachments |
463 | 540 | $oFileModel = getModel('file'); |
464 | 541 | $obj->uploaded_count = $oFileModel->getFilesCount($document_srl); |
@@ -475,10 +552,14 @@ discard block |
||
475 | 552 | function triggerAttachFiles(&$obj) |
476 | 553 | { |
477 | 554 | $document_srl = $obj->document_srl; |
478 | - if(!$document_srl) return new Object(); |
|
555 | + if(!$document_srl) { |
|
556 | + return new Object(); |
|
557 | + } |
|
479 | 558 | |
480 | 559 | $output = $this->setFilesValid($document_srl); |
481 | - if(!$output->toBool()) return $output; |
|
560 | + if(!$output->toBool()) { |
|
561 | + return $output; |
|
562 | + } |
|
482 | 563 | |
483 | 564 | return new Object(); |
484 | 565 | } |
@@ -492,7 +573,9 @@ discard block |
||
492 | 573 | function triggerDeleteAttached(&$obj) |
493 | 574 | { |
494 | 575 | $document_srl = $obj->document_srl; |
495 | - if(!$document_srl) return new Object(); |
|
576 | + if(!$document_srl) { |
|
577 | + return new Object(); |
|
578 | + } |
|
496 | 579 | |
497 | 580 | $output = $this->deleteFiles($document_srl); |
498 | 581 | return $output; |
@@ -507,7 +590,9 @@ discard block |
||
507 | 590 | function triggerCommentCheckAttached(&$obj) |
508 | 591 | { |
509 | 592 | $comment_srl = $obj->comment_srl; |
510 | - if(!$comment_srl) return new Object(); |
|
593 | + if(!$comment_srl) { |
|
594 | + return new Object(); |
|
595 | + } |
|
511 | 596 | // Get numbers of attachments |
512 | 597 | $oFileModel = getModel('file'); |
513 | 598 | $obj->uploaded_count = $oFileModel->getFilesCount($comment_srl); |
@@ -525,10 +610,14 @@ discard block |
||
525 | 610 | { |
526 | 611 | $comment_srl = $obj->comment_srl; |
527 | 612 | $uploaded_count = $obj->uploaded_count; |
528 | - if(!$comment_srl || !$uploaded_count) return new Object(); |
|
613 | + if(!$comment_srl || !$uploaded_count) { |
|
614 | + return new Object(); |
|
615 | + } |
|
529 | 616 | |
530 | 617 | $output = $this->setFilesValid($comment_srl); |
531 | - if(!$output->toBool()) return $output; |
|
618 | + if(!$output->toBool()) { |
|
619 | + return $output; |
|
620 | + } |
|
532 | 621 | |
533 | 622 | return new Object(); |
534 | 623 | } |
@@ -542,9 +631,13 @@ discard block |
||
542 | 631 | function triggerCommentDeleteAttached(&$obj) |
543 | 632 | { |
544 | 633 | $comment_srl = $obj->comment_srl; |
545 | - if(!$comment_srl) return new Object(); |
|
634 | + if(!$comment_srl) { |
|
635 | + return new Object(); |
|
636 | + } |
|
546 | 637 | |
547 | - if($obj->isMoveToTrash) return new Object(); |
|
638 | + if($obj->isMoveToTrash) { |
|
639 | + return new Object(); |
|
640 | + } |
|
548 | 641 | |
549 | 642 | $output = $this->deleteFiles($comment_srl); |
550 | 643 | return $output; |
@@ -559,7 +652,9 @@ discard block |
||
559 | 652 | function triggerDeleteModuleFiles(&$obj) |
560 | 653 | { |
561 | 654 | $module_srl = $obj->module_srl; |
562 | - if(!$module_srl) return new Object(); |
|
655 | + if(!$module_srl) { |
|
656 | + return new Object(); |
|
657 | + } |
|
563 | 658 | |
564 | 659 | $oFileController = getAdminController('file'); |
565 | 660 | return $oFileController->deleteModuleFiles($module_srl); |
@@ -634,7 +729,9 @@ discard block |
||
634 | 729 | $trigger_obj->module_srl = $module_srl; |
635 | 730 | $trigger_obj->upload_target_srl = $upload_target_srl; |
636 | 731 | $output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj); |
637 | - if(!$output->toBool()) return $output; |
|
732 | + if(!$output->toBool()) { |
|
733 | + return $output; |
|
734 | + } |
|
638 | 735 | |
639 | 736 | // A workaround for Firefox upload bug |
640 | 737 | if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match)) |
@@ -672,13 +769,17 @@ discard block |
||
672 | 769 | $allowed_filesize = $config->allowed_filesize * 1024 * 1024; |
673 | 770 | $allowed_attach_size = $config->allowed_attach_size * 1024 * 1024; |
674 | 771 | // An error appears if file size exceeds a limit |
675 | - if($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-1, 'msg_exceeds_limit_size'); |
|
772 | + if($allowed_filesize < filesize($file_info['tmp_name'])) { |
|
773 | + return new Object(-1, 'msg_exceeds_limit_size'); |
|
774 | + } |
|
676 | 775 | // Get total file size of all attachements (from DB) |
677 | 776 | $size_args = new stdClass; |
678 | 777 | $size_args->upload_target_srl = $upload_target_srl; |
679 | 778 | $output = executeQuery('file.getAttachedFileSize', $size_args); |
680 | 779 | $attached_size = (int)$output->data->attached_size + filesize($file_info['tmp_name']); |
681 | - if($attached_size > $allowed_attach_size) return new Object(-1, 'msg_exceeds_limit_size'); |
|
780 | + if($attached_size > $allowed_attach_size) { |
|
781 | + return new Object(-1, 'msg_exceeds_limit_size'); |
|
782 | + } |
|
682 | 783 | } |
683 | 784 | } |
684 | 785 | |
@@ -708,18 +809,21 @@ discard block |
||
708 | 809 | $idx++; |
709 | 810 | } |
710 | 811 | $direct_download = 'Y'; |
711 | - } |
|
712 | - else |
|
812 | + } else |
|
713 | 813 | { |
714 | 814 | $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3)); |
715 | 815 | $filename = $path.$random->createSecureSalt(32, 'hex'); |
716 | 816 | $direct_download = 'N'; |
717 | 817 | } |
718 | 818 | // Create a directory |
719 | - if(!FileHandler::makeDir($path)) return new Object(-1,'msg_not_permitted_create'); |
|
819 | + if(!FileHandler::makeDir($path)) { |
|
820 | + return new Object(-1,'msg_not_permitted_create'); |
|
821 | + } |
|
720 | 822 | |
721 | 823 | // Check uploaded file |
722 | - if(!checkUploadedFile($file_info['tmp_name'])) return new Object(-1,'msg_file_upload_error'); |
|
824 | + if(!checkUploadedFile($file_info['tmp_name'])) { |
|
825 | + return new Object(-1,'msg_file_upload_error'); |
|
826 | + } |
|
723 | 827 | |
724 | 828 | // Get random number generator |
725 | 829 | $random = new Password(); |
@@ -733,13 +837,14 @@ discard block |
||
733 | 837 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
734 | 838 | @copy($file_info['tmp_name'], $filename); |
735 | 839 | } |
736 | - } |
|
737 | - else |
|
840 | + } else |
|
738 | 841 | { |
739 | 842 | if(!@move_uploaded_file($file_info['tmp_name'], $filename)) |
740 | 843 | { |
741 | 844 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
742 | - if(!@move_uploaded_file($file_info['tmp_name'], $filename)) return new Object(-1,'msg_file_upload_error'); |
|
845 | + if(!@move_uploaded_file($file_info['tmp_name'], $filename)) { |
|
846 | + return new Object(-1,'msg_file_upload_error'); |
|
847 | + } |
|
743 | 848 | } |
744 | 849 | } |
745 | 850 | // Get member information |
@@ -760,10 +865,14 @@ discard block |
||
760 | 865 | $args->sid = $random->createSecureSalt(32, 'hex'); |
761 | 866 | |
762 | 867 | $output = executeQuery('file.insertFile', $args); |
763 | - if(!$output->toBool()) return $output; |
|
868 | + if(!$output->toBool()) { |
|
869 | + return $output; |
|
870 | + } |
|
764 | 871 | // Call a trigger (after) |
765 | 872 | $trigger_output = ModuleHandler::triggerCall('file.insertFile', 'after', $args); |
766 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
873 | + if(!$trigger_output->toBool()) { |
|
874 | + return $trigger_output; |
|
875 | + } |
|
767 | 876 | |
768 | 877 | $_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true; |
769 | 878 | |
@@ -806,10 +915,14 @@ discard block |
||
806 | 915 | */ |
807 | 916 | function deleteFile($file_srl) |
808 | 917 | { |
809 | - if(!$file_srl) return; |
|
918 | + if(!$file_srl) { |
|
919 | + return; |
|
920 | + } |
|
810 | 921 | |
811 | 922 | $srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl); |
812 | - if(!count($srls)) return; |
|
923 | + if(!count($srls)) { |
|
924 | + return; |
|
925 | + } |
|
813 | 926 | |
814 | 927 | $oDocumentController = getController('document'); |
815 | 928 | $documentSrlList = array(); |
@@ -844,15 +957,21 @@ discard block |
||
844 | 957 | // Call a trigger (before) |
845 | 958 | $trigger_obj = $output->data; |
846 | 959 | $output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj); |
847 | - if(!$output->toBool()) return $output; |
|
960 | + if(!$output->toBool()) { |
|
961 | + return $output; |
|
962 | + } |
|
848 | 963 | |
849 | 964 | // Remove from the DB |
850 | 965 | $output = executeQuery('file.deleteFile', $args); |
851 | - if(!$output->toBool()) return $output; |
|
966 | + if(!$output->toBool()) { |
|
967 | + return $output; |
|
968 | + } |
|
852 | 969 | |
853 | 970 | // Call a trigger (after) |
854 | 971 | $trigger_output = ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj); |
855 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
972 | + if(!$trigger_output->toBool()) { |
|
973 | + return $trigger_output; |
|
974 | + } |
|
856 | 975 | |
857 | 976 | // If successfully deleted, remove the file |
858 | 977 | FileHandler::removeFile($uploaded_filename); |
@@ -876,7 +995,9 @@ discard block |
||
876 | 995 | $columnList = array('file_srl', 'uploaded_filename', 'module_srl'); |
877 | 996 | $file_list = $oFileModel->getFiles($upload_target_srl, $columnList); |
878 | 997 | // Success returned if no attachement exists |
879 | - if(!is_array($file_list)||!count($file_list)) return new Object(); |
|
998 | + if(!is_array($file_list)||!count($file_list)) { |
|
999 | + return new Object(); |
|
1000 | + } |
|
880 | 1001 | |
881 | 1002 | // Delete the file |
882 | 1003 | $path = array(); |
@@ -887,14 +1008,18 @@ discard block |
||
887 | 1008 | |
888 | 1009 | $uploaded_filename = $file_list[$i]->uploaded_filename; |
889 | 1010 | $path_info = pathinfo($uploaded_filename); |
890 | - if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
1011 | + if(!in_array($path_info['dirname'], $path)) { |
|
1012 | + $path[] = $path_info['dirname']; |
|
1013 | + } |
|
891 | 1014 | } |
892 | 1015 | |
893 | 1016 | // Remove from the DB |
894 | 1017 | $args = new stdClass(); |
895 | 1018 | $args->upload_target_srl = $upload_target_srl; |
896 | 1019 | $output = executeQuery('file.deleteFiles', $args); |
897 | - if(!$output->toBool()) return $output; |
|
1020 | + if(!$output->toBool()) { |
|
1021 | + return $output; |
|
1022 | + } |
|
898 | 1023 | |
899 | 1024 | // Remove a file directory of the document |
900 | 1025 | for($i=0, $c=count($path); $i<$c; $i++) |
@@ -915,11 +1040,15 @@ discard block |
||
915 | 1040 | */ |
916 | 1041 | function moveFile($source_srl, $target_module_srl, $target_srl) |
917 | 1042 | { |
918 | - if($source_srl == $target_srl) return; |
|
1043 | + if($source_srl == $target_srl) { |
|
1044 | + return; |
|
1045 | + } |
|
919 | 1046 | |
920 | 1047 | $oFileModel = getModel('file'); |
921 | 1048 | $file_list = $oFileModel->getFiles($source_srl); |
922 | - if(!$file_list) return; |
|
1049 | + if(!$file_list) { |
|
1050 | + return; |
|
1051 | + } |
|
923 | 1052 | |
924 | 1053 | $file_count = count($file_list); |
925 | 1054 | |
@@ -933,15 +1062,16 @@ discard block |
||
933 | 1062 | { |
934 | 1063 | $path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl); |
935 | 1064 | $new_file = $path.$file_info->source_filename; |
936 | - } |
|
937 | - else |
|
1065 | + } else |
|
938 | 1066 | { |
939 | 1067 | $path = sprintf("./files/attach/binaries/%s/%s/", $target_module_srl, $target_srl); |
940 | 1068 | $random = new Password(); |
941 | 1069 | $new_file = $path.$random->createSecureSalt(32, 'hex'); |
942 | 1070 | } |
943 | 1071 | // Pass if a target document to move is same |
944 | - if($old_file == $new_file) continue; |
|
1072 | + if($old_file == $new_file) { |
|
1073 | + continue; |
|
1074 | + } |
|
945 | 1075 | // Create a directory |
946 | 1076 | FileHandler::makeDir($path); |
947 | 1077 | // Move the file |
@@ -961,16 +1091,22 @@ discard block |
||
961 | 1091 | $vars = Context::getRequestVars(); |
962 | 1092 | $logged_info = Context::get('logged_info'); |
963 | 1093 | |
964 | - if(!$vars->editor_sequence) return new Object(-1, 'msg_invalid_request'); |
|
1094 | + if(!$vars->editor_sequence) { |
|
1095 | + return new Object(-1, 'msg_invalid_request'); |
|
1096 | + } |
|
965 | 1097 | |
966 | 1098 | $upload_target_srl = $_SESSION['upload_info'][$vars->editor_sequence]->upload_target_srl; |
967 | 1099 | |
968 | 1100 | $oFileModel = getModel('file'); |
969 | 1101 | $file_info = $oFileModel->getFile($vars->file_srl); |
970 | 1102 | |
971 | - if(!$file_info) return new Object(-1, 'msg_not_founded'); |
|
1103 | + if(!$file_info) { |
|
1104 | + return new Object(-1, 'msg_not_founded'); |
|
1105 | + } |
|
972 | 1106 | |
973 | - if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted'); |
|
1107 | + if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) { |
|
1108 | + return new Object(-1, 'msg_not_permitted'); |
|
1109 | + } |
|
974 | 1110 | |
975 | 1111 | $args = new stdClass(); |
976 | 1112 | $args->file_srl = $vars->file_srl; |