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 ( c67393...45bf93 )
by gyeong-won
14:34
created
modules/file/file.model.php 1 patch
Spacing   +47 added lines, -47 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,26 +138,26 @@  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 = preg_replace('/[a-z]/is', '', ini_get('upload_max_filesize'));
156
-		if($config->allowed_filesize > $size) 
156
+		if ($config->allowed_filesize > $size) 
157 157
 		{	
158 158
 			$config->allowed_filesize = $size;
159 159
 		}
160
-		if($config->allowed_attach_size > $size) 
160
+		if ($config->allowed_attach_size > $size) 
161 161
 		{
162 162
 			$config->allowed_attach_size = $size;
163 163
 		}
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
 		$args = new stdClass();
178 178
 		$args->file_srl = $file_srl;
179 179
 		$output = executeQueryArray('file.getFile', $args, $columnList);
180
-		if(!$output->toBool()) return $output;
180
+		if (!$output->toBool()) return $output;
181 181
 
182 182
 		// old version compatibility
183
-		if(count($output->data) == 1)
183
+		if (count($output->data) == 1)
184 184
 		{
185 185
 			$file = $output->data[0];
186 186
 			$file->download_url = $this->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl);
@@ -191,9 +191,9 @@  discard block
 block discarded – undo
191 191
 		{
192 192
 			$fileList = array();
193 193
 
194
-			if(is_array($output->data))
194
+			if (is_array($output->data))
195 195
 			{
196
-				foreach($output->data as $key=>$value)
196
+				foreach ($output->data as $key=>$value)
197 197
 				{
198 198
 					$file = $value;
199 199
 					$file->download_url = $this->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl);
@@ -217,16 +217,16 @@  discard block
 block discarded – undo
217 217
 		$args = new stdClass();
218 218
 		$args->upload_target_srl = $upload_target_srl;
219 219
 		$args->sort_index = $sortIndex;
220
-		if($ckValid) $args->isvalid = 'Y';
220
+		if ($ckValid) $args->isvalid = 'Y';
221 221
 		$output = executeQuery('file.getFiles', $args, $columnList);
222
-		if(!$output->data) return;
222
+		if (!$output->data) return;
223 223
 
224 224
 		$file_list = $output->data;
225 225
 
226
-		if($file_list && !is_array($file_list)) $file_list = array($file_list);
226
+		if ($file_list && !is_array($file_list)) $file_list = array($file_list);
227 227
 
228 228
 		$file_count = count($file_list);
229
-		for($i=0;$i<$file_count;$i++)
229
+		for ($i = 0; $i < $file_count; $i++)
230 230
 		{
231 231
 			$file = $file_list[$i];
232 232
 			$file->source_filename = stripslashes($file->source_filename);
@@ -249,14 +249,14 @@  discard block
 block discarded – undo
249 249
 
250 250
 		$module_srl = Context::get('module_srl');
251 251
 		// Get the current module if module_srl doesn't exist
252
-		if(!$module_srl)
252
+		if (!$module_srl)
253 253
 		{
254 254
 			$current_module_info = Context::get('current_module_info');
255 255
 			$module_srl = $current_module_info->module_srl;
256 256
 		}
257 257
 		$file_config = $this->getFileConfig($module_srl);
258 258
 
259
-		if($logged_info->is_admin == 'Y')
259
+		if ($logged_info->is_admin == 'Y')
260 260
 		{
261 261
 			$iniPostMaxSize = FileHandler::returnbytes(ini_get('post_max_size'));
262 262
 			$iniUploadMaxSize = FileHandler::returnbytes(ini_get('upload_max_filesize'));
@@ -282,9 +282,9 @@  discard block
 block discarded – undo
282 282
 			'%s : %s/ %s<br /> %s : %s (%s : %s)',
283 283
 			Context::getLang('allowed_attach_size'),
284 284
 			FileHandler::filesize($attached_size),
285
-			FileHandler::filesize($file_config->allowed_attach_size*1024*1024),
285
+			FileHandler::filesize($file_config->allowed_attach_size * 1024 * 1024),
286 286
 			Context::getLang('allowed_filesize'),
287
-			FileHandler::filesize($file_config->allowed_filesize*1024*1024),
287
+			FileHandler::filesize($file_config->allowed_filesize * 1024 * 1024),
288 288
 			Context::getLang('allowed_filetypes'),
289 289
 			$file_config->allowed_filetypes
290 290
 		);
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
 	 */
312 312
 	function getFileGrant($file_info, $member_info)
313 313
 	{
314
-		if(!$file_info) return null;
314
+		if (!$file_info) return null;
315 315
 
316
-		if($_SESSION['__XE_UPLOADING_FILES_INFO__'][$file_info->file_srl])
316
+		if ($_SESSION['__XE_UPLOADING_FILES_INFO__'][$file_info->file_srl])
317 317
 		{
318 318
 			$file_grant->is_deletable = true;
319 319
 			return $file_grant;
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 
325 325
 		$oDocumentModel = getModel('document');
326 326
 		$oDocument = $oDocumentModel->getDocument($file_info->upload_target_srl);
327
-		if($oDocument->isExists()) $document_grant = $oDocument->isGranted();
327
+		if ($oDocument->isExists()) $document_grant = $oDocument->isGranted();
328 328
 
329 329
 		$file_grant->is_deletable = ($document_grant || $member_info->is_admin == 'Y' || $member_info->member_srl == $file_info->member_srl || $grant->manager);
330 330
 
Please login to merge, or discard this patch.
classes/validator/Validator.class.php 1 patch
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		$this->_filters = array();
82 82
 		$this->_xml_ruleset = NULL;
83 83
 
84
-		if($xml_path)
84
+		if ($xml_path)
85 85
 			$this->load($xml_path);
86 86
 
87 87
 		// predefined rules
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		));
97 97
 
98 98
 		$this->_has_mb_func = is_callable('mb_strlen');
99
-		$this->setCacheDir(_XE_PATH_ . 'files/cache');
99
+		$this->setCacheDir(_XE_PATH_.'files/cache');
100 100
 	}
101 101
 
102 102
 	/**
@@ -119,32 +119,32 @@  discard block
 block discarded – undo
119 119
 		$this->_xml_ruleset = NULL;
120 120
 
121 121
 		$xml_path = realpath($xml_path);
122
-		if(!is_readable($xml_path))
122
+		if (!is_readable($xml_path))
123 123
 		{
124 124
 			return FALSE;
125 125
 		}
126 126
 
127 127
 		$parser = new XmlParser();
128 128
 		$xml = $parser->loadXmlFile($xml_path);
129
-		if(!isset($xml->ruleset) || !isset($xml->ruleset->fields) || !isset($xml->ruleset->fields->field))
129
+		if (!isset($xml->ruleset) || !isset($xml->ruleset->fields) || !isset($xml->ruleset->fields->field))
130 130
 		{
131 131
 			return FALSE;
132 132
 		}
133 133
 
134 134
 		// custom rules
135
-		if(isset($xml->ruleset->customrules) && isset($xml->ruleset->customrules->rule))
135
+		if (isset($xml->ruleset->customrules) && isset($xml->ruleset->customrules->rule))
136 136
 		{
137 137
 			$customrules = $xml->ruleset->customrules->rule;
138
-			if(!is_array($customrules))
138
+			if (!is_array($customrules))
139 139
 			{
140 140
 				$customrules = array($customrules);
141 141
 			}
142 142
 
143 143
 			$rules = array();
144 144
 			$messages = array();
145
-			foreach($customrules as $rule)
145
+			foreach ($customrules as $rule)
146 146
 			{
147
-				if(!isset($rule->attrs) || !isset($rule->attrs->name))
147
+				if (!isset($rule->attrs) || !isset($rule->attrs->name))
148 148
 				{
149 149
 					continue;
150 150
 				}
@@ -156,12 +156,12 @@  discard block
 block discarded – undo
156 156
 				unset($rule['name']);
157 157
 
158 158
 				$rules[$name] = $rule;
159
-				if(isset($message))
159
+				if (isset($message))
160 160
 				{
161
-					$messages['invalid_' . $name] = $message;
161
+					$messages['invalid_'.$name] = $message;
162 162
 				}
163 163
 			}
164
-			if(count($rules))
164
+			if (count($rules))
165 165
 			{
166 166
 				$this->addRule($rules);
167 167
 			}
@@ -169,19 +169,19 @@  discard block
 block discarded – undo
169 169
 
170 170
 		// filters
171 171
 		$fields = $xml->ruleset->fields->field;
172
-		if(!is_array($fields))
172
+		if (!is_array($fields))
173 173
 		{
174 174
 			$fields = array($fields);
175 175
 		}
176 176
 
177 177
 		$filters = array();
178 178
 		$fieldsNames = array();
179
-		foreach($fields as $field)
179
+		foreach ($fields as $field)
180 180
 		{
181 181
 			$name = '';
182 182
 			$filter = array();
183 183
 
184
-			if(!isset($field->attrs) || !isset($field->attrs->name))
184
+			if (!isset($field->attrs) || !isset($field->attrs->name))
185 185
 			{
186 186
 				continue;
187 187
 			}
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 			$filter['title'] = $title;
192 192
 
193 193
 			$name = $filter['name'];
194
-			if(isset($title))
194
+			if (isset($title))
195 195
 			{
196 196
 				$fieldsNames[$name] = $title;
197 197
 			}
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
 			unset($filter['name']);
200 200
 
201 201
 			// conditional statement
202
-			if(isset($field->if))
202
+			if (isset($field->if))
203 203
 			{
204 204
 				$if = $field->if;
205
-				if(!is_array($if))
205
+				if (!is_array($if))
206 206
 				{
207 207
 					$if = array($if);
208 208
 				}
209
-				foreach($if as $idx => $cond)
209
+				foreach ($if as $idx => $cond)
210 210
 				{
211 211
 					$if[$idx] = (array) $cond->attrs;
212 212
 				}
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	 */
233 233
 	function setCacheDir($cache_dir)
234 234
 	{
235
-		if(is_dir($cache_dir))
235
+		if (is_dir($cache_dir))
236 236
 		{
237 237
 			$this->_cache_dir = preg_replace('@/$@', '', $cache_dir);
238 238
 		}
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 */
246 246
 	function validate($fields_ = null)
247 247
 	{
248
-		if(is_array($fields_))
248
+		if (is_array($fields_))
249 249
 		{
250 250
 			$fields = $fields_;
251 251
 		}
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 			$fields = (array) Context::getRequestVars();
256 256
 		}
257 257
 
258
-		if(!is_array($fields))
258
+		if (!is_array($fields))
259 259
 		{
260 260
 			return TRUE;
261 261
 		}
@@ -276,14 +276,14 @@  discard block
 block discarded – undo
276 276
 		$filters = array();
277 277
 
278 278
 		// get field names matching patterns
279
-		foreach($this->_filters as $key => $filter)
279
+		foreach ($this->_filters as $key => $filter)
280 280
 		{
281 281
 			$names = array();
282
-			if($key{0} == '^')
282
+			if ($key{0} == '^')
283 283
 			{
284
-				$names = preg_grep('/^' . preg_quote(substr($key, 1)) . '/', $field_names);
284
+				$names = preg_grep('/^'.preg_quote(substr($key, 1)).'/', $field_names);
285 285
 			}
286
-			elseif(substr($key, -2) == '[]')
286
+			elseif (substr($key, -2) == '[]')
287 287
 			{
288 288
 				$filters[substr($key, 0, -2)] = $filter;
289 289
 				unset($filters[$key]);
@@ -293,24 +293,24 @@  discard block
 block discarded – undo
293 293
 				$filters[$key] = $filter;
294 294
 			}
295 295
 
296
-			if(!count($names))
296
+			if (!count($names))
297 297
 			{
298 298
 				continue;
299 299
 			}
300 300
 
301
-			foreach($names as $name)
301
+			foreach ($names as $name)
302 302
 			{
303 303
 				$filters[$name] = $filter;
304 304
 			}
305 305
 			unset($filters[$key]);
306 306
 		}
307 307
 
308
-		foreach($filters as $key => $filter)
308
+		foreach ($filters as $key => $filter)
309 309
 		{
310 310
 			$fname = preg_replace('/\[\]$/', '', $key);
311 311
 			$filter = array_merge($filter_default, $filter);
312 312
 
313
-			if(preg_match("/(^[a-z_]*)[\[](?:\'|\")?([a-z_]*)(?:\'|\")?[\]]$/i", $key, $matches))
313
+			if (preg_match("/(^[a-z_]*)[\[](?:\'|\")?([a-z_]*)(?:\'|\")?[\]]$/i", $key, $matches))
314 314
 			{
315 315
 				$exists = array_key_exists($matches[1], $fields);
316 316
 				$value = $exists ? $fields[$matches[1]][$matches[2]] : NULL;
@@ -321,9 +321,9 @@  discard block
 block discarded – undo
321 321
 				$value = $exists ? $fields[$fname] : NULL;
322 322
 			}
323 323
 
324
-			if(is_array($value))
324
+			if (is_array($value))
325 325
 			{
326
-				if(!isset($value[tmp_name]))
326
+				if (!isset($value[tmp_name]))
327 327
 				{
328 328
 					$value = implode('', $value);
329 329
 				}
@@ -334,9 +334,9 @@  discard block
 block discarded – undo
334 334
 			}
335 335
 
336 336
 			// conditional statement
337
-			foreach($filter['if'] as $cond)
337
+			foreach ($filter['if'] as $cond)
338 338
 			{
339
-				if(!isset($cond['test']) || !isset($cond['attr']))
339
+				if (!isset($cond['test']) || !isset($cond['attr']))
340 340
 				{
341 341
 					continue;
342 342
 				}
@@ -344,17 +344,17 @@  discard block
 block discarded – undo
344 344
 				$func_body = preg_replace('/\\$(\w+)/', '$c[\'$1\']', $cond['test']);
345 345
 				$func = create_function('$c', "return !!({$func_body});");
346 346
 
347
-				if($func($fields))
347
+				if ($func($fields))
348 348
 				{
349 349
 					$filter[$cond['attr']] = $cond['value'];
350 350
 				}
351 351
 			}
352 352
 
353 353
 			// attr : default
354
-			if(!$value && strlen($default = trim($filter['default'])))
354
+			if (!$value && strlen($default = trim($filter['default'])))
355 355
 			{
356 356
 				$value = $default;
357
-				if(is_null($fields_))
357
+				if (is_null($fields_))
358 358
 				{
359 359
 					Context::set($fname, $value);
360 360
 				}
@@ -366,25 +366,25 @@  discard block
 block discarded – undo
366 366
 			$value_len = strlen($value);
367 367
 
368 368
 			// attr : modifier
369
-			if(is_string($modifiers = $filter['modifiers']))
369
+			if (is_string($modifiers = $filter['modifiers']))
370 370
 			{
371 371
 				$modifiers = explode(',', trim($modifiers));
372 372
 			}
373 373
 
374 374
 			// attr : required
375
-			if($filter['required'] === 'true' && !$value_len)
375
+			if ($filter['required'] === 'true' && !$value_len)
376 376
 			{
377 377
 				return $this->error($key, 'isnull');
378 378
 			}
379 379
 
380 380
 			// if the field wasn't passed, ignore this value
381
-			if(!$exists && !$value_len)
381
+			if (!$exists && !$value_len)
382 382
 			{
383 383
 				continue;
384 384
 			}
385 385
 
386 386
 			// attr : length
387
-			if($length = $filter['length'])
387
+			if ($length = $filter['length'])
388 388
 			{
389 389
 				list($min, $max) = explode(':', trim($length));
390 390
 				$is_min_b = (substr($min, -1) === 'b');
@@ -392,41 +392,41 @@  discard block
 block discarded – undo
392 392
 				list($min, $max) = array((int) $min, (int) $max);
393 393
 
394 394
 				$strbytes = strlen($value);
395
-				if(!$is_min_b || !$is_max_b)
395
+				if (!$is_min_b || !$is_max_b)
396 396
 				{
397 397
 					$strlength = $this->_has_mb_func ? mb_strlen($value, 'utf-8') : $this->mbStrLen($value);
398 398
 				}
399 399
 
400
-				if(($min && $min > ($is_min_b ? $strbytes : $strlength)) || ($max && $max < ($is_max_b ? $strbytes : $strlength)))
400
+				if (($min && $min > ($is_min_b ? $strbytes : $strlength)) || ($max && $max < ($is_max_b ? $strbytes : $strlength)))
401 401
 				{
402 402
 					return $this->error($key, 'outofrange');
403 403
 				}
404 404
 			}
405 405
 
406 406
 			// equalto
407
-			if($equalto = $filter['equalto'])
407
+			if ($equalto = $filter['equalto'])
408 408
 			{
409
-				if(!array_key_exists($equalto, $fields) || trim($fields[$equalto]) !== $value)
409
+				if (!array_key_exists($equalto, $fields) || trim($fields[$equalto]) !== $value)
410 410
 				{
411 411
 					return $this->error($key, 'equalto');
412 412
 				}
413 413
 			}
414 414
 
415 415
 			// rules
416
-			if($rules = $filter['rule'])
416
+			if ($rules = $filter['rule'])
417 417
 			{
418 418
 				$rules = explode(',', $rules);
419
-				foreach($rules as $rule)
419
+				foreach ($rules as $rule)
420 420
 				{
421 421
 					$result = $this->applyRule($rule, $value);
422 422
 					// apply the 'not' modifier
423
-					if(in_array('not', $modifiers))
423
+					if (in_array('not', $modifiers))
424 424
 					{
425 425
 						$result = !$result;
426 426
 					}
427
-					if(!$result)
427
+					if (!$result)
428 428
 					{
429
-						return $this->error($key, 'invalid_' . $rule);
429
+						return $this->error($key, 'invalid_'.$rule);
430 430
 					}
431 431
 				}
432 432
 			}
@@ -442,12 +442,12 @@  discard block
 block discarded – undo
442 442
 	 */
443 443
 	function arrayTrim($array)
444 444
 	{
445
-		if(!is_array($array))
445
+		if (!is_array($array))
446 446
 		{
447 447
 			return trim($array);
448 448
 		}
449 449
 
450
-		foreach($array as $key => $value)
450
+		foreach ($array as $key => $value)
451 451
 		{
452 452
 			$array[$key] = $this->arrayTrim($value);
453 453
 		}
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 	 */
463 463
 	function error($field, $msg)
464 464
 	{
465
-		if(isset($this->_message[$msg]))
465
+		if (isset($this->_message[$msg]))
466 466
 		{
467 467
 			$msg = $this->_message[$msg];
468 468
 		}
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 			$msg = isset($lang_filter->{$msg}) ? $lang_filter->{$msg} : $lang_filter->invalid;
473 473
 		}
474 474
 
475
-		if(isset($this->_fieldNames[$field]))
475
+		if (isset($this->_fieldNames[$field]))
476 476
 		{
477 477
 			$fieldName = $this->_fieldNames[$field];
478 478
 		}
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 	 */
506 506
 	function addRule($name, $rule = '')
507 507
 	{
508
-		if(is_array($name))
508
+		if (is_array($name))
509 509
 		{
510 510
 			$args = $name;
511 511
 		}
@@ -514,18 +514,18 @@  discard block
 block discarded – undo
514 514
 			$args = array($name => $rule);
515 515
 		}
516 516
 
517
-		foreach($args as $name => $rule)
517
+		foreach ($args as $name => $rule)
518 518
 		{
519
-			if(!$rule)
519
+			if (!$rule)
520 520
 			{
521 521
 				continue;
522 522
 			}
523
-			if(is_string($rule))
523
+			if (is_string($rule))
524 524
 			{
525 525
 				$rule = array('type' => 'regex', 'test' => $rule);
526 526
 			}
527 527
 
528
-			if($rule['type'] == 'enum')
528
+			if ($rule['type'] == 'enum')
529 529
 			{
530 530
 				$delim = isset($rule['delim']) ? $rule['delim'] : ',';
531 531
 				$rule['test'] = explode($delim, $rule['test']);
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 	 */
554 554
 	function addFilter($name, $filter = '')
555 555
 	{
556
-		if(is_array($name))
556
+		if (is_array($name))
557 557
 		{
558 558
 			$args = $name;
559 559
 		}
@@ -562,19 +562,19 @@  discard block
 block discarded – undo
562 562
 			$args = array($name => $filter);
563 563
 		}
564 564
 
565
-		foreach($args as $name => $filter)
565
+		foreach ($args as $name => $filter)
566 566
 		{
567
-			if(!$filter)
567
+			if (!$filter)
568 568
 			{
569 569
 				continue;
570 570
 			}
571 571
 
572
-			if(isset($filter['if']))
572
+			if (isset($filter['if']))
573 573
 			{
574
-				if(is_array($filter['if']) && count($filter['if']))
574
+				if (is_array($filter['if']) && count($filter['if']))
575 575
 				{
576 576
 					$key = key($filter['if']);
577
-					if(!is_int($key))
577
+					if (!is_int($key))
578 578
 					{
579 579
 						$filter['if'] = array($filter['if']);
580 580
 					}
@@ -609,21 +609,21 @@  discard block
 block discarded – undo
609 609
 	{
610 610
 		$rule = $this->_rules[$name];
611 611
 
612
-		if(is_array($value) && isset($value['tmp_name']))
612
+		if (is_array($value) && isset($value['tmp_name']))
613 613
 		{
614 614
 			$value = $value['name'];
615 615
 		}
616 616
 
617
-		switch($rule['type'])
617
+		switch ($rule['type'])
618 618
 		{
619 619
 			case 'regex':
620 620
 				return (preg_match($rule['test'], $value) > 0);
621 621
 			case 'enum':
622 622
 				return in_array($value, $rule['test']);
623 623
 			case 'expr':
624
-				if(!$rule['func_test'])
624
+				if (!$rule['func_test'])
625 625
 				{
626
-					$rule['func_test'] = create_function('$a', 'return (' . preg_replace('/\$\$/', '$a', html_entity_decode($rule['test'])) . ');');
626
+					$rule['func_test'] = create_function('$a', 'return ('.preg_replace('/\$\$/', '$a', html_entity_decode($rule['test'])).');');
627 627
 				}
628 628
 				return $rule['func_test']($value);
629 629
 		}
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 	function mbStrLen($str)
640 640
 	{
641 641
 		$arr = count_chars($str);
642
-		for($i = 0x80; $i < 0xc0; $i++)
642
+		for ($i = 0x80; $i < 0xc0; $i++)
643 643
 		{
644 644
 			unset($arr[$i]);
645 645
 		}
@@ -652,17 +652,17 @@  discard block
 block discarded – undo
652 652
 	 */
653 653
 	function getJsPath()
654 654
 	{
655
-		if(!$this->_cache_dir)
655
+		if (!$this->_cache_dir)
656 656
 		{
657 657
 			return FALSE;
658 658
 		}
659 659
 
660
-		$dir = $this->_cache_dir . '/ruleset';
661
-		if(!is_dir($dir) && !mkdir($dir))
660
+		$dir = $this->_cache_dir.'/ruleset';
661
+		if (!is_dir($dir) && !mkdir($dir))
662 662
 		{
663 663
 			return FALSE;
664 664
 		}
665
-		if(!$this->_xml_path)
665
+		if (!$this->_xml_path)
666 666
 		{
667 667
 			return FALSE;
668 668
 		}
@@ -671,14 +671,14 @@  discard block
 block discarded – undo
671 671
 		$lang_type = class_exists('Context', false) ? Context::getLangType() : 'en';
672 672
 
673 673
 		// check the file
674
-		$filepath = $dir . '/' . md5($this->_version . ' ' . $this->_xml_path) . ".{$lang_type}.js";
675
-		if(is_readable($filepath) && filemtime($filepath) > filemtime($this->_xml_path))
674
+		$filepath = $dir.'/'.md5($this->_version.' '.$this->_xml_path).".{$lang_type}.js";
675
+		if (is_readable($filepath) && filemtime($filepath) > filemtime($this->_xml_path))
676 676
 		{
677 677
 			return $filepath;
678 678
 		}
679 679
 
680 680
 		$content = $this->_compile2js();
681
-		if($content === FALSE)
681
+		if ($content === FALSE)
682 682
 		{
683 683
 			return FALSE;
684 684
 		}
@@ -699,9 +699,9 @@  discard block
 block discarded – undo
699 699
 		$ruleset = basename($this->_xml_path, '.xml');
700 700
 		$content = array();
701 701
 
702
-		if(preg_match('@(^|/)files/ruleset/\w+\.xml$@i', $this->_xml_path))
702
+		if (preg_match('@(^|/)files/ruleset/\w+\.xml$@i', $this->_xml_path))
703 703
 		{
704
-			$ruleset = '@' . $ruleset;
704
+			$ruleset = '@'.$ruleset;
705 705
 		}
706 706
 
707 707
 		list($ruleset) = explode('.', $ruleset);
@@ -711,22 +711,22 @@  discard block
 block discarded – undo
711 711
 
712 712
 		// custom rulesets
713 713
 		$addrules = array();
714
-		foreach($this->_rules as $name => $rule)
714
+		foreach ($this->_rules as $name => $rule)
715 715
 		{
716 716
 			$name = strtolower($name);
717 717
 
718
-			if(in_array($name, array('email', 'userid', 'url', 'alpha', 'alpha_number', 'number', 'float')))
718
+			if (in_array($name, array('email', 'userid', 'url', 'alpha', 'alpha_number', 'number', 'float')))
719 719
 			{
720 720
 				continue;
721 721
 			}
722 722
 
723
-			switch($rule['type'])
723
+			switch ($rule['type'])
724 724
 			{
725 725
 				case 'regex':
726 726
 					$addrules[] = "v.cast('ADD_RULE', ['{$name}', {$rule['test']}]);";
727 727
 					break;
728 728
 				case 'enum':
729
-					$enums = '"' . implode('","', $rule['test']) . '"';
729
+					$enums = '"'.implode('","', $rule['test']).'"';
730 730
 					$addrules[] = "v.cast('ADD_RULE', ['{$name}', function($$){ return ($.inArray($$,[{$enums}]) > -1); }]);";
731 731
 					break;
732 732
 				case 'expr':
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
 			}
736 736
 
737 737
 			// if have a message, add message
738
-			if(isset($rule['message']))
738
+			if (isset($rule['message']))
739 739
 			{
740 740
 				$text = preg_replace('@\r?\n@', '\\n', addslashes($rule['message']));
741 741
 				$addrules[] = "v.cast('ADD_MESSAGE',['invalid_{$name}','{$text}']);";
@@ -746,79 +746,79 @@  discard block
 block discarded – undo
746 746
 		// filters
747 747
 		$content = array();
748 748
 		$messages = array();
749
-		foreach($this->_filters as $name => $filter)
749
+		foreach ($this->_filters as $name => $filter)
750 750
 		{
751 751
 			$field = array();
752 752
 
753 753
 			// form filed name
754
-			if(isset($filter['title']))
754
+			if (isset($filter['title']))
755 755
 			{
756 756
 				$field_lang = addslashes($filter['title']);
757 757
 				$messages[] = "v.cast('ADD_MESSAGE',['{$name}','{$field_lang}']);";
758 758
 			}
759
-			elseif(isset($lang->{$name}))
759
+			elseif (isset($lang->{$name}))
760 760
 			{
761 761
 				$field_lang = addslashes($lang->{$name});
762 762
 				$messages[] = "v.cast('ADD_MESSAGE',['{$name}','{$field_lang}']);";
763 763
 			}
764 764
 
765
-			if($filter['required'] == 'true')
765
+			if ($filter['required'] == 'true')
766 766
 			{
767 767
 				$field[] = 'required:true';
768 768
 			}
769
-			if($filter['rule'])
769
+			if ($filter['rule'])
770 770
 			{
771
-				$field[] = "rule:'" . strtolower($filter['rule']) . "'";
771
+				$field[] = "rule:'".strtolower($filter['rule'])."'";
772 772
 			}
773
-			if($filter['default'])
773
+			if ($filter['default'])
774 774
 			{
775 775
 				$field[] = "default:'{$filter['default']}'";
776 776
 			}
777
-			if($filter['modifier'])
777
+			if ($filter['modifier'])
778 778
 			{
779 779
 				$field[] = "modifier:'{$filter['modifier']}'";
780 780
 			}
781
-			if($filter['length'])
781
+			if ($filter['length'])
782 782
 			{
783 783
 				list($min, $max) = explode(':', $filter['length']);
784
-				if($min)
784
+				if ($min)
785 785
 				{
786 786
 					$field[] = "minlength:'{$min}'";
787 787
 				}
788
-				if($max)
788
+				if ($max)
789 789
 				{
790 790
 					$field[] = "maxlength:'{$max}'";
791 791
 				}
792 792
 			}
793
-			if($filter['if'])
793
+			if ($filter['if'])
794 794
 			{
795 795
 				$ifs = array();
796
-				if(!isset($filter['if'][0]))
796
+				if (!isset($filter['if'][0]))
797 797
 				{
798 798
 					$filter['if'] = array($filter['if']);
799 799
 				}
800
-				foreach($filter['if'] as $if)
800
+				foreach ($filter['if'] as $if)
801 801
 				{
802
-					$ifs[] = "{test:'" . addslashes($if['test']) . "', attr:'{$if['attr']}', value:'" . addslashes($if['value']) . "'}";
802
+					$ifs[] = "{test:'".addslashes($if['test'])."', attr:'{$if['attr']}', value:'".addslashes($if['value'])."'}";
803 803
 				}
804
-				$field[] = "'if':[" . implode(',', $ifs) . "]";
804
+				$field[] = "'if':[".implode(',', $ifs)."]";
805 805
 			}
806
-			if(count($field))
806
+			if (count($field))
807 807
 			{
808
-				$field = '{' . implode(',', $field) . '}';
808
+				$field = '{'.implode(',', $field).'}';
809 809
 				$content[] = "'{$name}':{$field}";
810 810
 			}
811 811
 		}
812 812
 
813
-		if(!$content)
813
+		if (!$content)
814 814
 		{
815 815
 			return '/* Error : empty ruleset  */';
816 816
 		}
817 817
 
818 818
 		// error messages
819
-		foreach($lang->filter as $key => $text)
819
+		foreach ($lang->filter as $key => $text)
820 820
 		{
821
-			if($text)
821
+			if ($text)
822 822
 			{
823 823
 				$text = preg_replace('@\r?\n@', '\\n', addslashes($text));
824 824
 				$messages[] = "v.cast('ADD_MESSAGE',['{$key}','{$text}']);";
Please login to merge, or discard this patch.