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 ( c84ca2...51d075 )
by gyeong-won
07:46
created
modules/importer/ttimport.class.php 1 patch
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @param string $module_name
32 32
 	 * @return int
33 33
 	 */
34
-	function importModule($key, $cur, $index_file, $unit_count, $module_srl, $guestbook_module_srl, $user_id, $module_name=null)
34
+	function importModule($key, $cur, $index_file, $unit_count, $module_srl, $guestbook_module_srl, $user_id, $module_name = null)
35 35
 	{
36 36
 		// Pre-create the objects needed
37 37
 		$this->oXmlParser = new XmlParser();
@@ -40,33 +40,33 @@  discard block
 block discarded – undo
40 40
 		$oDocumentModel = getModel('document');
41 41
 		$category_list = $category_titles = array();
42 42
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
43
-		if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
43
+		if (count($category_list)) foreach ($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
44 44
 		// First handle categorty information
45 45
 		$category_file = preg_replace('/index$/i', 'category.xml', $index_file);
46
-		if(file_exists($category_file))
46
+		if (file_exists($category_file))
47 47
 		{
48 48
 			// Create the xmlParser object
49 49
 			$xmlDoc = $this->oXmlParser->loadXmlFile($category_file);
50 50
 			// List category information
51
-			if($xmlDoc->categories->category)
51
+			if ($xmlDoc->categories->category)
52 52
 			{
53 53
 				$categories = array();
54 54
 				$idx = 0;
55 55
 				$this->arrangeCategory($xmlDoc->categories, $categories, $idx, 0);
56 56
 
57 57
 				$match_sequence = array();
58
-				foreach($categories as $k => $v)
58
+				foreach ($categories as $k => $v)
59 59
 				{
60 60
 					$category = $v->name;
61
-					if(!$category || $category_titles[$category]) continue;
61
+					if (!$category || $category_titles[$category]) continue;
62 62
 
63 63
 					$obj = null;
64 64
 					$obj->title = $category;
65 65
 					$obj->module_srl = $module_srl; 
66
-					if($v->parent) $obj->parent_srl = $match_sequence[$v->parent];
66
+					if ($v->parent) $obj->parent_srl = $match_sequence[$v->parent];
67 67
 					$output = $oDocumentController->insertCategory($obj);
68 68
 
69
-					if($output->toBool()) $match_sequence[$v->sequence] = $category_titles[$category] = $output->get('category_srl');
69
+					if ($output->toBool()) $match_sequence[$v->sequence] = $category_titles[$category] = $output->get('category_srl');
70 70
 				}
71 71
 				$oDocumentController->makeCategoryFile($module_srl);
72 72
 			}
@@ -74,28 +74,28 @@  discard block
 block discarded – undo
74 74
 		}
75 75
 		$category_list = $category_titles = array();
76 76
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
77
-		if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
77
+		if (count($category_list)) foreach ($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
78 78
 		// Get administrator information
79 79
 		$oMemberModel = getModel('member');
80 80
 		$member_info = $oMemberModel->getMemberInfoByUserID($user_id);
81 81
 		$author_xml_id = 0;
82 82
 
83
-		if(!$cur) $cur = 0;
83
+		if (!$cur) $cur = 0;
84 84
 		// Open an index file
85
-		$f = fopen($index_file,"r");
85
+		$f = fopen($index_file, "r");
86 86
 		// Pass if already read
87
-		for($i=0;$i<$cur;$i++) fgets($f, 1024);
87
+		for ($i = 0; $i < $cur; $i++) fgets($f, 1024);
88 88
 		// Read each line until the codition meets
89
-		for($idx=$cur;$idx<$cur+$unit_count;$idx++)
89
+		for ($idx = $cur; $idx < $cur + $unit_count; $idx++)
90 90
 		{
91
-			if(feof($f)) break;
91
+			if (feof($f)) break;
92 92
 			// Find a location
93 93
 			$target_file = trim(fgets($f, 1024));
94 94
 
95
-			if(!file_exists($target_file)) continue;
95
+			if (!file_exists($target_file)) continue;
96 96
 			// Start importing data
97
-			$fp = fopen($target_file,"r");
98
-			if(!$fp) continue;
97
+			$fp = fopen($target_file, "r");
98
+			if (!$fp) continue;
99 99
 
100 100
 			$obj = null;
101 101
 			$obj->module_srl = $module_srl;
@@ -107,57 +107,57 @@  discard block
 block discarded – undo
107 107
 			$started = false;
108 108
 			$buff = null;
109 109
 			// Start importing from the body data
110
-			while(!feof($fp))
110
+			while (!feof($fp))
111 111
 			{
112 112
 				$str = fgets($fp, 1024);
113 113
 				// Prepare an item
114
-				if(substr($str,0,5) == '<post')
114
+				if (substr($str, 0, 5) == '<post')
115 115
 				{
116 116
 					$started = true;
117 117
 					continue;
118 118
 					// Import the attachment
119 119
 				}
120
-				else if(substr($str,0,12) == '<attachment ')
120
+				else if (substr($str, 0, 12) == '<attachment ')
121 121
 				{
122
-					if($this->importAttaches($fp, $module_srl, $obj->document_srl, $files, $str)) $obj->uploaded_count++;
122
+					if ($this->importAttaches($fp, $module_srl, $obj->document_srl, $files, $str)) $obj->uploaded_count++;
123 123
 					continue;
124 124
 				}
125 125
 
126
-				if($started) $buff .= $str;
126
+				if ($started) $buff .= $str;
127 127
 			}
128 128
 
129 129
 			$xmlDoc = $this->oXmlParser->parse('<post>'.$buff);
130 130
 
131 131
 			$author_xml_id = $xmlDoc->post->author->body;
132 132
 
133
-			if($xmlDoc->post->category->body)
133
+			if ($xmlDoc->post->category->body)
134 134
 			{
135
-				$tmp_arr = explode('/',$xmlDoc->post->category->body);
136
-				$category = trim($tmp_arr[count($tmp_arr)-1]);
137
-				if($category_titles[$category]) $obj->category_srl = $category_titles[$category];
135
+				$tmp_arr = explode('/', $xmlDoc->post->category->body);
136
+				$category = trim($tmp_arr[count($tmp_arr) - 1]);
137
+				if ($category_titles[$category]) $obj->category_srl = $category_titles[$category];
138 138
 			}
139 139
 
140 140
 			$obj->is_notice = 'N';
141
-			$obj->status = in_array($xmlDoc->post->visibility->body, array('public','syndicated'))?$oDocumentModel->getConfigStatus('public'):$oDocumentModel->getConfigStatus('secret');
141
+			$obj->status = in_array($xmlDoc->post->visibility->body, array('public', 'syndicated')) ? $oDocumentModel->getConfigStatus('public') : $oDocumentModel->getConfigStatus('secret');
142 142
 			$obj->title = $xmlDoc->post->title->body;
143 143
 			$obj->content = $xmlDoc->post->content->body;
144 144
 			$obj->password = md5($xmlDoc->post->password->body);
145
-			$obj->commentStatus = $xmlDoc->post->acceptcomment->body=='1'?'ALLOW':'DENY';
146
-			$obj->allow_trackback = $xmlDoc->post->accepttrackback->body=='1'?'Y':'N';
145
+			$obj->commentStatus = $xmlDoc->post->acceptcomment->body == '1' ? 'ALLOW' : 'DENY';
146
+			$obj->allow_trackback = $xmlDoc->post->accepttrackback->body == '1' ? 'Y' : 'N';
147 147
 			//$obj->allow_comment = $xmlDoc->post->acceptComment->body=='1'?'Y':'N';
148 148
 			//$obj->allow_trackback = $xmlDoc->post->acceptTrackback->body=='1'?'Y':'N';
149
-			$obj->regdate = date("YmdHis",$xmlDoc->post->published->body);
149
+			$obj->regdate = date("YmdHis", $xmlDoc->post->published->body);
150 150
 			$obj->last_update = date("YmdHis", $xmlDoc->post->modified->body);
151
-			if(!$obj->last_update) $obj->last_update = $obj->regdate;
151
+			if (!$obj->last_update) $obj->last_update = $obj->regdate;
152 152
 
153 153
 			$tag = null;
154 154
 			$tmp_tags = null;
155 155
 			$tag = $xmlDoc->post->tag;
156
-			if($tag)
156
+			if ($tag)
157 157
 			{
158
-				if(!is_array($tag)) $tag = array($tag);
159
-				foreach($tag as $key => $val) $tmp_tags[] = $val->body;
160
-				$obj->tags = implode(',',$tmp_tags);
158
+				if (!is_array($tag)) $tag = array($tag);
159
+				foreach ($tag as $key => $val) $tmp_tags[] = $val->body;
160
+				$obj->tags = implode(',', $tmp_tags);
161 161
 			}
162 162
 
163 163
 			$obj->readed_count = 0;
@@ -169,33 +169,33 @@  discard block
 block discarded – undo
169 169
 			$obj->email_address = $member_info->email_address;
170 170
 			$obj->homepage = $member_info->homepage;
171 171
 			$obj->ipaddress = $_REMOTE['SERVER_ADDR'];
172
-			$obj->list_order = $obj->update_order = $obj->document_srl*-1;
172
+			$obj->list_order = $obj->update_order = $obj->document_srl * -1;
173 173
 			$obj->notify_message = 'N';
174 174
 			// Change content information (attachment)
175
-			$obj->content = str_replace('[##_ATTACH_PATH_##]/','',$obj->content);
176
-			if(count($files))
175
+			$obj->content = str_replace('[##_ATTACH_PATH_##]/', '', $obj->content);
176
+			if (count($files))
177 177
 			{
178
-				foreach($files as $key => $val) {
179
-					$obj->content = preg_replace('/(src|href)\=(["\']?)'.preg_quote($key).'(["\']?)/i','$1="'.$val->url.'"',$obj->content);
178
+				foreach ($files as $key => $val) {
179
+					$obj->content = preg_replace('/(src|href)\=(["\']?)'.preg_quote($key).'(["\']?)/i', '$1="'.$val->url.'"', $obj->content);
180 180
 				}
181 181
 			}
182 182
 
183 183
 			$obj->content = preg_replace_callback('!\[##_Movie\|([^\|]*)\|(.*?)_##\]!is', array($this, '_replaceTTMovie'), $obj->content);
184 184
 
185
-			if(count($files))
185
+			if (count($files))
186 186
 			{
187 187
 				$this->files = $files;
188 188
 				$obj->content = preg_replace_callback('!\[##_([a-z0-9]+)\|([^\|]*)\|([^\|]*)\|(.*?)_##\]!is', array($this, '_replaceTTAttach'), $obj->content);
189 189
 			}
190 190
 			// Trackback inserted
191 191
 			$obj->trackback_count = 0;
192
-			if($xmlDoc->post->trackback)
192
+			if ($xmlDoc->post->trackback)
193 193
 			{
194 194
 				$trackbacks = $xmlDoc->post->trackback;
195
-				if(!is_array($trackbacks)) $trackbacks = array($trackbacks);
196
-				if(count($trackbacks))
195
+				if (!is_array($trackbacks)) $trackbacks = array($trackbacks);
196
+				if (count($trackbacks))
197 197
 				{
198
-					foreach($trackbacks as $key => $val)
198
+					foreach ($trackbacks as $key => $val)
199 199
 					{
200 200
 						$tobj = null;
201 201
 						$tobj->trackback_srl = getNextSequence();
@@ -205,40 +205,40 @@  discard block
 block discarded – undo
205 205
 						$tobj->title = $val->title->body;
206 206
 						$tobj->blog_name = $val->site->body;
207 207
 						$tobj->excerpt = $val->excerpt->body;
208
-						$tobj->regdate = date("YmdHis",$val->received->body);
208
+						$tobj->regdate = date("YmdHis", $val->received->body);
209 209
 						$tobj->ipaddress = $val->ip->body;
210
-						$tobj->list_order = -1*$tobj->trackback_srl;
210
+						$tobj->list_order = -1 * $tobj->trackback_srl;
211 211
 						$output = executeQuery('trackback.insertTrackback', $tobj);
212
-						if($output->toBool()) $obj->trackback_count++;
212
+						if ($output->toBool()) $obj->trackback_count++;
213 213
 					}
214 214
 				}
215 215
 			}
216 216
 			// Comment
217 217
 			$obj->comment_count = 0;
218
-			if($xmlDoc->post->comment)
218
+			if ($xmlDoc->post->comment)
219 219
 			{
220 220
 				$comment = $xmlDoc->post->comment;
221
-				if(!is_array($comment)) $comment = array($comment);
222
-				foreach($comment as $key => $val)
221
+				if (!is_array($comment)) $comment = array($comment);
222
+				foreach ($comment as $key => $val)
223 223
 				{
224 224
 					$parent_srl = $this->insertComment($val, $module_srl, $obj->document_srl, $member_info, 0, $author_xml_id);
225
-					if($parent_srl === false) continue;
225
+					if ($parent_srl === false) continue;
226 226
 
227 227
 					$obj->comment_count++;
228
-					if($val->comment)
228
+					if ($val->comment)
229 229
 					{
230 230
 						$child_comment = $val->comment;
231
-						if(!is_array($child_comment)) $child_comment = array($child_comment);
232
-						foreach($child_comment as $k => $v)
231
+						if (!is_array($child_comment)) $child_comment = array($child_comment);
232
+						foreach ($child_comment as $k => $v)
233 233
 						{
234 234
 							$result = $this->insertComment($v, $module_srl, $obj->document_srl, $member_info, $parent_srl, $author_xml_id);
235
-							if($result !== false) $obj->comment_count++;
235
+							if ($result !== false) $obj->comment_count++;
236 236
 						}
237 237
 					}
238 238
 				}
239 239
 			}
240 240
 
241
-			if($module_name == 'textyle')
241
+			if ($module_name == 'textyle')
242 242
 			{
243 243
 				$args->document_srl = $obj->document_srl;
244 244
 				$args->module_srl = $obj->module_srl;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 				// Visibility value of published state
248 248
 				$status_published = array('public', 'syndicated');
249 249
 				// Save state if not published
250
-				if(!in_array($xmlDoc->post->visibility->body, $status_published))
250
+				if (!in_array($xmlDoc->post->visibility->body, $status_published))
251 251
 				{
252 252
 					$obj->module_srl = $member_info->member_srl; 
253 253
 				}
@@ -255,14 +255,14 @@  discard block
 block discarded – undo
255 255
 			// Document
256 256
 			$output = executeQuery('document.insertDocument', $obj);
257 257
 
258
-			if($output->toBool())
258
+			if ($output->toBool())
259 259
 			{
260 260
 				// Tags
261
-				if($obj->tags)
261
+				if ($obj->tags)
262 262
 				{
263
-					$tag_list = explode(',',$obj->tags);
263
+					$tag_list = explode(',', $obj->tags);
264 264
 					$tag_count = count($tag_list);
265
-					for($i=0;$i<$tag_count;$i++)
265
+					for ($i = 0; $i < $tag_count; $i++)
266 266
 					{
267 267
 						$args = new stdClass;
268 268
 						$args->tag_srl = getNextSequence();
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 						$args->document_srl = $obj->document_srl;
271 271
 						$args->tag = trim($tag_list[$i]);
272 272
 						$args->regdate = $obj->regdate;
273
-						if(!$args->tag) continue;
273
+						if (!$args->tag) continue;
274 274
 						$output = executeQuery('tag.insertTag', $args);
275 275
 					}
276 276
 				}
@@ -282,63 +282,63 @@  discard block
 block discarded – undo
282 282
 
283 283
 		fclose($f);
284 284
 
285
-		if(count($category_list)) foreach($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl);
285
+		if (count($category_list)) foreach ($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl);
286 286
 		// Guestbook information
287 287
 		$guestbook_file = preg_replace('/index$/i', 'guestbook.xml', $index_file);
288
-		if(file_exists($guestbook_file))
288
+		if (file_exists($guestbook_file))
289 289
 		{
290 290
 			// Create the xmlParser object
291 291
 			$xmlDoc = $this->oXmlParser->loadXmlFile($guestbook_file);
292 292
 			// Handle guest book information
293
-			if($guestbook_module_srl && $xmlDoc->guestbook->comment)
293
+			if ($guestbook_module_srl && $xmlDoc->guestbook->comment)
294 294
 			{
295 295
 				$comment = $xmlDoc->guestbook->comment;
296
-				if(!is_array($comment)) $comment = array($comment);
296
+				if (!is_array($comment)) $comment = array($comment);
297 297
 
298
-				if($module_name =='textyle')
298
+				if ($module_name == 'textyle')
299 299
 				{
300
-					foreach($comment as $key => $val)
300
+					foreach ($comment as $key => $val)
301 301
 					{
302
-						$textyle_guestbook_srl  = getNextSequence();
302
+						$textyle_guestbook_srl = getNextSequence();
303 303
 
304
-						if($val->comment)
304
+						if ($val->comment)
305 305
 						{
306 306
 							$child_comment = $val->comment;
307
-							if(!is_array($child_comment)) $child_comment = array($child_comment);
308
-							foreach($child_comment as $k => $v)
307
+							if (!is_array($child_comment)) $child_comment = array($child_comment);
308
+							foreach ($child_comment as $k => $v)
309 309
 							{
310
-								$result = $this->insertTextyleGuestbookItem($v, $module_srl, $member_info,0,$textyle_guestbook_srl,$author_xml_id);
310
+								$result = $this->insertTextyleGuestbookItem($v, $module_srl, $member_info, 0, $textyle_guestbook_srl, $author_xml_id);
311 311
 							}
312 312
 						}
313 313
 
314
-						$result = $this->insertTextyleGuestbookItem($val, $module_srl, $member_info,$textyle_guestbook_srl,0,$author_xml_id);
314
+						$result = $this->insertTextyleGuestbookItem($val, $module_srl, $member_info, $textyle_guestbook_srl, 0, $author_xml_id);
315 315
 					}
316 316
 				}
317 317
 				else
318 318
 				{
319
-					foreach($comment as $key => $val)
319
+					foreach ($comment as $key => $val)
320 320
 					{
321 321
 						$obj = null;
322 322
 						$obj->module_srl = $guestbook_module_srl;
323 323
 						$obj->document_srl = getNextSequence();
324 324
 						$obj->uploaded_count = 0;
325 325
 						$obj->is_notice = 'N';
326
-						$obj->status = $val->secret->body=='1'?$oDocumentModel->getConfigStatus('secret'):$oDocumentModel->getConfigStatus('public');
326
+						$obj->status = $val->secret->body == '1' ? $oDocumentModel->getConfigStatus('secret') : $oDocumentModel->getConfigStatus('public');
327 327
 						$obj->content = nl2br($val->content->body);
328 328
 
329 329
 						// Extract a title form the bocy
330
-						$obj->title = cut_str(strip_tags($obj->content),20,'...');
330
+						$obj->title = cut_str(strip_tags($obj->content), 20, '...');
331 331
 						if ($obj->title == '') $obj->title = 'Untitled';
332 332
 
333 333
 						$obj->commentStatus = 'ALLOW';
334 334
 						$obj->allow_trackback = 'N';
335
-						$obj->regdate = date("YmdHis",$val->written->body);
335
+						$obj->regdate = date("YmdHis", $val->written->body);
336 336
 						$obj->last_update = date("YmdHis", $val->written->body);
337
-						if(!$obj->last_update) $obj->last_update = $obj->regdate;
337
+						if (!$obj->last_update) $obj->last_update = $obj->regdate;
338 338
 						$obj->tags = '';
339 339
 						$obj->readed_count = 0;
340 340
 						$obj->voted_count = 0;
341
-						if($author_xml_id && $val->commenter->attrs->id == $author_xml_id)
341
+						if ($author_xml_id && $val->commenter->attrs->id == $author_xml_id)
342 342
 						{
343 343
 							$obj->password = '';
344 344
 							$obj->nick_name = $member_info->nick_name;
@@ -356,19 +356,19 @@  discard block
 block discarded – undo
356 356
 							$homepage = $val->commenter->homepage->body;
357 357
 						}
358 358
 						$obj->ipaddress = $val->commenter->ip->body;
359
-						$obj->list_order = $obj->update_order = $obj->document_srl*-1;
359
+						$obj->list_order = $obj->update_order = $obj->document_srl * -1;
360 360
 						$obj->notify_message = 'N';
361 361
 						$obj->trackback_count = 0;
362 362
 
363 363
 						$obj->comment_count = 0;
364
-						if($val->comment)
364
+						if ($val->comment)
365 365
 						{
366 366
 							$child_comment = $val->comment;
367
-							if(!is_array($child_comment)) $child_comment = array($child_comment);
368
-							foreach($child_comment as $k => $v)
367
+							if (!is_array($child_comment)) $child_comment = array($child_comment);
368
+							foreach ($child_comment as $k => $v)
369 369
 							{
370
-								$result = $this->insertComment($v, $module_srl, $obj->document_srl, $member_info, 0,$author_xml_id);
371
-								if($result !== false) $obj->comment_count++;
370
+								$result = $this->insertComment($v, $module_srl, $obj->document_srl, $member_info, 0, $author_xml_id);
371
+								if ($result !== false) $obj->comment_count++;
372 372
 							}
373 373
 						}
374 374
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 			FileHandler::removeFile($guestbook_file);
381 381
 		}
382 382
 
383
-		return $idx-1;
383
+		return $idx - 1;
384 384
 	}
385 385
 
386 386
 	/**
@@ -393,10 +393,10 @@  discard block
 block discarded – undo
393 393
 	 * @param int $author_xml_id
394 394
 	 * @return int|bool
395 395
 	 */
396
-	function insertTextyleGuestbookItem($val, $module_srl, $member_info, $textyle_guestbook_srl,$parent_srl = 0, $author_xml_id=null)
396
+	function insertTextyleGuestbookItem($val, $module_srl, $member_info, $textyle_guestbook_srl, $parent_srl = 0, $author_xml_id = null)
397 397
 	{
398 398
 		$tobj = null;
399
-		if($textyle_guestbook_srl>0)
399
+		if ($textyle_guestbook_srl > 0)
400 400
 		{
401 401
 			$tobj->textyle_guestbook_srl = $textyle_guestbook_srl;
402 402
 		}
@@ -405,9 +405,9 @@  discard block
 block discarded – undo
405 405
 			$tobj->textyle_guestbook_srl = getNextSequence();
406 406
 		}
407 407
 		$tobj->module_srl = $module_srl;
408
-		$tobj->is_secret = $val->secret->body=='1'?1:-1;
408
+		$tobj->is_secret = $val->secret->body == '1' ? 1 : -1;
409 409
 		$tobj->content = nl2br($val->content->body);
410
-		if($author_xml_id && $val->commenter->attrs->id == $author_xml_id)
410
+		if ($author_xml_id && $val->commenter->attrs->id == $author_xml_id)
411 411
 		{
412 412
 			$tobj->password = '';
413 413
 			$tobj->nick_name = $member_info->nick_name;
@@ -424,22 +424,22 @@  discard block
 block discarded – undo
424 424
 			$tobj->homepage = $val->commenter->homepage->body;
425 425
 			$tobj->member_srl = 0;
426 426
 		}
427
-		$tobj->last_update = $tobj->regdate = date("YmdHis",$val->written->body);
427
+		$tobj->last_update = $tobj->regdate = date("YmdHis", $val->written->body);
428 428
 		$tobj->ipaddress = $val->commenter->ip->body;
429 429
 
430
-		if($parent_srl>0)
430
+		if ($parent_srl > 0)
431 431
 		{
432 432
 			$tobj->parent_srl = $parent_srl;
433 433
 			$tobj->list_order = $tobj->parent_srl * -1;
434 434
 		}
435 435
 		else
436 436
 		{
437
-			$tobj->list_order = $tobj->textyle_guestbook_srl*-1;
437
+			$tobj->list_order = $tobj->textyle_guestbook_srl * -1;
438 438
 		}
439 439
 
440 440
 		$output = executeQuery('textyle.insertTextyleGuestbook', $tobj);
441 441
 
442
-		if($output->toBool()) return $tobj->textyle_guestbook_srl;
442
+		if ($output->toBool()) return $tobj->textyle_guestbook_srl;
443 443
 		return false;
444 444
 	}
445 445
 
@@ -456,18 +456,18 @@  discard block
 block discarded – undo
456 456
 	{
457 457
 		$uploaded_count = 0;
458 458
 
459
-		$file_obj  = null;
459
+		$file_obj = null;
460 460
 		$file_obj->file_srl = getNextSequence();
461 461
 		$file_obj->upload_target_srl = $upload_target_srl;
462 462
 		$file_obj->module_srl = $module_srl;
463 463
 
464
-		while(!feof($fp))
464
+		while (!feof($fp))
465 465
 		{
466 466
 			$str = fgets($fp, 1024);
467 467
 			// If it ends with </attaches>, break
468
-			if(trim($str) == '</attachment>') break;
468
+			if (trim($str) == '</attachment>') break;
469 469
 			// If it starts with <file>, handle the attachement in the xml file
470
-			if(substr($str, 0, 9)=='<content>')
470
+			if (substr($str, 0, 9) == '<content>')
471 471
 			{
472 472
 				$file_obj->file = $this->saveTemporaryFile($fp, $str);
473 473
 				continue;
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 
476 476
 			$buff .= $str;
477 477
 		}
478
-		if(!file_exists($file_obj->file)) return false;
478
+		if (!file_exists($file_obj->file)) return false;
479 479
 
480 480
 		$buff .= '</attachment>';
481 481
 
@@ -485,20 +485,20 @@  discard block
 block discarded – undo
485 485
 		$file_obj->download_count = $xmlDoc->attachment->downloads->body;
486 486
 		$name = $xmlDoc->attachment->name->body;
487 487
 		// Set upload path by checking if the attachement is an image or other kind of file
488
-		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|swf|wav|webm|webp|wma|wmv)$/i", $file_obj->source_filename))
488
+		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|swf|wav|webm|webp|wma|wmv)$/i", $file_obj->source_filename))
489 489
 		{
490
-			$path = sprintf("./files/attach/images/%s/%s", $module_srl,getNumberingPath($upload_target_srl,3));
490
+			$path = sprintf("./files/attach/images/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3));
491 491
 			$filename = $path.$file_obj->source_filename;
492 492
 			$file_obj->direct_download = 'Y';
493 493
 		}
494 494
 		else
495 495
 		{
496
-			$path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3));
497
-			$filename = $path.md5(crypt(rand(1000000,900000), rand(0,100)));
496
+			$path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3));
497
+			$filename = $path.md5(crypt(rand(1000000, 900000), rand(0, 100)));
498 498
 			$file_obj->direct_download = 'N';
499 499
 		}
500 500
 		// Create a directory
501
-		if(!FileHandler::makeDir($path)) return;
501
+		if (!FileHandler::makeDir($path)) return;
502 502
 
503 503
 		FileHandler::rename($file_obj->file, $filename);
504 504
 		// Insert to the DB
@@ -507,16 +507,16 @@  discard block
 block discarded – undo
507 507
 		$file_obj->file_size = filesize($filename);
508 508
 		$file_obj->comment = NULL;
509 509
 		$file_obj->member_srl = 0;
510
-		$file_obj->sid = md5(rand(rand(1111111,4444444),rand(4444445,9999999)));
510
+		$file_obj->sid = md5(rand(rand(1111111, 4444444), rand(4444445, 9999999)));
511 511
 		$file_obj->isvalid = 'Y';
512 512
 		$output = executeQuery('file.insertFile', $file_obj);
513 513
 
514
-		if($output->toBool())
514
+		if ($output->toBool())
515 515
 		{
516 516
 			$uploaded_count++;
517 517
 			$tmp_obj = null;
518
-			if($file_obj->direct_download == 'Y') $files[$name]->url = $file_obj->uploaded_filename; 
519
-			else $files[$name]->url = getUrl('','module','file','act','procFileDownload','file_srl',$file_obj->file_srl,'sid',$file_obj->sid);
518
+			if ($file_obj->direct_download == 'Y') $files[$name]->url = $file_obj->uploaded_filename; 
519
+			else $files[$name]->url = getUrl('', 'module', 'file', 'act', 'procFileDownload', 'file_srl', $file_obj->file_srl, 'sid', $file_obj->sid);
520 520
 			$files[$name]->direct_download = $file_obj->direct_download;
521 521
 			$files[$name]->source_filename = $file_obj->source_filename;
522 522
 			return true;
@@ -532,9 +532,9 @@  discard block
 block discarded – undo
532 532
 	function getTmpFilename()
533 533
 	{
534 534
 		$path = "./files/cache/importer";
535
-		if(!is_dir($path)) FileHandler::makeDir($path);
536
-		$filename = sprintf("%s/%d", $path, rand(11111111,99999999));
537
-		if(file_exists($filename)) $filename .= rand(111,999);
535
+		if (!is_dir($path)) FileHandler::makeDir($path);
536
+		$filename = sprintf("%s/%d", $path, rand(11111111, 99999999));
537
+		if (file_exists($filename)) $filename .= rand(111, 999);
538 538
 		return $filename;
539 539
 	}
540 540
 
@@ -549,11 +549,11 @@  discard block
 block discarded – undo
549 549
 		$temp_filename = $this->getTmpFilename();
550 550
 		$buff = substr($buff, 9);
551 551
 
552
-		while(!feof($fp))
552
+		while (!feof($fp))
553 553
 		{
554 554
 			$str = trim(fgets($fp, 1024));
555 555
 			$buff .= $str;
556
-			if(substr($str, -10) == '</content>') break;
556
+			if (substr($str, -10) == '</content>') break;
557 557
 		}
558 558
 
559 559
 		$buff = substr($buff, 0, -10);
@@ -572,16 +572,16 @@  discard block
 block discarded – undo
572 572
 	function _replaceTTAttach($matches)
573 573
 	{
574 574
 		$name = $matches[2];
575
-		if(!$name) return $matches[0];
575
+		if (!$name) return $matches[0];
576 576
 
577 577
 		$obj = $this->files[$name];
578 578
 		// If multimedia file is,
579
-		if($obj->direct_download == 'Y')
579
+		if ($obj->direct_download == 'Y')
580 580
 		{
581 581
 			// If image file is
582
-			if(preg_match('/\.(jpg|gif|jpeg|png)$/i', $obj->source_filename))
582
+			if (preg_match('/\.(jpg|gif|jpeg|png)$/i', $obj->source_filename))
583 583
 			{
584
-				return sprintf('<img editor_component="image_link" src="%s" alt="%s" />', $obj->url, str_replace('"','\\"',$matches[4]));
584
+				return sprintf('<img editor_component="image_link" src="%s" alt="%s" />', $obj->url, str_replace('"', '\\"', $matches[4]));
585 585
 				// If other multimedia file but image is, 
586 586
 			}
587 587
 			else
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 	function _replaceTTMovie($matches)
604 604
 	{
605 605
 		$key = $matches[1];
606
-		if(!$key) return $matches[0];
606
+		if (!$key) return $matches[0];
607 607
 
608 608
 		return 
609 609
 			'<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="402">'.
@@ -631,12 +631,12 @@  discard block
 block discarded – undo
631 631
 		$tobj->comment_srl = getNextSequence();
632 632
 		$tobj->module_srl = $module_srl;
633 633
 		$tobj->document_srl = $document_srl;
634
-		$tobj->is_secret = $val->secret->body=='1'?'Y':'N';
634
+		$tobj->is_secret = $val->secret->body == '1' ? 'Y' : 'N';
635 635
 		$tobj->notify_message = 'N';
636 636
 		$tobj->content = nl2br($val->content->body);
637 637
 		$tobj->voted_count = 0;
638 638
 		$tobj->status = 1;
639
-		if($author_xml_id && $val->commenter->attrs->id == $author_xml_id)
639
+		if ($author_xml_id && $val->commenter->attrs->id == $author_xml_id)
640 640
 		{
641 641
 			$tobj->password = '';
642 642
 			$tobj->nick_name = $member_info->nick_name;
@@ -653,9 +653,9 @@  discard block
 block discarded – undo
653 653
 			$tobj->homepage = $val->commenter->homepage->body;
654 654
 			$tobj->member_srl = 0;
655 655
 		}
656
-		$tobj->last_update = $tobj->regdate = date("YmdHis",$val->written->body);
656
+		$tobj->last_update = $tobj->regdate = date("YmdHis", $val->written->body);
657 657
 		$tobj->ipaddress = $val->commenter->ip->body;
658
-		$tobj->list_order = $tobj->comment_srl*-1;
658
+		$tobj->list_order = $tobj->comment_srl * -1;
659 659
 		$tobj->sequence = $sequence;
660 660
 		$tobj->parent_srl = $parent_srl;
661 661
 		// Comment list first
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
 		$list_args->module_srl = $tobj->module_srl;
666 666
 		$list_args->regdate = $tobj->regdate;
667 667
 		// Set data directly if parent comment doesn't exist
668
-		if(!$tobj->parent_srl)
668
+		if (!$tobj->parent_srl)
669 669
 		{
670 670
 			$list_args->head = $list_args->arrange = $tobj->comment_srl;
671 671
 			$list_args->depth = 0;
@@ -677,25 +677,25 @@  discard block
 block discarded – undo
677 677
 			$parent_args->comment_srl = $tobj->parent_srl;
678 678
 			$parent_output = executeQuery('comment.getCommentListItem', $parent_args);
679 679
 			// Return if parent comment doesn't exist
680
-			if(!$parent_output->toBool() || !$parent_output->data) return false;
680
+			if (!$parent_output->toBool() || !$parent_output->data) return false;
681 681
 			$parent = $parent_output->data;
682 682
 
683 683
 			$list_args->head = $parent->head;
684
-			$list_args->depth = $parent->depth+1;
685
-			if($list_args->depth<2) $list_args->arrange = $tobj->comment_srl;
684
+			$list_args->depth = $parent->depth + 1;
685
+			if ($list_args->depth < 2) $list_args->arrange = $tobj->comment_srl;
686 686
 			else
687 687
 			{
688 688
 				$list_args->arrange = $parent->arrange;
689 689
 				$output = executeQuery('comment.updateCommentListArrange', $list_args);
690
-				if(!$output->toBool()) return $output;
690
+				if (!$output->toBool()) return $output;
691 691
 			}
692 692
 		}
693 693
 
694 694
 		$output = executeQuery('comment.insertCommentList', $list_args);
695
-		if($output->toBool())
695
+		if ($output->toBool())
696 696
 		{
697 697
 			$output = executeQuery('comment.insertComment', $tobj);
698
-			if($output->toBool()) return $tobj->comment_srl;
698
+			if ($output->toBool()) return $tobj->comment_srl;
699 699
 		}
700 700
 		return false;
701 701
 	}
@@ -710,10 +710,10 @@  discard block
 block discarded – undo
710 710
 	 */
711 711
 	function arrangeCategory($obj, &$category, &$idx, $parent = 0)
712 712
 	{
713
-		if(!$obj->category) return;
714
-		if(!is_array($obj->category)) $c = array($obj->category);
713
+		if (!$obj->category) return;
714
+		if (!is_array($obj->category)) $c = array($obj->category);
715 715
 		else $c = $obj->category;
716
-		foreach($c as $val)
716
+		foreach ($c as $val)
717 717
 		{
718 718
 			$idx++;
719 719
 			$priority = $val->priority->body;
Please login to merge, or discard this patch.
modules/file/file.controller.php 1 patch
Spacing   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -29,24 +29,24 @@  discard block
 block discarded – undo
29 29
 		$file_info = $_FILES['Filedata'];
30 30
 
31 31
 		// An error appears if not a normally uploaded file
32
-		if(!is_uploaded_file($file_info['tmp_name'])) exit();
32
+		if (!is_uploaded_file($file_info['tmp_name'])) exit();
33 33
 
34 34
 		// Basic variables setting
35 35
 		$oFileModel = getModel('file');
36 36
 		$editor_sequence = Context::get('editor_sequence');
37 37
 		$upload_target_srl = intval(Context::get('uploadTargetSrl'));
38
-		if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl'));
38
+		if (!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl'));
39 39
 		$module_srl = $this->module_srl;
40 40
 		// Exit a session if there is neither upload permission nor information
41
-		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
41
+		if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
42 42
 		// Extract from session information if upload_target_srl is not specified
43
-		if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
43
+		if (!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
44 44
 		// Create if upload_target_srl is not defined in the session information
45
-		if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
45
+		if (!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
46 46
 
47 47
 		$output = $this->insertFile($file_info, $module_srl, $upload_target_srl);
48 48
 		Context::setResponseMethod('JSON');
49
-		if($output->error != '0') $this->stop($output->message);
49
+		if ($output->error != '0') $this->stop($output->message);
50 50
 	}
51 51
 
52 52
 	/**
@@ -61,26 +61,26 @@  discard block
 block discarded – undo
61 61
 		$callback = Context::get('callback');
62 62
 		$module_srl = $this->module_srl;
63 63
 		$upload_target_srl = intval(Context::get('uploadTargetSrl'));
64
-		if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl'));
64
+		if (!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl'));
65 65
 
66 66
 		// Exit a session if there is neither upload permission nor information
67
-		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
67
+		if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
68 68
 		// Extract from session information if upload_target_srl is not specified
69
-		if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
69
+		if (!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
70 70
 		// Create if upload_target_srl is not defined in the session information
71
-		if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
71
+		if (!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
72 72
 		// Delete and then attempt to re-upload if file_srl is requested
73 73
 		$file_srl = Context::get('file_srl');
74
-		if($file_srl) $this->deleteFile($file_srl);
74
+		if ($file_srl) $this->deleteFile($file_srl);
75 75
 
76 76
 		$file_info = Context::get('Filedata');
77 77
 		// An error appears if not a normally uploaded file
78
-		if(is_uploaded_file($file_info['tmp_name'])) {
78
+		if (is_uploaded_file($file_info['tmp_name'])) {
79 79
 			$output = $this->insertFile($file_info, $module_srl, $upload_target_srl);
80
-			Context::set('uploaded_fileinfo',$output);
80
+			Context::set('uploaded_fileinfo', $output);
81 81
 		}
82 82
 
83
-		Context::set('layout','none');
83
+		Context::set('layout', 'none');
84 84
 
85 85
 		$this->setTemplatePath($this->module_path.'tpl');
86 86
 		$this->setTemplateFile('iframe');
@@ -97,24 +97,24 @@  discard block
 block discarded – undo
97 97
 		$width = Context::get('width');
98 98
 		$height = Context::get('height');
99 99
 
100
-		if(!$file_srl || !$width)
100
+		if (!$file_srl || !$width)
101 101
 		{
102
-			return new Object(-1,'msg_invalid_request');
102
+			return new Object(-1, 'msg_invalid_request');
103 103
 		}
104 104
 
105 105
 		$oFileModel = getModel('file');
106 106
 		$fileInfo = $oFileModel->getFile($file_srl);
107
-		if(!$fileInfo || $fileInfo->direct_download != 'Y')
107
+		if (!$fileInfo || $fileInfo->direct_download != 'Y')
108 108
 		{
109
-			return new Object(-1,'msg_invalid_request');
109
+			return new Object(-1, 'msg_invalid_request');
110 110
 		}
111 111
 
112 112
 		$source_src = $fileInfo->uploaded_filename;
113
-		$output_src = $source_src . '.resized' . strrchr($source_src,'.');
113
+		$output_src = $source_src.'.resized'.strrchr($source_src, '.');
114 114
 
115
-		if(!$height) $height = $width-1;
115
+		if (!$height) $height = $width - 1;
116 116
 
117
-		if(FileHandler::createImageFile($source_src,$output_src,$width,$height,'','ratio'))
117
+		if (FileHandler::createImageFile($source_src, $output_src, $width, $height, '', 'ratio'))
118 118
 		{
119 119
 			$output = new stdClass();
120 120
 			$output->info = getimagesize($output_src);
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
 		}
123 123
 		else
124 124
 		{
125
-			return new Object(-1,'msg_invalid_request');
125
+			return new Object(-1, 'msg_invalid_request');
126 126
 		}
127 127
 
128
-		$this->add('resized_info',$output);
128
+		$this->add('resized_info', $output);
129 129
 	}
130 130
 
131 131
 	/**
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	{
164 164
 		$oFileModel = getModel('file');
165 165
 
166
-		if(isset($this->grant->access) && $this->grant->access !== true) return new Object(-1, 'msg_not_permitted');
166
+		if (isset($this->grant->access) && $this->grant->access !== true) return new Object(-1, 'msg_not_permitted');
167 167
 
168 168
 		$file_srl = Context::get('file_srl');
169 169
 		$sid = Context::get('sid');
@@ -172,26 +172,26 @@  discard block
 block discarded – undo
172 172
 		$columnList = array('file_srl', 'sid', 'isvalid', 'source_filename', 'module_srl', 'uploaded_filename', 'file_size', 'member_srl', 'upload_target_srl', 'upload_target_type');
173 173
 		$file_obj = $oFileModel->getFile($file_srl, $columnList);
174 174
 		// If the requested file information is incorrect, an error that file cannot be found appears
175
-		if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) return $this->stop('msg_file_not_found');
175
+		if ($file_obj->file_srl != $file_srl || $file_obj->sid != $sid) return $this->stop('msg_file_not_found');
176 176
 		// Notify that file download is not allowed when standing-by(Only a top-administrator is permitted)
177
-		if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') return $this->stop('msg_not_permitted_download');
177
+		if ($logged_info->is_admin != 'Y' && $file_obj->isvalid != 'Y') return $this->stop('msg_not_permitted_download');
178 178
 		// File name
179 179
 		$filename = $file_obj->source_filename;
180 180
 		$file_module_config = $oFileModel->getFileModuleConfig($file_obj->module_srl);
181 181
 		// Not allow the file outlink
182
-		if($file_module_config->allow_outlink == 'N')
182
+		if ($file_module_config->allow_outlink == 'N')
183 183
 		{
184 184
 			// Handles extension to allow outlink
185
-			if($file_module_config->allow_outlink_format)
185
+			if ($file_module_config->allow_outlink_format)
186 186
 			{
187 187
 				$allow_outlink_format_array = array();
188 188
 				$allow_outlink_format_array = explode(',', $file_module_config->allow_outlink_format);
189
-				if(!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format;
189
+				if (!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format;
190 190
 
191
-				foreach($allow_outlink_format_array as $val)
191
+				foreach ($allow_outlink_format_array as $val)
192 192
 				{
193 193
 					$val = trim($val);
194
-					if(preg_match("/\.{$val}$/i", $filename))
194
+					if (preg_match("/\.{$val}$/i", $filename))
195 195
 					{
196 196
 						$file_module_config->allow_outlink = 'Y';
197 197
 						break;
@@ -199,21 +199,21 @@  discard block
 block discarded – undo
199 199
 				}
200 200
 			}
201 201
 			// Sites that outlink is allowed
202
-			if($file_module_config->allow_outlink != 'Y')
202
+			if ($file_module_config->allow_outlink != 'Y')
203 203
 			{
204 204
 				$referer = parse_url($_SERVER["HTTP_REFERER"]);
205
-				if($referer['host'] != $_SERVER['HTTP_HOST'])
205
+				if ($referer['host'] != $_SERVER['HTTP_HOST'])
206 206
 				{
207
-					if($file_module_config->allow_outlink_site)
207
+					if ($file_module_config->allow_outlink_site)
208 208
 					{
209 209
 						$allow_outlink_site_array = array();
210 210
 						$allow_outlink_site_array = explode("\n", $file_module_config->allow_outlink_site);
211
-						if(!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site;
211
+						if (!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site;
212 212
 
213
-						foreach($allow_outlink_site_array as $val)
213
+						foreach ($allow_outlink_site_array as $val)
214 214
 						{
215 215
 							$site = parse_url(trim($val));
216
-							if($site['host'] == $referer['host'])
216
+							if ($site['host'] == $referer['host'])
217 217
 							{
218 218
 								$file_module_config->allow_outlink = 'Y';
219 219
 								break;
@@ -223,49 +223,49 @@  discard block
 block discarded – undo
223 223
 				}
224 224
 				else $file_module_config->allow_outlink = 'Y';
225 225
 			}
226
-			if($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink');
226
+			if ($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink');
227 227
 		}
228 228
 
229 229
 		// Check if a permission for file download is granted
230 230
 		$downloadGrantCount = 0;
231
-		if(is_array($file_module_config->download_grant))
231
+		if (is_array($file_module_config->download_grant))
232 232
 		{
233
-			foreach($file_module_config->download_grant AS $value)
234
-				if($value) $downloadGrantCount++;
233
+			foreach ($file_module_config->download_grant AS $value)
234
+				if ($value) $downloadGrantCount++;
235 235
 		}
236 236
 
237
-		if(is_array($file_module_config->download_grant) && $downloadGrantCount>0)
237
+		if (is_array($file_module_config->download_grant) && $downloadGrantCount > 0)
238 238
 		{
239
-			if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download');
239
+			if (!Context::get('is_logged')) return $this->stop('msg_not_permitted_download');
240 240
 			$logged_info = Context::get('logged_info');
241
-			if($logged_info->is_admin != 'Y')
241
+			if ($logged_info->is_admin != 'Y')
242 242
 			{
243
-				$oModuleModel =& getModel('module');
243
+				$oModuleModel = & getModel('module');
244 244
 				$columnList = array('module_srl', 'site_srl');
245 245
 				$module_info = $oModuleModel->getModuleInfoByModuleSrl($file_obj->module_srl, $columnList);
246 246
 
247
-				if(!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl))
247
+				if (!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl))
248 248
 				{
249
-					$oMemberModel =& getModel('member');
249
+					$oMemberModel = & getModel('member');
250 250
 					$member_groups = $oMemberModel->getMemberGroups($logged_info->member_srl, $module_info->site_srl);
251 251
 
252 252
 					$is_permitted = false;
253
-					for($i=0;$i<count($file_module_config->download_grant);$i++)
253
+					for ($i = 0; $i < count($file_module_config->download_grant); $i++)
254 254
 					{
255 255
 						$group_srl = $file_module_config->download_grant[$i];
256
-						if($member_groups[$group_srl])
256
+						if ($member_groups[$group_srl])
257 257
 						{
258 258
 							$is_permitted = true;
259 259
 							break;
260 260
 						}
261 261
 					}
262
-					if(!$is_permitted) return $this->stop('msg_not_permitted_download');
262
+					if (!$is_permitted) return $this->stop('msg_not_permitted_download');
263 263
 				}
264 264
 			}
265 265
 		}
266 266
 		// Call a trigger (before)
267 267
 		$output = ModuleHandler::triggerCall('file.downloadFile', 'before', $file_obj);
268
-		if(!$output->toBool()) return $this->stop(($output->message)?$output->message:'msg_not_permitted_download');
268
+		if (!$output->toBool()) return $this->stop(($output->message) ? $output->message : 'msg_not_permitted_download');
269 269
 
270 270
 
271 271
 		// 다운로드 후 (가상)
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 
279 279
 		$random = new Password();
280 280
 		$file_key = $_SESSION['__XE_FILE_KEY__'][$file_srl] = $random->createSecureSalt(32, 'hex');
281
-		header('Location: '.getNotEncodedUrl('', 'act', 'procFileOutput','file_srl',$file_srl,'file_key',$file_key));
281
+		header('Location: '.getNotEncodedUrl('', 'act', 'procFileOutput', 'file_srl', $file_srl, 'file_key', $file_key));
282 282
 		Context::close();
283 283
 		exit();
284 284
 
@@ -289,18 +289,18 @@  discard block
 block discarded – undo
289 289
 		$oFileModel = getModel('file');
290 290
 		$file_srl = Context::get('file_srl');
291 291
 		$file_key = Context::get('file_key');
292
-		if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true;
292
+		if (strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true;
293 293
 
294
-		if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__';
294
+		if ($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__';
295 295
 		else $session_key = '__XE_FILE_KEY__';
296 296
 		$columnList = array('source_filename', 'uploaded_filename', 'file_size');
297 297
 		$file_obj = $oFileModel->getFile($file_srl, $columnList);
298 298
 
299 299
 		$uploaded_filename = $file_obj->uploaded_filename;
300 300
 
301
-		if(!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found');
301
+		if (!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found');
302 302
 
303
-		if(!$file_key || $_SESSION[$session_key][$file_srl] != $file_key)
303
+		if (!$file_key || $_SESSION[$session_key][$file_srl] != $file_key)
304 304
 		{
305 305
 			unset($_SESSION[$session_key][$file_srl]);
306 306
 			return $this->stop('msg_invalid_request');
@@ -309,34 +309,34 @@  discard block
 block discarded – undo
309 309
 		$file_size = $file_obj->file_size;
310 310
 		$filename = $file_obj->source_filename;
311 311
 		
312
-		if(preg_match('#(?:Chrome|Edge)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 11)
312
+		if (preg_match('#(?:Chrome|Edge)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 11)
313 313
 		{
314
-			if($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT']))
314
+			if ($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT']))
315 315
 			{
316
-				$filename_param = 'filename="' . $filename . '"';
316
+				$filename_param = 'filename="'.$filename.'"';
317 317
 			}
318 318
 			else
319 319
 			{
320
-				$filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"';
320
+				$filename_param = "filename*=UTF-8''".rawurlencode($filename).'; filename="'.rawurlencode($filename).'"';
321 321
 			}
322 322
 		}
323
-		elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6)
323
+		elseif (preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6)
324 324
 		{
325
-			$filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"';
325
+			$filename_param = "filename*=UTF-8''".rawurlencode($filename).'; filename="'.rawurlencode($filename).'"';
326 326
 		}
327
-		elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
327
+		elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
328 328
 		{
329 329
 			$filename = rawurlencode($filename);
330
-			$filename_param = 'filename="' . preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1) . '"';
330
+			$filename_param = 'filename="'.preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1).'"';
331 331
 		}
332 332
 		else
333 333
 		{
334
-			$filename_param = 'filename="' . $filename . '"';
334
+			$filename_param = 'filename="'.$filename.'"';
335 335
 		}
336 336
 
337
-		if($is_android)
337
+		if ($is_android)
338 338
 		{
339
-			if($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key;
339
+			if ($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key;
340 340
 		}
341 341
 
342 342
 		unset($_SESSION[$session_key][$file_srl]);
@@ -344,21 +344,21 @@  discard block
 block discarded – undo
344 344
 		Context::close();
345 345
 
346 346
 		$fp = fopen($uploaded_filename, 'rb');
347
-		if(!$fp) return $this->stop('msg_file_not_found');
347
+		if (!$fp) return $this->stop('msg_file_not_found');
348 348
 
349 349
 		header("Cache-Control: ");
350 350
 		header("Pragma: ");
351 351
 		header("Content-Type: application/octet-stream");
352
-		header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
352
+		header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
353 353
 
354
-		header("Content-Length: " .(string)($file_size));
355
-		header('Content-Disposition: attachment; ' . $filename_param);
354
+		header("Content-Length: ".(string) ($file_size));
355
+		header('Content-Disposition: attachment; '.$filename_param);
356 356
 		header("Content-Transfer-Encoding: binary\n");
357 357
 
358 358
 		// if file size is lager than 10MB, use fread function (#18675748)
359
-		if(filesize($uploaded_filename) > 1024 * 1024)
359
+		if (filesize($uploaded_filename) > 1024 * 1024)
360 360
 		{
361
-			while(!feof($fp)) echo fread($fp, 1024);
361
+			while (!feof($fp)) echo fread($fp, 1024);
362 362
 			fclose($fp);
363 363
 		}
364 364
 		else
@@ -380,36 +380,36 @@  discard block
 block discarded – undo
380 380
 		$editor_sequence = Context::get('editor_sequence');
381 381
 		$file_srl = Context::get('file_srl');
382 382
 		$file_srls = Context::get('file_srls');
383
-		if($file_srls) $file_srl = $file_srls;
383
+		if ($file_srls) $file_srl = $file_srls;
384 384
 		// Exit a session if there is neither upload permission nor information
385
-		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
385
+		if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
386 386
 
387 387
 		$upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
388 388
 
389 389
 		$logged_info = Context::get('logged_info');
390 390
 		$oFileModel = getModel('file');
391 391
 
392
-		$srls = explode(',',$file_srl);
393
-		if(!count($srls)) return;
392
+		$srls = explode(',', $file_srl);
393
+		if (!count($srls)) return;
394 394
 
395
-		for($i=0;$i<count($srls);$i++)
395
+		for ($i = 0; $i < count($srls); $i++)
396 396
 		{
397
-			$srl = (int)$srls[$i];
398
-			if(!$srl) continue;
397
+			$srl = (int) $srls[$i];
398
+			if (!$srl) continue;
399 399
 
400 400
 			$args = new stdClass;
401 401
 			$args->file_srl = $srl;
402 402
 			$output = executeQuery('file.getFile', $args);
403
-			if(!$output->toBool()) continue;
403
+			if (!$output->toBool()) continue;
404 404
 
405 405
 			$file_info = $output->data;
406
-			if(!$file_info) continue;
406
+			if (!$file_info) continue;
407 407
 
408 408
 			$file_grant = $oFileModel->getFileGrant($file_info, $logged_info);
409 409
 
410
-			if(!$file_grant->is_deletable) continue;
410
+			if (!$file_grant->is_deletable) continue;
411 411
 
412
-			if($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl);
412
+			if ($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl);
413 413
 		}
414 414
 	}
415 415
 
@@ -420,23 +420,23 @@  discard block
 block discarded – undo
420 420
 	 */
421 421
 	function procFileGetList()
422 422
 	{
423
-		if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted');
423
+		if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted');
424 424
 		$fileSrls = Context::get('file_srls');
425
-		if($fileSrls) $fileSrlList = explode(',', $fileSrls);
425
+		if ($fileSrls) $fileSrlList = explode(',', $fileSrls);
426 426
 
427 427
 		global $lang;
428
-		if(count($fileSrlList) > 0)
428
+		if (count($fileSrlList) > 0)
429 429
 		{
430 430
 			$oFileModel = getModel('file');
431 431
 			$fileList = $oFileModel->getFile($fileSrlList);
432
-			if(!is_array($fileList)) $fileList = array($fileList);
432
+			if (!is_array($fileList)) $fileList = array($fileList);
433 433
 
434
-			if(is_array($fileList))
434
+			if (is_array($fileList))
435 435
 			{
436
-				foreach($fileList AS $key=>$value)
436
+				foreach ($fileList AS $key=>$value)
437 437
 				{
438 438
 					$value->human_file_size = FileHandler::filesize($value->file_size);
439
-					if($value->isvalid=='Y') $value->validName = $lang->is_valid;
439
+					if ($value->isvalid == 'Y') $value->validName = $lang->is_valid;
440 440
 					else $value->validName = $lang->is_stand_by;
441 441
 				}
442 442
 			}
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 	function triggerCheckAttached(&$obj)
459 459
 	{
460 460
 		$document_srl = $obj->document_srl;
461
-		if(!$document_srl) return new Object();
461
+		if (!$document_srl) return new Object();
462 462
 		// Get numbers of attachments
463 463
 		$oFileModel = getModel('file');
464 464
 		$obj->uploaded_count = $oFileModel->getFilesCount($document_srl);
@@ -475,10 +475,10 @@  discard block
 block discarded – undo
475 475
 	function triggerAttachFiles(&$obj)
476 476
 	{
477 477
 		$document_srl = $obj->document_srl;
478
-		if(!$document_srl) return new Object();
478
+		if (!$document_srl) return new Object();
479 479
 
480 480
 		$output = $this->setFilesValid($document_srl);
481
-		if(!$output->toBool()) return $output;
481
+		if (!$output->toBool()) return $output;
482 482
 
483 483
 		return new Object();
484 484
 	}
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 	function triggerDeleteAttached(&$obj)
493 493
 	{
494 494
 		$document_srl = $obj->document_srl;
495
-		if(!$document_srl) return new Object();
495
+		if (!$document_srl) return new Object();
496 496
 
497 497
 		$output = $this->deleteFiles($document_srl);
498 498
 		return $output;
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 	function triggerCommentCheckAttached(&$obj)
508 508
 	{
509 509
 		$comment_srl = $obj->comment_srl;
510
-		if(!$comment_srl) return new Object();
510
+		if (!$comment_srl) return new Object();
511 511
 		// Get numbers of attachments
512 512
 		$oFileModel = getModel('file');
513 513
 		$obj->uploaded_count = $oFileModel->getFilesCount($comment_srl);
@@ -525,10 +525,10 @@  discard block
 block discarded – undo
525 525
 	{
526 526
 		$comment_srl = $obj->comment_srl;
527 527
 		$uploaded_count = $obj->uploaded_count;
528
-		if(!$comment_srl || !$uploaded_count) return new Object();
528
+		if (!$comment_srl || !$uploaded_count) return new Object();
529 529
 
530 530
 		$output = $this->setFilesValid($comment_srl);
531
-		if(!$output->toBool()) return $output;
531
+		if (!$output->toBool()) return $output;
532 532
 
533 533
 		return new Object();
534 534
 	}
@@ -542,9 +542,9 @@  discard block
 block discarded – undo
542 542
 	function triggerCommentDeleteAttached(&$obj)
543 543
 	{
544 544
 		$comment_srl = $obj->comment_srl;
545
-		if(!$comment_srl) return new Object();
545
+		if (!$comment_srl) return new Object();
546 546
 
547
-		if($obj->isMoveToTrash) return new Object();
547
+		if ($obj->isMoveToTrash) return new Object();
548 548
 
549 549
 		$output = $this->deleteFiles($comment_srl);
550 550
 		return $output;
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 	function triggerDeleteModuleFiles(&$obj)
560 560
 	{
561 561
 		$module_srl = $obj->module_srl;
562
-		if(!$module_srl) return new Object();
562
+		if (!$module_srl) return new Object();
563 563
 
564 564
 		$oFileController = getAdminController('file');
565 565
 		return $oFileController->deleteModuleFiles($module_srl);
@@ -572,9 +572,9 @@  discard block
 block discarded – undo
572 572
 	 * @param int $upload_target_srl
573 573
 	 * @return void
574 574
 	 */
575
-	function setUploadInfo($editor_sequence, $upload_target_srl=0)
575
+	function setUploadInfo($editor_sequence, $upload_target_srl = 0)
576 576
 	{
577
-		if(!isset($_SESSION['upload_info'][$editor_sequence]))
577
+		if (!isset($_SESSION['upload_info'][$editor_sequence]))
578 578
 		{
579 579
 			$_SESSION['upload_info'][$editor_sequence] = new stdClass();
580 580
 		}
@@ -634,36 +634,36 @@  discard block
 block discarded – undo
634 634
 		$trigger_obj->module_srl = $module_srl;
635 635
 		$trigger_obj->upload_target_srl = $upload_target_srl;
636 636
 		$output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj);
637
-		if(!$output->toBool()) return $output;
637
+		if (!$output->toBool()) return $output;
638 638
 
639 639
 		// A workaround for Firefox upload bug
640
-		if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match))
640
+		if (preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match))
641 641
 		{
642 642
 			$file_info['name'] = base64_decode(strtr($match[1], ':', '/'));
643 643
 		}
644 644
 
645
-		if(!$manual_insert)
645
+		if (!$manual_insert)
646 646
 		{
647 647
 			// Get the file configurations
648 648
 			$logged_info = Context::get('logged_info');
649
-			if($logged_info->is_admin != 'Y')
649
+			if ($logged_info->is_admin != 'Y')
650 650
 			{
651 651
 				$oFileModel = getModel('file');
652 652
 				$config = $oFileModel->getFileConfig($module_srl);
653 653
 
654 654
 				// check file type
655
-				if(isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*')
655
+				if (isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*')
656 656
 				{
657 657
 					$filetypes = explode(';', $config->allowed_filetypes);
658 658
 					$ext = array();
659
-					foreach($filetypes as $item) {
659
+					foreach ($filetypes as $item) {
660 660
 						$item = explode('.', $item);
661 661
 						$ext[] = strtolower($item[1]);
662 662
 					}
663 663
 					$uploaded_ext = explode('.', $file_info['name']);
664 664
 					$uploaded_ext = strtolower(array_pop($uploaded_ext));
665 665
 
666
-					if(!in_array($uploaded_ext, $ext))
666
+					if (!in_array($uploaded_ext, $ext))
667 667
 					{
668 668
 						return $this->stop('msg_not_allowed_filetype');
669 669
 					}
@@ -672,63 +672,63 @@  discard block
 block discarded – undo
672 672
 				$allowed_filesize = $config->allowed_filesize * 1024 * 1024;
673 673
 				$allowed_attach_size = $config->allowed_attach_size * 1024 * 1024;
674 674
 				// An error appears if file size exceeds a limit
675
-				if($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-1, 'msg_exceeds_limit_size');
675
+				if ($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-1, 'msg_exceeds_limit_size');
676 676
 				// Get total file size of all attachements (from DB)
677 677
 				$size_args = new stdClass;
678 678
 				$size_args->upload_target_srl = $upload_target_srl;
679 679
 				$output = executeQuery('file.getAttachedFileSize', $size_args);
680
-				$attached_size = (int)$output->data->attached_size + filesize($file_info['tmp_name']);
681
-				if($attached_size > $allowed_attach_size) return new Object(-1, 'msg_exceeds_limit_size');
680
+				$attached_size = (int) $output->data->attached_size + filesize($file_info['tmp_name']);
681
+				if ($attached_size > $allowed_attach_size) return new Object(-1, 'msg_exceeds_limit_size');
682 682
 			}
683 683
 		}
684 684
 
685 685
 		// https://github.com/xpressengine/xe-core/issues/1713
686
-		$file_info['name'] = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x',$file_info['name']);
686
+		$file_info['name'] = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x', $file_info['name']);
687 687
 		$file_info['name'] = removeHackTag($file_info['name']);
688
-		$file_info['name'] = str_replace(array('<','>'),array('%3C','%3E'),$file_info['name']);
688
+		$file_info['name'] = str_replace(array('<', '>'), array('%3C', '%3E'), $file_info['name']);
689 689
 
690 690
 		// Get random number generator
691 691
 		$random = new Password();
692 692
 
693 693
 		// Set upload path by checking if the attachement is an image or other kinds of file
694
-		if(preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|swf|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_info['name']))
694
+		if (preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|swf|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_info['name']))
695 695
 		{
696
-			$path = sprintf("./files/attach/images/%s/%s", $module_srl,getNumberingPath($upload_target_srl,3));
696
+			$path = sprintf("./files/attach/images/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3));
697 697
 
698 698
 			// special character to '_'
699 699
 			// change to random file name. because window php bug. window php is not recognize unicode character file name - by cherryfilter
700
-			$ext = substr(strrchr($file_info['name'],'.'),1);
700
+			$ext = substr(strrchr($file_info['name'], '.'), 1);
701 701
 			//$_filename = preg_replace('/[#$&*?+%"\']/', '_', $file_info['name']);
702 702
 			$_filename = $random->createSecureSalt(32, 'hex').'.'.$ext;
703 703
 			$filename  = $path.$_filename;
704 704
 			$idx = 1;
705
-			while(file_exists($filename))
705
+			while (file_exists($filename))
706 706
 			{
707
-				$filename = $path.preg_replace('/\.([a-z0-9]+)$/i','_'.$idx.'.$1',$_filename);
707
+				$filename = $path.preg_replace('/\.([a-z0-9]+)$/i', '_'.$idx.'.$1', $_filename);
708 708
 				$idx++;
709 709
 			}
710 710
 			$direct_download = 'Y';
711 711
 		}
712 712
 		else
713 713
 		{
714
-			$path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3));
714
+			$path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3));
715 715
 			$filename = $path.$random->createSecureSalt(32, 'hex');
716 716
 			$direct_download = 'N';
717 717
 		}
718 718
 		// Create a directory
719
-		if(!FileHandler::makeDir($path)) return new Object(-1,'msg_not_permitted_create');
719
+		if (!FileHandler::makeDir($path)) return new Object(-1, 'msg_not_permitted_create');
720 720
 
721 721
 		// Check uploaded file
722
-		if(!checkUploadedFile($file_info['tmp_name']))  return new Object(-1,'msg_file_upload_error');
722
+		if (!checkUploadedFile($file_info['tmp_name']))  return new Object(-1, 'msg_file_upload_error');
723 723
 
724 724
 		// Get random number generator
725 725
 		$random = new Password();
726 726
 		
727 727
 		// Move the file
728
-		if($manual_insert)
728
+		if ($manual_insert)
729 729
 		{
730 730
 			@copy($file_info['tmp_name'], $filename);
731
-			if(!file_exists($filename))
731
+			if (!file_exists($filename))
732 732
 			{
733 733
 				$filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext;
734 734
 				@copy($file_info['tmp_name'], $filename);
@@ -736,10 +736,10 @@  discard block
 block discarded – undo
736 736
 		}
737 737
 		else
738 738
 		{
739
-			if(!@move_uploaded_file($file_info['tmp_name'], $filename))
739
+			if (!@move_uploaded_file($file_info['tmp_name'], $filename))
740 740
 			{
741 741
 				$filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext;
742
-				if(!@move_uploaded_file($file_info['tmp_name'], $filename))  return new Object(-1,'msg_file_upload_error');
742
+				if (!@move_uploaded_file($file_info['tmp_name'], $filename))  return new Object(-1, 'msg_file_upload_error');
743 743
 			}
744 744
 		}
745 745
 		// Get member information
@@ -760,10 +760,10 @@  discard block
 block discarded – undo
760 760
 		$args->sid = $random->createSecureSalt(32, 'hex');
761 761
 
762 762
 		$output = executeQuery('file.insertFile', $args);
763
-		if(!$output->toBool()) return $output;
763
+		if (!$output->toBool()) return $output;
764 764
 		// Call a trigger (after)
765 765
 		$trigger_output = ModuleHandler::triggerCall('file.insertFile', 'after', $args);
766
-		if(!$trigger_output->toBool()) return $trigger_output;
766
+		if (!$trigger_output->toBool()) return $trigger_output;
767 767
 
768 768
 		$_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true;
769 769
 
@@ -806,18 +806,18 @@  discard block
 block discarded – undo
806 806
 	 */
807 807
 	function deleteFile($file_srl)
808 808
 	{
809
-		if(!$file_srl) return;
809
+		if (!$file_srl) return;
810 810
 
811 811
 		$srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl);
812
-		if(!count($srls)) return;
812
+		if (!count($srls)) return;
813 813
 
814 814
 		$oDocumentController = getController('document');
815 815
 		$documentSrlList = array();
816 816
 
817
-		foreach($srls as $srl)
817
+		foreach ($srls as $srl)
818 818
 		{
819
-			$srl = (int)$srl;
820
-			if(!$srl) 
819
+			$srl = (int) $srl;
820
+			if (!$srl) 
821 821
 			{
822 822
 				continue;
823 823
 			}
@@ -826,14 +826,14 @@  discard block
 block discarded – undo
826 826
 			$args->file_srl = $srl;
827 827
 			$output = executeQuery('file.getFile', $args);
828 828
 
829
-			if(!$output->toBool() || !$output->data) 
829
+			if (!$output->toBool() || !$output->data) 
830 830
 			{
831 831
 				continue;
832 832
 			}
833 833
 
834 834
 			$file_info = $output->data;
835 835
 
836
-			if($file_info->upload_target_srl)
836
+			if ($file_info->upload_target_srl)
837 837
 			{
838 838
 				$documentSrlList[] = $file_info->upload_target_srl;
839 839
 			}
@@ -844,15 +844,15 @@  discard block
 block discarded – undo
844 844
 			// Call a trigger (before)
845 845
 			$trigger_obj = $output->data;
846 846
 			$output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj);
847
-			if(!$output->toBool()) return $output;
847
+			if (!$output->toBool()) return $output;
848 848
 
849 849
 			// Remove from the DB
850 850
 			$output = executeQuery('file.deleteFile', $args);
851
-			if(!$output->toBool()) return $output;
851
+			if (!$output->toBool()) return $output;
852 852
 
853 853
 			// Call a trigger (after)
854 854
 			$trigger_output = ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj);
855
-			if(!$trigger_output->toBool()) return $trigger_output;
855
+			if (!$trigger_output->toBool()) return $trigger_output;
856 856
 
857 857
 			// If successfully deleted, remove the file
858 858
 			FileHandler::removeFile($uploaded_filename);
@@ -876,28 +876,28 @@  discard block
 block discarded – undo
876 876
 		$columnList = array('file_srl', 'uploaded_filename', 'module_srl');
877 877
 		$file_list = $oFileModel->getFiles($upload_target_srl, $columnList);
878 878
 		// Success returned if no attachement exists
879
-		if(!is_array($file_list)||!count($file_list)) return new Object();
879
+		if (!is_array($file_list) || !count($file_list)) return new Object();
880 880
 
881 881
 		// Delete the file
882 882
 		$path = array();
883 883
 		$file_count = count($file_list);
884
-		for($i=0;$i<$file_count;$i++)
884
+		for ($i = 0; $i < $file_count; $i++)
885 885
 		{
886 886
 			$this->deleteFile($file_list[$i]->file_srl);
887 887
 
888 888
 			$uploaded_filename = $file_list[$i]->uploaded_filename;
889 889
 			$path_info = pathinfo($uploaded_filename);
890
-			if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
890
+			if (!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
891 891
 		}
892 892
 
893 893
 		// Remove from the DB
894 894
 		$args = new stdClass();
895 895
 		$args->upload_target_srl = $upload_target_srl;
896 896
 		$output = executeQuery('file.deleteFiles', $args);
897
-		if(!$output->toBool()) return $output;
897
+		if (!$output->toBool()) return $output;
898 898
 		
899 899
 		// Remove a file directory of the document
900
-		for($i=0, $c=count($path); $i<$c; $i++)
900
+		for ($i = 0, $c = count($path); $i < $c; $i++)
901 901
 		{
902 902
 			FileHandler::removeBlankDir($path[$i]);
903 903
 		}
@@ -915,23 +915,23 @@  discard block
 block discarded – undo
915 915
 	 */
916 916
 	function moveFile($source_srl, $target_module_srl, $target_srl)
917 917
 	{
918
-		if($source_srl == $target_srl) return;
918
+		if ($source_srl == $target_srl) return;
919 919
 
920 920
 		$oFileModel = getModel('file');
921 921
 		$file_list = $oFileModel->getFiles($source_srl);
922
-		if(!$file_list) return;
922
+		if (!$file_list) return;
923 923
 
924 924
 		$file_count = count($file_list);
925 925
 
926
-		for($i=0;$i<$file_count;$i++)
926
+		for ($i = 0; $i < $file_count; $i++)
927 927
 		{
928 928
 			unset($file_info);
929 929
 			$file_info = $file_list[$i];
930 930
 			$old_file = $file_info->uploaded_filename;
931 931
 			// Determine the file path by checking if the file is an image or other kinds
932
-			if(preg_match("/\.(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|swf|wav|webm|webp|wma|wmv)$/i", $file_info->source_filename))
932
+			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|swf|wav|webm|webp|wma|wmv)$/i", $file_info->source_filename))
933 933
 			{
934
-				$path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl);
934
+				$path = sprintf("./files/attach/images/%s/%s/", $target_module_srl, $target_srl);
935 935
 				$new_file = $path.$file_info->source_filename;
936 936
 			}
937 937
 			else
@@ -941,7 +941,7 @@  discard block
 block discarded – undo
941 941
 				$new_file = $path.$random->createSecureSalt(32, 'hex');
942 942
 			}
943 943
 			// Pass if a target document to move is same
944
-			if($old_file == $new_file) continue;
944
+			if ($old_file == $new_file) continue;
945 945
 			// Create a directory
946 946
 			FileHandler::makeDir($path);
947 947
 			// Move the file
@@ -961,18 +961,18 @@  discard block
 block discarded – undo
961 961
 		$vars = Context::getRequestVars();
962 962
 		$logged_info = Context::get('logged_info');
963 963
 
964
-		if(!$vars->editor_sequence) return new Object(-1, 'msg_invalid_request');
964
+		if (!$vars->editor_sequence) return new Object(-1, 'msg_invalid_request');
965 965
 
966 966
 		$upload_target_srl = $_SESSION['upload_info'][$vars->editor_sequence]->upload_target_srl;
967 967
 
968 968
 		$oFileModel = getModel('file');
969 969
 		$file_info = $oFileModel->getFile($vars->file_srl);
970 970
 
971
-		if(!$file_info) return new Object(-1, 'msg_not_founded');
971
+		if (!$file_info) return new Object(-1, 'msg_not_founded');
972 972
 
973
-		if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted');
973
+		if (!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted');
974 974
 
975
-		$args =  new stdClass();
975
+		$args = new stdClass();
976 976
 		$args->file_srl = $vars->file_srl;
977 977
 		$args->upload_target_srl = $upload_target_srl;
978 978
 
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
 
982 982
 		$args->cover_image = 'N';
983 983
 		$output = executeQuery('file.updateClearCoverImage', $args);
984
-		if(!$output->toBool())
984
+		if (!$output->toBool())
985 985
 		{
986 986
 			$oDB->rollback();
987 987
 			return $output;
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
 
990 990
 		$args->cover_image = 'Y';
991 991
 		$output = executeQuery('file.updateCoverImage', $args);
992
-		if(!$output->toBool())
992
+		if (!$output->toBool())
993 993
 		{
994 994
 			$oDB->rollback();
995 995
 			return $output;
@@ -1021,9 +1021,9 @@  discard block
 block discarded – undo
1021 1021
 		$fileConfig = $oModuleModel->getModulePartConfig('file', $obj->originModuleSrl);
1022 1022
 
1023 1023
 		$oModuleController = getController('module');
1024
-		if(is_array($obj->moduleSrlList))
1024
+		if (is_array($obj->moduleSrlList))
1025 1025
 		{
1026
-			foreach($obj->moduleSrlList AS $key=>$moduleSrl)
1026
+			foreach ($obj->moduleSrlList AS $key=>$moduleSrl)
1027 1027
 			{
1028 1028
 				$oModuleController->insertModulePartConfig('file', $moduleSrl, $fileConfig);
1029 1029
 			}
Please login to merge, or discard this patch.