@@ -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,28 +61,28 @@ 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 | - $this->setTemplatePath($this->module_path.'tpl'); |
|
85 | + $this->setTemplatePath($this->module_path . 'tpl'); |
|
86 | 86 | $this->setTemplateFile('iframe'); |
87 | 87 | } |
88 | 88 | |
@@ -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'], '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'], '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,28 +324,28 @@ 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 | 332 | header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
333 | 333 | |
334 | - header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
334 | + header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
335 | 335 | header("Content-Transfer-Encoding: binary\n"); |
336 | - header("Content-Length: " .(string)($file_size)); |
|
336 | + header("Content-Length: " . (string) ($file_size)); |
|
337 | 337 | |
338 | - if(isset($_SERVER['HTTP_RANGE'])) |
|
338 | + if (isset($_SERVER['HTTP_RANGE'])) |
|
339 | 339 | { |
340 | 340 | preg_match('/bytes=(\d+)-(\d+)?/', $_SERVER['HTTP_RANGE'], $matches); |
341 | 341 | $start = intval($matches[1]); |
342 | 342 | $length = intval($matches[2]) - $start; |
343 | 343 | fseek($fp, $start); |
344 | 344 | header('HTTP/1.1 206 Partial Content'); |
345 | - header('Content-Range: bytes '.$start.'-'.($start+$length).'/'.$file_size); |
|
346 | - if($length > 1024 * 1024) |
|
345 | + header('Content-Range: bytes ' . $start . '-' . ($start + $length) . '/' . $file_size); |
|
346 | + if ($length > 1024 * 1024) |
|
347 | 347 | { |
348 | - while(!feof($fp)) echo fread($fp, 1024); |
|
348 | + while (!feof($fp)) echo fread($fp, 1024); |
|
349 | 349 | fclose($fp); |
350 | 350 | } |
351 | 351 | else |
@@ -356,9 +356,9 @@ discard block |
||
356 | 356 | else |
357 | 357 | { |
358 | 358 | // if file size is lager than 10MB, use fread function (#18675748) |
359 | - if($file_size > 1024 * 1024) |
|
359 | + if ($file_size > 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 |
@@ -381,36 +381,36 @@ discard block |
||
381 | 381 | $editor_sequence = Context::get('editor_sequence'); |
382 | 382 | $file_srl = Context::get('file_srl'); |
383 | 383 | $file_srls = Context::get('file_srls'); |
384 | - if($file_srls) $file_srl = $file_srls; |
|
384 | + if ($file_srls) $file_srl = $file_srls; |
|
385 | 385 | // Exit a session if there is neither upload permission nor information |
386 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
386 | + if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
387 | 387 | |
388 | 388 | $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
389 | 389 | |
390 | 390 | $logged_info = Context::get('logged_info'); |
391 | 391 | $oFileModel = getModel('file'); |
392 | 392 | |
393 | - $srls = explode(',',$file_srl); |
|
394 | - if(!count($srls)) return; |
|
393 | + $srls = explode(',', $file_srl); |
|
394 | + if (!count($srls)) return; |
|
395 | 395 | |
396 | - for($i=0;$i<count($srls);$i++) |
|
396 | + for ($i = 0; $i < count($srls); $i++) |
|
397 | 397 | { |
398 | - $srl = (int)$srls[$i]; |
|
399 | - if(!$srl) continue; |
|
398 | + $srl = (int) $srls[$i]; |
|
399 | + if (!$srl) continue; |
|
400 | 400 | |
401 | 401 | $args = new stdClass; |
402 | 402 | $args->file_srl = $srl; |
403 | 403 | $output = executeQuery('file.getFile', $args); |
404 | - if(!$output->toBool()) continue; |
|
404 | + if (!$output->toBool()) continue; |
|
405 | 405 | |
406 | 406 | $file_info = $output->data; |
407 | - if(!$file_info) continue; |
|
407 | + if (!$file_info) continue; |
|
408 | 408 | |
409 | 409 | $file_grant = $oFileModel->getFileGrant($file_info, $logged_info); |
410 | 410 | |
411 | - if(!$file_grant->is_deletable) continue; |
|
411 | + if (!$file_grant->is_deletable) continue; |
|
412 | 412 | |
413 | - if($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl); |
|
413 | + if ($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl); |
|
414 | 414 | } |
415 | 415 | } |
416 | 416 | |
@@ -421,23 +421,23 @@ discard block |
||
421 | 421 | */ |
422 | 422 | function procFileGetList() |
423 | 423 | { |
424 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
424 | + if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted'); |
|
425 | 425 | $fileSrls = Context::get('file_srls'); |
426 | - if($fileSrls) $fileSrlList = explode(',', $fileSrls); |
|
426 | + if ($fileSrls) $fileSrlList = explode(',', $fileSrls); |
|
427 | 427 | |
428 | 428 | global $lang; |
429 | - if(count($fileSrlList) > 0) |
|
429 | + if (count($fileSrlList) > 0) |
|
430 | 430 | { |
431 | 431 | $oFileModel = getModel('file'); |
432 | 432 | $fileList = $oFileModel->getFile($fileSrlList); |
433 | - if(!is_array($fileList)) $fileList = array($fileList); |
|
433 | + if (!is_array($fileList)) $fileList = array($fileList); |
|
434 | 434 | |
435 | - if(is_array($fileList)) |
|
435 | + if (is_array($fileList)) |
|
436 | 436 | { |
437 | - foreach($fileList AS $key=>$value) |
|
437 | + foreach ($fileList AS $key=>$value) |
|
438 | 438 | { |
439 | 439 | $value->human_file_size = FileHandler::filesize($value->file_size); |
440 | - if($value->isvalid=='Y') $value->validName = $lang->is_valid; |
|
440 | + if ($value->isvalid == 'Y') $value->validName = $lang->is_valid; |
|
441 | 441 | else $value->validName = $lang->is_stand_by; |
442 | 442 | } |
443 | 443 | } |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | function triggerCheckAttached(&$obj) |
460 | 460 | { |
461 | 461 | $document_srl = $obj->document_srl; |
462 | - if(!$document_srl) return new Object(); |
|
462 | + if (!$document_srl) return new Object(); |
|
463 | 463 | // Get numbers of attachments |
464 | 464 | $oFileModel = getModel('file'); |
465 | 465 | $obj->uploaded_count = $oFileModel->getFilesCount($document_srl); |
@@ -476,10 +476,10 @@ discard block |
||
476 | 476 | function triggerAttachFiles(&$obj) |
477 | 477 | { |
478 | 478 | $document_srl = $obj->document_srl; |
479 | - if(!$document_srl) return new Object(); |
|
479 | + if (!$document_srl) return new Object(); |
|
480 | 480 | |
481 | 481 | $output = $this->setFilesValid($document_srl); |
482 | - if(!$output->toBool()) return $output; |
|
482 | + if (!$output->toBool()) return $output; |
|
483 | 483 | |
484 | 484 | return new Object(); |
485 | 485 | } |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | function triggerDeleteAttached(&$obj) |
494 | 494 | { |
495 | 495 | $document_srl = $obj->document_srl; |
496 | - if(!$document_srl) return new Object(); |
|
496 | + if (!$document_srl) return new Object(); |
|
497 | 497 | |
498 | 498 | $output = $this->deleteFiles($document_srl); |
499 | 499 | return $output; |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | function triggerCommentCheckAttached(&$obj) |
509 | 509 | { |
510 | 510 | $comment_srl = $obj->comment_srl; |
511 | - if(!$comment_srl) return new Object(); |
|
511 | + if (!$comment_srl) return new Object(); |
|
512 | 512 | // Get numbers of attachments |
513 | 513 | $oFileModel = getModel('file'); |
514 | 514 | $obj->uploaded_count = $oFileModel->getFilesCount($comment_srl); |
@@ -526,10 +526,10 @@ discard block |
||
526 | 526 | { |
527 | 527 | $comment_srl = $obj->comment_srl; |
528 | 528 | $uploaded_count = $obj->uploaded_count; |
529 | - if(!$comment_srl || !$uploaded_count) return new Object(); |
|
529 | + if (!$comment_srl || !$uploaded_count) return new Object(); |
|
530 | 530 | |
531 | 531 | $output = $this->setFilesValid($comment_srl); |
532 | - if(!$output->toBool()) return $output; |
|
532 | + if (!$output->toBool()) return $output; |
|
533 | 533 | |
534 | 534 | return new Object(); |
535 | 535 | } |
@@ -543,9 +543,9 @@ discard block |
||
543 | 543 | function triggerCommentDeleteAttached(&$obj) |
544 | 544 | { |
545 | 545 | $comment_srl = $obj->comment_srl; |
546 | - if(!$comment_srl) return new Object(); |
|
546 | + if (!$comment_srl) return new Object(); |
|
547 | 547 | |
548 | - if($obj->isMoveToTrash) return new Object(); |
|
548 | + if ($obj->isMoveToTrash) return new Object(); |
|
549 | 549 | |
550 | 550 | $output = $this->deleteFiles($comment_srl); |
551 | 551 | return $output; |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | function triggerDeleteModuleFiles(&$obj) |
561 | 561 | { |
562 | 562 | $module_srl = $obj->module_srl; |
563 | - if(!$module_srl) return new Object(); |
|
563 | + if (!$module_srl) return new Object(); |
|
564 | 564 | |
565 | 565 | $oFileController = getAdminController('file'); |
566 | 566 | return $oFileController->deleteModuleFiles($module_srl); |
@@ -573,9 +573,9 @@ discard block |
||
573 | 573 | * @param int $upload_target_srl |
574 | 574 | * @return void |
575 | 575 | */ |
576 | - function setUploadInfo($editor_sequence, $upload_target_srl=0) |
|
576 | + function setUploadInfo($editor_sequence, $upload_target_srl = 0) |
|
577 | 577 | { |
578 | - if(!isset($_SESSION['upload_info'][$editor_sequence])) |
|
578 | + if (!isset($_SESSION['upload_info'][$editor_sequence])) |
|
579 | 579 | { |
580 | 580 | $_SESSION['upload_info'][$editor_sequence] = new stdClass(); |
581 | 581 | } |
@@ -635,36 +635,36 @@ discard block |
||
635 | 635 | $trigger_obj->module_srl = $module_srl; |
636 | 636 | $trigger_obj->upload_target_srl = $upload_target_srl; |
637 | 637 | $output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj); |
638 | - if(!$output->toBool()) return $output; |
|
638 | + if (!$output->toBool()) return $output; |
|
639 | 639 | |
640 | 640 | // A workaround for Firefox upload bug |
641 | - if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match)) |
|
641 | + if (preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match)) |
|
642 | 642 | { |
643 | 643 | $file_info['name'] = base64_decode(strtr($match[1], ':', '/')); |
644 | 644 | } |
645 | 645 | |
646 | - if(!$manual_insert) |
|
646 | + if (!$manual_insert) |
|
647 | 647 | { |
648 | 648 | // Get the file configurations |
649 | 649 | $logged_info = Context::get('logged_info'); |
650 | - if($logged_info->is_admin != 'Y') |
|
650 | + if ($logged_info->is_admin != 'Y') |
|
651 | 651 | { |
652 | 652 | $oFileModel = getModel('file'); |
653 | 653 | $config = $oFileModel->getFileConfig($module_srl); |
654 | 654 | |
655 | 655 | // check file type |
656 | - if(isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*') |
|
656 | + if (isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*') |
|
657 | 657 | { |
658 | 658 | $filetypes = explode(';', $config->allowed_filetypes); |
659 | 659 | $ext = array(); |
660 | - foreach($filetypes as $item) { |
|
660 | + foreach ($filetypes as $item) { |
|
661 | 661 | $item = explode('.', $item); |
662 | 662 | $ext[] = strtolower($item[1]); |
663 | 663 | } |
664 | 664 | $uploaded_ext = explode('.', $file_info['name']); |
665 | 665 | $uploaded_ext = strtolower(array_pop($uploaded_ext)); |
666 | 666 | |
667 | - if(!in_array($uploaded_ext, $ext)) |
|
667 | + if (!in_array($uploaded_ext, $ext)) |
|
668 | 668 | { |
669 | 669 | return $this->stop('msg_not_allowed_filetype'); |
670 | 670 | } |
@@ -673,74 +673,74 @@ discard block |
||
673 | 673 | $allowed_filesize = $config->allowed_filesize * 1024 * 1024; |
674 | 674 | $allowed_attach_size = $config->allowed_attach_size * 1024 * 1024; |
675 | 675 | // An error appears if file size exceeds a limit |
676 | - if($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-1, 'msg_exceeds_limit_size'); |
|
676 | + if ($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-1, 'msg_exceeds_limit_size'); |
|
677 | 677 | // Get total file size of all attachements (from DB) |
678 | 678 | $size_args = new stdClass; |
679 | 679 | $size_args->upload_target_srl = $upload_target_srl; |
680 | 680 | $output = executeQuery('file.getAttachedFileSize', $size_args); |
681 | - $attached_size = (int)$output->data->attached_size + filesize($file_info['tmp_name']); |
|
682 | - if($attached_size > $allowed_attach_size) return new Object(-1, 'msg_exceeds_limit_size'); |
|
681 | + $attached_size = (int) $output->data->attached_size + filesize($file_info['tmp_name']); |
|
682 | + if ($attached_size > $allowed_attach_size) return new Object(-1, 'msg_exceeds_limit_size'); |
|
683 | 683 | } |
684 | 684 | } |
685 | 685 | |
686 | 686 | // https://github.com/xpressengine/xe-core/issues/1713 |
687 | - $file_info['name'] = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x',$file_info['name']); |
|
687 | + $file_info['name'] = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x', $file_info['name']); |
|
688 | 688 | $file_info['name'] = removeHackTag($file_info['name']); |
689 | - $file_info['name'] = str_replace(array('<','>'),array('%3C','%3E'),$file_info['name']); |
|
689 | + $file_info['name'] = str_replace(array('<', '>'), array('%3C', '%3E'), $file_info['name']); |
|
690 | 690 | |
691 | 691 | // Get random number generator |
692 | 692 | $random = new Password(); |
693 | 693 | |
694 | 694 | // Set upload path by checking if the attachement is an image or other kinds of file |
695 | - 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 | + 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'])) |
|
696 | 696 | { |
697 | - $path = sprintf("./files/attach/images/%s/%s", $module_srl,getNumberingPath($upload_target_srl,3)); |
|
697 | + $path = sprintf("./files/attach/images/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3)); |
|
698 | 698 | |
699 | 699 | // special character to '_' |
700 | 700 | // change to random file name. because window php bug. window php is not recognize unicode character file name - by cherryfilter |
701 | - $ext = substr(strrchr($file_info['name'],'.'),1); |
|
701 | + $ext = substr(strrchr($file_info['name'], '.'), 1); |
|
702 | 702 | //$_filename = preg_replace('/[#$&*?+%"\']/', '_', $file_info['name']); |
703 | - $_filename = $random->createSecureSalt(32, 'hex').'.'.$ext; |
|
704 | - $filename = $path.$_filename; |
|
703 | + $_filename = $random->createSecureSalt(32, 'hex') . '.' . $ext; |
|
704 | + $filename = $path . $_filename; |
|
705 | 705 | $idx = 1; |
706 | - while(file_exists($filename)) |
|
706 | + while (file_exists($filename)) |
|
707 | 707 | { |
708 | - $filename = $path.preg_replace('/\.([a-z0-9]+)$/i','_'.$idx.'.$1',$_filename); |
|
708 | + $filename = $path . preg_replace('/\.([a-z0-9]+)$/i', '_' . $idx . '.$1', $_filename); |
|
709 | 709 | $idx++; |
710 | 710 | } |
711 | 711 | $direct_download = 'Y'; |
712 | 712 | } |
713 | 713 | else |
714 | 714 | { |
715 | - $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3)); |
|
716 | - $filename = $path.$random->createSecureSalt(32, 'hex'); |
|
715 | + $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3)); |
|
716 | + $filename = $path . $random->createSecureSalt(32, 'hex'); |
|
717 | 717 | $direct_download = 'N'; |
718 | 718 | } |
719 | 719 | // Create a directory |
720 | - if(!FileHandler::makeDir($path)) return new Object(-1,'msg_not_permitted_create'); |
|
720 | + if (!FileHandler::makeDir($path)) return new Object(-1, 'msg_not_permitted_create'); |
|
721 | 721 | |
722 | 722 | // Check uploaded file |
723 | - if(!checkUploadedFile($file_info['tmp_name'])) return new Object(-1,'msg_file_upload_error'); |
|
723 | + if (!checkUploadedFile($file_info['tmp_name'])) return new Object(-1, 'msg_file_upload_error'); |
|
724 | 724 | |
725 | 725 | // Get random number generator |
726 | 726 | $random = new Password(); |
727 | 727 | |
728 | 728 | // Move the file |
729 | - if($manual_insert) |
|
729 | + if ($manual_insert) |
|
730 | 730 | { |
731 | 731 | @copy($file_info['tmp_name'], $filename); |
732 | - if(!file_exists($filename)) |
|
732 | + if (!file_exists($filename)) |
|
733 | 733 | { |
734 | - $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
|
734 | + $filename = $path . $random->createSecureSalt(32, 'hex') . '.' . $ext; |
|
735 | 735 | @copy($file_info['tmp_name'], $filename); |
736 | 736 | } |
737 | 737 | } |
738 | 738 | else |
739 | 739 | { |
740 | - if(!@move_uploaded_file($file_info['tmp_name'], $filename)) |
|
740 | + if (!@move_uploaded_file($file_info['tmp_name'], $filename)) |
|
741 | 741 | { |
742 | - $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
|
743 | - if(!@move_uploaded_file($file_info['tmp_name'], $filename)) return new Object(-1,'msg_file_upload_error'); |
|
742 | + $filename = $path . $random->createSecureSalt(32, 'hex') . '.' . $ext; |
|
743 | + if (!@move_uploaded_file($file_info['tmp_name'], $filename)) return new Object(-1, 'msg_file_upload_error'); |
|
744 | 744 | } |
745 | 745 | } |
746 | 746 | // Get member information |
@@ -761,10 +761,10 @@ discard block |
||
761 | 761 | $args->sid = $random->createSecureSalt(32, 'hex'); |
762 | 762 | |
763 | 763 | $output = executeQuery('file.insertFile', $args); |
764 | - if(!$output->toBool()) return $output; |
|
764 | + if (!$output->toBool()) return $output; |
|
765 | 765 | // Call a trigger (after) |
766 | 766 | $trigger_output = ModuleHandler::triggerCall('file.insertFile', 'after', $args); |
767 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
767 | + if (!$trigger_output->toBool()) return $trigger_output; |
|
768 | 768 | |
769 | 769 | $_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true; |
770 | 770 | |
@@ -807,18 +807,18 @@ discard block |
||
807 | 807 | */ |
808 | 808 | function deleteFile($file_srl) |
809 | 809 | { |
810 | - if(!$file_srl) return; |
|
810 | + if (!$file_srl) return; |
|
811 | 811 | |
812 | 812 | $srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl); |
813 | - if(!count($srls)) return; |
|
813 | + if (!count($srls)) return; |
|
814 | 814 | |
815 | 815 | $oDocumentController = getController('document'); |
816 | 816 | $documentSrlList = array(); |
817 | 817 | |
818 | - foreach($srls as $srl) |
|
818 | + foreach ($srls as $srl) |
|
819 | 819 | { |
820 | - $srl = (int)$srl; |
|
821 | - if(!$srl) |
|
820 | + $srl = (int) $srl; |
|
821 | + if (!$srl) |
|
822 | 822 | { |
823 | 823 | continue; |
824 | 824 | } |
@@ -827,14 +827,14 @@ discard block |
||
827 | 827 | $args->file_srl = $srl; |
828 | 828 | $output = executeQuery('file.getFile', $args); |
829 | 829 | |
830 | - if(!$output->toBool() || !$output->data) |
|
830 | + if (!$output->toBool() || !$output->data) |
|
831 | 831 | { |
832 | 832 | continue; |
833 | 833 | } |
834 | 834 | |
835 | 835 | $file_info = $output->data; |
836 | 836 | |
837 | - if($file_info->upload_target_srl) |
|
837 | + if ($file_info->upload_target_srl) |
|
838 | 838 | { |
839 | 839 | $documentSrlList[] = $file_info->upload_target_srl; |
840 | 840 | } |
@@ -845,15 +845,15 @@ discard block |
||
845 | 845 | // Call a trigger (before) |
846 | 846 | $trigger_obj = $output->data; |
847 | 847 | $output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj); |
848 | - if(!$output->toBool()) return $output; |
|
848 | + if (!$output->toBool()) return $output; |
|
849 | 849 | |
850 | 850 | // Remove from the DB |
851 | 851 | $output = executeQuery('file.deleteFile', $args); |
852 | - if(!$output->toBool()) return $output; |
|
852 | + if (!$output->toBool()) return $output; |
|
853 | 853 | |
854 | 854 | // Call a trigger (after) |
855 | 855 | $trigger_output = ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj); |
856 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
856 | + if (!$trigger_output->toBool()) return $trigger_output; |
|
857 | 857 | |
858 | 858 | // If successfully deleted, remove the file |
859 | 859 | FileHandler::removeFile($uploaded_filename); |
@@ -877,28 +877,28 @@ discard block |
||
877 | 877 | $columnList = array('file_srl', 'uploaded_filename', 'module_srl'); |
878 | 878 | $file_list = $oFileModel->getFiles($upload_target_srl, $columnList); |
879 | 879 | // Success returned if no attachement exists |
880 | - if(!is_array($file_list)||!count($file_list)) return new Object(); |
|
880 | + if (!is_array($file_list) || !count($file_list)) return new Object(); |
|
881 | 881 | |
882 | 882 | // Delete the file |
883 | 883 | $path = array(); |
884 | 884 | $file_count = count($file_list); |
885 | - for($i=0;$i<$file_count;$i++) |
|
885 | + for ($i = 0; $i < $file_count; $i++) |
|
886 | 886 | { |
887 | 887 | $this->deleteFile($file_list[$i]->file_srl); |
888 | 888 | |
889 | 889 | $uploaded_filename = $file_list[$i]->uploaded_filename; |
890 | 890 | $path_info = pathinfo($uploaded_filename); |
891 | - if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
891 | + if (!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
892 | 892 | } |
893 | 893 | |
894 | 894 | // Remove from the DB |
895 | 895 | $args = new stdClass(); |
896 | 896 | $args->upload_target_srl = $upload_target_srl; |
897 | 897 | $output = executeQuery('file.deleteFiles', $args); |
898 | - if(!$output->toBool()) return $output; |
|
898 | + if (!$output->toBool()) return $output; |
|
899 | 899 | |
900 | 900 | // Remove a file directory of the document |
901 | - for($i=0, $c=count($path); $i<$c; $i++) |
|
901 | + for ($i = 0, $c = count($path); $i < $c; $i++) |
|
902 | 902 | { |
903 | 903 | FileHandler::removeBlankDir($path[$i]); |
904 | 904 | } |
@@ -916,33 +916,33 @@ discard block |
||
916 | 916 | */ |
917 | 917 | function moveFile($source_srl, $target_module_srl, $target_srl) |
918 | 918 | { |
919 | - if($source_srl == $target_srl) return; |
|
919 | + if ($source_srl == $target_srl) return; |
|
920 | 920 | |
921 | 921 | $oFileModel = getModel('file'); |
922 | 922 | $file_list = $oFileModel->getFiles($source_srl); |
923 | - if(!$file_list) return; |
|
923 | + if (!$file_list) return; |
|
924 | 924 | |
925 | 925 | $file_count = count($file_list); |
926 | 926 | |
927 | - for($i=0;$i<$file_count;$i++) |
|
927 | + for ($i = 0; $i < $file_count; $i++) |
|
928 | 928 | { |
929 | 929 | unset($file_info); |
930 | 930 | $file_info = $file_list[$i]; |
931 | 931 | $old_file = $file_info->uploaded_filename; |
932 | 932 | // Determine the file path by checking if the file is an image or other kinds |
933 | - 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 | + 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)) |
|
934 | 934 | { |
935 | - $path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl); |
|
936 | - $new_file = $path.$file_info->source_filename; |
|
935 | + $path = sprintf("./files/attach/images/%s/%s/", $target_module_srl, $target_srl); |
|
936 | + $new_file = $path . $file_info->source_filename; |
|
937 | 937 | } |
938 | 938 | else |
939 | 939 | { |
940 | 940 | $path = sprintf("./files/attach/binaries/%s/%s/", $target_module_srl, $target_srl); |
941 | 941 | $random = new Password(); |
942 | - $new_file = $path.$random->createSecureSalt(32, 'hex'); |
|
942 | + $new_file = $path . $random->createSecureSalt(32, 'hex'); |
|
943 | 943 | } |
944 | 944 | // Pass if a target document to move is same |
945 | - if($old_file == $new_file) continue; |
|
945 | + if ($old_file == $new_file) continue; |
|
946 | 946 | // Create a directory |
947 | 947 | FileHandler::makeDir($path); |
948 | 948 | // Move the file |
@@ -962,18 +962,18 @@ discard block |
||
962 | 962 | $vars = Context::getRequestVars(); |
963 | 963 | $logged_info = Context::get('logged_info'); |
964 | 964 | |
965 | - if(!$vars->editor_sequence) return new Object(-1, 'msg_invalid_request'); |
|
965 | + if (!$vars->editor_sequence) return new Object(-1, 'msg_invalid_request'); |
|
966 | 966 | |
967 | 967 | $upload_target_srl = $_SESSION['upload_info'][$vars->editor_sequence]->upload_target_srl; |
968 | 968 | |
969 | 969 | $oFileModel = getModel('file'); |
970 | 970 | $file_info = $oFileModel->getFile($vars->file_srl); |
971 | 971 | |
972 | - if(!$file_info) return new Object(-1, 'msg_not_founded'); |
|
972 | + if (!$file_info) return new Object(-1, 'msg_not_founded'); |
|
973 | 973 | |
974 | - if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted'); |
|
974 | + if (!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted'); |
|
975 | 975 | |
976 | - $args = new stdClass(); |
|
976 | + $args = new stdClass(); |
|
977 | 977 | $args->file_srl = $vars->file_srl; |
978 | 978 | $args->upload_target_srl = $upload_target_srl; |
979 | 979 | |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | |
983 | 983 | $args->cover_image = 'N'; |
984 | 984 | $output = executeQuery('file.updateClearCoverImage', $args); |
985 | - if(!$output->toBool()) |
|
985 | + if (!$output->toBool()) |
|
986 | 986 | { |
987 | 987 | $oDB->rollback(); |
988 | 988 | return $output; |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | |
991 | 991 | $args->cover_image = 'Y'; |
992 | 992 | $output = executeQuery('file.updateCoverImage', $args); |
993 | - if(!$output->toBool()) |
|
993 | + if (!$output->toBool()) |
|
994 | 994 | { |
995 | 995 | $oDB->rollback(); |
996 | 996 | return $output; |
@@ -1022,9 +1022,9 @@ discard block |
||
1022 | 1022 | $fileConfig = $oModuleModel->getModulePartConfig('file', $obj->originModuleSrl); |
1023 | 1023 | |
1024 | 1024 | $oModuleController = getController('module'); |
1025 | - if(is_array($obj->moduleSrlList)) |
|
1025 | + if (is_array($obj->moduleSrlList)) |
|
1026 | 1026 | { |
1027 | - foreach($obj->moduleSrlList AS $key=>$moduleSrl) |
|
1027 | + foreach ($obj->moduleSrlList AS $key=>$moduleSrl) |
|
1028 | 1028 | { |
1029 | 1029 | $oModuleController->insertModulePartConfig('file', $moduleSrl, $fileConfig); |
1030 | 1030 | } |
@@ -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 | { |
@@ -316,7 +366,9 @@ discard block |
||
316 | 366 | |
317 | 367 | if($is_android) |
318 | 368 | { |
319 | - if($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
369 | + if($_SESSION['__XE_FILE_KEY__'][$file_srl]) { |
|
370 | + $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
371 | + } |
|
320 | 372 | } |
321 | 373 | |
322 | 374 | unset($_SESSION[$session_key][$file_srl]); |
@@ -324,7 +376,9 @@ discard block |
||
324 | 376 | Context::close(); |
325 | 377 | |
326 | 378 | $fp = fopen($uploaded_filename, 'rb'); |
327 | - if(!$fp) return $this->stop('msg_file_not_found'); |
|
379 | + if(!$fp) { |
|
380 | + return $this->stop('msg_file_not_found'); |
|
381 | + } |
|
328 | 382 | |
329 | 383 | header("Cache-Control: "); |
330 | 384 | header("Pragma: "); |
@@ -345,23 +399,24 @@ discard block |
||
345 | 399 | header('Content-Range: bytes '.$start.'-'.($start+$length).'/'.$file_size); |
346 | 400 | if($length > 1024 * 1024) |
347 | 401 | { |
348 | - while(!feof($fp)) echo fread($fp, 1024); |
|
402 | + while(!feof($fp)) { |
|
403 | + echo fread($fp, 1024); |
|
404 | + } |
|
349 | 405 | fclose($fp); |
350 | - } |
|
351 | - else |
|
406 | + } else |
|
352 | 407 | { |
353 | 408 | fpassthru($fp); |
354 | 409 | } |
355 | - } |
|
356 | - else |
|
410 | + } else |
|
357 | 411 | { |
358 | 412 | // if file size is lager than 10MB, use fread function (#18675748) |
359 | 413 | if($file_size > 1024 * 1024) |
360 | 414 | { |
361 | - while(!feof($fp)) echo fread($fp, 1024); |
|
415 | + while(!feof($fp)) { |
|
416 | + echo fread($fp, 1024); |
|
417 | + } |
|
362 | 418 | fclose($fp); |
363 | - } |
|
364 | - else |
|
419 | + } else |
|
365 | 420 | { |
366 | 421 | fpassthru($fp); |
367 | 422 | } |
@@ -381,9 +436,13 @@ discard block |
||
381 | 436 | $editor_sequence = Context::get('editor_sequence'); |
382 | 437 | $file_srl = Context::get('file_srl'); |
383 | 438 | $file_srls = Context::get('file_srls'); |
384 | - if($file_srls) $file_srl = $file_srls; |
|
439 | + if($file_srls) { |
|
440 | + $file_srl = $file_srls; |
|
441 | + } |
|
385 | 442 | // Exit a session if there is neither upload permission nor information |
386 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
443 | + if(!$_SESSION['upload_info'][$editor_sequence]->enabled) { |
|
444 | + exit(); |
|
445 | + } |
|
387 | 446 | |
388 | 447 | $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
389 | 448 | |
@@ -391,26 +450,38 @@ discard block |
||
391 | 450 | $oFileModel = getModel('file'); |
392 | 451 | |
393 | 452 | $srls = explode(',',$file_srl); |
394 | - if(!count($srls)) return; |
|
453 | + if(!count($srls)) { |
|
454 | + return; |
|
455 | + } |
|
395 | 456 | |
396 | 457 | for($i=0;$i<count($srls);$i++) |
397 | 458 | { |
398 | 459 | $srl = (int)$srls[$i]; |
399 | - if(!$srl) continue; |
|
460 | + if(!$srl) { |
|
461 | + continue; |
|
462 | + } |
|
400 | 463 | |
401 | 464 | $args = new stdClass; |
402 | 465 | $args->file_srl = $srl; |
403 | 466 | $output = executeQuery('file.getFile', $args); |
404 | - if(!$output->toBool()) continue; |
|
467 | + if(!$output->toBool()) { |
|
468 | + continue; |
|
469 | + } |
|
405 | 470 | |
406 | 471 | $file_info = $output->data; |
407 | - if(!$file_info) continue; |
|
472 | + if(!$file_info) { |
|
473 | + continue; |
|
474 | + } |
|
408 | 475 | |
409 | 476 | $file_grant = $oFileModel->getFileGrant($file_info, $logged_info); |
410 | 477 | |
411 | - if(!$file_grant->is_deletable) continue; |
|
478 | + if(!$file_grant->is_deletable) { |
|
479 | + continue; |
|
480 | + } |
|
412 | 481 | |
413 | - if($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl); |
|
482 | + if($upload_target_srl && $file_srl) { |
|
483 | + $output = $this->deleteFile($file_srl); |
|
484 | + } |
|
414 | 485 | } |
415 | 486 | } |
416 | 487 | |
@@ -421,28 +492,36 @@ discard block |
||
421 | 492 | */ |
422 | 493 | function procFileGetList() |
423 | 494 | { |
424 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
495 | + if(!Context::get('is_logged')) { |
|
496 | + return new Object(-1,'msg_not_permitted'); |
|
497 | + } |
|
425 | 498 | $fileSrls = Context::get('file_srls'); |
426 | - if($fileSrls) $fileSrlList = explode(',', $fileSrls); |
|
499 | + if($fileSrls) { |
|
500 | + $fileSrlList = explode(',', $fileSrls); |
|
501 | + } |
|
427 | 502 | |
428 | 503 | global $lang; |
429 | 504 | if(count($fileSrlList) > 0) |
430 | 505 | { |
431 | 506 | $oFileModel = getModel('file'); |
432 | 507 | $fileList = $oFileModel->getFile($fileSrlList); |
433 | - if(!is_array($fileList)) $fileList = array($fileList); |
|
508 | + if(!is_array($fileList)) { |
|
509 | + $fileList = array($fileList); |
|
510 | + } |
|
434 | 511 | |
435 | 512 | if(is_array($fileList)) |
436 | 513 | { |
437 | 514 | foreach($fileList AS $key=>$value) |
438 | 515 | { |
439 | 516 | $value->human_file_size = FileHandler::filesize($value->file_size); |
440 | - if($value->isvalid=='Y') $value->validName = $lang->is_valid; |
|
441 | - else $value->validName = $lang->is_stand_by; |
|
517 | + if($value->isvalid=='Y') { |
|
518 | + $value->validName = $lang->is_valid; |
|
519 | + } else { |
|
520 | + $value->validName = $lang->is_stand_by; |
|
521 | + } |
|
442 | 522 | } |
443 | 523 | } |
444 | - } |
|
445 | - else |
|
524 | + } else |
|
446 | 525 | { |
447 | 526 | $fileList = array(); |
448 | 527 | $this->setMessage($lang->no_files); |
@@ -459,7 +538,9 @@ discard block |
||
459 | 538 | function triggerCheckAttached(&$obj) |
460 | 539 | { |
461 | 540 | $document_srl = $obj->document_srl; |
462 | - if(!$document_srl) return new Object(); |
|
541 | + if(!$document_srl) { |
|
542 | + return new Object(); |
|
543 | + } |
|
463 | 544 | // Get numbers of attachments |
464 | 545 | $oFileModel = getModel('file'); |
465 | 546 | $obj->uploaded_count = $oFileModel->getFilesCount($document_srl); |
@@ -476,10 +557,14 @@ discard block |
||
476 | 557 | function triggerAttachFiles(&$obj) |
477 | 558 | { |
478 | 559 | $document_srl = $obj->document_srl; |
479 | - if(!$document_srl) return new Object(); |
|
560 | + if(!$document_srl) { |
|
561 | + return new Object(); |
|
562 | + } |
|
480 | 563 | |
481 | 564 | $output = $this->setFilesValid($document_srl); |
482 | - if(!$output->toBool()) return $output; |
|
565 | + if(!$output->toBool()) { |
|
566 | + return $output; |
|
567 | + } |
|
483 | 568 | |
484 | 569 | return new Object(); |
485 | 570 | } |
@@ -493,7 +578,9 @@ discard block |
||
493 | 578 | function triggerDeleteAttached(&$obj) |
494 | 579 | { |
495 | 580 | $document_srl = $obj->document_srl; |
496 | - if(!$document_srl) return new Object(); |
|
581 | + if(!$document_srl) { |
|
582 | + return new Object(); |
|
583 | + } |
|
497 | 584 | |
498 | 585 | $output = $this->deleteFiles($document_srl); |
499 | 586 | return $output; |
@@ -508,7 +595,9 @@ discard block |
||
508 | 595 | function triggerCommentCheckAttached(&$obj) |
509 | 596 | { |
510 | 597 | $comment_srl = $obj->comment_srl; |
511 | - if(!$comment_srl) return new Object(); |
|
598 | + if(!$comment_srl) { |
|
599 | + return new Object(); |
|
600 | + } |
|
512 | 601 | // Get numbers of attachments |
513 | 602 | $oFileModel = getModel('file'); |
514 | 603 | $obj->uploaded_count = $oFileModel->getFilesCount($comment_srl); |
@@ -526,10 +615,14 @@ discard block |
||
526 | 615 | { |
527 | 616 | $comment_srl = $obj->comment_srl; |
528 | 617 | $uploaded_count = $obj->uploaded_count; |
529 | - if(!$comment_srl || !$uploaded_count) return new Object(); |
|
618 | + if(!$comment_srl || !$uploaded_count) { |
|
619 | + return new Object(); |
|
620 | + } |
|
530 | 621 | |
531 | 622 | $output = $this->setFilesValid($comment_srl); |
532 | - if(!$output->toBool()) return $output; |
|
623 | + if(!$output->toBool()) { |
|
624 | + return $output; |
|
625 | + } |
|
533 | 626 | |
534 | 627 | return new Object(); |
535 | 628 | } |
@@ -543,9 +636,13 @@ discard block |
||
543 | 636 | function triggerCommentDeleteAttached(&$obj) |
544 | 637 | { |
545 | 638 | $comment_srl = $obj->comment_srl; |
546 | - if(!$comment_srl) return new Object(); |
|
639 | + if(!$comment_srl) { |
|
640 | + return new Object(); |
|
641 | + } |
|
547 | 642 | |
548 | - if($obj->isMoveToTrash) return new Object(); |
|
643 | + if($obj->isMoveToTrash) { |
|
644 | + return new Object(); |
|
645 | + } |
|
549 | 646 | |
550 | 647 | $output = $this->deleteFiles($comment_srl); |
551 | 648 | return $output; |
@@ -560,7 +657,9 @@ discard block |
||
560 | 657 | function triggerDeleteModuleFiles(&$obj) |
561 | 658 | { |
562 | 659 | $module_srl = $obj->module_srl; |
563 | - if(!$module_srl) return new Object(); |
|
660 | + if(!$module_srl) { |
|
661 | + return new Object(); |
|
662 | + } |
|
564 | 663 | |
565 | 664 | $oFileController = getAdminController('file'); |
566 | 665 | return $oFileController->deleteModuleFiles($module_srl); |
@@ -635,7 +734,9 @@ discard block |
||
635 | 734 | $trigger_obj->module_srl = $module_srl; |
636 | 735 | $trigger_obj->upload_target_srl = $upload_target_srl; |
637 | 736 | $output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj); |
638 | - if(!$output->toBool()) return $output; |
|
737 | + if(!$output->toBool()) { |
|
738 | + return $output; |
|
739 | + } |
|
639 | 740 | |
640 | 741 | // A workaround for Firefox upload bug |
641 | 742 | if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match)) |
@@ -673,13 +774,17 @@ discard block |
||
673 | 774 | $allowed_filesize = $config->allowed_filesize * 1024 * 1024; |
674 | 775 | $allowed_attach_size = $config->allowed_attach_size * 1024 * 1024; |
675 | 776 | // An error appears if file size exceeds a limit |
676 | - if($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-1, 'msg_exceeds_limit_size'); |
|
777 | + if($allowed_filesize < filesize($file_info['tmp_name'])) { |
|
778 | + return new Object(-1, 'msg_exceeds_limit_size'); |
|
779 | + } |
|
677 | 780 | // Get total file size of all attachements (from DB) |
678 | 781 | $size_args = new stdClass; |
679 | 782 | $size_args->upload_target_srl = $upload_target_srl; |
680 | 783 | $output = executeQuery('file.getAttachedFileSize', $size_args); |
681 | 784 | $attached_size = (int)$output->data->attached_size + filesize($file_info['tmp_name']); |
682 | - if($attached_size > $allowed_attach_size) return new Object(-1, 'msg_exceeds_limit_size'); |
|
785 | + if($attached_size > $allowed_attach_size) { |
|
786 | + return new Object(-1, 'msg_exceeds_limit_size'); |
|
787 | + } |
|
683 | 788 | } |
684 | 789 | } |
685 | 790 | |
@@ -709,18 +814,21 @@ discard block |
||
709 | 814 | $idx++; |
710 | 815 | } |
711 | 816 | $direct_download = 'Y'; |
712 | - } |
|
713 | - else |
|
817 | + } else |
|
714 | 818 | { |
715 | 819 | $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3)); |
716 | 820 | $filename = $path.$random->createSecureSalt(32, 'hex'); |
717 | 821 | $direct_download = 'N'; |
718 | 822 | } |
719 | 823 | // Create a directory |
720 | - if(!FileHandler::makeDir($path)) return new Object(-1,'msg_not_permitted_create'); |
|
824 | + if(!FileHandler::makeDir($path)) { |
|
825 | + return new Object(-1,'msg_not_permitted_create'); |
|
826 | + } |
|
721 | 827 | |
722 | 828 | // Check uploaded file |
723 | - if(!checkUploadedFile($file_info['tmp_name'])) return new Object(-1,'msg_file_upload_error'); |
|
829 | + if(!checkUploadedFile($file_info['tmp_name'])) { |
|
830 | + return new Object(-1,'msg_file_upload_error'); |
|
831 | + } |
|
724 | 832 | |
725 | 833 | // Get random number generator |
726 | 834 | $random = new Password(); |
@@ -734,13 +842,14 @@ discard block |
||
734 | 842 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
735 | 843 | @copy($file_info['tmp_name'], $filename); |
736 | 844 | } |
737 | - } |
|
738 | - else |
|
845 | + } else |
|
739 | 846 | { |
740 | 847 | if(!@move_uploaded_file($file_info['tmp_name'], $filename)) |
741 | 848 | { |
742 | 849 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
743 | - if(!@move_uploaded_file($file_info['tmp_name'], $filename)) return new Object(-1,'msg_file_upload_error'); |
|
850 | + if(!@move_uploaded_file($file_info['tmp_name'], $filename)) { |
|
851 | + return new Object(-1,'msg_file_upload_error'); |
|
852 | + } |
|
744 | 853 | } |
745 | 854 | } |
746 | 855 | // Get member information |
@@ -761,10 +870,14 @@ discard block |
||
761 | 870 | $args->sid = $random->createSecureSalt(32, 'hex'); |
762 | 871 | |
763 | 872 | $output = executeQuery('file.insertFile', $args); |
764 | - if(!$output->toBool()) return $output; |
|
873 | + if(!$output->toBool()) { |
|
874 | + return $output; |
|
875 | + } |
|
765 | 876 | // Call a trigger (after) |
766 | 877 | $trigger_output = ModuleHandler::triggerCall('file.insertFile', 'after', $args); |
767 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
878 | + if(!$trigger_output->toBool()) { |
|
879 | + return $trigger_output; |
|
880 | + } |
|
768 | 881 | |
769 | 882 | $_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true; |
770 | 883 | |
@@ -807,10 +920,14 @@ discard block |
||
807 | 920 | */ |
808 | 921 | function deleteFile($file_srl) |
809 | 922 | { |
810 | - if(!$file_srl) return; |
|
923 | + if(!$file_srl) { |
|
924 | + return; |
|
925 | + } |
|
811 | 926 | |
812 | 927 | $srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl); |
813 | - if(!count($srls)) return; |
|
928 | + if(!count($srls)) { |
|
929 | + return; |
|
930 | + } |
|
814 | 931 | |
815 | 932 | $oDocumentController = getController('document'); |
816 | 933 | $documentSrlList = array(); |
@@ -845,15 +962,21 @@ discard block |
||
845 | 962 | // Call a trigger (before) |
846 | 963 | $trigger_obj = $output->data; |
847 | 964 | $output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj); |
848 | - if(!$output->toBool()) return $output; |
|
965 | + if(!$output->toBool()) { |
|
966 | + return $output; |
|
967 | + } |
|
849 | 968 | |
850 | 969 | // Remove from the DB |
851 | 970 | $output = executeQuery('file.deleteFile', $args); |
852 | - if(!$output->toBool()) return $output; |
|
971 | + if(!$output->toBool()) { |
|
972 | + return $output; |
|
973 | + } |
|
853 | 974 | |
854 | 975 | // Call a trigger (after) |
855 | 976 | $trigger_output = ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj); |
856 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
977 | + if(!$trigger_output->toBool()) { |
|
978 | + return $trigger_output; |
|
979 | + } |
|
857 | 980 | |
858 | 981 | // If successfully deleted, remove the file |
859 | 982 | FileHandler::removeFile($uploaded_filename); |
@@ -877,7 +1000,9 @@ discard block |
||
877 | 1000 | $columnList = array('file_srl', 'uploaded_filename', 'module_srl'); |
878 | 1001 | $file_list = $oFileModel->getFiles($upload_target_srl, $columnList); |
879 | 1002 | // Success returned if no attachement exists |
880 | - if(!is_array($file_list)||!count($file_list)) return new Object(); |
|
1003 | + if(!is_array($file_list)||!count($file_list)) { |
|
1004 | + return new Object(); |
|
1005 | + } |
|
881 | 1006 | |
882 | 1007 | // Delete the file |
883 | 1008 | $path = array(); |
@@ -888,14 +1013,18 @@ discard block |
||
888 | 1013 | |
889 | 1014 | $uploaded_filename = $file_list[$i]->uploaded_filename; |
890 | 1015 | $path_info = pathinfo($uploaded_filename); |
891 | - if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
1016 | + if(!in_array($path_info['dirname'], $path)) { |
|
1017 | + $path[] = $path_info['dirname']; |
|
1018 | + } |
|
892 | 1019 | } |
893 | 1020 | |
894 | 1021 | // Remove from the DB |
895 | 1022 | $args = new stdClass(); |
896 | 1023 | $args->upload_target_srl = $upload_target_srl; |
897 | 1024 | $output = executeQuery('file.deleteFiles', $args); |
898 | - if(!$output->toBool()) return $output; |
|
1025 | + if(!$output->toBool()) { |
|
1026 | + return $output; |
|
1027 | + } |
|
899 | 1028 | |
900 | 1029 | // Remove a file directory of the document |
901 | 1030 | for($i=0, $c=count($path); $i<$c; $i++) |
@@ -916,11 +1045,15 @@ discard block |
||
916 | 1045 | */ |
917 | 1046 | function moveFile($source_srl, $target_module_srl, $target_srl) |
918 | 1047 | { |
919 | - if($source_srl == $target_srl) return; |
|
1048 | + if($source_srl == $target_srl) { |
|
1049 | + return; |
|
1050 | + } |
|
920 | 1051 | |
921 | 1052 | $oFileModel = getModel('file'); |
922 | 1053 | $file_list = $oFileModel->getFiles($source_srl); |
923 | - if(!$file_list) return; |
|
1054 | + if(!$file_list) { |
|
1055 | + return; |
|
1056 | + } |
|
924 | 1057 | |
925 | 1058 | $file_count = count($file_list); |
926 | 1059 | |
@@ -934,15 +1067,16 @@ discard block |
||
934 | 1067 | { |
935 | 1068 | $path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl); |
936 | 1069 | $new_file = $path.$file_info->source_filename; |
937 | - } |
|
938 | - else |
|
1070 | + } else |
|
939 | 1071 | { |
940 | 1072 | $path = sprintf("./files/attach/binaries/%s/%s/", $target_module_srl, $target_srl); |
941 | 1073 | $random = new Password(); |
942 | 1074 | $new_file = $path.$random->createSecureSalt(32, 'hex'); |
943 | 1075 | } |
944 | 1076 | // Pass if a target document to move is same |
945 | - if($old_file == $new_file) continue; |
|
1077 | + if($old_file == $new_file) { |
|
1078 | + continue; |
|
1079 | + } |
|
946 | 1080 | // Create a directory |
947 | 1081 | FileHandler::makeDir($path); |
948 | 1082 | // Move the file |
@@ -962,16 +1096,22 @@ discard block |
||
962 | 1096 | $vars = Context::getRequestVars(); |
963 | 1097 | $logged_info = Context::get('logged_info'); |
964 | 1098 | |
965 | - if(!$vars->editor_sequence) return new Object(-1, 'msg_invalid_request'); |
|
1099 | + if(!$vars->editor_sequence) { |
|
1100 | + return new Object(-1, 'msg_invalid_request'); |
|
1101 | + } |
|
966 | 1102 | |
967 | 1103 | $upload_target_srl = $_SESSION['upload_info'][$vars->editor_sequence]->upload_target_srl; |
968 | 1104 | |
969 | 1105 | $oFileModel = getModel('file'); |
970 | 1106 | $file_info = $oFileModel->getFile($vars->file_srl); |
971 | 1107 | |
972 | - if(!$file_info) return new Object(-1, 'msg_not_founded'); |
|
1108 | + if(!$file_info) { |
|
1109 | + return new Object(-1, 'msg_not_founded'); |
|
1110 | + } |
|
973 | 1111 | |
974 | - if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted'); |
|
1112 | + if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) { |
|
1113 | + return new Object(-1, 'msg_not_permitted'); |
|
1114 | + } |
|
975 | 1115 | |
976 | 1116 | $args = new stdClass(); |
977 | 1117 | $args->file_srl = $vars->file_srl; |