@@ -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,14 +238,14 @@ 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 | 247 | $grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($oDocument->get('module_srl')), $logged_info); |
248 | - if(!$grant->access) |
|
248 | + if (!$grant->access) |
|
249 | 249 | { |
250 | 250 | return $this->stop('msg_not_permitted'); |
251 | 251 | } |
@@ -253,16 +253,16 @@ discard block |
||
253 | 253 | $args = new stdClass(); |
254 | 254 | $args->upload_target_srl = $upload_target_srl; |
255 | 255 | $args->sort_index = $sortIndex; |
256 | - if($ckValid) $args->isvalid = 'Y'; |
|
256 | + if ($ckValid) $args->isvalid = 'Y'; |
|
257 | 257 | $output = executeQuery('file.getFiles', $args, $columnList); |
258 | - if(!$output->data) return; |
|
258 | + if (!$output->data) return; |
|
259 | 259 | |
260 | 260 | $file_list = $output->data; |
261 | 261 | |
262 | - if($file_list && !is_array($file_list)) $file_list = array($file_list); |
|
262 | + if ($file_list && !is_array($file_list)) $file_list = array($file_list); |
|
263 | 263 | |
264 | 264 | $file_count = count($file_list); |
265 | - for($i=0;$i<$file_count;$i++) |
|
265 | + for ($i = 0; $i < $file_count; $i++) |
|
266 | 266 | { |
267 | 267 | $file = $file_list[$i]; |
268 | 268 | $file->source_filename = stripslashes($file->source_filename); |
@@ -285,14 +285,14 @@ discard block |
||
285 | 285 | |
286 | 286 | $module_srl = Context::get('module_srl'); |
287 | 287 | // Get the current module if module_srl doesn't exist |
288 | - if(!$module_srl) |
|
288 | + if (!$module_srl) |
|
289 | 289 | { |
290 | 290 | $current_module_info = Context::get('current_module_info'); |
291 | 291 | $module_srl = $current_module_info->module_srl; |
292 | 292 | } |
293 | 293 | $file_config = $this->getFileConfig($module_srl); |
294 | 294 | |
295 | - if($logged_info->is_admin == 'Y') |
|
295 | + if ($logged_info->is_admin == 'Y') |
|
296 | 296 | { |
297 | 297 | $iniPostMaxSize = FileHandler::returnbytes(ini_get('post_max_size')); |
298 | 298 | $iniUploadMaxSize = FileHandler::returnbytes(ini_get('upload_max_filesize')); |
@@ -318,9 +318,9 @@ discard block |
||
318 | 318 | '%s : %s/ %s<br /> %s : %s (%s : %s)', |
319 | 319 | Context::getLang('allowed_attach_size'), |
320 | 320 | FileHandler::filesize($attached_size), |
321 | - FileHandler::filesize($file_config->allowed_attach_size*1024*1024), |
|
321 | + FileHandler::filesize($file_config->allowed_attach_size * 1024 * 1024), |
|
322 | 322 | Context::getLang('allowed_filesize'), |
323 | - FileHandler::filesize($file_config->allowed_filesize*1024*1024), |
|
323 | + FileHandler::filesize($file_config->allowed_filesize * 1024 * 1024), |
|
324 | 324 | Context::getLang('allowed_filetypes'), |
325 | 325 | $file_config->allowed_filetypes |
326 | 326 | ); |
@@ -347,9 +347,9 @@ discard block |
||
347 | 347 | */ |
348 | 348 | function getFileGrant($file_info, $member_info) |
349 | 349 | { |
350 | - if(!$file_info) return null; |
|
350 | + if (!$file_info) return null; |
|
351 | 351 | |
352 | - if($_SESSION['__XE_UPLOADING_FILES_INFO__'][$file_info->file_srl]) |
|
352 | + if ($_SESSION['__XE_UPLOADING_FILES_INFO__'][$file_info->file_srl]) |
|
353 | 353 | { |
354 | 354 | $file_grant->is_deletable = true; |
355 | 355 | return $file_grant; |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | |
361 | 361 | $oDocumentModel = getModel('document'); |
362 | 362 | $oDocument = $oDocumentModel->getDocument($file_info->upload_target_srl); |
363 | - if($oDocument->isExists()) $document_grant = $oDocument->isGranted(); |
|
363 | + if ($oDocument->isExists()) $document_grant = $oDocument->isGranted(); |
|
364 | 364 | |
365 | 365 | $file_grant->is_deletable = ($document_grant || $member_info->is_admin == 'Y' || $member_info->member_srl == $file_info->member_srl || $grant->manager); |
366 | 366 |