@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | /** |
153 | 153 | * Start element handler. |
154 | - * @param resource $parse an instance of parser |
|
154 | + * @param resource $parser an instance of parser |
|
155 | 155 | * @param string $node_name a name of node |
156 | 156 | * @param array $attrs attributes to be set |
157 | 157 | * @return array |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | /** |
169 | 169 | * Character data handler |
170 | 170 | * Variable in the last element of this->output |
171 | - * @param resource $parse an instance of parser |
|
171 | + * @param resource $parser an instance of parser |
|
172 | 172 | * @param string $body a data to be added |
173 | 173 | * @return void |
174 | 174 | */ |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | |
181 | 181 | /** |
182 | 182 | * End element handler |
183 | - * @param resource $parse an instance of parser |
|
183 | + * @param resource $parser an instance of parser |
|
184 | 184 | * @param string $node_name name of xml node |
185 | 185 | * @return void |
186 | 186 | */ |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | function loadXmlFile($filename) |
71 | 71 | { |
72 | - if(!file_exists($filename)) |
|
72 | + if (!file_exists($filename)) |
|
73 | 73 | { |
74 | 74 | return; |
75 | 75 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | function parse($input = '', $arg1 = NULL, $arg2 = NULL) |
90 | 90 | { |
91 | 91 | // Save the compile starting time for debugging |
92 | - if(__DEBUG__ == 3) |
|
92 | + if (__DEBUG__ == 3) |
|
93 | 93 | { |
94 | 94 | $start = getMicroTime(); |
95 | 95 | } |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | preg_match_all("/xml:lang=\"([^\"].+)\"/i", $this->input, $matches); |
104 | 104 | |
105 | 105 | // extracts the supported lanuage when xml:lang is used |
106 | - if(count($matches[1]) && $supported_lang = array_unique($matches[1])) |
|
106 | + if (count($matches[1]) && $supported_lang = array_unique($matches[1])) |
|
107 | 107 | { |
108 | 108 | $tmpLangList = array_flip($supported_lang); |
109 | 109 | // if lang of the first log-in user doesn't exist, apply en by default if exists. Otherwise apply the first lang. |
110 | - if(!isset($tmpLangList[$this->lang])) |
|
110 | + if (!isset($tmpLangList[$this->lang])) |
|
111 | 111 | { |
112 | - if(isset($tmpLangList['en'])) |
|
112 | + if (isset($tmpLangList['en'])) |
|
113 | 113 | { |
114 | 114 | $this->lang = 'en'; |
115 | 115 | } |
@@ -134,14 +134,14 @@ discard block |
||
134 | 134 | xml_parse($this->oParser, $this->input); |
135 | 135 | xml_parser_free($this->oParser); |
136 | 136 | |
137 | - if(!count($this->output)) |
|
137 | + if (!count($this->output)) |
|
138 | 138 | { |
139 | 139 | return; |
140 | 140 | } |
141 | 141 | |
142 | 142 | $output = array_shift($this->output); |
143 | 143 | // Save compile starting time for debugging |
144 | - if(__DEBUG__ == 3) |
|
144 | + if (__DEBUG__ == 3) |
|
145 | 145 | { |
146 | 146 | $GLOBALS['__xmlparse_elapsed__'] += getMicroTime() - $start; |
147 | 147 | } |
@@ -189,19 +189,19 @@ discard block |
||
189 | 189 | $node_name = strtolower($node_name); |
190 | 190 | $cur_obj = array_pop($this->output); |
191 | 191 | $parent_obj = &$this->output[count($this->output) - 1]; |
192 | - if($this->lang && $cur_obj->attrs->{'xml:lang'} && $cur_obj->attrs->{'xml:lang'} != $this->lang) |
|
192 | + if ($this->lang && $cur_obj->attrs->{'xml:lang'} && $cur_obj->attrs->{'xml:lang'} != $this->lang) |
|
193 | 193 | { |
194 | 194 | return; |
195 | 195 | } |
196 | - if($this->lang && $parent_obj->{$node_name}->attrs->{'xml:lang'} && $parent_obj->{$node_name}->attrs->{'xml:lang'} != $this->lang) |
|
196 | + if ($this->lang && $parent_obj->{$node_name}->attrs->{'xml:lang'} && $parent_obj->{$node_name}->attrs->{'xml:lang'} != $this->lang) |
|
197 | 197 | { |
198 | 198 | return; |
199 | 199 | } |
200 | 200 | |
201 | - if(isset($parent_obj->{$node_name})) |
|
201 | + if (isset($parent_obj->{$node_name})) |
|
202 | 202 | { |
203 | 203 | $tmp_obj = $parent_obj->{$node_name}; |
204 | - if(is_array($tmp_obj)) |
|
204 | + if (is_array($tmp_obj)) |
|
205 | 205 | { |
206 | 206 | $parent_obj->{$node_name}[] = $cur_obj; |
207 | 207 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | } |
213 | 213 | else |
214 | 214 | { |
215 | - if(!is_object($parent_obj)) |
|
215 | + if (!is_object($parent_obj)) |
|
216 | 216 | { |
217 | 217 | $parent_obj = (object) $parent_obj; |
218 | 218 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | function _arrToAttrsObj($arr) |
230 | 230 | { |
231 | 231 | $output = new Xml_Node_(); |
232 | - foreach($arr as $key => $val) |
|
232 | + foreach ($arr as $key => $val) |
|
233 | 233 | { |
234 | 234 | $key = strtolower($key); |
235 | 235 | $output->{$key} = $val; |
@@ -112,15 +112,13 @@ discard block |
||
112 | 112 | if(isset($tmpLangList['en'])) |
113 | 113 | { |
114 | 114 | $this->lang = 'en'; |
115 | - } |
|
116 | - else |
|
115 | + } else |
|
117 | 116 | { |
118 | 117 | $this->lang = array_shift($supported_lang); |
119 | 118 | } |
120 | 119 | } |
121 | 120 | // uncheck the language if no specific language is set. |
122 | - } |
|
123 | - else |
|
121 | + } else |
|
124 | 122 | { |
125 | 123 | $this->lang = ''; |
126 | 124 | } |
@@ -204,13 +202,11 @@ discard block |
||
204 | 202 | if(is_array($tmp_obj)) |
205 | 203 | { |
206 | 204 | $parent_obj->{$node_name}[] = $cur_obj; |
207 | - } |
|
208 | - else |
|
205 | + } else |
|
209 | 206 | { |
210 | 207 | $parent_obj->{$node_name} = array($tmp_obj, $cur_obj); |
211 | 208 | } |
212 | - } |
|
213 | - else |
|
209 | + } else |
|
214 | 210 | { |
215 | 211 | if(!is_object($parent_obj)) |
216 | 212 | { |
@@ -90,6 +90,9 @@ discard block |
||
90 | 90 | $this->type = $value; |
91 | 91 | } |
92 | 92 | |
93 | + /** |
|
94 | + * @param string $operation |
|
95 | + */ |
|
93 | 96 | function setColumnOperation($operation) |
94 | 97 | { |
95 | 98 | $this->column_operation = $operation; |
@@ -282,6 +285,9 @@ discard block |
||
282 | 285 | return $this->errorMessage; |
283 | 286 | } |
284 | 287 | |
288 | + /** |
|
289 | + * @param integer $default_value |
|
290 | + */ |
|
285 | 291 | function ensureDefaultValue($default_value) |
286 | 292 | { |
287 | 293 | if($this->value === NULL || $this->value === '') |
@@ -180,8 +180,7 @@ discard block |
||
180 | 180 | if(!is_array($value)) |
181 | 181 | { |
182 | 182 | $value = $this->_escapeStringValue($value); |
183 | - } |
|
184 | - else |
|
183 | + } else |
|
185 | 184 | { |
186 | 185 | foreach($value as $key=>$val) |
187 | 186 | { |
@@ -204,8 +203,7 @@ discard block |
||
204 | 203 | $value[$key] = (int) $val; |
205 | 204 | } |
206 | 205 | } |
207 | - } |
|
208 | - else |
|
206 | + } else |
|
209 | 207 | { |
210 | 208 | $value = (int) $value; |
211 | 209 | } |
@@ -236,8 +234,7 @@ discard block |
||
236 | 234 | { |
237 | 235 | // Valid byte sequence. Return unmodified. |
238 | 236 | return $captures[1]; |
239 | - } |
|
240 | - else if(strlen($captures[2])) |
|
237 | + } else if(strlen($captures[2])) |
|
241 | 238 | { |
242 | 239 | // Remove user defined area |
243 | 240 | if("\xF3\xB0\x80\x80" <= $captures[2]) |
@@ -246,8 +243,7 @@ discard block |
||
246 | 243 | } |
247 | 244 | |
248 | 245 | return $captures[2]; |
249 | - } |
|
250 | - else |
|
246 | + } else |
|
251 | 247 | { |
252 | 248 | return; |
253 | 249 | } |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | |
74 | 74 | function getType() |
75 | 75 | { |
76 | - if(isset($this->type)) |
|
76 | + if (isset($this->type)) |
|
77 | 77 | { |
78 | 78 | return $this->type; |
79 | 79 | } |
80 | - if(is_string($this->value)) |
|
80 | + if (is_string($this->value)) |
|
81 | 81 | { |
82 | 82 | return 'column_name'; |
83 | 83 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | |
103 | 103 | function getValue() |
104 | 104 | { |
105 | - if(!isset($this->_value)) |
|
105 | + if (!isset($this->_value)) |
|
106 | 106 | { |
107 | 107 | $value = $this->getEscapedValue(); |
108 | 108 | $this->_value = $this->toString($value); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | |
128 | 128 | function getUnescapedValue() |
129 | 129 | { |
130 | - if($this->value === 'null') |
|
130 | + if ($this->value === 'null') |
|
131 | 131 | { |
132 | 132 | return null; |
133 | 133 | } |
@@ -141,17 +141,17 @@ discard block |
||
141 | 141 | */ |
142 | 142 | function toString($value) |
143 | 143 | { |
144 | - if(is_array($value)) |
|
144 | + if (is_array($value)) |
|
145 | 145 | { |
146 | - if(count($value) === 0) |
|
146 | + if (count($value) === 0) |
|
147 | 147 | { |
148 | 148 | return ''; |
149 | 149 | } |
150 | - if(count($value) === 1 && $value[0] === '') |
|
150 | + if (count($value) === 1 && $value[0] === '') |
|
151 | 151 | { |
152 | 152 | return ''; |
153 | 153 | } |
154 | - return '(' . implode(',', $value) . ')'; |
|
154 | + return '('.implode(',', $value).')'; |
|
155 | 155 | } |
156 | 156 | return $value; |
157 | 157 | } |
@@ -164,42 +164,42 @@ discard block |
||
164 | 164 | function escapeValue($value) |
165 | 165 | { |
166 | 166 | $column_type = $this->getType(); |
167 | - if($column_type == 'column_name') |
|
167 | + if ($column_type == 'column_name') |
|
168 | 168 | { |
169 | 169 | $dbParser = DB::getParser(); |
170 | 170 | return $dbParser->parseExpression($value); |
171 | 171 | } |
172 | - if(!isset($value)) |
|
172 | + if (!isset($value)) |
|
173 | 173 | { |
174 | 174 | return null; |
175 | 175 | } |
176 | 176 | |
177 | 177 | $columnTypeList = array('date' => 1, 'varchar' => 1, 'char' => 1, 'text' => 1, 'bigtext' => 1); |
178 | - if(isset($columnTypeList[$column_type])) |
|
178 | + if (isset($columnTypeList[$column_type])) |
|
179 | 179 | { |
180 | - if(!is_array($value)) |
|
180 | + if (!is_array($value)) |
|
181 | 181 | { |
182 | 182 | $value = $this->_escapeStringValue($value); |
183 | 183 | } |
184 | 184 | else |
185 | 185 | { |
186 | - foreach($value as $key=>$val) |
|
186 | + foreach ($value as $key=>$val) |
|
187 | 187 | { |
188 | 188 | $value[$key] = $this->_escapeStringValue($val); |
189 | 189 | } |
190 | 190 | } |
191 | 191 | } |
192 | - if($this->uses_default_value) |
|
192 | + if ($this->uses_default_value) |
|
193 | 193 | { |
194 | 194 | return $value; |
195 | 195 | } |
196 | - if($column_type == 'number') |
|
196 | + if ($column_type == 'number') |
|
197 | 197 | { |
198 | - if(is_array($value)) |
|
198 | + if (is_array($value)) |
|
199 | 199 | { |
200 | - foreach($value AS $key => $val) |
|
200 | + foreach ($value AS $key => $val) |
|
201 | 201 | { |
202 | - if(isset($val) && $val !== '') |
|
202 | + if (isset($val) && $val !== '') |
|
203 | 203 | { |
204 | 204 | $value[$key] = (int) $val; |
205 | 205 | } |
@@ -227,20 +227,20 @@ discard block |
||
227 | 227 | $value = preg_replace_callback($regex, array($this, 'utf8Replacer'), $value); |
228 | 228 | $db = DB::getInstance(); |
229 | 229 | $value = $db->addQuotes($value); |
230 | - return '\'' . $value . '\''; |
|
230 | + return '\''.$value.'\''; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | function utf8Replacer($captures) |
234 | 234 | { |
235 | - if(strlen($captures[1])) |
|
235 | + if (strlen($captures[1])) |
|
236 | 236 | { |
237 | 237 | // Valid byte sequence. Return unmodified. |
238 | 238 | return $captures[1]; |
239 | 239 | } |
240 | - else if(strlen($captures[2])) |
|
240 | + else if (strlen($captures[2])) |
|
241 | 241 | { |
242 | 242 | // Remove user defined area |
243 | - if("\xF3\xB0\x80\x80" <= $captures[2]) |
|
243 | + if ("\xF3\xB0\x80\x80" <= $captures[2]) |
|
244 | 244 | { |
245 | 245 | return; |
246 | 246 | } |
@@ -262,15 +262,15 @@ discard block |
||
262 | 262 | { |
263 | 263 | $type = $this->getType(); |
264 | 264 | $value = $this->getUnescapedValue(); |
265 | - if($type == 'column_name') |
|
265 | + if ($type == 'column_name') |
|
266 | 266 | { |
267 | 267 | return TRUE; |
268 | 268 | } |
269 | - if($type == 'number' && is_null($value)) |
|
269 | + if ($type == 'number' && is_null($value)) |
|
270 | 270 | { |
271 | 271 | return FALSE; |
272 | 272 | } |
273 | - if($type == 'number' && !is_numeric($value) && $this->uses_default_value) |
|
273 | + if ($type == 'number' && !is_numeric($value) && $this->uses_default_value) |
|
274 | 274 | { |
275 | 275 | return TRUE; |
276 | 276 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | |
285 | 285 | function ensureDefaultValue($default_value) |
286 | 286 | { |
287 | - if($this->value === NULL || $this->value === '') |
|
287 | + if ($this->value === NULL || $this->value === '') |
|
288 | 288 | { |
289 | 289 | $this->value = $default_value; |
290 | 290 | $this->uses_default_value = TRUE; |
@@ -298,23 +298,23 @@ discard block |
||
298 | 298 | */ |
299 | 299 | function checkFilter($filter_type) |
300 | 300 | { |
301 | - if(isset($this->value) && $this->value != '') |
|
301 | + if (isset($this->value) && $this->value != '') |
|
302 | 302 | { |
303 | 303 | global $lang; |
304 | 304 | $val = $this->value; |
305 | 305 | $key = $this->name; |
306 | - switch($filter_type) |
|
306 | + switch ($filter_type) |
|
307 | 307 | { |
308 | 308 | case 'email' : |
309 | 309 | case 'email_address' : |
310 | - if(!preg_match('/^[\w-]+((?:\.|\+|\~)[\w-]+)*@[\w-]+(\.[\w-]+)+$/is', $val)) |
|
310 | + if (!preg_match('/^[\w-]+((?:\.|\+|\~)[\w-]+)*@[\w-]+(\.[\w-]+)+$/is', $val)) |
|
311 | 311 | { |
312 | 312 | $this->isValid = FALSE; |
313 | 313 | $this->errorMessage = new BaseObject(-1, sprintf($lang->filter->invalid_email, $lang->{$key} ? $lang->{$key} : $key)); |
314 | 314 | } |
315 | 315 | break; |
316 | 316 | case 'homepage' : |
317 | - if(!preg_match('/^(http|https)+(:\/\/)+[0-9a-z_-]+\.[^ ]+$/is', $val)) |
|
317 | + if (!preg_match('/^(http|https)+(:\/\/)+[0-9a-z_-]+\.[^ ]+$/is', $val)) |
|
318 | 318 | { |
319 | 319 | $this->isValid = FALSE; |
320 | 320 | $this->errorMessage = new BaseObject(-1, sprintf($lang->filter->invalid_homepage, $lang->{$key} ? $lang->{$key} : $key)); |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | break; |
323 | 323 | case 'userid' : |
324 | 324 | case 'user_id' : |
325 | - if(!preg_match('/^[a-zA-Z]+([_0-9a-zA-Z]+)*$/is', $val)) |
|
325 | + if (!preg_match('/^[a-zA-Z]+([_0-9a-zA-Z]+)*$/is', $val)) |
|
326 | 326 | { |
327 | 327 | $this->isValid = FALSE; |
328 | 328 | $this->errorMessage = new BaseObject(-1, sprintf($lang->filter->invalid_userid, $lang->{$key} ? $lang->{$key} : $key)); |
@@ -330,25 +330,25 @@ discard block |
||
330 | 330 | break; |
331 | 331 | case 'number' : |
332 | 332 | case 'numbers' : |
333 | - if(is_array($val)) |
|
333 | + if (is_array($val)) |
|
334 | 334 | { |
335 | 335 | $val = join(',', $val); |
336 | 336 | } |
337 | - if(!preg_match('/^(-?)[0-9]+(,\-?[0-9]+)*$/is', $val)) |
|
337 | + if (!preg_match('/^(-?)[0-9]+(,\-?[0-9]+)*$/is', $val)) |
|
338 | 338 | { |
339 | 339 | $this->isValid = FALSE; |
340 | 340 | $this->errorMessage = new BaseObject(-1, sprintf($lang->filter->invalid_number, $lang->{$key} ? $lang->{$key} : $key)); |
341 | 341 | } |
342 | 342 | break; |
343 | 343 | case 'alpha' : |
344 | - if(!preg_match('/^[a-z]+$/is', $val)) |
|
344 | + if (!preg_match('/^[a-z]+$/is', $val)) |
|
345 | 345 | { |
346 | 346 | $this->isValid = FALSE; |
347 | 347 | $this->errorMessage = new BaseObject(-1, sprintf($lang->filter->invalid_alpha, $lang->{$key} ? $lang->{$key} : $key)); |
348 | 348 | } |
349 | 349 | break; |
350 | 350 | case 'alpha_number' : |
351 | - if(!preg_match('/^[0-9a-z]+$/is', $val)) |
|
351 | + if (!preg_match('/^[0-9a-z]+$/is', $val)) |
|
352 | 352 | { |
353 | 353 | $this->isValid = FALSE; |
354 | 354 | $this->errorMessage = new BaseObject(-1, sprintf($lang->filter->invalid_alpha_number, $lang->{$key} ? $lang->{$key} : $key)); |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | |
361 | 361 | function checkMaxLength($length) |
362 | 362 | { |
363 | - if($this->value && (strlen($this->value) > $length)) |
|
363 | + if ($this->value && (strlen($this->value) > $length)) |
|
364 | 364 | { |
365 | 365 | global $lang; |
366 | 366 | $this->isValid = FALSE; |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | |
372 | 372 | function checkMinLength($length) |
373 | 373 | { |
374 | - if($this->value && (strlen($this->value) < $length)) |
|
374 | + if ($this->value && (strlen($this->value) < $length)) |
|
375 | 375 | { |
376 | 376 | global $lang; |
377 | 377 | $this->isValid = FALSE; |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | |
383 | 383 | function checkNotNull() |
384 | 384 | { |
385 | - if(!isset($this->value)) |
|
385 | + if (!isset($this->value)) |
|
386 | 386 | { |
387 | 387 | global $lang; |
388 | 388 | $this->isValid = FALSE; |
@@ -116,7 +116,7 @@ |
||
116 | 116 | * In this case, the column type is retrieved according to argument |
117 | 117 | * value type (using the PHP function is_numeric). |
118 | 118 | * |
119 | - * @return type string |
|
119 | + * @return string string |
|
120 | 120 | */ |
121 | 121 | function getType() |
122 | 122 | { |
@@ -56,8 +56,7 @@ discard block |
||
56 | 56 | if(defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1') |
57 | 57 | { |
58 | 58 | $this->value = '^' . str_replace('%', '(.*)', preg_quote($value)); |
59 | - } |
|
60 | - else |
|
59 | + } else |
|
61 | 60 | { |
62 | 61 | $this->value = $value . '%'; |
63 | 62 | } |
@@ -66,8 +65,7 @@ discard block |
||
66 | 65 | if(defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1') |
67 | 66 | { |
68 | 67 | $this->value = str_replace('%', '(.*)', preg_quote($value)) . '$'; |
69 | - } |
|
70 | - else |
|
68 | + } else |
|
71 | 69 | { |
72 | 70 | $this->value = '%' . $value; |
73 | 71 | } |
@@ -76,8 +74,7 @@ discard block |
||
76 | 74 | if(defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1') |
77 | 75 | { |
78 | 76 | $this->value = str_replace('%', '(.*)', preg_quote($value)); |
79 | - } |
|
80 | - else |
|
77 | + } else |
|
81 | 78 | { |
82 | 79 | $this->value = '%' . $value . '%'; |
83 | 80 | } |
@@ -123,12 +120,10 @@ discard block |
||
123 | 120 | if($this->type) |
124 | 121 | { |
125 | 122 | return $this->type; |
126 | - } |
|
127 | - else if(!is_numeric($this->value)) |
|
123 | + } else if(!is_numeric($this->value)) |
|
128 | 124 | { |
129 | 125 | return 'varchar'; |
130 | - } |
|
131 | - else |
|
126 | + } else |
|
132 | 127 | { |
133 | 128 | return ''; |
134 | 129 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | function ConditionArgument($name, $value, $operation) |
27 | 27 | { |
28 | 28 | $operationList = array('in' => 1, 'notin' => 1, 'not_in' => 1, 'between' => 1); |
29 | - if(isset($value) && isset($operationList[$operation]) && !is_array($value) && $value != '') |
|
29 | + if (isset($value) && isset($operationList[$operation]) && !is_array($value) && $value != '') |
|
30 | 30 | { |
31 | 31 | $value = str_replace(' ', '', $value); |
32 | 32 | $value = str_replace('\'', '', $value); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | function createConditionValue() |
44 | 44 | { |
45 | - if(!isset($this->value)) |
|
45 | + if (!isset($this->value)) |
|
46 | 46 | { |
47 | 47 | return; |
48 | 48 | } |
@@ -50,56 +50,56 @@ discard block |
||
50 | 50 | $operation = $this->operation; |
51 | 51 | $value = $this->value; |
52 | 52 | |
53 | - switch($operation) |
|
53 | + switch ($operation) |
|
54 | 54 | { |
55 | 55 | case 'like_prefix' : |
56 | - if(defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1') |
|
56 | + if (defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1') |
|
57 | 57 | { |
58 | - $this->value = '^' . str_replace('%', '(.*)', preg_quote($value)); |
|
58 | + $this->value = '^'.str_replace('%', '(.*)', preg_quote($value)); |
|
59 | 59 | } |
60 | 60 | else |
61 | 61 | { |
62 | - $this->value = $value . '%'; |
|
62 | + $this->value = $value.'%'; |
|
63 | 63 | } |
64 | 64 | break; |
65 | 65 | case 'like_tail' : |
66 | - if(defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1') |
|
66 | + if (defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1') |
|
67 | 67 | { |
68 | - $this->value = str_replace('%', '(.*)', preg_quote($value)) . '$'; |
|
68 | + $this->value = str_replace('%', '(.*)', preg_quote($value)).'$'; |
|
69 | 69 | } |
70 | 70 | else |
71 | 71 | { |
72 | - $this->value = '%' . $value; |
|
72 | + $this->value = '%'.$value; |
|
73 | 73 | } |
74 | 74 | break; |
75 | 75 | case 'like' : |
76 | - if(defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1') |
|
76 | + if (defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1') |
|
77 | 77 | { |
78 | 78 | $this->value = str_replace('%', '(.*)', preg_quote($value)); |
79 | 79 | } |
80 | 80 | else |
81 | 81 | { |
82 | - $this->value = '%' . $value . '%'; |
|
82 | + $this->value = '%'.$value.'%'; |
|
83 | 83 | } |
84 | 84 | break; |
85 | 85 | case 'notlike' : |
86 | - $this->value = '%' . $value . '%'; |
|
86 | + $this->value = '%'.$value.'%'; |
|
87 | 87 | break; |
88 | 88 | case 'notlike_prefix' : |
89 | - $this->value = $value . '%'; |
|
89 | + $this->value = $value.'%'; |
|
90 | 90 | break; |
91 | 91 | case 'notlike_tail' : |
92 | - $this->value = '%' . $value; |
|
92 | + $this->value = '%'.$value; |
|
93 | 93 | break; |
94 | 94 | case 'in': |
95 | - if(!is_array($value)) |
|
95 | + if (!is_array($value)) |
|
96 | 96 | { |
97 | 97 | $this->value = array($value); |
98 | 98 | } |
99 | 99 | break; |
100 | 100 | case 'notin': |
101 | 101 | case 'not_in': |
102 | - if(!is_array($value)) |
|
102 | + if (!is_array($value)) |
|
103 | 103 | { |
104 | 104 | $this->value = array($value); |
105 | 105 | } |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | */ |
121 | 121 | function getType() |
122 | 122 | { |
123 | - if($this->type) |
|
123 | + if ($this->type) |
|
124 | 124 | { |
125 | 125 | return $this->type; |
126 | 126 | } |
127 | - else if(!is_numeric($this->value)) |
|
127 | + else if (!is_numeric($this->value)) |
|
128 | 128 | { |
129 | 129 | return 'varchar'; |
130 | 130 | } |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | |
137 | 137 | function setColumnType($column_type) |
138 | 138 | { |
139 | - if(!isset($this->value)) |
|
139 | + if (!isset($this->value)) |
|
140 | 140 | { |
141 | 141 | return; |
142 | 142 | } |
143 | - if($column_type === '') |
|
143 | + if ($column_type === '') |
|
144 | 144 | { |
145 | 145 | return; |
146 | 146 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | * |
29 | 29 | * @param object $query XML object obtained after reading the XML Query file |
30 | 30 | * @param bool $isSubQuery |
31 | - * @return void |
|
31 | + * @return string |
|
32 | 32 | */ |
33 | 33 | function QueryParser($query = NULL, $isSubQuery = FALSE) |
34 | 34 | { |
@@ -59,8 +59,7 @@ |
||
59 | 59 | $target = 'modules'; |
60 | 60 | $module = $id_args[0]; |
61 | 61 | $id = $id_args[1]; |
62 | - } |
|
63 | - else if(count($id_args) == 3) |
|
62 | + } else if(count($id_args) == 3) |
|
64 | 63 | { |
65 | 64 | $target = $id_args[0]; |
66 | 65 | $targetList = array('modules' => 1, 'addons' => 1, 'widgets' => 1); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | function QueryParser($query = NULL, $isSubQuery = FALSE) |
34 | 34 | { |
35 | - if($query) |
|
35 | + if ($query) |
|
36 | 36 | { |
37 | 37 | $this->queryTag = new QueryTag($query, $isSubQuery); |
38 | 38 | } |
@@ -54,17 +54,17 @@ discard block |
||
54 | 54 | $module = ''; |
55 | 55 | |
56 | 56 | $id_args = explode('.', $query_id); |
57 | - if(count($id_args) == 2) |
|
57 | + if (count($id_args) == 2) |
|
58 | 58 | { |
59 | 59 | $target = 'modules'; |
60 | 60 | $module = $id_args[0]; |
61 | 61 | $id = $id_args[1]; |
62 | 62 | } |
63 | - else if(count($id_args) == 3) |
|
63 | + else if (count($id_args) == 3) |
|
64 | 64 | { |
65 | 65 | $target = $id_args[0]; |
66 | 66 | $targetList = array('modules' => 1, 'addons' => 1, 'widgets' => 1); |
67 | - if(!isset($targetList[$target])) |
|
67 | + if (!isset($targetList[$target])) |
|
68 | 68 | { |
69 | 69 | return; |
70 | 70 | } |
@@ -74,33 +74,33 @@ discard block |
||
74 | 74 | |
75 | 75 | // get column properties from the table |
76 | 76 | $table_file = sprintf('%s%s/%s/schemas/%s.xml', _XE_PATH_, 'modules', $module, $table_name); |
77 | - if(!file_exists($table_file)) |
|
77 | + if (!file_exists($table_file)) |
|
78 | 78 | { |
79 | - $searched_list = FileHandler::readDir(_XE_PATH_ . 'modules'); |
|
79 | + $searched_list = FileHandler::readDir(_XE_PATH_.'modules'); |
|
80 | 80 | $searched_count = count($searched_list); |
81 | - for($i = 0; $i < $searched_count; $i++) |
|
81 | + for ($i = 0; $i < $searched_count; $i++) |
|
82 | 82 | { |
83 | 83 | $table_file = sprintf('%s%s/%s/schemas/%s.xml', _XE_PATH_, 'modules', $searched_list[$i], $table_name); |
84 | - if(file_exists($table_file)) |
|
84 | + if (file_exists($table_file)) |
|
85 | 85 | { |
86 | 86 | break; |
87 | 87 | } |
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | - if(file_exists($table_file)) |
|
91 | + if (file_exists($table_file)) |
|
92 | 92 | { |
93 | 93 | $table_xml = FileHandler::readFile($table_file); |
94 | 94 | $xml_parser = new XmlParser(); |
95 | 95 | $table_obj = $xml_parser->parse($table_xml); |
96 | - if($table_obj->table) |
|
96 | + if ($table_obj->table) |
|
97 | 97 | { |
98 | - if(isset($table_obj->table->column) && !is_array($table_obj->table->column)) |
|
98 | + if (isset($table_obj->table->column) && !is_array($table_obj->table->column)) |
|
99 | 99 | { |
100 | 100 | $table_obj->table->column = array($table_obj->table->column); |
101 | 101 | } |
102 | 102 | |
103 | - foreach($table_obj->table->column as $k => $v) |
|
103 | + foreach ($table_obj->table->column as $k => $v) |
|
104 | 104 | { |
105 | 105 | $column_type[$v->attrs->name] = $v->attrs->type; |
106 | 106 | } |
@@ -169,6 +169,9 @@ |
||
169 | 169 | return $this->query->attrs->action; |
170 | 170 | } |
171 | 171 | |
172 | + /** |
|
173 | + * @param TablesTag $tables |
|
174 | + */ |
|
172 | 175 | function setTableColumnTypes($tables) |
173 | 176 | { |
174 | 177 | $query_id = $this->getQueryId(); |
@@ -195,16 +195,13 @@ discard block |
||
195 | 195 | if($this->action == 'select') |
196 | 196 | { |
197 | 197 | return $this->columns = new SelectColumnsTag($this->query->columns); |
198 | - } |
|
199 | - else if($this->action == 'insert' || $this->action == 'insert-select') |
|
198 | + } else if($this->action == 'insert' || $this->action == 'insert-select') |
|
200 | 199 | { |
201 | 200 | return $this->columns = new InsertColumnsTag($this->query->columns->column); |
202 | - } |
|
203 | - else if($this->action == 'update') |
|
201 | + } else if($this->action == 'update') |
|
204 | 202 | { |
205 | 203 | return $this->columns = new UpdateColumnsTag($this->query->columns->column); |
206 | - } |
|
207 | - else if($this->action == 'delete') |
|
204 | + } else if($this->action == 'delete') |
|
208 | 205 | { |
209 | 206 | return $this->columns = null; |
210 | 207 | } |
@@ -237,8 +234,7 @@ discard block |
||
237 | 234 | { |
238 | 235 | $column_type = $this->column_type[$this->getQueryId()][$table_alias][$argument->getColumnName()]; |
239 | 236 | } |
240 | - } |
|
241 | - else |
|
237 | + } else |
|
242 | 238 | { |
243 | 239 | $current_tables = $this->column_type[$this->getQueryId()]; |
244 | 240 | $column_name = $argument->getColumnName(); |
@@ -316,8 +312,7 @@ discard block |
||
316 | 312 | if($this->query->index_hint && ($this->query->index_hint->attrs->for == 'ALL' || Context::getDBType() == strtolower($this->query->index_hint->attrs->for))) |
317 | 313 | { |
318 | 314 | return $this->tables = new TablesTag($this->query->tables, $this->query->index_hint); |
319 | - } |
|
320 | - else |
|
315 | + } else |
|
321 | 316 | { |
322 | 317 | return $this->tables = new TablesTag($this->query->tables); |
323 | 318 | } |
@@ -341,8 +336,7 @@ discard block |
||
341 | 336 | if($this->query->groups) |
342 | 337 | { |
343 | 338 | return $this->groups = new GroupsTag($this->query->groups->group); |
344 | - } |
|
345 | - else |
|
339 | + } else |
|
346 | 340 | { |
347 | 341 | return $this->groups = new GroupsTag(NULL); |
348 | 342 | } |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | $this->priority = $query->attrs->priority; |
127 | 127 | $this->query = $query; |
128 | 128 | $this->isSubQuery = $isSubQuery; |
129 | - if($this->isSubQuery) |
|
129 | + if ($this->isSubQuery) |
|
130 | 130 | { |
131 | 131 | $this->action = 'select'; |
132 | 132 | } |
133 | - if($query->attrs->alias) |
|
133 | + if ($query->attrs->alias) |
|
134 | 134 | { |
135 | 135 | $dbParser = DB::getParser(); |
136 | 136 | $this->alias = $dbParser->escape($query->attrs->alias); |
@@ -172,13 +172,13 @@ discard block |
||
172 | 172 | function setTableColumnTypes($tables) |
173 | 173 | { |
174 | 174 | $query_id = $this->getQueryId(); |
175 | - if(!isset($this->column_type[$query_id])) |
|
175 | + if (!isset($this->column_type[$query_id])) |
|
176 | 176 | { |
177 | 177 | $table_tags = $tables->getTables(); |
178 | 178 | $column_type = array(); |
179 | - foreach($table_tags as $table_tag) |
|
179 | + foreach ($table_tags as $table_tag) |
|
180 | 180 | { |
181 | - if(is_a($table_tag, 'TableTag')) |
|
181 | + if (is_a($table_tag, 'TableTag')) |
|
182 | 182 | { |
183 | 183 | $table_name = $table_tag->getTableName(); |
184 | 184 | $table_alias = $table_tag->getTableAlias(); |
@@ -192,19 +192,19 @@ discard block |
||
192 | 192 | |
193 | 193 | function getColumns() |
194 | 194 | { |
195 | - if($this->action == 'select') |
|
195 | + if ($this->action == 'select') |
|
196 | 196 | { |
197 | 197 | return $this->columns = new SelectColumnsTag($this->query->columns); |
198 | 198 | } |
199 | - else if($this->action == 'insert' || $this->action == 'insert-select') |
|
199 | + else if ($this->action == 'insert' || $this->action == 'insert-select') |
|
200 | 200 | { |
201 | 201 | return $this->columns = new InsertColumnsTag($this->query->columns->column); |
202 | 202 | } |
203 | - else if($this->action == 'update') |
|
203 | + else if ($this->action == 'update') |
|
204 | 204 | { |
205 | 205 | return $this->columns = new UpdateColumnsTag($this->query->columns->column); |
206 | 206 | } |
207 | - else if($this->action == 'delete') |
|
207 | + else if ($this->action == 'delete') |
|
208 | 208 | { |
209 | 209 | return $this->columns = null; |
210 | 210 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | |
213 | 213 | function getPrebuff() |
214 | 214 | { |
215 | - if($this->isSubQuery) |
|
215 | + if ($this->isSubQuery) |
|
216 | 216 | { |
217 | 217 | return; |
218 | 218 | } |
@@ -220,20 +220,20 @@ discard block |
||
220 | 220 | $arguments = $this->getArguments(); |
221 | 221 | |
222 | 222 | $prebuff = ''; |
223 | - foreach($arguments as $argument) |
|
223 | + foreach ($arguments as $argument) |
|
224 | 224 | { |
225 | - if(isset($argument)) |
|
225 | + if (isset($argument)) |
|
226 | 226 | { |
227 | 227 | $arg_name = $argument->getArgumentName(); |
228 | - if($arg_name) |
|
228 | + if ($arg_name) |
|
229 | 229 | { |
230 | 230 | unset($column_type); |
231 | 231 | $prebuff .= $argument->toString(); |
232 | 232 | |
233 | 233 | $table_alias = $argument->getTableName(); |
234 | - if(isset($table_alias)) |
|
234 | + if (isset($table_alias)) |
|
235 | 235 | { |
236 | - if(isset($this->column_type[$this->getQueryId()][$table_alias][$argument->getColumnName()])) |
|
236 | + if (isset($this->column_type[$this->getQueryId()][$table_alias][$argument->getColumnName()])) |
|
237 | 237 | { |
238 | 238 | $column_type = $this->column_type[$this->getQueryId()][$table_alias][$argument->getColumnName()]; |
239 | 239 | } |
@@ -242,18 +242,18 @@ discard block |
||
242 | 242 | { |
243 | 243 | $current_tables = $this->column_type[$this->getQueryId()]; |
244 | 244 | $column_name = $argument->getColumnName(); |
245 | - foreach($current_tables as $current_table) |
|
245 | + foreach ($current_tables as $current_table) |
|
246 | 246 | { |
247 | - if(isset($current_table[$column_name])) |
|
247 | + if (isset($current_table[$column_name])) |
|
248 | 248 | { |
249 | 249 | $column_type = $current_table[$column_name]; |
250 | 250 | } |
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
254 | - if(isset($column_type)) |
|
254 | + if (isset($column_type)) |
|
255 | 255 | { |
256 | - $prebuff .= sprintf('if(${\'%s_argument\'} !== null) ${\'%s_argument\'}->setColumnType(\'%s\');' . "\n" |
|
256 | + $prebuff .= sprintf('if(${\'%s_argument\'} !== null) ${\'%s_argument\'}->setColumnType(\'%s\');'."\n" |
|
257 | 257 | , $arg_name |
258 | 258 | , $arg_name |
259 | 259 | , $column_type); |
@@ -269,43 +269,43 @@ discard block |
||
269 | 269 | function getBuff() |
270 | 270 | { |
271 | 271 | $buff = ''; |
272 | - if($this->isSubQuery) |
|
272 | + if ($this->isSubQuery) |
|
273 | 273 | { |
274 | 274 | $buff = 'new Subquery('; |
275 | - $buff .= "'" . $this->alias . '\', '; |
|
276 | - $buff .= ($this->columns ? $this->columns->toString() : 'null' ) . ', ' . PHP_EOL; |
|
277 | - $buff .= $this->tables->toString() . ',' . PHP_EOL; |
|
278 | - $buff .= $this->conditions->toString() . ',' . PHP_EOL; |
|
279 | - $buff .= $this->groups->toString() . ',' . PHP_EOL; |
|
280 | - $buff .= $this->navigation->getOrderByString() . ',' . PHP_EOL; |
|
275 | + $buff .= "'".$this->alias.'\', '; |
|
276 | + $buff .= ($this->columns ? $this->columns->toString() : 'null').', '.PHP_EOL; |
|
277 | + $buff .= $this->tables->toString().','.PHP_EOL; |
|
278 | + $buff .= $this->conditions->toString().','.PHP_EOL; |
|
279 | + $buff .= $this->groups->toString().','.PHP_EOL; |
|
280 | + $buff .= $this->navigation->getOrderByString().','.PHP_EOL; |
|
281 | 281 | $limit = $this->navigation->getLimitString(); |
282 | - $buff .= $limit ? $limit : 'null' . PHP_EOL; |
|
283 | - $buff .= $this->join_type ? "'" . $this->join_type . "'" : ''; |
|
282 | + $buff .= $limit ? $limit : 'null'.PHP_EOL; |
|
283 | + $buff .= $this->join_type ? "'".$this->join_type."'" : ''; |
|
284 | 284 | $buff .= ')'; |
285 | 285 | |
286 | 286 | $this->buff = $buff; |
287 | 287 | return $this->buff; |
288 | 288 | } |
289 | 289 | |
290 | - $buff .= '$query = new Query();' . PHP_EOL; |
|
290 | + $buff .= '$query = new Query();'.PHP_EOL; |
|
291 | 291 | $buff .= sprintf('$query->setQueryId("%s");%s', $this->query_id, "\n"); |
292 | 292 | $buff .= sprintf('$query->setAction("%s");%s', $this->action, "\n"); |
293 | 293 | $buff .= sprintf('$query->setPriority("%s");%s', $this->priority, "\n"); |
294 | 294 | $buff .= $this->preBuff; |
295 | - if($this->columns) |
|
295 | + if ($this->columns) |
|
296 | 296 | { |
297 | - $buff .= '$query->setColumns(' . $this->columns->toString() . ');' . PHP_EOL; |
|
297 | + $buff .= '$query->setColumns('.$this->columns->toString().');'.PHP_EOL; |
|
298 | 298 | } |
299 | 299 | |
300 | - $buff .= '$query->setTables(' . $this->tables->toString() . ');' . PHP_EOL; |
|
301 | - if($this->action == 'insert-select') |
|
300 | + $buff .= '$query->setTables('.$this->tables->toString().');'.PHP_EOL; |
|
301 | + if ($this->action == 'insert-select') |
|
302 | 302 | { |
303 | - $buff .= '$query->setSubquery(' . $this->subquery->toString() . ');' . PHP_EOL; |
|
303 | + $buff .= '$query->setSubquery('.$this->subquery->toString().');'.PHP_EOL; |
|
304 | 304 | } |
305 | - $buff .= '$query->setConditions(' . $this->conditions->toString() . ');' . PHP_EOL; |
|
306 | - $buff .= '$query->setGroups(' . $this->groups->toString() . ');' . PHP_EOL; |
|
307 | - $buff .= '$query->setOrder(' . $this->navigation->getOrderByString() . ');' . PHP_EOL; |
|
308 | - $buff .= '$query->setLimit(' . $this->navigation->getLimitString() . ');' . PHP_EOL; |
|
305 | + $buff .= '$query->setConditions('.$this->conditions->toString().');'.PHP_EOL; |
|
306 | + $buff .= '$query->setGroups('.$this->groups->toString().');'.PHP_EOL; |
|
307 | + $buff .= '$query->setOrder('.$this->navigation->getOrderByString().');'.PHP_EOL; |
|
308 | + $buff .= '$query->setLimit('.$this->navigation->getLimitString().');'.PHP_EOL; |
|
309 | 309 | |
310 | 310 | $this->buff = $buff; |
311 | 311 | return $this->buff; |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | |
314 | 314 | function getTables() |
315 | 315 | { |
316 | - if($this->query->index_hint && ($this->query->index_hint->attrs->for == 'ALL' || Context::getDBType() == strtolower($this->query->index_hint->attrs->for))) |
|
316 | + if ($this->query->index_hint && ($this->query->index_hint->attrs->for == 'ALL' || Context::getDBType() == strtolower($this->query->index_hint->attrs->for))) |
|
317 | 317 | { |
318 | 318 | return $this->tables = new TablesTag($this->query->tables, $this->query->index_hint); |
319 | 319 | } |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | |
326 | 326 | function getSubquery() |
327 | 327 | { |
328 | - if($this->query->query) |
|
328 | + if ($this->query->query) |
|
329 | 329 | { |
330 | 330 | $this->subquery = new QueryTag($this->query->query, true); |
331 | 331 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | |
339 | 339 | function getGroups() |
340 | 340 | { |
341 | - if($this->query->groups) |
|
341 | + if ($this->query->groups) |
|
342 | 342 | { |
343 | 343 | return $this->groups = new GroupsTag($this->query->groups->group); |
344 | 344 | } |
@@ -376,11 +376,11 @@ discard block |
||
376 | 376 | function getArguments() |
377 | 377 | { |
378 | 378 | $arguments = array(); |
379 | - if($this->columns) |
|
379 | + if ($this->columns) |
|
380 | 380 | { |
381 | 381 | $arguments = array_merge($arguments, $this->columns->getArguments()); |
382 | 382 | } |
383 | - if($this->action == 'insert-select') |
|
383 | + if ($this->action == 'insert-select') |
|
384 | 384 | { |
385 | 385 | $arguments = array_merge($arguments, $this->subquery->getArguments()); |
386 | 386 | } |
@@ -79,9 +79,9 @@ |
||
79 | 79 | /** |
80 | 80 | * Override for parent "parse" method |
81 | 81 | * |
82 | - * @param null $query_id |
|
83 | - * @param null $xml_file |
|
84 | - * @param null $cache_file |
|
82 | + * @param string $query_id |
|
83 | + * @param string $xml_file |
|
84 | + * @param string $cache_file |
|
85 | 85 | * |
86 | 86 | * @return void |
87 | 87 | */ |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | /** |
5 | 5 | * File containing the XE 1.5 XmlQueryParserClass |
6 | 6 | */ |
7 | -if(!defined('__XE_LOADED_XML_CLASS__')) |
|
7 | +if (!defined('__XE_LOADED_XML_CLASS__')) |
|
8 | 8 | { |
9 | 9 | define('__XE_LOADED_XML_CLASS__', 1); |
10 | 10 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | function &getInstance() |
38 | 38 | { |
39 | 39 | static $theInstance = NULL; |
40 | - if(!isset($theInstance)) |
|
40 | + if (!isset($theInstance)) |
|
41 | 41 | { |
42 | 42 | $theInstance = new XmlQueryParser(); |
43 | 43 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | // insert, update, delete, select action |
66 | 66 | $action = strtolower($xml_obj->query->attrs->action); |
67 | - if(!$action) |
|
67 | + if (!$action) |
|
68 | 68 | { |
69 | 69 | return; |
70 | 70 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | { |
102 | 102 | $buff = FileHandler::readFile($xml_file); |
103 | 103 | $xml_obj = parent::parse($buff); |
104 | - if(!$xml_obj) |
|
104 | + if (!$xml_obj) |
|
105 | 105 | { |
106 | 106 | return; |
107 | 107 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param string $module_name The module name to get a instance |
75 | 75 | * @param string $type disp, proc, controller, class |
76 | 76 | * @param string $kind admin, null |
77 | - * @return mixed Module instance |
|
77 | + * @return ModuleObject Module instance |
|
78 | 78 | */ |
79 | 79 | function getModule($module_name, $type = 'view', $kind = '') |
80 | 80 | { |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * Create a controller instance of the module |
86 | 86 | * |
87 | 87 | * @param string $module_name The module name to get a controller instance |
88 | - * @return mixed Module controller instance |
|
88 | + * @return ModuleObject Module controller instance |
|
89 | 89 | */ |
90 | 90 | function getController($module_name) |
91 | 91 | { |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * Create a admin controller instance of the module |
97 | 97 | * |
98 | 98 | * @param string $module_name The module name to get a admin controller instance |
99 | - * @return mixed Module admin controller instance |
|
99 | + * @return ModuleObject Module admin controller instance |
|
100 | 100 | */ |
101 | 101 | function getAdminController($module_name) |
102 | 102 | { |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * Create a view instance of the module |
108 | 108 | * |
109 | 109 | * @param string $module_name The module name to get a view instance |
110 | - * @return mixed Module view instance |
|
110 | + * @return ModuleObject Module view instance |
|
111 | 111 | */ |
112 | 112 | function getView($module_name) |
113 | 113 | { |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * Create a mobile instance of the module |
119 | 119 | * |
120 | 120 | * @param string $module_name The module name to get a mobile instance |
121 | - * @return mixed Module mobile instance |
|
121 | + * @return ModuleObject Module mobile instance |
|
122 | 122 | */ |
123 | 123 | function &getMobile($module_name) |
124 | 124 | { |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * Create a admin view instance of the module |
130 | 130 | * |
131 | 131 | * @param string $module_name The module name to get a admin view instance |
132 | - * @return mixed Module admin view instance |
|
132 | + * @return ModuleObject Module admin view instance |
|
133 | 133 | */ |
134 | 134 | function getAdminView($module_name) |
135 | 135 | { |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * Create a model instance of the module |
141 | 141 | * |
142 | 142 | * @param string $module_name The module name to get a model instance |
143 | - * @return mixed Module model instance |
|
143 | + * @return ModuleObject Module model instance |
|
144 | 144 | */ |
145 | 145 | function getModel($module_name) |
146 | 146 | { |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * Create an admin model instance of the module |
152 | 152 | * |
153 | 153 | * @param string $module_name The module name to get a admin model instance |
154 | - * @return mixed Module admin model instance |
|
154 | + * @return ModuleObject Module admin model instance |
|
155 | 155 | */ |
156 | 156 | function getAdminModel($module_name) |
157 | 157 | { |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * Create an api instance of the module |
163 | 163 | * |
164 | 164 | * @param string $module_name The module name to get a api instance |
165 | - * @return mixed Module api class instance |
|
165 | + * @return ModuleObject Module api class instance |
|
166 | 166 | */ |
167 | 167 | function getAPI($module_name) |
168 | 168 | { |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * Create a wap instance of the module |
174 | 174 | * |
175 | 175 | * @param string $module_name The module name to get a wap instance |
176 | - * @return mixed Module wap class instance |
|
176 | + * @return ModuleObject Module wap class instance |
|
177 | 177 | */ |
178 | 178 | function getWAP($module_name) |
179 | 179 | { |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * Create a class instance of the module |
185 | 185 | * |
186 | 186 | * @param string $module_name The module name to get a class instance |
187 | - * @return mixed Module class instance |
|
187 | + * @return ModuleObject Module class instance |
|
188 | 188 | */ |
189 | 189 | function getClass($module_name) |
190 | 190 | { |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | * Return if domain of the virtual site is url type or id type |
488 | 488 | * |
489 | 489 | * @param string $domain |
490 | - * @return bool |
|
490 | + * @return integer |
|
491 | 491 | */ |
492 | 492 | function isSiteID($domain) |
493 | 493 | { |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | /** |
557 | 557 | * Get a time gap between server's timezone and XE's timezone |
558 | 558 | * |
559 | - * @return int |
|
559 | + * @return double |
|
560 | 560 | */ |
561 | 561 | function zgap() |
562 | 562 | { |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | * YYYYMMDDHHIISS format changed to unix time value |
598 | 598 | * |
599 | 599 | * @param string $str Time value in format of YYYYMMDDHHIISS |
600 | - * @return int |
|
600 | + * @return null|double |
|
601 | 601 | */ |
602 | 602 | function ztime($str) |
603 | 603 | { |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | * Display $buff contents into the file ./files/_debug_message.php. |
791 | 791 | * You can see the file on your prompt by command: tail-f./files/_debug_message.php |
792 | 792 | * |
793 | - * @param mixed $debug_output Target object to be printed |
|
793 | + * @param string $debug_output Target object to be printed |
|
794 | 794 | * @param bool $display_option boolean Flag whether to print seperator (default:true) |
795 | 795 | * @param string $file Target file name |
796 | 796 | * @return void |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | /** |
885 | 885 | * @param string $type query, trigger |
886 | 886 | * @param float $elapsed_time |
887 | - * @param object $obj |
|
887 | + * @param stdClass $obj |
|
888 | 888 | */ |
889 | 889 | function writeSlowlog($type, $elapsed_time, $obj) |
890 | 890 | { |
@@ -1631,6 +1631,9 @@ discard block |
||
1631 | 1631 | } |
1632 | 1632 | } |
1633 | 1633 | |
1634 | +/** |
|
1635 | + * @param string $key |
|
1636 | + */ |
|
1634 | 1637 | function changeValueInUrl($key, $requestKey, $dbKey, $urlName = 'success_return_url') |
1635 | 1638 | { |
1636 | 1639 | if($requestKey != $dbKey) |
@@ -296,10 +296,11 @@ discard block |
||
296 | 296 | $num_args = func_num_args(); |
297 | 297 | $args_list = func_get_args(); |
298 | 298 | |
299 | - if($num_args) |
|
300 | - $url = Context::getUrl($num_args, $args_list); |
|
301 | - else |
|
302 | - $url = Context::getRequestUri(); |
|
299 | + if($num_args) { |
|
300 | + $url = Context::getUrl($num_args, $args_list); |
|
301 | + } else { |
|
302 | + $url = Context::getRequestUri(); |
|
303 | + } |
|
303 | 304 | |
304 | 305 | return preg_replace('@\berror_return_url=[^&]*|\w+=(?:&|$)@', '', $url); |
305 | 306 | } |
@@ -318,8 +319,7 @@ discard block |
||
318 | 319 | if($num_args) |
319 | 320 | { |
320 | 321 | $url = Context::getUrl($num_args, $args_list, NULL, FALSE); |
321 | - } |
|
322 | - else |
|
322 | + } else |
|
323 | 323 | { |
324 | 324 | $url = Context::getRequestUri(); |
325 | 325 | } |
@@ -341,8 +341,7 @@ discard block |
||
341 | 341 | if($num_args) |
342 | 342 | { |
343 | 343 | $url = Context::getUrl($num_args, $args_list, NULL, TRUE, TRUE); |
344 | - } |
|
345 | - else |
|
344 | + } else |
|
346 | 345 | { |
347 | 346 | $url = Context::getRequestUri(); |
348 | 347 | } |
@@ -531,13 +530,11 @@ discard block |
||
531 | 530 | { |
532 | 531 | $char_width += (int) $chars[$c - 32]; |
533 | 532 | $idx++; |
534 | - } |
|
535 | - else if(191 < $c && $c < 224) |
|
533 | + } else if(191 < $c && $c < 224) |
|
536 | 534 | { |
537 | 535 | $char_width += $chars[4]; |
538 | 536 | $idx += 2; |
539 | - } |
|
540 | - else |
|
537 | + } else |
|
541 | 538 | { |
542 | 539 | $char_width += $chars[0]; |
543 | 540 | $idx += 3; |
@@ -564,8 +561,7 @@ discard block |
||
564 | 561 | if($time_zone < 0) |
565 | 562 | { |
566 | 563 | $to = -1; |
567 | - } |
|
568 | - else |
|
564 | + } else |
|
569 | 565 | { |
570 | 566 | $to = 1; |
571 | 567 | } |
@@ -577,8 +573,7 @@ discard block |
||
577 | 573 | if($server_time_zone < 0) |
578 | 574 | { |
579 | 575 | $so = -1; |
580 | - } |
|
581 | - else |
|
576 | + } else |
|
582 | 577 | { |
583 | 578 | $so = 1; |
584 | 579 | } |
@@ -615,8 +610,7 @@ discard block |
||
615 | 610 | if(strlen($str) <= 8) |
616 | 611 | { |
617 | 612 | $gap = 0; |
618 | - } |
|
619 | - else |
|
613 | + } else |
|
620 | 614 | { |
621 | 615 | $gap = zgap(); |
622 | 616 | } |
@@ -639,20 +633,16 @@ discard block |
||
639 | 633 | if($gap < 60) |
640 | 634 | { |
641 | 635 | $buff = sprintf($lang_time_gap['min'], (int) ($gap / 60) + 1); |
642 | - } |
|
643 | - elseif($gap < 60 * 60) |
|
636 | + } elseif($gap < 60 * 60) |
|
644 | 637 | { |
645 | 638 | $buff = sprintf($lang_time_gap['mins'], (int) ($gap / 60) + 1); |
646 | - } |
|
647 | - elseif($gap < 60 * 60 * 2) |
|
639 | + } elseif($gap < 60 * 60 * 2) |
|
648 | 640 | { |
649 | 641 | $buff = sprintf($lang_time_gap['hour'], (int) ($gap / 60 / 60) + 1); |
650 | - } |
|
651 | - elseif($gap < 60 * 60 * 24) |
|
642 | + } elseif($gap < 60 * 60 * 24) |
|
652 | 643 | { |
653 | 644 | $buff = sprintf($lang_time_gap['hours'], (int) ($gap / 60 / 60) + 1); |
654 | - } |
|
655 | - else |
|
645 | + } else |
|
656 | 646 | { |
657 | 647 | $buff = zdate($date, $format); |
658 | 648 | } |
@@ -699,12 +689,10 @@ discard block |
||
699 | 689 | if($format == 'Y-m-d') |
700 | 690 | { |
701 | 691 | $format = 'M d, Y'; |
702 | - } |
|
703 | - elseif($format == 'Y-m-d H:i:s') |
|
692 | + } elseif($format == 'Y-m-d H:i:s') |
|
704 | 693 | { |
705 | 694 | $format = 'M d, Y H:i:s'; |
706 | - } |
|
707 | - elseif($format == 'Y-m-d H:i') |
|
695 | + } elseif($format == 'Y-m-d H:i') |
|
708 | 696 | { |
709 | 697 | $format = 'M d, Y H:i'; |
710 | 698 | } |
@@ -713,12 +701,10 @@ discard block |
||
713 | 701 | if($format == 'Y-m-d') |
714 | 702 | { |
715 | 703 | $format = 'd-m-Y'; |
716 | - } |
|
717 | - elseif($format == 'Y-m-d H:i:s') |
|
704 | + } elseif($format == 'Y-m-d H:i:s') |
|
718 | 705 | { |
719 | 706 | $format = 'H:i:s d-m-Y'; |
720 | - } |
|
721 | - elseif($format == 'Y-m-d H:i') |
|
707 | + } elseif($format == 'Y-m-d H:i') |
|
722 | 708 | { |
723 | 709 | $format = 'H:i d-m-Y'; |
724 | 710 | } |
@@ -754,8 +740,7 @@ discard block |
||
754 | 740 | ); |
755 | 741 | |
756 | 742 | $string = strtr($format, $trans); |
757 | - } |
|
758 | - else |
|
743 | + } else |
|
759 | 744 | { |
760 | 745 | // if year value is greater than 1970, get unixtime by using ztime() for date() function's argument. |
761 | 746 | $string = date($format, ztime($str)); |
@@ -842,8 +827,7 @@ discard block |
||
842 | 827 | } |
843 | 828 | |
844 | 829 | $firephp->fb($debug_output, $label, $type); |
845 | - } |
|
846 | - else |
|
830 | + } else |
|
847 | 831 | { |
848 | 832 | if(__DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) |
849 | 833 | { |
@@ -855,7 +839,9 @@ discard block |
||
855 | 839 | { |
856 | 840 | $debug_file = _XE_PATH_ . 'files/' . $file; |
857 | 841 | } |
858 | - if(!file_exists($debug_file)) $print[] = '<?php exit() ?>'; |
|
842 | + if(!file_exists($debug_file)) { |
|
843 | + $print[] = '<?php exit() ?>'; |
|
844 | + } |
|
859 | 845 | |
860 | 846 | if($display_option === TRUE || $display_option === 'ERROR') |
861 | 847 | { |
@@ -868,13 +854,11 @@ discard block |
||
868 | 854 | if($display_option === 'ERROR') |
869 | 855 | { |
870 | 856 | $print[] = 'ERROR : ' . var_export($debug_output, TRUE); |
871 | - } |
|
872 | - else |
|
857 | + } else |
|
873 | 858 | { |
874 | 859 | $print[] = 'DEBUG : ' . $type . '(' . var_export($debug_output, TRUE) . ')'; |
875 | 860 | } |
876 | - } |
|
877 | - else |
|
861 | + } else |
|
878 | 862 | { |
879 | 863 | $print[] = 'DEBUG : ' . trim(preg_replace('/\r?\n/', "\n" . ' ', print_r($debug_output, true))); |
880 | 864 | } |
@@ -901,7 +885,9 @@ discard block |
||
901 | 885 | */ |
902 | 886 | function writeSlowlog($type, $elapsed_time, $obj) |
903 | 887 | { |
904 | - if(!__LOG_SLOW_TRIGGER__ && !__LOG_SLOW_ADDON__ && !__LOG_SLOW_WIDGET__ && !__LOG_SLOW_QUERY__) return; |
|
888 | + if(!__LOG_SLOW_TRIGGER__ && !__LOG_SLOW_ADDON__ && !__LOG_SLOW_WIDGET__ && !__LOG_SLOW_QUERY__) { |
|
889 | + return; |
|
890 | + } |
|
905 | 891 | |
906 | 892 | static $log_filename = array( |
907 | 893 | 'query' => 'files/_slowlog_query.php', |
@@ -921,25 +907,21 @@ discard block |
||
921 | 907 | { |
922 | 908 | $buff[] = "\tCaller : " . $obj->caller; |
923 | 909 | $buff[] = "\tCalled : " . $obj->called; |
924 | - } |
|
925 | - else if($type == 'addon' && __LOG_SLOW_ADDON__ > 0 && $elapsed_time > __LOG_SLOW_ADDON__) |
|
910 | + } else if($type == 'addon' && __LOG_SLOW_ADDON__ > 0 && $elapsed_time > __LOG_SLOW_ADDON__) |
|
926 | 911 | { |
927 | 912 | $buff[] = "\tAddon : " . $obj->called; |
928 | 913 | $buff[] = "\tCalled position : " . $obj->caller; |
929 | - } |
|
930 | - else if($type == 'widget' && __LOG_SLOW_WIDGET__ > 0 && $elapsed_time > __LOG_SLOW_WIDGET__) |
|
914 | + } else if($type == 'widget' && __LOG_SLOW_WIDGET__ > 0 && $elapsed_time > __LOG_SLOW_WIDGET__) |
|
931 | 915 | { |
932 | 916 | $buff[] = "\tWidget : " . $obj->called; |
933 | - } |
|
934 | - else if($type == 'query' && __LOG_SLOW_QUERY__ > 0 && $elapsed_time > __LOG_SLOW_QUERY__) |
|
917 | + } else if($type == 'query' && __LOG_SLOW_QUERY__ > 0 && $elapsed_time > __LOG_SLOW_QUERY__) |
|
935 | 918 | { |
936 | 919 | |
937 | 920 | $buff[] = $obj->query; |
938 | 921 | $buff[] = "\tQuery ID : " . $obj->query_id; |
939 | 922 | $buff[] = "\tCaller : " . $obj->caller; |
940 | 923 | $buff[] = "\tConnection : " . $obj->connection; |
941 | - } |
|
942 | - else |
|
924 | + } else |
|
943 | 925 | { |
944 | 926 | $write_file = false; |
945 | 927 | } |
@@ -1031,8 +1013,11 @@ discard block |
||
1031 | 1013 | |
1032 | 1014 | foreach($del_vars as $var) |
1033 | 1015 | { |
1034 | - if(is_array($vars)) unset($vars[$var]); |
|
1035 | - else if(is_object($vars)) unset($vars->$var); |
|
1016 | + if(is_array($vars)) { |
|
1017 | + unset($vars[$var]); |
|
1018 | + } else if(is_object($vars)) { |
|
1019 | + unset($vars->$var); |
|
1020 | + } |
|
1036 | 1021 | } |
1037 | 1022 | |
1038 | 1023 | return $vars; |
@@ -1169,8 +1154,7 @@ discard block |
||
1169 | 1154 | if(($close_xmp = strrpos($content, '</xmp>')) === FALSE) |
1170 | 1155 | { |
1171 | 1156 | $content .= '</xmp>'; |
1172 | - } |
|
1173 | - else if($close_xmp < $start_xmp) |
|
1157 | + } else if($close_xmp < $start_xmp) |
|
1174 | 1158 | { |
1175 | 1159 | $content .= '</xmp>'; |
1176 | 1160 | } |
@@ -1227,12 +1211,18 @@ discard block |
||
1227 | 1211 | |
1228 | 1212 | $filter_arrts = array('style', 'src', 'href'); |
1229 | 1213 | |
1230 | - if($tag === 'object') array_push($filter_arrts, 'data'); |
|
1231 | - if($tag === 'param') array_push($filter_arrts, 'value'); |
|
1214 | + if($tag === 'object') { |
|
1215 | + array_push($filter_arrts, 'data'); |
|
1216 | + } |
|
1217 | + if($tag === 'param') { |
|
1218 | + array_push($filter_arrts, 'value'); |
|
1219 | + } |
|
1232 | 1220 | |
1233 | 1221 | foreach($filter_arrts as $attr) |
1234 | 1222 | { |
1235 | - if(!isset($attrs[$attr])) continue; |
|
1223 | + if(!isset($attrs[$attr])) { |
|
1224 | + continue; |
|
1225 | + } |
|
1236 | 1226 | |
1237 | 1227 | $attr_value = rawurldecode($attrs[$attr]); |
1238 | 1228 | $attr_value = htmlspecialchars_decode($attr_value, ENT_COMPAT); |
@@ -1395,16 +1385,14 @@ discard block |
||
1395 | 1385 | $unicode = hexdec($unicodeHexVal); |
1396 | 1386 | $decodedStr .= _code2utf($unicode); |
1397 | 1387 | $pos += 4; |
1398 | - } |
|
1399 | - else |
|
1388 | + } else |
|
1400 | 1389 | { |
1401 | 1390 | // we have an escaped ascii character |
1402 | 1391 | $hexVal = substr($source, $pos, 2); |
1403 | 1392 | $decodedStr .= chr(hexdec($hexVal)); |
1404 | 1393 | $pos += 2; |
1405 | 1394 | } |
1406 | - } |
|
1407 | - else |
|
1395 | + } else |
|
1408 | 1396 | { |
1409 | 1397 | $decodedStr .= $charAt; |
1410 | 1398 | $pos++; |
@@ -1596,8 +1584,7 @@ discard block |
||
1596 | 1584 | if(version_compare(PHP_VERSION, "5.3.0") < 0) |
1597 | 1585 | { |
1598 | 1586 | set_include_path(_XE_PATH_ . "libs/PEAR" . PATH_SEPARATOR . get_include_path()); |
1599 | - } |
|
1600 | - else |
|
1587 | + } else |
|
1601 | 1588 | { |
1602 | 1589 | set_include_path(_XE_PATH_ . "libs/PEAR.1.9.5" . PATH_SEPARATOR . get_include_path()); |
1603 | 1590 | } |
@@ -1634,8 +1621,7 @@ discard block |
||
1634 | 1621 | { |
1635 | 1622 | return FALSE; |
1636 | 1623 | } |
1637 | - } |
|
1638 | - else |
|
1624 | + } else |
|
1639 | 1625 | { |
1640 | 1626 | $virtualSiteInfo = $oModuleModel->getSiteInfo($siteModuleInfo->site_srl); |
1641 | 1627 | if(strtolower($virtualSiteInfo->domain) != strtolower(Context::get('vid')) && !strstr(strtolower($virtualSiteInfo->domain), strtolower($referer['host']))) |
@@ -6,13 +6,13 @@ discard block |
||
6 | 6 | * |
7 | 7 | * @author NAVER ([email protected]) |
8 | 8 | */ |
9 | -if(!defined('__XE__')) |
|
9 | +if (!defined('__XE__')) |
|
10 | 10 | { |
11 | 11 | exit(); |
12 | 12 | } |
13 | 13 | |
14 | 14 | // define an empty function to avoid errors when iconv function doesn't exist |
15 | -if(!function_exists('iconv')) |
|
15 | +if (!function_exists('iconv')) |
|
16 | 16 | { |
17 | 17 | eval(' |
18 | 18 | function iconv($in_charset, $out_charset, $str) |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | { |
221 | 221 | $oDB = DB::getInstance(); |
222 | 222 | $output = $oDB->executeQuery($query_id, $args, $arg_columns); |
223 | - if(!is_array($output->data) && count($output->data) > 0) |
|
223 | + if (!is_array($output->data) && count($output->data) > 0) |
|
224 | 224 | { |
225 | 225 | $output->data = array($output->data); |
226 | 226 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | function setUserSequence($seq) |
251 | 251 | { |
252 | 252 | $arr_seq = array(); |
253 | - if(isset($_SESSION['seq'])) |
|
253 | + if (isset($_SESSION['seq'])) |
|
254 | 254 | { |
255 | 255 | $arr_seq = $_SESSION['seq']; |
256 | 256 | } |
@@ -266,11 +266,11 @@ discard block |
||
266 | 266 | */ |
267 | 267 | function checkUserSequence($seq) |
268 | 268 | { |
269 | - if(!isset($_SESSION['seq'])) |
|
269 | + if (!isset($_SESSION['seq'])) |
|
270 | 270 | { |
271 | 271 | return false; |
272 | 272 | } |
273 | - if(!in_array($seq, $_SESSION['seq'])) |
|
273 | + if (!in_array($seq, $_SESSION['seq'])) |
|
274 | 274 | { |
275 | 275 | return false; |
276 | 276 | } |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | $num_args = func_num_args(); |
297 | 297 | $args_list = func_get_args(); |
298 | 298 | |
299 | - if($num_args) |
|
299 | + if ($num_args) |
|
300 | 300 | $url = Context::getUrl($num_args, $args_list); |
301 | 301 | else |
302 | 302 | $url = Context::getRequestUri(); |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | $num_args = func_num_args(); |
316 | 316 | $args_list = func_get_args(); |
317 | 317 | |
318 | - if($num_args) |
|
318 | + if ($num_args) |
|
319 | 319 | { |
320 | 320 | $url = Context::getUrl($num_args, $args_list, NULL, FALSE); |
321 | 321 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | $num_args = func_num_args(); |
339 | 339 | $args_list = func_get_args(); |
340 | 340 | |
341 | - if($num_args) |
|
341 | + if ($num_args) |
|
342 | 342 | { |
343 | 343 | $url = Context::getUrl($num_args, $args_list, NULL, TRUE, TRUE); |
344 | 344 | } |
@@ -360,16 +360,16 @@ discard block |
||
360 | 360 | $num_args = func_num_args(); |
361 | 361 | $args_list = func_get_args(); |
362 | 362 | $request_uri = Context::getRequestUri(); |
363 | - if(!$num_args) |
|
363 | + if (!$num_args) |
|
364 | 364 | { |
365 | 365 | return $request_uri; |
366 | 366 | } |
367 | 367 | |
368 | 368 | $url = Context::getUrl($num_args, $args_list); |
369 | - if(strncasecmp('http', $url, 4) !== 0) |
|
369 | + if (strncasecmp('http', $url, 4) !== 0) |
|
370 | 370 | { |
371 | 371 | preg_match('/^(http|https):\/\/([^\/]+)\//', $request_uri, $match); |
372 | - return substr($match[0], 0, -1) . $url; |
|
372 | + return substr($match[0], 0, -1).$url; |
|
373 | 373 | } |
374 | 374 | return $url; |
375 | 375 | } |
@@ -384,17 +384,17 @@ discard block |
||
384 | 384 | $num_args = func_num_args(); |
385 | 385 | $args_list = func_get_args(); |
386 | 386 | $request_uri = Context::getRequestUri(); |
387 | - if(!$num_args) |
|
387 | + if (!$num_args) |
|
388 | 388 | { |
389 | 389 | return $request_uri; |
390 | 390 | } |
391 | 391 | |
392 | 392 | $url = Context::getUrl($num_args, $args_list, NULL, FALSE); |
393 | - if(strncasecmp('http', $url, 4) !== 0) |
|
393 | + if (strncasecmp('http', $url, 4) !== 0) |
|
394 | 394 | { |
395 | 395 | preg_match('/^(http|https):\/\/([^\/]+)\//', $request_uri, $match); |
396 | 396 | $url = Context::getUrl($num_args, $args_list, NULL, FALSE); |
397 | - return substr($match[0], 0, -1) . $url; |
|
397 | + return substr($match[0], 0, -1).$url; |
|
398 | 398 | } |
399 | 399 | return $url; |
400 | 400 | } |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | $num_args = func_num_args(); |
411 | 411 | $args_list = func_get_args(); |
412 | 412 | |
413 | - if(!$num_args) |
|
413 | + if (!$num_args) |
|
414 | 414 | { |
415 | 415 | return Context::getRequestUri(); |
416 | 416 | } |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | $num_args = func_num_args(); |
433 | 433 | $args_list = func_get_args(); |
434 | 434 | |
435 | - if(!$num_args) |
|
435 | + if (!$num_args) |
|
436 | 436 | { |
437 | 437 | return Context::getRequestUri(); |
438 | 438 | } |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | $args_list = func_get_args(); |
455 | 455 | |
456 | 456 | $request_uri = Context::getRequestUri(); |
457 | - if(!$num_args) |
|
457 | + if (!$num_args) |
|
458 | 458 | { |
459 | 459 | return $request_uri; |
460 | 460 | } |
@@ -463,10 +463,10 @@ discard block |
||
463 | 463 | $num_args = count($args_list); |
464 | 464 | |
465 | 465 | $url = Context::getUrl($num_args, $args_list, $domain); |
466 | - if(strncasecmp('http', $url, 4) !== 0) |
|
466 | + if (strncasecmp('http', $url, 4) !== 0) |
|
467 | 467 | { |
468 | 468 | preg_match('/^(http|https):\/\/([^\/]+)\//', $request_uri, $match); |
469 | - return substr($match[0], 0, -1) . $url; |
|
469 | + return substr($match[0], 0, -1).$url; |
|
470 | 470 | } |
471 | 471 | return $url; |
472 | 472 | } |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | function getCurrentPageUrl() |
480 | 480 | { |
481 | 481 | $protocol = $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://'; |
482 | - $url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
482 | + $url = $protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |
|
483 | 483 | return htmlspecialchars($url, ENT_COMPAT, 'UTF-8', FALSE); |
484 | 484 | } |
485 | 485 | |
@@ -504,12 +504,12 @@ discard block |
||
504 | 504 | */ |
505 | 505 | function cut_str($string, $cut_size = 0, $tail = '...') |
506 | 506 | { |
507 | - if($cut_size < 1 || !$string) |
|
507 | + if ($cut_size < 1 || !$string) |
|
508 | 508 | { |
509 | 509 | return $string; |
510 | 510 | } |
511 | 511 | |
512 | - if($GLOBALS['use_mb_strimwidth'] || function_exists('mb_strimwidth')) |
|
512 | + if ($GLOBALS['use_mb_strimwidth'] || function_exists('mb_strimwidth')) |
|
513 | 513 | { |
514 | 514 | $GLOBALS['use_mb_strimwidth'] = TRUE; |
515 | 515 | return mb_strimwidth($string, 0, $cut_size + 4, $tail, 'utf-8'); |
@@ -523,16 +523,16 @@ discard block |
||
523 | 523 | $char_count = 0; |
524 | 524 | |
525 | 525 | $idx = 0; |
526 | - while($idx < $string_length && $char_count < $cut_size && $char_width <= $max_width) |
|
526 | + while ($idx < $string_length && $char_count < $cut_size && $char_width <= $max_width) |
|
527 | 527 | { |
528 | 528 | $c = ord(substr($string, $idx, 1)); |
529 | 529 | $char_count++; |
530 | - if($c < 128) |
|
530 | + if ($c < 128) |
|
531 | 531 | { |
532 | 532 | $char_width += (int) $chars[$c - 32]; |
533 | 533 | $idx++; |
534 | 534 | } |
535 | - else if(191 < $c && $c < 224) |
|
535 | + else if (191 < $c && $c < 224) |
|
536 | 536 | { |
537 | 537 | $char_width += $chars[4]; |
538 | 538 | $idx += 2; |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | } |
546 | 546 | |
547 | 547 | $output = substr($string, 0, $idx); |
548 | - if(strlen($output) < $string_length) |
|
548 | + if (strlen($output) < $string_length) |
|
549 | 549 | { |
550 | 550 | $output .= $tail; |
551 | 551 | } |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | function zgap() |
562 | 562 | { |
563 | 563 | $time_zone = $GLOBALS['_time_zone']; |
564 | - if($time_zone < 0) |
|
564 | + if ($time_zone < 0) |
|
565 | 565 | { |
566 | 566 | $to = -1; |
567 | 567 | } |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | $t_min = substr($time_zone, 3, 2) * $to; |
575 | 575 | |
576 | 576 | $server_time_zone = date("O"); |
577 | - if($server_time_zone < 0) |
|
577 | + if ($server_time_zone < 0) |
|
578 | 578 | { |
579 | 579 | $so = -1; |
580 | 580 | } |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | */ |
602 | 602 | function ztime($str) |
603 | 603 | { |
604 | - if(!$str) |
|
604 | + if (!$str) |
|
605 | 605 | { |
606 | 606 | return; |
607 | 607 | } |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | $year = (int) substr($str, 0, 4); |
613 | 613 | $month = (int) substr($str, 4, 2); |
614 | 614 | $day = (int) substr($str, 6, 2); |
615 | - if(strlen($str) <= 8) |
|
615 | + if (strlen($str) <= 8) |
|
616 | 616 | { |
617 | 617 | $gap = 0; |
618 | 618 | } |
@@ -636,19 +636,19 @@ discard block |
||
636 | 636 | $gap = $_SERVER['REQUEST_TIME'] + zgap() - ztime($date); |
637 | 637 | |
638 | 638 | $lang_time_gap = Context::getLang('time_gap'); |
639 | - if($gap < 60) |
|
639 | + if ($gap < 60) |
|
640 | 640 | { |
641 | 641 | $buff = sprintf($lang_time_gap['min'], (int) ($gap / 60) + 1); |
642 | 642 | } |
643 | - elseif($gap < 60 * 60) |
|
643 | + elseif ($gap < 60 * 60) |
|
644 | 644 | { |
645 | 645 | $buff = sprintf($lang_time_gap['mins'], (int) ($gap / 60) + 1); |
646 | 646 | } |
647 | - elseif($gap < 60 * 60 * 2) |
|
647 | + elseif ($gap < 60 * 60 * 2) |
|
648 | 648 | { |
649 | 649 | $buff = sprintf($lang_time_gap['hour'], (int) ($gap / 60 / 60) + 1); |
650 | 650 | } |
651 | - elseif($gap < 60 * 60 * 24) |
|
651 | + elseif ($gap < 60 * 60 * 24) |
|
652 | 652 | { |
653 | 653 | $buff = sprintf($lang_time_gap['hours'], (int) ($gap / 60 / 60) + 1); |
654 | 654 | } |
@@ -685,40 +685,40 @@ discard block |
||
685 | 685 | function zdate($str, $format = 'Y-m-d H:i:s', $conversion = TRUE) |
686 | 686 | { |
687 | 687 | // return null if no target time is specified |
688 | - if(!$str) |
|
688 | + if (!$str) |
|
689 | 689 | { |
690 | 690 | return; |
691 | 691 | } |
692 | 692 | // convert the date format according to the language |
693 | - if($conversion == TRUE) |
|
693 | + if ($conversion == TRUE) |
|
694 | 694 | { |
695 | - switch(Context::getLangType()) |
|
695 | + switch (Context::getLangType()) |
|
696 | 696 | { |
697 | 697 | case 'en' : |
698 | 698 | case 'es' : |
699 | - if($format == 'Y-m-d') |
|
699 | + if ($format == 'Y-m-d') |
|
700 | 700 | { |
701 | 701 | $format = 'M d, Y'; |
702 | 702 | } |
703 | - elseif($format == 'Y-m-d H:i:s') |
|
703 | + elseif ($format == 'Y-m-d H:i:s') |
|
704 | 704 | { |
705 | 705 | $format = 'M d, Y H:i:s'; |
706 | 706 | } |
707 | - elseif($format == 'Y-m-d H:i') |
|
707 | + elseif ($format == 'Y-m-d H:i') |
|
708 | 708 | { |
709 | 709 | $format = 'M d, Y H:i'; |
710 | 710 | } |
711 | 711 | break; |
712 | 712 | case 'vi' : |
713 | - if($format == 'Y-m-d') |
|
713 | + if ($format == 'Y-m-d') |
|
714 | 714 | { |
715 | 715 | $format = 'd-m-Y'; |
716 | 716 | } |
717 | - elseif($format == 'Y-m-d H:i:s') |
|
717 | + elseif ($format == 'Y-m-d H:i:s') |
|
718 | 718 | { |
719 | 719 | $format = 'H:i:s d-m-Y'; |
720 | 720 | } |
721 | - elseif($format == 'Y-m-d H:i') |
|
721 | + elseif ($format == 'Y-m-d H:i') |
|
722 | 722 | { |
723 | 723 | $format = 'H:i d-m-Y'; |
724 | 724 | } |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | } |
728 | 728 | |
729 | 729 | // If year value is less than 1970, handle it separately. |
730 | - if((int) substr($str, 0, 4) < 1970) |
|
730 | + if ((int) substr($str, 0, 4) < 1970) |
|
731 | 731 | { |
732 | 732 | $hour = (int) substr($str, 8, 2); |
733 | 733 | $min = (int) substr($str, 10, 2); |
@@ -777,9 +777,9 @@ discard block |
||
777 | 777 | function getEncodeEmailAddress($email) |
778 | 778 | { |
779 | 779 | $return = ''; |
780 | - for($i = 0, $c = strlen($email); $i < $c; $i++) |
|
780 | + for ($i = 0, $c = strlen($email); $i < $c; $i++) |
|
781 | 781 | { |
782 | - $return .= '&#' . (rand(0, 1) == 0 ? ord($email[$i]) : 'X' . dechex(ord($email[$i]))) . ';'; |
|
782 | + $return .= '&#'.(rand(0, 1) == 0 ? ord($email[$i]) : 'X'.dechex(ord($email[$i]))).';'; |
|
783 | 783 | } |
784 | 784 | return $return; |
785 | 785 | } |
@@ -799,25 +799,25 @@ discard block |
||
799 | 799 | { |
800 | 800 | static $debug_file; |
801 | 801 | |
802 | - if(!(__DEBUG__ & 1)) |
|
802 | + if (!(__DEBUG__ & 1)) |
|
803 | 803 | { |
804 | 804 | return; |
805 | 805 | } |
806 | 806 | |
807 | 807 | static $firephp; |
808 | 808 | $bt = debug_backtrace(); |
809 | - if(is_array($bt)) |
|
809 | + if (is_array($bt)) |
|
810 | 810 | { |
811 | 811 | $bt_debug_print = array_shift($bt); |
812 | 812 | $bt_called_function = array_shift($bt); |
813 | 813 | } |
814 | 814 | $file_name = str_replace(_XE_PATH_, '', $bt_debug_print['file']); |
815 | 815 | $line_num = $bt_debug_print['line']; |
816 | - $function = $bt_called_function['class'] . $bt_called_function['type'] . $bt_called_function['function']; |
|
816 | + $function = $bt_called_function['class'].$bt_called_function['type'].$bt_called_function['function']; |
|
817 | 817 | |
818 | - if(__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '6.0.0') === -1) |
|
818 | + if (__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '6.0.0') === -1) |
|
819 | 819 | { |
820 | - if(!isset($firephp)) |
|
820 | + if (!isset($firephp)) |
|
821 | 821 | { |
822 | 822 | $firephp = FirePHP::getInstance(TRUE); |
823 | 823 | } |
@@ -826,16 +826,16 @@ discard block |
||
826 | 826 | $label = sprintf('[%s:%d] %s() (Memory usage: current=%s, peak=%s)', $file_name, $line_num, $function, FileHandler::filesize(memory_get_usage()), FileHandler::filesize(memory_get_peak_usage())); |
827 | 827 | |
828 | 828 | // Check a FirePHP option |
829 | - if($display_option === 'TABLE') |
|
829 | + if ($display_option === 'TABLE') |
|
830 | 830 | { |
831 | 831 | $label = $display_option; |
832 | 832 | } |
833 | - if($display_option === 'ERROR') |
|
833 | + if ($display_option === 'ERROR') |
|
834 | 834 | { |
835 | 835 | $type = $display_option; |
836 | 836 | } |
837 | 837 | // Check if the IP specified by __DEBUG_PROTECT__ option is same as the access IP. |
838 | - if(__DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) |
|
838 | + if (__DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) |
|
839 | 839 | { |
840 | 840 | $debug_output = 'The IP address is not allowed. Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php'; |
841 | 841 | $label = NULL; |
@@ -845,52 +845,52 @@ discard block |
||
845 | 845 | } |
846 | 846 | else |
847 | 847 | { |
848 | - if(__DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) |
|
848 | + if (__DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) |
|
849 | 849 | { |
850 | 850 | return; |
851 | 851 | } |
852 | 852 | |
853 | 853 | $print = array(); |
854 | - if(!$debug_file) |
|
854 | + if (!$debug_file) |
|
855 | 855 | { |
856 | - $debug_file = _XE_PATH_ . 'files/' . $file; |
|
856 | + $debug_file = _XE_PATH_.'files/'.$file; |
|
857 | 857 | } |
858 | - if(!file_exists($debug_file)) $print[] = '<?php exit() ?>'; |
|
858 | + if (!file_exists($debug_file)) $print[] = '<?php exit() ?>'; |
|
859 | 859 | |
860 | - if($display_option === TRUE || $display_option === 'ERROR') |
|
860 | + if ($display_option === TRUE || $display_option === 'ERROR') |
|
861 | 861 | { |
862 | - $print[] = sprintf("[%s %s:%d] %s() - mem(%s)", date('Y-m-d H:i:s'), $file_name, $line_num, $function, FileHandler::filesize(memory_get_usage()));; |
|
862 | + $print[] = sprintf("[%s %s:%d] %s() - mem(%s)", date('Y-m-d H:i:s'), $file_name, $line_num, $function, FileHandler::filesize(memory_get_usage())); ; |
|
863 | 863 | $print[] = str_repeat('=', 80); |
864 | 864 | } |
865 | 865 | $type = gettype($debug_output); |
866 | - if(!in_array($type, array('array', 'object', 'resource'))) |
|
866 | + if (!in_array($type, array('array', 'object', 'resource'))) |
|
867 | 867 | { |
868 | - if($display_option === 'ERROR') |
|
868 | + if ($display_option === 'ERROR') |
|
869 | 869 | { |
870 | - $print[] = 'ERROR : ' . var_export($debug_output, TRUE); |
|
870 | + $print[] = 'ERROR : '.var_export($debug_output, TRUE); |
|
871 | 871 | } |
872 | 872 | else |
873 | 873 | { |
874 | - $print[] = 'DEBUG : ' . $type . '(' . var_export($debug_output, TRUE) . ')'; |
|
874 | + $print[] = 'DEBUG : '.$type.'('.var_export($debug_output, TRUE).')'; |
|
875 | 875 | } |
876 | 876 | } |
877 | 877 | else |
878 | 878 | { |
879 | - $print[] = 'DEBUG : ' . trim(preg_replace('/\r?\n/', "\n" . ' ', print_r($debug_output, true))); |
|
879 | + $print[] = 'DEBUG : '.trim(preg_replace('/\r?\n/', "\n".' ', print_r($debug_output, true))); |
|
880 | 880 | } |
881 | 881 | $backtrace_args = defined('\DEBUG_BACKTRACE_IGNORE_ARGS') ? \DEBUG_BACKTRACE_IGNORE_ARGS : 0; |
882 | 882 | $backtrace = debug_backtrace($backtrace_args); |
883 | 883 | |
884 | - if(count($backtrace) > 1 && $backtrace[1]['function'] === 'debugPrint' && !$backtrace[1]['class']) |
|
884 | + if (count($backtrace) > 1 && $backtrace[1]['function'] === 'debugPrint' && !$backtrace[1]['class']) |
|
885 | 885 | { |
886 | 886 | array_shift($backtrace); |
887 | 887 | } |
888 | - foreach($backtrace as $val) |
|
888 | + foreach ($backtrace as $val) |
|
889 | 889 | { |
890 | - $print[] = ' - ' . $val['file'] . ' : ' . $val['line']; |
|
890 | + $print[] = ' - '.$val['file'].' : '.$val['line']; |
|
891 | 891 | } |
892 | 892 | $print[] = PHP_EOL; |
893 | - @file_put_contents($debug_file, implode(PHP_EOL, $print), FILE_APPEND|LOCK_EX); |
|
893 | + @file_put_contents($debug_file, implode(PHP_EOL, $print), FILE_APPEND | LOCK_EX); |
|
894 | 894 | } |
895 | 895 | } |
896 | 896 | |
@@ -901,7 +901,7 @@ discard block |
||
901 | 901 | */ |
902 | 902 | function writeSlowlog($type, $elapsed_time, $obj) |
903 | 903 | { |
904 | - if(!__LOG_SLOW_TRIGGER__ && !__LOG_SLOW_ADDON__ && !__LOG_SLOW_WIDGET__ && !__LOG_SLOW_QUERY__) return; |
|
904 | + if (!__LOG_SLOW_TRIGGER__ && !__LOG_SLOW_ADDON__ && !__LOG_SLOW_WIDGET__ && !__LOG_SLOW_QUERY__) return; |
|
905 | 905 | |
906 | 906 | static $log_filename = array( |
907 | 907 | 'query' => 'files/_slowlog_query.php', |
@@ -911,47 +911,47 @@ discard block |
||
911 | 911 | ); |
912 | 912 | $write_file = true; |
913 | 913 | |
914 | - $log_file = _XE_PATH_ . $log_filename[$type]; |
|
914 | + $log_file = _XE_PATH_.$log_filename[$type]; |
|
915 | 915 | |
916 | 916 | $buff = array(); |
917 | 917 | $buff[] = '<?php exit(); ?>'; |
918 | 918 | $buff[] = date('c'); |
919 | 919 | |
920 | - if($type == 'trigger' && __LOG_SLOW_TRIGGER__ > 0 && $elapsed_time > __LOG_SLOW_TRIGGER__) |
|
920 | + if ($type == 'trigger' && __LOG_SLOW_TRIGGER__ > 0 && $elapsed_time > __LOG_SLOW_TRIGGER__) |
|
921 | 921 | { |
922 | - $buff[] = "\tCaller : " . $obj->caller; |
|
923 | - $buff[] = "\tCalled : " . $obj->called; |
|
922 | + $buff[] = "\tCaller : ".$obj->caller; |
|
923 | + $buff[] = "\tCalled : ".$obj->called; |
|
924 | 924 | } |
925 | - else if($type == 'addon' && __LOG_SLOW_ADDON__ > 0 && $elapsed_time > __LOG_SLOW_ADDON__) |
|
925 | + else if ($type == 'addon' && __LOG_SLOW_ADDON__ > 0 && $elapsed_time > __LOG_SLOW_ADDON__) |
|
926 | 926 | { |
927 | - $buff[] = "\tAddon : " . $obj->called; |
|
928 | - $buff[] = "\tCalled position : " . $obj->caller; |
|
927 | + $buff[] = "\tAddon : ".$obj->called; |
|
928 | + $buff[] = "\tCalled position : ".$obj->caller; |
|
929 | 929 | } |
930 | - else if($type == 'widget' && __LOG_SLOW_WIDGET__ > 0 && $elapsed_time > __LOG_SLOW_WIDGET__) |
|
930 | + else if ($type == 'widget' && __LOG_SLOW_WIDGET__ > 0 && $elapsed_time > __LOG_SLOW_WIDGET__) |
|
931 | 931 | { |
932 | - $buff[] = "\tWidget : " . $obj->called; |
|
932 | + $buff[] = "\tWidget : ".$obj->called; |
|
933 | 933 | } |
934 | - else if($type == 'query' && __LOG_SLOW_QUERY__ > 0 && $elapsed_time > __LOG_SLOW_QUERY__) |
|
934 | + else if ($type == 'query' && __LOG_SLOW_QUERY__ > 0 && $elapsed_time > __LOG_SLOW_QUERY__) |
|
935 | 935 | { |
936 | 936 | |
937 | 937 | $buff[] = $obj->query; |
938 | - $buff[] = "\tQuery ID : " . $obj->query_id; |
|
939 | - $buff[] = "\tCaller : " . $obj->caller; |
|
940 | - $buff[] = "\tConnection : " . $obj->connection; |
|
938 | + $buff[] = "\tQuery ID : ".$obj->query_id; |
|
939 | + $buff[] = "\tCaller : ".$obj->caller; |
|
940 | + $buff[] = "\tConnection : ".$obj->connection; |
|
941 | 941 | } |
942 | 942 | else |
943 | 943 | { |
944 | 944 | $write_file = false; |
945 | 945 | } |
946 | 946 | |
947 | - if($write_file) |
|
947 | + if ($write_file) |
|
948 | 948 | { |
949 | 949 | $buff[] = sprintf("\t%0.6f sec", $elapsed_time); |
950 | - $buff[] = PHP_EOL . PHP_EOL; |
|
950 | + $buff[] = PHP_EOL.PHP_EOL; |
|
951 | 951 | file_put_contents($log_file, implode(PHP_EOL, $buff), FILE_APPEND); |
952 | 952 | } |
953 | 953 | |
954 | - if($type != 'query') |
|
954 | + if ($type != 'query') |
|
955 | 955 | { |
956 | 956 | $trigger_args = $obj; |
957 | 957 | $trigger_args->_log_type = $type; |
@@ -991,11 +991,11 @@ discard block |
||
991 | 991 | */ |
992 | 992 | function delObjectVars($target_obj, $del_obj) |
993 | 993 | { |
994 | - if(!is_object($target_obj)) |
|
994 | + if (!is_object($target_obj)) |
|
995 | 995 | { |
996 | 996 | return; |
997 | 997 | } |
998 | - if(!is_object($del_obj)) |
|
998 | + if (!is_object($del_obj)) |
|
999 | 999 | { |
1000 | 1000 | return; |
1001 | 1001 | } |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | |
1006 | 1006 | $target = array_keys($target_vars); |
1007 | 1007 | $del = array_keys($del_vars); |
1008 | - if(!count($target) || !count($del)) |
|
1008 | + if (!count($target) || !count($del)) |
|
1009 | 1009 | { |
1010 | 1010 | return $target_obj; |
1011 | 1011 | } |
@@ -1013,10 +1013,10 @@ discard block |
||
1013 | 1013 | $return_obj = new stdClass(); |
1014 | 1014 | |
1015 | 1015 | $target_count = count($target); |
1016 | - for($i = 0; $i < $target_count; $i++) |
|
1016 | + for ($i = 0; $i < $target_count; $i++) |
|
1017 | 1017 | { |
1018 | 1018 | $target_key = $target[$i]; |
1019 | - if(!in_array($target_key, $del)) |
|
1019 | + if (!in_array($target_key, $del)) |
|
1020 | 1020 | { |
1021 | 1021 | $return_obj->{$target_key} = $target_obj->{$target_key}; |
1022 | 1022 | } |
@@ -1029,10 +1029,10 @@ discard block |
||
1029 | 1029 | { |
1030 | 1030 | $del_vars = array('error_return_url', 'success_return_url', 'ruleset', 'xe_validator_id'); |
1031 | 1031 | |
1032 | - foreach($del_vars as $var) |
|
1032 | + foreach ($del_vars as $var) |
|
1033 | 1033 | { |
1034 | - if(is_array($vars)) unset($vars[$var]); |
|
1035 | - else if(is_object($vars)) unset($vars->$var); |
|
1034 | + if (is_array($vars)) unset($vars[$var]); |
|
1035 | + else if (is_object($vars)) unset($vars->$var); |
|
1036 | 1036 | } |
1037 | 1037 | |
1038 | 1038 | return $vars; |
@@ -1049,12 +1049,12 @@ discard block |
||
1049 | 1049 | */ |
1050 | 1050 | function handleError($errno, $errstr, $file, $line) |
1051 | 1051 | { |
1052 | - if(!__DEBUG__) |
|
1052 | + if (!__DEBUG__) |
|
1053 | 1053 | { |
1054 | 1054 | return; |
1055 | 1055 | } |
1056 | 1056 | $errors = array(E_USER_ERROR, E_ERROR, E_PARSE); |
1057 | - if(!in_array($errno, $errors)) |
|
1057 | + if (!in_array($errno, $errors)) |
|
1058 | 1058 | { |
1059 | 1059 | return; |
1060 | 1060 | } |
@@ -1074,8 +1074,8 @@ discard block |
||
1074 | 1074 | function getNumberingPath($no, $size = 3) |
1075 | 1075 | { |
1076 | 1076 | $mod = pow(10, $size); |
1077 | - $output = sprintf('%0' . $size . 'd/', $no % $mod); |
|
1078 | - if($no >= $mod) |
|
1077 | + $output = sprintf('%0'.$size.'d/', $no % $mod); |
|
1078 | + if ($no >= $mod) |
|
1079 | 1079 | { |
1080 | 1080 | $output .= getNumberingPath((int) $no / $mod, $size); |
1081 | 1081 | } |
@@ -1095,7 +1095,7 @@ discard block |
||
1095 | 1095 | |
1096 | 1096 | function purifierHtml(&$content) |
1097 | 1097 | { |
1098 | - require_once(_XE_PATH_ . 'classes/security/Purifier.class.php'); |
|
1098 | + require_once(_XE_PATH_.'classes/security/Purifier.class.php'); |
|
1099 | 1099 | $oPurifier = Purifier::getInstance(); |
1100 | 1100 | $oPurifier->purify($content); |
1101 | 1101 | } |
@@ -1108,7 +1108,7 @@ discard block |
||
1108 | 1108 | */ |
1109 | 1109 | function removeHackTag($content) |
1110 | 1110 | { |
1111 | - require_once(_XE_PATH_ . 'classes/security/EmbedFilter.class.php'); |
|
1111 | + require_once(_XE_PATH_.'classes/security/EmbedFilter.class.php'); |
|
1112 | 1112 | $oEmbedFilter = EmbedFilter::getInstance(); |
1113 | 1113 | $oEmbedFilter->check($content); |
1114 | 1114 | |
@@ -1150,7 +1150,7 @@ discard block |
||
1150 | 1150 | */ |
1151 | 1151 | function checkUploadedFile($file) |
1152 | 1152 | { |
1153 | - require_once(_XE_PATH_ . 'classes/security/UploadFileFilter.class.php'); |
|
1153 | + require_once(_XE_PATH_.'classes/security/UploadFileFilter.class.php'); |
|
1154 | 1154 | return UploadFileFilter::check($file); |
1155 | 1155 | } |
1156 | 1156 | |
@@ -1164,13 +1164,13 @@ discard block |
||
1164 | 1164 | { |
1165 | 1165 | $content = preg_replace('@<(/?)xmp.*?>@i', '<\1xmp>', $content); |
1166 | 1166 | |
1167 | - if(($start_xmp = strrpos($content, '<xmp>')) !== FALSE) |
|
1167 | + if (($start_xmp = strrpos($content, '<xmp>')) !== FALSE) |
|
1168 | 1168 | { |
1169 | - if(($close_xmp = strrpos($content, '</xmp>')) === FALSE) |
|
1169 | + if (($close_xmp = strrpos($content, '</xmp>')) === FALSE) |
|
1170 | 1170 | { |
1171 | 1171 | $content .= '</xmp>'; |
1172 | 1172 | } |
1173 | - else if($close_xmp < $start_xmp) |
|
1173 | + else if ($close_xmp < $start_xmp) |
|
1174 | 1174 | { |
1175 | 1175 | $content .= '</xmp>'; |
1176 | 1176 | } |
@@ -1190,33 +1190,33 @@ discard block |
||
1190 | 1190 | $tag = strtolower($match[2]); |
1191 | 1191 | |
1192 | 1192 | // xmp tag ?뺣━ |
1193 | - if($tag == 'xmp') |
|
1193 | + if ($tag == 'xmp') |
|
1194 | 1194 | { |
1195 | 1195 | return "<{$match[1]}xmp>"; |
1196 | 1196 | } |
1197 | - if($match[1]) |
|
1197 | + if ($match[1]) |
|
1198 | 1198 | { |
1199 | 1199 | return $match[0]; |
1200 | 1200 | } |
1201 | - if($match[4]) |
|
1201 | + if ($match[4]) |
|
1202 | 1202 | { |
1203 | - $match[4] = ' ' . $match[4]; |
|
1203 | + $match[4] = ' '.$match[4]; |
|
1204 | 1204 | } |
1205 | 1205 | |
1206 | 1206 | $attrs = array(); |
1207 | - if(preg_match_all('/([\w:-]+)\s*=(?:\s*(["\']))?(?(2)(.*?)\2|([^ ]+))/s', $match[3], $m)) |
|
1207 | + if (preg_match_all('/([\w:-]+)\s*=(?:\s*(["\']))?(?(2)(.*?)\2|([^ ]+))/s', $match[3], $m)) |
|
1208 | 1208 | { |
1209 | - foreach($m[1] as $idx => $name) |
|
1209 | + foreach ($m[1] as $idx => $name) |
|
1210 | 1210 | { |
1211 | - if(strlen($name) >= 2 && substr_compare($name, 'on', 0, 2) === 0) |
|
1211 | + if (strlen($name) >= 2 && substr_compare($name, 'on', 0, 2) === 0) |
|
1212 | 1212 | { |
1213 | 1213 | continue; |
1214 | 1214 | } |
1215 | 1215 | |
1216 | - $val = preg_replace_callback('/&#(?:x([a-fA-F0-9]+)|0*(\d+));/', function($n) {return chr($n[1] ? ('0x00' . $n[1]) : ($n[2] + 0)); }, $m[3][$idx] . $m[4][$idx]); |
|
1216 | + $val = preg_replace_callback('/&#(?:x([a-fA-F0-9]+)|0*(\d+));/', function($n) {return chr($n[1] ? ('0x00'.$n[1]) : ($n[2] + 0)); }, $m[3][$idx].$m[4][$idx]); |
|
1217 | 1217 | $val = preg_replace('/^\s+|[\t\n\r]+/', '', $val); |
1218 | 1218 | |
1219 | - if(preg_match('/^[a-z]+script:/i', $val)) |
|
1219 | + if (preg_match('/^[a-z]+script:/i', $val)) |
|
1220 | 1220 | { |
1221 | 1221 | continue; |
1222 | 1222 | } |
@@ -1227,60 +1227,60 @@ discard block |
||
1227 | 1227 | |
1228 | 1228 | $filter_arrts = array('style', 'src', 'href'); |
1229 | 1229 | |
1230 | - if($tag === 'object') array_push($filter_arrts, 'data'); |
|
1231 | - if($tag === 'param') array_push($filter_arrts, 'value'); |
|
1230 | + if ($tag === 'object') array_push($filter_arrts, 'data'); |
|
1231 | + if ($tag === 'param') array_push($filter_arrts, 'value'); |
|
1232 | 1232 | |
1233 | - foreach($filter_arrts as $attr) |
|
1233 | + foreach ($filter_arrts as $attr) |
|
1234 | 1234 | { |
1235 | - if(!isset($attrs[$attr])) continue; |
|
1235 | + if (!isset($attrs[$attr])) continue; |
|
1236 | 1236 | |
1237 | 1237 | $attr_value = rawurldecode($attrs[$attr]); |
1238 | 1238 | $attr_value = htmlspecialchars_decode($attr_value, ENT_COMPAT); |
1239 | 1239 | $attr_value = preg_replace('/\s+|[\t\n\r]+/', '', $attr_value); |
1240 | - if(preg_match('@(\?|&|;)(act=(\w+))@i', $attr_value, $m) && $m[3] !== 'procFileDownload') |
|
1240 | + if (preg_match('@(\?|&|;)(act=(\w+))@i', $attr_value, $m) && $m[3] !== 'procFileDownload') |
|
1241 | 1241 | { |
1242 | 1242 | unset($attrs[$attr]); |
1243 | 1243 | } |
1244 | 1244 | } |
1245 | 1245 | |
1246 | - if(isset($attrs['style']) && preg_match('@(?:/\*|\*/|\n|:\s*expression\s*\()@i', $attrs['style'])) |
|
1246 | + if (isset($attrs['style']) && preg_match('@(?:/\*|\*/|\n|:\s*expression\s*\()@i', $attrs['style'])) |
|
1247 | 1247 | { |
1248 | 1248 | unset($attrs['style']); |
1249 | 1249 | } |
1250 | 1250 | |
1251 | 1251 | $attr = array(); |
1252 | - foreach($attrs as $name => $val) |
|
1252 | + foreach ($attrs as $name => $val) |
|
1253 | 1253 | { |
1254 | - if($tag == 'object' || $tag == 'embed' || $tag == 'a') |
|
1254 | + if ($tag == 'object' || $tag == 'embed' || $tag == 'a') |
|
1255 | 1255 | { |
1256 | 1256 | $attribute = strtolower(trim($name)); |
1257 | - if($attribute == 'data' || $attribute == 'src' || $attribute == 'href') |
|
1257 | + if ($attribute == 'data' || $attribute == 'src' || $attribute == 'href') |
|
1258 | 1258 | { |
1259 | - if(stripos($val, 'data:') === 0) |
|
1259 | + if (stripos($val, 'data:') === 0) |
|
1260 | 1260 | { |
1261 | 1261 | continue; |
1262 | 1262 | } |
1263 | 1263 | } |
1264 | 1264 | } |
1265 | 1265 | |
1266 | - if($tag == 'img') |
|
1266 | + if ($tag == 'img') |
|
1267 | 1267 | { |
1268 | 1268 | $attribute = strtolower(trim($name)); |
1269 | - if(stripos($val, 'data:') === 0) |
|
1269 | + if (stripos($val, 'data:') === 0) |
|
1270 | 1270 | { |
1271 | 1271 | continue; |
1272 | 1272 | } |
1273 | 1273 | } |
1274 | 1274 | $val = str_replace('"', '"', $val); |
1275 | - $attr[] = $name . "=\"{$val}\""; |
|
1275 | + $attr[] = $name."=\"{$val}\""; |
|
1276 | 1276 | } |
1277 | - $attr = count($attr) ? ' ' . implode(' ', $attr) : ''; |
|
1277 | + $attr = count($attr) ? ' '.implode(' ', $attr) : ''; |
|
1278 | 1278 | |
1279 | 1279 | return "<{$match[1]}{$tag}{$attr}{$match[4]}>"; |
1280 | 1280 | } |
1281 | 1281 | |
1282 | 1282 | // convert hexa value to RGB |
1283 | -if(!function_exists('hexrgb')) |
|
1283 | +if (!function_exists('hexrgb')) |
|
1284 | 1284 | { |
1285 | 1285 | |
1286 | 1286 | /** |
@@ -1316,9 +1316,9 @@ discard block |
||
1316 | 1316 | |
1317 | 1317 | settype($password, "string"); |
1318 | 1318 | |
1319 | - for($i = 0; $i < strlen($password); $i++) |
|
1319 | + for ($i = 0; $i < strlen($password); $i++) |
|
1320 | 1320 | { |
1321 | - if($password[$i] == ' ' || $password[$i] == '\t') |
|
1321 | + if ($password[$i] == ' ' || $password[$i] == '\t') |
|
1322 | 1322 | { |
1323 | 1323 | continue; |
1324 | 1324 | } |
@@ -1330,11 +1330,11 @@ discard block |
||
1330 | 1330 | $result1 = sprintf("%08lx", $nr & ((1 << 31) - 1)); |
1331 | 1331 | $result2 = sprintf("%08lx", $nr2 & ((1 << 31) - 1)); |
1332 | 1332 | |
1333 | - if($result1 == '80000000') |
|
1333 | + if ($result1 == '80000000') |
|
1334 | 1334 | { |
1335 | 1335 | $nr += 0x80000000; |
1336 | 1336 | } |
1337 | - if($result2 == '80000000') |
|
1337 | + if ($result2 == '80000000') |
|
1338 | 1338 | { |
1339 | 1339 | $nr2 += 0x80000000; |
1340 | 1340 | } |
@@ -1350,7 +1350,7 @@ discard block |
||
1350 | 1350 | function getScriptPath() |
1351 | 1351 | { |
1352 | 1352 | static $url = NULL; |
1353 | - if($url == NULL) |
|
1353 | + if ($url == NULL) |
|
1354 | 1354 | { |
1355 | 1355 | $script_path = filter_var($_SERVER['SCRIPT_NAME'], FILTER_SANITIZE_STRING); |
1356 | 1356 | $url = str_ireplace('/tools/', '/', preg_replace('/index.php.*/i', '', str_replace('\\', '/', $script_path))); |
@@ -1381,14 +1381,14 @@ discard block |
||
1381 | 1381 | $decodedStr = ''; |
1382 | 1382 | $pos = 0; |
1383 | 1383 | $len = strlen($source); |
1384 | - while($pos < $len) |
|
1384 | + while ($pos < $len) |
|
1385 | 1385 | { |
1386 | 1386 | $charAt = substr($source, $pos, 1); |
1387 | - if($charAt == '%') |
|
1387 | + if ($charAt == '%') |
|
1388 | 1388 | { |
1389 | 1389 | $pos++; |
1390 | 1390 | $charAt = substr($source, $pos, 1); |
1391 | - if($charAt == 'u') |
|
1391 | + if ($charAt == 'u') |
|
1392 | 1392 | { |
1393 | 1393 | // we got a unicode character |
1394 | 1394 | $pos++; |
@@ -1422,21 +1422,21 @@ discard block |
||
1422 | 1422 | */ |
1423 | 1423 | function _code2utf($num) |
1424 | 1424 | { |
1425 | - if($num < 128) |
|
1425 | + if ($num < 128) |
|
1426 | 1426 | { |
1427 | 1427 | return chr($num); |
1428 | 1428 | } |
1429 | - if($num < 2048) |
|
1429 | + if ($num < 2048) |
|
1430 | 1430 | { |
1431 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
1431 | + return chr(($num >> 6) + 192).chr(($num & 63) + 128); |
|
1432 | 1432 | } |
1433 | - if($num < 65536) |
|
1433 | + if ($num < 65536) |
|
1434 | 1434 | { |
1435 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
1435 | + return chr(($num >> 12) + 224).chr((($num >> 6) & 63) + 128).chr(($num & 63) + 128); |
|
1436 | 1436 | } |
1437 | - if($num < 2097152) |
|
1437 | + if ($num < 2097152) |
|
1438 | 1438 | { |
1439 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
1439 | + return chr(($num >> 18) + 240).chr((($num >> 12) & 63) + 128).chr((($num >> 6) & 63) + 128).chr(($num & 63) + 128); |
|
1440 | 1440 | } |
1441 | 1441 | return ''; |
1442 | 1442 | } |
@@ -1451,7 +1451,7 @@ discard block |
||
1451 | 1451 | */ |
1452 | 1452 | function detectUTF8($string, $return_convert = FALSE, $urldecode = TRUE) |
1453 | 1453 | { |
1454 | - if($urldecode) |
|
1454 | + if ($urldecode) |
|
1455 | 1455 | { |
1456 | 1456 | $string = urldecode($string); |
1457 | 1457 | } |
@@ -1459,12 +1459,12 @@ discard block |
||
1459 | 1459 | $sample = iconv('utf-8', 'utf-8', $string); |
1460 | 1460 | $is_utf8 = (md5($sample) === md5($string)); |
1461 | 1461 | |
1462 | - if(!$urldecode) |
|
1462 | + if (!$urldecode) |
|
1463 | 1463 | { |
1464 | 1464 | $string = urldecode($string); |
1465 | 1465 | } |
1466 | 1466 | |
1467 | - if($return_convert) |
|
1467 | + if ($return_convert) |
|
1468 | 1468 | { |
1469 | 1469 | return ($is_utf8) ? $string : iconv('euc-kr', 'utf-8', $string); |
1470 | 1470 | } |
@@ -1480,7 +1480,7 @@ discard block |
||
1480 | 1480 | */ |
1481 | 1481 | function json_encode2($data) |
1482 | 1482 | { |
1483 | - switch(gettype($data)) |
|
1483 | + switch (gettype($data)) |
|
1484 | 1484 | { |
1485 | 1485 | case 'boolean': |
1486 | 1486 | return $data ? 'true' : 'false'; |
@@ -1488,15 +1488,15 @@ discard block |
||
1488 | 1488 | case 'double': |
1489 | 1489 | return $data; |
1490 | 1490 | case 'string': |
1491 | - return '"' . strtr($data, array('\\' => '\\\\', '"' => '\\"')) . '"'; |
|
1491 | + return '"'.strtr($data, array('\\' => '\\\\', '"' => '\\"')).'"'; |
|
1492 | 1492 | case 'object': |
1493 | 1493 | $data = get_object_vars($data); |
1494 | 1494 | case 'array': |
1495 | 1495 | $rel = FALSE; // relative array? |
1496 | 1496 | $key = array_keys($data); |
1497 | - foreach($key as $v) |
|
1497 | + foreach ($key as $v) |
|
1498 | 1498 | { |
1499 | - if(!is_int($v)) |
|
1499 | + if (!is_int($v)) |
|
1500 | 1500 | { |
1501 | 1501 | $rel = TRUE; |
1502 | 1502 | break; |
@@ -1504,12 +1504,12 @@ discard block |
||
1504 | 1504 | } |
1505 | 1505 | |
1506 | 1506 | $arr = array(); |
1507 | - foreach($data as $k => $v) |
|
1507 | + foreach ($data as $k => $v) |
|
1508 | 1508 | { |
1509 | - $arr[] = ($rel ? '"' . strtr($k, array('\\' => '\\\\', '"' => '\\"')) . '":' : '') . json_encode2($v); |
|
1509 | + $arr[] = ($rel ? '"'.strtr($k, array('\\' => '\\\\', '"' => '\\"')).'":' : '').json_encode2($v); |
|
1510 | 1510 | } |
1511 | 1511 | |
1512 | - return $rel ? '{' . join(',', $arr) . '}' : '[' . join(',', $arr) . ']'; |
|
1512 | + return $rel ? '{'.join(',', $arr).'}' : '['.join(',', $arr).']'; |
|
1513 | 1513 | default: |
1514 | 1514 | return '""'; |
1515 | 1515 | } |
@@ -1523,7 +1523,7 @@ discard block |
||
1523 | 1523 | */ |
1524 | 1524 | function isCrawler($agent = NULL) |
1525 | 1525 | { |
1526 | - if(!$agent) |
|
1526 | + if (!$agent) |
|
1527 | 1527 | { |
1528 | 1528 | $agent = $_SERVER['HTTP_USER_AGENT']; |
1529 | 1529 | } |
@@ -1533,9 +1533,9 @@ discard block |
||
1533 | 1533 | /*'211.245.21.110-211.245.21.119' mixsh is closed */ |
1534 | 1534 | ); |
1535 | 1535 | |
1536 | - foreach($check_agent as $str) |
|
1536 | + foreach ($check_agent as $str) |
|
1537 | 1537 | { |
1538 | - if(stristr($agent, $str) != FALSE) |
|
1538 | + if (stristr($agent, $str) != FALSE) |
|
1539 | 1539 | { |
1540 | 1540 | return TRUE; |
1541 | 1541 | } |
@@ -1553,7 +1553,7 @@ discard block |
||
1553 | 1553 | */ |
1554 | 1554 | function stripEmbedTagForAdmin(&$content, $writer_member_srl) |
1555 | 1555 | { |
1556 | - if(!Context::get('is_logged')) |
|
1556 | + if (!Context::get('is_logged')) |
|
1557 | 1557 | { |
1558 | 1558 | return; |
1559 | 1559 | } |
@@ -1561,18 +1561,18 @@ discard block |
||
1561 | 1561 | $oModuleModel = getModel('module'); |
1562 | 1562 | $logged_info = Context::get('logged_info'); |
1563 | 1563 | |
1564 | - if($writer_member_srl != $logged_info->member_srl && ($logged_info->is_admin == "Y" || $oModuleModel->isSiteAdmin($logged_info))) |
|
1564 | + if ($writer_member_srl != $logged_info->member_srl && ($logged_info->is_admin == "Y" || $oModuleModel->isSiteAdmin($logged_info))) |
|
1565 | 1565 | { |
1566 | - if($writer_member_srl) |
|
1566 | + if ($writer_member_srl) |
|
1567 | 1567 | { |
1568 | 1568 | $oMemberModel = getModel('member'); |
1569 | 1569 | $member_info = $oMemberModel->getMemberInfoByMemberSrl($writer_member_srl); |
1570 | - if($member_info->is_admin == "Y") |
|
1570 | + if ($member_info->is_admin == "Y") |
|
1571 | 1571 | { |
1572 | 1572 | return; |
1573 | 1573 | } |
1574 | 1574 | } |
1575 | - $security_msg = "<div style='border: 1px solid #DDD; background: #FAFAFA; text-align:center; margin: 1em 0;'><p style='margin: 1em;'>" . Context::getLang('security_warning_embed') . "</p></div>"; |
|
1575 | + $security_msg = "<div style='border: 1px solid #DDD; background: #FAFAFA; text-align:center; margin: 1em 0;'><p style='margin: 1em;'>".Context::getLang('security_warning_embed')."</p></div>"; |
|
1576 | 1576 | $content = preg_replace('/<object[^>]+>(.*?<\/object>)?/is', $security_msg, $content); |
1577 | 1577 | $content = preg_replace('/<embed[^>]+>(\s*<\/embed>)?/is', $security_msg, $content); |
1578 | 1578 | $content = preg_replace('/<img[^>]+editor_component="multimedia_link"[^>]*>(\s*<\/img>)?/is', $security_msg, $content); |
@@ -1589,18 +1589,18 @@ discard block |
||
1589 | 1589 | function requirePear() |
1590 | 1590 | { |
1591 | 1591 | static $required = false; |
1592 | - if($required) |
|
1592 | + if ($required) |
|
1593 | 1593 | { |
1594 | 1594 | return; |
1595 | 1595 | } |
1596 | 1596 | |
1597 | - if(version_compare(PHP_VERSION, "5.3.0") < 0) |
|
1597 | + if (version_compare(PHP_VERSION, "5.3.0") < 0) |
|
1598 | 1598 | { |
1599 | - set_include_path(_XE_PATH_ . "libs/PEAR" . PATH_SEPARATOR . get_include_path()); |
|
1599 | + set_include_path(_XE_PATH_."libs/PEAR".PATH_SEPARATOR.get_include_path()); |
|
1600 | 1600 | } |
1601 | 1601 | else |
1602 | 1602 | { |
1603 | - set_include_path(_XE_PATH_ . "libs/PEAR.1.9.5" . PATH_SEPARATOR . get_include_path()); |
|
1603 | + set_include_path(_XE_PATH_."libs/PEAR.1.9.5".PATH_SEPARATOR.get_include_path()); |
|
1604 | 1604 | } |
1605 | 1605 | |
1606 | 1606 | $required = true; |
@@ -1608,7 +1608,7 @@ discard block |
||
1608 | 1608 | |
1609 | 1609 | function checkCSRF() |
1610 | 1610 | { |
1611 | - if($_SERVER['REQUEST_METHOD'] != 'POST') |
|
1611 | + if ($_SERVER['REQUEST_METHOD'] != 'POST') |
|
1612 | 1612 | { |
1613 | 1613 | return FALSE; |
1614 | 1614 | } |
@@ -1616,9 +1616,9 @@ discard block |
||
1616 | 1616 | $default_url = Context::getDefaultUrl(); |
1617 | 1617 | $referer = $_SERVER["HTTP_REFERER"]; |
1618 | 1618 | |
1619 | - if(strpos($default_url, 'xn--') !== FALSE && strpos($referer, 'xn--') === FALSE) |
|
1619 | + if (strpos($default_url, 'xn--') !== FALSE && strpos($referer, 'xn--') === FALSE) |
|
1620 | 1620 | { |
1621 | - require_once(_XE_PATH_ . 'libs/idna_convert/idna_convert.class.php'); |
|
1621 | + require_once(_XE_PATH_.'libs/idna_convert/idna_convert.class.php'); |
|
1622 | 1622 | $IDN = new idna_convert(array('idn_version' => 2008)); |
1623 | 1623 | $referer = $IDN->encode($referer); |
1624 | 1624 | } |
@@ -1629,9 +1629,9 @@ discard block |
||
1629 | 1629 | $oModuleModel = getModel('module'); |
1630 | 1630 | $siteModuleInfo = $oModuleModel->getDefaultMid(); |
1631 | 1631 | |
1632 | - if($siteModuleInfo->site_srl == 0) |
|
1632 | + if ($siteModuleInfo->site_srl == 0) |
|
1633 | 1633 | { |
1634 | - if($default_url['host'] !== $referer['host']) |
|
1634 | + if ($default_url['host'] !== $referer['host']) |
|
1635 | 1635 | { |
1636 | 1636 | return FALSE; |
1637 | 1637 | } |
@@ -1639,7 +1639,7 @@ discard block |
||
1639 | 1639 | else |
1640 | 1640 | { |
1641 | 1641 | $virtualSiteInfo = $oModuleModel->getSiteInfo($siteModuleInfo->site_srl); |
1642 | - if(strtolower($virtualSiteInfo->domain) != strtolower(Context::get('vid')) && !strstr(strtolower($virtualSiteInfo->domain), strtolower($referer['host']))) |
|
1642 | + if (strtolower($virtualSiteInfo->domain) != strtolower(Context::get('vid')) && !strstr(strtolower($virtualSiteInfo->domain), strtolower($referer['host']))) |
|
1643 | 1643 | { |
1644 | 1644 | return FALSE; |
1645 | 1645 | } |
@@ -1655,15 +1655,15 @@ discard block |
||
1655 | 1655 | */ |
1656 | 1656 | function recurciveExposureCheck(&$menu) |
1657 | 1657 | { |
1658 | - if(is_array($menu)) |
|
1658 | + if (is_array($menu)) |
|
1659 | 1659 | { |
1660 | - foreach($menu AS $key=>$value) |
|
1660 | + foreach ($menu AS $key=>$value) |
|
1661 | 1661 | { |
1662 | - if(!$value['isShow']) |
|
1662 | + if (!$value['isShow']) |
|
1663 | 1663 | { |
1664 | 1664 | unset($menu[$key]); |
1665 | 1665 | } |
1666 | - if(is_array($value['list']) && count($value['list']) > 0) |
|
1666 | + if (is_array($value['list']) && count($value['list']) > 0) |
|
1667 | 1667 | { |
1668 | 1668 | recurciveExposureCheck($menu[$key]['list']); |
1669 | 1669 | } |
@@ -1673,14 +1673,14 @@ discard block |
||
1673 | 1673 | |
1674 | 1674 | function changeValueInUrl($key, $requestKey, $dbKey, $urlName = 'success_return_url') |
1675 | 1675 | { |
1676 | - if($requestKey != $dbKey) |
|
1676 | + if ($requestKey != $dbKey) |
|
1677 | 1677 | { |
1678 | 1678 | $arrayUrl = parse_url(Context::get('success_return_url')); |
1679 | - if($arrayUrl['query']) |
|
1679 | + if ($arrayUrl['query']) |
|
1680 | 1680 | { |
1681 | 1681 | parse_str($arrayUrl['query'], $parsedStr); |
1682 | 1682 | |
1683 | - if(isset($parsedStr[$key])) |
|
1683 | + if (isset($parsedStr[$key])) |
|
1684 | 1684 | { |
1685 | 1685 | $parsedStr[$key] = $requestKey; |
1686 | 1686 | $successReturnUrl .= $arrayUrl['path'].'?'.http_build_query($parsedStr); |
@@ -1723,14 +1723,14 @@ discard block |
||
1723 | 1723 | */ |
1724 | 1724 | function alertScript($msg) |
1725 | 1725 | { |
1726 | - if(!$msg) |
|
1726 | + if (!$msg) |
|
1727 | 1727 | { |
1728 | 1728 | return; |
1729 | 1729 | } |
1730 | 1730 | |
1731 | 1731 | echo '<script type="text/javascript"> |
1732 | 1732 | //<![CDATA[ |
1733 | -alert("' . $msg . '"); |
|
1733 | +alert("' . $msg.'"); |
|
1734 | 1734 | //]]> |
1735 | 1735 | </script>'; |
1736 | 1736 | } |
@@ -1761,7 +1761,7 @@ discard block |
||
1761 | 1761 | |
1762 | 1762 | echo '<script type="text/javascript"> |
1763 | 1763 | //<![CDATA[ |
1764 | -' . $reloadScript . ' |
|
1764 | +' . $reloadScript.' |
|
1765 | 1765 | //]]> |
1766 | 1766 | </script>'; |
1767 | 1767 | } |
@@ -50,7 +50,6 @@ discard block |
||
50 | 50 | * "Server" request tab. |
51 | 51 | * |
52 | 52 | * @see http://www.firephp.org/Wiki/Reference/Fb |
53 | - * @param mixed $Object |
|
54 | 53 | * @return true |
55 | 54 | * @throws Exception |
56 | 55 | */ |
@@ -130,7 +129,6 @@ discard block |
||
130 | 129 | * Log object to firebug |
131 | 130 | * |
132 | 131 | * @see http://www.firephp.org/Wiki/Reference/Fb |
133 | - * @param mixed $Object |
|
134 | 132 | * @return true |
135 | 133 | * @throws Exception |
136 | 134 | */ |
@@ -150,7 +148,7 @@ discard block |
||
150 | 148 | * |
151 | 149 | * @param string $Name |
152 | 150 | * @param array $Options OPTIONAL Instructions on how to log the group |
153 | - * @return true |
|
151 | + * @return boolean |
|
154 | 152 | */ |
155 | 153 | public static function group($Name, $Options=null) { |
156 | 154 | $instance = FirePHP::getInstance(true); |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | * @return void |
74 | 74 | */ |
75 | 75 | public static function setEnabled($Enabled) { |
76 | - $instance = FirePHP::getInstance(true); |
|
77 | - $instance->setEnabled($Enabled); |
|
76 | + $instance = FirePHP::getInstance(true); |
|
77 | + $instance->setEnabled($Enabled); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | * @return boolean TRUE if enabled |
85 | 85 | */ |
86 | 86 | public static function getEnabled() { |
87 | - $instance = FirePHP::getInstance(true); |
|
88 | - return $instance->getEnabled(); |
|
87 | + $instance = FirePHP::getInstance(true); |
|
88 | + return $instance->getEnabled(); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | * @return void |
100 | 100 | */ |
101 | 101 | public static function setObjectFilter($Class, $Filter) { |
102 | - $instance = FirePHP::getInstance(true); |
|
103 | - $instance->setObjectFilter($Class, $Filter); |
|
102 | + $instance = FirePHP::getInstance(true); |
|
103 | + $instance->setObjectFilter($Class, $Filter); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | * @return void |
112 | 112 | */ |
113 | 113 | public static function setOptions($Options) { |
114 | - $instance = FirePHP::getInstance(true); |
|
115 | - $instance->setOptions($Options); |
|
114 | + $instance = FirePHP::getInstance(true); |
|
115 | + $instance->setOptions($Options); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @return array The options |
123 | 123 | */ |
124 | 124 | public static function getOptions() { |
125 | - $instance = FirePHP::getInstance(true); |
|
126 | - return $instance->getOptions(); |
|
125 | + $instance = FirePHP::getInstance(true); |
|
126 | + return $instance->getOptions(); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -136,9 +136,9 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public static function send() |
138 | 138 | { |
139 | - $instance = FirePHP::getInstance(true); |
|
140 | - $args = func_get_args(); |
|
141 | - return call_user_func_array(array($instance,'fb'),$args); |
|
139 | + $instance = FirePHP::getInstance(true); |
|
140 | + $args = func_get_args(); |
|
141 | + return call_user_func_array(array($instance,'fb'),$args); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | * @return true |
154 | 154 | */ |
155 | 155 | public static function group($Name, $Options=null) { |
156 | - $instance = FirePHP::getInstance(true); |
|
157 | - return $instance->group($Name, $Options); |
|
156 | + $instance = FirePHP::getInstance(true); |
|
157 | + return $instance->group($Name, $Options); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @throws Exception |
165 | 165 | */ |
166 | 166 | public static function groupEnd() { |
167 | - return self::send(null, null, FirePHP::GROUP_END); |
|
167 | + return self::send(null, null, FirePHP::GROUP_END); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @throws Exception |
178 | 178 | */ |
179 | 179 | public static function log($Object, $Label=null) { |
180 | - return self::send($Object, $Label, FirePHP::LOG); |
|
180 | + return self::send($Object, $Label, FirePHP::LOG); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @throws Exception |
191 | 191 | */ |
192 | 192 | public static function info($Object, $Label=null) { |
193 | - return self::send($Object, $Label, FirePHP::INFO); |
|
193 | + return self::send($Object, $Label, FirePHP::INFO); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @throws Exception |
204 | 204 | */ |
205 | 205 | public static function warn($Object, $Label=null) { |
206 | - return self::send($Object, $Label, FirePHP::WARN); |
|
206 | + return self::send($Object, $Label, FirePHP::WARN); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * @throws Exception |
217 | 217 | */ |
218 | 218 | public static function error($Object, $Label=null) { |
219 | - return self::send($Object, $Label, FirePHP::ERROR); |
|
219 | + return self::send($Object, $Label, FirePHP::ERROR); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @throws Exception |
230 | 230 | */ |
231 | 231 | public static function dump($Key, $Variable) { |
232 | - return self::send($Variable, $Key, FirePHP::DUMP); |
|
232 | + return self::send($Variable, $Key, FirePHP::DUMP); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @throws Exception |
242 | 242 | */ |
243 | 243 | public static function trace($Label) { |
244 | - return self::send($Label, FirePHP::TRACE); |
|
244 | + return self::send($Label, FirePHP::TRACE); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * @throws Exception |
255 | 255 | */ |
256 | 256 | public static function table($Label, $Table) { |
257 | - return self::send($Table, $Label, FirePHP::TABLE); |
|
257 | + return self::send($Table, $Label, FirePHP::TABLE); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $instance = FirePHP::getInstance(true); |
60 | 60 | |
61 | 61 | $args = func_get_args(); |
62 | - return call_user_func_array(array($instance,'fb'),$args); |
|
62 | + return call_user_func_array(array($instance, 'fb'), $args); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | { |
139 | 139 | $instance = FirePHP::getInstance(true); |
140 | 140 | $args = func_get_args(); |
141 | - return call_user_func_array(array($instance,'fb'),$args); |
|
141 | + return call_user_func_array(array($instance, 'fb'), $args); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @param array $Options OPTIONAL Instructions on how to log the group |
153 | 153 | * @return true |
154 | 154 | */ |
155 | - public static function group($Name, $Options=null) { |
|
155 | + public static function group($Name, $Options = null) { |
|
156 | 156 | $instance = FirePHP::getInstance(true); |
157 | 157 | return $instance->group($Name, $Options); |
158 | 158 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @return true |
177 | 177 | * @throws Exception |
178 | 178 | */ |
179 | - public static function log($Object, $Label=null) { |
|
179 | + public static function log($Object, $Label = null) { |
|
180 | 180 | return self::send($Object, $Label, FirePHP::LOG); |
181 | 181 | } |
182 | 182 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * @return true |
190 | 190 | * @throws Exception |
191 | 191 | */ |
192 | - public static function info($Object, $Label=null) { |
|
192 | + public static function info($Object, $Label = null) { |
|
193 | 193 | return self::send($Object, $Label, FirePHP::INFO); |
194 | 194 | } |
195 | 195 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @return true |
203 | 203 | * @throws Exception |
204 | 204 | */ |
205 | - public static function warn($Object, $Label=null) { |
|
205 | + public static function warn($Object, $Label = null) { |
|
206 | 206 | return self::send($Object, $Label, FirePHP::WARN); |
207 | 207 | } |
208 | 208 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @return true |
216 | 216 | * @throws Exception |
217 | 217 | */ |
218 | - public static function error($Object, $Label=null) { |
|
218 | + public static function error($Object, $Label = null) { |
|
219 | 219 | return self::send($Object, $Label, FirePHP::ERROR); |
220 | 220 | } |
221 | 221 |
@@ -177,6 +177,9 @@ discard block |
||
177 | 177 | return $response; |
178 | 178 | } |
179 | 179 | |
180 | + /** |
|
181 | + * @param string $pathname |
|
182 | + */ |
|
180 | 183 | function ftp_delete($pathname) |
181 | 184 | { |
182 | 185 | $this->ftp_putcmd("DELE", $pathname); |
@@ -187,6 +190,9 @@ discard block |
||
187 | 190 | return $response; |
188 | 191 | } |
189 | 192 | |
193 | + /** |
|
194 | + * @param string $pathname |
|
195 | + */ |
|
190 | 196 | function ftp_rmdir($pathname) |
191 | 197 | { |
192 | 198 | $this->ftp_putcmd("RMD", $pathname); |
@@ -197,6 +203,9 @@ discard block |
||
197 | 203 | return $response; |
198 | 204 | } |
199 | 205 | |
206 | + /** |
|
207 | + * @param string $pathname |
|
208 | + */ |
|
200 | 209 | function ftp_mkdir($pathname) |
201 | 210 | { |
202 | 211 | $this->ftp_putcmd("MKD", $pathname); |
@@ -358,6 +367,10 @@ discard block |
||
358 | 367 | return $response; |
359 | 368 | } |
360 | 369 | |
370 | + /** |
|
371 | + * @param string $remotefile |
|
372 | + * @param string $localfile |
|
373 | + */ |
|
361 | 374 | function ftp_put($remotefile, $localfile, $mode = 1) |
362 | 375 | { |
363 | 376 | |
@@ -408,6 +421,9 @@ discard block |
||
408 | 421 | return $response; |
409 | 422 | } |
410 | 423 | |
424 | + /** |
|
425 | + * @param string $command |
|
426 | + */ |
|
411 | 427 | function ftp_site($command) |
412 | 428 | { |
413 | 429 | $this->ftp_putcmd("SITE", $command); |
@@ -431,6 +447,9 @@ discard block |
||
431 | 447 | |
432 | 448 | /* Private Functions */ |
433 | 449 | |
450 | + /** |
|
451 | + * @param integer $mode |
|
452 | + */ |
|
434 | 453 | function ftp_type($mode) |
435 | 454 | { |
436 | 455 | if ($mode) { |
@@ -468,6 +487,9 @@ discard block |
||
468 | 487 | return $ip_port; |
469 | 488 | } |
470 | 489 | |
490 | + /** |
|
491 | + * @param string $cmd |
|
492 | + */ |
|
471 | 493 | function ftp_putcmd($cmd, $arg = "") |
472 | 494 | { |
473 | 495 | if ($arg != "") { |
@@ -536,6 +558,9 @@ discard block |
||
536 | 558 | return fclose($sock); |
537 | 559 | } |
538 | 560 | |
561 | + /** |
|
562 | + * @param string $ip_port |
|
563 | + */ |
|
539 | 564 | function ftp_open_data_connection($ip_port) |
540 | 565 | { |
541 | 566 | if (!preg_match("@[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+@", $ip_port)) { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /********************************************************************* |
|
2 | + /********************************************************************* |
|
3 | 3 | * |
4 | 4 | * PHP FTP Client Class By TOMO ( [email protected] ) |
5 | 5 | * Modified By NAVER ( [email protected] ) |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * |
19 | 19 | ********************************************************************/ |
20 | 20 | |
21 | - /********************************************************************* |
|
21 | + /********************************************************************* |
|
22 | 22 | * List of available functions |
23 | 23 | * ftp_connect($server, $port = 21) |
24 | 24 | * ftp_login($user, $pass) |
@@ -41,448 +41,448 @@ discard block |
||
41 | 41 | * ftp_quit() |
42 | 42 | *********************************************************************/ |
43 | 43 | |
44 | - class ftp |
|
45 | - { |
|
46 | - /* Public variables */ |
|
47 | - var $debug; |
|
48 | - var $umask; |
|
49 | - var $timeout; |
|
50 | - |
|
51 | - /* Private variables */ |
|
52 | - var $ftp_sock; |
|
53 | - var $ftp_resp; |
|
54 | - |
|
55 | - /* Constractor */ |
|
56 | - function ftp() |
|
57 | - { |
|
58 | - $this->debug = false; |
|
59 | - $this->umask = 0022; |
|
60 | - $this->timeout = 30; |
|
61 | - |
|
62 | - if (!defined("FTP_BINARY")) { |
|
63 | - define("FTP_BINARY", 1); |
|
64 | - } |
|
65 | - if (!defined("FTP_ASCII")) { |
|
66 | - define("FTP_ASCII", 0); |
|
67 | - } |
|
68 | - |
|
69 | - $this->ftp_resp = ""; |
|
70 | - } |
|
71 | - |
|
72 | - /* Public functions */ |
|
73 | - function ftp_connect($server, $port = 21) |
|
74 | - { |
|
75 | - $this->ftp_debug("Trying to ".$server.":".$port." ...\n"); |
|
76 | - $this->ftp_sock = @fsockopen($server, $port, $errno, $errstr, $this->timeout); |
|
77 | - |
|
78 | - if (!$this->ftp_sock || !$this->ftp_ok()) { |
|
79 | - $this->ftp_debug("Error : Cannot connect to remote host \"".$server.":".$port."\"\n"); |
|
80 | - $this->ftp_debug("Error : fsockopen() ".$errstr." (".$errno.")\n"); |
|
81 | - return FALSE; |
|
82 | - } |
|
44 | + class ftp |
|
45 | + { |
|
46 | + /* Public variables */ |
|
47 | + var $debug; |
|
48 | + var $umask; |
|
49 | + var $timeout; |
|
50 | + |
|
51 | + /* Private variables */ |
|
52 | + var $ftp_sock; |
|
53 | + var $ftp_resp; |
|
54 | + |
|
55 | + /* Constractor */ |
|
56 | + function ftp() |
|
57 | + { |
|
58 | + $this->debug = false; |
|
59 | + $this->umask = 0022; |
|
60 | + $this->timeout = 30; |
|
61 | + |
|
62 | + if (!defined("FTP_BINARY")) { |
|
63 | + define("FTP_BINARY", 1); |
|
64 | + } |
|
65 | + if (!defined("FTP_ASCII")) { |
|
66 | + define("FTP_ASCII", 0); |
|
67 | + } |
|
68 | + |
|
69 | + $this->ftp_resp = ""; |
|
70 | + } |
|
71 | + |
|
72 | + /* Public functions */ |
|
73 | + function ftp_connect($server, $port = 21) |
|
74 | + { |
|
75 | + $this->ftp_debug("Trying to ".$server.":".$port." ...\n"); |
|
76 | + $this->ftp_sock = @fsockopen($server, $port, $errno, $errstr, $this->timeout); |
|
77 | + |
|
78 | + if (!$this->ftp_sock || !$this->ftp_ok()) { |
|
79 | + $this->ftp_debug("Error : Cannot connect to remote host \"".$server.":".$port."\"\n"); |
|
80 | + $this->ftp_debug("Error : fsockopen() ".$errstr." (".$errno.")\n"); |
|
81 | + return FALSE; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | if(substr($this->ftp_resp, 0, 3) !== '220') |
85 | 85 | { |
86 | 86 | return FALSE; |
87 | 87 | } |
88 | 88 | |
89 | - $this->ftp_debug("Connected to remote host \"".$server.":".$port."\"\n"); |
|
90 | - |
|
91 | - return TRUE; |
|
92 | - } |
|
93 | - |
|
94 | - function ftp_login($user, $pass) |
|
95 | - { |
|
96 | - $this->ftp_putcmd("USER", $user); |
|
97 | - if (!$this->ftp_ok()) { |
|
98 | - $this->ftp_debug("Error : USER command failed\n"); |
|
99 | - return FALSE; |
|
100 | - } |
|
101 | - |
|
102 | - $this->ftp_putcmd("PASS", $pass); |
|
103 | - if (!$this->ftp_ok()) { |
|
104 | - $this->ftp_debug("Error : PASS command failed\n"); |
|
105 | - return FALSE; |
|
106 | - } |
|
107 | - $this->ftp_debug("Authentication succeeded\n"); |
|
108 | - |
|
109 | - return TRUE; |
|
110 | - } |
|
111 | - |
|
112 | - function ftp_pwd() |
|
113 | - { |
|
114 | - $this->ftp_putcmd("PWD"); |
|
115 | - if (!$this->ftp_ok()) { |
|
116 | - $this->ftp_debug("Error : PWD command failed\n"); |
|
117 | - return FALSE; |
|
118 | - } |
|
119 | - |
|
120 | - return preg_replace("@^[0-9]{3} \"(.+)\" .+\r\n@", "\\1", $this->ftp_resp); |
|
121 | - } |
|
122 | - |
|
123 | - function ftp_size($pathname) |
|
124 | - { |
|
125 | - $this->ftp_putcmd("SIZE", $pathname); |
|
126 | - if (!$this->ftp_ok()) { |
|
127 | - $this->ftp_debug("Error : SIZE command failed\n"); |
|
128 | - return -1; |
|
129 | - } |
|
130 | - |
|
131 | - return preg_replace("@^[0-9]{3} ([0-9]+)\r\n@", "\\1", $this->ftp_resp); |
|
132 | - } |
|
133 | - |
|
134 | - function ftp_mdtm($pathname) |
|
135 | - { |
|
136 | - $this->ftp_putcmd("MDTM", $pathname); |
|
137 | - if (!$this->ftp_ok()) { |
|
138 | - $this->ftp_debug("Error : MDTM command failed\n"); |
|
139 | - return -1; |
|
140 | - } |
|
141 | - $mdtm = preg_replace("@^[0-9]{3} ([0-9]+)\r\n@", "\\1", $this->ftp_resp); |
|
142 | - $date = sscanf($mdtm, "%4d%2d%2d%2d%2d%2d"); |
|
143 | - $timestamp = mktime($date[3], $date[4], $date[5], $date[1], $date[2], $date[0]); |
|
144 | - |
|
145 | - return $timestamp; |
|
146 | - } |
|
147 | - |
|
148 | - function ftp_systype() |
|
149 | - { |
|
150 | - $this->ftp_putcmd("SYST"); |
|
151 | - if (!$this->ftp_ok()) { |
|
152 | - $this->ftp_debug("Error : SYST command failed\n"); |
|
153 | - return FALSE; |
|
154 | - } |
|
155 | - $DATA = explode(" ", $this->ftp_resp); |
|
156 | - |
|
157 | - return $DATA[1]; |
|
158 | - } |
|
159 | - |
|
160 | - function ftp_cdup() |
|
161 | - { |
|
162 | - $this->ftp_putcmd("CDUP"); |
|
163 | - $response = $this->ftp_ok(); |
|
164 | - if (!$response) { |
|
165 | - $this->ftp_debug("Error : CDUP command failed\n"); |
|
166 | - } |
|
167 | - return $response; |
|
168 | - } |
|
169 | - |
|
170 | - function ftp_chdir($pathname) |
|
171 | - { |
|
172 | - $this->ftp_putcmd("CWD", $pathname); |
|
173 | - $response = $this->ftp_ok(); |
|
174 | - if (!$response) { |
|
175 | - $this->ftp_debug("Error : CWD command failed\n"); |
|
176 | - } |
|
177 | - return $response; |
|
178 | - } |
|
179 | - |
|
180 | - function ftp_delete($pathname) |
|
181 | - { |
|
182 | - $this->ftp_putcmd("DELE", $pathname); |
|
183 | - $response = $this->ftp_ok(); |
|
184 | - if (!$response) { |
|
185 | - $this->ftp_debug("Error : DELE command failed\n"); |
|
186 | - } |
|
187 | - return $response; |
|
188 | - } |
|
189 | - |
|
190 | - function ftp_rmdir($pathname) |
|
191 | - { |
|
192 | - $this->ftp_putcmd("RMD", $pathname); |
|
193 | - $response = $this->ftp_ok(); |
|
194 | - if (!$response) { |
|
195 | - $this->ftp_debug("Error : RMD command failed\n"); |
|
196 | - } |
|
197 | - return $response; |
|
198 | - } |
|
199 | - |
|
200 | - function ftp_mkdir($pathname) |
|
201 | - { |
|
202 | - $this->ftp_putcmd("MKD", $pathname); |
|
203 | - $response = $this->ftp_ok(); |
|
204 | - if (!$response) { |
|
205 | - $this->ftp_debug("Error : MKD command failed\n"); |
|
206 | - } |
|
207 | - return $response; |
|
208 | - } |
|
209 | - |
|
210 | - function ftp_file_exists($pathname) |
|
211 | - { |
|
212 | - if (!($remote_list = $this->ftp_nlist("-a"))) { |
|
213 | - $this->ftp_debug("Error : Cannot get remote file list\n"); |
|
214 | - return -1; |
|
215 | - } |
|
89 | + $this->ftp_debug("Connected to remote host \"".$server.":".$port."\"\n"); |
|
90 | + |
|
91 | + return TRUE; |
|
92 | + } |
|
93 | + |
|
94 | + function ftp_login($user, $pass) |
|
95 | + { |
|
96 | + $this->ftp_putcmd("USER", $user); |
|
97 | + if (!$this->ftp_ok()) { |
|
98 | + $this->ftp_debug("Error : USER command failed\n"); |
|
99 | + return FALSE; |
|
100 | + } |
|
101 | + |
|
102 | + $this->ftp_putcmd("PASS", $pass); |
|
103 | + if (!$this->ftp_ok()) { |
|
104 | + $this->ftp_debug("Error : PASS command failed\n"); |
|
105 | + return FALSE; |
|
106 | + } |
|
107 | + $this->ftp_debug("Authentication succeeded\n"); |
|
108 | + |
|
109 | + return TRUE; |
|
110 | + } |
|
111 | + |
|
112 | + function ftp_pwd() |
|
113 | + { |
|
114 | + $this->ftp_putcmd("PWD"); |
|
115 | + if (!$this->ftp_ok()) { |
|
116 | + $this->ftp_debug("Error : PWD command failed\n"); |
|
117 | + return FALSE; |
|
118 | + } |
|
119 | + |
|
120 | + return preg_replace("@^[0-9]{3} \"(.+)\" .+\r\n@", "\\1", $this->ftp_resp); |
|
121 | + } |
|
122 | + |
|
123 | + function ftp_size($pathname) |
|
124 | + { |
|
125 | + $this->ftp_putcmd("SIZE", $pathname); |
|
126 | + if (!$this->ftp_ok()) { |
|
127 | + $this->ftp_debug("Error : SIZE command failed\n"); |
|
128 | + return -1; |
|
129 | + } |
|
130 | + |
|
131 | + return preg_replace("@^[0-9]{3} ([0-9]+)\r\n@", "\\1", $this->ftp_resp); |
|
132 | + } |
|
133 | + |
|
134 | + function ftp_mdtm($pathname) |
|
135 | + { |
|
136 | + $this->ftp_putcmd("MDTM", $pathname); |
|
137 | + if (!$this->ftp_ok()) { |
|
138 | + $this->ftp_debug("Error : MDTM command failed\n"); |
|
139 | + return -1; |
|
140 | + } |
|
141 | + $mdtm = preg_replace("@^[0-9]{3} ([0-9]+)\r\n@", "\\1", $this->ftp_resp); |
|
142 | + $date = sscanf($mdtm, "%4d%2d%2d%2d%2d%2d"); |
|
143 | + $timestamp = mktime($date[3], $date[4], $date[5], $date[1], $date[2], $date[0]); |
|
144 | + |
|
145 | + return $timestamp; |
|
146 | + } |
|
147 | + |
|
148 | + function ftp_systype() |
|
149 | + { |
|
150 | + $this->ftp_putcmd("SYST"); |
|
151 | + if (!$this->ftp_ok()) { |
|
152 | + $this->ftp_debug("Error : SYST command failed\n"); |
|
153 | + return FALSE; |
|
154 | + } |
|
155 | + $DATA = explode(" ", $this->ftp_resp); |
|
156 | + |
|
157 | + return $DATA[1]; |
|
158 | + } |
|
159 | + |
|
160 | + function ftp_cdup() |
|
161 | + { |
|
162 | + $this->ftp_putcmd("CDUP"); |
|
163 | + $response = $this->ftp_ok(); |
|
164 | + if (!$response) { |
|
165 | + $this->ftp_debug("Error : CDUP command failed\n"); |
|
166 | + } |
|
167 | + return $response; |
|
168 | + } |
|
169 | + |
|
170 | + function ftp_chdir($pathname) |
|
171 | + { |
|
172 | + $this->ftp_putcmd("CWD", $pathname); |
|
173 | + $response = $this->ftp_ok(); |
|
174 | + if (!$response) { |
|
175 | + $this->ftp_debug("Error : CWD command failed\n"); |
|
176 | + } |
|
177 | + return $response; |
|
178 | + } |
|
179 | + |
|
180 | + function ftp_delete($pathname) |
|
181 | + { |
|
182 | + $this->ftp_putcmd("DELE", $pathname); |
|
183 | + $response = $this->ftp_ok(); |
|
184 | + if (!$response) { |
|
185 | + $this->ftp_debug("Error : DELE command failed\n"); |
|
186 | + } |
|
187 | + return $response; |
|
188 | + } |
|
189 | + |
|
190 | + function ftp_rmdir($pathname) |
|
191 | + { |
|
192 | + $this->ftp_putcmd("RMD", $pathname); |
|
193 | + $response = $this->ftp_ok(); |
|
194 | + if (!$response) { |
|
195 | + $this->ftp_debug("Error : RMD command failed\n"); |
|
196 | + } |
|
197 | + return $response; |
|
198 | + } |
|
199 | + |
|
200 | + function ftp_mkdir($pathname) |
|
201 | + { |
|
202 | + $this->ftp_putcmd("MKD", $pathname); |
|
203 | + $response = $this->ftp_ok(); |
|
204 | + if (!$response) { |
|
205 | + $this->ftp_debug("Error : MKD command failed\n"); |
|
206 | + } |
|
207 | + return $response; |
|
208 | + } |
|
209 | + |
|
210 | + function ftp_file_exists($pathname) |
|
211 | + { |
|
212 | + if (!($remote_list = $this->ftp_nlist("-a"))) { |
|
213 | + $this->ftp_debug("Error : Cannot get remote file list\n"); |
|
214 | + return -1; |
|
215 | + } |
|
216 | 216 | |
217 | - reset($remote_list); |
|
218 | - while (list(,$value) = each($remote_list)) { |
|
219 | - if ($value == $pathname) { |
|
220 | - $this->ftp_debug("Remote file ".$pathname." exists\n"); |
|
221 | - return 1; |
|
222 | - } |
|
223 | - } |
|
224 | - $this->ftp_debug("Remote file ".$pathname." does not exist\n"); |
|
225 | - |
|
226 | - return 0; |
|
227 | - } |
|
228 | - |
|
229 | - function ftp_rename($from, $to) |
|
230 | - { |
|
231 | - $this->ftp_putcmd("RNFR", $from); |
|
232 | - if (!$this->ftp_ok()) { |
|
233 | - $this->ftp_debug("Error : RNFR command failed\n"); |
|
234 | - return FALSE; |
|
235 | - } |
|
236 | - $this->ftp_putcmd("RNTO", $to); |
|
237 | - |
|
238 | - $response = $this->ftp_ok(); |
|
239 | - if (!$response) { |
|
240 | - $this->ftp_debug("Error : RNTO command failed\n"); |
|
241 | - } |
|
242 | - return $response; |
|
243 | - } |
|
244 | - |
|
245 | - function ftp_nlist($arg = "", $pathname = "") |
|
246 | - { |
|
247 | - if (!($string = $this->ftp_pasv())) { |
|
248 | - return FALSE; |
|
249 | - } |
|
250 | - |
|
251 | - if ($arg == "") { |
|
252 | - $nlst = "NLST"; |
|
253 | - } else { |
|
254 | - $nlst = "NLST ".$arg; |
|
255 | - } |
|
256 | - $this->ftp_putcmd($nlst, $pathname); |
|
257 | - |
|
258 | - $sock_data = $this->ftp_open_data_connection($string); |
|
259 | - if (!$sock_data || !$this->ftp_ok()) { |
|
260 | - $this->ftp_debug("Error : Cannot connect to remote host\n"); |
|
261 | - $this->ftp_debug("Error : NLST command failed\n"); |
|
262 | - return FALSE; |
|
263 | - } |
|
264 | - $this->ftp_debug("Connected to remote host\n"); |
|
217 | + reset($remote_list); |
|
218 | + while (list(,$value) = each($remote_list)) { |
|
219 | + if ($value == $pathname) { |
|
220 | + $this->ftp_debug("Remote file ".$pathname." exists\n"); |
|
221 | + return 1; |
|
222 | + } |
|
223 | + } |
|
224 | + $this->ftp_debug("Remote file ".$pathname." does not exist\n"); |
|
225 | + |
|
226 | + return 0; |
|
227 | + } |
|
228 | + |
|
229 | + function ftp_rename($from, $to) |
|
230 | + { |
|
231 | + $this->ftp_putcmd("RNFR", $from); |
|
232 | + if (!$this->ftp_ok()) { |
|
233 | + $this->ftp_debug("Error : RNFR command failed\n"); |
|
234 | + return FALSE; |
|
235 | + } |
|
236 | + $this->ftp_putcmd("RNTO", $to); |
|
237 | + |
|
238 | + $response = $this->ftp_ok(); |
|
239 | + if (!$response) { |
|
240 | + $this->ftp_debug("Error : RNTO command failed\n"); |
|
241 | + } |
|
242 | + return $response; |
|
243 | + } |
|
244 | + |
|
245 | + function ftp_nlist($arg = "", $pathname = "") |
|
246 | + { |
|
247 | + if (!($string = $this->ftp_pasv())) { |
|
248 | + return FALSE; |
|
249 | + } |
|
250 | + |
|
251 | + if ($arg == "") { |
|
252 | + $nlst = "NLST"; |
|
253 | + } else { |
|
254 | + $nlst = "NLST ".$arg; |
|
255 | + } |
|
256 | + $this->ftp_putcmd($nlst, $pathname); |
|
257 | + |
|
258 | + $sock_data = $this->ftp_open_data_connection($string); |
|
259 | + if (!$sock_data || !$this->ftp_ok()) { |
|
260 | + $this->ftp_debug("Error : Cannot connect to remote host\n"); |
|
261 | + $this->ftp_debug("Error : NLST command failed\n"); |
|
262 | + return FALSE; |
|
263 | + } |
|
264 | + $this->ftp_debug("Connected to remote host\n"); |
|
265 | 265 | |
266 | 266 | $list = array(); |
267 | - while (!feof($sock_data)) { |
|
268 | - $list[] = preg_replace("@[\r\n]@", "", fgets($sock_data, 512)); |
|
269 | - } |
|
270 | - $this->ftp_close_data_connection($sock_data); |
|
271 | - $this->ftp_debug(implode("\n", $list)); |
|
272 | - |
|
273 | - if (!$this->ftp_ok()) { |
|
274 | - $this->ftp_debug("Error : NLST command failed\n"); |
|
275 | - return FALSE; |
|
276 | - } |
|
277 | - |
|
278 | - return $list; |
|
279 | - } |
|
280 | - |
|
281 | - function ftp_rawlist($pathname = "") |
|
282 | - { |
|
283 | - if (!($string = $this->ftp_pasv())) { |
|
284 | - return FALSE; |
|
285 | - } |
|
286 | - |
|
287 | - $this->ftp_putcmd("LIST", $pathname); |
|
288 | - |
|
289 | - $sock_data = $this->ftp_open_data_connection($string); |
|
290 | - if (!$sock_data || !$this->ftp_ok()) { |
|
291 | - $this->ftp_debug("Error : Cannot connect to remote host\n"); |
|
292 | - $this->ftp_debug("Error : LIST command failed\n"); |
|
293 | - return FALSE; |
|
294 | - } |
|
295 | - |
|
296 | - $this->ftp_debug("Connected to remote host\n"); |
|
297 | - |
|
298 | - while (!feof($sock_data)) { |
|
299 | - $list[] = preg_replace("@[\r\n]@", "", fgets($sock_data, 512)); |
|
300 | - } |
|
301 | - $this->ftp_debug(implode("\n", $list)); |
|
302 | - $this->ftp_close_data_connection($sock_data); |
|
303 | - |
|
304 | - if (!$this->ftp_ok()) { |
|
305 | - $this->ftp_debug("Error : LIST command failed\n"); |
|
306 | - return FALSE; |
|
307 | - } |
|
308 | - |
|
309 | - return $list; |
|
310 | - } |
|
311 | - |
|
312 | - function ftp_get($localfile, $remotefile, $mode = 1) |
|
313 | - { |
|
314 | - umask($this->umask); |
|
315 | - |
|
316 | - if (@file_exists($localfile)) { |
|
317 | - $this->ftp_debug("Warning : local file will be overwritten\n"); |
|
318 | - } |
|
319 | - |
|
320 | - $fp = @fopen($localfile, "w"); |
|
321 | - if (!$fp) { |
|
322 | - $this->ftp_debug("Error : Cannot create \"".$localfile."\""); |
|
323 | - $this->ftp_debug("Error : GET command failed\n"); |
|
324 | - return FALSE; |
|
325 | - } |
|
326 | - |
|
327 | - if (!$this->ftp_type($mode)) { |
|
328 | - $this->ftp_debug("Error : GET command failed\n"); |
|
329 | - return FALSE; |
|
330 | - } |
|
331 | - |
|
332 | - if (!($string = $this->ftp_pasv())) { |
|
333 | - $this->ftp_debug("Error : GET command failed\n"); |
|
334 | - return FALSE; |
|
335 | - } |
|
336 | - |
|
337 | - $this->ftp_putcmd("RETR", $remotefile); |
|
338 | - |
|
339 | - $sock_data = $this->ftp_open_data_connection($string); |
|
340 | - if (!$sock_data || !$this->ftp_ok()) { |
|
341 | - $this->ftp_debug("Error : Cannot connect to remote host\n"); |
|
342 | - $this->ftp_debug("Error : GET command failed\n"); |
|
343 | - return FALSE; |
|
344 | - } |
|
345 | - $this->ftp_debug("Connected to remote host\n"); |
|
346 | - $this->ftp_debug("Retrieving remote file \"".$remotefile."\" to local file \"".$localfile."\"\n"); |
|
347 | - while (!feof($sock_data)) { |
|
348 | - fputs($fp, fread($sock_data, 4096)); |
|
349 | - } |
|
350 | - fclose($fp); |
|
351 | - |
|
352 | - $this->ftp_close_data_connection($sock_data); |
|
353 | - |
|
354 | - $response = $this->ftp_ok(); |
|
355 | - if (!$response) { |
|
356 | - $this->ftp_debug("Error : GET command failed\n"); |
|
357 | - } |
|
358 | - return $response; |
|
359 | - } |
|
360 | - |
|
361 | - function ftp_put($remotefile, $localfile, $mode = 1) |
|
362 | - { |
|
267 | + while (!feof($sock_data)) { |
|
268 | + $list[] = preg_replace("@[\r\n]@", "", fgets($sock_data, 512)); |
|
269 | + } |
|
270 | + $this->ftp_close_data_connection($sock_data); |
|
271 | + $this->ftp_debug(implode("\n", $list)); |
|
272 | + |
|
273 | + if (!$this->ftp_ok()) { |
|
274 | + $this->ftp_debug("Error : NLST command failed\n"); |
|
275 | + return FALSE; |
|
276 | + } |
|
277 | + |
|
278 | + return $list; |
|
279 | + } |
|
280 | + |
|
281 | + function ftp_rawlist($pathname = "") |
|
282 | + { |
|
283 | + if (!($string = $this->ftp_pasv())) { |
|
284 | + return FALSE; |
|
285 | + } |
|
286 | + |
|
287 | + $this->ftp_putcmd("LIST", $pathname); |
|
288 | + |
|
289 | + $sock_data = $this->ftp_open_data_connection($string); |
|
290 | + if (!$sock_data || !$this->ftp_ok()) { |
|
291 | + $this->ftp_debug("Error : Cannot connect to remote host\n"); |
|
292 | + $this->ftp_debug("Error : LIST command failed\n"); |
|
293 | + return FALSE; |
|
294 | + } |
|
295 | + |
|
296 | + $this->ftp_debug("Connected to remote host\n"); |
|
297 | + |
|
298 | + while (!feof($sock_data)) { |
|
299 | + $list[] = preg_replace("@[\r\n]@", "", fgets($sock_data, 512)); |
|
300 | + } |
|
301 | + $this->ftp_debug(implode("\n", $list)); |
|
302 | + $this->ftp_close_data_connection($sock_data); |
|
303 | + |
|
304 | + if (!$this->ftp_ok()) { |
|
305 | + $this->ftp_debug("Error : LIST command failed\n"); |
|
306 | + return FALSE; |
|
307 | + } |
|
308 | + |
|
309 | + return $list; |
|
310 | + } |
|
311 | + |
|
312 | + function ftp_get($localfile, $remotefile, $mode = 1) |
|
313 | + { |
|
314 | + umask($this->umask); |
|
315 | + |
|
316 | + if (@file_exists($localfile)) { |
|
317 | + $this->ftp_debug("Warning : local file will be overwritten\n"); |
|
318 | + } |
|
319 | + |
|
320 | + $fp = @fopen($localfile, "w"); |
|
321 | + if (!$fp) { |
|
322 | + $this->ftp_debug("Error : Cannot create \"".$localfile."\""); |
|
323 | + $this->ftp_debug("Error : GET command failed\n"); |
|
324 | + return FALSE; |
|
325 | + } |
|
326 | + |
|
327 | + if (!$this->ftp_type($mode)) { |
|
328 | + $this->ftp_debug("Error : GET command failed\n"); |
|
329 | + return FALSE; |
|
330 | + } |
|
331 | + |
|
332 | + if (!($string = $this->ftp_pasv())) { |
|
333 | + $this->ftp_debug("Error : GET command failed\n"); |
|
334 | + return FALSE; |
|
335 | + } |
|
336 | + |
|
337 | + $this->ftp_putcmd("RETR", $remotefile); |
|
338 | + |
|
339 | + $sock_data = $this->ftp_open_data_connection($string); |
|
340 | + if (!$sock_data || !$this->ftp_ok()) { |
|
341 | + $this->ftp_debug("Error : Cannot connect to remote host\n"); |
|
342 | + $this->ftp_debug("Error : GET command failed\n"); |
|
343 | + return FALSE; |
|
344 | + } |
|
345 | + $this->ftp_debug("Connected to remote host\n"); |
|
346 | + $this->ftp_debug("Retrieving remote file \"".$remotefile."\" to local file \"".$localfile."\"\n"); |
|
347 | + while (!feof($sock_data)) { |
|
348 | + fputs($fp, fread($sock_data, 4096)); |
|
349 | + } |
|
350 | + fclose($fp); |
|
351 | + |
|
352 | + $this->ftp_close_data_connection($sock_data); |
|
353 | + |
|
354 | + $response = $this->ftp_ok(); |
|
355 | + if (!$response) { |
|
356 | + $this->ftp_debug("Error : GET command failed\n"); |
|
357 | + } |
|
358 | + return $response; |
|
359 | + } |
|
360 | + |
|
361 | + function ftp_put($remotefile, $localfile, $mode = 1) |
|
362 | + { |
|
363 | 363 | |
364 | - if (!@file_exists($localfile)) { |
|
365 | - $this->ftp_debug("Error : No such file or directory \"".$localfile."\"\n"); |
|
366 | - $this->ftp_debug("Error : PUT command failed\n"); |
|
367 | - return FALSE; |
|
368 | - } |
|
369 | - |
|
370 | - $fp = @fopen($localfile, "r"); |
|
371 | - if (!$fp) { |
|
372 | - $this->ftp_debug("Error : Cannot read file \"".$localfile."\"\n"); |
|
373 | - $this->ftp_debug("Error : PUT command failed\n"); |
|
374 | - return FALSE; |
|
375 | - } |
|
376 | - |
|
377 | - if (!$this->ftp_type($mode)) { |
|
378 | - $this->ftp_debug("Error : PUT command failed\n"); |
|
379 | - return FALSE; |
|
380 | - } |
|
381 | - |
|
382 | - if (!($string = $this->ftp_pasv())) { |
|
383 | - $this->ftp_debug("Error : PUT command failed\n"); |
|
384 | - return FALSE; |
|
385 | - } |
|
386 | - |
|
387 | - $this->ftp_putcmd("STOR", $remotefile); |
|
388 | - |
|
389 | - $sock_data = $this->ftp_open_data_connection($string); |
|
390 | - if (!$sock_data || !$this->ftp_ok()) { |
|
391 | - $this->ftp_debug("Error : Cannot connect to remote host\n"); |
|
392 | - $this->ftp_debug("Error : PUT command failed\n"); |
|
393 | - return FALSE; |
|
394 | - } |
|
395 | - $this->ftp_debug("Connected to remote host\n"); |
|
396 | - $this->ftp_debug("Storing local file \"".$localfile."\" to remote file \"".$remotefile."\"\n"); |
|
397 | - while (!feof($fp)) { |
|
398 | - fputs($sock_data, fread($fp, 4096)); |
|
399 | - } |
|
400 | - fclose($fp); |
|
401 | - |
|
402 | - $this->ftp_close_data_connection($sock_data); |
|
403 | - |
|
404 | - $response = $this->ftp_ok(); |
|
405 | - if (!$response) { |
|
406 | - $this->ftp_debug("Error : PUT command failed\n"); |
|
407 | - } |
|
408 | - return $response; |
|
409 | - } |
|
410 | - |
|
411 | - function ftp_site($command) |
|
412 | - { |
|
413 | - $this->ftp_putcmd("SITE", $command); |
|
414 | - $response = $this->ftp_ok(); |
|
415 | - if (!$response) { |
|
416 | - $this->ftp_debug("Error : SITE command failed\n"); |
|
417 | - } |
|
418 | - return $response; |
|
419 | - } |
|
420 | - |
|
421 | - function ftp_quit() |
|
422 | - { |
|
423 | - $this->ftp_putcmd("QUIT"); |
|
424 | - if (!$this->ftp_ok() || !fclose($this->ftp_sock)) { |
|
425 | - $this->ftp_debug("Error : QUIT command failed\n"); |
|
426 | - return FALSE; |
|
427 | - } |
|
428 | - $this->ftp_debug("Disconnected from remote host\n"); |
|
429 | - return TRUE; |
|
430 | - } |
|
431 | - |
|
432 | - /* Private Functions */ |
|
433 | - |
|
434 | - function ftp_type($mode) |
|
435 | - { |
|
436 | - if ($mode) { |
|
437 | - $type = "I"; //Binary mode |
|
438 | - } else { |
|
439 | - $type = "A"; //ASCII mode |
|
440 | - } |
|
441 | - $this->ftp_putcmd("TYPE", $type); |
|
442 | - $response = $this->ftp_ok(); |
|
443 | - if (!$response) { |
|
444 | - $this->ftp_debug("Error : TYPE command failed\n"); |
|
445 | - } |
|
446 | - return $response; |
|
447 | - } |
|
448 | - |
|
449 | - function ftp_port($ip_port) |
|
450 | - { |
|
451 | - $this->ftp_putcmd("PORT", $ip_port); |
|
452 | - $response = $this->ftp_ok(); |
|
453 | - if (!$response) { |
|
454 | - $this->ftp_debug("Error : PORT command failed\n"); |
|
455 | - } |
|
456 | - return $response; |
|
457 | - } |
|
458 | - |
|
459 | - function ftp_pasv() |
|
460 | - { |
|
461 | - $this->ftp_putcmd("PASV"); |
|
462 | - if (!$this->ftp_ok()) { |
|
463 | - $this->ftp_debug("Error : PASV command failed\n"); |
|
464 | - return FALSE; |
|
465 | - } |
|
466 | - |
|
467 | - $ip_port = preg_replace("@^.+ \\(?([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+)\\)?.*\r\n$@", "\\1", $this->ftp_resp); |
|
468 | - return $ip_port; |
|
469 | - } |
|
470 | - |
|
471 | - function ftp_putcmd($cmd, $arg = "") |
|
472 | - { |
|
473 | - if ($arg != "") { |
|
474 | - $cmd = $cmd." ".$arg; |
|
475 | - } |
|
476 | - |
|
477 | - fputs($this->ftp_sock, $cmd."\r\n"); |
|
478 | - $this->ftp_debug("> ".$cmd."\n"); |
|
479 | - |
|
480 | - return TRUE; |
|
481 | - } |
|
482 | - |
|
483 | - function ftp_ok() |
|
484 | - { |
|
485 | - $this->ftp_resp = ""; |
|
364 | + if (!@file_exists($localfile)) { |
|
365 | + $this->ftp_debug("Error : No such file or directory \"".$localfile."\"\n"); |
|
366 | + $this->ftp_debug("Error : PUT command failed\n"); |
|
367 | + return FALSE; |
|
368 | + } |
|
369 | + |
|
370 | + $fp = @fopen($localfile, "r"); |
|
371 | + if (!$fp) { |
|
372 | + $this->ftp_debug("Error : Cannot read file \"".$localfile."\"\n"); |
|
373 | + $this->ftp_debug("Error : PUT command failed\n"); |
|
374 | + return FALSE; |
|
375 | + } |
|
376 | + |
|
377 | + if (!$this->ftp_type($mode)) { |
|
378 | + $this->ftp_debug("Error : PUT command failed\n"); |
|
379 | + return FALSE; |
|
380 | + } |
|
381 | + |
|
382 | + if (!($string = $this->ftp_pasv())) { |
|
383 | + $this->ftp_debug("Error : PUT command failed\n"); |
|
384 | + return FALSE; |
|
385 | + } |
|
386 | + |
|
387 | + $this->ftp_putcmd("STOR", $remotefile); |
|
388 | + |
|
389 | + $sock_data = $this->ftp_open_data_connection($string); |
|
390 | + if (!$sock_data || !$this->ftp_ok()) { |
|
391 | + $this->ftp_debug("Error : Cannot connect to remote host\n"); |
|
392 | + $this->ftp_debug("Error : PUT command failed\n"); |
|
393 | + return FALSE; |
|
394 | + } |
|
395 | + $this->ftp_debug("Connected to remote host\n"); |
|
396 | + $this->ftp_debug("Storing local file \"".$localfile."\" to remote file \"".$remotefile."\"\n"); |
|
397 | + while (!feof($fp)) { |
|
398 | + fputs($sock_data, fread($fp, 4096)); |
|
399 | + } |
|
400 | + fclose($fp); |
|
401 | + |
|
402 | + $this->ftp_close_data_connection($sock_data); |
|
403 | + |
|
404 | + $response = $this->ftp_ok(); |
|
405 | + if (!$response) { |
|
406 | + $this->ftp_debug("Error : PUT command failed\n"); |
|
407 | + } |
|
408 | + return $response; |
|
409 | + } |
|
410 | + |
|
411 | + function ftp_site($command) |
|
412 | + { |
|
413 | + $this->ftp_putcmd("SITE", $command); |
|
414 | + $response = $this->ftp_ok(); |
|
415 | + if (!$response) { |
|
416 | + $this->ftp_debug("Error : SITE command failed\n"); |
|
417 | + } |
|
418 | + return $response; |
|
419 | + } |
|
420 | + |
|
421 | + function ftp_quit() |
|
422 | + { |
|
423 | + $this->ftp_putcmd("QUIT"); |
|
424 | + if (!$this->ftp_ok() || !fclose($this->ftp_sock)) { |
|
425 | + $this->ftp_debug("Error : QUIT command failed\n"); |
|
426 | + return FALSE; |
|
427 | + } |
|
428 | + $this->ftp_debug("Disconnected from remote host\n"); |
|
429 | + return TRUE; |
|
430 | + } |
|
431 | + |
|
432 | + /* Private Functions */ |
|
433 | + |
|
434 | + function ftp_type($mode) |
|
435 | + { |
|
436 | + if ($mode) { |
|
437 | + $type = "I"; //Binary mode |
|
438 | + } else { |
|
439 | + $type = "A"; //ASCII mode |
|
440 | + } |
|
441 | + $this->ftp_putcmd("TYPE", $type); |
|
442 | + $response = $this->ftp_ok(); |
|
443 | + if (!$response) { |
|
444 | + $this->ftp_debug("Error : TYPE command failed\n"); |
|
445 | + } |
|
446 | + return $response; |
|
447 | + } |
|
448 | + |
|
449 | + function ftp_port($ip_port) |
|
450 | + { |
|
451 | + $this->ftp_putcmd("PORT", $ip_port); |
|
452 | + $response = $this->ftp_ok(); |
|
453 | + if (!$response) { |
|
454 | + $this->ftp_debug("Error : PORT command failed\n"); |
|
455 | + } |
|
456 | + return $response; |
|
457 | + } |
|
458 | + |
|
459 | + function ftp_pasv() |
|
460 | + { |
|
461 | + $this->ftp_putcmd("PASV"); |
|
462 | + if (!$this->ftp_ok()) { |
|
463 | + $this->ftp_debug("Error : PASV command failed\n"); |
|
464 | + return FALSE; |
|
465 | + } |
|
466 | + |
|
467 | + $ip_port = preg_replace("@^.+ \\(?([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+)\\)?.*\r\n$@", "\\1", $this->ftp_resp); |
|
468 | + return $ip_port; |
|
469 | + } |
|
470 | + |
|
471 | + function ftp_putcmd($cmd, $arg = "") |
|
472 | + { |
|
473 | + if ($arg != "") { |
|
474 | + $cmd = $cmd." ".$arg; |
|
475 | + } |
|
476 | + |
|
477 | + fputs($this->ftp_sock, $cmd."\r\n"); |
|
478 | + $this->ftp_debug("> ".$cmd."\n"); |
|
479 | + |
|
480 | + return TRUE; |
|
481 | + } |
|
482 | + |
|
483 | + function ftp_ok() |
|
484 | + { |
|
485 | + $this->ftp_resp = ""; |
|
486 | 486 | |
487 | 487 | // 한줄을 읽는다. |
488 | 488 | $line = ''; |
@@ -521,49 +521,49 @@ discard block |
||
521 | 521 | }while($line); |
522 | 522 | } |
523 | 523 | |
524 | - $this->ftp_debug(str_replace("\r\n", "\n", $this->ftp_resp)); |
|
525 | - |
|
526 | - if (!preg_match("@^[123]@", $this->ftp_resp)) { |
|
527 | - return FALSE; |
|
528 | - } |
|
529 | - |
|
530 | - return TRUE; |
|
531 | - } |
|
532 | - |
|
533 | - function ftp_close_data_connection($sock) |
|
534 | - { |
|
535 | - $this->ftp_debug("Disconnected from remote host\n"); |
|
536 | - return fclose($sock); |
|
537 | - } |
|
538 | - |
|
539 | - function ftp_open_data_connection($ip_port) |
|
540 | - { |
|
541 | - if (!preg_match("@[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+@", $ip_port)) { |
|
542 | - $this->ftp_debug("Error : Illegal ip-port format(".$ip_port.")\n"); |
|
543 | - return FALSE; |
|
544 | - } |
|
545 | - |
|
546 | - $DATA = explode(",", $ip_port); |
|
547 | - $ipaddr = $DATA[0].".".$DATA[1].".".$DATA[2].".".$DATA[3]; |
|
548 | - $port = $DATA[4]*256 + $DATA[5]; |
|
549 | - $this->ftp_debug("Trying to ".$ipaddr.":".$port." ...\n"); |
|
550 | - $data_connection = @fsockopen($ipaddr, $port, $errno, $errstr); |
|
551 | - if (!$data_connection) { |
|
552 | - $this->ftp_debug("Error : Cannot open data connection to ".$ipaddr.":".$port."\n"); |
|
553 | - $this->ftp_debug("Error : ".$errstr." (".$errno.")\n"); |
|
554 | - return FALSE; |
|
555 | - } |
|
556 | - |
|
557 | - return $data_connection; |
|
558 | - } |
|
559 | - |
|
560 | - function ftp_debug($message = "") |
|
561 | - { |
|
562 | - if ($this->debug) { |
|
563 | - echo $message; |
|
564 | - } |
|
565 | - |
|
566 | - return TRUE; |
|
567 | - } |
|
568 | - } |
|
524 | + $this->ftp_debug(str_replace("\r\n", "\n", $this->ftp_resp)); |
|
525 | + |
|
526 | + if (!preg_match("@^[123]@", $this->ftp_resp)) { |
|
527 | + return FALSE; |
|
528 | + } |
|
529 | + |
|
530 | + return TRUE; |
|
531 | + } |
|
532 | + |
|
533 | + function ftp_close_data_connection($sock) |
|
534 | + { |
|
535 | + $this->ftp_debug("Disconnected from remote host\n"); |
|
536 | + return fclose($sock); |
|
537 | + } |
|
538 | + |
|
539 | + function ftp_open_data_connection($ip_port) |
|
540 | + { |
|
541 | + if (!preg_match("@[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+@", $ip_port)) { |
|
542 | + $this->ftp_debug("Error : Illegal ip-port format(".$ip_port.")\n"); |
|
543 | + return FALSE; |
|
544 | + } |
|
545 | + |
|
546 | + $DATA = explode(",", $ip_port); |
|
547 | + $ipaddr = $DATA[0].".".$DATA[1].".".$DATA[2].".".$DATA[3]; |
|
548 | + $port = $DATA[4]*256 + $DATA[5]; |
|
549 | + $this->ftp_debug("Trying to ".$ipaddr.":".$port." ...\n"); |
|
550 | + $data_connection = @fsockopen($ipaddr, $port, $errno, $errstr); |
|
551 | + if (!$data_connection) { |
|
552 | + $this->ftp_debug("Error : Cannot open data connection to ".$ipaddr.":".$port."\n"); |
|
553 | + $this->ftp_debug("Error : ".$errstr." (".$errno.")\n"); |
|
554 | + return FALSE; |
|
555 | + } |
|
556 | + |
|
557 | + return $data_connection; |
|
558 | + } |
|
559 | + |
|
560 | + function ftp_debug($message = "") |
|
561 | + { |
|
562 | + if ($this->debug) { |
|
563 | + echo $message; |
|
564 | + } |
|
565 | + |
|
566 | + return TRUE; |
|
567 | + } |
|
568 | + } |
|
569 | 569 | ?> |
@@ -489,7 +489,9 @@ discard block |
||
489 | 489 | while(($char = fgetc($this->ftp_sock)) !== FALSE) |
490 | 490 | { |
491 | 491 | $line .= $char; |
492 | - if($char === "\n") break; |
|
492 | + if($char === "\n") { |
|
493 | + break; |
|
494 | + } |
|
493 | 495 | } |
494 | 496 | |
495 | 497 | // 세자리 응답 코드가 나와야 한다. |
@@ -512,12 +514,16 @@ discard block |
||
512 | 514 | while(($char = fgetc($this->ftp_sock)) !== FALSE) |
513 | 515 | { |
514 | 516 | $line .= $char; |
515 | - if($char === "\n") break; |
|
517 | + if($char === "\n") { |
|
518 | + break; |
|
519 | + } |
|
516 | 520 | } |
517 | 521 | $this->ftp_resp .= $line; |
518 | 522 | |
519 | 523 | // 응답 코드와 같은 코드가 나오고 공백이 있으면 끝 |
520 | - if($code . ' ' === substr($line, 0, 4)) break; |
|
524 | + if($code . ' ' === substr($line, 0, 4)) { |
|
525 | + break; |
|
526 | + } |
|
521 | 527 | }while($line); |
522 | 528 | } |
523 | 529 |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | return FALSE; |
82 | 82 | } |
83 | 83 | |
84 | - if(substr($this->ftp_resp, 0, 3) !== '220') |
|
84 | + if (substr($this->ftp_resp, 0, 3) !== '220') |
|
85 | 85 | { |
86 | 86 | return FALSE; |
87 | 87 | } |
@@ -486,14 +486,14 @@ discard block |
||
486 | 486 | |
487 | 487 | // 한줄을 읽는다. |
488 | 488 | $line = ''; |
489 | - while(($char = fgetc($this->ftp_sock)) !== FALSE) |
|
489 | + while (($char = fgetc($this->ftp_sock)) !== FALSE) |
|
490 | 490 | { |
491 | 491 | $line .= $char; |
492 | - if($char === "\n") break; |
|
492 | + if ($char === "\n") break; |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | // 세자리 응답 코드가 나와야 한다. |
496 | - if(!preg_match('@^[0-9]{3}@', $line)) |
|
496 | + if (!preg_match('@^[0-9]{3}@', $line)) |
|
497 | 497 | { |
498 | 498 | return FALSE; |
499 | 499 | } |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | $this->ftp_resp = $line; |
502 | 502 | |
503 | 503 | // 4번째 문자가 -이면 여러줄인 응답이다. |
504 | - if($line[3] === '-') |
|
504 | + if ($line[3] === '-') |
|
505 | 505 | { |
506 | 506 | $code = substr($line, 0, 3); |
507 | 507 | |
@@ -509,16 +509,16 @@ discard block |
||
509 | 509 | do |
510 | 510 | { |
511 | 511 | $line = ''; |
512 | - while(($char = fgetc($this->ftp_sock)) !== FALSE) |
|
512 | + while (($char = fgetc($this->ftp_sock)) !== FALSE) |
|
513 | 513 | { |
514 | 514 | $line .= $char; |
515 | - if($char === "\n") break; |
|
515 | + if ($char === "\n") break; |
|
516 | 516 | } |
517 | 517 | $this->ftp_resp .= $line; |
518 | 518 | |
519 | 519 | // 응답 코드와 같은 코드가 나오고 공백이 있으면 끝 |
520 | - if($code . ' ' === substr($line, 0, 4)) break; |
|
521 | - }while($line); |
|
520 | + if ($code.' ' === substr($line, 0, 4)) break; |
|
521 | + } while ($line); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | $this->ftp_debug(str_replace("\r\n", "\n", $this->ftp_resp)); |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | |
546 | 546 | $DATA = explode(",", $ip_port); |
547 | 547 | $ipaddr = $DATA[0].".".$DATA[1].".".$DATA[2].".".$DATA[3]; |
548 | - $port = $DATA[4]*256 + $DATA[5]; |
|
548 | + $port = $DATA[4] * 256 + $DATA[5]; |
|
549 | 549 | $this->ftp_debug("Trying to ".$ipaddr.":".$port." ...\n"); |
550 | 550 | $data_connection = @fsockopen($ipaddr, $port, $errno, $errstr); |
551 | 551 | if (!$data_connection) { |