GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( 5044c3...4bdfc8 )
by gyeong-won
06:14
created
modules/document/document.admin.controller.php 1 patch
Spacing   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -27,21 +27,21 @@  discard block
 block discarded – undo
27 27
 	{
28 28
 		// error appears if no doc is selected
29 29
 		$cart = Context::get('cart');
30
-		if(!$cart) return $this->stop('msg_cart_is_null');
31
-		$document_srl_list= explode('|@|', $cart);
30
+		if (!$cart) return $this->stop('msg_cart_is_null');
31
+		$document_srl_list = explode('|@|', $cart);
32 32
 		$document_count = count($document_srl_list);
33
-		if(!$document_count) return $this->stop('msg_cart_is_null');
33
+		if (!$document_count) return $this->stop('msg_cart_is_null');
34 34
 		// Delete a doc
35 35
 		$oDocumentController = getController('document');
36
-		for($i=0;$i<$document_count;$i++)
36
+		for ($i = 0; $i < $document_count; $i++)
37 37
 		{
38 38
 			$document_srl = trim($document_srl_list[$i]);
39
-			if(!$document_srl) continue;
39
+			if (!$document_srl) continue;
40 40
 
41 41
 			$oDocumentController->deleteDocument($document_srl, true);
42 42
 		}
43 43
 
44
-		$this->setMessage(sprintf(Context::getLang('msg_checked_document_is_deleted'), $document_count) );
44
+		$this->setMessage(sprintf(Context::getLang('msg_checked_document_is_deleted'), $document_count));
45 45
 	}
46 46
 
47 47
 	/**
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	function moveDocumentModule($document_srl_list, $module_srl, $category_srl)
55 55
 	{
56
-		if(!count($document_srl_list)) return;
56
+		if (!count($document_srl_list)) return;
57 57
 
58 58
 		$oDocumentModel = getModel('document');
59 59
 		$oDocumentController = getController('document');
@@ -62,24 +62,24 @@  discard block
 block discarded – undo
62 62
 		$oDB->begin();
63 63
 
64 64
 		$triggerObj = new stdClass();
65
-		$triggerObj->document_srls = implode(',',$document_srl_list);
65
+		$triggerObj->document_srls = implode(',', $document_srl_list);
66 66
 		$triggerObj->module_srl = $module_srl;
67 67
 		$triggerObj->source_module_srl = array();
68 68
 		$triggerObj->category_srl = $category_srl;
69 69
 
70 70
 		// Call a trigger (before)
71 71
 		$output = ModuleHandler::triggerCall('document.moveDocumentModule', 'before', $triggerObj);
72
-		if(!$output->toBool())
72
+		if (!$output->toBool())
73 73
 		{
74 74
 			$oDB->rollback();
75 75
 			return $output;
76 76
 		}
77 77
 
78
-		for($i=count($document_srl_list)-1;$i>=0;$i--)
78
+		for ($i = count($document_srl_list) - 1; $i >= 0; $i--)
79 79
 		{
80 80
 			$document_srl = $document_srl_list[$i];
81 81
 			$oDocument = $oDocumentModel->getDocument($document_srl);
82
-			if(!$oDocument->isExists()) continue;
82
+			if (!$oDocument->isExists()) continue;
83 83
 
84 84
 			$triggerObj->source_module_srl[$document_srl] = $oDocument->get('module_srl');
85 85
 
@@ -94,33 +94,33 @@  discard block
 block discarded – undo
94 94
 			$obj->content = $output_ori->data->content;
95 95
 
96 96
 			// Move the attached file if the target module is different
97
-			if($module_srl != $obj->module_srl && $oDocument->hasUploadedFiles())
97
+			if ($module_srl != $obj->module_srl && $oDocument->hasUploadedFiles())
98 98
 			{
99 99
 				$oFileController = getController('file');
100 100
 
101 101
 				$files = $oDocument->getUploadedFiles();
102 102
 				$delete_file_srls = array();
103
-				if(is_array($files))
103
+				if (is_array($files))
104 104
 				{
105
-					foreach($files as $val)
105
+					foreach ($files as $val)
106 106
 					{
107 107
 						$file_info = array();
108 108
 						$file_info['tmp_name'] = $val->uploaded_filename;
109 109
 						$file_info['name'] = $val->source_filename;
110 110
 						$inserted_file = $oFileController->insertFile($file_info, $module_srl, $obj->document_srl, $val->download_count, true);
111 111
 
112
-						if(!$inserted_file->toBool()) {
112
+						if (!$inserted_file->toBool()) {
113 113
 							$oDB->rollback();
114 114
 							return $inserted_file;
115 115
 						}
116 116
 
117
-						if($inserted_file && $inserted_file->toBool())
117
+						if ($inserted_file && $inserted_file->toBool())
118 118
 						{
119 119
 							// for image/video files
120
-							if($val->direct_download == 'Y')
120
+							if ($val->direct_download == 'Y')
121 121
 							{
122
-								$source_filename = substr($val->uploaded_filename,2);
123
-								$target_filename = substr($inserted_file->get('uploaded_filename'),2);
122
+								$source_filename = substr($val->uploaded_filename, 2);
123
+								$target_filename = substr($inserted_file->get('uploaded_filename'), 2);
124 124
 								$obj->content = str_replace($source_filename, $target_filename, $obj->content);
125 125
 								// For binary files
126 126
 							}
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 				$oFileController->setFilesValid($obj->document_srl);
140 140
 			}
141 141
 
142
-			if($module_srl != $obj->module_srl)
142
+			if ($module_srl != $obj->module_srl)
143 143
 			{
144 144
 				$oDocumentController->deleteDocumentAliasByDocument($obj->document_srl);
145 145
 			}
@@ -147,48 +147,48 @@  discard block
 block discarded – undo
147 147
 			$obj->module_srl = $module_srl;
148 148
 			$obj->category_srl = $category_srl;
149 149
 			$output = executeQuery('document.updateDocumentModule', $obj);
150
-			if(!$output->toBool()) {
150
+			if (!$output->toBool()) {
151 151
 				$oDB->rollback();
152 152
 				return $output;
153 153
 			}
154 154
 
155 155
 			//Move a module of the extra vars
156 156
 			$output = executeQuery('document.moveDocumentExtraVars', $obj);
157
-			if(!$output->toBool()) {
157
+			if (!$output->toBool()) {
158 158
 				$oDB->rollback();
159 159
 				return $output;
160 160
 			}
161 161
 			// Set 0 if a new category doesn't exist after catergory change
162
-			if($source_category_srl != $category_srl)
162
+			if ($source_category_srl != $category_srl)
163 163
 			{
164
-				if($source_category_srl) $oDocumentController->updateCategoryCount($oDocument->get('module_srl'), $source_category_srl);
165
-				if($category_srl) $oDocumentController->updateCategoryCount($module_srl, $category_srl);
164
+				if ($source_category_srl) $oDocumentController->updateCategoryCount($oDocument->get('module_srl'), $source_category_srl);
165
+				if ($category_srl) $oDocumentController->updateCategoryCount($module_srl, $category_srl);
166 166
 			}
167 167
 		}
168 168
 
169 169
 		$args = new stdClass();
170
-		$args->document_srls = implode(',',$document_srl_list);
170
+		$args->document_srls = implode(',', $document_srl_list);
171 171
 		$args->module_srl = $module_srl;
172 172
 		// move the comment
173 173
 		$output = executeQuery('comment.updateCommentModule', $args);
174
-		if(!$output->toBool())
174
+		if (!$output->toBool())
175 175
 		{
176 176
 			$oDB->rollback();
177 177
 			return $output;
178 178
 		}
179 179
 
180 180
 		$output = executeQuery('comment.updateCommentListModule', $args);
181
-		if(!$output->toBool())
181
+		if (!$output->toBool())
182 182
 		{
183 183
 			$oDB->rollback();
184 184
 			return $output;
185 185
 		}
186 186
 		
187 187
 		// move the trackback
188
-		if(getClass('trackback'))
188
+		if (getClass('trackback'))
189 189
 		{
190 190
 			$output = executeQuery('trackback.updateTrackbackModule', $args);
191
-			if(!$output->toBool())
191
+			if (!$output->toBool())
192 192
 			{
193 193
 				$oDB->rollback();
194 194
 				return $output;
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
 
198 198
 		// Tags
199 199
 		$output = executeQuery('tag.updateTagModule', $args);
200
-		if(!$output->toBool())
200
+		if (!$output->toBool())
201 201
 		{
202 202
 			$oDB->rollback();
203 203
 			return $output;
204 204
 		}
205 205
 		// Call a trigger (before)
206 206
 		$output = ModuleHandler::triggerCall('document.moveDocumentModule', 'after', $triggerObj);
207
-		if(!$output->toBool())
207
+		if (!$output->toBool())
208 208
 		{
209 209
 			$oDB->rollback();
210 210
 			return $output;
@@ -213,11 +213,11 @@  discard block
 block discarded – undo
213 213
 		$oDB->commit();
214 214
 		//remove from cache
215 215
 		$oCacheHandler = CacheHandler::getInstance('object');
216
-		if($oCacheHandler->isSupport())
216
+		if ($oCacheHandler->isSupport())
217 217
 		{
218
-			foreach($document_srl_list as $document_srl)
218
+			foreach ($document_srl_list as $document_srl)
219 219
 			{
220
-				$cache_key_item = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
220
+				$cache_key_item = 'document_item:'.getNumberingPath($document_srl).$document_srl;
221 221
 				$oCacheHandler->delete($cache_key_item);
222 222
 			}
223 223
 		}
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 */
234 234
 	function copyDocumentModule($document_srl_list, $module_srl, $category_srl)
235 235
 	{
236
-		if(count($document_srl_list) < 1) return;
236
+		if (count($document_srl_list) < 1) return;
237 237
 
238 238
 		$oDocumentModel = getModel('document');
239 239
 		$oDocumentController = getController('document');
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
 		$oDB->begin();
245 245
 
246 246
 		$triggerObj = new stdClass();
247
-		$triggerObj->document_srls = implode(',',$document_srl_list);
247
+		$triggerObj->document_srls = implode(',', $document_srl_list);
248 248
 		$triggerObj->module_srl = $module_srl;
249 249
 		$triggerObj->category_srl = $category_srl;
250 250
 		// Call a trigger (before)
251 251
 		$output = ModuleHandler::triggerCall('document.copyDocumentModule', 'before', $triggerObj);
252
-		if(!$output->toBool())
252
+		if (!$output->toBool())
253 253
 		{
254 254
 			$oDB->rollback();
255 255
 			return $output;
@@ -257,11 +257,11 @@  discard block
 block discarded – undo
257 257
 
258 258
 		$extraVarsList = $oDocumentModel->getDocumentExtraVarsFromDB($document_srl_list);
259 259
 		$extraVarsListByDocumentSrl = array();
260
-		if(is_array($extraVarsList->data))
260
+		if (is_array($extraVarsList->data))
261 261
 		{
262
-			foreach($extraVarsList->data as $value)
262
+			foreach ($extraVarsList->data as $value)
263 263
 			{
264
-				if(!isset($extraVarsListByDocumentSrl[$value->document_srl]))
264
+				if (!isset($extraVarsListByDocumentSrl[$value->document_srl]))
265 265
 				{
266 266
 					$extraVarsListByDocumentSrl[$value->document_srl] = array();
267 267
 				}
@@ -270,22 +270,22 @@  discard block
 block discarded – undo
270 270
 			}
271 271
 		}
272 272
 
273
-		for($i=count($document_srl_list)-1;$i>=0;$i--)
273
+		for ($i = count($document_srl_list) - 1; $i >= 0; $i--)
274 274
 		{
275 275
 			$document_srl = $document_srl_list[$i];
276 276
 			$oDocument = $oDocumentModel->getDocument($document_srl);
277
-			if(!$oDocument->isExists()) continue;
277
+			if (!$oDocument->isExists()) continue;
278 278
 
279 279
 			$obj = $oDocument->getObjectVars();
280 280
 
281 281
 			$extraVars = $extraVarsListByDocumentSrl[$document_srl];
282
-			if($module_srl == $obj->module_srl)
282
+			if ($module_srl == $obj->module_srl)
283 283
 			{
284
-				if(is_array($extraVars))
284
+				if (is_array($extraVars))
285 285
 				{
286
-					foreach($extraVars as $extraItem)
286
+					foreach ($extraVars as $extraItem)
287 287
 					{
288
-						if($extraItem->var_idx >= 0) $obj->{'extra_vars'.$extraItem->var_idx} = $extraItem->value;
288
+						if ($extraItem->var_idx >= 0) $obj->{'extra_vars'.$extraItem->var_idx} = $extraItem->value;
289 289
 					}
290 290
 				}
291 291
 			}
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
 			$obj->trackback_count = 0;
298 298
 
299 299
 			// Pre-register the attachment
300
-			if($oDocument->hasUploadedFiles())
300
+			if ($oDocument->hasUploadedFiles())
301 301
 			{
302 302
 				$files = $oDocument->getUploadedFiles();
303
-				foreach($files as $val)
303
+				foreach ($files as $val)
304 304
 				{
305 305
 					$file_info = array();
306 306
 					$file_info['tmp_name'] = $val->uploaded_filename;
@@ -308,16 +308,16 @@  discard block
 block discarded – undo
308 308
 					$oFileController = getController('file');
309 309
 					$inserted_file = $oFileController->insertFile($file_info, $module_srl, $obj->document_srl, 0, true);
310 310
 
311
-					if(!$inserted_file->toBool()) {
311
+					if (!$inserted_file->toBool()) {
312 312
 						$oDB->rollback();
313 313
 						return $inserted_file;
314 314
 					}
315 315
 
316 316
 					// if image/video files
317
-					if($val->direct_download == 'Y')
317
+					if ($val->direct_download == 'Y')
318 318
 					{
319
-						$source_filename = substr($val->uploaded_filename,2);
320
-						$target_filename = substr($inserted_file->get('uploaded_filename'),2);
319
+						$source_filename = substr($val->uploaded_filename, 2);
320
+						$target_filename = substr($inserted_file->get('uploaded_filename'), 2);
321 321
 						$obj->content = str_replace($source_filename, $target_filename, $obj->content);
322 322
 						// If binary file
323 323
 					}
@@ -331,23 +331,23 @@  discard block
 block discarded – undo
331 331
 
332 332
 			// Write a post
333 333
 			$output = $oDocumentController->insertDocument($obj, true, true);
334
-			if(!$output->toBool())
334
+			if (!$output->toBool())
335 335
 			{
336 336
 				$oDB->rollback();
337 337
 				return $output;
338 338
 			}
339 339
 
340 340
 			// copy multi language contents
341
-			if(is_array($extraVars))
341
+			if (is_array($extraVars))
342 342
 			{
343
-				foreach($extraVars as $value)
343
+				foreach ($extraVars as $value)
344 344
 				{
345
-					if($value->idx >= 0 && $value->lang_code == Context::getLangType())
345
+					if ($value->idx >= 0 && $value->lang_code == Context::getLangType())
346 346
 					{
347 347
 						continue;
348 348
 					}
349 349
 
350
-					if( $value->var_idx < 0 || ($module_srl == $value->module_srl && $value->var_idx >= 0) )
350
+					if ($value->var_idx < 0 || ($module_srl == $value->module_srl && $value->var_idx >= 0))
351 351
 					{
352 352
 						$oDocumentController->insertDocumentExtraVar($value->module_srl, $obj->document_srl, $value->var_idx, $value->value, $value->eid, $value->lang_code);
353 353
 					}
@@ -355,26 +355,26 @@  discard block
 block discarded – undo
355 355
 			}
356 356
 
357 357
 			// Move the comments
358
-			if($oDocument->getCommentCount())
358
+			if ($oDocument->getCommentCount())
359 359
 			{
360 360
 				$oCommentModel = getModel('comment');
361 361
 				$comment_output = $oCommentModel->getCommentList($document_srl, 0, true, 99999999);
362 362
 				$comments = $comment_output->data;
363
-				if(count($comments) > 0)
363
+				if (count($comments) > 0)
364 364
 				{
365 365
 					$oCommentController = getController('comment');
366 366
 					$success_count = 0;
367 367
 					$p_comment_srl = array();
368
-					foreach($comments as $comment_obj)
368
+					foreach ($comments as $comment_obj)
369 369
 					{
370 370
 						$comment_srl = getNextSequence();
371 371
 						$p_comment_srl[$comment_obj->comment_srl] = $comment_srl;
372 372
 
373 373
 						// Pre-register the attachment
374
-						if($comment_obj->uploaded_count)
374
+						if ($comment_obj->uploaded_count)
375 375
 						{
376 376
 							$files = $oFileModel->getFiles($comment_obj->comment_srl, true);
377
-							foreach($files as $val)
377
+							foreach ($files as $val)
378 378
 							{
379 379
 								$file_info = array();
380 380
 								$file_info['tmp_name'] = $val->uploaded_filename;
@@ -382,10 +382,10 @@  discard block
 block discarded – undo
382 382
 								$oFileController = getController('file');
383 383
 								$inserted_file = $oFileController->insertFile($file_info, $module_srl, $comment_srl, 0, true);
384 384
 								// if image/video files
385
-								if($val->direct_download == 'Y')
385
+								if ($val->direct_download == 'Y')
386 386
 								{
387
-									$source_filename = substr($val->uploaded_filename,2);
388
-									$target_filename = substr($inserted_file->get('uploaded_filename'),2);
387
+									$source_filename = substr($val->uploaded_filename, 2);
388
+									$target_filename = substr($inserted_file->get('uploaded_filename'), 2);
389 389
 									$comment_obj->content = str_replace($source_filename, $target_filename, $comment_obj->content);
390 390
 									// If binary file
391 391
 								}
@@ -401,10 +401,10 @@  discard block
 block discarded – undo
401 401
 						$comment_obj->document_srl = $obj->document_srl;
402 402
 						$comment_obj->comment_srl = $comment_srl;
403 403
 
404
-						if($comment_obj->parent_srl) $comment_obj->parent_srl = $p_comment_srl[$comment_obj->parent_srl];
404
+						if ($comment_obj->parent_srl) $comment_obj->parent_srl = $p_comment_srl[$comment_obj->parent_srl];
405 405
 
406 406
 						$output = $oCommentController->insertComment($comment_obj, true);
407
-						if($output->toBool()) $success_count ++;
407
+						if ($output->toBool()) $success_count++;
408 408
 					}
409 409
 					$oDocumentController->updateCommentCount($obj->document_srl, $success_count, $comment_obj->nick_name, true);
410 410
 				}
@@ -412,19 +412,19 @@  discard block
 block discarded – undo
412 412
 
413 413
 			// Move the trackbacks
414 414
 			$oTrackbackModel = getModel('trackback');
415
-			if($oTrackbackModel && $oDocument->getTrackbackCount())
415
+			if ($oTrackbackModel && $oDocument->getTrackbackCount())
416 416
 			{
417 417
 				$trackbacks = $oTrackbackModel->getTrackbackList($oDocument->document_srl);
418
-				if(count($trackbacks))
418
+				if (count($trackbacks))
419 419
 				{
420 420
 					$success_count = 0;
421
-					foreach($trackbacks as $trackback_obj)
421
+					foreach ($trackbacks as $trackback_obj)
422 422
 					{
423 423
 						$trackback_obj->trackback_srl = getNextSequence();
424 424
 						$trackback_obj->module_srl = $obj->module_srl;
425 425
 						$trackback_obj->document_srl = $obj->document_srl;
426 426
 						$output = executeQuery('trackback.insertTrackback', $trackback_obj);
427
-						if($output->toBool()) $success_count++;
427
+						if ($output->toBool()) $success_count++;
428 428
 					}
429 429
 					// Update the number of trackbacks
430 430
 					$oDocumentController->updateTrackbackCount($obj->document_srl, $success_count);
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 		// Call a trigger (before)
438 438
 		$triggerObj->copied_srls = $copied_srls;
439 439
 		$output = ModuleHandler::triggerCall('document.copyDocumentModule', 'after', $triggerObj);
440
-		if(!$output->toBool())
440
+		if (!$output->toBool())
441 441
 		{
442 442
 			$oDB->rollback();
443 443
 			return $output;
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 		$document_list = $oDocumentModel->getDocumentList($args);
465 465
 		$documents = $document_list->data;
466 466
 		$output = executeQuery('document.deleteModuleDocument', $args);
467
-		if(is_array($documents))
467
+		if (is_array($documents))
468 468
 		{
469 469
 			foreach ($documents as $oDocument)
470 470
 			{
@@ -473,13 +473,13 @@  discard block
 block discarded – undo
473 473
 		}
474 474
 		//remove from cache
475 475
 		$oCacheHandler = CacheHandler::getInstance('object');
476
-		if($oCacheHandler->isSupport())
476
+		if ($oCacheHandler->isSupport())
477 477
 		{
478
-			if(is_array($document_srl_list))
478
+			if (is_array($document_srl_list))
479 479
 			{
480
-				foreach($document_srl_list as $document_srl)
480
+				foreach ($document_srl_list as $document_srl)
481 481
 				{
482
-					$cache_key_item = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
482
+					$cache_key_item = 'document_item:'.getNumberingPath($document_srl).$document_srl;
483 483
 					$oCacheHandler->delete($cache_key_item);
484 484
 				}
485 485
 			}
@@ -498,8 +498,8 @@  discard block
 block discarded – undo
498 498
 		$config = getModel('document')->getDocumentConfig();
499 499
 		$config->icons = Context::get('icons');
500 500
 		$config->micons = Context::get('micons');
501
-		$output = $oModuleController->insertModuleConfig('document',$config);
502
-		if(!$output->toBool())
501
+		$output = $oModuleController->insertModuleConfig('document', $config);
502
+		if (!$output->toBool())
503 503
 		{
504 504
 			return $output;
505 505
 		}
@@ -518,11 +518,11 @@  discard block
 block discarded – undo
518 518
 	{
519 519
 		$document_srl = trim(Context::get('document_srl'));
520 520
 
521
-		if($document_srl)
521
+		if ($document_srl)
522 522
 		{
523 523
 			$args->document_srl = $document_srl;
524 524
 			$output = executeQuery('document.deleteDeclaredDocuments', $args);
525
-			if(!$output->toBool()) return $output;
525
+			if (!$output->toBool()) return $output;
526 526
 		}
527 527
 	}
528 528
 
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 	 */
533 533
 	function procDocumentAdminDeleteAllThumbnail()
534 534
 	{
535
-		$temp_cache_dir = './files/thumbnails_' . $_SERVER['REQUEST_TIME'];
535
+		$temp_cache_dir = './files/thumbnails_'.$_SERVER['REQUEST_TIME'];
536 536
 		FileHandler::rename('./files/thumbnails', $temp_cache_dir);
537 537
 		FileHandler::makeDir('./files/thumbnails');
538 538
 
@@ -548,12 +548,12 @@  discard block
 block discarded – undo
548 548
 	function deleteThumbnailFile($path)
549 549
 	{
550 550
 		$directory = dir($path);
551
-		while($entry = $directory->read()) {
551
+		while ($entry = $directory->read()) {
552 552
 			if ($entry != "." && $entry != "..") {
553 553
 				if (is_dir($path."/".$entry)) {
554 554
 					$this->deleteThumbnailFile($path."/".$entry);
555 555
 				} else {
556
-					if(!preg_match('/^thumbnail_([^\.]*)\.jpg$/i',$entry)) continue;
556
+					if (!preg_match('/^thumbnail_([^\.]*)\.jpg$/i', $entry)) continue;
557 557
 					FileHandler::removeFile($path.'/'.$entry);
558 558
 				}
559 559
 			}
@@ -578,13 +578,13 @@  discard block
 block discarded – undo
578 578
 		$eid = Context::get('eid');
579 579
 		$obj = new stdClass();
580 580
 
581
-		if(!$module_srl || !$name || !$eid) return new BaseObject(-1,'msg_invalid_request');
581
+		if (!$module_srl || !$name || !$eid) return new BaseObject(-1, 'msg_invalid_request');
582 582
 		// set the max value if idx is not specified
583
-		if(!$var_idx)
583
+		if (!$var_idx)
584 584
 		{
585 585
 			$obj->module_srl = $module_srl;
586 586
 			$output = executeQuery('document.getDocumentMaxExtraKeyIdx', $obj);
587
-			$var_idx = $output->data->var_idx+1;
587
+			$var_idx = $output->data->var_idx + 1;
588 588
 		}
589 589
 
590 590
 		// Check if the module name already exists
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 		$obj->var_idx = $var_idx;
593 593
 		$obj->eid = $eid;
594 594
 		$output = executeQuery('document.isExistsExtraKey', $obj);
595
-		if(!$output->toBool() || $output->data->count)
595
+		if (!$output->toBool() || $output->data->count)
596 596
 		{
597 597
 			return new BaseObject(-1, 'msg_extra_name_exists');
598 598
 		}
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 		// insert or update
601 601
 		$oDocumentController = getController('document');
602 602
 		$output = $oDocumentController->insertDocumentExtraKey($module_srl, $var_idx, $name, $type, $is_required, $search, $default, $desc, $eid);
603
-		if(!$output->toBool()) return $output;
603
+		if (!$output->toBool()) return $output;
604 604
 
605 605
 		$this->setMessage('success_registed');
606 606
 
@@ -616,11 +616,11 @@  discard block
 block discarded – undo
616 616
 	{
617 617
 		$module_srl = Context::get('module_srl');
618 618
 		$var_idx = Context::get('var_idx');
619
-		if(!$module_srl || !$var_idx) return new BaseObject(-1,'msg_invalid_request');
619
+		if (!$module_srl || !$var_idx) return new BaseObject(-1, 'msg_invalid_request');
620 620
 
621 621
 		$oDocumentController = getController('document');
622 622
 		$output = $oDocumentController->deleteDocumentExtraKeys($module_srl, $var_idx);
623
-		if(!$output->toBool()) return $output;
623
+		if (!$output->toBool()) return $output;
624 624
 
625 625
 		$this->setMessage('success_deleted');
626 626
 	}
@@ -635,19 +635,19 @@  discard block
 block discarded – undo
635 635
 		$module_srl = Context::get('module_srl');
636 636
 		$var_idx = Context::get('var_idx');
637 637
 
638
-		if(!$type || !$module_srl || !$var_idx) return new BaseObject(-1,'msg_invalid_request');
638
+		if (!$type || !$module_srl || !$var_idx) return new BaseObject(-1, 'msg_invalid_request');
639 639
 
640 640
 		$oModuleModel = getModel('module');
641 641
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
642
-		if(!$module_info->module_srl) return new BaseObject(-1,'msg_invalid_request');
642
+		if (!$module_info->module_srl) return new BaseObject(-1, 'msg_invalid_request');
643 643
 
644 644
 		$oDocumentModel = getModel('document');
645 645
 		$extra_keys = $oDocumentModel->getExtraKeys($module_srl);
646
-		if(!$extra_keys[$var_idx]) return new BaseObject(-1,'msg_invalid_request');
646
+		if (!$extra_keys[$var_idx]) return new BaseObject(-1, 'msg_invalid_request');
647 647
 
648
-		if($type == 'up') $new_idx = $var_idx-1;
649
-		else $new_idx = $var_idx+1;
650
-		if($new_idx<1) return new BaseObject(-1,'msg_invalid_request');
648
+		if ($type == 'up') $new_idx = $var_idx - 1;
649
+		else $new_idx = $var_idx + 1;
650
+		if ($new_idx < 1) return new BaseObject(-1, 'msg_invalid_request');
651 651
 
652 652
 		$args = new stdClass();
653 653
 		$args->module_srl = $module_srl;
@@ -658,16 +658,16 @@  discard block
 block discarded – undo
658 658
 		unset($args);
659 659
 
660 660
 		// update immediately if there is no idx to change
661
-		if(!$extra_keys[$new_idx])
661
+		if (!$extra_keys[$new_idx])
662 662
 		{
663 663
 			$args = new stdClass();
664 664
 			$args->module_srl = $module_srl;
665 665
 			$args->var_idx = $var_idx;
666 666
 			$args->new_idx = $new_idx;
667 667
 			$output = executeQuery('document.updateDocumentExtraKeyIdx', $args);
668
-			if(!$output->toBool()) return $output;
668
+			if (!$output->toBool()) return $output;
669 669
 			$output = executeQuery('document.updateDocumentExtraVarIdx', $args);
670
-			if(!$output->toBool()) return $output;
670
+			if (!$output->toBool()) return $output;
671 671
 			// replace if exists
672 672
 		}
673 673
 		else
@@ -677,27 +677,27 @@  discard block
 block discarded – undo
677 677
 			$args->var_idx = $new_idx;
678 678
 			$args->new_idx = -10000;
679 679
 			$output = executeQuery('document.updateDocumentExtraKeyIdx', $args);
680
-			if(!$output->toBool()) return $output;
680
+			if (!$output->toBool()) return $output;
681 681
 			$output = executeQuery('document.updateDocumentExtraVarIdx', $args);
682
-			if(!$output->toBool()) return $output;
682
+			if (!$output->toBool()) return $output;
683 683
 
684 684
 			$args->var_idx = $var_idx;
685 685
 			$args->new_idx = $new_idx;
686 686
 			$output = executeQuery('document.updateDocumentExtraKeyIdx', $args);
687
-			if(!$output->toBool()) return $output;
687
+			if (!$output->toBool()) return $output;
688 688
 			$output = executeQuery('document.updateDocumentExtraVarIdx', $args);
689
-			if(!$output->toBool()) return $output;
689
+			if (!$output->toBool()) return $output;
690 690
 
691 691
 			$args->var_idx = -10000;
692 692
 			$args->new_idx = $var_idx;
693 693
 			$output = executeQuery('document.updateDocumentExtraKeyIdx', $args);
694
-			if(!$output->toBool()) return $output;
694
+			if (!$output->toBool()) return $output;
695 695
 			$output = executeQuery('document.updateDocumentExtraVarIdx', $args);
696
-			if(!$output->toBool()) return $output;
696
+			if (!$output->toBool()) return $output;
697 697
 		}
698 698
 
699 699
 		$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
700
-		if($oCacheHandler->isSupport())
700
+		if ($oCacheHandler->isSupport())
701 701
 		{
702 702
 			$object_key = 'module_document_extra_keys:'.$module_srl;
703 703
 			$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
@@ -711,9 +711,9 @@  discard block
 block discarded – undo
711 711
 	 */
712 712
 	function procDocumentAdminInsertAlias()
713 713
 	{
714
-		$args = Context::gets('module_srl','document_srl', 'alias_title');
714
+		$args = Context::gets('module_srl', 'document_srl', 'alias_title');
715 715
 		$alias_srl = Context::get('alias_srl');
716
-		if(!$alias_srl)
716
+		if (!$alias_srl)
717 717
 		{
718 718
 			$args->alias_srl = getNextSequence();
719 719
 			$query = "document.insertAlias";
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 		$oDocumentModel = getModel('document');
757 757
 		$oDocumentController = getController('document');
758 758
 		$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
759
-		if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted');
759
+		if (!$oDocument->isGranted()) return $this->stop('msg_not_permitted');
760 760
 	
761 761
 		$oModuleModel = getModel('module');
762 762
 		$module_info = $oModuleModel->getModuleInfoByDocumentSrl($document_srl);
@@ -768,31 +768,31 @@  discard block
 block discarded – undo
768 768
 		$oDocumentController->moveDocumentToTrash($args);
769 769
 
770 770
 		$returnUrl = Context::get('success_return_url');
771
-		if(!$returnUrl)	
771
+		if (!$returnUrl)	
772 772
 		{
773 773
 			$arrUrl = parse_url(Context::get('cur_url'));
774 774
 			$query = "";
775 775
 
776
-			if($arrUrl['query'])
776
+			if ($arrUrl['query'])
777 777
 			{
778 778
 				parse_str($arrUrl['query'], $arrQuery);
779 779
 
780 780
 				// set query
781
-				if(isset($arrQuery['document_srl']))
781
+				if (isset($arrQuery['document_srl']))
782 782
 					unset($arrQuery['document_srl']);
783 783
 
784 784
 				$searchArgs = new stdClass;
785
-				foreach($arrQuery as $key=>$val)
785
+				foreach ($arrQuery as $key=>$val)
786 786
 				{
787 787
 					$searchArgs->{$key} = $val;
788 788
 				}
789 789
 
790
-				if(!isset($searchArgs->sort_index))
790
+				if (!isset($searchArgs->sort_index))
791 791
 					$searchArgs->sort_index = $module_info->order_target;
792 792
 
793
-				foreach($module_info as $key=>$val)
793
+				foreach ($module_info as $key=>$val)
794 794
 				{
795
-					if(!isset($searchArgs->{$key}))
795
+					if (!isset($searchArgs->{$key}))
796 796
 						$searchArgs->{$key} = $val;
797 797
 				}
798 798
 
@@ -800,20 +800,20 @@  discard block
 block discarded – undo
800 800
 				$output = $oDocumentModel->getDocumentList($searchArgs, $module_info->except_notice, TRUE, array('document_srl'));
801 801
 
802 802
 				$cur_page = 1;
803
-				if(isset($arrQuery['page'])) {
804
-					$cur_page = (int)$arrQuery['page'];
803
+				if (isset($arrQuery['page'])) {
804
+					$cur_page = (int) $arrQuery['page'];
805 805
 				}
806 806
 
807 807
 
808
-				if($cur_page>1 && count($output->data) == 0)
808
+				if ($cur_page > 1 && count($output->data) == 0)
809 809
 					$arrQuery['page'] = $cur_page - 1;
810 810
 
811 811
 				$query = "?";
812
-				foreach($arrQuery as $key=>$val)
812
+				foreach ($arrQuery as $key=>$val)
813 813
 					$query .= sprintf("%s=%s&", $key, $val);
814 814
 				$query = substr($query, 0, -1);
815 815
 			}
816
-			$returnUrl = $arrUrl['path'] . $query;
816
+			$returnUrl = $arrUrl['path'].$query;
817 817
 		}
818 818
 
819 819
 		$this->add('redirect_url', $returnUrl);
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
 	 */
891 891
 	function restoreTrash($originObject)
892 892
 	{
893
-		if(is_array($originObject)) $originObject = (object)$originObject;
893
+		if (is_array($originObject)) $originObject = (object) $originObject;
894 894
 
895 895
 		$oDocumentController = getController('document');
896 896
 		$oDocumentModel = getModel('document');
@@ -900,12 +900,12 @@  discard block
 block discarded – undo
900 900
 
901 901
 		//DB restore
902 902
 		$output = $oDocumentController->insertDocument($originObject, false, true, false);
903
-		if(!$output->toBool()) return new BaseObject(-1, $output->getMessage());
903
+		if (!$output->toBool()) return new BaseObject(-1, $output->getMessage());
904 904
 
905 905
 		//FILE restore
906 906
 		$oDocument = $oDocumentModel->getDocument($originObject->document_srl);
907 907
 		// If the post was not temorarily saved, set the attachment's status to be valid
908
-		if($oDocument->hasUploadedFiles() && $originObject->member_srl != $originObject->module_srl)
908
+		if ($oDocument->hasUploadedFiles() && $originObject->member_srl != $originObject->module_srl)
909 909
 		{
910 910
 			$args = new stdClass();
911 911
 			$args->upload_target_srl = $oDocument->document_srl;
@@ -914,10 +914,10 @@  discard block
 block discarded – undo
914 914
 		}
915 915
 
916 916
 		// call a trigger (after)
917
-		if($output->toBool())
917
+		if ($output->toBool())
918 918
 		{
919 919
 			$trigger_output = ModuleHandler::triggerCall('document.restoreTrash', 'after', $originObject);
920
-			if(!$trigger_output->toBool())
920
+			if (!$trigger_output->toBool())
921 921
 			{
922 922
 				$oDB->rollback();
923 923
 				return $trigger_output;
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
 	function emptyTrash($originObject)
939 939
 	{
940 940
 		$originObject = unserialize($originObject);
941
-		if(is_array($originObject)) $originObject = (object) $originObject;
941
+		if (is_array($originObject)) $originObject = (object) $originObject;
942 942
 
943 943
 		$oDocument = new documentItem();
944 944
 		$oDocument->setAttribute($originObject);
Please login to merge, or discard this patch.
modules/file/file.controller.php 2 patches
Spacing   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -29,30 +29,30 @@  discard block
 block discarded – undo
29 29
 		$file_info = Context::get('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
-		$this->add('file_srl',$output->get('file_srl'));
50
-		$this->add('file_size',$output->get('file_size'));
51
-		$this->add('direct_download',$output->get('direct_download'));
52
-		$this->add('source_filename',$output->get('source_filename'));
53
-		$this->add('download_url',$output->get('uploaded_filename'));
54
-		$this->add('upload_target_srl',$output->get('upload_target_srl'));
55
-		if($output->error != '0') $this->stop($output->message);
49
+		$this->add('file_srl', $output->get('file_srl'));
50
+		$this->add('file_size', $output->get('file_size'));
51
+		$this->add('direct_download', $output->get('direct_download'));
52
+		$this->add('source_filename', $output->get('source_filename'));
53
+		$this->add('download_url', $output->get('uploaded_filename'));
54
+		$this->add('upload_target_srl', $output->get('upload_target_srl'));
55
+		if ($output->error != '0') $this->stop($output->message);
56 56
 	}
57 57
 
58 58
 	/**
@@ -67,24 +67,24 @@  discard block
 block discarded – undo
67 67
 		$callback = Context::get('callback');
68 68
 		$module_srl = $this->module_srl;
69 69
 		$upload_target_srl = intval(Context::get('uploadTargetSrl'));
70
-		if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl'));
70
+		if (!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl'));
71 71
 
72 72
 		// Exit a session if there is neither upload permission nor information
73
-		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
73
+		if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
74 74
 		// Extract from session information if upload_target_srl is not specified
75
-		if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
75
+		if (!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
76 76
 		// Create if upload_target_srl is not defined in the session information
77
-		if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
77
+		if (!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
78 78
 
79 79
 		// Delete and then attempt to re-upload if file_srl is requested
80 80
 		$file_srl = Context::get('file_srl');
81
-		if($file_srl)
81
+		if ($file_srl)
82 82
 		{
83 83
 			$oFileModel = getModel('file');
84 84
 			$logged_info = Context::get('logged_info');
85 85
 			$file_info = $oFileModel->getFile($file_srl);
86 86
 			$file_grant = $oFileModel->getFileGrant($file_info, $logged_info);
87
-			if($file_info->file_srl == $file_srl && $file_grant->is_deletable)
87
+			if ($file_info->file_srl == $file_srl && $file_grant->is_deletable)
88 88
 			{
89 89
 				$this->deleteFile($file_srl);
90 90
 			}
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 
93 93
 		$file_info = Context::get('Filedata');
94 94
 		// An error appears if not a normally uploaded file
95
-		if(is_uploaded_file($file_info['tmp_name'])) {
95
+		if (is_uploaded_file($file_info['tmp_name'])) {
96 96
 			$output = $this->insertFile($file_info, $module_srl, $upload_target_srl);
97
-			Context::set('uploaded_fileinfo',$output);
97
+			Context::set('uploaded_fileinfo', $output);
98 98
 		}
99 99
 
100
-		Context::set('layout','none');
100
+		Context::set('layout', 'none');
101 101
 
102 102
 		$this->setTemplatePath($this->module_path.'tpl');
103 103
 		$this->setTemplateFile('iframe');
@@ -114,24 +114,24 @@  discard block
 block discarded – undo
114 114
 		$width = Context::get('width');
115 115
 		$height = Context::get('height');
116 116
 
117
-		if(!$file_srl || !$width)
117
+		if (!$file_srl || !$width)
118 118
 		{
119
-			return new BaseObject(-1,'msg_invalid_request');
119
+			return new BaseObject(-1, 'msg_invalid_request');
120 120
 		}
121 121
 
122 122
 		$oFileModel = getModel('file');
123 123
 		$fileInfo = $oFileModel->getFile($file_srl);
124
-		if(!$fileInfo || $fileInfo->direct_download != 'Y')
124
+		if (!$fileInfo || $fileInfo->direct_download != 'Y')
125 125
 		{
126
-			return new BaseObject(-1,'msg_invalid_request');
126
+			return new BaseObject(-1, 'msg_invalid_request');
127 127
 		}
128 128
 
129 129
 		$source_src = $fileInfo->uploaded_filename;
130
-		$output_src = $source_src . '.resized' . strrchr($source_src,'.');
130
+		$output_src = $source_src.'.resized'.strrchr($source_src, '.');
131 131
 
132
-		if(!$height) $height = $width-1;
132
+		if (!$height) $height = $width - 1;
133 133
 
134
-		if(FileHandler::createImageFile($source_src,$output_src,$width,$height,'','ratio'))
134
+		if (FileHandler::createImageFile($source_src, $output_src, $width, $height, '', 'ratio'))
135 135
 		{
136 136
 			$output = new stdClass();
137 137
 			$output->info = getimagesize($output_src);
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
 		}
140 140
 		else
141 141
 		{
142
-			return new BaseObject(-1,'msg_invalid_request');
142
+			return new BaseObject(-1, 'msg_invalid_request');
143 143
 		}
144 144
 
145
-		$this->add('resized_info',$output);
145
+		$this->add('resized_info', $output);
146 146
 	}
147 147
 
148 148
 	/**
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	{
181 181
 		$oFileModel = getModel('file');
182 182
 
183
-		if(isset($this->grant->access) && $this->grant->access !== true) return new BaseObject(-1, 'msg_not_permitted');
183
+		if (isset($this->grant->access) && $this->grant->access !== true) return new BaseObject(-1, 'msg_not_permitted');
184 184
 
185 185
 		$file_srl = Context::get('file_srl');
186 186
 		$sid = Context::get('sid');
@@ -189,26 +189,26 @@  discard block
 block discarded – undo
189 189
 		$columnList = array('file_srl', 'sid', 'isvalid', 'source_filename', 'module_srl', 'uploaded_filename', 'file_size', 'member_srl', 'upload_target_srl', 'upload_target_type');
190 190
 		$file_obj = $oFileModel->getFile($file_srl, $columnList);
191 191
 		// If the requested file information is incorrect, an error that file cannot be found appears
192
-		if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) return $this->stop('msg_file_not_found');
192
+		if ($file_obj->file_srl != $file_srl || $file_obj->sid != $sid) return $this->stop('msg_file_not_found');
193 193
 		// Notify that file download is not allowed when standing-by(Only a top-administrator is permitted)
194
-		if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') return $this->stop('msg_not_permitted_download');
194
+		if ($logged_info->is_admin != 'Y' && $file_obj->isvalid != 'Y') return $this->stop('msg_not_permitted_download');
195 195
 		// File name
196 196
 		$filename = $file_obj->source_filename;
197 197
 		$file_module_config = $oFileModel->getFileModuleConfig($file_obj->module_srl);
198 198
 		// Not allow the file outlink
199
-		if($file_module_config->allow_outlink == 'N')
199
+		if ($file_module_config->allow_outlink == 'N')
200 200
 		{
201 201
 			// Handles extension to allow outlink
202
-			if($file_module_config->allow_outlink_format)
202
+			if ($file_module_config->allow_outlink_format)
203 203
 			{
204 204
 				$allow_outlink_format_array = array();
205 205
 				$allow_outlink_format_array = explode(',', $file_module_config->allow_outlink_format);
206
-				if(!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format;
206
+				if (!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format;
207 207
 
208
-				foreach($allow_outlink_format_array as $val)
208
+				foreach ($allow_outlink_format_array as $val)
209 209
 				{
210 210
 					$val = trim($val);
211
-					if(preg_match("/\.{$val}$/i", $filename))
211
+					if (preg_match("/\.{$val}$/i", $filename))
212 212
 					{
213 213
 						$file_module_config->allow_outlink = 'Y';
214 214
 						break;
@@ -216,21 +216,21 @@  discard block
 block discarded – undo
216 216
 				}
217 217
 			}
218 218
 			// Sites that outlink is allowed
219
-			if($file_module_config->allow_outlink != 'Y')
219
+			if ($file_module_config->allow_outlink != 'Y')
220 220
 			{
221 221
 				$referer = parse_url($_SERVER["HTTP_REFERER"]);
222
-				if($referer['host'] != $_SERVER['HTTP_HOST'])
222
+				if ($referer['host'] != $_SERVER['HTTP_HOST'])
223 223
 				{
224
-					if($file_module_config->allow_outlink_site)
224
+					if ($file_module_config->allow_outlink_site)
225 225
 					{
226 226
 						$allow_outlink_site_array = array();
227 227
 						$allow_outlink_site_array = explode("\n", $file_module_config->allow_outlink_site);
228
-						if(!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site;
228
+						if (!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site;
229 229
 
230
-						foreach($allow_outlink_site_array as $val)
230
+						foreach ($allow_outlink_site_array as $val)
231 231
 						{
232 232
 							$site = parse_url(trim($val));
233
-							if($site['host'] == $referer['host'])
233
+							if ($site['host'] == $referer['host'])
234 234
 							{
235 235
 								$file_module_config->allow_outlink = 'Y';
236 236
 								break;
@@ -240,49 +240,49 @@  discard block
 block discarded – undo
240 240
 				}
241 241
 				else $file_module_config->allow_outlink = 'Y';
242 242
 			}
243
-			if($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink');
243
+			if ($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink');
244 244
 		}
245 245
 
246 246
 		// Check if a permission for file download is granted
247 247
 		$downloadGrantCount = 0;
248
-		if(is_array($file_module_config->download_grant))
248
+		if (is_array($file_module_config->download_grant))
249 249
 		{
250
-			foreach($file_module_config->download_grant AS $value)
251
-				if($value) $downloadGrantCount++;
250
+			foreach ($file_module_config->download_grant AS $value)
251
+				if ($value) $downloadGrantCount++;
252 252
 		}
253 253
 
254
-		if(is_array($file_module_config->download_grant) && $downloadGrantCount>0)
254
+		if (is_array($file_module_config->download_grant) && $downloadGrantCount > 0)
255 255
 		{
256
-			if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download');
256
+			if (!Context::get('is_logged')) return $this->stop('msg_not_permitted_download');
257 257
 			$logged_info = Context::get('logged_info');
258
-			if($logged_info->is_admin != 'Y')
258
+			if ($logged_info->is_admin != 'Y')
259 259
 			{
260
-				$oModuleModel =& getModel('module');
260
+				$oModuleModel = & getModel('module');
261 261
 				$columnList = array('module_srl', 'site_srl');
262 262
 				$module_info = $oModuleModel->getModuleInfoByModuleSrl($file_obj->module_srl, $columnList);
263 263
 
264
-				if(!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl))
264
+				if (!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl))
265 265
 				{
266
-					$oMemberModel =& getModel('member');
266
+					$oMemberModel = & getModel('member');
267 267
 					$member_groups = $oMemberModel->getMemberGroups($logged_info->member_srl, $module_info->site_srl);
268 268
 
269 269
 					$is_permitted = false;
270
-					for($i=0;$i<count($file_module_config->download_grant);$i++)
270
+					for ($i = 0; $i < count($file_module_config->download_grant); $i++)
271 271
 					{
272 272
 						$group_srl = $file_module_config->download_grant[$i];
273
-						if($member_groups[$group_srl])
273
+						if ($member_groups[$group_srl])
274 274
 						{
275 275
 							$is_permitted = true;
276 276
 							break;
277 277
 						}
278 278
 					}
279
-					if(!$is_permitted) return $this->stop('msg_not_permitted_download');
279
+					if (!$is_permitted) return $this->stop('msg_not_permitted_download');
280 280
 				}
281 281
 			}
282 282
 		}
283 283
 		// Call a trigger (before)
284 284
 		$output = ModuleHandler::triggerCall('file.downloadFile', 'before', $file_obj);
285
-		if(!$output->toBool()) return $this->stop(($output->message)?$output->message:'msg_not_permitted_download');
285
+		if (!$output->toBool()) return $this->stop(($output->message) ? $output->message : 'msg_not_permitted_download');
286 286
 
287 287
 
288 288
 		// 다운로드 후 (가상)
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 
296 296
 		$random = new Password();
297 297
 		$file_key = $_SESSION['__XE_FILE_KEY__'][$file_srl] = $random->createSecureSalt(32, 'hex');
298
-		header('Location: '.getNotEncodedUrl('', 'act', 'procFileOutput','file_srl',$file_srl,'file_key',$file_key));
298
+		header('Location: '.getNotEncodedUrl('', 'act', 'procFileOutput', 'file_srl', $file_srl, 'file_key', $file_key));
299 299
 		Context::close();
300 300
 		exit();
301 301
 
@@ -306,18 +306,18 @@  discard block
 block discarded – undo
306 306
 		$oFileModel = getModel('file');
307 307
 		$file_srl = Context::get('file_srl');
308 308
 		$file_key = Context::get('file_key');
309
-		if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true;
309
+		if (strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true;
310 310
 
311
-		if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__';
311
+		if ($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__';
312 312
 		else $session_key = '__XE_FILE_KEY__';
313 313
 		$columnList = array('source_filename', 'uploaded_filename', 'file_size');
314 314
 		$file_obj = $oFileModel->getFile($file_srl, $columnList);
315 315
 
316 316
 		$uploaded_filename = $file_obj->uploaded_filename;
317 317
 
318
-		if(!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found');
318
+		if (!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found');
319 319
 
320
-		if(!$file_key || $_SESSION[$session_key][$file_srl] != $file_key)
320
+		if (!$file_key || $_SESSION[$session_key][$file_srl] != $file_key)
321 321
 		{
322 322
 			unset($_SESSION[$session_key][$file_srl]);
323 323
 			return $this->stop('msg_invalid_request');
@@ -326,34 +326,34 @@  discard block
 block discarded – undo
326 326
 		$file_size = $file_obj->file_size;
327 327
 		$filename = $file_obj->source_filename;
328 328
 		
329
-		if(preg_match('#(?:Chrome|Edge)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 11)
329
+		if (preg_match('#(?:Chrome|Edge)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 11)
330 330
 		{
331
-			if($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT']))
331
+			if ($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT']))
332 332
 			{
333
-				$filename_param = 'filename="' . $filename . '"';
333
+				$filename_param = 'filename="'.$filename.'"';
334 334
 			}
335 335
 			else
336 336
 			{
337 337
 				$filename_param = sprintf('filename="%s"; filename*=UTF-8\'\'%s', $filename, rawurlencode($filename));
338 338
 			}
339 339
 		}
340
-		elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6)
340
+		elseif (preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6)
341 341
 		{
342 342
 			$filename_param = sprintf('filename="%s"; filename*=UTF-8\'\'%s', $filename, rawurlencode($filename));
343 343
 		}
344
-		elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
344
+		elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
345 345
 		{
346 346
 			$filename = rawurlencode($filename);
347
-			$filename_param = 'filename="' . preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1) . '"';
347
+			$filename_param = 'filename="'.preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1).'"';
348 348
 		}
349 349
 		else
350 350
 		{
351
-			$filename_param = 'filename="' . $filename . '"';
351
+			$filename_param = 'filename="'.$filename.'"';
352 352
 		}
353 353
 
354
-		if($is_android)
354
+		if ($is_android)
355 355
 		{
356
-			if($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key;
356
+			if ($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key;
357 357
 		}
358 358
 
359 359
 		unset($_SESSION[$session_key][$file_srl]);
@@ -361,21 +361,21 @@  discard block
 block discarded – undo
361 361
 		Context::close();
362 362
 
363 363
 		$fp = fopen($uploaded_filename, 'rb');
364
-		if(!$fp) return $this->stop('msg_file_not_found');
364
+		if (!$fp) return $this->stop('msg_file_not_found');
365 365
 
366 366
 		header("Cache-Control: ");
367 367
 		header("Pragma: ");
368 368
 		header("Content-Type: application/octet-stream");
369
-		header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
369
+		header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
370 370
 
371
-		header("Content-Length: " .(string)($file_size));
372
-		header('Content-Disposition: attachment; ' . $filename_param);
371
+		header("Content-Length: ".(string) ($file_size));
372
+		header('Content-Disposition: attachment; '.$filename_param);
373 373
 		header("Content-Transfer-Encoding: binary\n");
374 374
 
375 375
 		// if file size is lager than 10MB, use fread function (#18675748)
376
-		if($file_size > 1024 * 1024)
376
+		if ($file_size > 1024 * 1024)
377 377
 		{
378
-			while(!feof($fp)) echo fread($fp, 1024);
378
+			while (!feof($fp)) echo fread($fp, 1024);
379 379
 			fclose($fp);
380 380
 		}
381 381
 		else
@@ -397,36 +397,36 @@  discard block
 block discarded – undo
397 397
 		$editor_sequence = Context::get('editor_sequence');
398 398
 		$file_srl = Context::get('file_srl');
399 399
 		$file_srls = Context::get('file_srls');
400
-		if($file_srls) $file_srl = $file_srls;
400
+		if ($file_srls) $file_srl = $file_srls;
401 401
 		// Exit a session if there is neither upload permission nor information
402
-		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
402
+		if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
403 403
 
404 404
 		$upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
405 405
 
406 406
 		$logged_info = Context::get('logged_info');
407 407
 		$oFileModel = getModel('file');
408 408
 
409
-		$srls = explode(',',$file_srl);
410
-		if(!count($srls)) return;
409
+		$srls = explode(',', $file_srl);
410
+		if (!count($srls)) return;
411 411
 
412
-		for($i=0;$i<count($srls);$i++)
412
+		for ($i = 0; $i < count($srls); $i++)
413 413
 		{
414
-			$srl = (int)$srls[$i];
415
-			if(!$srl) continue;
414
+			$srl = (int) $srls[$i];
415
+			if (!$srl) continue;
416 416
 
417 417
 			$args = new stdClass;
418 418
 			$args->file_srl = $srl;
419 419
 			$output = executeQuery('file.getFile', $args);
420
-			if(!$output->toBool()) continue;
420
+			if (!$output->toBool()) continue;
421 421
 
422 422
 			$file_info = $output->data;
423
-			if(!$file_info) continue;
423
+			if (!$file_info) continue;
424 424
 
425 425
 			$file_grant = $oFileModel->getFileGrant($file_info, $logged_info);
426 426
 
427
-			if(!$file_grant->is_deletable) continue;
427
+			if (!$file_grant->is_deletable) continue;
428 428
 
429
-			if($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl);
429
+			if ($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl);
430 430
 		}
431 431
 	}
432 432
 
@@ -437,32 +437,32 @@  discard block
 block discarded – undo
437 437
 	 */
438 438
 	function procFileGetList()
439 439
 	{
440
-		if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted');
440
+		if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted');
441 441
 
442 442
 		$oModuleModel = getModel('module');
443 443
 
444 444
 		$logged_info = Context::get('logged_info');
445
-		if($logged_info->is_admin !== 'Y' && !$oModuleModel->isSiteAdmin($logged_info))
445
+		if ($logged_info->is_admin !== 'Y' && !$oModuleModel->isSiteAdmin($logged_info))
446 446
 		{
447 447
 			return new BaseObject(-1, 'msg_not_permitted');
448 448
 		}
449 449
 
450 450
 		$fileSrls = Context::get('file_srls');
451
-		if($fileSrls) $fileSrlList = explode(',', $fileSrls);
451
+		if ($fileSrls) $fileSrlList = explode(',', $fileSrls);
452 452
 
453 453
 		global $lang;
454
-		if(count($fileSrlList) > 0)
454
+		if (count($fileSrlList) > 0)
455 455
 		{
456 456
 			$oFileModel = getModel('file');
457 457
 			$fileList = $oFileModel->getFile($fileSrlList);
458
-			if(!is_array($fileList)) $fileList = array($fileList);
458
+			if (!is_array($fileList)) $fileList = array($fileList);
459 459
 
460
-			if(is_array($fileList))
460
+			if (is_array($fileList))
461 461
 			{
462
-				foreach($fileList AS $key=>$value)
462
+				foreach ($fileList AS $key=>$value)
463 463
 				{
464 464
 					$value->human_file_size = FileHandler::filesize($value->file_size);
465
-					if($value->isvalid=='Y') $value->validName = $lang->is_valid;
465
+					if ($value->isvalid == 'Y') $value->validName = $lang->is_valid;
466 466
 					else $value->validName = $lang->is_stand_by;
467 467
 				}
468 468
 			}
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 	function triggerCheckAttached(&$obj)
485 485
 	{
486 486
 		$document_srl = $obj->document_srl;
487
-		if(!$document_srl) return new BaseObject();
487
+		if (!$document_srl) return new BaseObject();
488 488
 		// Get numbers of attachments
489 489
 		$oFileModel = getModel('file');
490 490
 		$obj->uploaded_count = $oFileModel->getFilesCount($document_srl);
@@ -501,10 +501,10 @@  discard block
 block discarded – undo
501 501
 	function triggerAttachFiles(&$obj)
502 502
 	{
503 503
 		$document_srl = $obj->document_srl;
504
-		if(!$document_srl) return new BaseObject();
504
+		if (!$document_srl) return new BaseObject();
505 505
 
506 506
 		$output = $this->setFilesValid($document_srl);
507
-		if(!$output->toBool()) return $output;
507
+		if (!$output->toBool()) return $output;
508 508
 
509 509
 		return new BaseObject();
510 510
 	}
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 	function triggerDeleteAttached(&$obj)
519 519
 	{
520 520
 		$document_srl = $obj->document_srl;
521
-		if(!$document_srl) return new BaseObject();
521
+		if (!$document_srl) return new BaseObject();
522 522
 
523 523
 		$output = $this->deleteFiles($document_srl);
524 524
 		return $output;
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 	function triggerCommentCheckAttached(&$obj)
534 534
 	{
535 535
 		$comment_srl = $obj->comment_srl;
536
-		if(!$comment_srl) return new BaseObject();
536
+		if (!$comment_srl) return new BaseObject();
537 537
 		// Get numbers of attachments
538 538
 		$oFileModel = getModel('file');
539 539
 		$obj->uploaded_count = $oFileModel->getFilesCount($comment_srl);
@@ -551,10 +551,10 @@  discard block
 block discarded – undo
551 551
 	{
552 552
 		$comment_srl = $obj->comment_srl;
553 553
 		$uploaded_count = $obj->uploaded_count;
554
-		if(!$comment_srl || !$uploaded_count) return new BaseObject();
554
+		if (!$comment_srl || !$uploaded_count) return new BaseObject();
555 555
 
556 556
 		$output = $this->setFilesValid($comment_srl);
557
-		if(!$output->toBool()) return $output;
557
+		if (!$output->toBool()) return $output;
558 558
 
559 559
 		return new BaseObject();
560 560
 	}
@@ -568,9 +568,9 @@  discard block
 block discarded – undo
568 568
 	function triggerCommentDeleteAttached(&$obj)
569 569
 	{
570 570
 		$comment_srl = $obj->comment_srl;
571
-		if(!$comment_srl) return new BaseObject();
571
+		if (!$comment_srl) return new BaseObject();
572 572
 
573
-		if($obj->isMoveToTrash) return new BaseObject();
573
+		if ($obj->isMoveToTrash) return new BaseObject();
574 574
 
575 575
 		$output = $this->deleteFiles($comment_srl);
576 576
 		return $output;
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 	function triggerDeleteModuleFiles(&$obj)
586 586
 	{
587 587
 		$module_srl = $obj->module_srl;
588
-		if(!$module_srl) return new BaseObject();
588
+		if (!$module_srl) return new BaseObject();
589 589
 
590 590
 		$oFileController = getAdminController('file');
591 591
 		return $oFileController->deleteModuleFiles($module_srl);
@@ -598,9 +598,9 @@  discard block
 block discarded – undo
598 598
 	 * @param int $upload_target_srl
599 599
 	 * @return void
600 600
 	 */
601
-	function setUploadInfo($editor_sequence, $upload_target_srl=0)
601
+	function setUploadInfo($editor_sequence, $upload_target_srl = 0)
602 602
 	{
603
-		if(!isset($_SESSION['upload_info'][$editor_sequence]))
603
+		if (!isset($_SESSION['upload_info'][$editor_sequence]))
604 604
 		{
605 605
 			$_SESSION['upload_info'][$editor_sequence] = new stdClass();
606 606
 		}
@@ -660,36 +660,36 @@  discard block
 block discarded – undo
660 660
 		$trigger_obj->module_srl = $module_srl;
661 661
 		$trigger_obj->upload_target_srl = $upload_target_srl;
662 662
 		$output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj);
663
-		if(!$output->toBool()) return $output;
663
+		if (!$output->toBool()) return $output;
664 664
 
665 665
 		// A workaround for Firefox upload bug
666
-		if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match))
666
+		if (preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match))
667 667
 		{
668 668
 			$file_info['name'] = base64_decode(strtr($match[1], ':', '/'));
669 669
 		}
670 670
 
671
-		if(!$manual_insert)
671
+		if (!$manual_insert)
672 672
 		{
673 673
 			// Get the file configurations
674 674
 			$logged_info = Context::get('logged_info');
675
-			if($logged_info->is_admin != 'Y')
675
+			if ($logged_info->is_admin != 'Y')
676 676
 			{
677 677
 				$oFileModel = getModel('file');
678 678
 				$config = $oFileModel->getFileConfig($module_srl);
679 679
 
680 680
 				// check file type
681
-				if(isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*')
681
+				if (isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*')
682 682
 				{
683 683
 					$filetypes = explode(';', $config->allowed_filetypes);
684 684
 					$ext = array();
685
-					foreach($filetypes as $item) {
685
+					foreach ($filetypes as $item) {
686 686
 						$item = explode('.', $item);
687 687
 						$ext[] = strtolower($item[1]);
688 688
 					}
689 689
 					$uploaded_ext = explode('.', $file_info['name']);
690 690
 					$uploaded_ext = strtolower(array_pop($uploaded_ext));
691 691
 
692
-					if(!in_array($uploaded_ext, $ext))
692
+					if (!in_array($uploaded_ext, $ext))
693 693
 					{
694 694
 						return $this->stop('msg_not_allowed_filetype');
695 695
 					}
@@ -698,64 +698,64 @@  discard block
 block discarded – undo
698 698
 				$allowed_filesize = $config->allowed_filesize * 1024 * 1024;
699 699
 				$allowed_attach_size = $config->allowed_attach_size * 1024 * 1024;
700 700
 				// An error appears if file size exceeds a limit
701
-				if($allowed_filesize < filesize($file_info['tmp_name'])) return new BaseObject(-1, 'msg_exceeds_limit_size');
701
+				if ($allowed_filesize < filesize($file_info['tmp_name'])) return new BaseObject(-1, 'msg_exceeds_limit_size');
702 702
 				// Get total file size of all attachements (from DB)
703 703
 				$size_args = new stdClass;
704 704
 				$size_args->upload_target_srl = $upload_target_srl;
705 705
 				$output = executeQuery('file.getAttachedFileSize', $size_args);
706
-				$attached_size = (int)$output->data->attached_size + filesize($file_info['tmp_name']);
707
-				if($attached_size > $allowed_attach_size) return new BaseObject(-1, 'msg_exceeds_limit_size');
706
+				$attached_size = (int) $output->data->attached_size + filesize($file_info['tmp_name']);
707
+				if ($attached_size > $allowed_attach_size) return new BaseObject(-1, 'msg_exceeds_limit_size');
708 708
 			}
709 709
 		}
710 710
 
711 711
 		// https://github.com/xpressengine/xe-core/issues/1713
712
-		$file_info['name'] = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x',$file_info['name']);
712
+		$file_info['name'] = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x', $file_info['name']);
713 713
 		$file_info['name'] = removeHackTag($file_info['name']);
714
-		$file_info['name'] = str_replace(array('<','>'),array('%3C','%3E'),$file_info['name']);
714
+		$file_info['name'] = str_replace(array('<', '>'), array('%3C', '%3E'), $file_info['name']);
715 715
 		$file_info['name'] = str_replace('&amp;', '&', $file_info['name']);
716 716
 
717 717
 		// Get random number generator
718 718
 		$random = new Password();
719 719
 
720 720
 		// Set upload path by checking if the attachement is an image or other kinds of file
721
-		if(preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_info['name']))
721
+		if (preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_info['name']))
722 722
 		{
723
-			$path = sprintf("./files/attach/images/%s/%s", $module_srl,getNumberingPath($upload_target_srl,3));
723
+			$path = sprintf("./files/attach/images/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3));
724 724
 
725 725
 			// special character to '_'
726 726
 			// change to random file name. because window php bug. window php is not recognize unicode character file name - by cherryfilter
727
-			$ext = substr(strrchr($file_info['name'],'.'),1);
727
+			$ext = substr(strrchr($file_info['name'], '.'), 1);
728 728
 			//$_filename = preg_replace('/[#$&*?+%"\']/', '_', $file_info['name']);
729 729
 			$_filename = $random->createSecureSalt(32, 'hex').'.'.$ext;
730 730
 			$filename  = $path.$_filename;
731 731
 			$idx = 1;
732
-			while(file_exists($filename))
732
+			while (file_exists($filename))
733 733
 			{
734
-				$filename = $path.preg_replace('/\.([a-z0-9]+)$/i','_'.$idx.'.$1',$_filename);
734
+				$filename = $path.preg_replace('/\.([a-z0-9]+)$/i', '_'.$idx.'.$1', $_filename);
735 735
 				$idx++;
736 736
 			}
737 737
 			$direct_download = 'Y';
738 738
 		}
739 739
 		else
740 740
 		{
741
-			$path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3));
741
+			$path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3));
742 742
 			$filename = $path.$random->createSecureSalt(32, 'hex');
743 743
 			$direct_download = 'N';
744 744
 		}
745 745
 		// Create a directory
746
-		if(!FileHandler::makeDir($path)) return new BaseObject(-1,'msg_not_permitted_create');
746
+		if (!FileHandler::makeDir($path)) return new BaseObject(-1, 'msg_not_permitted_create');
747 747
 
748 748
 		// Check uploaded file
749
-		if(!$manual_insert && !checkUploadedFile($file_info['tmp_name']))  return new BaseObject(-1,'msg_file_upload_error');
749
+		if (!$manual_insert && !checkUploadedFile($file_info['tmp_name']))  return new BaseObject(-1, 'msg_file_upload_error');
750 750
 
751 751
 		// Get random number generator
752 752
 		$random = new Password();
753 753
 		
754 754
 		// Move the file
755
-		if($manual_insert)
755
+		if ($manual_insert)
756 756
 		{
757 757
 			@copy($file_info['tmp_name'], $filename);
758
-			if(!file_exists($filename))
758
+			if (!file_exists($filename))
759 759
 			{
760 760
 				$filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext;
761 761
 				@copy($file_info['tmp_name'], $filename);
@@ -763,10 +763,10 @@  discard block
 block discarded – undo
763 763
 		}
764 764
 		else
765 765
 		{
766
-			if(!@move_uploaded_file($file_info['tmp_name'], $filename))
766
+			if (!@move_uploaded_file($file_info['tmp_name'], $filename))
767 767
 			{
768 768
 				$filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext;
769
-				if(!@move_uploaded_file($file_info['tmp_name'], $filename))  return new BaseObject(-1,'msg_file_upload_error');
769
+				if (!@move_uploaded_file($file_info['tmp_name'], $filename))  return new BaseObject(-1, 'msg_file_upload_error');
770 770
 			}
771 771
 		}
772 772
 		// Get member information
@@ -787,10 +787,10 @@  discard block
 block discarded – undo
787 787
 		$args->sid = $random->createSecureSalt(32, 'hex');
788 788
 
789 789
 		$output = executeQuery('file.insertFile', $args);
790
-		if(!$output->toBool()) return $output;
790
+		if (!$output->toBool()) return $output;
791 791
 		// Call a trigger (after)
792 792
 		$trigger_output = ModuleHandler::triggerCall('file.insertFile', 'after', $args);
793
-		if(!$trigger_output->toBool()) return $trigger_output;
793
+		if (!$trigger_output->toBool()) return $trigger_output;
794 794
 
795 795
 		$_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true;
796 796
 
@@ -833,18 +833,18 @@  discard block
 block discarded – undo
833 833
 	 */
834 834
 	function deleteFile($file_srl)
835 835
 	{
836
-		if(!$file_srl) return;
836
+		if (!$file_srl) return;
837 837
 
838 838
 		$srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl);
839
-		if(!count($srls)) return;
839
+		if (!count($srls)) return;
840 840
 
841 841
 		$oDocumentController = getController('document');
842 842
 		$documentSrlList = array();
843 843
 
844
-		foreach($srls as $srl)
844
+		foreach ($srls as $srl)
845 845
 		{
846
-			$srl = (int)$srl;
847
-			if(!$srl) 
846
+			$srl = (int) $srl;
847
+			if (!$srl) 
848 848
 			{
849 849
 				continue;
850 850
 			}
@@ -853,14 +853,14 @@  discard block
 block discarded – undo
853 853
 			$args->file_srl = $srl;
854 854
 			$output = executeQuery('file.getFile', $args);
855 855
 
856
-			if(!$output->toBool() || !$output->data) 
856
+			if (!$output->toBool() || !$output->data) 
857 857
 			{
858 858
 				continue;
859 859
 			}
860 860
 
861 861
 			$file_info = $output->data;
862 862
 
863
-			if($file_info->upload_target_srl)
863
+			if ($file_info->upload_target_srl)
864 864
 			{
865 865
 				$documentSrlList[] = $file_info->upload_target_srl;
866 866
 			}
@@ -871,15 +871,15 @@  discard block
 block discarded – undo
871 871
 			// Call a trigger (before)
872 872
 			$trigger_obj = $output->data;
873 873
 			$output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj);
874
-			if(!$output->toBool()) return $output;
874
+			if (!$output->toBool()) return $output;
875 875
 
876 876
 			// Remove from the DB
877 877
 			$output = executeQuery('file.deleteFile', $args);
878
-			if(!$output->toBool()) return $output;
878
+			if (!$output->toBool()) return $output;
879 879
 
880 880
 			// Call a trigger (after)
881 881
 			$trigger_output = ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj);
882
-			if(!$trigger_output->toBool()) return $trigger_output;
882
+			if (!$trigger_output->toBool()) return $trigger_output;
883 883
 
884 884
 			// If successfully deleted, remove the file
885 885
 			FileHandler::removeFile($uploaded_filename);
@@ -903,28 +903,28 @@  discard block
 block discarded – undo
903 903
 		$columnList = array('file_srl', 'uploaded_filename', 'module_srl');
904 904
 		$file_list = $oFileModel->getFiles($upload_target_srl, $columnList);
905 905
 		// Success returned if no attachement exists
906
-		if(!is_array($file_list)||!count($file_list)) return new BaseObject();
906
+		if (!is_array($file_list) || !count($file_list)) return new BaseObject();
907 907
 
908 908
 		// Delete the file
909 909
 		$path = array();
910 910
 		$file_count = count($file_list);
911
-		for($i=0;$i<$file_count;$i++)
911
+		for ($i = 0; $i < $file_count; $i++)
912 912
 		{
913 913
 			$this->deleteFile($file_list[$i]->file_srl);
914 914
 
915 915
 			$uploaded_filename = $file_list[$i]->uploaded_filename;
916 916
 			$path_info = pathinfo($uploaded_filename);
917
-			if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
917
+			if (!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
918 918
 		}
919 919
 
920 920
 		// Remove from the DB
921 921
 		$args = new stdClass();
922 922
 		$args->upload_target_srl = $upload_target_srl;
923 923
 		$output = executeQuery('file.deleteFiles', $args);
924
-		if(!$output->toBool()) return $output;
924
+		if (!$output->toBool()) return $output;
925 925
 		
926 926
 		// Remove a file directory of the document
927
-		for($i=0, $c=count($path); $i<$c; $i++)
927
+		for ($i = 0, $c = count($path); $i < $c; $i++)
928 928
 		{
929 929
 			FileHandler::removeBlankDir($path[$i]);
930 930
 		}
@@ -942,23 +942,23 @@  discard block
 block discarded – undo
942 942
 	 */
943 943
 	function moveFile($source_srl, $target_module_srl, $target_srl)
944 944
 	{
945
-		if($source_srl == $target_srl) return;
945
+		if ($source_srl == $target_srl) return;
946 946
 
947 947
 		$oFileModel = getModel('file');
948 948
 		$file_list = $oFileModel->getFiles($source_srl);
949
-		if(!$file_list) return;
949
+		if (!$file_list) return;
950 950
 
951 951
 		$file_count = count($file_list);
952 952
  
953
-		for($i=0;$i<$file_count;$i++)
953
+		for ($i = 0; $i < $file_count; $i++)
954 954
 		{
955 955
 			unset($file_info);
956 956
 			$file_info = $file_list[$i];
957 957
 			$old_file = $file_info->uploaded_filename;
958 958
 			// Determine the file path by checking if the file is an image or other kinds
959
-			if(preg_match("/\.(asf|asf|asx|avi|flv|gif|jpeg|jpg|m4a|m4v|mid|midi|moov|mov|mp1|mp2|mp3|mp4|mpeg|mpg|ogg|png|qt|ra|ram|rm|rmm|wav|webm|webp|wma|wmv)$/i", $file_info->source_filename))
959
+			if (preg_match("/\.(asf|asf|asx|avi|flv|gif|jpeg|jpg|m4a|m4v|mid|midi|moov|mov|mp1|mp2|mp3|mp4|mpeg|mpg|ogg|png|qt|ra|ram|rm|rmm|wav|webm|webp|wma|wmv)$/i", $file_info->source_filename))
960 960
 			{
961
-				$path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl);
961
+				$path = sprintf("./files/attach/images/%s/%s/", $target_module_srl, $target_srl);
962 962
 				$new_file = $path.$file_info->source_filename;
963 963
 			}
964 964
 			else
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 				$new_file = $path.$random->createSecureSalt(32, 'hex');
969 969
 			}
970 970
 			// Pass if a target document to move is same
971
-			if($old_file == $new_file) continue;
971
+			if ($old_file == $new_file) continue;
972 972
 			// Create a directory
973 973
 			FileHandler::makeDir($path);
974 974
 			// Move the file
@@ -988,18 +988,18 @@  discard block
 block discarded – undo
988 988
 		$vars = Context::getRequestVars();
989 989
 		$logged_info = Context::get('logged_info');
990 990
 
991
-		if(!$vars->editor_sequence) return new BaseObject(-1, 'msg_invalid_request');
991
+		if (!$vars->editor_sequence) return new BaseObject(-1, 'msg_invalid_request');
992 992
 
993 993
 		$upload_target_srl = $_SESSION['upload_info'][$vars->editor_sequence]->upload_target_srl;
994 994
 
995 995
 		$oFileModel = getModel('file');
996 996
 		$file_info = $oFileModel->getFile($vars->file_srl);
997 997
 
998
-		if(!$file_info) return new BaseObject(-1, 'msg_not_founded');
998
+		if (!$file_info) return new BaseObject(-1, 'msg_not_founded');
999 999
 
1000
-		if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new BaseObject(-1, 'msg_not_permitted');
1000
+		if (!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new BaseObject(-1, 'msg_not_permitted');
1001 1001
 
1002
-		$args =  new stdClass();
1002
+		$args = new stdClass();
1003 1003
 		$args->file_srl = $vars->file_srl;
1004 1004
 		$args->upload_target_srl = $upload_target_srl;
1005 1005
 
@@ -1008,18 +1008,18 @@  discard block
 block discarded – undo
1008 1008
 		
1009 1009
 		$args->cover_image = 'N';
1010 1010
 		$output = executeQuery('file.updateClearCoverImage', $args);
1011
-		if(!$output->toBool())
1011
+		if (!$output->toBool())
1012 1012
 		{
1013 1013
 				$oDB->rollback();
1014 1014
 				return $output;
1015 1015
 		}
1016 1016
 
1017
-		if($file_info->cover_image != 'Y')
1017
+		if ($file_info->cover_image != 'Y')
1018 1018
 		{
1019 1019
 
1020 1020
 			$args->cover_image = 'Y';
1021 1021
 			$output = executeQuery('file.updateCoverImage', $args);
1022
-			if(!$output->toBool())
1022
+			if (!$output->toBool())
1023 1023
 			{
1024 1024
 				$oDB->rollback();
1025 1025
 				return $output;
@@ -1029,7 +1029,7 @@  discard block
 block discarded – undo
1029 1029
 
1030 1030
 		$oDB->commit();
1031 1031
 
1032
-		$this->add('is_cover',$args->cover_image);
1032
+		$this->add('is_cover', $args->cover_image);
1033 1033
 
1034 1034
 		// 썸네일 삭제
1035 1035
 		$thumbnail_path = sprintf('files/thumbnails/%s', getNumberingPath($upload_target_srl, 3));
@@ -1055,9 +1055,9 @@  discard block
 block discarded – undo
1055 1055
 		$fileConfig = $oModuleModel->getModulePartConfig('file', $obj->originModuleSrl);
1056 1056
 
1057 1057
 		$oModuleController = getController('module');
1058
-		if(is_array($obj->moduleSrlList))
1058
+		if (is_array($obj->moduleSrlList))
1059 1059
 		{
1060
-			foreach($obj->moduleSrlList AS $key=>$moduleSrl)
1060
+			foreach ($obj->moduleSrlList AS $key=>$moduleSrl)
1061 1061
 			{
1062 1062
 				$oModuleController->insertModulePartConfig('file', $moduleSrl, $fileConfig);
1063 1063
 			}
Please login to merge, or discard this patch.
Braces   +229 added lines, -95 removed lines patch added patch discarded remove patch
@@ -29,20 +29,30 @@  discard block
 block discarded – undo
29 29
 		$file_info = Context::get('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');
@@ -52,7 +62,9 @@  discard block
 block discarded – undo
52 62
 		$this->add('source_filename',$output->get('source_filename'));
53 63
 		$this->add('download_url',$output->get('uploaded_filename'));
54 64
 		$this->add('upload_target_srl',$output->get('upload_target_srl'));
55
-		if($output->error != '0') $this->stop($output->message);
65
+		if($output->error != '0') {
66
+			$this->stop($output->message);
67
+		}
56 68
 	}
57 69
 
58 70
 	/**
@@ -67,14 +79,22 @@  discard block
 block discarded – undo
67 79
 		$callback = Context::get('callback');
68 80
 		$module_srl = $this->module_srl;
69 81
 		$upload_target_srl = intval(Context::get('uploadTargetSrl'));
70
-		if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl'));
82
+		if(!$upload_target_srl) {
83
+			$upload_target_srl = intval(Context::get('upload_target_srl'));
84
+		}
71 85
 
72 86
 		// Exit a session if there is neither upload permission nor information
73
-		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
87
+		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) {
88
+			exit();
89
+		}
74 90
 		// Extract from session information if upload_target_srl is not specified
75
-		if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
91
+		if(!$upload_target_srl) {
92
+			$upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
93
+		}
76 94
 		// Create if upload_target_srl is not defined in the session information
77
-		if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
95
+		if(!$upload_target_srl) {
96
+			$_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
97
+		}
78 98
 
79 99
 		// Delete and then attempt to re-upload if file_srl is requested
80 100
 		$file_srl = Context::get('file_srl');
@@ -129,15 +149,16 @@  discard block
 block discarded – undo
129 149
 		$source_src = $fileInfo->uploaded_filename;
130 150
 		$output_src = $source_src . '.resized' . strrchr($source_src,'.');
131 151
 
132
-		if(!$height) $height = $width-1;
152
+		if(!$height) {
153
+			$height = $width-1;
154
+		}
133 155
 
134 156
 		if(FileHandler::createImageFile($source_src,$output_src,$width,$height,'','ratio'))
135 157
 		{
136 158
 			$output = new stdClass();
137 159
 			$output->info = getimagesize($output_src);
138 160
 			$output->src = $output_src;
139
-		}
140
-		else
161
+		} else
141 162
 		{
142 163
 			return new BaseObject(-1,'msg_invalid_request');
143 164
 		}
@@ -180,7 +201,9 @@  discard block
 block discarded – undo
180 201
 	{
181 202
 		$oFileModel = getModel('file');
182 203
 
183
-		if(isset($this->grant->access) && $this->grant->access !== true) return new BaseObject(-1, 'msg_not_permitted');
204
+		if(isset($this->grant->access) && $this->grant->access !== true) {
205
+			return new BaseObject(-1, 'msg_not_permitted');
206
+		}
184 207
 
185 208
 		$file_srl = Context::get('file_srl');
186 209
 		$sid = Context::get('sid');
@@ -189,9 +212,13 @@  discard block
 block discarded – undo
189 212
 		$columnList = array('file_srl', 'sid', 'isvalid', 'source_filename', 'module_srl', 'uploaded_filename', 'file_size', 'member_srl', 'upload_target_srl', 'upload_target_type');
190 213
 		$file_obj = $oFileModel->getFile($file_srl, $columnList);
191 214
 		// If the requested file information is incorrect, an error that file cannot be found appears
192
-		if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) return $this->stop('msg_file_not_found');
215
+		if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) {
216
+			return $this->stop('msg_file_not_found');
217
+		}
193 218
 		// Notify that file download is not allowed when standing-by(Only a top-administrator is permitted)
194
-		if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') return $this->stop('msg_not_permitted_download');
219
+		if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') {
220
+			return $this->stop('msg_not_permitted_download');
221
+		}
195 222
 		// File name
196 223
 		$filename = $file_obj->source_filename;
197 224
 		$file_module_config = $oFileModel->getFileModuleConfig($file_obj->module_srl);
@@ -203,7 +230,9 @@  discard block
 block discarded – undo
203 230
 			{
204 231
 				$allow_outlink_format_array = array();
205 232
 				$allow_outlink_format_array = explode(',', $file_module_config->allow_outlink_format);
206
-				if(!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format;
233
+				if(!is_array($allow_outlink_format_array)) {
234
+					$allow_outlink_format_array[0] = $file_module_config->allow_outlink_format;
235
+				}
207 236
 
208 237
 				foreach($allow_outlink_format_array as $val)
209 238
 				{
@@ -225,7 +254,9 @@  discard block
 block discarded – undo
225 254
 					{
226 255
 						$allow_outlink_site_array = array();
227 256
 						$allow_outlink_site_array = explode("\n", $file_module_config->allow_outlink_site);
228
-						if(!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site;
257
+						if(!is_array($allow_outlink_site_array)) {
258
+							$allow_outlink_site_array[0] = $file_module_config->allow_outlink_site;
259
+						}
229 260
 
230 261
 						foreach($allow_outlink_site_array as $val)
231 262
 						{
@@ -237,23 +268,29 @@  discard block
 block discarded – undo
237 268
 							}
238 269
 						}
239 270
 					}
271
+				} else {
272
+					$file_module_config->allow_outlink = 'Y';
240 273
 				}
241
-				else $file_module_config->allow_outlink = 'Y';
242 274
 			}
243
-			if($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink');
275
+			if($file_module_config->allow_outlink != 'Y') {
276
+				return $this->stop('msg_not_allowed_outlink');
277
+			}
244 278
 		}
245 279
 
246 280
 		// Check if a permission for file download is granted
247 281
 		$downloadGrantCount = 0;
248 282
 		if(is_array($file_module_config->download_grant))
249 283
 		{
250
-			foreach($file_module_config->download_grant AS $value)
251
-				if($value) $downloadGrantCount++;
284
+			foreach($file_module_config->download_grant AS $value) {
285
+							if($value) $downloadGrantCount++;
286
+			}
252 287
 		}
253 288
 
254 289
 		if(is_array($file_module_config->download_grant) && $downloadGrantCount>0)
255 290
 		{
256
-			if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download');
291
+			if(!Context::get('is_logged')) {
292
+				return $this->stop('msg_not_permitted_download');
293
+			}
257 294
 			$logged_info = Context::get('logged_info');
258 295
 			if($logged_info->is_admin != 'Y')
259 296
 			{
@@ -276,13 +313,17 @@  discard block
 block discarded – undo
276 313
 							break;
277 314
 						}
278 315
 					}
279
-					if(!$is_permitted) return $this->stop('msg_not_permitted_download');
316
+					if(!$is_permitted) {
317
+						return $this->stop('msg_not_permitted_download');
318
+					}
280 319
 				}
281 320
 			}
282 321
 		}
283 322
 		// Call a trigger (before)
284 323
 		$output = ModuleHandler::triggerCall('file.downloadFile', 'before', $file_obj);
285
-		if(!$output->toBool()) return $this->stop(($output->message)?$output->message:'msg_not_permitted_download');
324
+		if(!$output->toBool()) {
325
+			return $this->stop(($output->message)?$output->message:'msg_not_permitted_download');
326
+		}
286 327
 
287 328
 
288 329
 		// 다운로드 후 (가상)
@@ -306,16 +347,23 @@  discard block
 block discarded – undo
306 347
 		$oFileModel = getModel('file');
307 348
 		$file_srl = Context::get('file_srl');
308 349
 		$file_key = Context::get('file_key');
309
-		if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true;
350
+		if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) {
351
+			$is_android = true;
352
+		}
310 353
 
311
-		if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__';
312
-		else $session_key = '__XE_FILE_KEY__';
354
+		if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) {
355
+			$session_key = '__XE_FILE_KEY_AND__';
356
+		} else {
357
+			$session_key = '__XE_FILE_KEY__';
358
+		}
313 359
 		$columnList = array('source_filename', 'uploaded_filename', 'file_size');
314 360
 		$file_obj = $oFileModel->getFile($file_srl, $columnList);
315 361
 
316 362
 		$uploaded_filename = $file_obj->uploaded_filename;
317 363
 
318
-		if(!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found');
364
+		if(!file_exists($uploaded_filename)) {
365
+			return $this->stop('msg_file_not_found');
366
+		}
319 367
 
320 368
 		if(!$file_key || $_SESSION[$session_key][$file_srl] != $file_key)
321 369
 		{
@@ -331,29 +379,27 @@  discard block
 block discarded – undo
331 379
 			if($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT']))
332 380
 			{
333 381
 				$filename_param = 'filename="' . $filename . '"';
334
-			}
335
-			else
382
+			} else
336 383
 			{
337 384
 				$filename_param = sprintf('filename="%s"; filename*=UTF-8\'\'%s', $filename, rawurlencode($filename));
338 385
 			}
339
-		}
340
-		elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6)
386
+		} elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6)
341 387
 		{
342 388
 			$filename_param = sprintf('filename="%s"; filename*=UTF-8\'\'%s', $filename, rawurlencode($filename));
343
-		}
344
-		elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
389
+		} elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
345 390
 		{
346 391
 			$filename = rawurlencode($filename);
347 392
 			$filename_param = 'filename="' . preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1) . '"';
348
-		}
349
-		else
393
+		} else
350 394
 		{
351 395
 			$filename_param = 'filename="' . $filename . '"';
352 396
 		}
353 397
 
354 398
 		if($is_android)
355 399
 		{
356
-			if($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key;
400
+			if($_SESSION['__XE_FILE_KEY__'][$file_srl]) {
401
+				$_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key;
402
+			}
357 403
 		}
358 404
 
359 405
 		unset($_SESSION[$session_key][$file_srl]);
@@ -361,7 +407,9 @@  discard block
 block discarded – undo
361 407
 		Context::close();
362 408
 
363 409
 		$fp = fopen($uploaded_filename, 'rb');
364
-		if(!$fp) return $this->stop('msg_file_not_found');
410
+		if(!$fp) {
411
+			return $this->stop('msg_file_not_found');
412
+		}
365 413
 
366 414
 		header("Cache-Control: ");
367 415
 		header("Pragma: ");
@@ -375,10 +423,11 @@  discard block
 block discarded – undo
375 423
 		// if file size is lager than 10MB, use fread function (#18675748)
376 424
 		if($file_size > 1024 * 1024)
377 425
 		{
378
-			while(!feof($fp)) echo fread($fp, 1024);
426
+			while(!feof($fp)) {
427
+				echo fread($fp, 1024);
428
+			}
379 429
 			fclose($fp);
380
-		}
381
-		else
430
+		} else
382 431
 		{
383 432
 			fpassthru($fp);
384 433
 		}
@@ -397,9 +446,13 @@  discard block
 block discarded – undo
397 446
 		$editor_sequence = Context::get('editor_sequence');
398 447
 		$file_srl = Context::get('file_srl');
399 448
 		$file_srls = Context::get('file_srls');
400
-		if($file_srls) $file_srl = $file_srls;
449
+		if($file_srls) {
450
+			$file_srl = $file_srls;
451
+		}
401 452
 		// Exit a session if there is neither upload permission nor information
402
-		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
453
+		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) {
454
+			exit();
455
+		}
403 456
 
404 457
 		$upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
405 458
 
@@ -407,26 +460,38 @@  discard block
 block discarded – undo
407 460
 		$oFileModel = getModel('file');
408 461
 
409 462
 		$srls = explode(',',$file_srl);
410
-		if(!count($srls)) return;
463
+		if(!count($srls)) {
464
+			return;
465
+		}
411 466
 
412 467
 		for($i=0;$i<count($srls);$i++)
413 468
 		{
414 469
 			$srl = (int)$srls[$i];
415
-			if(!$srl) continue;
470
+			if(!$srl) {
471
+				continue;
472
+			}
416 473
 
417 474
 			$args = new stdClass;
418 475
 			$args->file_srl = $srl;
419 476
 			$output = executeQuery('file.getFile', $args);
420
-			if(!$output->toBool()) continue;
477
+			if(!$output->toBool()) {
478
+				continue;
479
+			}
421 480
 
422 481
 			$file_info = $output->data;
423
-			if(!$file_info) continue;
482
+			if(!$file_info) {
483
+				continue;
484
+			}
424 485
 
425 486
 			$file_grant = $oFileModel->getFileGrant($file_info, $logged_info);
426 487
 
427
-			if(!$file_grant->is_deletable) continue;
488
+			if(!$file_grant->is_deletable) {
489
+				continue;
490
+			}
428 491
 
429
-			if($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl);
492
+			if($upload_target_srl && $file_srl) {
493
+				$output = $this->deleteFile($file_srl);
494
+			}
430 495
 		}
431 496
 	}
432 497
 
@@ -437,7 +502,9 @@  discard block
 block discarded – undo
437 502
 	 */
438 503
 	function procFileGetList()
439 504
 	{
440
-		if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted');
505
+		if(!Context::get('is_logged')) {
506
+			return new BaseObject(-1,'msg_not_permitted');
507
+		}
441 508
 
442 509
 		$oModuleModel = getModel('module');
443 510
 
@@ -448,26 +515,32 @@  discard block
 block discarded – undo
448 515
 		}
449 516
 
450 517
 		$fileSrls = Context::get('file_srls');
451
-		if($fileSrls) $fileSrlList = explode(',', $fileSrls);
518
+		if($fileSrls) {
519
+			$fileSrlList = explode(',', $fileSrls);
520
+		}
452 521
 
453 522
 		global $lang;
454 523
 		if(count($fileSrlList) > 0)
455 524
 		{
456 525
 			$oFileModel = getModel('file');
457 526
 			$fileList = $oFileModel->getFile($fileSrlList);
458
-			if(!is_array($fileList)) $fileList = array($fileList);
527
+			if(!is_array($fileList)) {
528
+				$fileList = array($fileList);
529
+			}
459 530
 
460 531
 			if(is_array($fileList))
461 532
 			{
462 533
 				foreach($fileList AS $key=>$value)
463 534
 				{
464 535
 					$value->human_file_size = FileHandler::filesize($value->file_size);
465
-					if($value->isvalid=='Y') $value->validName = $lang->is_valid;
466
-					else $value->validName = $lang->is_stand_by;
536
+					if($value->isvalid=='Y') {
537
+						$value->validName = $lang->is_valid;
538
+					} else {
539
+						$value->validName = $lang->is_stand_by;
540
+					}
467 541
 				}
468 542
 			}
469
-		}
470
-		else
543
+		} else
471 544
 		{
472 545
 			$fileList = array();
473 546
 			$this->setMessage($lang->no_files);
@@ -484,7 +557,9 @@  discard block
 block discarded – undo
484 557
 	function triggerCheckAttached(&$obj)
485 558
 	{
486 559
 		$document_srl = $obj->document_srl;
487
-		if(!$document_srl) return new BaseObject();
560
+		if(!$document_srl) {
561
+			return new BaseObject();
562
+		}
488 563
 		// Get numbers of attachments
489 564
 		$oFileModel = getModel('file');
490 565
 		$obj->uploaded_count = $oFileModel->getFilesCount($document_srl);
@@ -501,10 +576,14 @@  discard block
 block discarded – undo
501 576
 	function triggerAttachFiles(&$obj)
502 577
 	{
503 578
 		$document_srl = $obj->document_srl;
504
-		if(!$document_srl) return new BaseObject();
579
+		if(!$document_srl) {
580
+			return new BaseObject();
581
+		}
505 582
 
506 583
 		$output = $this->setFilesValid($document_srl);
507
-		if(!$output->toBool()) return $output;
584
+		if(!$output->toBool()) {
585
+			return $output;
586
+		}
508 587
 
509 588
 		return new BaseObject();
510 589
 	}
@@ -518,7 +597,9 @@  discard block
 block discarded – undo
518 597
 	function triggerDeleteAttached(&$obj)
519 598
 	{
520 599
 		$document_srl = $obj->document_srl;
521
-		if(!$document_srl) return new BaseObject();
600
+		if(!$document_srl) {
601
+			return new BaseObject();
602
+		}
522 603
 
523 604
 		$output = $this->deleteFiles($document_srl);
524 605
 		return $output;
@@ -533,7 +614,9 @@  discard block
 block discarded – undo
533 614
 	function triggerCommentCheckAttached(&$obj)
534 615
 	{
535 616
 		$comment_srl = $obj->comment_srl;
536
-		if(!$comment_srl) return new BaseObject();
617
+		if(!$comment_srl) {
618
+			return new BaseObject();
619
+		}
537 620
 		// Get numbers of attachments
538 621
 		$oFileModel = getModel('file');
539 622
 		$obj->uploaded_count = $oFileModel->getFilesCount($comment_srl);
@@ -551,10 +634,14 @@  discard block
 block discarded – undo
551 634
 	{
552 635
 		$comment_srl = $obj->comment_srl;
553 636
 		$uploaded_count = $obj->uploaded_count;
554
-		if(!$comment_srl || !$uploaded_count) return new BaseObject();
637
+		if(!$comment_srl || !$uploaded_count) {
638
+			return new BaseObject();
639
+		}
555 640
 
556 641
 		$output = $this->setFilesValid($comment_srl);
557
-		if(!$output->toBool()) return $output;
642
+		if(!$output->toBool()) {
643
+			return $output;
644
+		}
558 645
 
559 646
 		return new BaseObject();
560 647
 	}
@@ -568,9 +655,13 @@  discard block
 block discarded – undo
568 655
 	function triggerCommentDeleteAttached(&$obj)
569 656
 	{
570 657
 		$comment_srl = $obj->comment_srl;
571
-		if(!$comment_srl) return new BaseObject();
658
+		if(!$comment_srl) {
659
+			return new BaseObject();
660
+		}
572 661
 
573
-		if($obj->isMoveToTrash) return new BaseObject();
662
+		if($obj->isMoveToTrash) {
663
+			return new BaseObject();
664
+		}
574 665
 
575 666
 		$output = $this->deleteFiles($comment_srl);
576 667
 		return $output;
@@ -585,7 +676,9 @@  discard block
 block discarded – undo
585 676
 	function triggerDeleteModuleFiles(&$obj)
586 677
 	{
587 678
 		$module_srl = $obj->module_srl;
588
-		if(!$module_srl) return new BaseObject();
679
+		if(!$module_srl) {
680
+			return new BaseObject();
681
+		}
589 682
 
590 683
 		$oFileController = getAdminController('file');
591 684
 		return $oFileController->deleteModuleFiles($module_srl);
@@ -660,7 +753,9 @@  discard block
 block discarded – undo
660 753
 		$trigger_obj->module_srl = $module_srl;
661 754
 		$trigger_obj->upload_target_srl = $upload_target_srl;
662 755
 		$output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj);
663
-		if(!$output->toBool()) return $output;
756
+		if(!$output->toBool()) {
757
+			return $output;
758
+		}
664 759
 
665 760
 		// A workaround for Firefox upload bug
666 761
 		if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match))
@@ -698,13 +793,17 @@  discard block
 block discarded – undo
698 793
 				$allowed_filesize = $config->allowed_filesize * 1024 * 1024;
699 794
 				$allowed_attach_size = $config->allowed_attach_size * 1024 * 1024;
700 795
 				// An error appears if file size exceeds a limit
701
-				if($allowed_filesize < filesize($file_info['tmp_name'])) return new BaseObject(-1, 'msg_exceeds_limit_size');
796
+				if($allowed_filesize < filesize($file_info['tmp_name'])) {
797
+					return new BaseObject(-1, 'msg_exceeds_limit_size');
798
+				}
702 799
 				// Get total file size of all attachements (from DB)
703 800
 				$size_args = new stdClass;
704 801
 				$size_args->upload_target_srl = $upload_target_srl;
705 802
 				$output = executeQuery('file.getAttachedFileSize', $size_args);
706 803
 				$attached_size = (int)$output->data->attached_size + filesize($file_info['tmp_name']);
707
-				if($attached_size > $allowed_attach_size) return new BaseObject(-1, 'msg_exceeds_limit_size');
804
+				if($attached_size > $allowed_attach_size) {
805
+					return new BaseObject(-1, 'msg_exceeds_limit_size');
806
+				}
708 807
 			}
709 808
 		}
710 809
 
@@ -735,18 +834,21 @@  discard block
 block discarded – undo
735 834
 				$idx++;
736 835
 			}
737 836
 			$direct_download = 'Y';
738
-		}
739
-		else
837
+		} else
740 838
 		{
741 839
 			$path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3));
742 840
 			$filename = $path.$random->createSecureSalt(32, 'hex');
743 841
 			$direct_download = 'N';
744 842
 		}
745 843
 		// Create a directory
746
-		if(!FileHandler::makeDir($path)) return new BaseObject(-1,'msg_not_permitted_create');
844
+		if(!FileHandler::makeDir($path)) {
845
+			return new BaseObject(-1,'msg_not_permitted_create');
846
+		}
747 847
 
748 848
 		// Check uploaded file
749
-		if(!$manual_insert && !checkUploadedFile($file_info['tmp_name']))  return new BaseObject(-1,'msg_file_upload_error');
849
+		if(!$manual_insert && !checkUploadedFile($file_info['tmp_name'])) {
850
+			return new BaseObject(-1,'msg_file_upload_error');
851
+		}
750 852
 
751 853
 		// Get random number generator
752 854
 		$random = new Password();
@@ -760,13 +862,14 @@  discard block
 block discarded – undo
760 862
 				$filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext;
761 863
 				@copy($file_info['tmp_name'], $filename);
762 864
 			}
763
-		}
764
-		else
865
+		} else
765 866
 		{
766 867
 			if(!@move_uploaded_file($file_info['tmp_name'], $filename))
767 868
 			{
768 869
 				$filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext;
769
-				if(!@move_uploaded_file($file_info['tmp_name'], $filename))  return new BaseObject(-1,'msg_file_upload_error');
870
+				if(!@move_uploaded_file($file_info['tmp_name'], $filename)) {
871
+					return new BaseObject(-1,'msg_file_upload_error');
872
+				}
770 873
 			}
771 874
 		}
772 875
 		// Get member information
@@ -787,10 +890,14 @@  discard block
 block discarded – undo
787 890
 		$args->sid = $random->createSecureSalt(32, 'hex');
788 891
 
789 892
 		$output = executeQuery('file.insertFile', $args);
790
-		if(!$output->toBool()) return $output;
893
+		if(!$output->toBool()) {
894
+			return $output;
895
+		}
791 896
 		// Call a trigger (after)
792 897
 		$trigger_output = ModuleHandler::triggerCall('file.insertFile', 'after', $args);
793
-		if(!$trigger_output->toBool()) return $trigger_output;
898
+		if(!$trigger_output->toBool()) {
899
+			return $trigger_output;
900
+		}
794 901
 
795 902
 		$_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true;
796 903
 
@@ -833,10 +940,14 @@  discard block
 block discarded – undo
833 940
 	 */
834 941
 	function deleteFile($file_srl)
835 942
 	{
836
-		if(!$file_srl) return;
943
+		if(!$file_srl) {
944
+			return;
945
+		}
837 946
 
838 947
 		$srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl);
839
-		if(!count($srls)) return;
948
+		if(!count($srls)) {
949
+			return;
950
+		}
840 951
 
841 952
 		$oDocumentController = getController('document');
842 953
 		$documentSrlList = array();
@@ -871,15 +982,21 @@  discard block
 block discarded – undo
871 982
 			// Call a trigger (before)
872 983
 			$trigger_obj = $output->data;
873 984
 			$output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj);
874
-			if(!$output->toBool()) return $output;
985
+			if(!$output->toBool()) {
986
+				return $output;
987
+			}
875 988
 
876 989
 			// Remove from the DB
877 990
 			$output = executeQuery('file.deleteFile', $args);
878
-			if(!$output->toBool()) return $output;
991
+			if(!$output->toBool()) {
992
+				return $output;
993
+			}
879 994
 
880 995
 			// Call a trigger (after)
881 996
 			$trigger_output = ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj);
882
-			if(!$trigger_output->toBool()) return $trigger_output;
997
+			if(!$trigger_output->toBool()) {
998
+				return $trigger_output;
999
+			}
883 1000
 
884 1001
 			// If successfully deleted, remove the file
885 1002
 			FileHandler::removeFile($uploaded_filename);
@@ -903,7 +1020,9 @@  discard block
 block discarded – undo
903 1020
 		$columnList = array('file_srl', 'uploaded_filename', 'module_srl');
904 1021
 		$file_list = $oFileModel->getFiles($upload_target_srl, $columnList);
905 1022
 		// Success returned if no attachement exists
906
-		if(!is_array($file_list)||!count($file_list)) return new BaseObject();
1023
+		if(!is_array($file_list)||!count($file_list)) {
1024
+			return new BaseObject();
1025
+		}
907 1026
 
908 1027
 		// Delete the file
909 1028
 		$path = array();
@@ -914,14 +1033,18 @@  discard block
 block discarded – undo
914 1033
 
915 1034
 			$uploaded_filename = $file_list[$i]->uploaded_filename;
916 1035
 			$path_info = pathinfo($uploaded_filename);
917
-			if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
1036
+			if(!in_array($path_info['dirname'], $path)) {
1037
+				$path[] = $path_info['dirname'];
1038
+			}
918 1039
 		}
919 1040
 
920 1041
 		// Remove from the DB
921 1042
 		$args = new stdClass();
922 1043
 		$args->upload_target_srl = $upload_target_srl;
923 1044
 		$output = executeQuery('file.deleteFiles', $args);
924
-		if(!$output->toBool()) return $output;
1045
+		if(!$output->toBool()) {
1046
+			return $output;
1047
+		}
925 1048
 		
926 1049
 		// Remove a file directory of the document
927 1050
 		for($i=0, $c=count($path); $i<$c; $i++)
@@ -942,11 +1065,15 @@  discard block
 block discarded – undo
942 1065
 	 */
943 1066
 	function moveFile($source_srl, $target_module_srl, $target_srl)
944 1067
 	{
945
-		if($source_srl == $target_srl) return;
1068
+		if($source_srl == $target_srl) {
1069
+			return;
1070
+		}
946 1071
 
947 1072
 		$oFileModel = getModel('file');
948 1073
 		$file_list = $oFileModel->getFiles($source_srl);
949
-		if(!$file_list) return;
1074
+		if(!$file_list) {
1075
+			return;
1076
+		}
950 1077
 
951 1078
 		$file_count = count($file_list);
952 1079
  
@@ -960,15 +1087,16 @@  discard block
 block discarded – undo
960 1087
 			{
961 1088
 				$path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl);
962 1089
 				$new_file = $path.$file_info->source_filename;
963
-			}
964
-			else
1090
+			} else
965 1091
 			{
966 1092
 				$path = sprintf("./files/attach/binaries/%s/%s/", $target_module_srl, $target_srl);
967 1093
 				$random = new Password();
968 1094
 				$new_file = $path.$random->createSecureSalt(32, 'hex');
969 1095
 			}
970 1096
 			// Pass if a target document to move is same
971
-			if($old_file == $new_file) continue;
1097
+			if($old_file == $new_file) {
1098
+				continue;
1099
+			}
972 1100
 			// Create a directory
973 1101
 			FileHandler::makeDir($path);
974 1102
 			// Move the file
@@ -988,16 +1116,22 @@  discard block
 block discarded – undo
988 1116
 		$vars = Context::getRequestVars();
989 1117
 		$logged_info = Context::get('logged_info');
990 1118
 
991
-		if(!$vars->editor_sequence) return new BaseObject(-1, 'msg_invalid_request');
1119
+		if(!$vars->editor_sequence) {
1120
+			return new BaseObject(-1, 'msg_invalid_request');
1121
+		}
992 1122
 
993 1123
 		$upload_target_srl = $_SESSION['upload_info'][$vars->editor_sequence]->upload_target_srl;
994 1124
 
995 1125
 		$oFileModel = getModel('file');
996 1126
 		$file_info = $oFileModel->getFile($vars->file_srl);
997 1127
 
998
-		if(!$file_info) return new BaseObject(-1, 'msg_not_founded');
1128
+		if(!$file_info) {
1129
+			return new BaseObject(-1, 'msg_not_founded');
1130
+		}
999 1131
 
1000
-		if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new BaseObject(-1, 'msg_not_permitted');
1132
+		if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) {
1133
+			return new BaseObject(-1, 'msg_not_permitted');
1134
+		}
1001 1135
 
1002 1136
 		$args =  new stdClass();
1003 1137
 		$args->file_srl = $vars->file_srl;
Please login to merge, or discard this patch.