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
Pull Request — develop (#1953)
by
unknown
12:50
created
modules/file/file.model.php 2 patches
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -29,24 +29,24 @@  discard block
 block discarded – undo
29 29
 		$mid = Context::get('mid');
30 30
 		$editor_sequence = Context::get('editor_sequence');
31 31
 		$upload_target_srl = Context::get('upload_target_srl');
32
-		if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
32
+		if (!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
33 33
 
34
-		if($upload_target_srl)
34
+		if ($upload_target_srl)
35 35
 		{
36 36
 			$tmp_files = $this->getFiles($upload_target_srl);
37 37
 			$file_count = count($tmp_files);
38 38
 
39
-			for($i=0;$i<$file_count;$i++)
39
+			for ($i = 0; $i < $file_count; $i++)
40 40
 			{
41 41
 				$file_info = $tmp_files[$i];
42
-				if(!$file_info->file_srl) continue;
42
+				if (!$file_info->file_srl) continue;
43 43
 
44 44
 				$obj = new stdClass;
45 45
 				$obj->file_srl = $file_info->file_srl;
46 46
 				$obj->source_filename = $file_info->source_filename;
47 47
 				$obj->file_size = $file_info->file_size;
48 48
 				$obj->disp_file_size = FileHandler::filesize($file_info->file_size);
49
-				if($file_info->direct_download=='N') $obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid, $file_info->module_srl);
49
+				if ($file_info->direct_download == 'N') $obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid, $file_info->module_srl);
50 50
 				else $obj->download_url = str_replace('./', '', $file_info->uploaded_filename);
51 51
 				$obj->direct_download = $file_info->direct_download;
52 52
 				$obj->cover_image = ($file_info->cover_image === 'Y') ? true : false;
@@ -66,17 +66,17 @@  discard block
 block discarded – undo
66 66
 		//$config = $oModuleModel->getModuleInfoByMid($mid);	//perhaps config varialbles not used
67 67
 
68 68
 		$file_config = $this->getUploadConfig();
69
-		$left_size = $file_config->allowed_attach_size*1024*1024 - $attached_size;
69
+		$left_size = $file_config->allowed_attach_size * 1024 * 1024 - $attached_size;
70 70
 		// Settings of required information
71 71
 		$attached_size = FileHandler::filesize($attached_size);
72
-		$allowed_attach_size = FileHandler::filesize($file_config->allowed_attach_size*1024*1024);
73
-		$allowed_filesize = FileHandler::filesize($file_config->allowed_filesize*1024*1024);
72
+		$allowed_attach_size = FileHandler::filesize($file_config->allowed_attach_size * 1024 * 1024);
73
+		$allowed_filesize = FileHandler::filesize($file_config->allowed_filesize * 1024 * 1024);
74 74
 		$allowed_filetypes = $file_config->allowed_filetypes;
75
-		$this->add("files",$files);
76
-		$this->add("editor_sequence",$editor_sequence);
77
-		$this->add("upload_target_srl",$upload_target_srl);
78
-		$this->add("upload_status",$upload_status);
79
-		$this->add("left_size",$left_size);
75
+		$this->add("files", $files);
76
+		$this->add("editor_sequence", $editor_sequence);
77
+		$this->add("upload_target_srl", $upload_target_srl);
78
+		$this->add("upload_status", $upload_status);
79
+		$this->add("left_size", $left_size);
80 80
 		$this->add('attached_size', $attached_size);
81 81
 		$this->add('allowed_attach_size', $allowed_attach_size);
82 82
 		$this->add('allowed_filesize', $allowed_filesize);
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 		$args = new stdClass();
95 95
 		$args->upload_target_srl = $upload_target_srl;
96 96
 		$output = executeQuery('file.getFilesCount', $args);
97
-		return (int)$output->data->count;
97
+		return (int) $output->data->count;
98 98
 	}
99 99
 
100 100
 	/**
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 * @param string $sid
105 105
 	 * @return string Returns a url
106 106
 	 */
107
-	function getDownloadUrl($file_srl, $sid, $module_srl="")
107
+	function getDownloadUrl($file_srl, $sid, $module_srl = "")
108 108
 	{
109 109
 		return sprintf('?module=%s&amp;act=%s&amp;file_srl=%s&amp;sid=%s&amp;module_srl=%s', 'file', 'procFileDownload', $file_srl, $sid, $module_srl);
110 110
 	}
@@ -122,12 +122,12 @@  discard block
 block discarded – undo
122 122
 
123 123
 		$file_module_config = $oModuleModel->getModuleConfig('file');
124 124
 
125
-		if($module_srl) $file_config = $oModuleModel->getModulePartConfig('file',$module_srl);
126
-		if(!$file_config) $file_config = $file_module_config;
125
+		if ($module_srl) $file_config = $oModuleModel->getModulePartConfig('file', $module_srl);
126
+		if (!$file_config) $file_config = $file_module_config;
127 127
 
128 128
 		$config = new stdClass();
129 129
 
130
-		if($file_config)
130
+		if ($file_config)
131 131
 		{
132 132
 			$config->allowed_filesize = $file_config->allowed_filesize;
133 133
 			$config->allowed_attach_size = $file_config->allowed_attach_size;
@@ -138,31 +138,31 @@  discard block
 block discarded – undo
138 138
 			$config->allow_outlink_format = $file_config->allow_outlink_format;
139 139
 		}
140 140
 		// Property for all files comes first than each property
141
-		if(!$config->allowed_filesize) $config->allowed_filesize = $file_module_config->allowed_filesize;
142
-		if(!$config->allowed_attach_size) $config->allowed_attach_size = $file_module_config->allowed_attach_size;
143
-		if(!$config->allowed_filetypes) $config->allowed_filetypes = $file_module_config->allowed_filetypes;
144
-		if(!$config->allow_outlink) $config->allow_outlink = $file_module_config->allow_outlink;
145
-		if(!$config->allow_outlink_site) $config->allow_outlink_site = $file_module_config->allow_outlink_site;
146
-		if(!$config->allow_outlink_format) $config->allow_outlink_format = $file_module_config->allow_outlink_format;
147
-		if(!$config->download_grant) $config->download_grant = $file_module_config->download_grant;
141
+		if (!$config->allowed_filesize) $config->allowed_filesize = $file_module_config->allowed_filesize;
142
+		if (!$config->allowed_attach_size) $config->allowed_attach_size = $file_module_config->allowed_attach_size;
143
+		if (!$config->allowed_filetypes) $config->allowed_filetypes = $file_module_config->allowed_filetypes;
144
+		if (!$config->allow_outlink) $config->allow_outlink = $file_module_config->allow_outlink;
145
+		if (!$config->allow_outlink_site) $config->allow_outlink_site = $file_module_config->allow_outlink_site;
146
+		if (!$config->allow_outlink_format) $config->allow_outlink_format = $file_module_config->allow_outlink_format;
147
+		if (!$config->download_grant) $config->download_grant = $file_module_config->download_grant;
148 148
 		// Default setting if not exists
149
-		if(!$config->allowed_filesize) $config->allowed_filesize = '2';
150
-		if(!$config->allowed_attach_size) $config->allowed_attach_size = '3';
151
-		if(!$config->allowed_filetypes) $config->allowed_filetypes = '*.*';
152
-		if(!$config->allow_outlink) $config->allow_outlink = 'Y';
153
-		if(!$config->download_grant) $config->download_grant = array();
149
+		if (!$config->allowed_filesize) $config->allowed_filesize = '2';
150
+		if (!$config->allowed_attach_size) $config->allowed_attach_size = '3';
151
+		if (!$config->allowed_filetypes) $config->allowed_filetypes = '*.*';
152
+		if (!$config->allow_outlink) $config->allow_outlink = 'Y';
153
+		if (!$config->download_grant) $config->download_grant = array();
154 154
 
155 155
 		$size = ini_get('upload_max_filesize');
156 156
 		$unit = strtolower($size[strlen($size) - 1]);
157
-		$size = (float)$size;
158
-		if($unit == 'g') $size *= 1024;
159
-		if($unit == 'k') $size /= 1024;
157
+		$size = (float) $size;
158
+		if ($unit == 'g') $size *= 1024;
159
+		if ($unit == 'k') $size /= 1024;
160 160
 
161
-		if($config->allowed_filesize > $size) 
161
+		if ($config->allowed_filesize > $size) 
162 162
 		{	
163 163
 			$config->allowed_filesize = $size;
164 164
 		}
165
-		if($config->allowed_attach_size > $size) 
165
+		if ($config->allowed_attach_size > $size) 
166 166
 		{
167 167
 			$config->allowed_attach_size = $size;
168 168
 		}
@@ -182,10 +182,10 @@  discard block
 block discarded – undo
182 182
 		$args = new stdClass();
183 183
 		$args->file_srl = $file_srl;
184 184
 		$output = executeQueryArray('file.getFile', $args, $columnList);
185
-		if(!$output->toBool()) return $output;
185
+		if (!$output->toBool()) return $output;
186 186
 
187 187
 		// old version compatibility
188
-		if(count($output->data) == 1)
188
+		if (count($output->data) == 1)
189 189
 		{
190 190
 			$file = $output->data[0];
191 191
 			$file->download_url = $this->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl);
@@ -196,9 +196,9 @@  discard block
 block discarded – undo
196 196
 		{
197 197
 			$fileList = array();
198 198
 
199
-			if(is_array($output->data))
199
+			if (is_array($output->data))
200 200
 			{
201
-				foreach($output->data as $key=>$value)
201
+				foreach ($output->data as $key=>$value)
202 202
 				{
203 203
 					$file = $value;
204 204
 					$file->download_url = $this->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl);
@@ -222,16 +222,16 @@  discard block
 block discarded – undo
222 222
 		$args = new stdClass();
223 223
 		$args->upload_target_srl = $upload_target_srl;
224 224
 		$args->sort_index = $sortIndex;
225
-		if($ckValid) $args->isvalid = 'Y';
225
+		if ($ckValid) $args->isvalid = 'Y';
226 226
 		$output = executeQuery('file.getFiles', $args, $columnList);
227
-		if(!$output->data) return;
227
+		if (!$output->data) return;
228 228
 
229 229
 		$file_list = $output->data;
230 230
 
231
-		if($file_list && !is_array($file_list)) $file_list = array($file_list);
231
+		if ($file_list && !is_array($file_list)) $file_list = array($file_list);
232 232
 
233 233
 		$file_count = count($file_list);
234
-		for($i=0;$i<$file_count;$i++)
234
+		for ($i = 0; $i < $file_count; $i++)
235 235
 		{
236 236
 			$file = $file_list[$i];
237 237
 			$file->source_filename = stripslashes($file->source_filename);
@@ -254,14 +254,14 @@  discard block
 block discarded – undo
254 254
 
255 255
 		$module_srl = Context::get('module_srl');
256 256
 		// Get the current module if module_srl doesn't exist
257
-		if(!$module_srl)
257
+		if (!$module_srl)
258 258
 		{
259 259
 			$current_module_info = Context::get('current_module_info');
260 260
 			$module_srl = $current_module_info->module_srl;
261 261
 		}
262 262
 		$file_config = $this->getFileConfig($module_srl);
263 263
 
264
-		if($logged_info->is_admin == 'Y')
264
+		if ($logged_info->is_admin == 'Y')
265 265
 		{
266 266
 			$iniPostMaxSize = FileHandler::returnbytes(ini_get('post_max_size'));
267 267
 			$iniUploadMaxSize = FileHandler::returnbytes(ini_get('upload_max_filesize'));
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
 			'%s : %s/ %s<br /> %s : %s (%s : %s)',
288 288
 			Context::getLang('allowed_attach_size'),
289 289
 			FileHandler::filesize($attached_size),
290
-			FileHandler::filesize($file_config->allowed_attach_size*1024*1024),
290
+			FileHandler::filesize($file_config->allowed_attach_size * 1024 * 1024),
291 291
 			Context::getLang('allowed_filesize'),
292
-			FileHandler::filesize($file_config->allowed_filesize*1024*1024),
292
+			FileHandler::filesize($file_config->allowed_filesize * 1024 * 1024),
293 293
 			Context::getLang('allowed_filetypes'),
294 294
 			$file_config->allowed_filetypes
295 295
 		);
@@ -316,9 +316,9 @@  discard block
 block discarded – undo
316 316
 	 */
317 317
 	function getFileGrant($file_info, $member_info)
318 318
 	{
319
-		if(!$file_info) return null;
319
+		if (!$file_info) return null;
320 320
 
321
-		if($_SESSION['__XE_UPLOADING_FILES_INFO__'][$file_info->file_srl])
321
+		if ($_SESSION['__XE_UPLOADING_FILES_INFO__'][$file_info->file_srl])
322 322
 		{
323 323
 			$file_grant->is_deletable = true;
324 324
 			return $file_grant;
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 
330 330
 		$oDocumentModel = getModel('document');
331 331
 		$oDocument = $oDocumentModel->getDocument($file_info->upload_target_srl);
332
-		if($oDocument->isExists()) $document_grant = $oDocument->isGranted();
332
+		if ($oDocument->isExists()) $document_grant = $oDocument->isGranted();
333 333
 
334 334
 		$file_grant->is_deletable = ($document_grant || $member_info->is_admin == 'Y' || $member_info->member_srl == $file_info->member_srl || $grant->manager);
335 335
 
Please login to merge, or discard this patch.
Braces   +79 added lines, -30 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		$mid = Context::get('mid');
30 30
 		$editor_sequence = Context::get('editor_sequence');
31 31
 		$upload_target_srl = Context::get('upload_target_srl');
32
-		if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
32
+		if(!$upload_target_srl) {
33
+			$upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
34
+		}
33 35
 
34 36
 		if($upload_target_srl)
35 37
 		{
@@ -39,22 +41,26 @@  discard block
 block discarded – undo
39 41
 			for($i=0;$i<$file_count;$i++)
40 42
 			{
41 43
 				$file_info = $tmp_files[$i];
42
-				if(!$file_info->file_srl) continue;
44
+				if(!$file_info->file_srl) {
45
+					continue;
46
+				}
43 47
 
44 48
 				$obj = new stdClass;
45 49
 				$obj->file_srl = $file_info->file_srl;
46 50
 				$obj->source_filename = $file_info->source_filename;
47 51
 				$obj->file_size = $file_info->file_size;
48 52
 				$obj->disp_file_size = FileHandler::filesize($file_info->file_size);
49
-				if($file_info->direct_download=='N') $obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid, $file_info->module_srl);
50
-				else $obj->download_url = str_replace('./', '', $file_info->uploaded_filename);
53
+				if($file_info->direct_download=='N') {
54
+					$obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid, $file_info->module_srl);
55
+				} else {
56
+					$obj->download_url = str_replace('./', '', $file_info->uploaded_filename);
57
+				}
51 58
 				$obj->direct_download = $file_info->direct_download;
52 59
 				$obj->cover_image = ($file_info->cover_image === 'Y') ? true : false;
53 60
 				$files[] = $obj;
54 61
 				$attached_size += $file_info->file_size;
55 62
 			}
56
-		}
57
-		else
63
+		} else
58 64
 		{
59 65
 			$upload_target_srl = 0;
60 66
 			$attached_size = 0;
@@ -122,8 +128,12 @@  discard block
 block discarded – undo
122 128
 
123 129
 		$file_module_config = $oModuleModel->getModuleConfig('file');
124 130
 
125
-		if($module_srl) $file_config = $oModuleModel->getModulePartConfig('file',$module_srl);
126
-		if(!$file_config) $file_config = $file_module_config;
131
+		if($module_srl) {
132
+			$file_config = $oModuleModel->getModulePartConfig('file',$module_srl);
133
+		}
134
+		if(!$file_config) {
135
+			$file_config = $file_module_config;
136
+		}
127 137
 
128 138
 		$config = new stdClass();
129 139
 
@@ -138,25 +148,53 @@  discard block
 block discarded – undo
138 148
 			$config->allow_outlink_format = $file_config->allow_outlink_format;
139 149
 		}
140 150
 		// Property for all files comes first than each property
141
-		if(!$config->allowed_filesize) $config->allowed_filesize = $file_module_config->allowed_filesize;
142
-		if(!$config->allowed_attach_size) $config->allowed_attach_size = $file_module_config->allowed_attach_size;
143
-		if(!$config->allowed_filetypes) $config->allowed_filetypes = $file_module_config->allowed_filetypes;
144
-		if(!$config->allow_outlink) $config->allow_outlink = $file_module_config->allow_outlink;
145
-		if(!$config->allow_outlink_site) $config->allow_outlink_site = $file_module_config->allow_outlink_site;
146
-		if(!$config->allow_outlink_format) $config->allow_outlink_format = $file_module_config->allow_outlink_format;
147
-		if(!$config->download_grant) $config->download_grant = $file_module_config->download_grant;
151
+		if(!$config->allowed_filesize) {
152
+			$config->allowed_filesize = $file_module_config->allowed_filesize;
153
+		}
154
+		if(!$config->allowed_attach_size) {
155
+			$config->allowed_attach_size = $file_module_config->allowed_attach_size;
156
+		}
157
+		if(!$config->allowed_filetypes) {
158
+			$config->allowed_filetypes = $file_module_config->allowed_filetypes;
159
+		}
160
+		if(!$config->allow_outlink) {
161
+			$config->allow_outlink = $file_module_config->allow_outlink;
162
+		}
163
+		if(!$config->allow_outlink_site) {
164
+			$config->allow_outlink_site = $file_module_config->allow_outlink_site;
165
+		}
166
+		if(!$config->allow_outlink_format) {
167
+			$config->allow_outlink_format = $file_module_config->allow_outlink_format;
168
+		}
169
+		if(!$config->download_grant) {
170
+			$config->download_grant = $file_module_config->download_grant;
171
+		}
148 172
 		// Default setting if not exists
149
-		if(!$config->allowed_filesize) $config->allowed_filesize = '2';
150
-		if(!$config->allowed_attach_size) $config->allowed_attach_size = '3';
151
-		if(!$config->allowed_filetypes) $config->allowed_filetypes = '*.*';
152
-		if(!$config->allow_outlink) $config->allow_outlink = 'Y';
153
-		if(!$config->download_grant) $config->download_grant = array();
173
+		if(!$config->allowed_filesize) {
174
+			$config->allowed_filesize = '2';
175
+		}
176
+		if(!$config->allowed_attach_size) {
177
+			$config->allowed_attach_size = '3';
178
+		}
179
+		if(!$config->allowed_filetypes) {
180
+			$config->allowed_filetypes = '*.*';
181
+		}
182
+		if(!$config->allow_outlink) {
183
+			$config->allow_outlink = 'Y';
184
+		}
185
+		if(!$config->download_grant) {
186
+			$config->download_grant = array();
187
+		}
154 188
 
155 189
 		$size = ini_get('upload_max_filesize');
156 190
 		$unit = strtolower($size[strlen($size) - 1]);
157 191
 		$size = (float)$size;
158
-		if($unit == 'g') $size *= 1024;
159
-		if($unit == 'k') $size /= 1024;
192
+		if($unit == 'g') {
193
+			$size *= 1024;
194
+		}
195
+		if($unit == 'k') {
196
+			$size /= 1024;
197
+		}
160 198
 
161 199
 		if($config->allowed_filesize > $size) 
162 200
 		{	
@@ -182,7 +220,9 @@  discard block
 block discarded – undo
182 220
 		$args = new stdClass();
183 221
 		$args->file_srl = $file_srl;
184 222
 		$output = executeQueryArray('file.getFile', $args, $columnList);
185
-		if(!$output->toBool()) return $output;
223
+		if(!$output->toBool()) {
224
+			return $output;
225
+		}
186 226
 
187 227
 		// old version compatibility
188 228
 		if(count($output->data) == 1)
@@ -191,8 +231,7 @@  discard block
 block discarded – undo
191 231
 			$file->download_url = $this->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl);
192 232
 
193 233
 			return $file;
194
-		}
195
-		else
234
+		} else
196 235
 		{
197 236
 			$fileList = array();
198 237
 
@@ -222,13 +261,19 @@  discard block
 block discarded – undo
222 261
 		$args = new stdClass();
223 262
 		$args->upload_target_srl = $upload_target_srl;
224 263
 		$args->sort_index = $sortIndex;
225
-		if($ckValid) $args->isvalid = 'Y';
264
+		if($ckValid) {
265
+			$args->isvalid = 'Y';
266
+		}
226 267
 		$output = executeQuery('file.getFiles', $args, $columnList);
227
-		if(!$output->data) return;
268
+		if(!$output->data) {
269
+			return;
270
+		}
228 271
 
229 272
 		$file_list = $output->data;
230 273
 
231
-		if($file_list && !is_array($file_list)) $file_list = array($file_list);
274
+		if($file_list && !is_array($file_list)) {
275
+			$file_list = array($file_list);
276
+		}
232 277
 
233 278
 		$file_count = count($file_list);
234 279
 		for($i=0;$i<$file_count;$i++)
@@ -316,7 +361,9 @@  discard block
 block discarded – undo
316 361
 	 */
317 362
 	function getFileGrant($file_info, $member_info)
318 363
 	{
319
-		if(!$file_info) return null;
364
+		if(!$file_info) {
365
+			return null;
366
+		}
320 367
 
321 368
 		if($_SESSION['__XE_UPLOADING_FILES_INFO__'][$file_info->file_srl])
322 369
 		{
@@ -329,7 +376,9 @@  discard block
 block discarded – undo
329 376
 
330 377
 		$oDocumentModel = getModel('document');
331 378
 		$oDocument = $oDocumentModel->getDocument($file_info->upload_target_srl);
332
-		if($oDocument->isExists()) $document_grant = $oDocument->isGranted();
379
+		if($oDocument->isExists()) {
380
+			$document_grant = $oDocument->isGranted();
381
+		}
333 382
 
334 383
 		$file_grant->is_deletable = ($document_grant || $member_info->is_admin == 'Y' || $member_info->member_srl == $file_info->member_srl || $grant->manager);
335 384
 
Please login to merge, or discard this patch.