@@ -29,23 +29,23 @@ discard block |
||
29 | 29 | $mid = Context::get('mid'); |
30 | 30 | $editor_sequence = Context::get('editor_sequence'); |
31 | 31 | $upload_target_srl = Context::get('upload_target_srl'); |
32 | - if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
32 | + if (!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
33 | 33 | |
34 | - if($upload_target_srl) |
|
34 | + if ($upload_target_srl) |
|
35 | 35 | { |
36 | 36 | $tmp_files = $this->getFiles($upload_target_srl); |
37 | - if($tmp_files instanceof Object && !$tmp_files->toBool()) return $tmp_files; |
|
37 | + if ($tmp_files instanceof Object && !$tmp_files->toBool()) return $tmp_files; |
|
38 | 38 | |
39 | - foreach($tmp_files as $file_info) |
|
39 | + foreach ($tmp_files as $file_info) |
|
40 | 40 | { |
41 | - if(!$file_info->file_srl) continue; |
|
41 | + if (!$file_info->file_srl) continue; |
|
42 | 42 | |
43 | 43 | $obj = new stdClass; |
44 | 44 | $obj->file_srl = $file_info->file_srl; |
45 | 45 | $obj->source_filename = $file_info->source_filename; |
46 | 46 | $obj->file_size = $file_info->file_size; |
47 | 47 | $obj->disp_file_size = FileHandler::filesize($file_info->file_size); |
48 | - if($file_info->direct_download=='N') $obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid, $file_info->module_srl); |
|
48 | + if ($file_info->direct_download == 'N') $obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid, $file_info->module_srl); |
|
49 | 49 | else $obj->download_url = str_replace('./', '', $file_info->uploaded_filename); |
50 | 50 | $obj->direct_download = $file_info->direct_download; |
51 | 51 | $obj->cover_image = ($file_info->cover_image === 'Y') ? true : false; |
@@ -65,17 +65,17 @@ discard block |
||
65 | 65 | //$config = $oModuleModel->getModuleInfoByMid($mid); //perhaps config varialbles not used |
66 | 66 | |
67 | 67 | $file_config = $this->getUploadConfig(); |
68 | - $left_size = $file_config->allowed_attach_size*1024*1024 - $attached_size; |
|
68 | + $left_size = $file_config->allowed_attach_size * 1024 * 1024 - $attached_size; |
|
69 | 69 | // Settings of required information |
70 | 70 | $attached_size = FileHandler::filesize($attached_size); |
71 | - $allowed_attach_size = FileHandler::filesize($file_config->allowed_attach_size*1024*1024); |
|
72 | - $allowed_filesize = FileHandler::filesize($file_config->allowed_filesize*1024*1024); |
|
71 | + $allowed_attach_size = FileHandler::filesize($file_config->allowed_attach_size * 1024 * 1024); |
|
72 | + $allowed_filesize = FileHandler::filesize($file_config->allowed_filesize * 1024 * 1024); |
|
73 | 73 | $allowed_filetypes = $file_config->allowed_filetypes; |
74 | - $this->add("files",$files); |
|
75 | - $this->add("editor_sequence",$editor_sequence); |
|
76 | - $this->add("upload_target_srl",$upload_target_srl); |
|
77 | - $this->add("upload_status",$upload_status); |
|
78 | - $this->add("left_size",$left_size); |
|
74 | + $this->add("files", $files); |
|
75 | + $this->add("editor_sequence", $editor_sequence); |
|
76 | + $this->add("upload_target_srl", $upload_target_srl); |
|
77 | + $this->add("upload_status", $upload_status); |
|
78 | + $this->add("left_size", $left_size); |
|
79 | 79 | $this->add('attached_size', $attached_size); |
80 | 80 | $this->add('allowed_attach_size', $allowed_attach_size); |
81 | 81 | $this->add('allowed_filesize', $allowed_filesize); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $args = new stdClass(); |
94 | 94 | $args->upload_target_srl = $upload_target_srl; |
95 | 95 | $output = executeQuery('file.getFilesCount', $args); |
96 | - return (int)$output->data->count; |
|
96 | + return (int) $output->data->count; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @param string $sid |
104 | 104 | * @return string Returns a url |
105 | 105 | */ |
106 | - function getDownloadUrl($file_srl, $sid, $module_srl="") |
|
106 | + function getDownloadUrl($file_srl, $sid, $module_srl = "") |
|
107 | 107 | { |
108 | 108 | return sprintf('?module=%s&act=%s&file_srl=%s&sid=%s&module_srl=%s', 'file', 'procFileDownload', $file_srl, $sid, $module_srl); |
109 | 109 | } |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | |
122 | 122 | $file_module_config = $oModuleModel->getModuleConfig('file'); |
123 | 123 | |
124 | - if($module_srl) $file_config = $oModuleModel->getModulePartConfig('file',$module_srl); |
|
125 | - if(!$file_config) $file_config = $file_module_config; |
|
124 | + if ($module_srl) $file_config = $oModuleModel->getModulePartConfig('file', $module_srl); |
|
125 | + if (!$file_config) $file_config = $file_module_config; |
|
126 | 126 | |
127 | 127 | $config = new stdClass(); |
128 | 128 | |
129 | - if($file_config) |
|
129 | + if ($file_config) |
|
130 | 130 | { |
131 | 131 | $config->allowed_filesize = $file_config->allowed_filesize; |
132 | 132 | $config->allowed_attach_size = $file_config->allowed_attach_size; |
@@ -137,31 +137,31 @@ discard block |
||
137 | 137 | $config->allow_outlink_format = $file_config->allow_outlink_format; |
138 | 138 | } |
139 | 139 | // Property for all files comes first than each property |
140 | - if(!$config->allowed_filesize) $config->allowed_filesize = $file_module_config->allowed_filesize; |
|
141 | - if(!$config->allowed_attach_size) $config->allowed_attach_size = $file_module_config->allowed_attach_size; |
|
142 | - if(!$config->allowed_filetypes) $config->allowed_filetypes = $file_module_config->allowed_filetypes; |
|
143 | - if(!$config->allow_outlink) $config->allow_outlink = $file_module_config->allow_outlink; |
|
144 | - if(!$config->allow_outlink_site) $config->allow_outlink_site = $file_module_config->allow_outlink_site; |
|
145 | - if(!$config->allow_outlink_format) $config->allow_outlink_format = $file_module_config->allow_outlink_format; |
|
146 | - if(!$config->download_grant) $config->download_grant = $file_module_config->download_grant; |
|
140 | + if (!$config->allowed_filesize) $config->allowed_filesize = $file_module_config->allowed_filesize; |
|
141 | + if (!$config->allowed_attach_size) $config->allowed_attach_size = $file_module_config->allowed_attach_size; |
|
142 | + if (!$config->allowed_filetypes) $config->allowed_filetypes = $file_module_config->allowed_filetypes; |
|
143 | + if (!$config->allow_outlink) $config->allow_outlink = $file_module_config->allow_outlink; |
|
144 | + if (!$config->allow_outlink_site) $config->allow_outlink_site = $file_module_config->allow_outlink_site; |
|
145 | + if (!$config->allow_outlink_format) $config->allow_outlink_format = $file_module_config->allow_outlink_format; |
|
146 | + if (!$config->download_grant) $config->download_grant = $file_module_config->download_grant; |
|
147 | 147 | // Default setting if not exists |
148 | - if(!$config->allowed_filesize) $config->allowed_filesize = '2'; |
|
149 | - if(!$config->allowed_attach_size) $config->allowed_attach_size = '3'; |
|
150 | - if(!$config->allowed_filetypes) $config->allowed_filetypes = '*.*'; |
|
151 | - if(!$config->allow_outlink) $config->allow_outlink = 'Y'; |
|
152 | - if(!$config->download_grant) $config->download_grant = array(); |
|
148 | + if (!$config->allowed_filesize) $config->allowed_filesize = '2'; |
|
149 | + if (!$config->allowed_attach_size) $config->allowed_attach_size = '3'; |
|
150 | + if (!$config->allowed_filetypes) $config->allowed_filetypes = '*.*'; |
|
151 | + if (!$config->allow_outlink) $config->allow_outlink = 'Y'; |
|
152 | + if (!$config->download_grant) $config->download_grant = array(); |
|
153 | 153 | |
154 | 154 | $size = ini_get('upload_max_filesize'); |
155 | 155 | $unit = strtolower($size[strlen($size) - 1]); |
156 | - $size = (float)$size; |
|
157 | - if($unit == 'g') $size *= 1024; |
|
158 | - if($unit == 'k') $size /= 1024; |
|
156 | + $size = (float) $size; |
|
157 | + if ($unit == 'g') $size *= 1024; |
|
158 | + if ($unit == 'k') $size /= 1024; |
|
159 | 159 | |
160 | - if($config->allowed_filesize > $size) |
|
160 | + if ($config->allowed_filesize > $size) |
|
161 | 161 | { |
162 | 162 | $config->allowed_filesize = $size; |
163 | 163 | } |
164 | - if($config->allowed_attach_size > $size) |
|
164 | + if ($config->allowed_attach_size > $size) |
|
165 | 165 | { |
166 | 166 | $config->allowed_attach_size = $size; |
167 | 167 | } |
@@ -181,10 +181,10 @@ discard block |
||
181 | 181 | $args = new stdClass(); |
182 | 182 | $args->file_srl = $file_srl; |
183 | 183 | $output = executeQueryArray('file.getFile', $args, $columnList); |
184 | - if(!$output->toBool()) return $output; |
|
184 | + if (!$output->toBool()) return $output; |
|
185 | 185 | |
186 | 186 | // old version compatibility |
187 | - if(count($output->data) == 1) |
|
187 | + if (count($output->data) == 1) |
|
188 | 188 | { |
189 | 189 | $file = $output->data[0]; |
190 | 190 | $file->download_url = $this->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl); |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | { |
196 | 196 | $fileList = array(); |
197 | 197 | |
198 | - if(is_array($output->data)) |
|
198 | + if (is_array($output->data)) |
|
199 | 199 | { |
200 | - foreach($output->data as $key=>$value) |
|
200 | + foreach ($output->data as $key=>$value) |
|
201 | 201 | { |
202 | 202 | $file = $value; |
203 | 203 | $file->download_url = $this->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl); |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | $oDocument = $oDocumentModel->getDocument($upload_target_srl); |
227 | 227 | |
228 | 228 | // comment 권한 확인 |
229 | - if(!$oDocument->isExists()) |
|
229 | + if (!$oDocument->isExists()) |
|
230 | 230 | { |
231 | 231 | $oComment = $oCommentModel->getComment($upload_target_srl); |
232 | - if($oComment->isExists() && $oComment->isSecret() && !$oComment->isGranted()) |
|
232 | + if ($oComment->isExists() && $oComment->isSecret() && !$oComment->isGranted()) |
|
233 | 233 | { |
234 | 234 | return $this->stop('msg_not_permitted'); |
235 | 235 | } |
@@ -238,16 +238,16 @@ discard block |
||
238 | 238 | } |
239 | 239 | |
240 | 240 | // document 권한 확인 |
241 | - if($oDocument->isExists() && $oDocument->isSecret() && !$oDocument->isGranted()) |
|
241 | + if ($oDocument->isExists() && $oDocument->isSecret() && !$oDocument->isGranted()) |
|
242 | 242 | { |
243 | 243 | return $this->stop('msg_not_permitted'); |
244 | 244 | } |
245 | 245 | |
246 | 246 | // 모듈 권한 확인 |
247 | - if($oDocument->isExists()) |
|
247 | + if ($oDocument->isExists()) |
|
248 | 248 | { |
249 | 249 | $grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($oDocument->get('module_srl')), $logged_info); |
250 | - if(!$grant->access) |
|
250 | + if (!$grant->access) |
|
251 | 251 | { |
252 | 252 | return $this->stop('msg_not_permitted'); |
253 | 253 | } |
@@ -256,16 +256,16 @@ discard block |
||
256 | 256 | $args = new stdClass(); |
257 | 257 | $args->upload_target_srl = $upload_target_srl; |
258 | 258 | $args->sort_index = $sortIndex; |
259 | - if($ckValid) $args->isvalid = 'Y'; |
|
259 | + if ($ckValid) $args->isvalid = 'Y'; |
|
260 | 260 | $output = executeQuery('file.getFiles', $args, $columnList); |
261 | - if(!$output->data) return; |
|
261 | + if (!$output->data) return; |
|
262 | 262 | |
263 | 263 | $file_list = $output->data; |
264 | 264 | |
265 | - if($file_list && !is_array($file_list)) $file_list = array($file_list); |
|
265 | + if ($file_list && !is_array($file_list)) $file_list = array($file_list); |
|
266 | 266 | |
267 | 267 | $file_count = count($file_list); |
268 | - for($i=0;$i<$file_count;$i++) |
|
268 | + for ($i = 0; $i < $file_count; $i++) |
|
269 | 269 | { |
270 | 270 | $file = $file_list[$i]; |
271 | 271 | $file->source_filename = stripslashes($file->source_filename); |
@@ -288,14 +288,14 @@ discard block |
||
288 | 288 | |
289 | 289 | $module_srl = Context::get('module_srl'); |
290 | 290 | // Get the current module if module_srl doesn't exist |
291 | - if(!$module_srl) |
|
291 | + if (!$module_srl) |
|
292 | 292 | { |
293 | 293 | $current_module_info = Context::get('current_module_info'); |
294 | 294 | $module_srl = $current_module_info->module_srl; |
295 | 295 | } |
296 | 296 | $file_config = $this->getFileConfig($module_srl); |
297 | 297 | |
298 | - if($logged_info->is_admin == 'Y') |
|
298 | + if ($logged_info->is_admin == 'Y') |
|
299 | 299 | { |
300 | 300 | $iniPostMaxSize = FileHandler::returnbytes(ini_get('post_max_size')); |
301 | 301 | $iniUploadMaxSize = FileHandler::returnbytes(ini_get('upload_max_filesize')); |
@@ -321,9 +321,9 @@ discard block |
||
321 | 321 | '%s : %s/ %s<br /> %s : %s (%s : %s)', |
322 | 322 | Context::getLang('allowed_attach_size'), |
323 | 323 | FileHandler::filesize($attached_size), |
324 | - FileHandler::filesize($file_config->allowed_attach_size*1024*1024), |
|
324 | + FileHandler::filesize($file_config->allowed_attach_size * 1024 * 1024), |
|
325 | 325 | Context::getLang('allowed_filesize'), |
326 | - FileHandler::filesize($file_config->allowed_filesize*1024*1024), |
|
326 | + FileHandler::filesize($file_config->allowed_filesize * 1024 * 1024), |
|
327 | 327 | Context::getLang('allowed_filetypes'), |
328 | 328 | $file_config->allowed_filetypes |
329 | 329 | ); |
@@ -350,9 +350,9 @@ discard block |
||
350 | 350 | */ |
351 | 351 | function getFileGrant($file_info, $member_info) |
352 | 352 | { |
353 | - if(!$file_info) return null; |
|
353 | + if (!$file_info) return null; |
|
354 | 354 | |
355 | - if($_SESSION['__XE_UPLOADING_FILES_INFO__'][$file_info->file_srl]) |
|
355 | + if ($_SESSION['__XE_UPLOADING_FILES_INFO__'][$file_info->file_srl]) |
|
356 | 356 | { |
357 | 357 | $file_grant->is_deletable = true; |
358 | 358 | return $file_grant; |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | |
364 | 364 | $oDocumentModel = getModel('document'); |
365 | 365 | $oDocument = $oDocumentModel->getDocument($file_info->upload_target_srl); |
366 | - if($oDocument->isExists()) $document_grant = $oDocument->isGranted(); |
|
366 | + if ($oDocument->isExists()) $document_grant = $oDocument->isGranted(); |
|
367 | 367 | |
368 | 368 | $file_grant->is_deletable = ($document_grant || $member_info->is_admin == 'Y' || $member_info->member_srl == $file_info->member_srl || $grant->manager); |
369 | 369 |