@@ -35,47 +35,47 @@ discard block |
||
35 | 35 | */ |
36 | 36 | |
37 | 37 | $kses_allowedentitynames = array( |
38 | - 'nbsp', 'iexcl', 'cent', 'pound', 'curren', 'yen', |
|
39 | - 'brvbar', 'sect', 'uml', 'copy', 'ordf', 'laquo', |
|
40 | - 'not', 'shy', 'reg', 'macr', 'deg', 'plusmn', |
|
41 | - 'acute', 'micro', 'para', 'middot', 'cedil', 'ordm', |
|
42 | - 'raquo', 'iquest', 'Agrave', 'Aacute', 'Acirc', 'Atilde', |
|
43 | - 'Auml', 'Aring', 'AElig', 'Ccedil', 'Egrave', 'Eacute', |
|
44 | - 'Ecirc', 'Euml', 'Igrave', 'Iacute', 'Icirc', 'Iuml', |
|
45 | - 'ETH', 'Ntilde', 'Ograve', 'Oacute', 'Ocirc', 'Otilde', |
|
46 | - 'Ouml', 'times', 'Oslash', 'Ugrave', 'Uacute', 'Ucirc', |
|
47 | - 'Uuml', 'Yacute', 'THORN', 'szlig', 'agrave', 'aacute', |
|
48 | - 'acirc', 'atilde', 'auml', 'aring', 'aelig', 'ccedil', |
|
49 | - 'egrave', 'eacute', 'ecirc', 'euml', 'igrave', 'iacute', |
|
50 | - 'icirc', 'iuml', 'eth', 'ntilde', 'ograve', 'oacute', |
|
51 | - 'ocirc', 'otilde', 'ouml', 'divide', 'oslash', 'ugrave', |
|
52 | - 'uacute', 'ucirc', 'uuml', 'yacute', 'thorn', 'yuml', |
|
53 | - 'quot', 'amp', 'lt', 'gt', 'apos', 'OElig', |
|
54 | - 'oelig', 'Scaron', 'scaron', 'Yuml', 'circ', 'tilde', |
|
55 | - 'ensp', 'emsp', 'thinsp', 'zwnj', 'zwj', 'lrm', |
|
56 | - 'rlm', 'ndash', 'mdash', 'lsquo', 'rsquo', 'sbquo', |
|
57 | - 'ldquo', 'rdquo', 'bdquo', 'dagger', 'Dagger', 'permil', |
|
58 | - 'lsaquo', 'rsaquo', 'euro', 'fnof', 'Alpha', 'Beta', |
|
59 | - 'Gamma', 'Delta', 'Epsilon', 'Zeta', 'Eta', 'Theta', |
|
60 | - 'Iota', 'Kappa', 'Lambda', 'Mu', 'Nu', 'Xi', |
|
61 | - 'Omicron', 'Pi', 'Rho', 'Sigma', 'Tau', 'Upsilon', |
|
62 | - 'Phi', 'Chi', 'Psi', 'Omega', 'alpha', 'beta', |
|
63 | - 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', |
|
64 | - 'iota', 'kappa', 'lambda', 'mu', 'nu', 'xi', |
|
65 | - 'omicron', 'pi', 'rho', 'sigmaf', 'sigma', 'tau', |
|
66 | - 'upsilon', 'phi', 'chi', 'psi', 'omega', 'thetasym', |
|
67 | - 'upsih', 'piv', 'bull', 'hellip', 'prime', 'Prime', |
|
68 | - 'oline', 'frasl', 'weierp', 'image', 'real', 'trade', |
|
69 | - 'alefsym', 'larr', 'uarr', 'rarr', 'darr', 'harr', |
|
70 | - 'crarr', 'lArr', 'uArr', 'rArr', 'dArr', 'hArr', |
|
71 | - 'forall', 'part', 'exist', 'empty', 'nabla', 'isin', |
|
72 | - 'notin', 'ni', 'prod', 'sum', 'minus', 'lowast', |
|
73 | - 'radic', 'prop', 'infin', 'ang', 'and', 'or', |
|
74 | - 'cap', 'cup', 'int', 'sim', 'cong', 'asymp', |
|
75 | - 'ne', 'equiv', 'le', 'ge', 'sub', 'sup', |
|
76 | - 'nsub', 'sube', 'supe', 'oplus', 'otimes', 'perp', |
|
77 | - 'sdot', 'lceil', 'rceil', 'lfloor', 'rfloor', 'lang', |
|
78 | - 'rang', 'loz', 'spades', 'clubs', 'hearts', 'diams', |
|
38 | + 'nbsp', 'iexcl', 'cent', 'pound', 'curren', 'yen', |
|
39 | + 'brvbar', 'sect', 'uml', 'copy', 'ordf', 'laquo', |
|
40 | + 'not', 'shy', 'reg', 'macr', 'deg', 'plusmn', |
|
41 | + 'acute', 'micro', 'para', 'middot', 'cedil', 'ordm', |
|
42 | + 'raquo', 'iquest', 'Agrave', 'Aacute', 'Acirc', 'Atilde', |
|
43 | + 'Auml', 'Aring', 'AElig', 'Ccedil', 'Egrave', 'Eacute', |
|
44 | + 'Ecirc', 'Euml', 'Igrave', 'Iacute', 'Icirc', 'Iuml', |
|
45 | + 'ETH', 'Ntilde', 'Ograve', 'Oacute', 'Ocirc', 'Otilde', |
|
46 | + 'Ouml', 'times', 'Oslash', 'Ugrave', 'Uacute', 'Ucirc', |
|
47 | + 'Uuml', 'Yacute', 'THORN', 'szlig', 'agrave', 'aacute', |
|
48 | + 'acirc', 'atilde', 'auml', 'aring', 'aelig', 'ccedil', |
|
49 | + 'egrave', 'eacute', 'ecirc', 'euml', 'igrave', 'iacute', |
|
50 | + 'icirc', 'iuml', 'eth', 'ntilde', 'ograve', 'oacute', |
|
51 | + 'ocirc', 'otilde', 'ouml', 'divide', 'oslash', 'ugrave', |
|
52 | + 'uacute', 'ucirc', 'uuml', 'yacute', 'thorn', 'yuml', |
|
53 | + 'quot', 'amp', 'lt', 'gt', 'apos', 'OElig', |
|
54 | + 'oelig', 'Scaron', 'scaron', 'Yuml', 'circ', 'tilde', |
|
55 | + 'ensp', 'emsp', 'thinsp', 'zwnj', 'zwj', 'lrm', |
|
56 | + 'rlm', 'ndash', 'mdash', 'lsquo', 'rsquo', 'sbquo', |
|
57 | + 'ldquo', 'rdquo', 'bdquo', 'dagger', 'Dagger', 'permil', |
|
58 | + 'lsaquo', 'rsaquo', 'euro', 'fnof', 'Alpha', 'Beta', |
|
59 | + 'Gamma', 'Delta', 'Epsilon', 'Zeta', 'Eta', 'Theta', |
|
60 | + 'Iota', 'Kappa', 'Lambda', 'Mu', 'Nu', 'Xi', |
|
61 | + 'Omicron', 'Pi', 'Rho', 'Sigma', 'Tau', 'Upsilon', |
|
62 | + 'Phi', 'Chi', 'Psi', 'Omega', 'alpha', 'beta', |
|
63 | + 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', |
|
64 | + 'iota', 'kappa', 'lambda', 'mu', 'nu', 'xi', |
|
65 | + 'omicron', 'pi', 'rho', 'sigmaf', 'sigma', 'tau', |
|
66 | + 'upsilon', 'phi', 'chi', 'psi', 'omega', 'thetasym', |
|
67 | + 'upsih', 'piv', 'bull', 'hellip', 'prime', 'Prime', |
|
68 | + 'oline', 'frasl', 'weierp', 'image', 'real', 'trade', |
|
69 | + 'alefsym', 'larr', 'uarr', 'rarr', 'darr', 'harr', |
|
70 | + 'crarr', 'lArr', 'uArr', 'rArr', 'dArr', 'hArr', |
|
71 | + 'forall', 'part', 'exist', 'empty', 'nabla', 'isin', |
|
72 | + 'notin', 'ni', 'prod', 'sum', 'minus', 'lowast', |
|
73 | + 'radic', 'prop', 'infin', 'ang', 'and', 'or', |
|
74 | + 'cap', 'cup', 'int', 'sim', 'cong', 'asymp', |
|
75 | + 'ne', 'equiv', 'le', 'ge', 'sub', 'sup', |
|
76 | + 'nsub', 'sube', 'supe', 'oplus', 'otimes', 'perp', |
|
77 | + 'sdot', 'lceil', 'rceil', 'lfloor', 'rfloor', 'lang', |
|
78 | + 'rang', 'loz', 'spades', 'clubs', 'hearts', 'diams', |
|
79 | 79 | ); |
80 | 80 | |
81 | 81 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | global $pass_allowed_html, $pass_allowed_protocols; |
146 | 146 | $pass_allowed_html = $allowed_html; |
147 | 147 | $pass_allowed_protocols = $allowed_protocols; |
148 | - return preg_replace_callback( '%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%', '_kses_split_callback', $string ); |
|
148 | + return preg_replace_callback('%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%', '_kses_split_callback', $string); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | * |
154 | 154 | * @access private |
155 | 155 | */ |
156 | -function _kses_split_callback( $match ) |
|
156 | +function _kses_split_callback($match) |
|
157 | 157 | { |
158 | 158 | global $pass_allowed_html, $pass_allowed_protocols; |
159 | - return kses_split2( $match[1], $pass_allowed_html, $pass_allowed_protocols ); |
|
159 | + return kses_split2($match[1], $pass_allowed_html, $pass_allowed_protocols); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -189,9 +189,9 @@ discard block |
||
189 | 189 | |
190 | 190 | if (preg_match('%^<!--(.*?)(-->)?$%', $string, $matches)) { |
191 | 191 | $string = str_replace(array('<!--', '-->'), '', $matches[1]); |
192 | - while ( $string != $newstring = kses($string, $allowed_html, $allowed_protocols) ) |
|
192 | + while ($string != $newstring = kses($string, $allowed_html, $allowed_protocols)) |
|
193 | 193 | $string = $newstring; |
194 | - if ( $string == '' ) |
|
194 | + if ($string == '') |
|
195 | 195 | return ''; |
196 | 196 | // prevent multiple dashes in comments |
197 | 197 | $string = preg_replace('/--+/', '-', $string); |
@@ -282,12 +282,12 @@ discard block |
||
282 | 282 | $currkey, $currval)) |
283 | 283 | { $ok = false; break; } |
284 | 284 | |
285 | - if ( strtolower($arreach['name']) == 'style' ) { |
|
285 | + if (strtolower($arreach['name']) == 'style') { |
|
286 | 286 | $orig_value = $arreach['value']; |
287 | 287 | |
288 | 288 | $value = kses_safecss_filter_attr($orig_value); |
289 | 289 | |
290 | - if ( empty($value) ) |
|
290 | + if (empty($value)) |
|
291 | 291 | continue; |
292 | 292 | |
293 | 293 | $arreach['value'] = $value; |
@@ -361,8 +361,8 @@ discard block |
||
361 | 361 | if (preg_match('/^\s+/', $attr)) // valueless |
362 | 362 | { |
363 | 363 | $working = 1; $mode = 0; |
364 | - if(FALSE === array_key_exists($attrname, $attrarr)) { |
|
365 | - $attrarr[$attrname] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y'); |
|
364 | + if (FALSE === array_key_exists($attrname, $attrarr)) { |
|
365 | + $attrarr[$attrname] = array('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y'); |
|
366 | 366 | } |
367 | 367 | $attr = preg_replace('/^\s+/', '', $attr); |
368 | 368 | } |
@@ -379,12 +379,12 @@ discard block |
||
379 | 379 | $thisval = $match[1]; |
380 | 380 | } else { |
381 | 381 | $thisval = $match[1]; |
382 | - if ( in_array(strtolower($attrname), $uris) ) |
|
382 | + if (in_array(strtolower($attrname), $uris)) |
|
383 | 383 | $thisval = kses_bad_protocol($thisval, $allowed_protocols); |
384 | 384 | } |
385 | 385 | |
386 | - if(FALSE === array_key_exists($attrname, $attrarr)) { |
|
387 | - $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n'); |
|
386 | + if (FALSE === array_key_exists($attrname, $attrarr)) { |
|
387 | + $attrarr[$attrname] = array('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n'); |
|
388 | 388 | } |
389 | 389 | $working = 1; $mode = 0; |
390 | 390 | $attr = preg_replace('/^"[^"]*"(\s+|$)/', '', $attr); |
@@ -395,11 +395,11 @@ discard block |
||
395 | 395 | // 'value' |
396 | 396 | { |
397 | 397 | $thisval = $match[1]; |
398 | - if ( in_array(strtolower($attrname), $uris) ) |
|
398 | + if (in_array(strtolower($attrname), $uris)) |
|
399 | 399 | $thisval = kses_bad_protocol($thisval, $allowed_protocols); |
400 | 400 | |
401 | - if(FALSE === array_key_exists($attrname, $attrarr)) { |
|
402 | - $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname='$thisval'", 'vless' => 'n'); |
|
401 | + if (FALSE === array_key_exists($attrname, $attrarr)) { |
|
402 | + $attrarr[$attrname] = array('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname='$thisval'", 'vless' => 'n'); |
|
403 | 403 | } |
404 | 404 | $working = 1; $mode = 0; |
405 | 405 | $attr = preg_replace("/^'[^']*'(\s+|$)/", '', $attr); |
@@ -410,11 +410,11 @@ discard block |
||
410 | 410 | // value |
411 | 411 | { |
412 | 412 | $thisval = $match[1]; |
413 | - if ( in_array(strtolower($attrname), $uris) ) |
|
413 | + if (in_array(strtolower($attrname), $uris)) |
|
414 | 414 | $thisval = kses_bad_protocol($thisval, $allowed_protocols); |
415 | 415 | |
416 | - if(FALSE === array_key_exists($attrname, $attrarr)) { |
|
417 | - $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n'); |
|
416 | + if (FALSE === array_key_exists($attrname, $attrarr)) { |
|
417 | + $attrarr[$attrname] = array('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n'); |
|
418 | 418 | } |
419 | 419 | // We add quotes to conform to W3C's HTML spec. |
420 | 420 | $working = 1; $mode = 0; |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | if ($mode == 1 && FALSE === array_key_exists($attrname, $attrarr)) |
435 | 435 | // special case, for when the attribute list ends with a valueless |
436 | 436 | // attribute like "selected" |
437 | - $attrarr[$attrname] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y'); |
|
437 | + $attrarr[$attrname] = array('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y'); |
|
438 | 438 | |
439 | 439 | return $attrarr; |
440 | 440 | } |
@@ -579,12 +579,12 @@ discard block |
||
579 | 579 | { |
580 | 580 | $outarray = array(); |
581 | 581 | |
582 | - foreach ( (array) $inarray as $inkey => $inval) |
|
582 | + foreach ((array) $inarray as $inkey => $inval) |
|
583 | 583 | { |
584 | 584 | $outkey = strtolower($inkey); |
585 | 585 | $outarray[$outkey] = array(); |
586 | 586 | |
587 | - foreach ( (array) $inval as $inkey2 => $inval2) |
|
587 | + foreach ((array) $inval as $inkey2 => $inval2) |
|
588 | 588 | { |
589 | 589 | $outkey2 = strtolower($inkey2); |
590 | 590 | $outarray[$outkey][$outkey2] = $inval2; |
@@ -632,9 +632,9 @@ discard block |
||
632 | 632 | function kses_bad_protocol_once($string, $allowed_protocols) |
633 | 633 | { |
634 | 634 | $string2 = preg_split('/:|�*58;|�*3a;/i', $string, 2); |
635 | - if(isset($string2[1]) && !preg_match('%/\?%',$string2[0])) |
|
635 | + if (isset($string2[1]) && !preg_match('%/\?%', $string2[0])) |
|
636 | 636 | { |
637 | - $string = kses_bad_protocol_once2($string2[0],$allowed_protocols).trim($string2[1]); |
|
637 | + $string = kses_bad_protocol_once2($string2[0], $allowed_protocols).trim($string2[1]); |
|
638 | 638 | } |
639 | 639 | return $string; |
640 | 640 | } |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | $string2 = strtolower($string2); |
661 | 661 | |
662 | 662 | $allowed = false; |
663 | - foreach ( (array) $allowed_protocols as $one_protocol) |
|
663 | + foreach ((array) $allowed_protocols as $one_protocol) |
|
664 | 664 | if (strtolower($one_protocol) == $string2) |
665 | 665 | { |
666 | 666 | $allowed = true; |
@@ -711,11 +711,11 @@ discard block |
||
711 | 711 | function kses_named_entities($matches) { |
712 | 712 | global $kses_allowedentitynames; |
713 | 713 | |
714 | - if ( empty($matches[1]) ) |
|
714 | + if (empty($matches[1])) |
|
715 | 715 | return ''; |
716 | 716 | |
717 | 717 | $i = $matches[1]; |
718 | - return ( ( ! in_array($i, $kses_allowedentitynames) ) ? "&$i;" : "&$i;" ); |
|
718 | + return ((!in_array($i, $kses_allowedentitynames)) ? "&$i;" : "&$i;"); |
|
719 | 719 | } |
720 | 720 | |
721 | 721 | /** |
@@ -730,12 +730,12 @@ discard block |
||
730 | 730 | * @return string Correctly encoded entity |
731 | 731 | */ |
732 | 732 | function kses_normalize_entities2($matches) { |
733 | - if ( empty($matches[1]) ) |
|
733 | + if (empty($matches[1])) |
|
734 | 734 | return ''; |
735 | 735 | |
736 | 736 | $i = $matches[1]; |
737 | 737 | if (kses_valid_unicode($i)) { |
738 | - $i = str_pad(ltrim($i,'0'), 3, '0', STR_PAD_LEFT); |
|
738 | + $i = str_pad(ltrim($i, '0'), 3, '0', STR_PAD_LEFT); |
|
739 | 739 | $i = "&#$i;"; |
740 | 740 | } else { |
741 | 741 | $i = "&#$i;"; |
@@ -756,11 +756,11 @@ discard block |
||
756 | 756 | * @return string Correctly encoded entity |
757 | 757 | */ |
758 | 758 | function kses_normalize_entities3($matches) { |
759 | - if ( empty($matches[1]) ) |
|
759 | + if (empty($matches[1])) |
|
760 | 760 | return ''; |
761 | 761 | |
762 | 762 | $hexchars = $matches[1]; |
763 | - return ( ( ! kses_valid_unicode(hexdec($hexchars)) ) ? "&#x$hexchars;" : '&#x'.ltrim($hexchars,'0').';' ); |
|
763 | + return ((!kses_valid_unicode(hexdec($hexchars))) ? "&#x$hexchars;" : '&#x'.ltrim($hexchars, '0').';'); |
|
764 | 764 | } |
765 | 765 | |
766 | 766 | /** |
@@ -770,10 +770,10 @@ discard block |
||
770 | 770 | * @return bool true if the value was a valid Unicode number |
771 | 771 | */ |
772 | 772 | function kses_valid_unicode($i) { |
773 | - return ( $i == 0x9 || $i == 0xa || $i == 0xd || |
|
773 | + return ($i == 0x9 || $i == 0xa || $i == 0xd || |
|
774 | 774 | ($i >= 0x20 && $i <= 0xd7ff) || |
775 | 775 | ($i >= 0xe000 && $i <= 0xfffd) || |
776 | - ($i >= 0x10000 && $i <= 0x10ffff) ); |
|
776 | + ($i >= 0x10000 && $i <= 0x10ffff)); |
|
777 | 777 | } |
778 | 778 | |
779 | 779 | /** |
@@ -800,8 +800,8 @@ discard block |
||
800 | 800 | * @param array $match preg match |
801 | 801 | * @return string |
802 | 802 | */ |
803 | -function _kses_decode_entities_chr( $match ) { |
|
804 | - return chr( $match[1] ); |
|
803 | +function _kses_decode_entities_chr($match) { |
|
804 | + return chr($match[1]); |
|
805 | 805 | } |
806 | 806 | |
807 | 807 | /** |
@@ -810,24 +810,24 @@ discard block |
||
810 | 810 | * @param array $match preg match |
811 | 811 | * @return string |
812 | 812 | */ |
813 | -function _kses_decode_entities_chr_hexdec( $match ) { |
|
814 | - return chr( hexdec( $match[1] ) ); |
|
813 | +function _kses_decode_entities_chr_hexdec($match) { |
|
814 | + return chr(hexdec($match[1])); |
|
815 | 815 | } |
816 | 816 | |
817 | 817 | /** |
818 | 818 | * Inline CSS filter |
819 | 819 | * |
820 | 820 | */ |
821 | -function kses_safecss_filter_attr( $css ) { |
|
821 | +function kses_safecss_filter_attr($css) { |
|
822 | 822 | |
823 | 823 | $css = kses_no_null($css); |
824 | - $css = str_replace(array("\n","\r","\t"), '', $css); |
|
824 | + $css = str_replace(array("\n", "\r", "\t"), '', $css); |
|
825 | 825 | |
826 | - if ( preg_match( '%[\\(&=}]|/\*%', $css ) ) // remove any inline css containing \ ( & } = or comments |
|
826 | + if (preg_match('%[\\(&=}]|/\*%', $css)) // remove any inline css containing \ ( & } = or comments |
|
827 | 827 | return ''; |
828 | 828 | |
829 | - $css_array = explode( ';', trim( $css ) ); |
|
830 | - $allowed_attr = array( 'text-align', 'margin', 'color', 'float', |
|
829 | + $css_array = explode(';', trim($css)); |
|
830 | + $allowed_attr = array('text-align', 'margin', 'color', 'float', |
|
831 | 831 | 'border', 'background', 'background-color', 'border-bottom', 'border-bottom-color', |
832 | 832 | 'border-bottom-style', 'border-bottom-width', 'border-collapse', 'border-color', 'border-left', |
833 | 833 | 'border-left-color', 'border-left-style', 'border-left-width', 'border-right', 'border-right-color', |
@@ -837,26 +837,26 @@ discard block |
||
837 | 837 | 'font-variant', 'font-weight', 'height', 'letter-spacing', 'line-height', 'margin-bottom', |
838 | 838 | 'margin-left', 'margin-right', 'margin-top', 'overflow', 'padding', 'padding-bottom', |
839 | 839 | 'padding-left', 'padding-right', 'padding-top', 'text-decoration', 'text-indent', 'vertical-align', |
840 | - 'width' ); |
|
840 | + 'width'); |
|
841 | 841 | |
842 | - if ( empty($allowed_attr) ) |
|
842 | + if (empty($allowed_attr)) |
|
843 | 843 | return $css; |
844 | 844 | |
845 | 845 | $css = ''; |
846 | - foreach ( $css_array as $css_item ) { |
|
847 | - if ( $css_item == '' ) |
|
846 | + foreach ($css_array as $css_item) { |
|
847 | + if ($css_item == '') |
|
848 | 848 | continue; |
849 | - $css_item = trim( $css_item ); |
|
849 | + $css_item = trim($css_item); |
|
850 | 850 | $found = false; |
851 | - if ( strpos( $css_item, ':' ) === false ) { |
|
851 | + if (strpos($css_item, ':') === false) { |
|
852 | 852 | $found = true; |
853 | 853 | } else { |
854 | - $parts = split( ':', $css_item ); |
|
855 | - if ( in_array( strtolower( trim( $parts[0] ) ), $allowed_attr ) ) |
|
854 | + $parts = split(':', $css_item); |
|
855 | + if (in_array(strtolower(trim($parts[0])), $allowed_attr)) |
|
856 | 856 | $found = true; |
857 | 857 | } |
858 | - if ( $found ) { |
|
859 | - if( $css != '' ) |
|
858 | + if ($found) { |
|
859 | + if ($css != '') |
|
860 | 860 | $css .= ';'; |
861 | 861 | $css .= $css_item; |
862 | 862 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @subpackage kses5 |
51 | 51 | */ |
52 | 52 | |
53 | - if(substr(phpversion(), 0, 1) < 5) |
|
53 | + if (substr(phpversion(), 0, 1) < 5) |
|
54 | 54 | { |
55 | 55 | die("Class kses requires PHP 5 or higher."); |
56 | 56 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | /** |
59 | 59 | * Only install KSES5 once |
60 | 60 | */ |
61 | - if(!defined('KSES_CLASS_PHP5')) |
|
61 | + if (!defined('KSES_CLASS_PHP5')) |
|
62 | 62 | { |
63 | 63 | define('KSES_CLASS_PHP5', true); |
64 | 64 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $string = preg_replace('%&\s*\{[^}]*(\}\s*;?|$)%', '', $string); |
156 | 156 | $string = $this->normalizeEntities($string); |
157 | 157 | $string = $this->filterKsesTextHook($string); |
158 | - $string = preg_replace('%(<' . '[^>]*' . '(>|$)' . '|>)%e', "\$this->stripTags('\\1')", $string); |
|
158 | + $string = preg_replace('%(<'.'[^>]*'.'(>|$)'.'|>)%e', "\$this->stripTags('\\1')", $string); |
|
159 | 159 | return $string; |
160 | 160 | } |
161 | 161 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | public function AddProtocols() |
178 | 178 | { |
179 | 179 | $c_args = func_num_args(); |
180 | - if($c_args != 1) |
|
180 | + if ($c_args != 1) |
|
181 | 181 | { |
182 | 182 | trigger_error("kses5::AddProtocols() did not receive an argument.", E_USER_WARNING); |
183 | 183 | return false; |
@@ -185,15 +185,15 @@ discard block |
||
185 | 185 | |
186 | 186 | $protocol_data = func_get_arg(0); |
187 | 187 | |
188 | - if(is_array($protocol_data) && count($protocol_data) > 0) |
|
188 | + if (is_array($protocol_data) && count($protocol_data) > 0) |
|
189 | 189 | { |
190 | - foreach($protocol_data as $protocol) |
|
190 | + foreach ($protocol_data as $protocol) |
|
191 | 191 | { |
192 | 192 | $this->AddProtocol($protocol); |
193 | 193 | } |
194 | 194 | return true; |
195 | 195 | } |
196 | - elseif(is_string($protocol_data)) |
|
196 | + elseif (is_string($protocol_data)) |
|
197 | 197 | { |
198 | 198 | $this->AddProtocol($protocol_data); |
199 | 199 | return true; |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | public function Protocols() |
217 | 217 | { |
218 | 218 | $c_args = func_num_args(); |
219 | - if($c_args != 1) |
|
219 | + if ($c_args != 1) |
|
220 | 220 | { |
221 | 221 | trigger_error("kses5::Protocols() did not receive an argument.", E_USER_WARNING); |
222 | 222 | return false; |
@@ -239,27 +239,27 @@ discard block |
||
239 | 239 | */ |
240 | 240 | public function AddProtocol($protocol = "") |
241 | 241 | { |
242 | - if(!is_string($protocol)) |
|
242 | + if (!is_string($protocol)) |
|
243 | 243 | { |
244 | 244 | trigger_error("kses5::AddProtocol() requires a string.", E_USER_WARNING); |
245 | 245 | return false; |
246 | 246 | } |
247 | 247 | |
248 | 248 | // Remove any inadvertent ':' at the end of the protocol. |
249 | - if(substr($protocol, strlen($protocol) - 1, 1) == ":") |
|
249 | + if (substr($protocol, strlen($protocol) - 1, 1) == ":") |
|
250 | 250 | { |
251 | 251 | $protocol = substr($protocol, 0, strlen($protocol) - 1); |
252 | 252 | } |
253 | 253 | |
254 | 254 | $protocol = strtolower(trim($protocol)); |
255 | - if($protocol == "") |
|
255 | + if ($protocol == "") |
|
256 | 256 | { |
257 | 257 | trigger_error("kses5::AddProtocol() tried to add an empty/NULL protocol.", E_USER_WARNING); |
258 | 258 | return false; |
259 | 259 | } |
260 | 260 | |
261 | 261 | // prevent duplicate protocols from being added. |
262 | - if(!in_array($protocol, $this->allowed_protocols)) |
|
262 | + if (!in_array($protocol, $this->allowed_protocols)) |
|
263 | 263 | { |
264 | 264 | array_push($this->allowed_protocols, $protocol); |
265 | 265 | sort($this->allowed_protocols); |
@@ -281,27 +281,27 @@ discard block |
||
281 | 281 | */ |
282 | 282 | public function RemoveProtocol($protocol = "") |
283 | 283 | { |
284 | - if(!is_string($protocol)) |
|
284 | + if (!is_string($protocol)) |
|
285 | 285 | { |
286 | 286 | trigger_error("kses5::RemoveProtocol() requires a string.", E_USER_WARNING); |
287 | 287 | return false; |
288 | 288 | } |
289 | 289 | |
290 | 290 | // Remove any inadvertent ':' at the end of the protocol. |
291 | - if(substr($protocol, strlen($protocol) - 1, 1) == ":") |
|
291 | + if (substr($protocol, strlen($protocol) - 1, 1) == ":") |
|
292 | 292 | { |
293 | 293 | $protocol = substr($protocol, 0, strlen($protocol) - 1); |
294 | 294 | } |
295 | 295 | |
296 | 296 | $protocol = strtolower(trim($protocol)); |
297 | - if($protocol == "") |
|
297 | + if ($protocol == "") |
|
298 | 298 | { |
299 | 299 | trigger_error("kses5::RemoveProtocol() tried to remove an empty/NULL protocol.", E_USER_WARNING); |
300 | 300 | return false; |
301 | 301 | } |
302 | 302 | |
303 | 303 | // Ensures that the protocol exists before removing it. |
304 | - if(in_array($protocol, $this->allowed_protocols)) |
|
304 | + if (in_array($protocol, $this->allowed_protocols)) |
|
305 | 305 | { |
306 | 306 | $this->allowed_protocols = array_diff($this->allowed_protocols, array($protocol)); |
307 | 307 | sort($this->allowed_protocols); |
@@ -328,21 +328,21 @@ discard block |
||
328 | 328 | public function RemoveProtocols() |
329 | 329 | { |
330 | 330 | $c_args = func_num_args(); |
331 | - if($c_args != 1) |
|
331 | + if ($c_args != 1) |
|
332 | 332 | { |
333 | 333 | return false; |
334 | 334 | } |
335 | 335 | |
336 | 336 | $protocol_data = func_get_arg(0); |
337 | 337 | |
338 | - if(is_array($protocol_data) && count($protocol_data) > 0) |
|
338 | + if (is_array($protocol_data) && count($protocol_data) > 0) |
|
339 | 339 | { |
340 | - foreach($protocol_data as $protocol) |
|
340 | + foreach ($protocol_data as $protocol) |
|
341 | 341 | { |
342 | 342 | $this->RemoveProtocol($protocol); |
343 | 343 | } |
344 | 344 | } |
345 | - elseif(is_string($protocol_data)) |
|
345 | + elseif (is_string($protocol_data)) |
|
346 | 346 | { |
347 | 347 | $this->RemoveProtocol($protocol_data); |
348 | 348 | return true; |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | public function SetProtocols() |
373 | 373 | { |
374 | 374 | $c_args = func_num_args(); |
375 | - if($c_args != 1) |
|
375 | + if ($c_args != 1) |
|
376 | 376 | { |
377 | 377 | trigger_error("kses5::SetProtocols() did not receive an argument.", E_USER_WARNING); |
378 | 378 | return false; |
@@ -380,16 +380,16 @@ discard block |
||
380 | 380 | |
381 | 381 | $protocol_data = func_get_arg(0); |
382 | 382 | |
383 | - if(is_array($protocol_data) && count($protocol_data) > 0) |
|
383 | + if (is_array($protocol_data) && count($protocol_data) > 0) |
|
384 | 384 | { |
385 | 385 | $this->allowed_protocols = array(); |
386 | - foreach($protocol_data as $protocol) |
|
386 | + foreach ($protocol_data as $protocol) |
|
387 | 387 | { |
388 | 388 | $this->AddProtocol($protocol); |
389 | 389 | } |
390 | 390 | return true; |
391 | 391 | } |
392 | - elseif(is_string($protocol_data)) |
|
392 | + elseif (is_string($protocol_data)) |
|
393 | 393 | { |
394 | 394 | $this->allowed_protocols = array(); |
395 | 395 | $this->AddProtocol($protocol_data); |
@@ -447,37 +447,37 @@ discard block |
||
447 | 447 | */ |
448 | 448 | public function AddHTML($tag = "", $attribs = array()) |
449 | 449 | { |
450 | - if(!is_string($tag)) |
|
450 | + if (!is_string($tag)) |
|
451 | 451 | { |
452 | 452 | trigger_error("kses5::AddHTML() requires the tag to be a string", E_USER_WARNING); |
453 | 453 | return false; |
454 | 454 | } |
455 | 455 | |
456 | 456 | $tag = strtolower(trim($tag)); |
457 | - if($tag == "") |
|
457 | + if ($tag == "") |
|
458 | 458 | { |
459 | 459 | trigger_error("kses5::AddHTML() tried to add an empty/NULL tag", E_USER_WARNING); |
460 | 460 | return false; |
461 | 461 | } |
462 | 462 | |
463 | - if(!is_array($attribs)) |
|
463 | + if (!is_array($attribs)) |
|
464 | 464 | { |
465 | 465 | trigger_error("kses5::AddHTML() requires an array (even an empty one) of attributes for '$tag'", E_USER_WARNING); |
466 | 466 | return false; |
467 | 467 | } |
468 | 468 | |
469 | 469 | $new_attribs = array(); |
470 | - if(is_array($attribs) && count($attribs) > 0) |
|
470 | + if (is_array($attribs) && count($attribs) > 0) |
|
471 | 471 | { |
472 | - foreach($attribs as $idx1 => $val1) |
|
472 | + foreach ($attribs as $idx1 => $val1) |
|
473 | 473 | { |
474 | 474 | $new_idx1 = strtolower($idx1); |
475 | 475 | $new_val1 = $attribs[$idx1]; |
476 | 476 | |
477 | - if(is_array($new_val1) && count($attribs) > 0) |
|
477 | + if (is_array($new_val1) && count($attribs) > 0) |
|
478 | 478 | { |
479 | 479 | $tmp_val = array(); |
480 | - foreach($new_val1 as $idx2 => $val2) |
|
480 | + foreach ($new_val1 as $idx2 => $val2) |
|
481 | 481 | { |
482 | 482 | $new_idx2 = strtolower($idx2); |
483 | 483 | $tmp_val[$new_idx2] = $val2; |
@@ -620,14 +620,14 @@ discard block |
||
620 | 620 | { |
621 | 621 | $out_array = array(); |
622 | 622 | |
623 | - if(is_array($in_array) && count($in_array) > 0) |
|
623 | + if (is_array($in_array) && count($in_array) > 0) |
|
624 | 624 | { |
625 | 625 | foreach ($in_array as $in_key => $in_val) |
626 | 626 | { |
627 | 627 | $out_key = strtolower($in_key); |
628 | 628 | $out_array[$out_key] = array(); |
629 | 629 | |
630 | - if(is_array($in_val) && count($in_val) > 0) |
|
630 | + if (is_array($in_val) && count($in_val) > 0) |
|
631 | 631 | { |
632 | 632 | foreach ($in_val as $in_key2 => $in_val2) |
633 | 633 | { |
@@ -732,11 +732,11 @@ discard block |
||
732 | 732 | # Go through $attrarr, and save the allowed attributes for this element |
733 | 733 | # in $attr2 |
734 | 734 | $attr2 = ''; |
735 | - if(is_array($attrarr) && count($attrarr) > 0) |
|
735 | + if (is_array($attrarr) && count($attrarr) > 0) |
|
736 | 736 | { |
737 | 737 | foreach ($attrarr as $arreach) |
738 | 738 | { |
739 | - if(!isset($this->allowed_html[strtolower($element)][strtolower($arreach['name'])])) |
|
739 | + if (!isset($this->allowed_html[strtolower($element)][strtolower($arreach['name'])])) |
|
740 | 740 | { |
741 | 741 | continue; |
742 | 742 | } |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | { |
753 | 753 | # there are some checks |
754 | 754 | $ok = true; |
755 | - if(is_array($current) && count($current) > 0) |
|
755 | + if (is_array($current) && count($current) > 0) |
|
756 | 756 | { |
757 | 757 | foreach ($current as $currkey => $currval) |
758 | 758 | { |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | 'whole' => $attrname, |
835 | 835 | 'vless' => 'y' |
836 | 836 | ); |
837 | - $attr = preg_replace('/^\s+/', '', $attr); |
|
837 | + $attr = preg_replace('/^\s+/', '', $attr); |
|
838 | 838 | } |
839 | 839 | break; |
840 | 840 | case 2: # attribute value, a URL after href= for instance |
@@ -844,7 +844,7 @@ discard block |
||
844 | 844 | $attrarr[] = array( |
845 | 845 | 'name' => $attrname, |
846 | 846 | 'value' => $thisval, |
847 | - 'whole' => $attrname . '="' . $thisval . '"', |
|
847 | + 'whole' => $attrname.'="'.$thisval.'"', |
|
848 | 848 | 'vless' => 'n' |
849 | 849 | ); |
850 | 850 | $working = 1; |
@@ -872,7 +872,7 @@ discard block |
||
872 | 872 | $attrarr[] = array( |
873 | 873 | 'name' => $attrname, |
874 | 874 | 'value' => $thisval, |
875 | - 'whole' => $attrname . '="' . $thisval . '"', |
|
875 | + 'whole' => $attrname.'="'.$thisval.'"', |
|
876 | 876 | 'vless' => 'n' |
877 | 877 | ); |
878 | 878 | # We add quotes to conform to W3C's HTML spec. |
@@ -922,10 +922,10 @@ discard block |
||
922 | 922 | { |
923 | 923 | $string = $this->RemoveNulls($string); |
924 | 924 | $string = preg_replace('/\xad+/', '', $string); # deals with Opera "feature" |
925 | - $string2 = $string . 'a'; |
|
925 | + $string2 = $string.'a'; |
|
926 | 926 | |
927 | 927 | $string2 = preg_split('/:|:|:/i', $string, 2); |
928 | - if(isset($string2[1]) && !preg_match('%/\?%',$string2[0])) |
|
928 | + if (isset($string2[1]) && !preg_match('%/\?%', $string2[0])) |
|
929 | 929 | { |
930 | 930 | $string = $this->filterProtocols($string2[0]).trim($string2[1]); |
931 | 931 | } |
@@ -952,7 +952,7 @@ discard block |
||
952 | 952 | $string = preg_replace('/\xad+/', '', $string2); # deals with Opera "feature" |
953 | 953 | $string = strtolower($string); |
954 | 954 | |
955 | - if(is_array($this->allowed_protocols) && count($this->allowed_protocols) > 0) |
|
955 | + if (is_array($this->allowed_protocols) && count($this->allowed_protocols) > 0) |
|
956 | 956 | { |
957 | 957 | foreach ($this->allowed_protocols as $one_protocol) |
958 | 958 | { |
@@ -989,8 +989,8 @@ discard block |
||
989 | 989 | private function checkAttributeValue($value, $vless, $checkname, $checkvalue) |
990 | 990 | { |
991 | 991 | $ok = true; |
992 | - $check_attribute_method_name = 'checkAttributeValue' . ucfirst(strtolower($checkname)); |
|
993 | - if(method_exists($this, $check_attribute_method_name)) |
|
992 | + $check_attribute_method_name = 'checkAttributeValue'.ucfirst(strtolower($checkname)); |
|
993 | + if (method_exists($this, $check_attribute_method_name)) |
|
994 | 994 | { |
995 | 995 | $ok = $this->$check_attribute_method_name($value, $checkvalue, $vless); |
996 | 996 | } |
@@ -5,11 +5,11 @@ discard block |
||
5 | 5 | // current valid email address at http://chaos.org/contact/ |
6 | 6 | |
7 | 7 | // Make sure we're in a usable PHP environment |
8 | - if(substr(phpversion(), 0, 1) < 4) |
|
8 | + if (substr(phpversion(), 0, 1) < 4) |
|
9 | 9 | { |
10 | 10 | define('KSESTEST_VER', 0); |
11 | 11 | } |
12 | - elseif(substr(phpversion(), 0, 1) >= 5) |
|
12 | + elseif (substr(phpversion(), 0, 1) >= 5) |
|
13 | 13 | { |
14 | 14 | define('KSESTEST_VER', 5); |
15 | 15 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | } |
20 | 20 | |
21 | 21 | // See if we're in command line or web |
22 | - if($_SERVER["DOCUMENT_ROOT"] == "") |
|
22 | + if ($_SERVER["DOCUMENT_ROOT"] == "") |
|
23 | 23 | { |
24 | 24 | define('KSESTEST_ENV', 'CLI'); |
25 | 25 | } |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | define('KSESTEST_ENV', 'WEB'); |
29 | 29 | } |
30 | 30 | |
31 | - if(KSESTEST_VER == 0) |
|
31 | + if (KSESTEST_VER == 0) |
|
32 | 32 | { |
33 | 33 | $message = array( |
34 | 34 | "Error: Not using a current version of PHP!", |
35 | - "You are using PHP version " . phpversion() . ".", |
|
35 | + "You are using PHP version ".phpversion().".", |
|
36 | 36 | "KSES Class version requires PHP4 or better.", |
37 | 37 | "KSES test program ending." |
38 | 38 | ); |
@@ -44,27 +44,27 @@ discard block |
||
44 | 44 | exit(); |
45 | 45 | } |
46 | 46 | |
47 | - $include_file = "php" . KSESTEST_VER . ".class.kses.php"; |
|
48 | - if(file_exists($include_file) && is_readable($include_file)) |
|
47 | + $include_file = "php".KSESTEST_VER.".class.kses.php"; |
|
48 | + if (file_exists($include_file) && is_readable($include_file)) |
|
49 | 49 | { |
50 | 50 | include_once($include_file); |
51 | 51 | } |
52 | 52 | else |
53 | 53 | { |
54 | 54 | $message = array( |
55 | - "Error: Unable to find '" . $include_file . "'.", |
|
55 | + "Error: Unable to find '".$include_file."'.", |
|
56 | 56 | "Please check your include path and make sure the file is available.", |
57 | - "Path: " . ini_get('include_path') |
|
57 | + "Path: ".ini_get('include_path') |
|
58 | 58 | ); |
59 | 59 | |
60 | 60 | displayPage( |
61 | - array('title' => 'Unable to include ' . $include_file, 'message' => $message) |
|
61 | + array('title' => 'Unable to include '.$include_file, 'message' => $message) |
|
62 | 62 | ); |
63 | 63 | |
64 | 64 | exit(); |
65 | 65 | } |
66 | 66 | |
67 | - $kses_type = "kses" . KSESTEST_VER; |
|
67 | + $kses_type = "kses".KSESTEST_VER; |
|
68 | 68 | $myKses = new $kses_type; |
69 | 69 | |
70 | 70 | $test_text = array(); |
@@ -98,16 +98,16 @@ discard block |
||
98 | 98 | |
99 | 99 | $out_li = array(); |
100 | 100 | // Keep only allowed HTML from the presumed 'form'. |
101 | - foreach($test_tags as $tag) |
|
101 | + foreach ($test_tags as $tag) |
|
102 | 102 | { |
103 | 103 | $temp = $myKses->Parse($tag); |
104 | 104 | $check = ($temp == $tag) ? true : false; |
105 | 105 | $text = ($temp == $tag) ? 'pass' : 'fail'; |
106 | 106 | |
107 | - $li_text = output_testresult($check, $text) . output_newline(); |
|
108 | - $li_text .= "Input: " . output_translate($tag) . output_newline(); |
|
109 | - $li_text .= "Output: " . output_translate($temp); |
|
110 | - if(KSESTEST_ENV == 'CLI') |
|
107 | + $li_text = output_testresult($check, $text).output_newline(); |
|
108 | + $li_text .= "Input: ".output_translate($tag).output_newline(); |
|
109 | + $li_text .= "Output: ".output_translate($temp); |
|
110 | + if (KSESTEST_ENV == 'CLI') |
|
111 | 111 | { |
112 | 112 | $li_text .= output_newline(); |
113 | 113 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | function output_code_wrap($text) |
125 | 125 | { |
126 | - if(KSESTEST_ENV == 'CLI') |
|
126 | + if (KSESTEST_ENV == 'CLI') |
|
127 | 127 | { |
128 | 128 | return $text; |
129 | 129 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | function output_translate($text) |
137 | 137 | { |
138 | - if(KSESTEST_ENV == 'CLI') |
|
138 | + if (KSESTEST_ENV == 'CLI') |
|
139 | 139 | { |
140 | 140 | return $text; |
141 | 141 | } |
@@ -147,26 +147,26 @@ discard block |
||
147 | 147 | |
148 | 148 | function output_testresult($pass = false, $text = "") |
149 | 149 | { |
150 | - if(KSESTEST_ENV == 'CLI') |
|
150 | + if (KSESTEST_ENV == 'CLI') |
|
151 | 151 | { |
152 | - return '[' . $text . ']'; |
|
152 | + return '['.$text.']'; |
|
153 | 153 | } |
154 | 154 | else |
155 | 155 | { |
156 | - if($pass == true) |
|
156 | + if ($pass == true) |
|
157 | 157 | { |
158 | - return '<span style="color: green;">[' . $text . ']</span>'; |
|
158 | + return '<span style="color: green;">['.$text.']</span>'; |
|
159 | 159 | } |
160 | 160 | else |
161 | 161 | { |
162 | - return '<span style="color: red;">[' . $text . ']</span>'; |
|
162 | + return '<span style="color: red;">['.$text.']</span>'; |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | 167 | function output_spaces() |
168 | 168 | { |
169 | - if(KSESTEST_ENV == 'WEB') |
|
169 | + if (KSESTEST_ENV == 'WEB') |
|
170 | 170 | { |
171 | 171 | $out = " "; |
172 | 172 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | |
181 | 181 | function output_newline() |
182 | 182 | { |
183 | - if(KSESTEST_ENV == 'WEB') |
|
183 | + if (KSESTEST_ENV == 'WEB') |
|
184 | 184 | { |
185 | 185 | $out = "<br />\n"; |
186 | 186 | } |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | |
200 | 200 | $out = ""; |
201 | 201 | |
202 | - foreach($message as $text) |
|
202 | + foreach ($message as $text) |
|
203 | 203 | { |
204 | - if(KSESTEST_ENV == 'WEB') |
|
204 | + if (KSESTEST_ENV == 'WEB') |
|
205 | 205 | { |
206 | 206 | $header = "\t\t<h1>$title</h1>\n\t\t<hr />\n"; |
207 | 207 | $out .= "\t\t<p>\n"; |
@@ -210,12 +210,12 @@ discard block |
||
210 | 210 | } |
211 | 211 | else |
212 | 212 | { |
213 | - $header = "$title\n" . str_repeat('-', 60) . "\n\n"; |
|
213 | + $header = "$title\n".str_repeat('-', 60)."\n\n"; |
|
214 | 214 | $out .= "\t$text\n\n"; |
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
218 | - if(KSESTEST_ENV == 'WEB') |
|
218 | + if (KSESTEST_ENV == 'WEB') |
|
219 | 219 | { |
220 | 220 | echo "<html>\n"; |
221 | 221 | echo "\t<head>\n"; |
@@ -236,28 +236,28 @@ discard block |
||
236 | 236 | |
237 | 237 | function output_hr() |
238 | 238 | { |
239 | - if(KSESTEST_ENV == 'WEB') |
|
239 | + if (KSESTEST_ENV == 'WEB') |
|
240 | 240 | { |
241 | 241 | return "\t\t\t<hr />\n"; |
242 | 242 | } |
243 | 243 | else |
244 | 244 | { |
245 | - return str_repeat(60, '-') . "\n"; |
|
245 | + return str_repeat(60, '-')."\n"; |
|
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
249 | 249 | function output_ul($data = array(), $padding = "") |
250 | 250 | { |
251 | - if(!is_array($data) || count($data) < 1) |
|
251 | + if (!is_array($data) || count($data) < 1) |
|
252 | 252 | { |
253 | 253 | return ""; |
254 | 254 | } |
255 | 255 | |
256 | 256 | $text = ""; |
257 | - if(KSESTEST_ENV == 'WEB') |
|
257 | + if (KSESTEST_ENV == 'WEB') |
|
258 | 258 | { |
259 | 259 | $text = "\t\t\t<ul>\n"; |
260 | - foreach($data as $li) |
|
260 | + foreach ($data as $li) |
|
261 | 261 | { |
262 | 262 | $text .= "\t\t\t\t<li>$li</li>\n"; |
263 | 263 | } |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | } |
266 | 266 | else |
267 | 267 | { |
268 | - foreach($data as $li) |
|
268 | + foreach ($data as $li) |
|
269 | 269 | { |
270 | - $text .= $padding . " * $li\n"; |
|
270 | + $text .= $padding." * $li\n"; |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | |
@@ -278,32 +278,32 @@ discard block |
||
278 | 278 | { |
279 | 279 | $default_prots = $myKses->dumpProtocols(); |
280 | 280 | $out_text = array(); |
281 | - if(count($default_prots) > 0) |
|
281 | + if (count($default_prots) > 0) |
|
282 | 282 | { |
283 | - array_push($out_text, "Initial protocols from KSES" . KSESTEST_VER . ":"); |
|
283 | + array_push($out_text, "Initial protocols from KSES".KSESTEST_VER.":"); |
|
284 | 284 | array_push($out_text, output_ul($default_prots)); |
285 | 285 | array_push($out_text, output_hr()); |
286 | 286 | } |
287 | 287 | |
288 | - $myKses->AddProtocols(array("proto1", "proto2:", "proto3")); // Add a list of protocols |
|
289 | - $myKses->AddProtocols("proto4:"); // Add a single protocol (Note ':' is optional at end) |
|
288 | + $myKses->AddProtocols(array("proto1", "proto2:", "proto3")); // Add a list of protocols |
|
289 | + $myKses->AddProtocols("proto4:"); // Add a single protocol (Note ':' is optional at end) |
|
290 | 290 | $myKses->AddProtocol("proto9", "mystery:", "anarchy"); |
291 | 291 | $myKses->AddProtocol("alpha", "beta", "gamma:"); |
292 | 292 | |
293 | 293 | $add_protocol = "\t\t\t<ol>\n"; |
294 | - $add_protocol .= "\t\t\t\t" . '<li>$myKses->AddProtocols(array("proto1", "proto2:", "proto3"));</li>' . "\n"; |
|
295 | - $add_protocol .= "\t\t\t\t" . '<li>$myKses->AddProtocols("proto4:");</li>' . "\n"; |
|
296 | - $add_protocol .= "\t\t\t\t" . '<li>$myKses->AddProtocols("proto4:");</li>' . "\n"; |
|
297 | - $add_protocol .= "\t\t\t\t" . '<li>$myKses->AddProtocol("proto9", "mystery:", "anarchy");</li>' . "\n"; |
|
298 | - $add_protocol .= "\t\t\t\t" . '<li>$myKses->AddProtocol("alpha", "beta", "gamma:");</li>' . "\n"; |
|
294 | + $add_protocol .= "\t\t\t\t".'<li>$myKses->AddProtocols(array("proto1", "proto2:", "proto3"));</li>'."\n"; |
|
295 | + $add_protocol .= "\t\t\t\t".'<li>$myKses->AddProtocols("proto4:");</li>'."\n"; |
|
296 | + $add_protocol .= "\t\t\t\t".'<li>$myKses->AddProtocols("proto4:");</li>'."\n"; |
|
297 | + $add_protocol .= "\t\t\t\t".'<li>$myKses->AddProtocol("proto9", "mystery:", "anarchy");</li>'."\n"; |
|
298 | + $add_protocol .= "\t\t\t\t".'<li>$myKses->AddProtocol("alpha", "beta", "gamma:");</li>'."\n"; |
|
299 | 299 | $add_protocol .= "\t\t\t</ol>\n"; |
300 | 300 | |
301 | 301 | array_push($out_text, $add_protocol); |
302 | 302 | |
303 | 303 | $new_prots = $myKses->dumpProtocols(); |
304 | - if(count($new_prots) > 0) |
|
304 | + if (count($new_prots) > 0) |
|
305 | 305 | { |
306 | - array_push($out_text, "New protocols from KSES" . KSESTEST_VER . " after using AddProtocol(s):"); |
|
306 | + array_push($out_text, "New protocols from KSES".KSESTEST_VER." after using AddProtocol(s):"); |
|
307 | 307 | array_push($out_text, output_ul($new_prots)); |
308 | 308 | array_push($out_text, output_hr()); |
309 | 309 | } |
@@ -314,31 +314,31 @@ discard block |
||
314 | 314 | $myKses->RemoveProtocol("gamma"); |
315 | 315 | |
316 | 316 | $remove_protocol = "\t\t\t<ol>\n"; |
317 | - $remove_protocol .= "\t\t\t\t" . '<li>$myKses->RemoveProtocols(array("mystery", "anarchy:"));</li>' . "\n"; |
|
318 | - $remove_protocol .= "\t\t\t\t" . '<li>$myKses->RemoveProtocols("alpha:");</li>' . "\n"; |
|
319 | - $remove_protocol .= "\t\t\t\t" . '<li>$myKses->RemoveProtocol("beta:");</li>' . "\n"; |
|
320 | - $remove_protocol .= "\t\t\t\t" . '<li>$myKses->RemoveProtocol("gamma");</li>' . "\n"; |
|
317 | + $remove_protocol .= "\t\t\t\t".'<li>$myKses->RemoveProtocols(array("mystery", "anarchy:"));</li>'."\n"; |
|
318 | + $remove_protocol .= "\t\t\t\t".'<li>$myKses->RemoveProtocols("alpha:");</li>'."\n"; |
|
319 | + $remove_protocol .= "\t\t\t\t".'<li>$myKses->RemoveProtocol("beta:");</li>'."\n"; |
|
320 | + $remove_protocol .= "\t\t\t\t".'<li>$myKses->RemoveProtocol("gamma");</li>'."\n"; |
|
321 | 321 | $remove_protocol .= "\t\t\t</ol>\n"; |
322 | 322 | array_push($out_text, $remove_protocol); |
323 | 323 | |
324 | 324 | $new_prots = $myKses->dumpProtocols(); |
325 | - if(count($new_prots) > 0) |
|
325 | + if (count($new_prots) > 0) |
|
326 | 326 | { |
327 | - array_push($out_text, "Resulting protocols from KSES" . KSESTEST_VER . " after using RemoveProtocol(s):"); |
|
327 | + array_push($out_text, "Resulting protocols from KSES".KSESTEST_VER." after using RemoveProtocol(s):"); |
|
328 | 328 | array_push($out_text, output_ul($new_prots)); |
329 | 329 | array_push($out_text, output_hr()); |
330 | 330 | } |
331 | 331 | |
332 | 332 | $myKses->SetProtocols(array("https", "gopher", "news")); |
333 | 333 | $set_protocol = "\t\t\t<ol>\n"; |
334 | - $set_protocol .= "\t\t\t\t" . '<li>$myKses->SetProtocols(array("https", "gopher", "news"));</li>' . "\n"; |
|
334 | + $set_protocol .= "\t\t\t\t".'<li>$myKses->SetProtocols(array("https", "gopher", "news"));</li>'."\n"; |
|
335 | 335 | $set_protocol .= "\t\t\t</ol>\n"; |
336 | 336 | array_push($out_text, $set_protocol); |
337 | 337 | |
338 | 338 | $new_prots = $myKses->dumpProtocols(); |
339 | - if(count($new_prots) > 0) |
|
339 | + if (count($new_prots) > 0) |
|
340 | 340 | { |
341 | - array_push($out_text, "Resulting protocols from KSES" . KSESTEST_VER . " after using SetProtocols:"); |
|
341 | + array_push($out_text, "Resulting protocols from KSES".KSESTEST_VER." after using SetProtocols:"); |
|
342 | 342 | array_push($out_text, output_ul($new_prots)); |
343 | 343 | array_push($out_text, output_hr()); |
344 | 344 | } |
@@ -427,18 +427,18 @@ discard block |
||
427 | 427 | array_push($out, "Net results:"); |
428 | 428 | |
429 | 429 | $out_elems = $myKses->DumpElements(); |
430 | - if(count($out_elems) > 0) |
|
430 | + if (count($out_elems) > 0) |
|
431 | 431 | { |
432 | 432 | //array_push($out, "\t\t\t<ul>\n"); |
433 | - foreach($out_elems as $tag => $attr_data) |
|
433 | + foreach ($out_elems as $tag => $attr_data) |
|
434 | 434 | { |
435 | 435 | $out_li_elems = array(); |
436 | 436 | $elem_text = "(X)HTML element $tag"; |
437 | 437 | $allow = ""; |
438 | - if(isset($attr_data) && is_array($attr_data) && count($attr_data) > 0) |
|
438 | + if (isset($attr_data) && is_array($attr_data) && count($attr_data) > 0) |
|
439 | 439 | { |
440 | 440 | $allow = " allows attribute"; |
441 | - if(count($attr_data) > 1) |
|
441 | + if (count($attr_data) > 1) |
|
442 | 442 | { |
443 | 443 | $allow .= "s"; |
444 | 444 | } |
@@ -448,31 +448,31 @@ discard block |
||
448 | 448 | array_push($out_li_elems, "$elem_text$allow"); |
449 | 449 | |
450 | 450 | $attr_test_li = array(); |
451 | - if(isset($attr_data) && is_array($attr_data) && count($attr_data) > 0) |
|
451 | + if (isset($attr_data) && is_array($attr_data) && count($attr_data) > 0) |
|
452 | 452 | { |
453 | - foreach($attr_data as $attr_name => $attr_tests) |
|
453 | + foreach ($attr_data as $attr_name => $attr_tests) |
|
454 | 454 | { |
455 | 455 | $li_text = $attr_name; |
456 | - if(isset($attr_tests) && count($attr_tests) > 0) |
|
456 | + if (isset($attr_tests) && count($attr_tests) > 0) |
|
457 | 457 | { |
458 | - foreach($attr_tests as $test_name => $test_val) |
|
458 | + foreach ($attr_tests as $test_name => $test_val) |
|
459 | 459 | { |
460 | - switch($test_name) |
|
460 | + switch ($test_name) |
|
461 | 461 | { |
462 | 462 | case "maxlen": |
463 | - $li_text .= " - maximum length of '" . $test_val . "' characters"; |
|
463 | + $li_text .= " - maximum length of '".$test_val."' characters"; |
|
464 | 464 | break; |
465 | 465 | case "minlen": |
466 | - $li_text .= " - minimum length of '" . $test_val . "' characters"; |
|
466 | + $li_text .= " - minimum length of '".$test_val."' characters"; |
|
467 | 467 | break; |
468 | 468 | case "minval": |
469 | - $li_text .= " - minimum value of '" . $test_val . "'"; |
|
469 | + $li_text .= " - minimum value of '".$test_val."'"; |
|
470 | 470 | break; |
471 | 471 | case "maxval": |
472 | - $li_text .= " - maximum value of '" . $test_val . "'"; |
|
472 | + $li_text .= " - maximum value of '".$test_val."'"; |
|
473 | 473 | break; |
474 | 474 | case "valueless": |
475 | - switch(strtolower($test_val)) |
|
475 | + switch (strtolower($test_val)) |
|
476 | 476 | { |
477 | 477 | case 'n': |
478 | 478 | $li_text .= " - must not be valueless"; |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | } |
492 | 492 | array_push($attr_test_li, $li_text); |
493 | 493 | } |
494 | - if(count($attr_test_li) > 0) |
|
494 | + if (count($attr_test_li) > 0) |
|
495 | 495 | { |
496 | 496 | $attr_test_li = output_ul($attr_test_li, " "); |
497 | 497 | $out_li_elems = array("$elem_text$allow$attr_test_li"); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @subpackage kses4 |
40 | 40 | */ |
41 | 41 | |
42 | - if(substr(phpversion(), 0, 1) < 4) |
|
42 | + if (substr(phpversion(), 0, 1) < 4) |
|
43 | 43 | { |
44 | 44 | die("Class kses requires PHP 4 or higher."); |
45 | 45 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | /** |
48 | 48 | * Only install KSES4 once |
49 | 49 | */ |
50 | - if(!defined('KSES_CLASS_PHP4')) |
|
50 | + if (!defined('KSES_CLASS_PHP4')) |
|
51 | 51 | { |
52 | 52 | define('KSES_CLASS_PHP4', true); |
53 | 53 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | function AddProtocols() |
151 | 151 | { |
152 | 152 | $c_args = func_num_args(); |
153 | - if($c_args != 1) |
|
153 | + if ($c_args != 1) |
|
154 | 154 | { |
155 | 155 | trigger_error("kses4::AddProtocols() did not receive an argument.", E_USER_WARNING); |
156 | 156 | return false; |
@@ -158,15 +158,15 @@ discard block |
||
158 | 158 | |
159 | 159 | $protocol_data = func_get_arg(0); |
160 | 160 | |
161 | - if(is_array($protocol_data) && count($protocol_data) > 0) |
|
161 | + if (is_array($protocol_data) && count($protocol_data) > 0) |
|
162 | 162 | { |
163 | - foreach($protocol_data as $protocol) |
|
163 | + foreach ($protocol_data as $protocol) |
|
164 | 164 | { |
165 | 165 | $this->AddProtocol($protocol); |
166 | 166 | } |
167 | 167 | return true; |
168 | 168 | } |
169 | - elseif(is_string($protocol_data)) |
|
169 | + elseif (is_string($protocol_data)) |
|
170 | 170 | { |
171 | 171 | $this->AddProtocol($protocol_data); |
172 | 172 | return true; |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | function Protocols() |
190 | 190 | { |
191 | 191 | $c_args = func_num_args(); |
192 | - if($c_args != 1) |
|
192 | + if ($c_args != 1) |
|
193 | 193 | { |
194 | 194 | trigger_error("kses4::Protocols() did not receive an argument.", E_USER_WARNING); |
195 | 195 | return false; |
@@ -212,26 +212,26 @@ discard block |
||
212 | 212 | */ |
213 | 213 | function AddProtocol($protocol = "") |
214 | 214 | { |
215 | - if(!is_string($protocol)) |
|
215 | + if (!is_string($protocol)) |
|
216 | 216 | { |
217 | 217 | trigger_error("kses4::AddProtocol() requires a string.", E_USER_WARNING); |
218 | 218 | return false; |
219 | 219 | } |
220 | 220 | |
221 | 221 | $protocol = strtolower(trim($protocol)); |
222 | - if($protocol == "") |
|
222 | + if ($protocol == "") |
|
223 | 223 | { |
224 | 224 | trigger_error("kses4::AddProtocol() tried to add an empty/NULL protocol.", E_USER_WARNING); |
225 | 225 | return false; |
226 | 226 | } |
227 | 227 | |
228 | 228 | // Remove any inadvertent ':' at the end of the protocol. |
229 | - if(substr($protocol, strlen($protocol) - 1, 1) == ":") |
|
229 | + if (substr($protocol, strlen($protocol) - 1, 1) == ":") |
|
230 | 230 | { |
231 | 231 | $protocol = substr($protocol, 0, strlen($protocol) - 1); |
232 | 232 | } |
233 | 233 | |
234 | - if(!in_array($protocol, $this->allowed_protocols)) |
|
234 | + if (!in_array($protocol, $this->allowed_protocols)) |
|
235 | 235 | { |
236 | 236 | array_push($this->allowed_protocols, $protocol); |
237 | 237 | sort($this->allowed_protocols); |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | function SetProtocols() |
258 | 258 | { |
259 | 259 | $c_args = func_num_args(); |
260 | - if($c_args != 1) |
|
260 | + if ($c_args != 1) |
|
261 | 261 | { |
262 | 262 | trigger_error("kses4::SetProtocols() did not receive an argument.", E_USER_WARNING); |
263 | 263 | return false; |
@@ -265,16 +265,16 @@ discard block |
||
265 | 265 | |
266 | 266 | $protocol_data = func_get_arg(0); |
267 | 267 | |
268 | - if(is_array($protocol_data) && count($protocol_data) > 0) |
|
268 | + if (is_array($protocol_data) && count($protocol_data) > 0) |
|
269 | 269 | { |
270 | 270 | $this->allowed_protocols = array(); |
271 | - foreach($protocol_data as $protocol) |
|
271 | + foreach ($protocol_data as $protocol) |
|
272 | 272 | { |
273 | 273 | $this->AddProtocol($protocol); |
274 | 274 | } |
275 | 275 | return true; |
276 | 276 | } |
277 | - elseif(is_string($protocol_data)) |
|
277 | + elseif (is_string($protocol_data)) |
|
278 | 278 | { |
279 | 279 | $this->allowed_protocols = array(); |
280 | 280 | $this->AddProtocol($protocol_data); |
@@ -331,37 +331,37 @@ discard block |
||
331 | 331 | */ |
332 | 332 | function AddHTML($tag = "", $attribs = array()) |
333 | 333 | { |
334 | - if(!is_string($tag)) |
|
334 | + if (!is_string($tag)) |
|
335 | 335 | { |
336 | 336 | trigger_error("kses4::AddHTML() requires the tag to be a string", E_USER_WARNING); |
337 | 337 | return false; |
338 | 338 | } |
339 | 339 | |
340 | 340 | $tag = strtolower(trim($tag)); |
341 | - if($tag == "") |
|
341 | + if ($tag == "") |
|
342 | 342 | { |
343 | 343 | trigger_error("kses4::AddHTML() tried to add an empty/NULL tag", E_USER_WARNING); |
344 | 344 | return false; |
345 | 345 | } |
346 | 346 | |
347 | - if(!is_array($attribs)) |
|
347 | + if (!is_array($attribs)) |
|
348 | 348 | { |
349 | 349 | trigger_error("kses4::AddHTML() requires an array (even an empty one) of attributes for '$tag'", E_USER_WARNING); |
350 | 350 | return false; |
351 | 351 | } |
352 | 352 | |
353 | 353 | $new_attribs = array(); |
354 | - if(is_array($attribs) && count($attribs) > 0) |
|
354 | + if (is_array($attribs) && count($attribs) > 0) |
|
355 | 355 | { |
356 | - foreach($attribs as $idx1 => $val1) |
|
356 | + foreach ($attribs as $idx1 => $val1) |
|
357 | 357 | { |
358 | 358 | $new_idx1 = strtolower($idx1); |
359 | 359 | $new_val1 = $attribs[$idx1]; |
360 | 360 | |
361 | - if(is_array($new_val1) && count($new_val1) > 0) |
|
361 | + if (is_array($new_val1) && count($new_val1) > 0) |
|
362 | 362 | { |
363 | 363 | $tmp_val = array(); |
364 | - foreach($new_val1 as $idx2 => $val2) |
|
364 | + foreach ($new_val1 as $idx2 => $val2) |
|
365 | 365 | { |
366 | 366 | $new_idx2 = strtolower($idx2); |
367 | 367 | $tmp_val[$new_idx2] = $val2; |
@@ -391,27 +391,27 @@ discard block |
||
391 | 391 | */ |
392 | 392 | function RemoveProtocol($protocol = "") |
393 | 393 | { |
394 | - if(!is_string($protocol)) |
|
394 | + if (!is_string($protocol)) |
|
395 | 395 | { |
396 | 396 | trigger_error("kses4::RemoveProtocol() requires a string.", E_USER_WARNING); |
397 | 397 | return false; |
398 | 398 | } |
399 | 399 | |
400 | 400 | // Remove any inadvertent ':' at the end of the protocol. |
401 | - if(substr($protocol, strlen($protocol) - 1, 1) == ":") |
|
401 | + if (substr($protocol, strlen($protocol) - 1, 1) == ":") |
|
402 | 402 | { |
403 | 403 | $protocol = substr($protocol, 0, strlen($protocol) - 1); |
404 | 404 | } |
405 | 405 | |
406 | 406 | $protocol = strtolower(trim($protocol)); |
407 | - if($protocol == "") |
|
407 | + if ($protocol == "") |
|
408 | 408 | { |
409 | 409 | trigger_error("kses4::RemoveProtocol() tried to remove an empty/NULL protocol.", E_USER_WARNING); |
410 | 410 | return false; |
411 | 411 | } |
412 | 412 | |
413 | 413 | // Ensures that the protocol exists before removing it. |
414 | - if(in_array($protocol, $this->allowed_protocols)) |
|
414 | + if (in_array($protocol, $this->allowed_protocols)) |
|
415 | 415 | { |
416 | 416 | $this->allowed_protocols = array_diff($this->allowed_protocols, array($protocol)); |
417 | 417 | sort($this->allowed_protocols); |
@@ -438,21 +438,21 @@ discard block |
||
438 | 438 | function RemoveProtocols() |
439 | 439 | { |
440 | 440 | $c_args = func_num_args(); |
441 | - if($c_args != 1) |
|
441 | + if ($c_args != 1) |
|
442 | 442 | { |
443 | 443 | return false; |
444 | 444 | } |
445 | 445 | |
446 | 446 | $protocol_data = func_get_arg(0); |
447 | 447 | |
448 | - if(is_array($protocol_data) && count($protocol_data) > 0) |
|
448 | + if (is_array($protocol_data) && count($protocol_data) > 0) |
|
449 | 449 | { |
450 | - foreach($protocol_data as $protocol) |
|
450 | + foreach ($protocol_data as $protocol) |
|
451 | 451 | { |
452 | 452 | $this->RemoveProtocol($protocol); |
453 | 453 | } |
454 | 454 | } |
455 | - elseif(is_string($protocol_data)) |
|
455 | + elseif (is_string($protocol_data)) |
|
456 | 456 | { |
457 | 457 | $this->RemoveProtocol($protocol_data); |
458 | 458 | return true; |
@@ -587,14 +587,14 @@ discard block |
||
587 | 587 | { |
588 | 588 | $outarray = array(); |
589 | 589 | |
590 | - if(is_array($inarray) && count($inarray) > 0) |
|
590 | + if (is_array($inarray) && count($inarray) > 0) |
|
591 | 591 | { |
592 | 592 | foreach ($inarray as $inkey => $inval) |
593 | 593 | { |
594 | 594 | $outkey = strtolower($inkey); |
595 | 595 | $outarray[$outkey] = array(); |
596 | 596 | |
597 | - if(is_array($inval) && count($inval) > 0) |
|
597 | + if (is_array($inval) && count($inval) > 0) |
|
598 | 598 | { |
599 | 599 | foreach ($inval as $inkey2 => $inval2) |
600 | 600 | { |
@@ -620,9 +620,9 @@ discard block |
||
620 | 620 | function _split($string) |
621 | 621 | { |
622 | 622 | return preg_replace( |
623 | - '%(<'. # EITHER: < |
|
624 | - '[^>]*'. # things that aren't > |
|
625 | - '(>|$)'. # > or end of string |
|
623 | + '%(<'.# EITHER: < |
|
624 | + '[^>]*'.# things that aren't > |
|
625 | + '(>|$)'.# > or end of string |
|
626 | 626 | '|>)%e', # OR: just a > |
627 | 627 | "\$this->_split2('\\1')", |
628 | 628 | $string); |
@@ -720,11 +720,11 @@ discard block |
||
720 | 720 | # Go through $attrarr, and save the allowed attributes for this element |
721 | 721 | # in $attr2 |
722 | 722 | $attr2 = ''; |
723 | - if(is_array($attrarr) && count($attrarr) > 0) |
|
723 | + if (is_array($attrarr) && count($attrarr) > 0) |
|
724 | 724 | { |
725 | 725 | foreach ($attrarr as $arreach) |
726 | 726 | { |
727 | - if(!isset($this->allowed_html[strtolower($element)][strtolower($arreach['name'])])) |
|
727 | + if (!isset($this->allowed_html[strtolower($element)][strtolower($arreach['name'])])) |
|
728 | 728 | { |
729 | 729 | continue; |
730 | 730 | } |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | { |
746 | 746 | # there are some checks |
747 | 747 | $ok = true; |
748 | - if(is_array($current) && count($current) > 0) |
|
748 | + if (is_array($current) && count($current) > 0) |
|
749 | 749 | { |
750 | 750 | foreach ($current as $currkey => $currval) |
751 | 751 | { |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | 'whole' => $attrname, |
828 | 828 | 'vless' => 'y' |
829 | 829 | ); |
830 | - $attr = preg_replace('/^\s+/', '', $attr); |
|
830 | + $attr = preg_replace('/^\s+/', '', $attr); |
|
831 | 831 | } |
832 | 832 | break; |
833 | 833 | case 2: # attribute value, a URL after href= for instance |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | function _bad_protocol_once($string) |
943 | 943 | { |
944 | 944 | $string2 = preg_split('/:|:|:/i', $string, 2); |
945 | - if(isset($string2[1]) && !preg_match('%/\?%',$string2[0])) |
|
945 | + if (isset($string2[1]) && !preg_match('%/\?%', $string2[0])) |
|
946 | 946 | { |
947 | 947 | $string = $this->_bad_protocol_once2($string2[0]).trim($string2[1]); |
948 | 948 | } |
@@ -970,7 +970,7 @@ discard block |
||
970 | 970 | $string = strtolower($string); |
971 | 971 | |
972 | 972 | $allowed = false; |
973 | - if(is_array($this->allowed_protocols) && count($this->allowed_protocols) > 0) |
|
973 | + if (is_array($this->allowed_protocols) && count($this->allowed_protocols) > 0) |
|
974 | 974 | { |
975 | 975 | foreach ($this->allowed_protocols as $one_protocol) |
976 | 976 | { |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $last_modified = 0; |
212 | 212 | $return = 0; |
213 | 213 | if (is_dir($dir)) { |
214 | - while(($entry = $dir->read()) !== false) |
|
214 | + while (($entry = $dir->read()) !== false) |
|
215 | 215 | { |
216 | 216 | if ($entry != '.' && $entry != '..') |
217 | 217 | continue; |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | 'props.session_id' |
285 | 285 | ); |
286 | 286 | |
287 | - $visibility_rule = ' props.visibility ' . ($can_see_invisible ? '<> 2' : '= 1'); |
|
287 | + $visibility_rule = ' props.visibility '.($can_see_invisible ? '<> 2' : '= 1'); |
|
288 | 288 | |
289 | 289 | $sql = "SELECT SUM(table1.size) FROM ( |
290 | 290 | SELECT size |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $count = intval($count); |
80 | 80 | $from = intval($from); |
81 | 81 | |
82 | - $sql .= " ORDER BY $column $direction"; |
|
82 | + $sql .= " ORDER BY $column $direction"; |
|
83 | 83 | $sql .= " LIMIT $count, $from "; |
84 | 84 | |
85 | 85 | $result = Database::query($sql); |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | static function deactivate_zombies($ceiling) |
94 | 94 | { |
95 | 95 | $zombies = self::list_zombies($ceiling); |
96 | - $ids = array(); |
|
97 | - foreach($zombies as $zombie) { |
|
96 | + $ids = array(); |
|
97 | + foreach ($zombies as $zombie) { |
|
98 | 98 | $ids[] = $zombie['user_id']; |
99 | 99 | } |
100 | 100 | UserManager::deactivate_users($ids); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | } |
168 | 168 | |
169 | 169 | $action = $this->get_action(); |
170 | - $f = array($this, 'action_' . $action); |
|
170 | + $f = array($this, 'action_'.$action); |
|
171 | 171 | if (is_callable($f)) { |
172 | 172 | return call_user_func($f, $ids); |
173 | 173 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | $text = get_lang('No'); |
293 | 293 | } |
294 | 294 | |
295 | - $result = Display::return_icon($image . '.png', $text); |
|
295 | + $result = Display::return_icon($image.'.png', $text); |
|
296 | 296 | return $result; |
297 | 297 | } |
298 | 298 |
@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | function xajaxCompressJavascript($sJS) |
44 | 44 | { |
45 | 45 | //remove windows cariage returns |
46 | - $sJS = str_replace("\r","",$sJS); |
|
46 | + $sJS = str_replace("\r", "", $sJS); |
|
47 | 47 | |
48 | 48 | //array to store replaced literal strings |
49 | 49 | $literal_strings = array(); |
50 | 50 | |
51 | 51 | //explode the string into lines |
52 | - $lines = explode("\n",$sJS); |
|
52 | + $lines = explode("\n", $sJS); |
|
53 | 53 | //loop through all the lines, building a new string at the same time as removing literal strings |
54 | 54 | $clean = ""; |
55 | 55 | $inComment = false; |
@@ -58,22 +58,22 @@ discard block |
||
58 | 58 | $escaped = false; |
59 | 59 | $quoteChar = ""; |
60 | 60 | |
61 | - for($i=0;$i<count($lines);$i++) |
|
61 | + for ($i = 0; $i < count($lines); $i++) |
|
62 | 62 | { |
63 | 63 | $line = $lines[$i]; |
64 | 64 | $inNormalComment = false; |
65 | 65 | |
66 | 66 | //loop through line's characters and take out any literal strings, replace them with ___i___ where i is the index of this string |
67 | - for($j=0;$j<strlen($line);$j++) |
|
67 | + for ($j = 0; $j < strlen($line); $j++) |
|
68 | 68 | { |
69 | - $c = substr($line,$j,1); |
|
70 | - $d = substr($line,$j,2); |
|
69 | + $c = substr($line, $j, 1); |
|
70 | + $d = substr($line, $j, 2); |
|
71 | 71 | |
72 | 72 | //look for start of quote |
73 | - if(!$inQuote && !$inComment) |
|
73 | + if (!$inQuote && !$inComment) |
|
74 | 74 | { |
75 | 75 | //is this character a quote or a comment |
76 | - if(($c=="\"" || $c=="'") && !$inComment && !$inNormalComment) |
|
76 | + if (($c == "\"" || $c == "'") && !$inComment && !$inNormalComment) |
|
77 | 77 | { |
78 | 78 | $inQuote = true; |
79 | 79 | $inComment = false; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $quoteChar = $c; |
82 | 82 | $literal = $c; |
83 | 83 | } |
84 | - else if($d=="/*" && !$inNormalComment) |
|
84 | + else if ($d == "/*" && !$inNormalComment) |
|
85 | 85 | { |
86 | 86 | $inQuote = false; |
87 | 87 | $inComment = true; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $literal = $d; |
91 | 91 | $j++; |
92 | 92 | } |
93 | - else if($d=="//") //ignore string markers that are found inside comments |
|
93 | + else if ($d == "//") //ignore string markers that are found inside comments |
|
94 | 94 | { |
95 | 95 | $inNormalComment = true; |
96 | 96 | $clean .= $c; |
@@ -102,32 +102,32 @@ discard block |
||
102 | 102 | } |
103 | 103 | else //allready in a string so find end quote |
104 | 104 | { |
105 | - if($c == $quoteChar && !$escaped && !$inComment) |
|
105 | + if ($c == $quoteChar && !$escaped && !$inComment) |
|
106 | 106 | { |
107 | 107 | $inQuote = false; |
108 | 108 | $literal .= $c; |
109 | 109 | |
110 | 110 | //subsitute in a marker for the string |
111 | - $clean .= "___" . count($literal_strings) . "___"; |
|
111 | + $clean .= "___".count($literal_strings)."___"; |
|
112 | 112 | |
113 | 113 | //push the string onto our array |
114 | - array_push($literal_strings,$literal); |
|
114 | + array_push($literal_strings, $literal); |
|
115 | 115 | |
116 | 116 | } |
117 | - else if($inComment && $d=="*/") |
|
117 | + else if ($inComment && $d == "*/") |
|
118 | 118 | { |
119 | 119 | $inComment = false; |
120 | 120 | $literal .= $d; |
121 | 121 | |
122 | 122 | //subsitute in a marker for the string |
123 | - $clean .= "___" . count($literal_strings) . "___"; |
|
123 | + $clean .= "___".count($literal_strings)."___"; |
|
124 | 124 | |
125 | 125 | //push the string onto our array |
126 | - array_push($literal_strings,$literal); |
|
126 | + array_push($literal_strings, $literal); |
|
127 | 127 | |
128 | 128 | $j++; |
129 | 129 | } |
130 | - else if($c == "\\" && !$escaped) |
|
130 | + else if ($c == "\\" && !$escaped) |
|
131 | 131 | $escaped = true; |
132 | 132 | else |
133 | 133 | $escaped = false; |
@@ -135,47 +135,47 @@ discard block |
||
135 | 135 | $literal .= $c; |
136 | 136 | } |
137 | 137 | } |
138 | - if($inComment) $literal .= "\n"; |
|
138 | + if ($inComment) $literal .= "\n"; |
|
139 | 139 | $clean .= "\n"; |
140 | 140 | } |
141 | 141 | //explode the clean string into lines again |
142 | - $lines = explode("\n",$clean); |
|
142 | + $lines = explode("\n", $clean); |
|
143 | 143 | |
144 | 144 | //now process each line at a time |
145 | - for($i=0;$i<count($lines);$i++) |
|
145 | + for ($i = 0; $i < count($lines); $i++) |
|
146 | 146 | { |
147 | 147 | $line = $lines[$i]; |
148 | 148 | |
149 | 149 | //remove comments |
150 | - $line = preg_replace("/\/\/(.*)/","",$line); |
|
150 | + $line = preg_replace("/\/\/(.*)/", "", $line); |
|
151 | 151 | |
152 | 152 | //strip leading and trailing whitespace |
153 | 153 | $line = trim($line); |
154 | 154 | |
155 | 155 | //remove all whitespace with a single space |
156 | - $line = preg_replace("/\s+/"," ",$line); |
|
156 | + $line = preg_replace("/\s+/", " ", $line); |
|
157 | 157 | |
158 | 158 | //remove any whitespace that occurs after/before an operator |
159 | - $line = preg_replace("/\s*([!\}\{;,&=\|\-\+\*\/\)\(:])\s*/","\\1",$line); |
|
159 | + $line = preg_replace("/\s*([!\}\{;,&=\|\-\+\*\/\)\(:])\s*/", "\\1", $line); |
|
160 | 160 | |
161 | 161 | $lines[$i] = $line; |
162 | 162 | } |
163 | 163 | |
164 | 164 | //implode the lines |
165 | - $sJS = implode("\n",$lines); |
|
165 | + $sJS = implode("\n", $lines); |
|
166 | 166 | |
167 | 167 | //make sure there is a max of 1 \n after each line |
168 | - $sJS = preg_replace("/[\n]+/","\n",$sJS); |
|
168 | + $sJS = preg_replace("/[\n]+/", "\n", $sJS); |
|
169 | 169 | |
170 | 170 | //strip out line breaks that immediately follow a semi-colon |
171 | - $sJS = preg_replace("/;\n/",";",$sJS); |
|
171 | + $sJS = preg_replace("/;\n/", ";", $sJS); |
|
172 | 172 | |
173 | 173 | //curly brackets aren't on their own |
174 | - $sJS = preg_replace("/[\n]*\{[\n]*/","{",$sJS); |
|
174 | + $sJS = preg_replace("/[\n]*\{[\n]*/", "{", $sJS); |
|
175 | 175 | |
176 | 176 | //finally loop through and replace all the literal strings: |
177 | - for($i=0;$i<count($literal_strings);$i++) |
|
178 | - $sJS = str_replace("___".$i."___",$literal_strings[$i],$sJS); |
|
177 | + for ($i = 0; $i < count($literal_strings); $i++) |
|
178 | + $sJS = str_replace("___".$i."___", $literal_strings[$i], $sJS); |
|
179 | 179 | |
180 | 180 | return $sJS; |
181 | 181 | } |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | if (@preg_match('/(.*<head.*)(<meta[^>]*content=[^>]*>)(.*<\/head>.*)/si', $string, $matches)) { |
59 | 59 | $meta = $matches[2]; |
60 | 60 | if (@preg_match("/(<meta[^>]*charset=)(.*)([\"';][^>]*>)/si", $meta, $matches1)) { |
61 | - $meta = $matches1[1] . $encoding . $matches1[3]; |
|
62 | - $string = $matches[1] . $meta . $matches[3]; |
|
61 | + $meta = $matches1[1].$encoding.$matches1[3]; |
|
62 | + $string = $matches[1].$meta.$matches[3]; |
|
63 | 63 | } else { |
64 | - $string = $matches[1] . '<meta http-equiv="Content-Type" content="text/html; charset='.$encoding.'"/>' . $matches[3]; |
|
64 | + $string = $matches[1].'<meta http-equiv="Content-Type" content="text/html; charset='.$encoding.'"/>'.$matches[3]; |
|
65 | 65 | } |
66 | 66 | } else { |
67 | 67 | $count = 1; |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | if (!preg_match(_PCRE_XML_ENCODING, $string)) { |
169 | 169 | if (strpos($matches[0], 'standalone') !== false) { |
170 | 170 | // The encoding option should precede the standalone option, othewise DOMDocument fails to load the document. |
171 | - $replace = str_replace('standalone', ' encoding="'.$to_encoding.'" standalone' , $matches[0]); |
|
171 | + $replace = str_replace('standalone', ' encoding="'.$to_encoding.'" standalone', $matches[0]); |
|
172 | 172 | } else { |
173 | - $replace = str_replace('?>', ' encoding="'.$to_encoding.'"?>' , $matches[0]); |
|
173 | + $replace = str_replace('?>', ' encoding="'.$to_encoding.'"?>', $matches[0]); |
|
174 | 174 | } |
175 | 175 | return api_convert_encoding(str_replace($matches[0], $replace, $string), $to_encoding, $from_encoding); |
176 | 176 | } |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | function _make_url_clickable_cb($matches) { |
336 | 336 | $url = $matches[2]; |
337 | 337 | |
338 | - if ( ')' == $matches[3] && strpos( $url, '(' ) ) { |
|
338 | + if (')' == $matches[3] && strpos($url, '(')) { |
|
339 | 339 | // If the trailing character is a closing parethesis, and the URL has an opening parenthesis in it, add the closing parenthesis to the URL. |
340 | 340 | // Then we can let the parenthesis balancer do its thing below. |
341 | 341 | $url .= $matches[3]; |
@@ -345,16 +345,16 @@ discard block |
||
345 | 345 | } |
346 | 346 | |
347 | 347 | // Include parentheses in the URL only if paired |
348 | - while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) { |
|
349 | - $suffix = strrchr( $url, ')' ) . $suffix; |
|
350 | - $url = substr( $url, 0, strrpos( $url, ')' ) ); |
|
348 | + while (substr_count($url, '(') < substr_count($url, ')')) { |
|
349 | + $suffix = strrchr($url, ')').$suffix; |
|
350 | + $url = substr($url, 0, strrpos($url, ')')); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | $url = esc_url($url); |
354 | - if ( empty($url) ) |
|
354 | + if (empty($url)) |
|
355 | 355 | return $matches[0]; |
356 | 356 | |
357 | - return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $suffix; |
|
357 | + return $matches[1]."<a href=\"$url\" rel=\"nofollow\">$url</a>".$suffix; |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | /** |
@@ -374,10 +374,10 @@ discard block |
||
374 | 374 | * @param string $_context Private. Use esc_url_raw() for database usage. |
375 | 375 | * @return string The cleaned $url after the 'clean_url' filter is applied. |
376 | 376 | */ |
377 | -function esc_url( $url, $protocols = null, $_context = 'display' ) { |
|
377 | +function esc_url($url, $protocols = null, $_context = 'display') { |
|
378 | 378 | //$original_url = $url; |
379 | 379 | |
380 | - if ( '' == $url ) |
|
380 | + if ('' == $url) |
|
381 | 381 | return $url; |
382 | 382 | $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url); |
383 | 383 | $strip = array('%0d', '%0a', '%0D', '%0A'); |
@@ -387,9 +387,9 @@ discard block |
||
387 | 387 | * presume it needs http:// appended (unless a relative |
388 | 388 | * link starting with /, # or ? or a php file). |
389 | 389 | */ |
390 | - if ( strpos($url, ':') === false && ! in_array( $url[0], array( '/', '#', '?' ) ) && |
|
391 | - ! preg_match('/^[a-z0-9-]+?\.php/i', $url) ) |
|
392 | - $url = 'http://' . $url; |
|
390 | + if (strpos($url, ':') === false && !in_array($url[0], array('/', '#', '?')) && |
|
391 | + !preg_match('/^[a-z0-9-]+?\.php/i', $url)) |
|
392 | + $url = 'http://'.$url; |
|
393 | 393 | |
394 | 394 | return Security::remove_XSS($url); |
395 | 395 | |
@@ -437,12 +437,12 @@ discard block |
||
437 | 437 | * @param string $subject The string being searched and replaced on, otherwise known as the haystack. |
438 | 438 | * @return string The string with the replaced svalues. |
439 | 439 | */ |
440 | -function _deep_replace( $search, $subject ) { |
|
440 | +function _deep_replace($search, $subject) { |
|
441 | 441 | $subject = (string) $subject; |
442 | 442 | |
443 | 443 | $count = 1; |
444 | - while ( $count ) { |
|
445 | - $subject = str_replace( $search, '', $subject, $count ); |
|
444 | + while ($count) { |
|
445 | + $subject = str_replace($search, '', $subject, $count); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | return $subject; |
@@ -464,17 +464,17 @@ discard block |
||
464 | 464 | function _make_web_ftp_clickable_cb($matches) { |
465 | 465 | $ret = ''; |
466 | 466 | $dest = $matches[2]; |
467 | - $dest = 'http://' . $dest; |
|
467 | + $dest = 'http://'.$dest; |
|
468 | 468 | $dest = esc_url($dest); |
469 | - if ( empty($dest) ) |
|
469 | + if (empty($dest)) |
|
470 | 470 | return $matches[0]; |
471 | 471 | |
472 | 472 | // removed trailing [.,;:)] from URL |
473 | - if ( in_array( substr($dest, -1), array('.', ',', ';', ':', ')') ) === true ) { |
|
473 | + if (in_array(substr($dest, -1), array('.', ',', ';', ':', ')')) === true) { |
|
474 | 474 | $ret = substr($dest, -1); |
475 | - $dest = substr($dest, 0, strlen($dest)-1); |
|
475 | + $dest = substr($dest, 0, strlen($dest) - 1); |
|
476 | 476 | } |
477 | - return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret"; |
|
477 | + return $matches[1]."<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret"; |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | /** |
@@ -490,8 +490,8 @@ discard block |
||
490 | 490 | * @return string HTML A element with email address. |
491 | 491 | */ |
492 | 492 | function _make_email_clickable_cb($matches) { |
493 | - $email = $matches[2] . '@' . $matches[3]; |
|
494 | - return $matches[1] . "<a href=\"mailto:$email\">$email</a>"; |
|
493 | + $email = $matches[2].'@'.$matches[3]; |
|
494 | + return $matches[1]."<a href=\"mailto:$email\">$email</a>"; |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | /** |
@@ -505,30 +505,30 @@ discard block |
||
505 | 505 | * @param string $text Content to convert URIs. |
506 | 506 | * @return string Content with converted URIs. |
507 | 507 | */ |
508 | -function make_clickable( $text ) { |
|
508 | +function make_clickable($text) { |
|
509 | 509 | $r = ''; |
510 | - $textarr = preg_split( '/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // split out HTML tags |
|
510 | + $textarr = preg_split('/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE); // split out HTML tags |
|
511 | 511 | $nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code> |
512 | - foreach ( $textarr as $piece ) { |
|
512 | + foreach ($textarr as $piece) { |
|
513 | 513 | |
514 | - if ( preg_match( '|^<code[\s>]|i', $piece ) || preg_match( '|^<pre[\s>]|i', $piece ) ) |
|
514 | + if (preg_match('|^<code[\s>]|i', $piece) || preg_match('|^<pre[\s>]|i', $piece)) |
|
515 | 515 | $nested_code_pre++; |
516 | - elseif ( ( '</code>' === strtolower( $piece ) || '</pre>' === strtolower( $piece ) ) && $nested_code_pre ) |
|
516 | + elseif (('</code>' === strtolower($piece) || '</pre>' === strtolower($piece)) && $nested_code_pre) |
|
517 | 517 | $nested_code_pre--; |
518 | 518 | |
519 | - if ( $nested_code_pre || empty( $piece ) || ( $piece[0] === '<' && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) { |
|
519 | + if ($nested_code_pre || empty($piece) || ($piece[0] === '<' && !preg_match('|^<\s*[\w]{1,20}+://|', $piece))) { |
|
520 | 520 | $r .= $piece; |
521 | 521 | continue; |
522 | 522 | } |
523 | 523 | |
524 | 524 | // Long strings might contain expensive edge cases ... |
525 | - if ( 10000 < strlen( $piece ) ) { |
|
525 | + if (10000 < strlen($piece)) { |
|
526 | 526 | // ... break it up |
527 | - foreach ( _split_str_by_whitespace( $piece, 2100 ) as $chunk ) { // 2100: Extra room for scheme and leading and trailing paretheses |
|
528 | - if ( 2101 < strlen( $chunk ) ) { |
|
527 | + foreach (_split_str_by_whitespace($piece, 2100) as $chunk) { // 2100: Extra room for scheme and leading and trailing paretheses |
|
528 | + if (2101 < strlen($chunk)) { |
|
529 | 529 | $r .= $chunk; // Too big, no whitespace: bail. |
530 | 530 | } else { |
531 | - $r .= make_clickable( $chunk ); |
|
531 | + $r .= make_clickable($chunk); |
|
532 | 532 | } |
533 | 533 | } |
534 | 534 | } else { |
@@ -549,18 +549,18 @@ discard block |
||
549 | 549 | ~xS'; // The regex is a non-anchored pattern and does not have a single fixed starting character. |
550 | 550 | // Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times. |
551 | 551 | |
552 | - $ret = preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $ret ); |
|
552 | + $ret = preg_replace_callback($url_clickable, '_make_url_clickable_cb', $ret); |
|
553 | 553 | |
554 | - $ret = preg_replace_callback( '#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret ); |
|
555 | - $ret = preg_replace_callback( '#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret ); |
|
554 | + $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret); |
|
555 | + $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret); |
|
556 | 556 | |
557 | - $ret = substr( $ret, 1, -1 ); // Remove our whitespace padding. |
|
557 | + $ret = substr($ret, 1, -1); // Remove our whitespace padding. |
|
558 | 558 | $r .= $ret; |
559 | 559 | } |
560 | 560 | } |
561 | 561 | |
562 | 562 | // Cleanup of accidental links within links |
563 | - $r = preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r ); |
|
563 | + $r = preg_replace('#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r); |
|
564 | 564 | return $r; |
565 | 565 | } |
566 | 566 | |
@@ -595,27 +595,27 @@ discard block |
||
595 | 595 | * @param int $goal The desired chunk length. |
596 | 596 | * @return array Numeric array of chunks. |
597 | 597 | */ |
598 | -function _split_str_by_whitespace( $string, $goal ) { |
|
598 | +function _split_str_by_whitespace($string, $goal) { |
|
599 | 599 | $chunks = array(); |
600 | 600 | |
601 | - $string_nullspace = strtr( $string, "\r\n\t\v\f ", "\000\000\000\000\000\000" ); |
|
601 | + $string_nullspace = strtr($string, "\r\n\t\v\f ", "\000\000\000\000\000\000"); |
|
602 | 602 | |
603 | - while ( $goal < strlen( $string_nullspace ) ) { |
|
604 | - $pos = strrpos( substr( $string_nullspace, 0, $goal + 1 ), "\000" ); |
|
603 | + while ($goal < strlen($string_nullspace)) { |
|
604 | + $pos = strrpos(substr($string_nullspace, 0, $goal + 1), "\000"); |
|
605 | 605 | |
606 | - if ( false === $pos ) { |
|
607 | - $pos = strpos( $string_nullspace, "\000", $goal + 1 ); |
|
608 | - if ( false === $pos ) { |
|
606 | + if (false === $pos) { |
|
607 | + $pos = strpos($string_nullspace, "\000", $goal + 1); |
|
608 | + if (false === $pos) { |
|
609 | 609 | break; |
610 | 610 | } |
611 | 611 | } |
612 | 612 | |
613 | - $chunks[] = substr( $string, 0, $pos + 1 ); |
|
614 | - $string = substr( $string, $pos + 1 ); |
|
615 | - $string_nullspace = substr( $string_nullspace, $pos + 1 ); |
|
613 | + $chunks[] = substr($string, 0, $pos + 1); |
|
614 | + $string = substr($string, $pos + 1); |
|
615 | + $string_nullspace = substr($string_nullspace, $pos + 1); |
|
616 | 616 | } |
617 | 617 | |
618 | - if ( $string ) { |
|
618 | + if ($string) { |
|
619 | 619 | $chunks[] = $string; |
620 | 620 | } |
621 | 621 | |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | */ |
694 | 694 | function get_week_from_day($date) { |
695 | 695 | if (!empty($date)) { |
696 | - $time = api_strtotime($date,'UTC'); |
|
696 | + $time = api_strtotime($date, 'UTC'); |
|
697 | 697 | return date('W', $time); |
698 | 698 | } else { |
699 | 699 | return date('W'); |
@@ -710,17 +710,17 @@ discard block |
||
710 | 710 | * @return a reduce string |
711 | 711 | */ |
712 | 712 | |
713 | -function substrwords($text,$maxchar,$end='...') |
|
713 | +function substrwords($text, $maxchar, $end = '...') |
|
714 | 714 | { |
715 | - if(strlen($text)>$maxchar) |
|
715 | + if (strlen($text) > $maxchar) |
|
716 | 716 | { |
717 | - $words=explode(" ",$text); |
|
717 | + $words = explode(" ", $text); |
|
718 | 718 | $output = ''; |
719 | - $i=0; |
|
720 | - while(1) |
|
719 | + $i = 0; |
|
720 | + while (1) |
|
721 | 721 | { |
722 | - $length = (strlen($output)+strlen($words[$i])); |
|
723 | - if($length>$maxchar) |
|
722 | + $length = (strlen($output) + strlen($words[$i])); |
|
723 | + if ($length > $maxchar) |
|
724 | 724 | { |
725 | 725 | break; |
726 | 726 | } |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | function implode_with_key($glue, $array) { |
743 | 743 | if (!empty($array)) { |
744 | 744 | $string = ''; |
745 | - foreach($array as $key => $value) { |
|
745 | + foreach ($array as $key => $value) { |
|
746 | 746 | if (empty($value)) { |
747 | 747 | $value = 'null'; |
748 | 748 | } |
@@ -764,13 +764,13 @@ discard block |
||
764 | 764 | { |
765 | 765 | $file_size = intval($file_size); |
766 | 766 | if ($file_size >= 1073741824) { |
767 | - $file_size = round($file_size / 1073741824 * 100) / 100 . 'G'; |
|
768 | - } elseif($file_size >= 1048576) { |
|
769 | - $file_size = round($file_size / 1048576 * 100) / 100 . 'M'; |
|
770 | - } elseif($file_size >= 1024) { |
|
771 | - $file_size = round($file_size / 1024 * 100) / 100 . 'k'; |
|
767 | + $file_size = round($file_size / 1073741824 * 100) / 100.'G'; |
|
768 | + } elseif ($file_size >= 1048576) { |
|
769 | + $file_size = round($file_size / 1048576 * 100) / 100.'M'; |
|
770 | + } elseif ($file_size >= 1024) { |
|
771 | + $file_size = round($file_size / 1024 * 100) / 100.'k'; |
|
772 | 772 | } else { |
773 | - $file_size = $file_size . 'B'; |
|
773 | + $file_size = $file_size.'B'; |
|
774 | 774 | } |
775 | 775 | return $file_size; |
776 | 776 | } |
@@ -779,18 +779,18 @@ discard block |
||
779 | 779 | { |
780 | 780 | $year = '0000'; |
781 | 781 | $month = $day = $hours = $minutes = $seconds = '00'; |
782 | - if (isset($array['Y']) && (isset($array['F']) || isset($array['M'])) && isset($array['d']) && isset($array['H']) && isset($array['i'])) { |
|
782 | + if (isset($array['Y']) && (isset($array['F']) || isset($array['M'])) && isset($array['d']) && isset($array['H']) && isset($array['i'])) { |
|
783 | 783 | $year = $array['Y']; |
784 | - $month = isset($array['F'])?$array['F']:$array['M']; |
|
785 | - if (intval($month) < 10 ) $month = '0'.$month; |
|
784 | + $month = isset($array['F']) ? $array['F'] : $array['M']; |
|
785 | + if (intval($month) < 10) $month = '0'.$month; |
|
786 | 786 | $day = $array['d']; |
787 | - if (intval($day) < 10 ) $day = '0'.$day; |
|
787 | + if (intval($day) < 10) $day = '0'.$day; |
|
788 | 788 | $hours = $array['H']; |
789 | - if (intval($hours) < 10 ) $hours = '0'.$hours; |
|
789 | + if (intval($hours) < 10) $hours = '0'.$hours; |
|
790 | 790 | $minutes = $array['i']; |
791 | - if (intval($minutes) < 10 ) $minutes = '0'.$minutes; |
|
791 | + if (intval($minutes) < 10) $minutes = '0'.$minutes; |
|
792 | 792 | } |
793 | - if (checkdate($month,$day,$year)) { |
|
793 | + if (checkdate($month, $day, $year)) { |
|
794 | 794 | $datetime = $year.'-'.$month.'-'.$day.' '.$hours.':'.$minutes.':'.$seconds; |
795 | 795 | } |
796 | 796 | return $datetime; |