@@ -59,11 +59,11 @@ |
||
59 | 59 | function getArguments() |
60 | 60 | { |
61 | 61 | $args = array(); |
62 | - if(is_a($this->column_name, 'Argument')) |
|
62 | + if (is_a($this->column_name, 'Argument')) |
|
63 | 63 | { |
64 | 64 | $args[] = $this->column_name; |
65 | 65 | } |
66 | - if(is_a($this->sort_order, 'Argument')) |
|
66 | + if (is_a($this->sort_order, 'Argument')) |
|
67 | 67 | { |
68 | 68 | $args[] = $this->sort_order; |
69 | 69 | } |
@@ -53,12 +53,10 @@ |
||
53 | 53 | if($index_hint_type == 'USE') |
54 | 54 | { |
55 | 55 | $use_index_hint .= $index_hint->getIndexName() . ', '; |
56 | - } |
|
57 | - else if($index_hint_type == 'FORCE') |
|
56 | + } else if($index_hint_type == 'FORCE') |
|
58 | 57 | { |
59 | 58 | $force_index_hint .= $index_hint->getIndexName() . ', '; |
60 | - } |
|
61 | - else if($index_hint_type == 'IGNORE') |
|
59 | + } else if($index_hint_type == 'IGNORE') |
|
62 | 60 | { |
63 | 61 | $ignore_index_hint .= $index_hint->getIndexName() . ', '; |
64 | 62 | } |
@@ -47,33 +47,33 @@ |
||
47 | 47 | $use_index_hint = ''; |
48 | 48 | $force_index_hint = ''; |
49 | 49 | $ignore_index_hint = ''; |
50 | - foreach($this->index_hints_list as $index_hint) |
|
50 | + foreach ($this->index_hints_list as $index_hint) |
|
51 | 51 | { |
52 | 52 | $index_hint_type = $index_hint->getIndexHintType(); |
53 | - if($index_hint_type == 'USE') |
|
53 | + if ($index_hint_type == 'USE') |
|
54 | 54 | { |
55 | - $use_index_hint .= $index_hint->getIndexName() . ', '; |
|
55 | + $use_index_hint .= $index_hint->getIndexName().', '; |
|
56 | 56 | } |
57 | - else if($index_hint_type == 'FORCE') |
|
57 | + else if ($index_hint_type == 'FORCE') |
|
58 | 58 | { |
59 | - $force_index_hint .= $index_hint->getIndexName() . ', '; |
|
59 | + $force_index_hint .= $index_hint->getIndexName().', '; |
|
60 | 60 | } |
61 | - else if($index_hint_type == 'IGNORE') |
|
61 | + else if ($index_hint_type == 'IGNORE') |
|
62 | 62 | { |
63 | - $ignore_index_hint .= $index_hint->getIndexName() . ', '; |
|
63 | + $ignore_index_hint .= $index_hint->getIndexName().', '; |
|
64 | 64 | } |
65 | 65 | } |
66 | - if($use_index_hint != '') |
|
66 | + if ($use_index_hint != '') |
|
67 | 67 | { |
68 | - $result .= ' USE INDEX (' . substr($use_index_hint, 0, -2) . ') '; |
|
68 | + $result .= ' USE INDEX ('.substr($use_index_hint, 0, -2).') '; |
|
69 | 69 | } |
70 | - if($force_index_hint != '') |
|
70 | + if ($force_index_hint != '') |
|
71 | 71 | { |
72 | - $result .= ' FORCE INDEX (' . substr($force_index_hint, 0, -2) . ') '; |
|
72 | + $result .= ' FORCE INDEX ('.substr($force_index_hint, 0, -2).') '; |
|
73 | 73 | } |
74 | - if($ignore_index_hint != '') |
|
74 | + if ($ignore_index_hint != '') |
|
75 | 75 | { |
76 | - $result .= ' IGNORE INDEX (' . substr($ignore_index_hint, 0, -2) . ') '; |
|
76 | + $result .= ' IGNORE INDEX ('.substr($ignore_index_hint, 0, -2).') '; |
|
77 | 77 | } |
78 | 78 | return $result; |
79 | 79 | } |
@@ -20,12 +20,12 @@ |
||
20 | 20 | { |
21 | 21 | Context::set('component_info', $info); |
22 | 22 | |
23 | - if(!$info->extra_vars) |
|
23 | + if (!$info->extra_vars) |
|
24 | 24 | { |
25 | 25 | return; |
26 | 26 | } |
27 | 27 | |
28 | - foreach($info->extra_vars as $key => $val) |
|
28 | + foreach ($info->extra_vars as $key => $val) |
|
29 | 29 | { |
30 | 30 | $this->{$key} = trim($val->value); |
31 | 31 | } |
@@ -215,12 +215,10 @@ discard block |
||
215 | 215 | if(is_array($value)) |
216 | 216 | { |
217 | 217 | $values = $value; |
218 | - } |
|
219 | - elseif(strpos($value, '|@|') !== FALSE) |
|
218 | + } elseif(strpos($value, '|@|') !== FALSE) |
|
220 | 219 | { |
221 | 220 | $values = explode('|@|', $value); |
222 | - } |
|
223 | - elseif(strpos($value, ',') !== FALSE) |
|
221 | + } elseif(strpos($value, ',') !== FALSE) |
|
224 | 222 | { |
225 | 223 | $values = explode(',', $value); |
226 | 224 | } |
@@ -238,16 +236,13 @@ discard block |
||
238 | 236 | if(is_array($value)) |
239 | 237 | { |
240 | 238 | $values = $value; |
241 | - } |
|
242 | - elseif(strpos($value, '|@|') !== FALSE) |
|
239 | + } elseif(strpos($value, '|@|') !== FALSE) |
|
243 | 240 | { |
244 | 241 | $values = explode('|@|', $value); |
245 | - } |
|
246 | - elseif(strpos($value, ',') !== FALSE) |
|
242 | + } elseif(strpos($value, ',') !== FALSE) |
|
247 | 243 | { |
248 | 244 | $values = explode(',', $value); |
249 | - } |
|
250 | - else |
|
245 | + } else |
|
251 | 246 | { |
252 | 247 | $values = array($value); |
253 | 248 | } |
@@ -263,12 +258,10 @@ discard block |
||
263 | 258 | if(is_array($value)) |
264 | 259 | { |
265 | 260 | $values = $value; |
266 | - } |
|
267 | - elseif(strpos($value, '|@|') !== false) |
|
261 | + } elseif(strpos($value, '|@|') !== false) |
|
268 | 262 | { |
269 | 263 | $values = explode('|@|', $value); |
270 | - } |
|
271 | - else |
|
264 | + } else |
|
272 | 265 | { |
273 | 266 | $values = array($value); |
274 | 267 | } |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | */ |
52 | 52 | function setExtraVarKeys($extra_keys) |
53 | 53 | { |
54 | - if(!is_array($extra_keys) || count($extra_keys) < 1) |
|
54 | + if (!is_array($extra_keys) || count($extra_keys) < 1) |
|
55 | 55 | { |
56 | 56 | return; |
57 | 57 | } |
58 | 58 | |
59 | - foreach($extra_keys as $val) |
|
59 | + foreach ($extra_keys as $val) |
|
60 | 60 | { |
61 | 61 | $obj = new ExtraItem($val->module_srl, $val->idx, $val->name, $val->type, $val->default, $val->desc, $val->is_required, $val->search, $val->value, $val->eid); |
62 | 62 | $this->keys[$val->idx] = $obj; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | function ExtraItem($module_srl, $idx, $name, $type = 'text', $default = null, $desc = '', $is_required = 'N', $search = 'N', $value = null, $eid = '') |
161 | 161 | { |
162 | - if(!$idx) |
|
162 | + if (!$idx) |
|
163 | 163 | { |
164 | 164 | return; |
165 | 165 | } |
@@ -197,36 +197,36 @@ discard block |
||
197 | 197 | function _getTypeValue($type, $value) |
198 | 198 | { |
199 | 199 | $value = trim($value); |
200 | - if(!isset($value)) |
|
200 | + if (!isset($value)) |
|
201 | 201 | { |
202 | 202 | return; |
203 | 203 | } |
204 | 204 | |
205 | - switch($type) |
|
205 | + switch ($type) |
|
206 | 206 | { |
207 | 207 | case 'homepage' : |
208 | - if($value && !preg_match('/^([a-z]+):\/\//i', $value)) |
|
208 | + if ($value && !preg_match('/^([a-z]+):\/\//i', $value)) |
|
209 | 209 | { |
210 | - $value = 'http://' . $value; |
|
210 | + $value = 'http://'.$value; |
|
211 | 211 | } |
212 | 212 | return htmlspecialchars($value, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
213 | 213 | |
214 | 214 | case 'tel' : |
215 | - if(is_array($value)) |
|
215 | + if (is_array($value)) |
|
216 | 216 | { |
217 | 217 | $values = $value; |
218 | 218 | } |
219 | - elseif(strpos($value, '|@|') !== FALSE) |
|
219 | + elseif (strpos($value, '|@|') !== FALSE) |
|
220 | 220 | { |
221 | 221 | $values = explode('|@|', $value); |
222 | 222 | } |
223 | - elseif(strpos($value, ',') !== FALSE) |
|
223 | + elseif (strpos($value, ',') !== FALSE) |
|
224 | 224 | { |
225 | 225 | $values = explode(',', $value); |
226 | 226 | } |
227 | 227 | |
228 | 228 | $values = array_values($values); |
229 | - for($i = 0, $c = count($values); $i < $c; $i++) |
|
229 | + for ($i = 0, $c = count($values); $i < $c; $i++) |
|
230 | 230 | { |
231 | 231 | $values[$i] = trim(htmlspecialchars($values[$i], ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
232 | 232 | } |
@@ -235,15 +235,15 @@ discard block |
||
235 | 235 | case 'checkbox' : |
236 | 236 | case 'radio' : |
237 | 237 | case 'select' : |
238 | - if(is_array($value)) |
|
238 | + if (is_array($value)) |
|
239 | 239 | { |
240 | 240 | $values = $value; |
241 | 241 | } |
242 | - elseif(strpos($value, '|@|') !== FALSE) |
|
242 | + elseif (strpos($value, '|@|') !== FALSE) |
|
243 | 243 | { |
244 | 244 | $values = explode('|@|', $value); |
245 | 245 | } |
246 | - elseif(strpos($value, ',') !== FALSE) |
|
246 | + elseif (strpos($value, ',') !== FALSE) |
|
247 | 247 | { |
248 | 248 | $values = explode(',', $value); |
249 | 249 | } |
@@ -253,18 +253,18 @@ discard block |
||
253 | 253 | } |
254 | 254 | |
255 | 255 | $values = array_values($values); |
256 | - for($i = 0, $c = count($values); $i < $c; $i++) |
|
256 | + for ($i = 0, $c = count($values); $i < $c; $i++) |
|
257 | 257 | { |
258 | 258 | $values[$i] = trim(htmlspecialchars($values[$i], ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
259 | 259 | } |
260 | 260 | return $values; |
261 | 261 | |
262 | 262 | case 'kr_zip' : |
263 | - if(is_array($value)) |
|
263 | + if (is_array($value)) |
|
264 | 264 | { |
265 | 265 | $values = $value; |
266 | 266 | } |
267 | - elseif(strpos($value, '|@|') !== false) |
|
267 | + elseif (strpos($value, '|@|') !== false) |
|
268 | 268 | { |
269 | 269 | $values = explode('|@|', $value); |
270 | 270 | } |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | } |
275 | 275 | |
276 | 276 | $values = array_values($values); |
277 | - for($i = 0, $c = count($values); $i < $c; $i++) |
|
277 | + for ($i = 0, $c = count($values); $i < $c; $i++) |
|
278 | 278 | { |
279 | 279 | $values[$i] = trim(htmlspecialchars($values[$i], ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
280 | 280 | } |
@@ -308,10 +308,10 @@ discard block |
||
308 | 308 | { |
309 | 309 | $value = $this->_getTypeValue($this->type, $this->value); |
310 | 310 | |
311 | - switch($this->type) |
|
311 | + switch ($this->type) |
|
312 | 312 | { |
313 | 313 | case 'homepage' : |
314 | - return ($value) ? (sprintf('<a href="%s" target="_blank">%s</a>', $value, strlen($value) > 60 ? substr($value, 0, 40) . '...' . substr($value, -10) : $value)) : ""; |
|
314 | + return ($value) ? (sprintf('<a href="%s" target="_blank">%s</a>', $value, strlen($value) > 60 ? substr($value, 0, 40).'...'.substr($value, -10) : $value)) : ""; |
|
315 | 315 | |
316 | 316 | case 'email_address' : |
317 | 317 | return ($value) ? sprintf('<a href="mailto:%s">%s</a>', $value, $value) : ""; |
@@ -328,14 +328,14 @@ discard block |
||
328 | 328 | case 'checkbox' : |
329 | 329 | case 'select' : |
330 | 330 | case 'radio' : |
331 | - if(is_array($value)) |
|
331 | + if (is_array($value)) |
|
332 | 332 | { |
333 | 333 | return implode(',', $value); |
334 | 334 | } |
335 | 335 | return $value; |
336 | 336 | |
337 | 337 | case 'kr_zip' : |
338 | - if(is_array($value)) |
|
338 | + if (is_array($value)) |
|
339 | 339 | { |
340 | 340 | return implode(' ', $value); |
341 | 341 | } |
@@ -360,77 +360,77 @@ discard block |
||
360 | 360 | $name = $this->name; |
361 | 361 | $value = $this->_getTypeValue($this->type, $this->value); |
362 | 362 | $default = $this->_getTypeValue($this->type, $this->default); |
363 | - $column_name = 'extra_vars' . $this->idx; |
|
364 | - $tmp_id = $column_name . '-' . $id_num++; |
|
363 | + $column_name = 'extra_vars'.$this->idx; |
|
364 | + $tmp_id = $column_name.'-'.$id_num++; |
|
365 | 365 | |
366 | 366 | $buff = array(); |
367 | - switch($type) |
|
367 | + switch ($type) |
|
368 | 368 | { |
369 | 369 | // Homepage |
370 | 370 | case 'homepage' : |
371 | - $buff[] = '<input type="text" name="' . $column_name . '" value="' . $value . '" class="homepage" />'; |
|
371 | + $buff[] = '<input type="text" name="'.$column_name.'" value="'.$value.'" class="homepage" />'; |
|
372 | 372 | break; |
373 | 373 | // Email Address |
374 | 374 | case 'email_address' : |
375 | - $buff[] = '<input type="text" name="' . $column_name . '" value="' . $value . '" class="email_address" />'; |
|
375 | + $buff[] = '<input type="text" name="'.$column_name.'" value="'.$value.'" class="email_address" />'; |
|
376 | 376 | break; |
377 | 377 | // Phone Number |
378 | 378 | case 'tel' : |
379 | - $buff[] = '<input type="text" name="' . $column_name . '[]" value="' . $value[0] . '" size="4" maxlength="4" class="tel" />'; |
|
380 | - $buff[] = '<input type="text" name="' . $column_name . '[]" value="' . $value[1] . '" size="4" maxlength="4" class="tel" />'; |
|
381 | - $buff[] = '<input type="text" name="' . $column_name . '[]" value="' . $value[2] . '" size="4" maxlength="4" class="tel" />'; |
|
379 | + $buff[] = '<input type="text" name="'.$column_name.'[]" value="'.$value[0].'" size="4" maxlength="4" class="tel" />'; |
|
380 | + $buff[] = '<input type="text" name="'.$column_name.'[]" value="'.$value[1].'" size="4" maxlength="4" class="tel" />'; |
|
381 | + $buff[] = '<input type="text" name="'.$column_name.'[]" value="'.$value[2].'" size="4" maxlength="4" class="tel" />'; |
|
382 | 382 | break; |
383 | 383 | // textarea |
384 | 384 | case 'textarea' : |
385 | - $buff[] = '<textarea name="' . $column_name . '" rows="8" cols="42">' . $value . '</textarea>'; |
|
385 | + $buff[] = '<textarea name="'.$column_name.'" rows="8" cols="42">'.$value.'</textarea>'; |
|
386 | 386 | break; |
387 | 387 | // multiple choice |
388 | 388 | case 'checkbox' : |
389 | 389 | $buff[] = '<ul>'; |
390 | - foreach($default as $v) |
|
390 | + foreach ($default as $v) |
|
391 | 391 | { |
392 | 392 | $checked = ''; |
393 | - if($value && in_array(trim($v), $value)) |
|
393 | + if ($value && in_array(trim($v), $value)) |
|
394 | 394 | { |
395 | 395 | $checked = ' checked="checked"'; |
396 | 396 | } |
397 | 397 | |
398 | 398 | // Temporary ID for labeling |
399 | - $tmp_id = $column_name . '-' . $id_num++; |
|
399 | + $tmp_id = $column_name.'-'.$id_num++; |
|
400 | 400 | |
401 | - $buff[] =' <li><input type="checkbox" name="' . $column_name . '[]" id="' . $tmp_id . '" value="' . htmlspecialchars($v, ENT_COMPAT | ENT_HTML401, 'UTF-8', false) . '" ' . $checked . ' /><label for="' . $tmp_id . '">' . $v . '</label></li>'; |
|
401 | + $buff[] = ' <li><input type="checkbox" name="'.$column_name.'[]" id="'.$tmp_id.'" value="'.htmlspecialchars($v, ENT_COMPAT | ENT_HTML401, 'UTF-8', false).'" '.$checked.' /><label for="'.$tmp_id.'">'.$v.'</label></li>'; |
|
402 | 402 | } |
403 | 403 | $buff[] = '</ul>'; |
404 | 404 | break; |
405 | 405 | // single choice |
406 | 406 | case 'select' : |
407 | - $buff[] = '<select name="' . $column_name . '" class="select">'; |
|
408 | - foreach($default as $v) |
|
407 | + $buff[] = '<select name="'.$column_name.'" class="select">'; |
|
408 | + foreach ($default as $v) |
|
409 | 409 | { |
410 | 410 | $selected = ''; |
411 | - if($value && in_array(trim($v), $value)) |
|
411 | + if ($value && in_array(trim($v), $value)) |
|
412 | 412 | { |
413 | 413 | $selected = ' selected="selected"'; |
414 | 414 | } |
415 | - $buff[] = ' <option value="' . $v . '" ' . $selected . '>' . $v . '</option>'; |
|
415 | + $buff[] = ' <option value="'.$v.'" '.$selected.'>'.$v.'</option>'; |
|
416 | 416 | } |
417 | 417 | $buff[] = '</select>'; |
418 | 418 | break; |
419 | 419 | // radio |
420 | 420 | case 'radio' : |
421 | 421 | $buff[] = '<ul>'; |
422 | - foreach($default as $v) |
|
422 | + foreach ($default as $v) |
|
423 | 423 | { |
424 | 424 | $checked = ''; |
425 | - if($value && in_array(trim($v), $value)) |
|
425 | + if ($value && in_array(trim($v), $value)) |
|
426 | 426 | { |
427 | 427 | $checked = ' checked="checked"'; |
428 | 428 | } |
429 | 429 | |
430 | 430 | // Temporary ID for labeling |
431 | - $tmp_id = $column_name . '-' . $id_num++; |
|
431 | + $tmp_id = $column_name.'-'.$id_num++; |
|
432 | 432 | |
433 | - $buff[] = '<li><input type="radio" name="' . $column_name . '" id="' . $tmp_id . '" ' . $checked . ' value="' . $v . '" class="radio" /><label for="' . $tmp_id . '">' . $v . '</label></li>'; |
|
433 | + $buff[] = '<li><input type="radio" name="'.$column_name.'" id="'.$tmp_id.'" '.$checked.' value="'.$v.'" class="radio" /><label for="'.$tmp_id.'">'.$v.'</label></li>'; |
|
434 | 434 | } |
435 | 435 | $buff[] = '</ul>'; |
436 | 436 | break; |
@@ -439,43 +439,43 @@ discard block |
||
439 | 439 | // datepicker javascript plugin load |
440 | 440 | Context::loadJavascriptPlugin('ui.datepicker'); |
441 | 441 | |
442 | - $buff[] = '<input type="hidden" name="' . $column_name . '" value="' . $value . '" />'; |
|
443 | - $buff[] = '<input type="text" id="date_' . $column_name . '" value="' . zdate($value, 'Y-m-d') . '" class="date" />'; |
|
444 | - $buff[] = '<input type="button" value="' . Context::getLang('cmd_delete') . '" class="btn" id="dateRemover_' . $column_name . '" />'; |
|
445 | - $buff[] = '<script type="text/javascript">'; |
|
442 | + $buff[] = '<input type="hidden" name="'.$column_name.'" value="'.$value.'" />'; |
|
443 | + $buff[] = '<input type="text" id="date_'.$column_name.'" value="'.zdate($value, 'Y-m-d').'" class="date" />'; |
|
444 | + $buff[] = '<input type="button" value="'.Context::getLang('cmd_delete').'" class="btn" id="dateRemover_'.$column_name.'" />'; |
|
445 | + $buff[] = '<script type="text/javascript">'; |
|
446 | 446 | $buff[] = '//<![CDATA['; |
447 | - $buff[] = '(function($){'; |
|
448 | - $buff[] = '$(function(){'; |
|
449 | - $buff[] = ' var option = { dateFormat: "yy-mm-dd", changeMonth:true, changeYear:true, gotoCurrent:false, yearRange:\'-100:+10\', onSelect:function(){'; |
|
450 | - $buff[] = ' $(this).prev(\'input[type="hidden"]\').val(this.value.replace(/-/g,""))}'; |
|
451 | - $buff[] = ' };'; |
|
452 | - $buff[] = ' $.extend(option,$.datepicker.regional[\'' . Context::getLangType() . '\']);'; |
|
453 | - $buff[] = ' $("#date_' . $column_name . '").datepicker(option);'; |
|
454 | - $buff[] = ' $("#dateRemover_' . $column_name . '").click(function(){'; |
|
455 | - $buff[] = ' $(this).siblings("input").val("");'; |
|
456 | - $buff[] = ' return false;'; |
|
457 | - $buff[] = ' })'; |
|
458 | - $buff[] = '});'; |
|
459 | - $buff[] = '})(jQuery);'; |
|
447 | + $buff[] = '(function($){'; |
|
448 | + $buff[] = '$(function(){'; |
|
449 | + $buff[] = ' var option = { dateFormat: "yy-mm-dd", changeMonth:true, changeYear:true, gotoCurrent:false, yearRange:\'-100:+10\', onSelect:function(){'; |
|
450 | + $buff[] = ' $(this).prev(\'input[type="hidden"]\').val(this.value.replace(/-/g,""))}'; |
|
451 | + $buff[] = ' };'; |
|
452 | + $buff[] = ' $.extend(option,$.datepicker.regional[\''.Context::getLangType().'\']);'; |
|
453 | + $buff[] = ' $("#date_'.$column_name.'").datepicker(option);'; |
|
454 | + $buff[] = ' $("#dateRemover_'.$column_name.'").click(function(){'; |
|
455 | + $buff[] = ' $(this).siblings("input").val("");'; |
|
456 | + $buff[] = ' return false;'; |
|
457 | + $buff[] = ' })'; |
|
458 | + $buff[] = '});'; |
|
459 | + $buff[] = '})(jQuery);'; |
|
460 | 460 | $buff[] = '//]]>'; |
461 | 461 | $buff[] = '</script>'; |
462 | 462 | break; |
463 | 463 | // address |
464 | 464 | case "kr_zip" : |
465 | - if(($oKrzipModel = getModel('krzip')) && method_exists($oKrzipModel , 'getKrzipCodeSearchHtml' )) |
|
465 | + if (($oKrzipModel = getModel('krzip')) && method_exists($oKrzipModel, 'getKrzipCodeSearchHtml')) |
|
466 | 466 | { |
467 | - $buff[] = $oKrzipModel->getKrzipCodeSearchHtml($column_name, $value); |
|
467 | + $buff[] = $oKrzipModel->getKrzipCodeSearchHtml($column_name, $value); |
|
468 | 468 | } |
469 | 469 | break; |
470 | 470 | // General text |
471 | 471 | default : |
472 | - $buff[] =' <input type="text" name="' . $column_name . '" value="' . ($value ? $value : $default) . '" class="text" />'; |
|
472 | + $buff[] = ' <input type="text" name="'.$column_name.'" value="'.($value ? $value : $default).'" class="text" />'; |
|
473 | 473 | } |
474 | - if($this->desc) |
|
474 | + if ($this->desc) |
|
475 | 475 | { |
476 | 476 | $oModuleController = getController('module'); |
477 | 477 | $oModuleController->replaceDefinedLangCode($this->desc); |
478 | - $buff[] = '<p>' . htmlspecialchars($this->desc, ENT_COMPAT | ENT_HTML401, 'UTF-8', false) . '</p>'; |
|
478 | + $buff[] = '<p>'.htmlspecialchars($this->desc, ENT_COMPAT | ENT_HTML401, 'UTF-8', false).'</p>'; |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | return join(PHP_EOL, $buff); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | function FileObject($path, $mode) |
38 | 38 | { |
39 | - if($path != NULL) |
|
39 | + if ($path != NULL) |
|
40 | 40 | { |
41 | 41 | $this->Open($path, $mode); |
42 | 42 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | function append($file_name) |
52 | 52 | { |
53 | 53 | $target = new FileObject($file_name, "r"); |
54 | - while(!$target->feof()) |
|
54 | + while (!$target->feof()) |
|
55 | 55 | { |
56 | 56 | $readstr = $target->read(); |
57 | 57 | $this->write($readstr); |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | function write($str) |
90 | 90 | { |
91 | 91 | $len = strlen($str); |
92 | - if(!$str || $len <= 0) |
|
92 | + if (!$str || $len <= 0) |
|
93 | 93 | { |
94 | 94 | return FALSE; |
95 | 95 | } |
96 | - if(!$this->fp) |
|
96 | + if (!$this->fp) |
|
97 | 97 | { |
98 | 98 | return FALSE; |
99 | 99 | } |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | */ |
113 | 113 | function open($path, $mode) |
114 | 114 | { |
115 | - if($this->fp != NULL) |
|
115 | + if ($this->fp != NULL) |
|
116 | 116 | { |
117 | 117 | $this->close(); |
118 | 118 | } |
119 | 119 | $this->fp = fopen($path, $mode); |
120 | - if(!is_resource($this->fp)) |
|
120 | + if (!is_resource($this->fp)) |
|
121 | 121 | { |
122 | 122 | $this->fp = NULL; |
123 | 123 | return FALSE; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | function getPath() |
135 | 135 | { |
136 | - if($this->fp != NULL) |
|
136 | + if ($this->fp != NULL) |
|
137 | 137 | { |
138 | 138 | return $this->path; |
139 | 139 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | function close() |
152 | 152 | { |
153 | - if($this->fp != NULL) |
|
153 | + if ($this->fp != NULL) |
|
154 | 154 | { |
155 | 155 | fclose($this->fp); |
156 | 156 | $this->fp = NULL; |
@@ -136,8 +136,7 @@ |
||
136 | 136 | if($this->fp != NULL) |
137 | 137 | { |
138 | 138 | return $this->path; |
139 | - } |
|
140 | - else |
|
139 | + } else |
|
141 | 140 | { |
142 | 141 | return NULL; |
143 | 142 | } |
@@ -39,18 +39,18 @@ discard block |
||
39 | 39 | $this->point = 0; |
40 | 40 | |
41 | 41 | $first_page = $cur_page - (int) ($page_count / 2); |
42 | - if($first_page < 1) |
|
42 | + if ($first_page < 1) |
|
43 | 43 | { |
44 | 44 | $first_page = 1; |
45 | 45 | } |
46 | 46 | |
47 | - if($total_page > $page_count && $first_page + $page_count - 1 > $total_page) |
|
47 | + if ($total_page > $page_count && $first_page + $page_count - 1 > $total_page) |
|
48 | 48 | { |
49 | 49 | $first_page -= $first_page + $page_count - 1 - $total_page; |
50 | 50 | } |
51 | 51 | |
52 | 52 | $last_page = $total_page; |
53 | - if($last_page > $total_page) |
|
53 | + if ($last_page > $total_page) |
|
54 | 54 | { |
55 | 55 | $last_page = $total_page; |
56 | 56 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $this->first_page = $first_page; |
59 | 59 | $this->last_page = $last_page; |
60 | 60 | |
61 | - if($total_page < $this->page_count) |
|
61 | + if ($total_page < $this->page_count) |
|
62 | 62 | { |
63 | 63 | $this->page_count = $total_page; |
64 | 64 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | function getNextPage() |
72 | 72 | { |
73 | 73 | $page = $this->first_page + $this->point++; |
74 | - if($this->point > $this->page_count || $page > $this->last_page) |
|
74 | + if ($this->point > $this->page_count || $page > $this->last_page) |
|
75 | 75 | { |
76 | 76 | $page = 0; |
77 | 77 | } |
@@ -5,24 +5,24 @@ discard block |
||
5 | 5 | { |
6 | 6 | public function filter($ip_list, $ip = NULL) |
7 | 7 | { |
8 | - if(!$ip) $ip = $_SERVER['REMOTE_ADDR']; |
|
8 | + if (!$ip) $ip = $_SERVER['REMOTE_ADDR']; |
|
9 | 9 | $long_ip = ip2long($ip); |
10 | - foreach($ip_list as $filter_ip) |
|
10 | + foreach ($ip_list as $filter_ip) |
|
11 | 11 | { |
12 | 12 | $range = explode('-', $filter_ip); |
13 | - if(!$range[1]) // single address type |
|
13 | + if (!$range[1]) // single address type |
|
14 | 14 | { |
15 | 15 | $star_pos = strpos($filter_ip, '*'); |
16 | - if($star_pos !== FALSE ) // wild card exist |
|
16 | + if ($star_pos !== FALSE) // wild card exist |
|
17 | 17 | { |
18 | - if(strncmp($filter_ip, $ip, $star_pos)===0) return true; |
|
18 | + if (strncmp($filter_ip, $ip, $star_pos) === 0) return true; |
|
19 | 19 | } |
20 | - else if(strcmp($filter_ip, $ip)===0) |
|
20 | + else if (strcmp($filter_ip, $ip) === 0) |
|
21 | 21 | { |
22 | 22 | return true; |
23 | 23 | } |
24 | 24 | } |
25 | - else if(ip2long($range[0]) <= $long_ip && ip2long($range[1]) >= $long_ip) |
|
25 | + else if (ip2long($range[0]) <= $long_ip && ip2long($range[1]) >= $long_ip) |
|
26 | 26 | { |
27 | 27 | return true; |
28 | 28 | } |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | ) |
75 | 75 | ) |
76 | 76 | $/"; |
77 | - $regex = str_replace(array("\r\n", "\n", "\r","\t"," "), '', $regex); |
|
77 | + $regex = str_replace(array("\r\n", "\n", "\r", "\t", " "), '', $regex); |
|
78 | 78 | |
79 | - foreach($ip_list as $i => $ip) |
|
79 | + foreach ($ip_list as $i => $ip) |
|
80 | 80 | { |
81 | 81 | preg_match($regex, $ip, $matches); |
82 | - if(!count($matches)) return false; |
|
82 | + if (!count($matches)) return false; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | return true; |
@@ -5,24 +5,28 @@ discard block |
||
5 | 5 | { |
6 | 6 | public function filter($ip_list, $ip = NULL) |
7 | 7 | { |
8 | - if(!$ip) $ip = $_SERVER['REMOTE_ADDR']; |
|
8 | + if(!$ip) { |
|
9 | + $ip = $_SERVER['REMOTE_ADDR']; |
|
10 | + } |
|
9 | 11 | $long_ip = ip2long($ip); |
10 | 12 | foreach($ip_list as $filter_ip) |
11 | 13 | { |
12 | 14 | $range = explode('-', $filter_ip); |
13 | - if(!$range[1]) // single address type |
|
15 | + if(!$range[1]) { |
|
16 | + // single address type |
|
14 | 17 | { |
15 | 18 | $star_pos = strpos($filter_ip, '*'); |
16 | - if($star_pos !== FALSE ) // wild card exist |
|
19 | + } |
|
20 | + if($star_pos !== FALSE ) { |
|
21 | + // wild card exist |
|
17 | 22 | { |
18 | 23 | if(strncmp($filter_ip, $ip, $star_pos)===0) return true; |
19 | 24 | } |
20 | - else if(strcmp($filter_ip, $ip)===0) |
|
25 | + } else if(strcmp($filter_ip, $ip)===0) |
|
21 | 26 | { |
22 | 27 | return true; |
23 | 28 | } |
24 | - } |
|
25 | - else if(ip2long($range[0]) <= $long_ip && ip2long($range[1]) >= $long_ip) |
|
29 | + } else if(ip2long($range[0]) <= $long_ip && ip2long($range[1]) >= $long_ip) |
|
26 | 30 | { |
27 | 31 | return true; |
28 | 32 | } |
@@ -79,7 +83,9 @@ discard block |
||
79 | 83 | foreach($ip_list as $i => $ip) |
80 | 84 | { |
81 | 85 | preg_match($regex, $ip, $matches); |
82 | - if(!count($matches)) return false; |
|
86 | + if(!count($matches)) { |
|
87 | + return false; |
|
88 | + } |
|
83 | 89 | } |
84 | 90 | |
85 | 91 | return true; |
@@ -55,8 +55,7 @@ discard block |
||
55 | 55 | { |
56 | 56 | $algorithm = 'md5'; // Historical default for XE |
57 | 57 | } |
58 | - } |
|
59 | - else |
|
58 | + } else |
|
60 | 59 | { |
61 | 60 | $algorithm = 'md5'; |
62 | 61 | } |
@@ -77,8 +76,7 @@ discard block |
||
77 | 76 | { |
78 | 77 | $work_factor = 8; // Reasonable default |
79 | 78 | } |
80 | - } |
|
81 | - else |
|
79 | + } else |
|
82 | 80 | { |
83 | 81 | $work_factor = 8; |
84 | 82 | } |
@@ -176,24 +174,19 @@ discard block |
||
176 | 174 | if(preg_match('/^\$2[axy]\$([0-9]{2})\$/', $hash, $matches)) |
177 | 175 | { |
178 | 176 | return 'bcrypt'; |
179 | - } |
|
180 | - elseif(preg_match('/^sha[0-9]+:([0-9]+):/', $hash, $matches)) |
|
177 | + } elseif(preg_match('/^sha[0-9]+:([0-9]+):/', $hash, $matches)) |
|
181 | 178 | { |
182 | 179 | return 'pbkdf2'; |
183 | - } |
|
184 | - elseif(strlen($hash) === 32 && ctype_xdigit($hash)) |
|
180 | + } elseif(strlen($hash) === 32 && ctype_xdigit($hash)) |
|
185 | 181 | { |
186 | 182 | return 'md5'; |
187 | - } |
|
188 | - elseif(strlen($hash) === 16 && ctype_xdigit($hash)) |
|
183 | + } elseif(strlen($hash) === 16 && ctype_xdigit($hash)) |
|
189 | 184 | { |
190 | 185 | return 'mysql_old_password'; |
191 | - } |
|
192 | - elseif(strlen($hash) === 41 && $hash[0] === '*') |
|
186 | + } elseif(strlen($hash) === 41 && $hash[0] === '*') |
|
193 | 187 | { |
194 | 188 | return 'mysql_password'; |
195 | - } |
|
196 | - else |
|
189 | + } else |
|
197 | 190 | { |
198 | 191 | return false; |
199 | 192 | } |
@@ -209,12 +202,10 @@ discard block |
||
209 | 202 | if(preg_match('/^\$2[axy]\$([0-9]{2})\$/', $hash, $matches)) |
210 | 203 | { |
211 | 204 | return intval($matches[1], 10); |
212 | - } |
|
213 | - elseif(preg_match('/^sha[0-9]+:([0-9]+):/', $hash, $matches)) |
|
205 | + } elseif(preg_match('/^sha[0-9]+:([0-9]+):/', $hash, $matches)) |
|
214 | 206 | { |
215 | 207 | return max(0, round(log($matches[1], 2)) - 5); |
216 | - } |
|
217 | - else |
|
208 | + } else |
|
218 | 209 | { |
219 | 210 | return false; |
220 | 211 | } |
@@ -250,22 +241,18 @@ discard block |
||
250 | 241 | if(function_exists('openssl_random_pseudo_bytes') && (!$is_windows || version_compare(PHP_VERSION, '5.4', '>='))) |
251 | 242 | { |
252 | 243 | $entropy = openssl_random_pseudo_bytes($entropy_capped_bytes); |
253 | - } |
|
254 | - elseif(function_exists('mcrypt_create_iv') && (!$is_windows || version_compare(PHP_VERSION, '5.3.7', '>='))) |
|
244 | + } elseif(function_exists('mcrypt_create_iv') && (!$is_windows || version_compare(PHP_VERSION, '5.3.7', '>='))) |
|
255 | 245 | { |
256 | 246 | $entropy = mcrypt_create_iv($entropy_capped_bytes, MCRYPT_DEV_URANDOM); |
257 | - } |
|
258 | - elseif(function_exists('mcrypt_create_iv') && $is_windows) |
|
247 | + } elseif(function_exists('mcrypt_create_iv') && $is_windows) |
|
259 | 248 | { |
260 | 249 | $entropy = mcrypt_create_iv($entropy_capped_bytes, MCRYPT_RAND); |
261 | - } |
|
262 | - elseif(!$is_windows && @is_readable('/dev/urandom')) |
|
250 | + } elseif(!$is_windows && @is_readable('/dev/urandom')) |
|
263 | 251 | { |
264 | 252 | $fp = fopen('/dev/urandom', 'rb'); |
265 | 253 | $entropy = fread($fp, $entropy_capped_bytes); |
266 | 254 | fclose($fp); |
267 | - } |
|
268 | - else |
|
255 | + } else |
|
269 | 256 | { |
270 | 257 | $entropy = ''; |
271 | 258 | for($i = 0; $i < $entropy_capped_bytes; $i += 2) |
@@ -341,8 +328,7 @@ discard block |
||
341 | 328 | if(function_exists('hash_pbkdf2')) |
342 | 329 | { |
343 | 330 | return hash_pbkdf2($algorithm, $password, $salt, $iterations, $length, true); |
344 | - } |
|
345 | - else |
|
331 | + } else |
|
346 | 332 | { |
347 | 333 | $output = ''; |
348 | 334 | $block_count = ceil($length / strlen(hash($algorithm, '', true))); // key length divided by the length of one hash |
@@ -350,10 +336,12 @@ discard block |
||
350 | 336 | { |
351 | 337 | $last = $salt . pack('N', $i); // $i encoded as 4 bytes, big endian |
352 | 338 | $last = $xorsum = hash_hmac($algorithm, $last, $password, true); // first iteration |
353 | - for($j = 1; $j < $iterations; $j++) // The other $count - 1 iterations |
|
339 | + for($j = 1; $j < $iterations; $j++) { |
|
340 | + // The other $count - 1 iterations |
|
354 | 341 | { |
355 | 342 | $xorsum ^= ($last = hash_hmac($algorithm, $last, $password, true)); |
356 | 343 | } |
344 | + } |
|
357 | 345 | $output .= $xorsum; |
358 | 346 | } |
359 | 347 | return substr($output, 0, $length); |
@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | public function getSupportedAlgorithms() |
20 | 20 | { |
21 | 21 | $retval = array(); |
22 | - if(function_exists('hash_hmac') && in_array('sha256', hash_algos())) |
|
22 | + if (function_exists('hash_hmac') && in_array('sha256', hash_algos())) |
|
23 | 23 | { |
24 | 24 | $retval['pbkdf2'] = 'pbkdf2'; |
25 | 25 | } |
26 | - if(version_compare(PHP_VERSION, '5.3.7', '>=') && defined('CRYPT_BLOWFISH')) |
|
26 | + if (version_compare(PHP_VERSION, '5.3.7', '>=') && defined('CRYPT_BLOWFISH')) |
|
27 | 27 | { |
28 | 28 | $retval['bcrypt'] = 'bcrypt'; |
29 | 29 | } |
@@ -47,13 +47,13 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function getCurrentlySelectedAlgorithm() |
49 | 49 | { |
50 | - if(function_exists('getModel')) |
|
50 | + if (function_exists('getModel')) |
|
51 | 51 | { |
52 | 52 | $config = getModel('member')->getMemberConfig(); |
53 | 53 | $algorithm = $config->password_hashing_algorithm; |
54 | - if(strval($algorithm) === '') |
|
54 | + if (strval($algorithm) === '') |
|
55 | 55 | { |
56 | - $algorithm = 'md5'; // Historical default for XE |
|
56 | + $algorithm = 'md5'; // Historical default for XE |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | else |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function getWorkFactor() |
71 | 71 | { |
72 | - if(function_exists('getModel')) |
|
72 | + if (function_exists('getModel')) |
|
73 | 73 | { |
74 | 74 | $config = getModel('member')->getMemberConfig(); |
75 | 75 | $work_factor = $config->password_hashing_work_factor; |
76 | - if(!$work_factor || $work_factor < 4 || $work_factor > 31) |
|
76 | + if (!$work_factor || $work_factor < 4 || $work_factor > 31) |
|
77 | 77 | { |
78 | - $work_factor = 8; // Reasonable default |
|
78 | + $work_factor = 8; // Reasonable default |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | else |
@@ -93,18 +93,18 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function createHash($password, $algorithm = null) |
95 | 95 | { |
96 | - if($algorithm === null) |
|
96 | + if ($algorithm === null) |
|
97 | 97 | { |
98 | 98 | $algorithm = $this->getCurrentlySelectedAlgorithm(); |
99 | 99 | } |
100 | - if(!array_key_exists($algorithm, $this->getSupportedAlgorithms())) |
|
100 | + if (!array_key_exists($algorithm, $this->getSupportedAlgorithms())) |
|
101 | 101 | { |
102 | 102 | return false; |
103 | 103 | } |
104 | 104 | |
105 | 105 | $password = trim($password); |
106 | 106 | |
107 | - switch($algorithm) |
|
107 | + switch ($algorithm) |
|
108 | 108 | { |
109 | 109 | case 'md5': |
110 | 110 | return md5($password); |
@@ -132,14 +132,14 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function checkPassword($password, $hash, $algorithm = null) |
134 | 134 | { |
135 | - if($algorithm === null) |
|
135 | + if ($algorithm === null) |
|
136 | 136 | { |
137 | 137 | $algorithm = $this->checkAlgorithm($hash); |
138 | 138 | } |
139 | 139 | |
140 | 140 | $password = trim($password); |
141 | 141 | |
142 | - switch($algorithm) |
|
142 | + switch ($algorithm) |
|
143 | 143 | { |
144 | 144 | case 'md5': |
145 | 145 | return md5($password) === $hash || md5(sha1(md5($password))) === $hash; |
@@ -173,23 +173,23 @@ discard block |
||
173 | 173 | */ |
174 | 174 | function checkAlgorithm($hash) |
175 | 175 | { |
176 | - if(preg_match('/^\$2[axy]\$([0-9]{2})\$/', $hash, $matches)) |
|
176 | + if (preg_match('/^\$2[axy]\$([0-9]{2})\$/', $hash, $matches)) |
|
177 | 177 | { |
178 | 178 | return 'bcrypt'; |
179 | 179 | } |
180 | - elseif(preg_match('/^sha[0-9]+:([0-9]+):/', $hash, $matches)) |
|
180 | + elseif (preg_match('/^sha[0-9]+:([0-9]+):/', $hash, $matches)) |
|
181 | 181 | { |
182 | 182 | return 'pbkdf2'; |
183 | 183 | } |
184 | - elseif(strlen($hash) === 32 && ctype_xdigit($hash)) |
|
184 | + elseif (strlen($hash) === 32 && ctype_xdigit($hash)) |
|
185 | 185 | { |
186 | 186 | return 'md5'; |
187 | 187 | } |
188 | - elseif(strlen($hash) === 16 && ctype_xdigit($hash)) |
|
188 | + elseif (strlen($hash) === 16 && ctype_xdigit($hash)) |
|
189 | 189 | { |
190 | 190 | return 'mysql_old_password'; |
191 | 191 | } |
192 | - elseif(strlen($hash) === 41 && $hash[0] === '*') |
|
192 | + elseif (strlen($hash) === 41 && $hash[0] === '*') |
|
193 | 193 | { |
194 | 194 | return 'mysql_password'; |
195 | 195 | } |
@@ -206,11 +206,11 @@ discard block |
||
206 | 206 | */ |
207 | 207 | function checkWorkFactor($hash) |
208 | 208 | { |
209 | - if(preg_match('/^\$2[axy]\$([0-9]{2})\$/', $hash, $matches)) |
|
209 | + if (preg_match('/^\$2[axy]\$([0-9]{2})\$/', $hash, $matches)) |
|
210 | 210 | { |
211 | 211 | return intval($matches[1], 10); |
212 | 212 | } |
213 | - elseif(preg_match('/^sha[0-9]+:([0-9]+):/', $hash, $matches)) |
|
213 | + elseif (preg_match('/^sha[0-9]+:([0-9]+):/', $hash, $matches)) |
|
214 | 214 | { |
215 | 215 | return max(0, round(log($matches[1], 2)) - 5); |
216 | 216 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | public function createSecureSalt($length, $format = 'hex') |
230 | 230 | { |
231 | 231 | // Find out how many bytes of entropy we really need |
232 | - switch($format) |
|
232 | + switch ($format) |
|
233 | 233 | { |
234 | 234 | case 'hex': |
235 | 235 | $entropy_required_bytes = ceil($length / 2); |
@@ -247,19 +247,19 @@ discard block |
||
247 | 247 | |
248 | 248 | // Find and use the most secure way to generate a random string |
249 | 249 | $is_windows = (defined('PHP_OS') && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'); |
250 | - if(function_exists('openssl_random_pseudo_bytes') && (!$is_windows || version_compare(PHP_VERSION, '5.4', '>='))) |
|
250 | + if (function_exists('openssl_random_pseudo_bytes') && (!$is_windows || version_compare(PHP_VERSION, '5.4', '>='))) |
|
251 | 251 | { |
252 | 252 | $entropy = openssl_random_pseudo_bytes($entropy_capped_bytes); |
253 | 253 | } |
254 | - elseif(function_exists('mcrypt_create_iv') && (!$is_windows || version_compare(PHP_VERSION, '5.3.7', '>='))) |
|
254 | + elseif (function_exists('mcrypt_create_iv') && (!$is_windows || version_compare(PHP_VERSION, '5.3.7', '>='))) |
|
255 | 255 | { |
256 | 256 | $entropy = mcrypt_create_iv($entropy_capped_bytes, MCRYPT_DEV_URANDOM); |
257 | 257 | } |
258 | - elseif(function_exists('mcrypt_create_iv') && $is_windows) |
|
258 | + elseif (function_exists('mcrypt_create_iv') && $is_windows) |
|
259 | 259 | { |
260 | 260 | $entropy = mcrypt_create_iv($entropy_capped_bytes, MCRYPT_RAND); |
261 | 261 | } |
262 | - elseif(!$is_windows && @is_readable('/dev/urandom')) |
|
262 | + elseif (!$is_windows && @is_readable('/dev/urandom')) |
|
263 | 263 | { |
264 | 264 | $fp = fopen('/dev/urandom', 'rb'); |
265 | 265 | $entropy = fread($fp, $entropy_capped_bytes); |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | else |
269 | 269 | { |
270 | 270 | $entropy = ''; |
271 | - for($i = 0; $i < $entropy_capped_bytes; $i += 2) |
|
271 | + for ($i = 0; $i < $entropy_capped_bytes; $i += 2) |
|
272 | 272 | { |
273 | 273 | $entropy .= pack('S', rand(0, 65536) ^ mt_rand(0, 65535)); |
274 | 274 | } |
@@ -276,13 +276,13 @@ discard block |
||
276 | 276 | |
277 | 277 | // Mixing (see RFC 4086 section 5) |
278 | 278 | $output = ''; |
279 | - for($i = 0; $i < $entropy_required_bytes; $i += 32) |
|
279 | + for ($i = 0; $i < $entropy_required_bytes; $i += 32) |
|
280 | 280 | { |
281 | - $output .= hash('sha256', $entropy . $i . rand(), true); |
|
281 | + $output .= hash('sha256', $entropy.$i.rand(), true); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | // Encode and return the random string |
285 | - switch($format) |
|
285 | + switch ($format) |
|
286 | 286 | { |
287 | 287 | case 'hex': |
288 | 288 | return substr(bin2hex($output), 0, $length); |
@@ -290,15 +290,15 @@ discard block |
||
290 | 290 | return substr($output, 0, $length); |
291 | 291 | case 'printable': |
292 | 292 | $salt = ''; |
293 | - for($i = 0; $i < $length; $i++) |
|
293 | + for ($i = 0; $i < $length; $i++) |
|
294 | 294 | { |
295 | - $salt .= chr(33 + (crc32(sha1($i . $output)) % 94)); |
|
295 | + $salt .= chr(33 + (crc32(sha1($i.$output)) % 94)); |
|
296 | 296 | } |
297 | 297 | return $salt; |
298 | 298 | case 'alnum': |
299 | 299 | default: |
300 | 300 | $salt = substr(base64_encode($output), 0, $length); |
301 | - $replacements = chr(rand(65, 90)) . chr(rand(97, 122)) . rand(0, 9); |
|
301 | + $replacements = chr(rand(65, 90)).chr(rand(97, 122)).rand(0, 9); |
|
302 | 302 | return strtr($salt, '+/=', $replacements); |
303 | 303 | } |
304 | 304 | } |
@@ -310,15 +310,15 @@ discard block |
||
310 | 310 | */ |
311 | 311 | public function createTemporaryPassword($length = 16) |
312 | 312 | { |
313 | - while(true) |
|
313 | + while (true) |
|
314 | 314 | { |
315 | 315 | $source = base64_encode($this->createSecureSalt(64, 'binary')); |
316 | 316 | $source = strtr($source, 'iIoOjl10/', '@#$%&*-!?'); |
317 | 317 | $source_length = strlen($source); |
318 | - for($i = 0; $i < $source_length - $length; $i++) |
|
318 | + for ($i = 0; $i < $source_length - $length; $i++) |
|
319 | 319 | { |
320 | 320 | $candidate = substr($source, $i, $length); |
321 | - if(preg_match('/[a-z]/', $candidate) && preg_match('/[A-Z]/', $candidate) && |
|
321 | + if (preg_match('/[a-z]/', $candidate) && preg_match('/[A-Z]/', $candidate) && |
|
322 | 322 | preg_match('/[0-9]/', $candidate) && preg_match('/[^a-zA-Z0-9]/', $candidate)) |
323 | 323 | { |
324 | 324 | return $candidate; |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | $key = self::getSecretKey(); |
338 | 338 | $salt = self::createSecureSalt(8, 'alnum'); |
339 | 339 | $hash = substr(base64_encode(hash_hmac('sha256', hash_hmac('sha256', $string, $salt), $key, true)), 0, 32); |
340 | - return $salt . strtr($hash, '+/', '-_'); |
|
340 | + return $salt.strtr($hash, '+/', '-_'); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | */ |
349 | 349 | public static function checkSignature($string, $signature) |
350 | 350 | { |
351 | - if(strlen($signature) !== 40) |
|
351 | + if (strlen($signature) !== 40) |
|
352 | 352 | { |
353 | 353 | return false; |
354 | 354 | } |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | { |
368 | 368 | // If the secret key does not exist, the config file needs to be updated |
369 | 369 | $db_info = Context::getDbInfo(); |
370 | - if(!isset($db_info->secret_key)) |
|
370 | + if (!isset($db_info->secret_key)) |
|
371 | 371 | { |
372 | 372 | $db_info->secret_key = self::createSecureSalt(48, 'alnum'); |
373 | 373 | Context::setDBInfo($db_info); |
@@ -387,19 +387,19 @@ discard block |
||
387 | 387 | */ |
388 | 388 | public function pbkdf2($password, $salt, $algorithm = 'sha256', $iterations = 8192, $length = 24) |
389 | 389 | { |
390 | - if(function_exists('hash_pbkdf2')) |
|
390 | + if (function_exists('hash_pbkdf2')) |
|
391 | 391 | { |
392 | 392 | return hash_pbkdf2($algorithm, $password, $salt, $iterations, $length, true); |
393 | 393 | } |
394 | 394 | else |
395 | 395 | { |
396 | 396 | $output = ''; |
397 | - $block_count = ceil($length / strlen(hash($algorithm, '', true))); // key length divided by the length of one hash |
|
398 | - for($i = 1; $i <= $block_count; $i++) |
|
397 | + $block_count = ceil($length / strlen(hash($algorithm, '', true))); // key length divided by the length of one hash |
|
398 | + for ($i = 1; $i <= $block_count; $i++) |
|
399 | 399 | { |
400 | - $last = $salt . pack('N', $i); // $i encoded as 4 bytes, big endian |
|
401 | - $last = $xorsum = hash_hmac($algorithm, $last, $password, true); // first iteration |
|
402 | - for($j = 1; $j < $iterations; $j++) // The other $count - 1 iterations |
|
400 | + $last = $salt.pack('N', $i); // $i encoded as 4 bytes, big endian |
|
401 | + $last = $xorsum = hash_hmac($algorithm, $last, $password, true); // first iteration |
|
402 | + for ($j = 1; $j < $iterations; $j++) // The other $count - 1 iterations |
|
403 | 403 | { |
404 | 404 | $xorsum ^= ($last = hash_hmac($algorithm, $last, $password, true)); |
405 | 405 | } |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | */ |
418 | 418 | public function bcrypt($password, $salt = null) |
419 | 419 | { |
420 | - if($salt === null) |
|
420 | + if ($salt === null) |
|
421 | 421 | { |
422 | 422 | $salt = '$2y$'.sprintf('%02d', $this->getWorkFactor()).'$'.$this->createSecureSalt(22, 'alnum'); |
423 | 423 | } |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | { |
435 | 435 | $diff = strlen($a) ^ strlen($b); |
436 | 436 | $maxlen = min(strlen($a), strlen($b)); |
437 | - for($i = 0; $i < $maxlen; $i++) |
|
437 | + for ($i = 0; $i < $maxlen; $i++) |
|
438 | 438 | { |
439 | 439 | $diff |= ord($a[$i]) ^ ord($b[$i]); |
440 | 440 | } |
@@ -60,12 +60,10 @@ discard block |
||
60 | 60 | if($use_context) |
61 | 61 | { |
62 | 62 | $var = Context::get($varName0); |
63 | - } |
|
64 | - elseif($varName0) |
|
63 | + } elseif($varName0) |
|
65 | 64 | { |
66 | 65 | $var = $is_object ? $this->_targetVar->{$varName0} : $this->_targetVar[$varName0]; |
67 | - } |
|
68 | - else |
|
66 | + } else |
|
69 | 67 | { |
70 | 68 | $var = $this->_targetVar; |
71 | 69 | } |
@@ -79,19 +77,16 @@ discard block |
||
79 | 77 | if($use_context) |
80 | 78 | { |
81 | 79 | Context::set($varName0, $var); |
82 | - } |
|
83 | - elseif($varName0) |
|
80 | + } elseif($varName0) |
|
84 | 81 | { |
85 | 82 | if($is_object) |
86 | 83 | { |
87 | 84 | $this->_targetVar->{$varName0} = $var; |
88 | - } |
|
89 | - else |
|
85 | + } else |
|
90 | 86 | { |
91 | 87 | $this->_targetVar[$varName0] = $var; |
92 | 88 | } |
93 | - } |
|
94 | - else |
|
89 | + } else |
|
95 | 90 | { |
96 | 91 | $this->_targetVar = $var; |
97 | 92 | } |
@@ -142,8 +137,7 @@ discard block |
||
142 | 137 | if($is_object) |
143 | 138 | { |
144 | 139 | $var->{$name0} = $target; |
145 | - } |
|
146 | - else |
|
140 | + } else |
|
147 | 141 | { |
148 | 142 | $var[$name0] = $target; |
149 | 143 | } |
@@ -165,8 +159,7 @@ discard block |
||
165 | 159 | if($is_object) |
166 | 160 | { |
167 | 161 | $var->{$key} = $target; |
168 | - } |
|
169 | - else |
|
162 | + } else |
|
170 | 163 | { |
171 | 164 | $var[$key] = $target; |
172 | 165 | } |
@@ -185,7 +178,9 @@ discard block |
||
185 | 178 | */ |
186 | 179 | static function detectingXEE($xml) |
187 | 180 | { |
188 | - if(!$xml) return FALSE; |
|
181 | + if(!$xml) { |
|
182 | + return FALSE; |
|
183 | + } |
|
189 | 184 | |
190 | 185 | if(strpos($xml, '<!ENTITY') !== FALSE) |
191 | 186 | { |
@@ -37,15 +37,15 @@ discard block |
||
37 | 37 | function encodeHTML(/* , $varName1, $varName2, ... */) |
38 | 38 | { |
39 | 39 | $varNames = func_get_args(); |
40 | - if(count($varNames) < 0) |
|
40 | + if (count($varNames) < 0) |
|
41 | 41 | { |
42 | 42 | return FALSE; |
43 | 43 | } |
44 | 44 | |
45 | 45 | $use_context = is_null($this->_targetVar); |
46 | - if(!$use_context) |
|
46 | + if (!$use_context) |
|
47 | 47 | { |
48 | - if(!count($varNames) || (!is_object($this->_targetVar) && !is_array($this->_targetVar))) |
|
48 | + if (!count($varNames) || (!is_object($this->_targetVar) && !is_array($this->_targetVar))) |
|
49 | 49 | { |
50 | 50 | return $this->_encodeHTML($this->_targetVar); |
51 | 51 | } |
@@ -53,15 +53,15 @@ discard block |
||
53 | 53 | $is_object = is_object($this->_targetVar); |
54 | 54 | } |
55 | 55 | |
56 | - foreach($varNames as $varName) |
|
56 | + foreach ($varNames as $varName) |
|
57 | 57 | { |
58 | 58 | $varName = explode('.', $varName); |
59 | 59 | $varName0 = array_shift($varName); |
60 | - if($use_context) |
|
60 | + if ($use_context) |
|
61 | 61 | { |
62 | 62 | $var = Context::get($varName0); |
63 | 63 | } |
64 | - elseif($varName0) |
|
64 | + elseif ($varName0) |
|
65 | 65 | { |
66 | 66 | $var = $is_object ? $this->_targetVar->{$varName0} : $this->_targetVar[$varName0]; |
67 | 67 | } |
@@ -71,18 +71,18 @@ discard block |
||
71 | 71 | } |
72 | 72 | $var = $this->_encodeHTML($var, $varName); |
73 | 73 | |
74 | - if($var === FALSE) |
|
74 | + if ($var === FALSE) |
|
75 | 75 | { |
76 | 76 | continue; |
77 | 77 | } |
78 | 78 | |
79 | - if($use_context) |
|
79 | + if ($use_context) |
|
80 | 80 | { |
81 | 81 | Context::set($varName0, $var); |
82 | 82 | } |
83 | - elseif($varName0) |
|
83 | + elseif ($varName0) |
|
84 | 84 | { |
85 | - if($is_object) |
|
85 | + if ($is_object) |
|
86 | 86 | { |
87 | 87 | $this->_targetVar->{$varName0} = $var; |
88 | 88 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | - if(!$use_context) |
|
100 | + if (!$use_context) |
|
101 | 101 | { |
102 | 102 | return $this->_targetVar; |
103 | 103 | } |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | */ |
112 | 112 | function _encodeHTML($var, $name = array()) |
113 | 113 | { |
114 | - if(is_string($var)) |
|
114 | + if (is_string($var)) |
|
115 | 115 | { |
116 | - if(strncmp('$user_lang->', $var, 12) !== 0) |
|
116 | + if (strncmp('$user_lang->', $var, 12) !== 0) |
|
117 | 117 | { |
118 | 118 | $var = htmlspecialchars($var, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
119 | 119 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | return $var; |
122 | 122 | } |
123 | 123 | |
124 | - if(!count($name) || (!is_array($var) && !is_object($var))) |
|
124 | + if (!count($name) || (!is_array($var) && !is_object($var))) |
|
125 | 125 | { |
126 | 126 | return false; |
127 | 127 | } |
@@ -129,17 +129,17 @@ discard block |
||
129 | 129 | $is_object = is_object($var); |
130 | 130 | $name0 = array_shift($name); |
131 | 131 | |
132 | - if(strlen($name0)) |
|
132 | + if (strlen($name0)) |
|
133 | 133 | { |
134 | 134 | $target = $is_object ? $var->{$name0} : $var[$name0]; |
135 | 135 | $target = $this->_encodeHTML($target, $name); |
136 | 136 | |
137 | - if($target === false) |
|
137 | + if ($target === false) |
|
138 | 138 | { |
139 | 139 | return $var; |
140 | 140 | } |
141 | 141 | |
142 | - if($is_object) |
|
142 | + if ($is_object) |
|
143 | 143 | { |
144 | 144 | $var->{$name0} = $target; |
145 | 145 | } |
@@ -151,18 +151,18 @@ discard block |
||
151 | 151 | return $var; |
152 | 152 | } |
153 | 153 | |
154 | - foreach($var as $key => $target) |
|
154 | + foreach ($var as $key => $target) |
|
155 | 155 | { |
156 | 156 | $cloned_name = array_slice($name, 0); |
157 | 157 | $target = $this->_encodeHTML($target, $name); |
158 | 158 | $name = $cloned_name; |
159 | 159 | |
160 | - if($target === false) |
|
160 | + if ($target === false) |
|
161 | 161 | { |
162 | 162 | continue; |
163 | 163 | } |
164 | 164 | |
165 | - if($is_object) |
|
165 | + if ($is_object) |
|
166 | 166 | { |
167 | 167 | $var->{$key} = $target; |
168 | 168 | } |
@@ -185,9 +185,9 @@ discard block |
||
185 | 185 | */ |
186 | 186 | static function detectingXEE($xml) |
187 | 187 | { |
188 | - if(!$xml) return FALSE; |
|
188 | + if (!$xml) return FALSE; |
|
189 | 189 | |
190 | - if(strpos($xml, '<!ENTITY') !== FALSE) |
|
190 | + if (strpos($xml, '<!ENTITY') !== FALSE) |
|
191 | 191 | { |
192 | 192 | return TRUE; |
193 | 193 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | // Strip XML declaration. |
196 | 196 | $header = preg_replace('/<\?xml.*?\?'.'>/s', '', substr($xml, 0, 100), 1); |
197 | 197 | $xml = trim(substr_replace($xml, $header, 0, 100)); |
198 | - if($xml == '') |
|
198 | + if ($xml == '') |
|
199 | 199 | { |
200 | 200 | return TRUE; |
201 | 201 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | // Strip DTD. |
204 | 204 | $header = preg_replace('/^<!DOCTYPE[^>]*+>/i', '', substr($xml, 0, 200), 1); |
205 | 205 | $xml = trim(substr_replace($xml, $header, 0, 200)); |
206 | - if($xml == '') |
|
206 | + if ($xml == '') |
|
207 | 207 | { |
208 | 208 | return TRUE; |
209 | 209 | } |
@@ -212,12 +212,12 @@ discard block |
||
212 | 212 | $root_tag = substr($xml, 0, strcspn(substr($xml, 0, 20), "> \t\r\n")); |
213 | 213 | |
214 | 214 | // Reject a second DTD. |
215 | - if(strtoupper($root_tag) == '<!DOCTYPE') |
|
215 | + if (strtoupper($root_tag) == '<!DOCTYPE') |
|
216 | 216 | { |
217 | 217 | return TRUE; |
218 | 218 | } |
219 | 219 | |
220 | - if(!in_array($root_tag, array('<methodCall', '<methodResponse', '<fault'))) |
|
220 | + if (!in_array($root_tag, array('<methodCall', '<methodResponse', '<fault'))) |
|
221 | 221 | { |
222 | 222 | return TRUE; |
223 | 223 | } |