@@ -15,28 +15,28 @@ discard block |
||
15 | 15 | public static function hl($t, $C=1, $S=array()){ |
16 | 16 | $C = is_array($C) ? $C : array(); |
17 | 17 | if(!empty($C['valid_xhtml'])){ |
18 | - $C['elements'] = empty($C['elements']) ? '*-acronym-big-center-dir-font-isindex-s-strike-tt' : $C['elements']; |
|
19 | - $C['make_tag_strict'] = isset($C['make_tag_strict']) ? $C['make_tag_strict'] : 2; |
|
20 | - $C['xml:lang'] = isset($C['xml:lang']) ? $C['xml:lang'] : 2; |
|
18 | + $C['elements'] = empty($C['elements']) ? '*-acronym-big-center-dir-font-isindex-s-strike-tt' : $C['elements']; |
|
19 | + $C['make_tag_strict'] = isset($C['make_tag_strict']) ? $C['make_tag_strict'] : 2; |
|
20 | + $C['xml:lang'] = isset($C['xml:lang']) ? $C['xml:lang'] : 2; |
|
21 | 21 | } |
22 | 22 | // config eles |
23 | 23 | $e = array('a'=>1, 'abbr'=>1, 'acronym'=>1, 'address'=>1, 'applet'=>1, 'area'=>1, 'article'=>1, 'aside'=>1, 'audio'=>1, 'b'=>1, 'bdi'=>1, 'bdo'=>1, 'big'=>1, 'blockquote'=>1, 'br'=>1, 'button'=>1, 'canvas'=>1, 'caption'=>1, 'center'=>1, 'cite'=>1, 'code'=>1, 'col'=>1, 'colgroup'=>1, 'command'=>1, 'data'=>1, 'datalist'=>1, 'dd'=>1, 'del'=>1, 'details'=>1, 'dfn'=>1, 'dir'=>1, 'div'=>1, 'dl'=>1, 'dt'=>1, 'em'=>1, 'embed'=>1, 'fieldset'=>1, 'figcaption'=>1, 'figure'=>1, 'font'=>1, 'footer'=>1, 'form'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'header'=>1, 'hgroup'=>1, 'hr'=>1, 'i'=>1, 'iframe'=>1, 'img'=>1, 'input'=>1, 'ins'=>1, 'isindex'=>1, 'kbd'=>1, 'keygen'=>1, 'label'=>1, 'legend'=>1, 'li'=>1, 'link'=>1, 'main'=>1, 'map'=>1, 'mark'=>1, 'menu'=>1, 'meta'=>1, 'meter'=>1, 'nav'=>1, 'noscript'=>1, 'object'=>1, 'ol'=>1, 'optgroup'=>1, 'option'=>1, 'output'=>1, 'p'=>1, 'param'=>1, 'pre'=>1, 'progress'=>1, 'q'=>1, 'rb'=>1, 'rbc'=>1, 'rp'=>1, 'rt'=>1, 'rtc'=>1, 'ruby'=>1, 's'=>1, 'samp'=>1, 'script'=>1, 'section'=>1, 'select'=>1, 'small'=>1, 'source'=>1, 'span'=>1, 'strike'=>1, 'strong'=>1, 'style'=>1, 'sub'=>1, 'summary'=>1, 'sup'=>1, 'table'=>1, 'tbody'=>1, 'td'=>1, 'textarea'=>1, 'tfoot'=>1, 'th'=>1, 'thead'=>1, 'time'=>1, 'tr'=>1, 'track'=>1, 'tt'=>1, 'u'=>1, 'ul'=>1, 'var'=>1, 'video'=>1, 'wbr'=>1); // 118 incl. deprecated & some Ruby |
24 | 24 | |
25 | 25 | if(!empty($C['safe'])){ |
26 | - unset($e['applet'], $e['audio'], $e['canvas'], $e['embed'], $e['iframe'], $e['object'], $e['script'], $e['video']); |
|
26 | + unset($e['applet'], $e['audio'], $e['canvas'], $e['embed'], $e['iframe'], $e['object'], $e['script'], $e['video']); |
|
27 | 27 | } |
28 | 28 | $x = !empty($C['elements']) ? str_replace(array("\n", "\r", "\t", ' '), '', $C['elements']) : '*'; |
29 | 29 | if($x == '-*'){$e = array();} |
30 | 30 | elseif(strpos($x, '*') === false){$e = array_flip(explode(',', $x));} |
31 | 31 | else{ |
32 | - if(isset($x[1])){ |
|
33 | - preg_match_all('`(?:^|-|\+)[^\-+]+?(?=-|\+|$)`', $x, $m, PREG_SET_ORDER); |
|
34 | - for($i=count($m); --$i>=0;){$m[$i] = $m[$i][0];} |
|
35 | - foreach($m as $v){ |
|
36 | - if($v[0] == '+'){$e[substr($v, 1)] = 1;} |
|
37 | - if($v[0] == '-' && isset($e[($v = substr($v, 1))]) && !in_array('+'. $v, $m)){unset($e[$v]);} |
|
38 | - } |
|
39 | - } |
|
32 | + if(isset($x[1])){ |
|
33 | + preg_match_all('`(?:^|-|\+)[^\-+]+?(?=-|\+|$)`', $x, $m, PREG_SET_ORDER); |
|
34 | + for($i=count($m); --$i>=0;){$m[$i] = $m[$i][0];} |
|
35 | + foreach($m as $v){ |
|
36 | + if($v[0] == '+'){$e[substr($v, 1)] = 1;} |
|
37 | + if($v[0] == '-' && isset($e[($v = substr($v, 1))]) && !in_array('+'. $v, $m)){unset($e[$v]);} |
|
38 | + } |
|
39 | + } |
|
40 | 40 | } |
41 | 41 | $C['elements'] =& $e; |
42 | 42 | // config attrs |
@@ -47,17 +47,17 @@ discard block |
||
47 | 47 | $x = (isset($C['schemes'][2]) && strpos($C['schemes'], ':')) ? strtolower($C['schemes']) : 'href: aim, feed, file, ftp, gopher, http, https, irc, mailto, news, nntp, sftp, ssh, tel, telnet'. (empty($C['safe']) ? ', app, javascript; *: data, javascript, ' : '; *:'). 'file, http, https'; |
48 | 48 | $C['schemes'] = array(); |
49 | 49 | foreach(explode(';', str_replace(array(' ', "\t", "\r", "\n"), '', $x)) as $v){ |
50 | - $x = $x2 = null; list($x, $x2) = explode(':', $v, 2); |
|
51 | - if($x2){$C['schemes'][$x] = array_flip(explode(',', $x2));} |
|
50 | + $x = $x2 = null; list($x, $x2) = explode(':', $v, 2); |
|
51 | + if($x2){$C['schemes'][$x] = array_flip(explode(',', $x2));} |
|
52 | 52 | } |
53 | 53 | if(!isset($C['schemes']['*'])){ |
54 | - $C['schemes']['*'] = array('file'=>1, 'http'=>1, 'https'=>1); |
|
55 | - if(empty($C['safe'])){$C['schemes']['*'] += array('data'=>1, 'javascript'=>1);} |
|
54 | + $C['schemes']['*'] = array('file'=>1, 'http'=>1, 'https'=>1); |
|
55 | + if(empty($C['safe'])){$C['schemes']['*'] += array('data'=>1, 'javascript'=>1);} |
|
56 | 56 | } |
57 | 57 | if(!empty($C['safe']) && empty($C['schemes']['style'])){$C['schemes']['style'] = array('!'=>1);} |
58 | 58 | $C['abs_url'] = isset($C['abs_url']) ? $C['abs_url'] : 0; |
59 | 59 | if(!isset($C['base_url']) or !preg_match('`^[a-zA-Z\d.+\-]+://[^/]+/(.+?/)?$`', $C['base_url'])){ |
60 | - $C['base_url'] = $C['abs_url'] = 0; |
|
60 | + $C['base_url'] = $C['abs_url'] = 0; |
|
61 | 61 | } |
62 | 62 | // config rest |
63 | 63 | $C['and_mark'] = empty($C['and_mark']) ? 0 : 1; |
@@ -92,16 +92,16 @@ discard block |
||
92 | 92 | |
93 | 93 | $t = preg_replace('`[\x00-\x08\x0b-\x0c\x0e-\x1f]`', '', $t); |
94 | 94 | if($C['clean_ms_char']){ |
95 | - $x = array("\x7f"=>'', "\x80"=>'€', "\x81"=>'', "\x83"=>'ƒ', "\x85"=>'…', "\x86"=>'†', "\x87"=>'‡', "\x88"=>'ˆ', "\x89"=>'‰', "\x8a"=>'Š', "\x8b"=>'‹', "\x8c"=>'Œ', "\x8d"=>'', "\x8e"=>'Ž', "\x8f"=>'', "\x90"=>'', "\x95"=>'•', "\x96"=>'–', "\x97"=>'—', "\x98"=>'˜', "\x99"=>'™', "\x9a"=>'š', "\x9b"=>'›', "\x9c"=>'œ', "\x9d"=>'', "\x9e"=>'ž', "\x9f"=>'Ÿ'); |
|
96 | - $x = $x + ($C['clean_ms_char'] == 1 ? array("\x82"=>'‚', "\x84"=>'„', "\x91"=>'‘', "\x92"=>'’', "\x93"=>'“', "\x94"=>'”') : array("\x82"=>'\'', "\x84"=>'"', "\x91"=>'\'', "\x92"=>'\'', "\x93"=>'"', "\x94"=>'"')); |
|
97 | - $t = strtr($t, $x); |
|
95 | + $x = array("\x7f"=>'', "\x80"=>'€', "\x81"=>'', "\x83"=>'ƒ', "\x85"=>'…', "\x86"=>'†', "\x87"=>'‡', "\x88"=>'ˆ', "\x89"=>'‰', "\x8a"=>'Š', "\x8b"=>'‹', "\x8c"=>'Œ', "\x8d"=>'', "\x8e"=>'Ž', "\x8f"=>'', "\x90"=>'', "\x95"=>'•', "\x96"=>'–', "\x97"=>'—', "\x98"=>'˜', "\x99"=>'™', "\x9a"=>'š', "\x9b"=>'›', "\x9c"=>'œ', "\x9d"=>'', "\x9e"=>'ž', "\x9f"=>'Ÿ'); |
|
96 | + $x = $x + ($C['clean_ms_char'] == 1 ? array("\x82"=>'‚', "\x84"=>'„', "\x91"=>'‘', "\x92"=>'’', "\x93"=>'“', "\x94"=>'”') : array("\x82"=>'\'', "\x84"=>'"', "\x91"=>'\'', "\x92"=>'\'', "\x93"=>'"', "\x94"=>'"')); |
|
97 | + $t = strtr($t, $x); |
|
98 | 98 | } |
99 | 99 | if($C['cdata'] or $C['comment']){$t = preg_replace_callback('`<!(?:(?:--.*?--)|(?:\[CDATA\[.*?\]\]))>`sm', 'htmLawed::hl_cmtcd', $t);} |
100 | 100 | $t = preg_replace_callback('`&([a-zA-Z][a-zA-Z0-9]{1,30}|#(?:[0-9]{1,8}|[Xx][0-9A-Fa-f]{1,7}));`', 'htmLawed::hl_ent', str_replace('&', '&', $t)); |
101 | 101 | if($C['unique_ids'] && !isset($GLOBALS['hl_Ids'])){$GLOBALS['hl_Ids'] = array();} |
102 | 102 | if($C['hook']){$t = $C['hook']($t, $C, $S);} |
103 | 103 | if($C['show_setting'] && preg_match('`^[a-z][a-z0-9_]*$`i', $C['show_setting'])){ |
104 | - $GLOBALS[$C['show_setting']] = array('config'=>$C, 'spec'=>$S, 'time'=>microtime()); |
|
104 | + $GLOBALS[$C['show_setting']] = array('config'=>$C, 'spec'=>$S, 'time'=>microtime()); |
|
105 | 105 | } |
106 | 106 | // main |
107 | 107 | $t = preg_replace_callback('`<(?:(?:\s|$)|(?:[^>]*(?:>|$)))|>`m', 'htmLawed::hl_tag', $t); |
@@ -121,30 +121,30 @@ discard block |
||
121 | 121 | $r = array(); |
122 | 122 | $t = !empty($s) ? explode($s, $t) : array($t); |
123 | 123 | foreach($t as $tk=>$tv){ |
124 | - $o = 1; $tv = trim($tv); $l = strlen($tv); |
|
125 | - foreach($p as $k=>$v){ |
|
126 | - if(!$l){continue;} |
|
127 | - switch($k){ |
|
128 | - case 'maxlen': if($l > $v){$o = 0;} |
|
129 | - break; case 'minlen': if($l < $v){$o = 0;} |
|
130 | - break; case 'maxval': if((float)($tv) > $v){$o = 0;} |
|
131 | - break; case 'minval': if((float)($tv) < $v){$o = 0;} |
|
132 | - break; case 'match': if(!preg_match($v, $tv)){$o = 0;} |
|
133 | - break; case 'nomatch': if(preg_match($v, $tv)){$o = 0;} |
|
134 | - break; case 'oneof': |
|
124 | + $o = 1; $tv = trim($tv); $l = strlen($tv); |
|
125 | + foreach($p as $k=>$v){ |
|
126 | + if(!$l){continue;} |
|
127 | + switch($k){ |
|
128 | + case 'maxlen': if($l > $v){$o = 0;} |
|
129 | + break; case 'minlen': if($l < $v){$o = 0;} |
|
130 | + break; case 'maxval': if((float)($tv) > $v){$o = 0;} |
|
131 | + break; case 'minval': if((float)($tv) < $v){$o = 0;} |
|
132 | + break; case 'match': if(!preg_match($v, $tv)){$o = 0;} |
|
133 | + break; case 'nomatch': if(preg_match($v, $tv)){$o = 0;} |
|
134 | + break; case 'oneof': |
|
135 | 135 | $m = 0; |
136 | 136 | foreach(explode('|', $v) as $n){if($tv == $n){$m = 1; break;}} |
137 | 137 | $o = $m; |
138 | - break; case 'noneof': |
|
138 | + break; case 'noneof': |
|
139 | 139 | $m = 1; |
140 | 140 | foreach(explode('|', $v) as $n){if($tv == $n){$m = 0; break;}} |
141 | 141 | $o = $m; |
142 | - break; default: |
|
142 | + break; default: |
|
143 | 143 | break; |
144 | - } |
|
145 | - if(!$o){break;} |
|
146 | - } |
|
147 | - if($o){$r[] = $tv;} |
|
144 | + } |
|
145 | + if(!$o){break;} |
|
146 | + } |
|
147 | + if($o){$r[] = $tv;} |
|
148 | 148 | } |
149 | 149 | if($s == ','){$s = ', ';} |
150 | 150 | $r = implode($s, $r); |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | // $in sets allowed child |
175 | 175 | $in = ((isset($eF[$in]) && $in != '#pcdata') or isset($eO[$in])) ? $in : 'div'; |
176 | 176 | if(isset($cE[$in])){ |
177 | - return (!$do ? '' : str_replace(array('<', '>'), array('<', '>'), $t)); |
|
177 | + return (!$do ? '' : str_replace(array('<', '>'), array('<', '>'), $t)); |
|
178 | 178 | } |
179 | 179 | if(isset($cS[$in])){$inOk = $cS[$in];} |
180 | 180 | elseif(isset($cI[$in])){$inOk = $eI; $cI['del'] = 1; $cI['ins'] = 1;} |
@@ -188,116 +188,116 @@ discard block |
||
188 | 188 | ob_start(); |
189 | 189 | |
190 | 190 | for($i=-1, $ci=count($t); ++$i<$ci;){ |
191 | - // allowed $ok in parent $p |
|
192 | - if($ql = count($q)){ |
|
193 | - $p = array_pop($q); |
|
194 | - $q[] = $p; |
|
195 | - if(isset($cS[$p])){$ok = $cS[$p];} |
|
196 | - elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} |
|
197 | - elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} |
|
198 | - elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} |
|
199 | - if(isset($cO[$p])){$ok = $ok + $cO[$p];} |
|
200 | - if(isset($cN[$p])){$ok = array_diff_assoc($ok, $cN[$p]);} |
|
201 | - }else{$ok = $inOk; unset($cI['del'], $cI['ins']);} |
|
202 | - // bad tags, & ele content |
|
203 | - if(isset($e) && ($do == 1 or (isset($ok['#pcdata']) && ($do == 3 or $do == 5)))){ |
|
204 | - echo '<', $s, $e, $a, '>'; |
|
205 | - } |
|
206 | - if(isset($x[0])){ |
|
207 | - if(strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))){ |
|
208 | - echo '<div>', $x, '</div>'; |
|
209 | - } |
|
210 | - elseif($do < 3 or isset($ok['#pcdata'])){echo $x;} |
|
211 | - elseif(strpos($x, "\x02\x04")){ |
|
212 | - foreach(preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $v){ |
|
191 | + // allowed $ok in parent $p |
|
192 | + if($ql = count($q)){ |
|
193 | + $p = array_pop($q); |
|
194 | + $q[] = $p; |
|
195 | + if(isset($cS[$p])){$ok = $cS[$p];} |
|
196 | + elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} |
|
197 | + elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} |
|
198 | + elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} |
|
199 | + if(isset($cO[$p])){$ok = $ok + $cO[$p];} |
|
200 | + if(isset($cN[$p])){$ok = array_diff_assoc($ok, $cN[$p]);} |
|
201 | + }else{$ok = $inOk; unset($cI['del'], $cI['ins']);} |
|
202 | + // bad tags, & ele content |
|
203 | + if(isset($e) && ($do == 1 or (isset($ok['#pcdata']) && ($do == 3 or $do == 5)))){ |
|
204 | + echo '<', $s, $e, $a, '>'; |
|
205 | + } |
|
206 | + if(isset($x[0])){ |
|
207 | + if(strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))){ |
|
208 | + echo '<div>', $x, '</div>'; |
|
209 | + } |
|
210 | + elseif($do < 3 or isset($ok['#pcdata'])){echo $x;} |
|
211 | + elseif(strpos($x, "\x02\x04")){ |
|
212 | + foreach(preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $v){ |
|
213 | 213 | echo (substr($v, 0, 2) == "\x01\x02" ? $v : ($do > 4 ? preg_replace('`\S`', '', $v) : '')); |
214 | - } |
|
215 | - }elseif($do > 4){echo preg_replace('`\S`', '', $x);} |
|
216 | - } |
|
217 | - // get markup |
|
218 | - if(!preg_match('`^(/?)([a-z1-6]+)([^>]*)>(.*)`sm', $t[$i], $r)){$x = $t[$i]; continue;} |
|
219 | - $s = null; $e = null; $a = null; $x = null; list($all, $s, $e, $a, $x) = $r; |
|
220 | - // close tag |
|
221 | - if($s){ |
|
222 | - if(isset($cE[$e]) or !in_array($e, $q)){continue;} // Empty/unopen |
|
223 | - if($p == $e){array_pop($q); echo '</', $e, '>'; unset($e); continue;} // Last open |
|
224 | - $add = ''; // Nesting - close open tags that need to be |
|
225 | - for($j=-1, $cj=count($q); ++$j<$cj;){ |
|
226 | - if(($d = array_pop($q)) == $e){break;} |
|
227 | - else{$add .= "</{$d}>";} |
|
228 | - } |
|
229 | - echo $add, '</', $e, '>'; unset($e); continue; |
|
230 | - } |
|
231 | - // open tag |
|
232 | - // $cB ele needs $eB ele as child |
|
233 | - if(isset($cB[$e]) && strlen(trim($x))){ |
|
234 | - $t[$i] = "{$e}{$a}>"; |
|
235 | - array_splice($t, $i+1, 0, 'div>'. $x); unset($e, $x); ++$ci; --$i; continue; |
|
236 | - } |
|
237 | - if((($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql)) && !isset($eB[$e]) && !isset($ok[$e])){ |
|
238 | - array_splice($t, $i, 0, 'div>'); unset($e, $x); ++$ci; --$i; continue; |
|
239 | - } |
|
240 | - // if no open ele, $in = parent; mostly immediate parent-child relation should hold |
|
241 | - if(!$ql or !isset($eN[$e]) or !array_intersect($q, $cN2)){ |
|
242 | - if(!isset($ok[$e])){ |
|
243 | - if($ql && isset($cT[$p])){echo '</', array_pop($q), '>'; unset($e, $x); --$i;} |
|
244 | - continue; |
|
245 | - } |
|
246 | - if(!isset($cE[$e])){$q[] = $e;} |
|
247 | - echo '<', $e, $a, '>'; unset($e); continue; |
|
248 | - } |
|
249 | - // specific parent-child |
|
250 | - if(isset($cS[$p][$e])){ |
|
251 | - if(!isset($cE[$e])){$q[] = $e;} |
|
252 | - echo '<', $e, $a, '>'; unset($e); continue; |
|
253 | - } |
|
254 | - // nesting |
|
255 | - $add = ''; |
|
256 | - $q2 = array(); |
|
257 | - for($k=-1, $kc=count($q); ++$k<$kc;){ |
|
258 | - $d = $q[$k]; |
|
259 | - $ok2 = array(); |
|
260 | - if(isset($cS[$d])){$q2[] = $d; continue;} |
|
261 | - $ok2 = isset($cI[$d]) ? $eI : $eF; |
|
262 | - if(isset($cO[$d])){$ok2 = $ok2 + $cO[$d];} |
|
263 | - if(isset($cN[$d])){$ok2 = array_diff_assoc($ok2, $cN[$d]);} |
|
264 | - if(!isset($ok2[$e])){ |
|
265 | - if(!$k && !isset($inOk[$e])){continue 2;} |
|
266 | - $add = "</{$d}>"; |
|
267 | - for(;++$k<$kc;){$add = "</{$q[$k]}>{$add}";} |
|
268 | - break; |
|
269 | - } |
|
270 | - else{$q2[] = $d;} |
|
271 | - } |
|
272 | - $q = $q2; |
|
273 | - if(!isset($cE[$e])){$q[] = $e;} |
|
274 | - echo $add, '<', $e, $a, '>'; unset($e); continue; |
|
214 | + } |
|
215 | + }elseif($do > 4){echo preg_replace('`\S`', '', $x);} |
|
216 | + } |
|
217 | + // get markup |
|
218 | + if(!preg_match('`^(/?)([a-z1-6]+)([^>]*)>(.*)`sm', $t[$i], $r)){$x = $t[$i]; continue;} |
|
219 | + $s = null; $e = null; $a = null; $x = null; list($all, $s, $e, $a, $x) = $r; |
|
220 | + // close tag |
|
221 | + if($s){ |
|
222 | + if(isset($cE[$e]) or !in_array($e, $q)){continue;} // Empty/unopen |
|
223 | + if($p == $e){array_pop($q); echo '</', $e, '>'; unset($e); continue;} // Last open |
|
224 | + $add = ''; // Nesting - close open tags that need to be |
|
225 | + for($j=-1, $cj=count($q); ++$j<$cj;){ |
|
226 | + if(($d = array_pop($q)) == $e){break;} |
|
227 | + else{$add .= "</{$d}>";} |
|
228 | + } |
|
229 | + echo $add, '</', $e, '>'; unset($e); continue; |
|
230 | + } |
|
231 | + // open tag |
|
232 | + // $cB ele needs $eB ele as child |
|
233 | + if(isset($cB[$e]) && strlen(trim($x))){ |
|
234 | + $t[$i] = "{$e}{$a}>"; |
|
235 | + array_splice($t, $i+1, 0, 'div>'. $x); unset($e, $x); ++$ci; --$i; continue; |
|
236 | + } |
|
237 | + if((($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql)) && !isset($eB[$e]) && !isset($ok[$e])){ |
|
238 | + array_splice($t, $i, 0, 'div>'); unset($e, $x); ++$ci; --$i; continue; |
|
239 | + } |
|
240 | + // if no open ele, $in = parent; mostly immediate parent-child relation should hold |
|
241 | + if(!$ql or !isset($eN[$e]) or !array_intersect($q, $cN2)){ |
|
242 | + if(!isset($ok[$e])){ |
|
243 | + if($ql && isset($cT[$p])){echo '</', array_pop($q), '>'; unset($e, $x); --$i;} |
|
244 | + continue; |
|
245 | + } |
|
246 | + if(!isset($cE[$e])){$q[] = $e;} |
|
247 | + echo '<', $e, $a, '>'; unset($e); continue; |
|
248 | + } |
|
249 | + // specific parent-child |
|
250 | + if(isset($cS[$p][$e])){ |
|
251 | + if(!isset($cE[$e])){$q[] = $e;} |
|
252 | + echo '<', $e, $a, '>'; unset($e); continue; |
|
253 | + } |
|
254 | + // nesting |
|
255 | + $add = ''; |
|
256 | + $q2 = array(); |
|
257 | + for($k=-1, $kc=count($q); ++$k<$kc;){ |
|
258 | + $d = $q[$k]; |
|
259 | + $ok2 = array(); |
|
260 | + if(isset($cS[$d])){$q2[] = $d; continue;} |
|
261 | + $ok2 = isset($cI[$d]) ? $eI : $eF; |
|
262 | + if(isset($cO[$d])){$ok2 = $ok2 + $cO[$d];} |
|
263 | + if(isset($cN[$d])){$ok2 = array_diff_assoc($ok2, $cN[$d]);} |
|
264 | + if(!isset($ok2[$e])){ |
|
265 | + if(!$k && !isset($inOk[$e])){continue 2;} |
|
266 | + $add = "</{$d}>"; |
|
267 | + for(;++$k<$kc;){$add = "</{$q[$k]}>{$add}";} |
|
268 | + break; |
|
269 | + } |
|
270 | + else{$q2[] = $d;} |
|
271 | + } |
|
272 | + $q = $q2; |
|
273 | + if(!isset($cE[$e])){$q[] = $e;} |
|
274 | + echo $add, '<', $e, $a, '>'; unset($e); continue; |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | // end |
278 | 278 | if($ql = count($q)){ |
279 | - $p = array_pop($q); |
|
280 | - $q[] = $p; |
|
281 | - if(isset($cS[$p])){$ok = $cS[$p];} |
|
282 | - elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} |
|
283 | - elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} |
|
284 | - elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} |
|
285 | - if(isset($cO[$p])){$ok = $ok + $cO[$p];} |
|
286 | - if(isset($cN[$p])){$ok = array_diff_assoc($ok, $cN[$p]);} |
|
279 | + $p = array_pop($q); |
|
280 | + $q[] = $p; |
|
281 | + if(isset($cS[$p])){$ok = $cS[$p];} |
|
282 | + elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} |
|
283 | + elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} |
|
284 | + elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} |
|
285 | + if(isset($cO[$p])){$ok = $ok + $cO[$p];} |
|
286 | + if(isset($cN[$p])){$ok = array_diff_assoc($ok, $cN[$p]);} |
|
287 | 287 | }else{$ok = $inOk; unset($cI['del'], $cI['ins']);} |
288 | 288 | if(isset($e) && ($do == 1 or (isset($ok['#pcdata']) && ($do == 3 or $do == 5)))){ |
289 | - echo '<', $s, $e, $a, '>'; |
|
289 | + echo '<', $s, $e, $a, '>'; |
|
290 | 290 | } |
291 | 291 | if(isset($x[0])){ |
292 | - if(strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))){ |
|
293 | - echo '<div>', $x, '</div>'; |
|
294 | - } |
|
295 | - elseif($do < 3 or isset($ok['#pcdata'])){echo $x;} |
|
296 | - elseif(strpos($x, "\x02\x04")){ |
|
297 | - foreach(preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $v){ |
|
298 | - echo (substr($v, 0, 2) == "\x01\x02" ? $v : ($do > 4 ? preg_replace('`\S`', '', $v) : '')); |
|
299 | - } |
|
300 | - }elseif($do > 4){echo preg_replace('`\S`', '', $x);} |
|
292 | + if(strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))){ |
|
293 | + echo '<div>', $x, '</div>'; |
|
294 | + } |
|
295 | + elseif($do < 3 or isset($ok['#pcdata'])){echo $x;} |
|
296 | + elseif(strpos($x, "\x02\x04")){ |
|
297 | + foreach(preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $v){ |
|
298 | + echo (substr($v, 0, 2) == "\x01\x02" ? $v : ($do > 4 ? preg_replace('`\S`', '', $v) : '')); |
|
299 | + } |
|
300 | + }elseif($do > 4){echo preg_replace('`\S`', '', $x);} |
|
301 | 301 | } |
302 | 302 | while(!empty($q) && ($e = array_pop($q))){echo '</', $e, '>';} |
303 | 303 | $o = ob_get_contents(); |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | if(!($v = $C[$n = $t[3] == '-' ? 'comment' : 'cdata'])){return $t;} |
313 | 313 | if($v == 1){return '';} |
314 | 314 | if($n == 'comment' && $v < 4){ |
315 | - if(substr(($t = preg_replace('`--+`', '-', substr($t, 4, -3))), -1) != ' '){$t .= ' ';} |
|
315 | + if(substr(($t = preg_replace('`--+`', '-', substr($t, 4, -3))), -1) != ' '){$t .= ' ';} |
|
316 | 316 | } |
317 | 317 | else{$t = substr($t, 1, -1);} |
318 | 318 | $t = $v == 2 ? str_replace(array('&', '<', '>'), array('&', '<', '>'), $t) : $t; |
@@ -326,10 +326,10 @@ discard block |
||
326 | 326 | static $U = array('quot'=>1,'amp'=>1,'lt'=>1,'gt'=>1); |
327 | 327 | static $N = array('fnof'=>'402', 'Alpha'=>'913', 'Beta'=>'914', 'Gamma'=>'915', 'Delta'=>'916', 'Epsilon'=>'917', 'Zeta'=>'918', 'Eta'=>'919', 'Theta'=>'920', 'Iota'=>'921', 'Kappa'=>'922', 'Lambda'=>'923', 'Mu'=>'924', 'Nu'=>'925', 'Xi'=>'926', 'Omicron'=>'927', 'Pi'=>'928', 'Rho'=>'929', 'Sigma'=>'931', 'Tau'=>'932', 'Upsilon'=>'933', 'Phi'=>'934', 'Chi'=>'935', 'Psi'=>'936', 'Omega'=>'937', 'alpha'=>'945', 'beta'=>'946', 'gamma'=>'947', 'delta'=>'948', 'epsilon'=>'949', 'zeta'=>'950', 'eta'=>'951', 'theta'=>'952', 'iota'=>'953', 'kappa'=>'954', 'lambda'=>'955', 'mu'=>'956', 'nu'=>'957', 'xi'=>'958', 'omicron'=>'959', 'pi'=>'960', 'rho'=>'961', 'sigmaf'=>'962', 'sigma'=>'963', 'tau'=>'964', 'upsilon'=>'965', 'phi'=>'966', 'chi'=>'967', 'psi'=>'968', 'omega'=>'969', 'thetasym'=>'977', 'upsih'=>'978', 'piv'=>'982', 'bull'=>'8226', 'hellip'=>'8230', 'prime'=>'8242', 'Prime'=>'8243', 'oline'=>'8254', 'frasl'=>'8260', 'weierp'=>'8472', 'image'=>'8465', 'real'=>'8476', 'trade'=>'8482', 'alefsym'=>'8501', 'larr'=>'8592', 'uarr'=>'8593', 'rarr'=>'8594', 'darr'=>'8595', 'harr'=>'8596', 'crarr'=>'8629', 'lArr'=>'8656', 'uArr'=>'8657', 'rArr'=>'8658', 'dArr'=>'8659', 'hArr'=>'8660', 'forall'=>'8704', 'part'=>'8706', 'exist'=>'8707', 'empty'=>'8709', 'nabla'=>'8711', 'isin'=>'8712', 'notin'=>'8713', 'ni'=>'8715', 'prod'=>'8719', 'sum'=>'8721', 'minus'=>'8722', 'lowast'=>'8727', 'radic'=>'8730', 'prop'=>'8733', 'infin'=>'8734', 'ang'=>'8736', 'and'=>'8743', 'or'=>'8744', 'cap'=>'8745', 'cup'=>'8746', 'int'=>'8747', 'there4'=>'8756', 'sim'=>'8764', 'cong'=>'8773', 'asymp'=>'8776', 'ne'=>'8800', 'equiv'=>'8801', 'le'=>'8804', 'ge'=>'8805', 'sub'=>'8834', 'sup'=>'8835', 'nsub'=>'8836', 'sube'=>'8838', 'supe'=>'8839', 'oplus'=>'8853', 'otimes'=>'8855', 'perp'=>'8869', 'sdot'=>'8901', 'lceil'=>'8968', 'rceil'=>'8969', 'lfloor'=>'8970', 'rfloor'=>'8971', 'lang'=>'9001', 'rang'=>'9002', 'loz'=>'9674', 'spades'=>'9824', 'clubs'=>'9827', 'hearts'=>'9829', 'diams'=>'9830', 'apos'=>'39', 'OElig'=>'338', 'oelig'=>'339', 'Scaron'=>'352', 'scaron'=>'353', 'Yuml'=>'376', 'circ'=>'710', 'tilde'=>'732', 'ensp'=>'8194', 'emsp'=>'8195', 'thinsp'=>'8201', 'zwnj'=>'8204', 'zwj'=>'8205', 'lrm'=>'8206', 'rlm'=>'8207', 'ndash'=>'8211', 'mdash'=>'8212', 'lsquo'=>'8216', 'rsquo'=>'8217', 'sbquo'=>'8218', 'ldquo'=>'8220', 'rdquo'=>'8221', 'bdquo'=>'8222', 'dagger'=>'8224', 'Dagger'=>'8225', 'permil'=>'8240', 'lsaquo'=>'8249', 'rsaquo'=>'8250', 'euro'=>'8364', 'nbsp'=>'160', 'iexcl'=>'161', 'cent'=>'162', 'pound'=>'163', 'curren'=>'164', 'yen'=>'165', 'brvbar'=>'166', 'sect'=>'167', 'uml'=>'168', 'copy'=>'169', 'ordf'=>'170', 'laquo'=>'171', 'not'=>'172', 'shy'=>'173', 'reg'=>'174', 'macr'=>'175', 'deg'=>'176', 'plusmn'=>'177', 'sup2'=>'178', 'sup3'=>'179', 'acute'=>'180', 'micro'=>'181', 'para'=>'182', 'middot'=>'183', 'cedil'=>'184', 'sup1'=>'185', 'ordm'=>'186', 'raquo'=>'187', 'frac14'=>'188', 'frac12'=>'189', 'frac34'=>'190', 'iquest'=>'191', 'Agrave'=>'192', 'Aacute'=>'193', 'Acirc'=>'194', 'Atilde'=>'195', 'Auml'=>'196', 'Aring'=>'197', 'AElig'=>'198', 'Ccedil'=>'199', 'Egrave'=>'200', 'Eacute'=>'201', 'Ecirc'=>'202', 'Euml'=>'203', 'Igrave'=>'204', 'Iacute'=>'205', 'Icirc'=>'206', 'Iuml'=>'207', 'ETH'=>'208', 'Ntilde'=>'209', 'Ograve'=>'210', 'Oacute'=>'211', 'Ocirc'=>'212', 'Otilde'=>'213', 'Ouml'=>'214', 'times'=>'215', 'Oslash'=>'216', 'Ugrave'=>'217', 'Uacute'=>'218', 'Ucirc'=>'219', 'Uuml'=>'220', 'Yacute'=>'221', 'THORN'=>'222', 'szlig'=>'223', 'agrave'=>'224', 'aacute'=>'225', 'acirc'=>'226', 'atilde'=>'227', 'auml'=>'228', 'aring'=>'229', 'aelig'=>'230', 'ccedil'=>'231', 'egrave'=>'232', 'eacute'=>'233', 'ecirc'=>'234', 'euml'=>'235', 'igrave'=>'236', 'iacute'=>'237', 'icirc'=>'238', 'iuml'=>'239', 'eth'=>'240', 'ntilde'=>'241', 'ograve'=>'242', 'oacute'=>'243', 'ocirc'=>'244', 'otilde'=>'245', 'ouml'=>'246', 'divide'=>'247', 'oslash'=>'248', 'ugrave'=>'249', 'uacute'=>'250', 'ucirc'=>'251', 'uuml'=>'252', 'yacute'=>'253', 'thorn'=>'254', 'yuml'=>'255'); |
328 | 328 | if($t[0] != '#'){ |
329 | - return ($C['and_mark'] ? "\x06" : '&'). (isset($U[$t]) ? $t : (isset($N[$t]) ? (!$C['named_entity'] ? '#'. ($C['hexdec_entity'] > 1 ? 'x'. dechex($N[$t]) : $N[$t]) : $t) : 'amp;'. $t)). ';'; |
|
329 | + return ($C['and_mark'] ? "\x06" : '&'). (isset($U[$t]) ? $t : (isset($N[$t]) ? (!$C['named_entity'] ? '#'. ($C['hexdec_entity'] > 1 ? 'x'. dechex($N[$t]) : $N[$t]) : $t) : 'amp;'. $t)). ';'; |
|
330 | 330 | } |
331 | 331 | if(($n = ctype_digit($t = substr($t, 1)) ? intval($t) : hexdec(substr($t, 1))) < 9 or ($n > 13 && $n < 32) or $n == 11 or $n == 12 or ($n > 126 && $n < 160 && $n != 133) or ($n > 55295 && ($n < 57344 or ($n > 64975 && $n < 64992) or $n == 65534 or $n == 65535 or $n > 1114111))){ |
332 | - return ($C['and_mark'] ? "\x06" : '&'). "amp;#{$t};"; |
|
332 | + return ($C['and_mark'] ? "\x06" : '&'). "amp;#{$t};"; |
|
333 | 333 | } |
334 | 334 | return ($C['and_mark'] ? "\x06" : '&'). '#'. (((ctype_digit($t) && $C['hexdec_entity'] < 2) or !$C['hexdec_entity']) ? $n : 'x'. dechex($n)). ';'; |
335 | 335 | } |
@@ -344,24 +344,24 @@ discard block |
||
344 | 344 | if(isset($c['!']) && substr($p, 0, 7) != $d){$p = "$d$p";} |
345 | 345 | if(isset($c['*']) or !strcspn($p, '#?;') or (substr($p, 0, 7) == $d)){return "{$b}{$p}{$a}";} // All ok, frag, query, param |
346 | 346 | if(preg_match('`^([^:?[@!$()*,=/\'\]]+?)(:|&#(58|x3a);|%3a|\\\\0{0,4}3a).`i', $p, $m) && !isset($c[strtolower($m[1])])){ // Denied prot |
347 | - return "{$b}{$d}{$p}{$a}"; |
|
347 | + return "{$b}{$d}{$p}{$a}"; |
|
348 | 348 | } |
349 | 349 | if($C['abs_url']){ |
350 | - if($C['abs_url'] == -1 && strpos($p, $C['base_url']) === 0){ // Make url rel |
|
351 | - $p = substr($p, strlen($C['base_url'])); |
|
352 | - }elseif(empty($m[1])){ // Make URL abs |
|
353 | - if(substr($p, 0, 2) == '//'){$p = substr($C['base_url'], 0, strpos($C['base_url'], ':')+1). $p;} |
|
354 | - elseif($p[0] == '/'){$p = preg_replace('`(^.+?://[^/]+)(.*)`', '$1', $C['base_url']). $p;} |
|
355 | - elseif(strcspn($p, './')){$p = $C['base_url']. $p;} |
|
356 | - else{ |
|
357 | - preg_match('`^([a-zA-Z\d\-+.]+://[^/]+)(.*)`', $C['base_url'], $m); |
|
358 | - $p = preg_replace('`(?<=/)\./`', '', $m[2]. $p); |
|
359 | - while(preg_match('`(?<=/)([^/]{3,}|[^/.]+?|\.[^/.]|[^/.]\.)/\.\./`', $p)){ |
|
350 | + if($C['abs_url'] == -1 && strpos($p, $C['base_url']) === 0){ // Make url rel |
|
351 | + $p = substr($p, strlen($C['base_url'])); |
|
352 | + }elseif(empty($m[1])){ // Make URL abs |
|
353 | + if(substr($p, 0, 2) == '//'){$p = substr($C['base_url'], 0, strpos($C['base_url'], ':')+1). $p;} |
|
354 | + elseif($p[0] == '/'){$p = preg_replace('`(^.+?://[^/]+)(.*)`', '$1', $C['base_url']). $p;} |
|
355 | + elseif(strcspn($p, './')){$p = $C['base_url']. $p;} |
|
356 | + else{ |
|
357 | + preg_match('`^([a-zA-Z\d\-+.]+://[^/]+)(.*)`', $C['base_url'], $m); |
|
358 | + $p = preg_replace('`(?<=/)\./`', '', $m[2]. $p); |
|
359 | + while(preg_match('`(?<=/)([^/]{3,}|[^/.]+?|\.[^/.]|[^/.]\.)/\.\./`', $p)){ |
|
360 | 360 | $p = preg_replace('`(?<=/)([^/]{3,}|[^/.]+?|\.[^/.]|[^/.]\.)/\.\./`', '', $p); |
361 | - } |
|
362 | - $p = $m[1]. $p; |
|
363 | - } |
|
364 | - } |
|
361 | + } |
|
362 | + $p = $m[1]. $p; |
|
363 | + } |
|
364 | + } |
|
365 | 365 | } |
366 | 366 | return "{$b}{$p}{$a}"; |
367 | 367 | } |
@@ -371,17 +371,17 @@ discard block |
||
371 | 371 | if(empty($p)){return 0;} |
372 | 372 | if($v = function_exists('error_clear_last') && function_exists('error_get_last')){error_clear_last();} |
373 | 373 | else{ |
374 | - if($t = ini_get('track_errors')){$o = isset($php_errormsg) ? $php_errormsg : null;} |
|
375 | - else{ini_set('track_errors', 1);} |
|
376 | - unset($php_errormsg); |
|
374 | + if($t = ini_get('track_errors')){$o = isset($php_errormsg) ? $php_errormsg : null;} |
|
375 | + else{ini_set('track_errors', 1);} |
|
376 | + unset($php_errormsg); |
|
377 | 377 | } |
378 | 378 | if(($d = ini_get('display_errors'))){ini_set('display_errors', 0);} |
379 | 379 | preg_match($p, ''); |
380 | 380 | if($v){$r = error_get_last() == null ? 1 : 0; } |
381 | 381 | else{ |
382 | - $r = isset($php_errormsg) ? 0 : 1; |
|
383 | - if($t){$php_errormsg = isset($o) ? $o : null;} |
|
384 | - else{ini_set('track_errors', 0);} |
|
382 | + $r = isset($php_errormsg) ? 0 : 1; |
|
383 | + if($t){$php_errormsg = isset($o) ? $o : null;} |
|
384 | + else{ini_set('track_errors', 0);} |
|
385 | 385 | } |
386 | 386 | if($d){ini_set('display_errors', 1);} |
387 | 387 | return $r; |
@@ -391,31 +391,31 @@ discard block |
||
391 | 391 | // final $spec |
392 | 392 | $s = array(); |
393 | 393 | if(!function_exists('hl_aux1')){function hl_aux1($m){ |
394 | - return substr(str_replace(array(";", "|", "~", " ", ",", "/", "(", ")", '`"'), array("\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", '"'), $m[0]), 1, -1); |
|
394 | + return substr(str_replace(array(";", "|", "~", " ", ",", "/", "(", ")", '`"'), array("\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", '"'), $m[0]), 1, -1); |
|
395 | 395 | }} |
396 | 396 | $t = str_replace(array("\t", "\r", "\n", ' '), '', preg_replace_callback('/"(?>(`.|[^"])*)"/sm', 'hl_aux1', trim($t))); |
397 | 397 | for($i = count(($t = explode(';', $t))); --$i>=0;){ |
398 | - $w = $t[$i]; |
|
399 | - if(empty($w) or ($e = strpos($w, '=')) === false or !strlen(($a = substr($w, $e+1)))){continue;} |
|
400 | - $y = $n = array(); |
|
401 | - foreach(explode(',', $a) as $v){ |
|
402 | - if(!preg_match('`^([a-z:\-\*]+)(?:\((.*?)\))?`i', $v, $m)){continue;} |
|
403 | - if(($x = strtolower($m[1])) == '-*'){$n['*'] = 1; continue;} |
|
404 | - if($x[0] == '-'){$n[substr($x, 1)] = 1; continue;} |
|
405 | - if(!isset($m[2])){$y[$x] = 1; continue;} |
|
406 | - foreach(explode('/', $m[2]) as $m){ |
|
407 | - if(empty($m) or ($p = strpos($m, '=')) == 0 or $p < 5){$y[$x] = 1; continue;} |
|
408 | - $y[$x][strtolower(substr($m, 0, $p))] = str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08"), array(";", "|", "~", " ", ",", "/", "(", ")"), substr($m, $p+1)); |
|
409 | - } |
|
410 | - if(isset($y[$x]['match']) && !htmLawed::hl_regex($y[$x]['match'])){unset($y[$x]['match']);} |
|
411 | - if(isset($y[$x]['nomatch']) && !htmLawed::hl_regex($y[$x]['nomatch'])){unset($y[$x]['nomatch']);} |
|
412 | - } |
|
413 | - if(!count($y) && !count($n)){continue;} |
|
414 | - foreach(explode(',', substr($w, 0, $e)) as $v){ |
|
415 | - if(!strlen(($v = strtolower($v)))){continue;} |
|
416 | - if(count($y)){if(!isset($s[$v])){$s[$v] = $y;} else{$s[$v] = array_merge($s[$v], $y);}} |
|
417 | - if(count($n)){if(!isset($s[$v]['n'])){$s[$v]['n'] = $n;} else{$s[$v]['n'] = array_merge($s[$v]['n'], $n);}} |
|
418 | - } |
|
398 | + $w = $t[$i]; |
|
399 | + if(empty($w) or ($e = strpos($w, '=')) === false or !strlen(($a = substr($w, $e+1)))){continue;} |
|
400 | + $y = $n = array(); |
|
401 | + foreach(explode(',', $a) as $v){ |
|
402 | + if(!preg_match('`^([a-z:\-\*]+)(?:\((.*?)\))?`i', $v, $m)){continue;} |
|
403 | + if(($x = strtolower($m[1])) == '-*'){$n['*'] = 1; continue;} |
|
404 | + if($x[0] == '-'){$n[substr($x, 1)] = 1; continue;} |
|
405 | + if(!isset($m[2])){$y[$x] = 1; continue;} |
|
406 | + foreach(explode('/', $m[2]) as $m){ |
|
407 | + if(empty($m) or ($p = strpos($m, '=')) == 0 or $p < 5){$y[$x] = 1; continue;} |
|
408 | + $y[$x][strtolower(substr($m, 0, $p))] = str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08"), array(";", "|", "~", " ", ",", "/", "(", ")"), substr($m, $p+1)); |
|
409 | + } |
|
410 | + if(isset($y[$x]['match']) && !htmLawed::hl_regex($y[$x]['match'])){unset($y[$x]['match']);} |
|
411 | + if(isset($y[$x]['nomatch']) && !htmLawed::hl_regex($y[$x]['nomatch'])){unset($y[$x]['nomatch']);} |
|
412 | + } |
|
413 | + if(!count($y) && !count($n)){continue;} |
|
414 | + foreach(explode(',', substr($w, 0, $e)) as $v){ |
|
415 | + if(!strlen(($v = strtolower($v)))){continue;} |
|
416 | + if(count($y)){if(!isset($s[$v])){$s[$v] = $y;} else{$s[$v] = array_merge($s[$v], $y);}} |
|
417 | + if(count($n)){if(!isset($s[$v]['n'])){$s[$v]['n'] = $n;} else{$s[$v]['n'] = array_merge($s[$v]['n'], $n);}} |
|
418 | + } |
|
419 | 419 | } |
420 | 420 | return $s; |
421 | 421 | } |
@@ -428,22 +428,22 @@ discard block |
||
428 | 428 | if($t == '< '){return '< ';} |
429 | 429 | if($t == '>'){return '>';} |
430 | 430 | if(!preg_match('`^<(/?)([a-zA-Z][a-zA-Z1-6]*)([^>]*?)\s?>$`m', $t, $m)){ |
431 | - return str_replace(array('<', '>'), array('<', '>'), $t); |
|
431 | + return str_replace(array('<', '>'), array('<', '>'), $t); |
|
432 | 432 | }elseif(!isset($C['elements'][($e = strtolower($m[2]))])){ |
433 | - return (($C['keep_bad']%2) ? str_replace(array('<', '>'), array('<', '>'), $t) : ''); |
|
433 | + return (($C['keep_bad']%2) ? str_replace(array('<', '>'), array('<', '>'), $t) : ''); |
|
434 | 434 | } |
435 | 435 | // attr string |
436 | 436 | $a = str_replace(array("\n", "\r", "\t"), ' ', trim($m[3])); |
437 | 437 | // tag transform |
438 | 438 | static $eD = array('acronym'=>1, 'applet'=>1, 'big'=>1, 'center'=>1, 'dir'=>1, 'font'=>1, 'isindex'=>1, 's'=>1, 'strike'=>1, 'tt'=>1); // Deprecated |
439 | 439 | if($C['make_tag_strict'] && isset($eD[$e])){ |
440 | - $trt = htmLawed::hl_tag2($e, $a, $C['make_tag_strict']); |
|
441 | - if(!$e){return (($C['keep_bad']%2) ? str_replace(array('<', '>'), array('<', '>'), $t) : '');} |
|
440 | + $trt = htmLawed::hl_tag2($e, $a, $C['make_tag_strict']); |
|
441 | + if(!$e){return (($C['keep_bad']%2) ? str_replace(array('<', '>'), array('<', '>'), $t) : '');} |
|
442 | 442 | } |
443 | 443 | // close tag |
444 | 444 | static $eE = array('area'=>1, 'br'=>1, 'col'=>1, 'command'=>1, 'embed'=>1, 'hr'=>1, 'img'=>1, 'input'=>1, 'isindex'=>1, 'keygen'=>1, 'link'=>1, 'meta'=>1, 'param'=>1, 'source'=>1, 'track'=>1, 'wbr'=>1); // Empty ele |
445 | 445 | if(!empty($m[1])){ |
446 | - return (!isset($eE[$e]) ? (empty($C['hook_tag']) ? "</$e>" : $C['hook_tag']($e)) : (($C['keep_bad'])%2 ? str_replace(array('<', '>'), array('<', '>'), $t) : '')); |
|
446 | + return (!isset($eE[$e]) ? (empty($C['hook_tag']) ? "</$e>" : $C['hook_tag']($e)) : (($C['keep_bad'])%2 ? str_replace(array('<', '>'), array('<', '>'), $t) : '')); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | // open tag & attr |
@@ -455,49 +455,49 @@ discard block |
||
455 | 455 | static $aNU = array('accesskey'=>1, 'class'=>1, 'contenteditable'=>1, 'contextmenu'=>1, 'dir'=>1, 'draggable'=>1, 'dropzone'=>1, 'hidden'=>1, 'id'=>1, 'inert'=>1, 'itemid'=>1, 'itemprop'=>1, 'itemref'=>1, 'itemscope'=>1, 'itemtype'=>1, 'lang'=>1, 'role'=>1, 'spellcheck'=>1, 'style'=>1, 'tabindex'=>1, 'title'=>1, 'translate'=>1, 'xmlns'=>1, 'xml:base'=>1, 'xml:lang'=>1, 'xml:space'=>1); // Univ; excludes on*, aria* |
456 | 456 | |
457 | 457 | if($C['lc_std_val']){ |
458 | - // predef attr vals for $eAL & $aNE ele |
|
459 | - static $aNL = array('all'=>1, 'auto'=>1, 'baseline'=>1, 'bottom'=>1, 'button'=>1, 'captions'=>1, 'center'=>1, 'chapters'=>1, 'char'=>1, 'checkbox'=>1, 'circle'=>1, 'col'=>1, 'colgroup'=>1, 'color'=>1, 'cols'=>1, 'data'=>1, 'date'=>1, 'datetime'=>1, 'datetime-local'=>1, 'default'=>1, 'descriptions'=>1, 'email'=>1, 'file'=>1, 'get'=>1, 'groups'=>1, 'hidden'=>1, 'image'=>1, 'justify'=>1, 'left'=>1, 'ltr'=>1, 'metadata'=>1, 'middle'=>1, 'month'=>1, 'none'=>1, 'number'=>1, 'object'=>1, 'password'=>1, 'poly'=>1, 'post'=>1, 'preserve'=>1, 'radio'=>1, 'range'=>1, 'rect'=>1, 'ref'=>1, 'reset'=>1, 'right'=>1, 'row'=>1, 'rowgroup'=>1, 'rows'=>1, 'rtl'=>1, 'search'=>1, 'submit'=>1, 'subtitles'=>1, 'tel'=>1, 'text'=>1, 'time'=>1, 'top'=>1, 'url'=>1, 'week'=>1); |
|
460 | - static $eAL = array('a'=>1, 'area'=>1, 'bdo'=>1, 'button'=>1, 'col'=>1, 'fieldset'=>1, 'form'=>1, 'img'=>1, 'input'=>1, 'object'=>1, 'ol'=>1, 'optgroup'=>1, 'option'=>1, 'param'=>1, 'script'=>1, 'select'=>1, 'table'=>1, 'td'=>1, 'textarea'=>1, 'tfoot'=>1, 'th'=>1, 'thead'=>1, 'tr'=>1, 'track'=>1, 'xml:space'=>1); |
|
461 | - $lcase = isset($eAL[$e]) ? 1 : 0; |
|
458 | + // predef attr vals for $eAL & $aNE ele |
|
459 | + static $aNL = array('all'=>1, 'auto'=>1, 'baseline'=>1, 'bottom'=>1, 'button'=>1, 'captions'=>1, 'center'=>1, 'chapters'=>1, 'char'=>1, 'checkbox'=>1, 'circle'=>1, 'col'=>1, 'colgroup'=>1, 'color'=>1, 'cols'=>1, 'data'=>1, 'date'=>1, 'datetime'=>1, 'datetime-local'=>1, 'default'=>1, 'descriptions'=>1, 'email'=>1, 'file'=>1, 'get'=>1, 'groups'=>1, 'hidden'=>1, 'image'=>1, 'justify'=>1, 'left'=>1, 'ltr'=>1, 'metadata'=>1, 'middle'=>1, 'month'=>1, 'none'=>1, 'number'=>1, 'object'=>1, 'password'=>1, 'poly'=>1, 'post'=>1, 'preserve'=>1, 'radio'=>1, 'range'=>1, 'rect'=>1, 'ref'=>1, 'reset'=>1, 'right'=>1, 'row'=>1, 'rowgroup'=>1, 'rows'=>1, 'rtl'=>1, 'search'=>1, 'submit'=>1, 'subtitles'=>1, 'tel'=>1, 'text'=>1, 'time'=>1, 'top'=>1, 'url'=>1, 'week'=>1); |
|
460 | + static $eAL = array('a'=>1, 'area'=>1, 'bdo'=>1, 'button'=>1, 'col'=>1, 'fieldset'=>1, 'form'=>1, 'img'=>1, 'input'=>1, 'object'=>1, 'ol'=>1, 'optgroup'=>1, 'option'=>1, 'param'=>1, 'script'=>1, 'select'=>1, 'table'=>1, 'td'=>1, 'textarea'=>1, 'tfoot'=>1, 'th'=>1, 'thead'=>1, 'tr'=>1, 'track'=>1, 'xml:space'=>1); |
|
461 | + $lcase = isset($eAL[$e]) ? 1 : 0; |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | $depTr = 0; |
465 | 465 | if($C['no_deprecated_attr']){ |
466 | - // depr attr:applicable ele |
|
467 | - static $aND = array('align'=>array('caption'=>1, 'div'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'hr'=>1, 'img'=>1, 'input'=>1, 'legend'=>1, 'object'=>1, 'p'=>1, 'table'=>1), 'bgcolor'=>array('table'=>1, 'td'=>1, 'th'=>1, 'tr'=>1), 'border'=>array('object'=>1), 'bordercolor'=>array('table'=>1, 'td'=>1, 'tr'=>1), 'cellspacing'=>array('table'=>1), 'clear'=>array('br'=>1), 'compact'=>array('dl'=>1, 'ol'=>1, 'ul'=>1), 'height'=>array('td'=>1, 'th'=>1), 'hspace'=>array('img'=>1, 'object'=>1), 'language'=>array('script'=>1), 'name'=>array('a'=>1, 'form'=>1, 'iframe'=>1, 'img'=>1, 'map'=>1), 'noshade'=>array('hr'=>1), 'nowrap'=>array('td'=>1, 'th'=>1), 'size'=>array('hr'=>1), 'vspace'=>array('img'=>1, 'object'=>1), 'width'=>array('hr'=>1, 'pre'=>1, 'table'=>1, 'td'=>1, 'th'=>1)); |
|
468 | - static $eAD = array('a'=>1, 'br'=>1, 'caption'=>1, 'div'=>1, 'dl'=>1, 'form'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'hr'=>1, 'iframe'=>1, 'img'=>1, 'input'=>1, 'legend'=>1, 'map'=>1, 'object'=>1, 'ol'=>1, 'p'=>1, 'pre'=>1, 'script'=>1, 'table'=>1, 'td'=>1, 'th'=>1, 'tr'=>1, 'ul'=>1); |
|
469 | - $depTr = isset($eAD[$e]) ? 1 : 0; |
|
466 | + // depr attr:applicable ele |
|
467 | + static $aND = array('align'=>array('caption'=>1, 'div'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'hr'=>1, 'img'=>1, 'input'=>1, 'legend'=>1, 'object'=>1, 'p'=>1, 'table'=>1), 'bgcolor'=>array('table'=>1, 'td'=>1, 'th'=>1, 'tr'=>1), 'border'=>array('object'=>1), 'bordercolor'=>array('table'=>1, 'td'=>1, 'tr'=>1), 'cellspacing'=>array('table'=>1), 'clear'=>array('br'=>1), 'compact'=>array('dl'=>1, 'ol'=>1, 'ul'=>1), 'height'=>array('td'=>1, 'th'=>1), 'hspace'=>array('img'=>1, 'object'=>1), 'language'=>array('script'=>1), 'name'=>array('a'=>1, 'form'=>1, 'iframe'=>1, 'img'=>1, 'map'=>1), 'noshade'=>array('hr'=>1), 'nowrap'=>array('td'=>1, 'th'=>1), 'size'=>array('hr'=>1), 'vspace'=>array('img'=>1, 'object'=>1), 'width'=>array('hr'=>1, 'pre'=>1, 'table'=>1, 'td'=>1, 'th'=>1)); |
|
468 | + static $eAD = array('a'=>1, 'br'=>1, 'caption'=>1, 'div'=>1, 'dl'=>1, 'form'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'hr'=>1, 'iframe'=>1, 'img'=>1, 'input'=>1, 'legend'=>1, 'map'=>1, 'object'=>1, 'ol'=>1, 'p'=>1, 'pre'=>1, 'script'=>1, 'table'=>1, 'td'=>1, 'th'=>1, 'tr'=>1, 'ul'=>1); |
|
469 | + $depTr = isset($eAD[$e]) ? 1 : 0; |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | // attr name-vals |
473 | 473 | if(strpos($a, "\x01") !== false){$a = preg_replace('`\x01[^\x01]*\x01`', '', $a);} // No comment/CDATA sec |
474 | 474 | $mode = 0; $a = trim($a, ' /'); $aA = array(); |
475 | 475 | while(strlen($a)){ |
476 | - $w = 0; |
|
477 | - switch($mode){ |
|
478 | - case 0: // Name |
|
476 | + $w = 0; |
|
477 | + switch($mode){ |
|
478 | + case 0: // Name |
|
479 | 479 | if(preg_match('`^[a-zA-Z][^\s=/]+`', $a, $m)){ |
480 | 480 | $nm = strtolower($m[0]); |
481 | 481 | $w = $mode = 1; $a = ltrim(substr_replace($a, '', 0, strlen($m[0]))); |
482 | - } |
|
483 | - break; case 1: |
|
482 | + } |
|
483 | + break; case 1: |
|
484 | 484 | if($a[0] == '='){ // = |
485 | 485 | $w = 1; $mode = 2; $a = ltrim($a, '= '); |
486 | - }else{ // No val |
|
486 | + }else{ // No val |
|
487 | 487 | $w = 1; $mode = 0; $a = ltrim($a); |
488 | 488 | $aA[$nm] = ''; |
489 | - } |
|
490 | - break; case 2: // Val |
|
489 | + } |
|
490 | + break; case 2: // Val |
|
491 | 491 | if(preg_match('`^((?:"[^"]*")|(?:\'[^\']*\')|(?:\s*[^\s"\']+))(.*)`', $a, $m)){ |
492 | 492 | $a = ltrim($m[2]); $m = $m[1]; $w = 1; $mode = 0; |
493 | 493 | $aA[$nm] = trim(str_replace('<', '<', ($m[0] == '"' or $m[0] == '\'') ? substr($m, 1, -1) : $m)); |
494 | - } |
|
495 | - break; |
|
496 | - } |
|
497 | - if($w == 0){ // Parse errs, deal with space, " & ' |
|
498 | - $a = preg_replace('`^(?:"[^"]*("|$)|\'[^\']*(\'|$)|\S)*\s*`', '', $a); |
|
499 | - $mode = 0; |
|
500 | - } |
|
494 | + } |
|
495 | + break; |
|
496 | + } |
|
497 | + if($w == 0){ // Parse errs, deal with space, " & ' |
|
498 | + $a = preg_replace('`^(?:"[^"]*("|$)|\'[^\']*(\'|$)|\S)*\s*`', '', $a); |
|
499 | + $mode = 0; |
|
500 | + } |
|
501 | 501 | } |
502 | 502 | if($mode == 1){$aA[$nm] = '';} |
503 | 503 | |
@@ -506,140 +506,140 @@ discard block |
||
506 | 506 | $rl = isset($S[$e]) ? $S[$e] : array(); |
507 | 507 | $a = array(); $nfr = 0; $d = $C['deny_attribute']; |
508 | 508 | foreach($aA as $k=>$v){ |
509 | - if(((isset($d['*']) ? isset($d[$k]) : !isset($d[$k])) && (isset($aN[$k][$e]) or isset($aNU[$k]) or (isset($aNO[$k]) && !isset($d['on*'])) or (isset($aNA[$k]) && !isset($d['aria*'])) or (!isset($d['data*']) && preg_match('`data-((?!xml)[^:]+$)`', $k))) && !isset($rl['n'][$k]) && !isset($rl['n']['*'])) or isset($rl[$k])){ |
|
510 | - if(isset($aNE[$k])){$v = $k;} |
|
511 | - elseif(!empty($lcase) && (($e != 'button' or $e != 'input') or $k == 'type')){ // Rather loose but ?not cause issues |
|
512 | - $v = (isset($aNL[($v2 = strtolower($v))])) ? $v2 : $v; |
|
513 | - } |
|
514 | - if($k == 'style' && !$C['style_pass']){ |
|
515 | - if(false !== strpos($v, '&#')){ |
|
509 | + if(((isset($d['*']) ? isset($d[$k]) : !isset($d[$k])) && (isset($aN[$k][$e]) or isset($aNU[$k]) or (isset($aNO[$k]) && !isset($d['on*'])) or (isset($aNA[$k]) && !isset($d['aria*'])) or (!isset($d['data*']) && preg_match('`data-((?!xml)[^:]+$)`', $k))) && !isset($rl['n'][$k]) && !isset($rl['n']['*'])) or isset($rl[$k])){ |
|
510 | + if(isset($aNE[$k])){$v = $k;} |
|
511 | + elseif(!empty($lcase) && (($e != 'button' or $e != 'input') or $k == 'type')){ // Rather loose but ?not cause issues |
|
512 | + $v = (isset($aNL[($v2 = strtolower($v))])) ? $v2 : $v; |
|
513 | + } |
|
514 | + if($k == 'style' && !$C['style_pass']){ |
|
515 | + if(false !== strpos($v, '&#')){ |
|
516 | 516 | static $sC = array(' '=>' ', ' '=>' ', 'E'=>'e', 'E'=>'e', 'e'=>'e', 'e'=>'e', 'X'=>'x', 'X'=>'x', 'x'=>'x', 'x'=>'x', 'P'=>'p', 'P'=>'p', 'p'=>'p', 'p'=>'p', 'S'=>'s', 'S'=>'s', 's'=>'s', 's'=>'s', 'I'=>'i', 'I'=>'i', 'i'=>'i', 'i'=>'i', 'O'=>'o', 'O'=>'o', 'o'=>'o', 'o'=>'o', 'N'=>'n', 'N'=>'n', 'n'=>'n', 'n'=>'n', 'U'=>'u', 'U'=>'u', 'u'=>'u', 'u'=>'u', 'R'=>'r', 'R'=>'r', 'r'=>'r', 'r'=>'r', 'L'=>'l', 'L'=>'l', 'l'=>'l', 'l'=>'l', '('=>'(', '('=>'(', ')'=>')', ')'=>')', ' '=>':', ' '=>':', '"'=>'"', '"'=>'"', '''=>"'", '''=>"'", '/'=>'/', '/'=>'/', '*'=>'*', '*'=>'*', '\'=>'\\', '\'=>'\\'); |
517 | 517 | $v = strtr($v, $sC); |
518 | - } |
|
519 | - $v = preg_replace_callback('`(url(?:\()(?: )*(?:\'|"|&(?:quot|apos);)?)(.+?)((?:\'|"|&(?:quot|apos);)?(?: )*(?:\)))`iS', 'htmLawed::hl_prot', $v); |
|
520 | - $v = !$C['css_expression'] ? preg_replace('`expression`i', ' ', preg_replace('`\\\\\S|(/|(%2f))(\*|(%2a))`i', ' ', $v)) : $v; |
|
521 | - }elseif(isset($aNP[$k]) or isset($aNO[$k])){ |
|
522 | - $v = str_replace("", ' ', (strpos($v, '&') !== false ? str_replace(array('­', '­', '­'), ' ', $v) : $v)); # double-quoted char: soft-hyphen; appears here as "" or hyphen or something else depending on viewing software |
|
523 | - if($k == 'srcset'){ |
|
518 | + } |
|
519 | + $v = preg_replace_callback('`(url(?:\()(?: )*(?:\'|"|&(?:quot|apos);)?)(.+?)((?:\'|"|&(?:quot|apos);)?(?: )*(?:\)))`iS', 'htmLawed::hl_prot', $v); |
|
520 | + $v = !$C['css_expression'] ? preg_replace('`expression`i', ' ', preg_replace('`\\\\\S|(/|(%2f))(\*|(%2a))`i', ' ', $v)) : $v; |
|
521 | + }elseif(isset($aNP[$k]) or isset($aNO[$k])){ |
|
522 | + $v = str_replace("", ' ', (strpos($v, '&') !== false ? str_replace(array('­', '­', '­'), ' ', $v) : $v)); # double-quoted char: soft-hyphen; appears here as "" or hyphen or something else depending on viewing software |
|
523 | + if($k == 'srcset'){ |
|
524 | 524 | $v2 = ''; |
525 | 525 | foreach(explode(',', $v) as $k1=>$v1){ |
526 | - $v1 = explode(' ', ltrim($v1), 2); |
|
527 | - $k1 = isset($v1[1]) ? trim($v1[1]) : ''; |
|
528 | - $v1 = trim($v1[0]); |
|
529 | - if(isset($v1[0])){$v2 .= htmLawed::hl_prot($v1, $k). (empty($k1) ? '' : ' '. $k1). ', ';} |
|
526 | + $v1 = explode(' ', ltrim($v1), 2); |
|
527 | + $k1 = isset($v1[1]) ? trim($v1[1]) : ''; |
|
528 | + $v1 = trim($v1[0]); |
|
529 | + if(isset($v1[0])){$v2 .= htmLawed::hl_prot($v1, $k). (empty($k1) ? '' : ' '. $k1). ', ';} |
|
530 | 530 | } |
531 | 531 | $v = trim($v2, ', '); |
532 | - } |
|
533 | - if($k == 'itemtype'){ |
|
532 | + } |
|
533 | + if($k == 'itemtype'){ |
|
534 | 534 | $v2 = ''; |
535 | 535 | foreach(explode(' ', $v) as $v1){ |
536 | - if(isset($v1[0])){$v2 .= htmLawed::hl_prot($v1, $k). ' ';} |
|
536 | + if(isset($v1[0])){$v2 .= htmLawed::hl_prot($v1, $k). ' ';} |
|
537 | 537 | } |
538 | 538 | $v = trim($v2, ' '); |
539 | - } |
|
540 | - else{$v = htmLawed::hl_prot($v, $k);} |
|
541 | - if($k == 'href'){ // X-spam |
|
539 | + } |
|
540 | + else{$v = htmLawed::hl_prot($v, $k);} |
|
541 | + if($k == 'href'){ // X-spam |
|
542 | 542 | if($C['anti_mail_spam'] && strpos($v, 'mailto:') === 0){ |
543 | - $v = str_replace('@', htmlspecialchars($C['anti_mail_spam']), $v); |
|
543 | + $v = str_replace('@', htmlspecialchars($C['anti_mail_spam']), $v); |
|
544 | 544 | }elseif($C['anti_link_spam']){ |
545 | - $r1 = $C['anti_link_spam'][1]; |
|
546 | - if(!empty($r1) && preg_match($r1, $v)){continue;} |
|
547 | - $r0 = $C['anti_link_spam'][0]; |
|
548 | - if(!empty($r0) && preg_match($r0, $v)){ |
|
549 | - if(isset($a['rel'])){ |
|
550 | - if(!preg_match('`\bnofollow\b`i', $a['rel'])){$a['rel'] .= ' nofollow';} |
|
551 | - }elseif(isset($aA['rel'])){ |
|
552 | - if(!preg_match('`\bnofollow\b`i', $aA['rel'])){$nfr = 1;} |
|
553 | - }else{$a['rel'] = 'nofollow';} |
|
554 | - } |
|
555 | - } |
|
556 | - } |
|
557 | - } |
|
558 | - if(isset($rl[$k]) && is_array($rl[$k]) && ($v = htmLawed::hl_attrval($k, $v, $rl[$k])) === 0){continue;} |
|
559 | - $a[$k] = str_replace('"', '"', $v); |
|
560 | - } |
|
545 | + $r1 = $C['anti_link_spam'][1]; |
|
546 | + if(!empty($r1) && preg_match($r1, $v)){continue;} |
|
547 | + $r0 = $C['anti_link_spam'][0]; |
|
548 | + if(!empty($r0) && preg_match($r0, $v)){ |
|
549 | + if(isset($a['rel'])){ |
|
550 | + if(!preg_match('`\bnofollow\b`i', $a['rel'])){$a['rel'] .= ' nofollow';} |
|
551 | + }elseif(isset($aA['rel'])){ |
|
552 | + if(!preg_match('`\bnofollow\b`i', $aA['rel'])){$nfr = 1;} |
|
553 | + }else{$a['rel'] = 'nofollow';} |
|
554 | + } |
|
555 | + } |
|
556 | + } |
|
557 | + } |
|
558 | + if(isset($rl[$k]) && is_array($rl[$k]) && ($v = htmLawed::hl_attrval($k, $v, $rl[$k])) === 0){continue;} |
|
559 | + $a[$k] = str_replace('"', '"', $v); |
|
560 | + } |
|
561 | 561 | } |
562 | 562 | if($nfr){$a['rel'] = isset($a['rel']) ? $a['rel']. ' nofollow' : 'nofollow';} |
563 | 563 | |
564 | 564 | // rqd attr |
565 | 565 | static $eAR = array('area'=>array('alt'=>'area'), 'bdo'=>array('dir'=>'ltr'), 'command'=>array('label'=>''), 'form'=>array('action'=>''), 'img'=>array('src'=>'', 'alt'=>'image'), 'map'=>array('name'=>''), 'optgroup'=>array('label'=>''), 'param'=>array('name'=>''), 'style'=>array('scoped'=>''), 'textarea'=>array('rows'=>'10', 'cols'=>'50')); |
566 | 566 | if(isset($eAR[$e])){ |
567 | - foreach($eAR[$e] as $k=>$v){ |
|
568 | - if(!isset($a[$k])){$a[$k] = isset($v[0]) ? $v : $k;} |
|
569 | - } |
|
567 | + foreach($eAR[$e] as $k=>$v){ |
|
568 | + if(!isset($a[$k])){$a[$k] = isset($v[0]) ? $v : $k;} |
|
569 | + } |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | // depr attr |
573 | 573 | if($depTr){ |
574 | - $c = array(); |
|
575 | - foreach($a as $k=>$v){ |
|
576 | - if($k == 'style' or !isset($aND[$k][$e])){continue;} |
|
577 | - $v = str_replace(array('\\', ':', ';', '&#'), '', $v); |
|
578 | - if($k == 'align'){ |
|
579 | - unset($a['align']); |
|
580 | - if($e == 'img' && ($v == 'left' or $v == 'right')){$c[] = 'float: '. $v;} |
|
581 | - elseif(($e == 'div' or $e == 'table') && $v == 'center'){$c[] = 'margin: auto';} |
|
582 | - else{$c[] = 'text-align: '. $v;} |
|
583 | - }elseif($k == 'bgcolor'){ |
|
584 | - unset($a['bgcolor']); |
|
585 | - $c[] = 'background-color: '. $v; |
|
586 | - }elseif($k == 'border'){ |
|
587 | - unset($a['border']); $c[] = "border: {$v}px"; |
|
588 | - }elseif($k == 'bordercolor'){ |
|
589 | - unset($a['bordercolor']); $c[] = 'border-color: '. $v; |
|
590 | - }elseif($k == 'cellspacing'){ |
|
591 | - unset($a['cellspacing']); $c[] = "border-spacing: {$v}px"; |
|
592 | - }elseif($k == 'clear'){ |
|
593 | - unset($a['clear']); $c[] = 'clear: '. ($v != 'all' ? $v : 'both'); |
|
594 | - }elseif($k == 'compact'){ |
|
595 | - unset($a['compact']); $c[] = 'font-size: 85%'; |
|
596 | - }elseif($k == 'height' or $k == 'width'){ |
|
597 | - unset($a[$k]); $c[] = $k. ': '. ($v[0] != '*' ? $v. (ctype_digit($v) ? 'px' : '') : 'auto'); |
|
598 | - }elseif($k == 'hspace'){ |
|
599 | - unset($a['hspace']); $c[] = "margin-left: {$v}px; margin-right: {$v}px"; |
|
600 | - }elseif($k == 'language' && !isset($a['type'])){ |
|
601 | - unset($a['language']); |
|
602 | - $a['type'] = 'text/'. strtolower($v); |
|
603 | - }elseif($k == 'name'){ |
|
604 | - if($C['no_deprecated_attr'] == 2 or ($e != 'a' && $e != 'map')){unset($a['name']);} |
|
605 | - if(!isset($a['id']) && !preg_match('`\W`', $v)){$a['id'] = $v;} |
|
606 | - }elseif($k == 'noshade'){ |
|
607 | - unset($a['noshade']); $c[] = 'border-style: none; border: 0; background-color: gray; color: gray'; |
|
608 | - }elseif($k == 'nowrap'){ |
|
609 | - unset($a['nowrap']); $c[] = 'white-space: nowrap'; |
|
610 | - }elseif($k == 'size'){ |
|
611 | - unset($a['size']); $c[] = 'size: '. $v. 'px'; |
|
612 | - }elseif($k == 'vspace'){ |
|
613 | - unset($a['vspace']); $c[] = "margin-top: {$v}px; margin-bottom: {$v}px"; |
|
614 | - } |
|
615 | - } |
|
616 | - if(count($c)){ |
|
617 | - $c = implode('; ', $c); |
|
618 | - $a['style'] = isset($a['style']) ? rtrim($a['style'], ' ;'). '; '. $c. ';': $c. ';'; |
|
619 | - } |
|
574 | + $c = array(); |
|
575 | + foreach($a as $k=>$v){ |
|
576 | + if($k == 'style' or !isset($aND[$k][$e])){continue;} |
|
577 | + $v = str_replace(array('\\', ':', ';', '&#'), '', $v); |
|
578 | + if($k == 'align'){ |
|
579 | + unset($a['align']); |
|
580 | + if($e == 'img' && ($v == 'left' or $v == 'right')){$c[] = 'float: '. $v;} |
|
581 | + elseif(($e == 'div' or $e == 'table') && $v == 'center'){$c[] = 'margin: auto';} |
|
582 | + else{$c[] = 'text-align: '. $v;} |
|
583 | + }elseif($k == 'bgcolor'){ |
|
584 | + unset($a['bgcolor']); |
|
585 | + $c[] = 'background-color: '. $v; |
|
586 | + }elseif($k == 'border'){ |
|
587 | + unset($a['border']); $c[] = "border: {$v}px"; |
|
588 | + }elseif($k == 'bordercolor'){ |
|
589 | + unset($a['bordercolor']); $c[] = 'border-color: '. $v; |
|
590 | + }elseif($k == 'cellspacing'){ |
|
591 | + unset($a['cellspacing']); $c[] = "border-spacing: {$v}px"; |
|
592 | + }elseif($k == 'clear'){ |
|
593 | + unset($a['clear']); $c[] = 'clear: '. ($v != 'all' ? $v : 'both'); |
|
594 | + }elseif($k == 'compact'){ |
|
595 | + unset($a['compact']); $c[] = 'font-size: 85%'; |
|
596 | + }elseif($k == 'height' or $k == 'width'){ |
|
597 | + unset($a[$k]); $c[] = $k. ': '. ($v[0] != '*' ? $v. (ctype_digit($v) ? 'px' : '') : 'auto'); |
|
598 | + }elseif($k == 'hspace'){ |
|
599 | + unset($a['hspace']); $c[] = "margin-left: {$v}px; margin-right: {$v}px"; |
|
600 | + }elseif($k == 'language' && !isset($a['type'])){ |
|
601 | + unset($a['language']); |
|
602 | + $a['type'] = 'text/'. strtolower($v); |
|
603 | + }elseif($k == 'name'){ |
|
604 | + if($C['no_deprecated_attr'] == 2 or ($e != 'a' && $e != 'map')){unset($a['name']);} |
|
605 | + if(!isset($a['id']) && !preg_match('`\W`', $v)){$a['id'] = $v;} |
|
606 | + }elseif($k == 'noshade'){ |
|
607 | + unset($a['noshade']); $c[] = 'border-style: none; border: 0; background-color: gray; color: gray'; |
|
608 | + }elseif($k == 'nowrap'){ |
|
609 | + unset($a['nowrap']); $c[] = 'white-space: nowrap'; |
|
610 | + }elseif($k == 'size'){ |
|
611 | + unset($a['size']); $c[] = 'size: '. $v. 'px'; |
|
612 | + }elseif($k == 'vspace'){ |
|
613 | + unset($a['vspace']); $c[] = "margin-top: {$v}px; margin-bottom: {$v}px"; |
|
614 | + } |
|
615 | + } |
|
616 | + if(count($c)){ |
|
617 | + $c = implode('; ', $c); |
|
618 | + $a['style'] = isset($a['style']) ? rtrim($a['style'], ' ;'). '; '. $c. ';': $c. ';'; |
|
619 | + } |
|
620 | 620 | } |
621 | 621 | // unique ID |
622 | 622 | if($C['unique_ids'] && isset($a['id'])){ |
623 | - if(preg_match('`\s`', ($id = $a['id'])) or (isset($GLOBALS['hl_Ids'][$id]) && $C['unique_ids'] == 1)){unset($a['id']); |
|
624 | - }else{ |
|
625 | - while(isset($GLOBALS['hl_Ids'][$id])){$id = $C['unique_ids']. $id;} |
|
626 | - $GLOBALS['hl_Ids'][($a['id'] = $id)] = 1; |
|
627 | - } |
|
623 | + if(preg_match('`\s`', ($id = $a['id'])) or (isset($GLOBALS['hl_Ids'][$id]) && $C['unique_ids'] == 1)){unset($a['id']); |
|
624 | + }else{ |
|
625 | + while(isset($GLOBALS['hl_Ids'][$id])){$id = $C['unique_ids']. $id;} |
|
626 | + $GLOBALS['hl_Ids'][($a['id'] = $id)] = 1; |
|
627 | + } |
|
628 | 628 | } |
629 | 629 | // xml:lang |
630 | 630 | if($C['xml:lang'] && isset($a['lang'])){ |
631 | - $a['xml:lang'] = isset($a['xml:lang']) ? $a['xml:lang'] : $a['lang']; |
|
632 | - if($C['xml:lang'] == 2){unset($a['lang']);} |
|
631 | + $a['xml:lang'] = isset($a['xml:lang']) ? $a['xml:lang'] : $a['lang']; |
|
632 | + if($C['xml:lang'] == 2){unset($a['lang']);} |
|
633 | 633 | } |
634 | 634 | // for transformed tag |
635 | 635 | if(!empty($trt)){ |
636 | - $a['style'] = isset($a['style']) ? rtrim($a['style'], ' ;'). '; '. $trt : $trt; |
|
636 | + $a['style'] = isset($a['style']) ? rtrim($a['style'], ' ;'). '; '. $trt : $trt; |
|
637 | 637 | } |
638 | 638 | // return with empty ele / |
639 | 639 | if(empty($C['hook_tag'])){ |
640 | - $aA = ''; |
|
641 | - foreach($a as $k=>$v){$aA .= " {$k}=\"{$v}\"";} |
|
642 | - return "<{$e}{$aA}". (isset($eE[$e]) ? ' /' : ''). '>'; |
|
640 | + $aA = ''; |
|
641 | + foreach($a as $k=>$v){$aA .= " {$k}=\"{$v}\"";} |
|
642 | + return "<{$e}{$aA}". (isset($eE[$e]) ? ' /' : ''). '>'; |
|
643 | 643 | } |
644 | 644 | else{return $C['hook_tag']($e, $a);} |
645 | 645 | } |
@@ -652,16 +652,16 @@ discard block |
||
652 | 652 | if($e == 'center'){$e = 'div'; return 'text-align: center;';} |
653 | 653 | static $fs = array('0'=>'xx-small', '1'=>'xx-small', '2'=>'small', '3'=>'medium', '4'=>'large', '5'=>'x-large', '6'=>'xx-large', '7'=>'300%', '-1'=>'smaller', '-2'=>'60%', '+1'=>'larger', '+2'=>'150%', '+3'=>'200%', '+4'=>'300%'); |
654 | 654 | if($e == 'font'){ |
655 | - $a2 = ''; |
|
656 | - while(preg_match('`(^|\s)(color|size)\s*=\s*(\'|")?(.+?)(\\3|\s|$)`i', $a, $m)){ |
|
657 | - $a = str_replace($m[0], ' ', $a); |
|
658 | - $a2 .= strtolower($m[2]) == 'color' ? (' color: '. str_replace('"', '\'', trim($m[4])). ';') : (isset($fs[($m = trim($m[4]))]) ? ($a2 .= ' font-size: '. str_replace('"', '\'', $fs[$m]). ';') : ''); |
|
659 | - } |
|
660 | - while(preg_match('`(^|\s)face\s*=\s*(\'|")?([^=]+?)\\2`i', $a, $m) or preg_match('`(^|\s)face\s*=(\s*)(\S+)`i', $a, $m)){ |
|
661 | - $a = str_replace($m[0], ' ', $a); |
|
662 | - $a2 .= ' font-family: '. str_replace('"', '\'', trim($m[3])). ';'; |
|
663 | - } |
|
664 | - $e = 'span'; return ltrim(str_replace('<', '', $a2)); |
|
655 | + $a2 = ''; |
|
656 | + while(preg_match('`(^|\s)(color|size)\s*=\s*(\'|")?(.+?)(\\3|\s|$)`i', $a, $m)){ |
|
657 | + $a = str_replace($m[0], ' ', $a); |
|
658 | + $a2 .= strtolower($m[2]) == 'color' ? (' color: '. str_replace('"', '\'', trim($m[4])). ';') : (isset($fs[($m = trim($m[4]))]) ? ($a2 .= ' font-size: '. str_replace('"', '\'', $fs[$m]). ';') : ''); |
|
659 | + } |
|
660 | + while(preg_match('`(^|\s)face\s*=\s*(\'|")?([^=]+?)\\2`i', $a, $m) or preg_match('`(^|\s)face\s*=(\s*)(\S+)`i', $a, $m)){ |
|
661 | + $a = str_replace($m[0], ' ', $a); |
|
662 | + $a2 .= ' font-family: '. str_replace('"', '\'', trim($m[3])). ';'; |
|
663 | + } |
|
664 | + $e = 'span'; return ltrim(str_replace('<', '', $a2)); |
|
665 | 665 | } |
666 | 666 | if($e == 'acronym'){$e = 'abbr'; return '';} |
667 | 667 | if($e == 'dir'){$e = 'ul'; return '';} |
@@ -673,11 +673,11 @@ discard block |
||
673 | 673 | // tidy/compact HTM |
674 | 674 | if(strpos(' pre,script,textarea', "$p,")){return $t;} |
675 | 675 | if(!function_exists('hl_aux2')){function hl_aux2($m){ |
676 | - return $m[1]. str_replace(array("<", ">", "\n", "\r", "\t", ' '), array("\x01", "\x02", "\x03", "\x04", "\x05", "\x07"), $m[3]). $m[4]; |
|
676 | + return $m[1]. str_replace(array("<", ">", "\n", "\r", "\t", ' '), array("\x01", "\x02", "\x03", "\x04", "\x05", "\x07"), $m[3]). $m[4]; |
|
677 | 677 | }} |
678 | 678 | $t = preg_replace(array('`(<\w[^>]*(?<!/)>)\s+`', '`\s+`', '`(<\w[^>]*(?<!/)>) `'), array(' $1', ' ', '$1'), preg_replace_callback(array('`(<(!\[CDATA\[))(.+?)(\]\]>)`sm', '`(<(!--))(.+?)(-->)`sm', '`(<(pre|script|textarea)[^>]*?>)(.+?)(</\2>)`sm'), 'hl_aux2', $t)); |
679 | 679 | if(($w = strtolower($w)) == -1){ |
680 | - return str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05", "\x07"), array('<', '>', "\n", "\r", "\t", ' '), $t); |
|
680 | + return str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05", "\x07"), array('<', '>', "\n", "\r", "\t", ' '), $t); |
|
681 | 681 | } |
682 | 682 | $s = strpos(" $w", 't') ? "\t" : ' '; |
683 | 683 | $s = preg_match('`\d`', $w, $m) ? str_repeat($s, $m[0]) : str_repeat($s, ($s == "\t" ? 1 : 2)); |
@@ -689,39 +689,39 @@ discard block |
||
689 | 689 | $T = explode('<', $t); |
690 | 690 | $X = 1; |
691 | 691 | while($X){ |
692 | - $n = $N; |
|
693 | - $t = $T; |
|
694 | - ob_start(); |
|
695 | - if(isset($d[$p])){echo str_repeat($s, ++$n);} |
|
696 | - echo ltrim(array_shift($t)); |
|
697 | - for($i=-1, $j=count($t); ++$i<$j;){ |
|
698 | - $r = ''; list($e, $r) = explode('>', $t[$i]); |
|
699 | - $x = $e[0] == '/' ? 0 : (substr($e, -1) == '/' ? 1 : ($e[0] != '!' ? 2 : -1)); |
|
700 | - $y = !$x ? ltrim($e, '/') : ($x > 0 ? substr($e, 0, strcspn($e, ' ')) : 0); |
|
701 | - $e = "<$e>"; |
|
702 | - if(isset($d[$y])){ |
|
703 | - if(!$x){ |
|
692 | + $n = $N; |
|
693 | + $t = $T; |
|
694 | + ob_start(); |
|
695 | + if(isset($d[$p])){echo str_repeat($s, ++$n);} |
|
696 | + echo ltrim(array_shift($t)); |
|
697 | + for($i=-1, $j=count($t); ++$i<$j;){ |
|
698 | + $r = ''; list($e, $r) = explode('>', $t[$i]); |
|
699 | + $x = $e[0] == '/' ? 0 : (substr($e, -1) == '/' ? 1 : ($e[0] != '!' ? 2 : -1)); |
|
700 | + $y = !$x ? ltrim($e, '/') : ($x > 0 ? substr($e, 0, strcspn($e, ' ')) : 0); |
|
701 | + $e = "<$e>"; |
|
702 | + if(isset($d[$y])){ |
|
703 | + if(!$x){ |
|
704 | 704 | if($n){echo "\n", str_repeat($s, --$n), "$e\n", str_repeat($s, $n);} |
705 | 705 | else{++$N; ob_end_clean(); continue 2;} |
706 | - } |
|
707 | - else{echo "\n", str_repeat($s, $n), "$e\n", str_repeat($s, ($x != 1 ? ++$n : $n));} |
|
708 | - echo $r; continue; |
|
709 | - } |
|
710 | - $f = "\n". str_repeat($s, $n); |
|
711 | - if(isset($c[$y])){ |
|
712 | - if(!$x){echo $e, $f, $r;} |
|
713 | - else{echo $f, $e, $r;} |
|
714 | - }elseif(isset($b[$y])){echo $f, $e, $r; |
|
715 | - }elseif(isset($a[$y])){echo $e, $f, $r; |
|
716 | - }elseif(!$y){echo $f, $e, $f, $r; |
|
717 | - }else{echo $e, $r;} |
|
718 | - } |
|
719 | - $X = 0; |
|
706 | + } |
|
707 | + else{echo "\n", str_repeat($s, $n), "$e\n", str_repeat($s, ($x != 1 ? ++$n : $n));} |
|
708 | + echo $r; continue; |
|
709 | + } |
|
710 | + $f = "\n". str_repeat($s, $n); |
|
711 | + if(isset($c[$y])){ |
|
712 | + if(!$x){echo $e, $f, $r;} |
|
713 | + else{echo $f, $e, $r;} |
|
714 | + }elseif(isset($b[$y])){echo $f, $e, $r; |
|
715 | + }elseif(isset($a[$y])){echo $e, $f, $r; |
|
716 | + }elseif(!$y){echo $f, $e, $f, $r; |
|
717 | + }else{echo $e, $r;} |
|
718 | + } |
|
719 | + $X = 0; |
|
720 | 720 | } |
721 | 721 | $t = str_replace(array("\n ", " \n"), "\n", preg_replace('`[\n]\s*?[\n]+`', "\n", ob_get_contents())); |
722 | 722 | ob_end_clean(); |
723 | 723 | if(($l = strpos(" $w", 'r') ? (strpos(" $w", 'n') ? "\r\n" : "\r") : 0)){ |
724 | - $t = str_replace("\n", $l, $t); |
|
724 | + $t = str_replace("\n", $l, $t); |
|
725 | 725 | } |
726 | 726 | return str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05", "\x07"), array('<', '>', "\n", "\r", "\t", ' '), $t); |
727 | 727 | } |
@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | See htmLawed_README.txt/htm |
11 | 11 | */ |
12 | 12 | |
13 | -class htmLawed{ |
|
13 | +class htmLawed { |
|
14 | 14 | // begin class |
15 | -public static function hl($t, $C=1, $S=array()){ |
|
15 | +public static function hl($t, $C = 1, $S = array()) { |
|
16 | 16 | $C = is_array($C) ? $C : array(); |
17 | -if(!empty($C['valid_xhtml'])){ |
|
17 | +if (!empty($C['valid_xhtml'])) { |
|
18 | 18 | $C['elements'] = empty($C['elements']) ? '*-acronym-big-center-dir-font-isindex-s-strike-tt' : $C['elements']; |
19 | 19 | $C['make_tag_strict'] = isset($C['make_tag_strict']) ? $C['make_tag_strict'] : 2; |
20 | 20 | $C['xml:lang'] = isset($C['xml:lang']) ? $C['xml:lang'] : 2; |
@@ -22,41 +22,41 @@ discard block |
||
22 | 22 | // config eles |
23 | 23 | $e = array('a'=>1, 'abbr'=>1, 'acronym'=>1, 'address'=>1, 'applet'=>1, 'area'=>1, 'article'=>1, 'aside'=>1, 'audio'=>1, 'b'=>1, 'bdi'=>1, 'bdo'=>1, 'big'=>1, 'blockquote'=>1, 'br'=>1, 'button'=>1, 'canvas'=>1, 'caption'=>1, 'center'=>1, 'cite'=>1, 'code'=>1, 'col'=>1, 'colgroup'=>1, 'command'=>1, 'data'=>1, 'datalist'=>1, 'dd'=>1, 'del'=>1, 'details'=>1, 'dfn'=>1, 'dir'=>1, 'div'=>1, 'dl'=>1, 'dt'=>1, 'em'=>1, 'embed'=>1, 'fieldset'=>1, 'figcaption'=>1, 'figure'=>1, 'font'=>1, 'footer'=>1, 'form'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'header'=>1, 'hgroup'=>1, 'hr'=>1, 'i'=>1, 'iframe'=>1, 'img'=>1, 'input'=>1, 'ins'=>1, 'isindex'=>1, 'kbd'=>1, 'keygen'=>1, 'label'=>1, 'legend'=>1, 'li'=>1, 'link'=>1, 'main'=>1, 'map'=>1, 'mark'=>1, 'menu'=>1, 'meta'=>1, 'meter'=>1, 'nav'=>1, 'noscript'=>1, 'object'=>1, 'ol'=>1, 'optgroup'=>1, 'option'=>1, 'output'=>1, 'p'=>1, 'param'=>1, 'pre'=>1, 'progress'=>1, 'q'=>1, 'rb'=>1, 'rbc'=>1, 'rp'=>1, 'rt'=>1, 'rtc'=>1, 'ruby'=>1, 's'=>1, 'samp'=>1, 'script'=>1, 'section'=>1, 'select'=>1, 'small'=>1, 'source'=>1, 'span'=>1, 'strike'=>1, 'strong'=>1, 'style'=>1, 'sub'=>1, 'summary'=>1, 'sup'=>1, 'table'=>1, 'tbody'=>1, 'td'=>1, 'textarea'=>1, 'tfoot'=>1, 'th'=>1, 'thead'=>1, 'time'=>1, 'tr'=>1, 'track'=>1, 'tt'=>1, 'u'=>1, 'ul'=>1, 'var'=>1, 'video'=>1, 'wbr'=>1); // 118 incl. deprecated & some Ruby |
24 | 24 | |
25 | -if(!empty($C['safe'])){ |
|
25 | +if (!empty($C['safe'])) { |
|
26 | 26 | unset($e['applet'], $e['audio'], $e['canvas'], $e['embed'], $e['iframe'], $e['object'], $e['script'], $e['video']); |
27 | 27 | } |
28 | 28 | $x = !empty($C['elements']) ? str_replace(array("\n", "\r", "\t", ' '), '', $C['elements']) : '*'; |
29 | -if($x == '-*'){$e = array();} |
|
30 | -elseif(strpos($x, '*') === false){$e = array_flip(explode(',', $x));} |
|
31 | -else{ |
|
32 | - if(isset($x[1])){ |
|
29 | +if ($x == '-*') {$e = array(); } |
|
30 | +elseif (strpos($x, '*') === false) {$e = array_flip(explode(',', $x)); } |
|
31 | +else { |
|
32 | + if (isset($x[1])) { |
|
33 | 33 | preg_match_all('`(?:^|-|\+)[^\-+]+?(?=-|\+|$)`', $x, $m, PREG_SET_ORDER); |
34 | - for($i=count($m); --$i>=0;){$m[$i] = $m[$i][0];} |
|
35 | - foreach($m as $v){ |
|
36 | - if($v[0] == '+'){$e[substr($v, 1)] = 1;} |
|
37 | - if($v[0] == '-' && isset($e[($v = substr($v, 1))]) && !in_array('+'. $v, $m)){unset($e[$v]);} |
|
34 | + for ($i = count($m); --$i >= 0;) {$m[$i] = $m[$i][0]; } |
|
35 | + foreach ($m as $v) { |
|
36 | + if ($v[0] == '+') {$e[substr($v, 1)] = 1; } |
|
37 | + if ($v[0] == '-' && isset($e[($v = substr($v, 1))]) && !in_array('+'.$v, $m)) {unset($e[$v]); } |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | } |
41 | -$C['elements'] =& $e; |
|
41 | +$C['elements'] = & $e; |
|
42 | 42 | // config attrs |
43 | 43 | $x = !empty($C['deny_attribute']) ? strtolower(str_replace(array("\n", "\r", "\t", ' '), '', $C['deny_attribute'])) : ''; |
44 | -$x = array_flip((isset($x[0]) && $x[0] == '*') ? str_replace('/', 'data-', explode('-', str_replace('data-', '/', $x))) : explode(',', $x. (!empty($C['safe']) ? ',on*' : ''))); |
|
44 | +$x = array_flip((isset($x[0]) && $x[0] == '*') ? str_replace('/', 'data-', explode('-', str_replace('data-', '/', $x))) : explode(',', $x.(!empty($C['safe']) ? ',on*' : ''))); |
|
45 | 45 | $C['deny_attribute'] = $x; |
46 | 46 | // config URLs |
47 | -$x = (isset($C['schemes'][2]) && strpos($C['schemes'], ':')) ? strtolower($C['schemes']) : 'href: aim, feed, file, ftp, gopher, http, https, irc, mailto, news, nntp, sftp, ssh, tel, telnet'. (empty($C['safe']) ? ', app, javascript; *: data, javascript, ' : '; *:'). 'file, http, https'; |
|
47 | +$x = (isset($C['schemes'][2]) && strpos($C['schemes'], ':')) ? strtolower($C['schemes']) : 'href: aim, feed, file, ftp, gopher, http, https, irc, mailto, news, nntp, sftp, ssh, tel, telnet'.(empty($C['safe']) ? ', app, javascript; *: data, javascript, ' : '; *:').'file, http, https'; |
|
48 | 48 | $C['schemes'] = array(); |
49 | -foreach(explode(';', str_replace(array(' ', "\t", "\r", "\n"), '', $x)) as $v){ |
|
49 | +foreach (explode(';', str_replace(array(' ', "\t", "\r", "\n"), '', $x)) as $v) { |
|
50 | 50 | $x = $x2 = null; list($x, $x2) = explode(':', $v, 2); |
51 | - if($x2){$C['schemes'][$x] = array_flip(explode(',', $x2));} |
|
51 | + if ($x2) {$C['schemes'][$x] = array_flip(explode(',', $x2)); } |
|
52 | 52 | } |
53 | -if(!isset($C['schemes']['*'])){ |
|
53 | +if (!isset($C['schemes']['*'])) { |
|
54 | 54 | $C['schemes']['*'] = array('file'=>1, 'http'=>1, 'https'=>1); |
55 | - if(empty($C['safe'])){$C['schemes']['*'] += array('data'=>1, 'javascript'=>1);} |
|
55 | + if (empty($C['safe'])) {$C['schemes']['*'] += array('data'=>1, 'javascript'=>1); } |
|
56 | 56 | } |
57 | -if(!empty($C['safe']) && empty($C['schemes']['style'])){$C['schemes']['style'] = array('!'=>1);} |
|
57 | +if (!empty($C['safe']) && empty($C['schemes']['style'])) {$C['schemes']['style'] = array('!'=>1); } |
|
58 | 58 | $C['abs_url'] = isset($C['abs_url']) ? $C['abs_url'] : 0; |
59 | -if(!isset($C['base_url']) or !preg_match('`^[a-zA-Z\d.+\-]+://[^/]+/(.+?/)?$`', $C['base_url'])){ |
|
59 | +if (!isset($C['base_url']) or !preg_match('`^[a-zA-Z\d.+\-]+://[^/]+/(.+?/)?$`', $C['base_url'])) { |
|
60 | 60 | $C['base_url'] = $C['abs_url'] = 0; |
61 | 61 | } |
62 | 62 | // config rest |
@@ -84,23 +84,23 @@ discard block |
||
84 | 84 | $C['unique_ids'] = isset($C['unique_ids']) && (!preg_match('`\W`', $C['unique_ids'])) ? $C['unique_ids'] : 1; |
85 | 85 | $C['xml:lang'] = isset($C['xml:lang']) ? $C['xml:lang'] : 0; |
86 | 86 | |
87 | -if(isset($GLOBALS['C'])){$reC = $GLOBALS['C'];} |
|
87 | +if (isset($GLOBALS['C'])) {$reC = $GLOBALS['C']; } |
|
88 | 88 | $GLOBALS['C'] = $C; |
89 | 89 | $S = is_array($S) ? $S : htmLawed::hl_spec($S); |
90 | -if(isset($GLOBALS['S'])){$reS = $GLOBALS['S'];} |
|
90 | +if (isset($GLOBALS['S'])) {$reS = $GLOBALS['S']; } |
|
91 | 91 | $GLOBALS['S'] = $S; |
92 | 92 | |
93 | 93 | $t = preg_replace('`[\x00-\x08\x0b-\x0c\x0e-\x1f]`', '', $t); |
94 | -if($C['clean_ms_char']){ |
|
94 | +if ($C['clean_ms_char']) { |
|
95 | 95 | $x = array("\x7f"=>'', "\x80"=>'€', "\x81"=>'', "\x83"=>'ƒ', "\x85"=>'…', "\x86"=>'†', "\x87"=>'‡', "\x88"=>'ˆ', "\x89"=>'‰', "\x8a"=>'Š', "\x8b"=>'‹', "\x8c"=>'Œ', "\x8d"=>'', "\x8e"=>'Ž', "\x8f"=>'', "\x90"=>'', "\x95"=>'•', "\x96"=>'–', "\x97"=>'—', "\x98"=>'˜', "\x99"=>'™', "\x9a"=>'š', "\x9b"=>'›', "\x9c"=>'œ', "\x9d"=>'', "\x9e"=>'ž', "\x9f"=>'Ÿ'); |
96 | 96 | $x = $x + ($C['clean_ms_char'] == 1 ? array("\x82"=>'‚', "\x84"=>'„', "\x91"=>'‘', "\x92"=>'’', "\x93"=>'“', "\x94"=>'”') : array("\x82"=>'\'', "\x84"=>'"', "\x91"=>'\'', "\x92"=>'\'', "\x93"=>'"', "\x94"=>'"')); |
97 | 97 | $t = strtr($t, $x); |
98 | 98 | } |
99 | -if($C['cdata'] or $C['comment']){$t = preg_replace_callback('`<!(?:(?:--.*?--)|(?:\[CDATA\[.*?\]\]))>`sm', 'htmLawed::hl_cmtcd', $t);} |
|
99 | +if ($C['cdata'] or $C['comment']) {$t = preg_replace_callback('`<!(?:(?:--.*?--)|(?:\[CDATA\[.*?\]\]))>`sm', 'htmLawed::hl_cmtcd', $t); } |
|
100 | 100 | $t = preg_replace_callback('`&([a-zA-Z][a-zA-Z0-9]{1,30}|#(?:[0-9]{1,8}|[Xx][0-9A-Fa-f]{1,7}));`', 'htmLawed::hl_ent', str_replace('&', '&', $t)); |
101 | -if($C['unique_ids'] && !isset($GLOBALS['hl_Ids'])){$GLOBALS['hl_Ids'] = array();} |
|
102 | -if($C['hook']){$t = $C['hook']($t, $C, $S);} |
|
103 | -if($C['show_setting'] && preg_match('`^[a-z][a-z0-9_]*$`i', $C['show_setting'])){ |
|
101 | +if ($C['unique_ids'] && !isset($GLOBALS['hl_Ids'])) {$GLOBALS['hl_Ids'] = array(); } |
|
102 | +if ($C['hook']) {$t = $C['hook']($t, $C, $S); } |
|
103 | +if ($C['show_setting'] && preg_match('`^[a-z][a-z0-9_]*$`i', $C['show_setting'])) { |
|
104 | 104 | $GLOBALS[$C['show_setting']] = array('config'=>$C, 'spec'=>$S, 'time'=>microtime()); |
105 | 105 | } |
106 | 106 | // main |
@@ -109,60 +109,60 @@ discard block |
||
109 | 109 | $t = (($C['cdata'] or $C['comment']) && strpos($t, "\x01") !== false) ? str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05"), array('', '', '&', '<', '>'), $t) : $t; |
110 | 110 | $t = $C['tidy'] ? htmLawed::hl_tidy($t, $C['tidy'], $C['parent']) : $t; |
111 | 111 | unset($C, $e); |
112 | -if(isset($reC)){$GLOBALS['C'] = $reC;} |
|
113 | -if(isset($reS)){$GLOBALS['S'] = $reS;} |
|
112 | +if (isset($reC)) {$GLOBALS['C'] = $reC; } |
|
113 | +if (isset($reS)) {$GLOBALS['S'] = $reS; } |
|
114 | 114 | return $t; |
115 | 115 | } |
116 | 116 | |
117 | -public static function hl_attrval($a, $t, $p){ |
|
117 | +public static function hl_attrval($a, $t, $p) { |
|
118 | 118 | // check attr val against $S |
119 | 119 | static $ma = array('accesskey', 'class', 'itemtype', 'rel'); |
120 | -$s = in_array($a, $ma) ? ' ' : ($a == 'srcset' ? ',': ''); |
|
120 | +$s = in_array($a, $ma) ? ' ' : ($a == 'srcset' ? ',' : ''); |
|
121 | 121 | $r = array(); |
122 | 122 | $t = !empty($s) ? explode($s, $t) : array($t); |
123 | -foreach($t as $tk=>$tv){ |
|
123 | +foreach ($t as $tk=>$tv) { |
|
124 | 124 | $o = 1; $tv = trim($tv); $l = strlen($tv); |
125 | - foreach($p as $k=>$v){ |
|
126 | - if(!$l){continue;} |
|
127 | - switch($k){ |
|
128 | - case 'maxlen': if($l > $v){$o = 0;} |
|
129 | - break; case 'minlen': if($l < $v){$o = 0;} |
|
130 | - break; case 'maxval': if((float)($tv) > $v){$o = 0;} |
|
131 | - break; case 'minval': if((float)($tv) < $v){$o = 0;} |
|
132 | - break; case 'match': if(!preg_match($v, $tv)){$o = 0;} |
|
133 | - break; case 'nomatch': if(preg_match($v, $tv)){$o = 0;} |
|
125 | + foreach ($p as $k=>$v) { |
|
126 | + if (!$l) {continue; } |
|
127 | + switch ($k) { |
|
128 | + case 'maxlen': if ($l > $v) {$o = 0; } |
|
129 | + break; case 'minlen': if ($l < $v) {$o = 0; } |
|
130 | + break; case 'maxval': if ((float)($tv) > $v) {$o = 0; } |
|
131 | + break; case 'minval': if ((float)($tv) < $v) {$o = 0; } |
|
132 | + break; case 'match': if (!preg_match($v, $tv)) {$o = 0; } |
|
133 | + break; case 'nomatch': if (preg_match($v, $tv)) {$o = 0; } |
|
134 | 134 | break; case 'oneof': |
135 | 135 | $m = 0; |
136 | - foreach(explode('|', $v) as $n){if($tv == $n){$m = 1; break;}} |
|
136 | + foreach (explode('|', $v) as $n) {if ($tv == $n) {$m = 1; break; }} |
|
137 | 137 | $o = $m; |
138 | 138 | break; case 'noneof': |
139 | 139 | $m = 1; |
140 | - foreach(explode('|', $v) as $n){if($tv == $n){$m = 0; break;}} |
|
140 | + foreach (explode('|', $v) as $n) {if ($tv == $n) {$m = 0; break; }} |
|
141 | 141 | $o = $m; |
142 | 142 | break; default: |
143 | 143 | break; |
144 | 144 | } |
145 | - if(!$o){break;} |
|
145 | + if (!$o) {break; } |
|
146 | 146 | } |
147 | - if($o){$r[] = $tv;} |
|
147 | + if ($o) {$r[] = $tv; } |
|
148 | 148 | } |
149 | -if($s == ','){$s = ', ';} |
|
149 | +if ($s == ',') {$s = ', '; } |
|
150 | 150 | $r = implode($s, $r); |
151 | 151 | return (isset($r[0]) ? $r : (isset($p['default']) ? $p['default'] : 0)); |
152 | 152 | } |
153 | 153 | |
154 | -public static function hl_bal($t, $do=1, $in='div'){ |
|
154 | +public static function hl_bal($t, $do = 1, $in = 'div') { |
|
155 | 155 | // balance tags |
156 | 156 | // by content |
157 | 157 | $cB = array('blockquote'=>1, 'form'=>1, 'map'=>1, 'noscript'=>1); // Block |
158 | 158 | $cE = array('area'=>1, 'br'=>1, 'col'=>1, 'command'=>1, 'embed'=>1, 'hr'=>1, 'img'=>1, 'input'=>1, 'isindex'=>1, 'keygen'=>1, 'link'=>1, 'meta'=>1, 'param'=>1, 'source'=>1, 'track'=>1, 'wbr'=>1); // Empty |
159 | 159 | $cF = array('a'=>1, 'article'=>1, 'aside'=>1, 'audio'=>1, 'button'=>1, 'canvas'=>1, 'del'=>1, 'details'=>1, 'div'=>1, 'dd'=>1, 'fieldset'=>1, 'figure'=>1, 'footer'=>1, 'header'=>1, 'iframe'=>1, 'ins'=>1, 'li'=>1, 'main'=>1, 'menu'=>1, 'nav'=>1, 'noscript'=>1, 'object'=>1, 'section'=>1, 'style'=>1, 'td'=>1, 'th'=>1, 'video'=>1); // Flow; later context-wise dynamic move of ins & del to $cI |
160 | 160 | $cI = array('abbr'=>1, 'acronym'=>1, 'address'=>1, 'b'=>1, 'bdi'=>1, 'bdo'=>1, 'big'=>1, 'caption'=>1, 'cite'=>1, 'code'=>1, 'data'=>1, 'datalist'=>1, 'dfn'=>1, 'dt'=>1, 'em'=>1, 'figcaption'=>1, 'font'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'hgroup'=>1, 'i'=>1, 'kbd'=>1, 'label'=>1, 'legend'=>1, 'mark'=>1, 'meter'=>1, 'output'=>1, 'p'=>1, 'pre'=>1, 'progress'=>1, 'q'=>1, 'rb'=>1, 'rt'=>1, 's'=>1, 'samp'=>1, 'small'=>1, 'span'=>1, 'strike'=>1, 'strong'=>1, 'sub'=>1, 'summary'=>1, 'sup'=>1, 'time'=>1, 'tt'=>1, 'u'=>1, 'var'=>1); // Inline |
161 | -$cN = array('a'=>array('a'=>1, 'address'=>1, 'button'=>1, 'details'=>1, 'embed'=>1, 'keygen'=>1, 'label'=>1, 'select'=>1, 'textarea'=>1), 'address'=>array('address'=>1, 'article'=>1, 'aside'=>1, 'header'=>1, 'keygen'=>1, 'footer'=>1, 'nav'=>1, 'section'=>1), 'button'=>array('a'=>1, 'address'=>1, 'button'=>1, 'details'=>1, 'embed'=>1, 'fieldset'=>1, 'form'=>1, 'iframe'=>1, 'input'=>1, 'keygen'=>1, 'label'=>1, 'select'=>1, 'textarea'=>1), 'fieldset'=>array('fieldset'=>1), 'footer'=>array('header'=>1, 'footer'=>1), 'form'=>array('form'=>1), 'header'=>array('header'=>1, 'footer'=>1), 'label'=>array('label'=>1), 'main'=>array('main'=>1), 'meter'=>array('meter'=>1), 'noscript'=>array('script'=>1), 'pre'=>array('big'=>1, 'font'=>1, 'img'=>1, 'object'=>1, 'script'=>1, 'small'=>1, 'sub'=>1, 'sup'=>1), 'progress'=>array('progress'=>1), 'rb'=>array('ruby'=>1), 'rt'=>array('ruby'=>1), 'time'=>array('time'=>1), ); // Illegal |
|
161 | +$cN = array('a'=>array('a'=>1, 'address'=>1, 'button'=>1, 'details'=>1, 'embed'=>1, 'keygen'=>1, 'label'=>1, 'select'=>1, 'textarea'=>1), 'address'=>array('address'=>1, 'article'=>1, 'aside'=>1, 'header'=>1, 'keygen'=>1, 'footer'=>1, 'nav'=>1, 'section'=>1), 'button'=>array('a'=>1, 'address'=>1, 'button'=>1, 'details'=>1, 'embed'=>1, 'fieldset'=>1, 'form'=>1, 'iframe'=>1, 'input'=>1, 'keygen'=>1, 'label'=>1, 'select'=>1, 'textarea'=>1), 'fieldset'=>array('fieldset'=>1), 'footer'=>array('header'=>1, 'footer'=>1), 'form'=>array('form'=>1), 'header'=>array('header'=>1, 'footer'=>1), 'label'=>array('label'=>1), 'main'=>array('main'=>1), 'meter'=>array('meter'=>1), 'noscript'=>array('script'=>1), 'pre'=>array('big'=>1, 'font'=>1, 'img'=>1, 'object'=>1, 'script'=>1, 'small'=>1, 'sub'=>1, 'sup'=>1), 'progress'=>array('progress'=>1), 'rb'=>array('ruby'=>1), 'rt'=>array('ruby'=>1), 'time'=>array('time'=>1),); // Illegal |
|
162 | 162 | $cN2 = array_keys($cN); |
163 | 163 | $cS = array('colgroup'=>array('col'=>1), 'datalist'=>array('option'=>1), 'dir'=>array('li'=>1), 'dl'=>array('dd'=>1, 'dt'=>1), 'hgroup'=>array('h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1), 'menu'=>array('li'=>1), 'ol'=>array('li'=>1), 'optgroup'=>array('option'=>1), 'option'=>array('#pcdata'=>1), 'rbc'=>array('rb'=>1), 'rp'=>array('#pcdata'=>1), 'rtc'=>array('rt'=>1), 'ruby'=>array('rb'=>1, 'rbc'=>1, 'rp'=>1, 'rt'=>1, 'rtc'=>1), 'select'=>array('optgroup'=>1, 'option'=>1), 'script'=>array('#pcdata'=>1), 'table'=>array('caption'=>1, 'col'=>1, 'colgroup'=>1, 'tfoot'=>1, 'tbody'=>1, 'tr'=>1, 'thead'=>1), 'tbody'=>array('tr'=>1), 'tfoot'=>array('tr'=>1), 'textarea'=>array('#pcdata'=>1), 'thead'=>array('tr'=>1), 'tr'=>array('td'=>1, 'th'=>1), 'ul'=>array('li'=>1)); // Specific - immediate parent-child |
164 | -if($GLOBALS['C']['direct_list_nest']){$cS['ol'] = $cS['ul'] = $cS['menu'] += array('menu'=>1, 'ol'=>1, 'ul'=>1);} |
|
165 | -$cO = array('address'=>array('p'=>1), 'applet'=>array('param'=>1), 'audio'=>array('source'=>1, 'track'=>1), 'blockquote'=>array('script'=>1), 'details'=>array('summary'=>1), 'fieldset'=>array('legend'=>1, '#pcdata'=>1), 'figure'=>array('figcaption'=>1),'form'=>array('script'=>1), 'map'=>array('area'=>1), 'object'=>array('param'=>1, 'embed'=>1), 'video'=>array('source'=>1, 'track'=>1)); // Other |
|
164 | +if ($GLOBALS['C']['direct_list_nest']) {$cS['ol'] = $cS['ul'] = $cS['menu'] += array('menu'=>1, 'ol'=>1, 'ul'=>1); } |
|
165 | +$cO = array('address'=>array('p'=>1), 'applet'=>array('param'=>1), 'audio'=>array('source'=>1, 'track'=>1), 'blockquote'=>array('script'=>1), 'details'=>array('summary'=>1), 'fieldset'=>array('legend'=>1, '#pcdata'=>1), 'figure'=>array('figcaption'=>1), 'form'=>array('script'=>1), 'map'=>array('area'=>1), 'object'=>array('param'=>1, 'embed'=>1), 'video'=>array('source'=>1, 'track'=>1)); // Other |
|
166 | 166 | $cT = array('colgroup'=>1, 'dd'=>1, 'dt'=>1, 'li'=>1, 'option'=>1, 'p'=>1, 'td'=>1, 'tfoot'=>1, 'th'=>1, 'thead'=>1, 'tr'=>1); // Omitable closing |
167 | 167 | // block/inline type; a/ins/del both type; #pcdata: text |
168 | 168 | $eB = array('a'=>1, 'address'=>1, 'article'=>1, 'aside'=>1, 'blockquote'=>1, 'center'=>1, 'del'=>1, 'details'=>1, 'dir'=>1, 'dl'=>1, 'div'=>1, 'fieldset'=>1, 'figure'=>1, 'footer'=>1, 'form'=>1, 'ins'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'header'=>1, 'hr'=>1, 'isindex'=>1, 'main'=>1, 'menu'=>1, 'nav'=>1, 'noscript'=>1, 'ol'=>1, 'p'=>1, 'pre'=>1, 'section'=>1, 'style'=>1, 'table'=>1, 'ul'=>1); |
@@ -173,277 +173,277 @@ discard block |
||
173 | 173 | |
174 | 174 | // $in sets allowed child |
175 | 175 | $in = ((isset($eF[$in]) && $in != '#pcdata') or isset($eO[$in])) ? $in : 'div'; |
176 | -if(isset($cE[$in])){ |
|
176 | +if (isset($cE[$in])) { |
|
177 | 177 | return (!$do ? '' : str_replace(array('<', '>'), array('<', '>'), $t)); |
178 | 178 | } |
179 | -if(isset($cS[$in])){$inOk = $cS[$in];} |
|
180 | -elseif(isset($cI[$in])){$inOk = $eI; $cI['del'] = 1; $cI['ins'] = 1;} |
|
181 | -elseif(isset($cF[$in])){$inOk = $eF; unset($cI['del'], $cI['ins']);} |
|
182 | -elseif(isset($cB[$in])){$inOk = $eB; unset($cI['del'], $cI['ins']);} |
|
183 | -if(isset($cO[$in])){$inOk = $inOk + $cO[$in];} |
|
184 | -if(isset($cN[$in])){$inOk = array_diff_assoc($inOk, $cN[$in]);} |
|
179 | +if (isset($cS[$in])) {$inOk = $cS[$in]; } |
|
180 | +elseif (isset($cI[$in])) {$inOk = $eI; $cI['del'] = 1; $cI['ins'] = 1; } |
|
181 | +elseif (isset($cF[$in])) {$inOk = $eF; unset($cI['del'], $cI['ins']); } |
|
182 | +elseif (isset($cB[$in])) {$inOk = $eB; unset($cI['del'], $cI['ins']); } |
|
183 | +if (isset($cO[$in])) {$inOk = $inOk + $cO[$in]; } |
|
184 | +if (isset($cN[$in])) {$inOk = array_diff_assoc($inOk, $cN[$in]); } |
|
185 | 185 | |
186 | 186 | $t = explode('<', $t); |
187 | 187 | $ok = $q = array(); // $q seq list of open non-empty ele |
188 | 188 | ob_start(); |
189 | 189 | |
190 | -for($i=-1, $ci=count($t); ++$i<$ci;){ |
|
190 | +for ($i = -1, $ci = count($t); ++$i < $ci;) { |
|
191 | 191 | // allowed $ok in parent $p |
192 | - if($ql = count($q)){ |
|
192 | + if ($ql = count($q)) { |
|
193 | 193 | $p = array_pop($q); |
194 | 194 | $q[] = $p; |
195 | - if(isset($cS[$p])){$ok = $cS[$p];} |
|
196 | - elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} |
|
197 | - elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} |
|
198 | - elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} |
|
199 | - if(isset($cO[$p])){$ok = $ok + $cO[$p];} |
|
200 | - if(isset($cN[$p])){$ok = array_diff_assoc($ok, $cN[$p]);} |
|
201 | - }else{$ok = $inOk; unset($cI['del'], $cI['ins']);} |
|
195 | + if (isset($cS[$p])) {$ok = $cS[$p]; } |
|
196 | + elseif (isset($cI[$p])) {$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1; } |
|
197 | + elseif (isset($cF[$p])) {$ok = $eF; unset($cI['del'], $cI['ins']); } |
|
198 | + elseif (isset($cB[$p])) {$ok = $eB; unset($cI['del'], $cI['ins']); } |
|
199 | + if (isset($cO[$p])) {$ok = $ok + $cO[$p]; } |
|
200 | + if (isset($cN[$p])) {$ok = array_diff_assoc($ok, $cN[$p]); } |
|
201 | + } else {$ok = $inOk; unset($cI['del'], $cI['ins']); } |
|
202 | 202 | // bad tags, & ele content |
203 | - if(isset($e) && ($do == 1 or (isset($ok['#pcdata']) && ($do == 3 or $do == 5)))){ |
|
203 | + if (isset($e) && ($do == 1 or (isset($ok['#pcdata']) && ($do == 3 or $do == 5)))) { |
|
204 | 204 | echo '<', $s, $e, $a, '>'; |
205 | 205 | } |
206 | - if(isset($x[0])){ |
|
207 | - if(strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))){ |
|
206 | + if (isset($x[0])) { |
|
207 | + if (strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))) { |
|
208 | 208 | echo '<div>', $x, '</div>'; |
209 | 209 | } |
210 | - elseif($do < 3 or isset($ok['#pcdata'])){echo $x;} |
|
211 | - elseif(strpos($x, "\x02\x04")){ |
|
212 | - foreach(preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $v){ |
|
210 | + elseif ($do < 3 or isset($ok['#pcdata'])) {echo $x; } |
|
211 | + elseif (strpos($x, "\x02\x04")) { |
|
212 | + foreach (preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $v) { |
|
213 | 213 | echo (substr($v, 0, 2) == "\x01\x02" ? $v : ($do > 4 ? preg_replace('`\S`', '', $v) : '')); |
214 | 214 | } |
215 | - }elseif($do > 4){echo preg_replace('`\S`', '', $x);} |
|
215 | + }elseif ($do > 4) {echo preg_replace('`\S`', '', $x); } |
|
216 | 216 | } |
217 | 217 | // get markup |
218 | - if(!preg_match('`^(/?)([a-z1-6]+)([^>]*)>(.*)`sm', $t[$i], $r)){$x = $t[$i]; continue;} |
|
218 | + if (!preg_match('`^(/?)([a-z1-6]+)([^>]*)>(.*)`sm', $t[$i], $r)) {$x = $t[$i]; continue; } |
|
219 | 219 | $s = null; $e = null; $a = null; $x = null; list($all, $s, $e, $a, $x) = $r; |
220 | 220 | // close tag |
221 | - if($s){ |
|
222 | - if(isset($cE[$e]) or !in_array($e, $q)){continue;} // Empty/unopen |
|
223 | - if($p == $e){array_pop($q); echo '</', $e, '>'; unset($e); continue;} // Last open |
|
221 | + if ($s) { |
|
222 | + if (isset($cE[$e]) or !in_array($e, $q)) {continue; } // Empty/unopen |
|
223 | + if ($p == $e) {array_pop($q); echo '</', $e, '>'; unset($e); continue; } // Last open |
|
224 | 224 | $add = ''; // Nesting - close open tags that need to be |
225 | - for($j=-1, $cj=count($q); ++$j<$cj;){ |
|
226 | - if(($d = array_pop($q)) == $e){break;} |
|
227 | - else{$add .= "</{$d}>";} |
|
225 | + for ($j = -1, $cj = count($q); ++$j < $cj;) { |
|
226 | + if (($d = array_pop($q)) == $e) {break; } |
|
227 | + else {$add .= "</{$d}>"; } |
|
228 | 228 | } |
229 | 229 | echo $add, '</', $e, '>'; unset($e); continue; |
230 | 230 | } |
231 | 231 | // open tag |
232 | 232 | // $cB ele needs $eB ele as child |
233 | - if(isset($cB[$e]) && strlen(trim($x))){ |
|
233 | + if (isset($cB[$e]) && strlen(trim($x))) { |
|
234 | 234 | $t[$i] = "{$e}{$a}>"; |
235 | - array_splice($t, $i+1, 0, 'div>'. $x); unset($e, $x); ++$ci; --$i; continue; |
|
235 | + array_splice($t, $i + 1, 0, 'div>'.$x); unset($e, $x); ++$ci; --$i; continue; |
|
236 | 236 | } |
237 | - if((($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql)) && !isset($eB[$e]) && !isset($ok[$e])){ |
|
237 | + if ((($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql)) && !isset($eB[$e]) && !isset($ok[$e])) { |
|
238 | 238 | array_splice($t, $i, 0, 'div>'); unset($e, $x); ++$ci; --$i; continue; |
239 | 239 | } |
240 | 240 | // if no open ele, $in = parent; mostly immediate parent-child relation should hold |
241 | - if(!$ql or !isset($eN[$e]) or !array_intersect($q, $cN2)){ |
|
242 | - if(!isset($ok[$e])){ |
|
243 | - if($ql && isset($cT[$p])){echo '</', array_pop($q), '>'; unset($e, $x); --$i;} |
|
241 | + if (!$ql or !isset($eN[$e]) or !array_intersect($q, $cN2)) { |
|
242 | + if (!isset($ok[$e])) { |
|
243 | + if ($ql && isset($cT[$p])) {echo '</', array_pop($q), '>'; unset($e, $x); --$i; } |
|
244 | 244 | continue; |
245 | 245 | } |
246 | - if(!isset($cE[$e])){$q[] = $e;} |
|
246 | + if (!isset($cE[$e])) {$q[] = $e; } |
|
247 | 247 | echo '<', $e, $a, '>'; unset($e); continue; |
248 | 248 | } |
249 | 249 | // specific parent-child |
250 | - if(isset($cS[$p][$e])){ |
|
251 | - if(!isset($cE[$e])){$q[] = $e;} |
|
250 | + if (isset($cS[$p][$e])) { |
|
251 | + if (!isset($cE[$e])) {$q[] = $e; } |
|
252 | 252 | echo '<', $e, $a, '>'; unset($e); continue; |
253 | 253 | } |
254 | 254 | // nesting |
255 | 255 | $add = ''; |
256 | 256 | $q2 = array(); |
257 | - for($k=-1, $kc=count($q); ++$k<$kc;){ |
|
257 | + for ($k = -1, $kc = count($q); ++$k < $kc;) { |
|
258 | 258 | $d = $q[$k]; |
259 | 259 | $ok2 = array(); |
260 | - if(isset($cS[$d])){$q2[] = $d; continue;} |
|
260 | + if (isset($cS[$d])) {$q2[] = $d; continue; } |
|
261 | 261 | $ok2 = isset($cI[$d]) ? $eI : $eF; |
262 | - if(isset($cO[$d])){$ok2 = $ok2 + $cO[$d];} |
|
263 | - if(isset($cN[$d])){$ok2 = array_diff_assoc($ok2, $cN[$d]);} |
|
264 | - if(!isset($ok2[$e])){ |
|
265 | - if(!$k && !isset($inOk[$e])){continue 2;} |
|
262 | + if (isset($cO[$d])) {$ok2 = $ok2 + $cO[$d]; } |
|
263 | + if (isset($cN[$d])) {$ok2 = array_diff_assoc($ok2, $cN[$d]); } |
|
264 | + if (!isset($ok2[$e])) { |
|
265 | + if (!$k && !isset($inOk[$e])) {continue 2; } |
|
266 | 266 | $add = "</{$d}>"; |
267 | - for(;++$k<$kc;){$add = "</{$q[$k]}>{$add}";} |
|
267 | + for (;++$k < $kc;) {$add = "</{$q[$k]}>{$add}"; } |
|
268 | 268 | break; |
269 | 269 | } |
270 | - else{$q2[] = $d;} |
|
270 | + else {$q2[] = $d; } |
|
271 | 271 | } |
272 | 272 | $q = $q2; |
273 | - if(!isset($cE[$e])){$q[] = $e;} |
|
273 | + if (!isset($cE[$e])) {$q[] = $e; } |
|
274 | 274 | echo $add, '<', $e, $a, '>'; unset($e); continue; |
275 | 275 | } |
276 | 276 | |
277 | 277 | // end |
278 | -if($ql = count($q)){ |
|
278 | +if ($ql = count($q)) { |
|
279 | 279 | $p = array_pop($q); |
280 | 280 | $q[] = $p; |
281 | - if(isset($cS[$p])){$ok = $cS[$p];} |
|
282 | - elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} |
|
283 | - elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} |
|
284 | - elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} |
|
285 | - if(isset($cO[$p])){$ok = $ok + $cO[$p];} |
|
286 | - if(isset($cN[$p])){$ok = array_diff_assoc($ok, $cN[$p]);} |
|
287 | -}else{$ok = $inOk; unset($cI['del'], $cI['ins']);} |
|
288 | -if(isset($e) && ($do == 1 or (isset($ok['#pcdata']) && ($do == 3 or $do == 5)))){ |
|
281 | + if (isset($cS[$p])) {$ok = $cS[$p]; } |
|
282 | + elseif (isset($cI[$p])) {$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1; } |
|
283 | + elseif (isset($cF[$p])) {$ok = $eF; unset($cI['del'], $cI['ins']); } |
|
284 | + elseif (isset($cB[$p])) {$ok = $eB; unset($cI['del'], $cI['ins']); } |
|
285 | + if (isset($cO[$p])) {$ok = $ok + $cO[$p]; } |
|
286 | + if (isset($cN[$p])) {$ok = array_diff_assoc($ok, $cN[$p]); } |
|
287 | +} else {$ok = $inOk; unset($cI['del'], $cI['ins']); } |
|
288 | +if (isset($e) && ($do == 1 or (isset($ok['#pcdata']) && ($do == 3 or $do == 5)))) { |
|
289 | 289 | echo '<', $s, $e, $a, '>'; |
290 | 290 | } |
291 | -if(isset($x[0])){ |
|
292 | - if(strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))){ |
|
291 | +if (isset($x[0])) { |
|
292 | + if (strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))) { |
|
293 | 293 | echo '<div>', $x, '</div>'; |
294 | 294 | } |
295 | - elseif($do < 3 or isset($ok['#pcdata'])){echo $x;} |
|
296 | - elseif(strpos($x, "\x02\x04")){ |
|
297 | - foreach(preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $v){ |
|
295 | + elseif ($do < 3 or isset($ok['#pcdata'])) {echo $x; } |
|
296 | + elseif (strpos($x, "\x02\x04")) { |
|
297 | + foreach (preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $v) { |
|
298 | 298 | echo (substr($v, 0, 2) == "\x01\x02" ? $v : ($do > 4 ? preg_replace('`\S`', '', $v) : '')); |
299 | 299 | } |
300 | - }elseif($do > 4){echo preg_replace('`\S`', '', $x);} |
|
300 | + }elseif ($do > 4) {echo preg_replace('`\S`', '', $x); } |
|
301 | 301 | } |
302 | -while(!empty($q) && ($e = array_pop($q))){echo '</', $e, '>';} |
|
302 | +while (!empty($q) && ($e = array_pop($q))) {echo '</', $e, '>'; } |
|
303 | 303 | $o = ob_get_contents(); |
304 | 304 | ob_end_clean(); |
305 | 305 | return $o; |
306 | 306 | } |
307 | 307 | |
308 | -public static function hl_cmtcd($t){ |
|
308 | +public static function hl_cmtcd($t) { |
|
309 | 309 | // comment/CDATA sec handler |
310 | 310 | $t = $t[0]; |
311 | 311 | global $C; |
312 | -if(!($v = $C[$n = $t[3] == '-' ? 'comment' : 'cdata'])){return $t;} |
|
313 | -if($v == 1){return '';} |
|
314 | -if($n == 'comment' && $v < 4){ |
|
315 | - if(substr(($t = preg_replace('`--+`', '-', substr($t, 4, -3))), -1) != ' '){$t .= ' ';} |
|
312 | +if (!($v = $C[$n = $t[3] == '-' ? 'comment' : 'cdata'])) {return $t; } |
|
313 | +if ($v == 1) {return ''; } |
|
314 | +if ($n == 'comment' && $v < 4) { |
|
315 | + if (substr(($t = preg_replace('`--+`', '-', substr($t, 4, -3))), -1) != ' ') {$t .= ' '; } |
|
316 | 316 | } |
317 | -else{$t = substr($t, 1, -1);} |
|
317 | +else {$t = substr($t, 1, -1); } |
|
318 | 318 | $t = $v == 2 ? str_replace(array('&', '<', '>'), array('&', '<', '>'), $t) : $t; |
319 | 319 | return str_replace(array('&', '<', '>'), array("\x03", "\x04", "\x05"), ($n == 'comment' ? "\x01\x02\x04!--$t--\x05\x02\x01" : "\x01\x01\x04$t\x05\x01\x01")); |
320 | 320 | } |
321 | 321 | |
322 | -public static function hl_ent($t){ |
|
322 | +public static function hl_ent($t) { |
|
323 | 323 | // entitity handler |
324 | 324 | global $C; |
325 | 325 | $t = $t[1]; |
326 | -static $U = array('quot'=>1,'amp'=>1,'lt'=>1,'gt'=>1); |
|
327 | -static $N = array('fnof'=>'402', 'Alpha'=>'913', 'Beta'=>'914', 'Gamma'=>'915', 'Delta'=>'916', 'Epsilon'=>'917', 'Zeta'=>'918', 'Eta'=>'919', 'Theta'=>'920', 'Iota'=>'921', 'Kappa'=>'922', 'Lambda'=>'923', 'Mu'=>'924', 'Nu'=>'925', 'Xi'=>'926', 'Omicron'=>'927', 'Pi'=>'928', 'Rho'=>'929', 'Sigma'=>'931', 'Tau'=>'932', 'Upsilon'=>'933', 'Phi'=>'934', 'Chi'=>'935', 'Psi'=>'936', 'Omega'=>'937', 'alpha'=>'945', 'beta'=>'946', 'gamma'=>'947', 'delta'=>'948', 'epsilon'=>'949', 'zeta'=>'950', 'eta'=>'951', 'theta'=>'952', 'iota'=>'953', 'kappa'=>'954', 'lambda'=>'955', 'mu'=>'956', 'nu'=>'957', 'xi'=>'958', 'omicron'=>'959', 'pi'=>'960', 'rho'=>'961', 'sigmaf'=>'962', 'sigma'=>'963', 'tau'=>'964', 'upsilon'=>'965', 'phi'=>'966', 'chi'=>'967', 'psi'=>'968', 'omega'=>'969', 'thetasym'=>'977', 'upsih'=>'978', 'piv'=>'982', 'bull'=>'8226', 'hellip'=>'8230', 'prime'=>'8242', 'Prime'=>'8243', 'oline'=>'8254', 'frasl'=>'8260', 'weierp'=>'8472', 'image'=>'8465', 'real'=>'8476', 'trade'=>'8482', 'alefsym'=>'8501', 'larr'=>'8592', 'uarr'=>'8593', 'rarr'=>'8594', 'darr'=>'8595', 'harr'=>'8596', 'crarr'=>'8629', 'lArr'=>'8656', 'uArr'=>'8657', 'rArr'=>'8658', 'dArr'=>'8659', 'hArr'=>'8660', 'forall'=>'8704', 'part'=>'8706', 'exist'=>'8707', 'empty'=>'8709', 'nabla'=>'8711', 'isin'=>'8712', 'notin'=>'8713', 'ni'=>'8715', 'prod'=>'8719', 'sum'=>'8721', 'minus'=>'8722', 'lowast'=>'8727', 'radic'=>'8730', 'prop'=>'8733', 'infin'=>'8734', 'ang'=>'8736', 'and'=>'8743', 'or'=>'8744', 'cap'=>'8745', 'cup'=>'8746', 'int'=>'8747', 'there4'=>'8756', 'sim'=>'8764', 'cong'=>'8773', 'asymp'=>'8776', 'ne'=>'8800', 'equiv'=>'8801', 'le'=>'8804', 'ge'=>'8805', 'sub'=>'8834', 'sup'=>'8835', 'nsub'=>'8836', 'sube'=>'8838', 'supe'=>'8839', 'oplus'=>'8853', 'otimes'=>'8855', 'perp'=>'8869', 'sdot'=>'8901', 'lceil'=>'8968', 'rceil'=>'8969', 'lfloor'=>'8970', 'rfloor'=>'8971', 'lang'=>'9001', 'rang'=>'9002', 'loz'=>'9674', 'spades'=>'9824', 'clubs'=>'9827', 'hearts'=>'9829', 'diams'=>'9830', 'apos'=>'39', 'OElig'=>'338', 'oelig'=>'339', 'Scaron'=>'352', 'scaron'=>'353', 'Yuml'=>'376', 'circ'=>'710', 'tilde'=>'732', 'ensp'=>'8194', 'emsp'=>'8195', 'thinsp'=>'8201', 'zwnj'=>'8204', 'zwj'=>'8205', 'lrm'=>'8206', 'rlm'=>'8207', 'ndash'=>'8211', 'mdash'=>'8212', 'lsquo'=>'8216', 'rsquo'=>'8217', 'sbquo'=>'8218', 'ldquo'=>'8220', 'rdquo'=>'8221', 'bdquo'=>'8222', 'dagger'=>'8224', 'Dagger'=>'8225', 'permil'=>'8240', 'lsaquo'=>'8249', 'rsaquo'=>'8250', 'euro'=>'8364', 'nbsp'=>'160', 'iexcl'=>'161', 'cent'=>'162', 'pound'=>'163', 'curren'=>'164', 'yen'=>'165', 'brvbar'=>'166', 'sect'=>'167', 'uml'=>'168', 'copy'=>'169', 'ordf'=>'170', 'laquo'=>'171', 'not'=>'172', 'shy'=>'173', 'reg'=>'174', 'macr'=>'175', 'deg'=>'176', 'plusmn'=>'177', 'sup2'=>'178', 'sup3'=>'179', 'acute'=>'180', 'micro'=>'181', 'para'=>'182', 'middot'=>'183', 'cedil'=>'184', 'sup1'=>'185', 'ordm'=>'186', 'raquo'=>'187', 'frac14'=>'188', 'frac12'=>'189', 'frac34'=>'190', 'iquest'=>'191', 'Agrave'=>'192', 'Aacute'=>'193', 'Acirc'=>'194', 'Atilde'=>'195', 'Auml'=>'196', 'Aring'=>'197', 'AElig'=>'198', 'Ccedil'=>'199', 'Egrave'=>'200', 'Eacute'=>'201', 'Ecirc'=>'202', 'Euml'=>'203', 'Igrave'=>'204', 'Iacute'=>'205', 'Icirc'=>'206', 'Iuml'=>'207', 'ETH'=>'208', 'Ntilde'=>'209', 'Ograve'=>'210', 'Oacute'=>'211', 'Ocirc'=>'212', 'Otilde'=>'213', 'Ouml'=>'214', 'times'=>'215', 'Oslash'=>'216', 'Ugrave'=>'217', 'Uacute'=>'218', 'Ucirc'=>'219', 'Uuml'=>'220', 'Yacute'=>'221', 'THORN'=>'222', 'szlig'=>'223', 'agrave'=>'224', 'aacute'=>'225', 'acirc'=>'226', 'atilde'=>'227', 'auml'=>'228', 'aring'=>'229', 'aelig'=>'230', 'ccedil'=>'231', 'egrave'=>'232', 'eacute'=>'233', 'ecirc'=>'234', 'euml'=>'235', 'igrave'=>'236', 'iacute'=>'237', 'icirc'=>'238', 'iuml'=>'239', 'eth'=>'240', 'ntilde'=>'241', 'ograve'=>'242', 'oacute'=>'243', 'ocirc'=>'244', 'otilde'=>'245', 'ouml'=>'246', 'divide'=>'247', 'oslash'=>'248', 'ugrave'=>'249', 'uacute'=>'250', 'ucirc'=>'251', 'uuml'=>'252', 'yacute'=>'253', 'thorn'=>'254', 'yuml'=>'255'); |
|
328 | -if($t[0] != '#'){ |
|
329 | - return ($C['and_mark'] ? "\x06" : '&'). (isset($U[$t]) ? $t : (isset($N[$t]) ? (!$C['named_entity'] ? '#'. ($C['hexdec_entity'] > 1 ? 'x'. dechex($N[$t]) : $N[$t]) : $t) : 'amp;'. $t)). ';'; |
|
326 | +static $U = array('quot'=>1, 'amp'=>1, 'lt'=>1, 'gt'=>1); |
|
327 | +static $N = array('fnof'=>'402', 'Alpha'=>'913', 'Beta'=>'914', 'Gamma'=>'915', 'Delta'=>'916', 'Epsilon'=>'917', 'Zeta'=>'918', 'Eta'=>'919', 'Theta'=>'920', 'Iota'=>'921', 'Kappa'=>'922', 'Lambda'=>'923', 'Mu'=>'924', 'Nu'=>'925', 'Xi'=>'926', 'Omicron'=>'927', 'Pi'=>'928', 'Rho'=>'929', 'Sigma'=>'931', 'Tau'=>'932', 'Upsilon'=>'933', 'Phi'=>'934', 'Chi'=>'935', 'Psi'=>'936', 'Omega'=>'937', 'alpha'=>'945', 'beta'=>'946', 'gamma'=>'947', 'delta'=>'948', 'epsilon'=>'949', 'zeta'=>'950', 'eta'=>'951', 'theta'=>'952', 'iota'=>'953', 'kappa'=>'954', 'lambda'=>'955', 'mu'=>'956', 'nu'=>'957', 'xi'=>'958', 'omicron'=>'959', 'pi'=>'960', 'rho'=>'961', 'sigmaf'=>'962', 'sigma'=>'963', 'tau'=>'964', 'upsilon'=>'965', 'phi'=>'966', 'chi'=>'967', 'psi'=>'968', 'omega'=>'969', 'thetasym'=>'977', 'upsih'=>'978', 'piv'=>'982', 'bull'=>'8226', 'hellip'=>'8230', 'prime'=>'8242', 'Prime'=>'8243', 'oline'=>'8254', 'frasl'=>'8260', 'weierp'=>'8472', 'image'=>'8465', 'real'=>'8476', 'trade'=>'8482', 'alefsym'=>'8501', 'larr'=>'8592', 'uarr'=>'8593', 'rarr'=>'8594', 'darr'=>'8595', 'harr'=>'8596', 'crarr'=>'8629', 'lArr'=>'8656', 'uArr'=>'8657', 'rArr'=>'8658', 'dArr'=>'8659', 'hArr'=>'8660', 'forall'=>'8704', 'part'=>'8706', 'exist'=>'8707', 'empty'=>'8709', 'nabla'=>'8711', 'isin'=>'8712', 'notin'=>'8713', 'ni'=>'8715', 'prod'=>'8719', 'sum'=>'8721', 'minus'=>'8722', 'lowast'=>'8727', 'radic'=>'8730', 'prop'=>'8733', 'infin'=>'8734', 'ang'=>'8736', 'and'=>'8743', 'or'=>'8744', 'cap'=>'8745', 'cup'=>'8746', 'int'=>'8747', 'there4'=>'8756', 'sim'=>'8764', 'cong'=>'8773', 'asymp'=>'8776', 'ne'=>'8800', 'equiv'=>'8801', 'le'=>'8804', 'ge'=>'8805', 'sub'=>'8834', 'sup'=>'8835', 'nsub'=>'8836', 'sube'=>'8838', 'supe'=>'8839', 'oplus'=>'8853', 'otimes'=>'8855', 'perp'=>'8869', 'sdot'=>'8901', 'lceil'=>'8968', 'rceil'=>'8969', 'lfloor'=>'8970', 'rfloor'=>'8971', 'lang'=>'9001', 'rang'=>'9002', 'loz'=>'9674', 'spades'=>'9824', 'clubs'=>'9827', 'hearts'=>'9829', 'diams'=>'9830', 'apos'=>'39', 'OElig'=>'338', 'oelig'=>'339', 'Scaron'=>'352', 'scaron'=>'353', 'Yuml'=>'376', 'circ'=>'710', 'tilde'=>'732', 'ensp'=>'8194', 'emsp'=>'8195', 'thinsp'=>'8201', 'zwnj'=>'8204', 'zwj'=>'8205', 'lrm'=>'8206', 'rlm'=>'8207', 'ndash'=>'8211', 'mdash'=>'8212', 'lsquo'=>'8216', 'rsquo'=>'8217', 'sbquo'=>'8218', 'ldquo'=>'8220', 'rdquo'=>'8221', 'bdquo'=>'8222', 'dagger'=>'8224', 'Dagger'=>'8225', 'permil'=>'8240', 'lsaquo'=>'8249', 'rsaquo'=>'8250', 'euro'=>'8364', 'nbsp'=>'160', 'iexcl'=>'161', 'cent'=>'162', 'pound'=>'163', 'curren'=>'164', 'yen'=>'165', 'brvbar'=>'166', 'sect'=>'167', 'uml'=>'168', 'copy'=>'169', 'ordf'=>'170', 'laquo'=>'171', 'not'=>'172', 'shy'=>'173', 'reg'=>'174', 'macr'=>'175', 'deg'=>'176', 'plusmn'=>'177', 'sup2'=>'178', 'sup3'=>'179', 'acute'=>'180', 'micro'=>'181', 'para'=>'182', 'middot'=>'183', 'cedil'=>'184', 'sup1'=>'185', 'ordm'=>'186', 'raquo'=>'187', 'frac14'=>'188', 'frac12'=>'189', 'frac34'=>'190', 'iquest'=>'191', 'Agrave'=>'192', 'Aacute'=>'193', 'Acirc'=>'194', 'Atilde'=>'195', 'Auml'=>'196', 'Aring'=>'197', 'AElig'=>'198', 'Ccedil'=>'199', 'Egrave'=>'200', 'Eacute'=>'201', 'Ecirc'=>'202', 'Euml'=>'203', 'Igrave'=>'204', 'Iacute'=>'205', 'Icirc'=>'206', 'Iuml'=>'207', 'ETH'=>'208', 'Ntilde'=>'209', 'Ograve'=>'210', 'Oacute'=>'211', 'Ocirc'=>'212', 'Otilde'=>'213', 'Ouml'=>'214', 'times'=>'215', 'Oslash'=>'216', 'Ugrave'=>'217', 'Uacute'=>'218', 'Ucirc'=>'219', 'Uuml'=>'220', 'Yacute'=>'221', 'THORN'=>'222', 'szlig'=>'223', 'agrave'=>'224', 'aacute'=>'225', 'acirc'=>'226', 'atilde'=>'227', 'auml'=>'228', 'aring'=>'229', 'aelig'=>'230', 'ccedil'=>'231', 'egrave'=>'232', 'eacute'=>'233', 'ecirc'=>'234', 'euml'=>'235', 'igrave'=>'236', 'iacute'=>'237', 'icirc'=>'238', 'iuml'=>'239', 'eth'=>'240', 'ntilde'=>'241', 'ograve'=>'242', 'oacute'=>'243', 'ocirc'=>'244', 'otilde'=>'245', 'ouml'=>'246', 'divide'=>'247', 'oslash'=>'248', 'ugrave'=>'249', 'uacute'=>'250', 'ucirc'=>'251', 'uuml'=>'252', 'yacute'=>'253', 'thorn'=>'254', 'yuml'=>'255'); |
|
328 | +if ($t[0] != '#') { |
|
329 | + return ($C['and_mark'] ? "\x06" : '&').(isset($U[$t]) ? $t : (isset($N[$t]) ? (!$C['named_entity'] ? '#'.($C['hexdec_entity'] > 1 ? 'x'.dechex($N[$t]) : $N[$t]) : $t) : 'amp;'.$t)).';'; |
|
330 | 330 | } |
331 | -if(($n = ctype_digit($t = substr($t, 1)) ? intval($t) : hexdec(substr($t, 1))) < 9 or ($n > 13 && $n < 32) or $n == 11 or $n == 12 or ($n > 126 && $n < 160 && $n != 133) or ($n > 55295 && ($n < 57344 or ($n > 64975 && $n < 64992) or $n == 65534 or $n == 65535 or $n > 1114111))){ |
|
332 | - return ($C['and_mark'] ? "\x06" : '&'). "amp;#{$t};"; |
|
331 | +if (($n = ctype_digit($t = substr($t, 1)) ? intval($t) : hexdec(substr($t, 1))) < 9 or ($n > 13 && $n < 32) or $n == 11 or $n == 12 or ($n > 126 && $n < 160 && $n != 133) or ($n > 55295 && ($n < 57344 or ($n > 64975 && $n < 64992) or $n == 65534 or $n == 65535 or $n > 1114111))) { |
|
332 | + return ($C['and_mark'] ? "\x06" : '&')."amp;#{$t};"; |
|
333 | 333 | } |
334 | -return ($C['and_mark'] ? "\x06" : '&'). '#'. (((ctype_digit($t) && $C['hexdec_entity'] < 2) or !$C['hexdec_entity']) ? $n : 'x'. dechex($n)). ';'; |
|
334 | +return ($C['and_mark'] ? "\x06" : '&').'#'.(((ctype_digit($t) && $C['hexdec_entity'] < 2) or !$C['hexdec_entity']) ? $n : 'x'.dechex($n)).';'; |
|
335 | 335 | } |
336 | 336 | |
337 | -public static function hl_prot($p, $c=null){ |
|
337 | +public static function hl_prot($p, $c = null) { |
|
338 | 338 | // check URL scheme |
339 | 339 | global $C; |
340 | 340 | $b = $a = ''; |
341 | -if($c == null){$c = 'style'; $b = $p[1]; $a = $p[3]; $p = trim($p[2]);} |
|
341 | +if ($c == null) {$c = 'style'; $b = $p[1]; $a = $p[3]; $p = trim($p[2]); } |
|
342 | 342 | $c = isset($C['schemes'][$c]) ? $C['schemes'][$c] : $C['schemes']['*']; |
343 | 343 | static $d = 'denied:'; |
344 | -if(isset($c['!']) && substr($p, 0, 7) != $d){$p = "$d$p";} |
|
345 | -if(isset($c['*']) or !strcspn($p, '#?;') or (substr($p, 0, 7) == $d)){return "{$b}{$p}{$a}";} // All ok, frag, query, param |
|
346 | -if(preg_match('`^([^:?[@!$()*,=/\'\]]+?)(:|&#(58|x3a);|%3a|\\\\0{0,4}3a).`i', $p, $m) && !isset($c[strtolower($m[1])])){ // Denied prot |
|
344 | +if (isset($c['!']) && substr($p, 0, 7) != $d) {$p = "$d$p"; } |
|
345 | +if (isset($c['*']) or !strcspn($p, '#?;') or (substr($p, 0, 7) == $d)) {return "{$b}{$p}{$a}"; } // All ok, frag, query, param |
|
346 | +if (preg_match('`^([^:?[@!$()*,=/\'\]]+?)(:|&#(58|x3a);|%3a|\\\\0{0,4}3a).`i', $p, $m) && !isset($c[strtolower($m[1])])) { // Denied prot |
|
347 | 347 | return "{$b}{$d}{$p}{$a}"; |
348 | 348 | } |
349 | -if($C['abs_url']){ |
|
350 | - if($C['abs_url'] == -1 && strpos($p, $C['base_url']) === 0){ // Make url rel |
|
349 | +if ($C['abs_url']) { |
|
350 | + if ($C['abs_url'] == -1 && strpos($p, $C['base_url']) === 0) { // Make url rel |
|
351 | 351 | $p = substr($p, strlen($C['base_url'])); |
352 | - }elseif(empty($m[1])){ // Make URL abs |
|
353 | - if(substr($p, 0, 2) == '//'){$p = substr($C['base_url'], 0, strpos($C['base_url'], ':')+1). $p;} |
|
354 | - elseif($p[0] == '/'){$p = preg_replace('`(^.+?://[^/]+)(.*)`', '$1', $C['base_url']). $p;} |
|
355 | - elseif(strcspn($p, './')){$p = $C['base_url']. $p;} |
|
356 | - else{ |
|
352 | + }elseif (empty($m[1])) { // Make URL abs |
|
353 | + if (substr($p, 0, 2) == '//') {$p = substr($C['base_url'], 0, strpos($C['base_url'], ':') + 1).$p; } |
|
354 | + elseif ($p[0] == '/') {$p = preg_replace('`(^.+?://[^/]+)(.*)`', '$1', $C['base_url']).$p; } |
|
355 | + elseif (strcspn($p, './')) {$p = $C['base_url'].$p; } |
|
356 | + else { |
|
357 | 357 | preg_match('`^([a-zA-Z\d\-+.]+://[^/]+)(.*)`', $C['base_url'], $m); |
358 | - $p = preg_replace('`(?<=/)\./`', '', $m[2]. $p); |
|
359 | - while(preg_match('`(?<=/)([^/]{3,}|[^/.]+?|\.[^/.]|[^/.]\.)/\.\./`', $p)){ |
|
358 | + $p = preg_replace('`(?<=/)\./`', '', $m[2].$p); |
|
359 | + while (preg_match('`(?<=/)([^/]{3,}|[^/.]+?|\.[^/.]|[^/.]\.)/\.\./`', $p)) { |
|
360 | 360 | $p = preg_replace('`(?<=/)([^/]{3,}|[^/.]+?|\.[^/.]|[^/.]\.)/\.\./`', '', $p); |
361 | 361 | } |
362 | - $p = $m[1]. $p; |
|
362 | + $p = $m[1].$p; |
|
363 | 363 | } |
364 | 364 | } |
365 | 365 | } |
366 | 366 | return "{$b}{$p}{$a}"; |
367 | 367 | } |
368 | 368 | |
369 | -public static function hl_regex($p){ |
|
369 | +public static function hl_regex($p) { |
|
370 | 370 | // check regex |
371 | -if(empty($p)){return 0;} |
|
372 | -if($v = function_exists('error_clear_last') && function_exists('error_get_last')){error_clear_last();} |
|
373 | -else{ |
|
374 | - if($t = ini_get('track_errors')){$o = isset($php_errormsg) ? $php_errormsg : null;} |
|
375 | - else{ini_set('track_errors', 1);} |
|
371 | +if (empty($p)) {return 0; } |
|
372 | +if ($v = function_exists('error_clear_last') && function_exists('error_get_last')) {error_clear_last(); } |
|
373 | +else { |
|
374 | + if ($t = ini_get('track_errors')) {$o = isset($php_errormsg) ? $php_errormsg : null; } |
|
375 | + else {ini_set('track_errors', 1); } |
|
376 | 376 | unset($php_errormsg); |
377 | 377 | } |
378 | -if(($d = ini_get('display_errors'))){ini_set('display_errors', 0);} |
|
378 | +if (($d = ini_get('display_errors'))) {ini_set('display_errors', 0); } |
|
379 | 379 | preg_match($p, ''); |
380 | -if($v){$r = error_get_last() == null ? 1 : 0; } |
|
381 | -else{ |
|
380 | +if ($v) {$r = error_get_last() == null ? 1 : 0; } |
|
381 | +else { |
|
382 | 382 | $r = isset($php_errormsg) ? 0 : 1; |
383 | - if($t){$php_errormsg = isset($o) ? $o : null;} |
|
384 | - else{ini_set('track_errors', 0);} |
|
383 | + if ($t) {$php_errormsg = isset($o) ? $o : null; } |
|
384 | + else {ini_set('track_errors', 0); } |
|
385 | 385 | } |
386 | -if($d){ini_set('display_errors', 1);} |
|
386 | +if ($d) {ini_set('display_errors', 1); } |
|
387 | 387 | return $r; |
388 | 388 | } |
389 | 389 | |
390 | -public static function hl_spec($t){ |
|
390 | +public static function hl_spec($t) { |
|
391 | 391 | // final $spec |
392 | 392 | $s = array(); |
393 | -if(!function_exists('hl_aux1')){function hl_aux1($m){ |
|
393 | +if (!function_exists('hl_aux1')) {function hl_aux1($m) { |
|
394 | 394 | return substr(str_replace(array(";", "|", "~", " ", ",", "/", "(", ")", '`"'), array("\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", '"'), $m[0]), 1, -1); |
395 | 395 | }} |
396 | 396 | $t = str_replace(array("\t", "\r", "\n", ' '), '', preg_replace_callback('/"(?>(`.|[^"])*)"/sm', 'hl_aux1', trim($t))); |
397 | -for($i = count(($t = explode(';', $t))); --$i>=0;){ |
|
397 | +for ($i = count(($t = explode(';', $t))); --$i >= 0;) { |
|
398 | 398 | $w = $t[$i]; |
399 | - if(empty($w) or ($e = strpos($w, '=')) === false or !strlen(($a = substr($w, $e+1)))){continue;} |
|
399 | + if (empty($w) or ($e = strpos($w, '=')) === false or !strlen(($a = substr($w, $e + 1)))) {continue; } |
|
400 | 400 | $y = $n = array(); |
401 | - foreach(explode(',', $a) as $v){ |
|
402 | - if(!preg_match('`^([a-z:\-\*]+)(?:\((.*?)\))?`i', $v, $m)){continue;} |
|
403 | - if(($x = strtolower($m[1])) == '-*'){$n['*'] = 1; continue;} |
|
404 | - if($x[0] == '-'){$n[substr($x, 1)] = 1; continue;} |
|
405 | - if(!isset($m[2])){$y[$x] = 1; continue;} |
|
406 | - foreach(explode('/', $m[2]) as $m){ |
|
407 | - if(empty($m) or ($p = strpos($m, '=')) == 0 or $p < 5){$y[$x] = 1; continue;} |
|
408 | - $y[$x][strtolower(substr($m, 0, $p))] = str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08"), array(";", "|", "~", " ", ",", "/", "(", ")"), substr($m, $p+1)); |
|
401 | + foreach (explode(',', $a) as $v) { |
|
402 | + if (!preg_match('`^([a-z:\-\*]+)(?:\((.*?)\))?`i', $v, $m)) {continue; } |
|
403 | + if (($x = strtolower($m[1])) == '-*') {$n['*'] = 1; continue; } |
|
404 | + if ($x[0] == '-') {$n[substr($x, 1)] = 1; continue; } |
|
405 | + if (!isset($m[2])) {$y[$x] = 1; continue; } |
|
406 | + foreach (explode('/', $m[2]) as $m) { |
|
407 | + if (empty($m) or ($p = strpos($m, '=')) == 0 or $p < 5) {$y[$x] = 1; continue; } |
|
408 | + $y[$x][strtolower(substr($m, 0, $p))] = str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08"), array(";", "|", "~", " ", ",", "/", "(", ")"), substr($m, $p + 1)); |
|
409 | 409 | } |
410 | - if(isset($y[$x]['match']) && !htmLawed::hl_regex($y[$x]['match'])){unset($y[$x]['match']);} |
|
411 | - if(isset($y[$x]['nomatch']) && !htmLawed::hl_regex($y[$x]['nomatch'])){unset($y[$x]['nomatch']);} |
|
410 | + if (isset($y[$x]['match']) && !htmLawed::hl_regex($y[$x]['match'])) {unset($y[$x]['match']); } |
|
411 | + if (isset($y[$x]['nomatch']) && !htmLawed::hl_regex($y[$x]['nomatch'])) {unset($y[$x]['nomatch']); } |
|
412 | 412 | } |
413 | - if(!count($y) && !count($n)){continue;} |
|
414 | - foreach(explode(',', substr($w, 0, $e)) as $v){ |
|
415 | - if(!strlen(($v = strtolower($v)))){continue;} |
|
416 | - if(count($y)){if(!isset($s[$v])){$s[$v] = $y;} else{$s[$v] = array_merge($s[$v], $y);}} |
|
417 | - if(count($n)){if(!isset($s[$v]['n'])){$s[$v]['n'] = $n;} else{$s[$v]['n'] = array_merge($s[$v]['n'], $n);}} |
|
413 | + if (!count($y) && !count($n)) {continue; } |
|
414 | + foreach (explode(',', substr($w, 0, $e)) as $v) { |
|
415 | + if (!strlen(($v = strtolower($v)))) {continue; } |
|
416 | + if (count($y)) {if (!isset($s[$v])) {$s[$v] = $y; } else {$s[$v] = array_merge($s[$v], $y); }} |
|
417 | + if (count($n)) {if (!isset($s[$v]['n'])) {$s[$v]['n'] = $n; } else {$s[$v]['n'] = array_merge($s[$v]['n'], $n); }} |
|
418 | 418 | } |
419 | 419 | } |
420 | 420 | return $s; |
421 | 421 | } |
422 | 422 | |
423 | -public static function hl_tag($t){ |
|
423 | +public static function hl_tag($t) { |
|
424 | 424 | // tag/attribute handler |
425 | 425 | global $C; |
426 | 426 | $t = $t[0]; |
427 | 427 | // invalid < > |
428 | -if($t == '< '){return '< ';} |
|
429 | -if($t == '>'){return '>';} |
|
430 | -if(!preg_match('`^<(/?)([a-zA-Z][a-zA-Z1-6]*)([^>]*?)\s?>$`m', $t, $m)){ |
|
428 | +if ($t == '< ') {return '< '; } |
|
429 | +if ($t == '>') {return '>'; } |
|
430 | +if (!preg_match('`^<(/?)([a-zA-Z][a-zA-Z1-6]*)([^>]*?)\s?>$`m', $t, $m)) { |
|
431 | 431 | return str_replace(array('<', '>'), array('<', '>'), $t); |
432 | -}elseif(!isset($C['elements'][($e = strtolower($m[2]))])){ |
|
433 | - return (($C['keep_bad']%2) ? str_replace(array('<', '>'), array('<', '>'), $t) : ''); |
|
432 | +}elseif (!isset($C['elements'][($e = strtolower($m[2]))])) { |
|
433 | + return (($C['keep_bad'] % 2) ? str_replace(array('<', '>'), array('<', '>'), $t) : ''); |
|
434 | 434 | } |
435 | 435 | // attr string |
436 | 436 | $a = str_replace(array("\n", "\r", "\t"), ' ', trim($m[3])); |
437 | 437 | // tag transform |
438 | 438 | static $eD = array('acronym'=>1, 'applet'=>1, 'big'=>1, 'center'=>1, 'dir'=>1, 'font'=>1, 'isindex'=>1, 's'=>1, 'strike'=>1, 'tt'=>1); // Deprecated |
439 | -if($C['make_tag_strict'] && isset($eD[$e])){ |
|
439 | +if ($C['make_tag_strict'] && isset($eD[$e])) { |
|
440 | 440 | $trt = htmLawed::hl_tag2($e, $a, $C['make_tag_strict']); |
441 | - if(!$e){return (($C['keep_bad']%2) ? str_replace(array('<', '>'), array('<', '>'), $t) : '');} |
|
441 | + if (!$e) {return (($C['keep_bad'] % 2) ? str_replace(array('<', '>'), array('<', '>'), $t) : ''); } |
|
442 | 442 | } |
443 | 443 | // close tag |
444 | 444 | static $eE = array('area'=>1, 'br'=>1, 'col'=>1, 'command'=>1, 'embed'=>1, 'hr'=>1, 'img'=>1, 'input'=>1, 'isindex'=>1, 'keygen'=>1, 'link'=>1, 'meta'=>1, 'param'=>1, 'source'=>1, 'track'=>1, 'wbr'=>1); // Empty ele |
445 | -if(!empty($m[1])){ |
|
446 | - return (!isset($eE[$e]) ? (empty($C['hook_tag']) ? "</$e>" : $C['hook_tag']($e)) : (($C['keep_bad'])%2 ? str_replace(array('<', '>'), array('<', '>'), $t) : '')); |
|
445 | +if (!empty($m[1])) { |
|
446 | + return (!isset($eE[$e]) ? (empty($C['hook_tag']) ? "</$e>" : $C['hook_tag']($e)) : (($C['keep_bad']) % 2 ? str_replace(array('<', '>'), array('<', '>'), $t) : '')); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | // open tag & attr |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | static $aNP = array('action'=>1, 'cite'=>1, 'classid'=>1, 'codebase'=>1, 'data'=>1, 'href'=>1, 'itemtype'=>1, 'longdesc'=>1, 'model'=>1, 'pluginspage'=>1, 'pluginurl'=>1, 'src'=>1, 'srcset'=>1, 'usemap'=>1); // Need scheme check; excludes style, on* |
455 | 455 | static $aNU = array('accesskey'=>1, 'class'=>1, 'contenteditable'=>1, 'contextmenu'=>1, 'dir'=>1, 'draggable'=>1, 'dropzone'=>1, 'hidden'=>1, 'id'=>1, 'inert'=>1, 'itemid'=>1, 'itemprop'=>1, 'itemref'=>1, 'itemscope'=>1, 'itemtype'=>1, 'lang'=>1, 'role'=>1, 'spellcheck'=>1, 'style'=>1, 'tabindex'=>1, 'title'=>1, 'translate'=>1, 'xmlns'=>1, 'xml:base'=>1, 'xml:lang'=>1, 'xml:space'=>1); // Univ; excludes on*, aria* |
456 | 456 | |
457 | -if($C['lc_std_val']){ |
|
457 | +if ($C['lc_std_val']) { |
|
458 | 458 | // predef attr vals for $eAL & $aNE ele |
459 | 459 | static $aNL = array('all'=>1, 'auto'=>1, 'baseline'=>1, 'bottom'=>1, 'button'=>1, 'captions'=>1, 'center'=>1, 'chapters'=>1, 'char'=>1, 'checkbox'=>1, 'circle'=>1, 'col'=>1, 'colgroup'=>1, 'color'=>1, 'cols'=>1, 'data'=>1, 'date'=>1, 'datetime'=>1, 'datetime-local'=>1, 'default'=>1, 'descriptions'=>1, 'email'=>1, 'file'=>1, 'get'=>1, 'groups'=>1, 'hidden'=>1, 'image'=>1, 'justify'=>1, 'left'=>1, 'ltr'=>1, 'metadata'=>1, 'middle'=>1, 'month'=>1, 'none'=>1, 'number'=>1, 'object'=>1, 'password'=>1, 'poly'=>1, 'post'=>1, 'preserve'=>1, 'radio'=>1, 'range'=>1, 'rect'=>1, 'ref'=>1, 'reset'=>1, 'right'=>1, 'row'=>1, 'rowgroup'=>1, 'rows'=>1, 'rtl'=>1, 'search'=>1, 'submit'=>1, 'subtitles'=>1, 'tel'=>1, 'text'=>1, 'time'=>1, 'top'=>1, 'url'=>1, 'week'=>1); |
460 | 460 | static $eAL = array('a'=>1, 'area'=>1, 'bdo'=>1, 'button'=>1, 'col'=>1, 'fieldset'=>1, 'form'=>1, 'img'=>1, 'input'=>1, 'object'=>1, 'ol'=>1, 'optgroup'=>1, 'option'=>1, 'param'=>1, 'script'=>1, 'select'=>1, 'table'=>1, 'td'=>1, 'textarea'=>1, 'tfoot'=>1, 'th'=>1, 'thead'=>1, 'tr'=>1, 'track'=>1, 'xml:space'=>1); |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | } |
463 | 463 | |
464 | 464 | $depTr = 0; |
465 | -if($C['no_deprecated_attr']){ |
|
465 | +if ($C['no_deprecated_attr']) { |
|
466 | 466 | // depr attr:applicable ele |
467 | 467 | static $aND = array('align'=>array('caption'=>1, 'div'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'hr'=>1, 'img'=>1, 'input'=>1, 'legend'=>1, 'object'=>1, 'p'=>1, 'table'=>1), 'bgcolor'=>array('table'=>1, 'td'=>1, 'th'=>1, 'tr'=>1), 'border'=>array('object'=>1), 'bordercolor'=>array('table'=>1, 'td'=>1, 'tr'=>1), 'cellspacing'=>array('table'=>1), 'clear'=>array('br'=>1), 'compact'=>array('dl'=>1, 'ol'=>1, 'ul'=>1), 'height'=>array('td'=>1, 'th'=>1), 'hspace'=>array('img'=>1, 'object'=>1), 'language'=>array('script'=>1), 'name'=>array('a'=>1, 'form'=>1, 'iframe'=>1, 'img'=>1, 'map'=>1), 'noshade'=>array('hr'=>1), 'nowrap'=>array('td'=>1, 'th'=>1), 'size'=>array('hr'=>1), 'vspace'=>array('img'=>1, 'object'=>1), 'width'=>array('hr'=>1, 'pre'=>1, 'table'=>1, 'td'=>1, 'th'=>1)); |
468 | 468 | static $eAD = array('a'=>1, 'br'=>1, 'caption'=>1, 'div'=>1, 'dl'=>1, 'form'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'hr'=>1, 'iframe'=>1, 'img'=>1, 'input'=>1, 'legend'=>1, 'map'=>1, 'object'=>1, 'ol'=>1, 'p'=>1, 'pre'=>1, 'script'=>1, 'table'=>1, 'td'=>1, 'th'=>1, 'tr'=>1, 'ul'=>1); |
@@ -470,213 +470,213 @@ discard block |
||
470 | 470 | } |
471 | 471 | |
472 | 472 | // attr name-vals |
473 | -if(strpos($a, "\x01") !== false){$a = preg_replace('`\x01[^\x01]*\x01`', '', $a);} // No comment/CDATA sec |
|
473 | +if (strpos($a, "\x01") !== false) {$a = preg_replace('`\x01[^\x01]*\x01`', '', $a); } // No comment/CDATA sec |
|
474 | 474 | $mode = 0; $a = trim($a, ' /'); $aA = array(); |
475 | -while(strlen($a)){ |
|
475 | +while (strlen($a)) { |
|
476 | 476 | $w = 0; |
477 | - switch($mode){ |
|
477 | + switch ($mode) { |
|
478 | 478 | case 0: // Name |
479 | - if(preg_match('`^[a-zA-Z][^\s=/]+`', $a, $m)){ |
|
479 | + if (preg_match('`^[a-zA-Z][^\s=/]+`', $a, $m)) { |
|
480 | 480 | $nm = strtolower($m[0]); |
481 | 481 | $w = $mode = 1; $a = ltrim(substr_replace($a, '', 0, strlen($m[0]))); |
482 | 482 | } |
483 | 483 | break; case 1: |
484 | - if($a[0] == '='){ // = |
|
484 | + if ($a[0] == '=') { // = |
|
485 | 485 | $w = 1; $mode = 2; $a = ltrim($a, '= '); |
486 | - }else{ // No val |
|
486 | + } else { // No val |
|
487 | 487 | $w = 1; $mode = 0; $a = ltrim($a); |
488 | 488 | $aA[$nm] = ''; |
489 | 489 | } |
490 | 490 | break; case 2: // Val |
491 | - if(preg_match('`^((?:"[^"]*")|(?:\'[^\']*\')|(?:\s*[^\s"\']+))(.*)`', $a, $m)){ |
|
491 | + if (preg_match('`^((?:"[^"]*")|(?:\'[^\']*\')|(?:\s*[^\s"\']+))(.*)`', $a, $m)) { |
|
492 | 492 | $a = ltrim($m[2]); $m = $m[1]; $w = 1; $mode = 0; |
493 | 493 | $aA[$nm] = trim(str_replace('<', '<', ($m[0] == '"' or $m[0] == '\'') ? substr($m, 1, -1) : $m)); |
494 | 494 | } |
495 | 495 | break; |
496 | 496 | } |
497 | - if($w == 0){ // Parse errs, deal with space, " & ' |
|
497 | + if ($w == 0) { // Parse errs, deal with space, " & ' |
|
498 | 498 | $a = preg_replace('`^(?:"[^"]*("|$)|\'[^\']*(\'|$)|\S)*\s*`', '', $a); |
499 | 499 | $mode = 0; |
500 | 500 | } |
501 | 501 | } |
502 | -if($mode == 1){$aA[$nm] = '';} |
|
502 | +if ($mode == 1) {$aA[$nm] = ''; } |
|
503 | 503 | |
504 | 504 | // clean attrs |
505 | 505 | global $S; |
506 | 506 | $rl = isset($S[$e]) ? $S[$e] : array(); |
507 | 507 | $a = array(); $nfr = 0; $d = $C['deny_attribute']; |
508 | -foreach($aA as $k=>$v){ |
|
509 | - if(((isset($d['*']) ? isset($d[$k]) : !isset($d[$k])) && (isset($aN[$k][$e]) or isset($aNU[$k]) or (isset($aNO[$k]) && !isset($d['on*'])) or (isset($aNA[$k]) && !isset($d['aria*'])) or (!isset($d['data*']) && preg_match('`data-((?!xml)[^:]+$)`', $k))) && !isset($rl['n'][$k]) && !isset($rl['n']['*'])) or isset($rl[$k])){ |
|
510 | - if(isset($aNE[$k])){$v = $k;} |
|
511 | - elseif(!empty($lcase) && (($e != 'button' or $e != 'input') or $k == 'type')){ // Rather loose but ?not cause issues |
|
508 | +foreach ($aA as $k=>$v) { |
|
509 | + if (((isset($d['*']) ? isset($d[$k]) : !isset($d[$k])) && (isset($aN[$k][$e]) or isset($aNU[$k]) or (isset($aNO[$k]) && !isset($d['on*'])) or (isset($aNA[$k]) && !isset($d['aria*'])) or (!isset($d['data*']) && preg_match('`data-((?!xml)[^:]+$)`', $k))) && !isset($rl['n'][$k]) && !isset($rl['n']['*'])) or isset($rl[$k])) { |
|
510 | + if (isset($aNE[$k])) {$v = $k; } |
|
511 | + elseif (!empty($lcase) && (($e != 'button' or $e != 'input') or $k == 'type')) { // Rather loose but ?not cause issues |
|
512 | 512 | $v = (isset($aNL[($v2 = strtolower($v))])) ? $v2 : $v; |
513 | 513 | } |
514 | - if($k == 'style' && !$C['style_pass']){ |
|
515 | - if(false !== strpos($v, '&#')){ |
|
514 | + if ($k == 'style' && !$C['style_pass']) { |
|
515 | + if (false !== strpos($v, '&#')) { |
|
516 | 516 | static $sC = array(' '=>' ', ' '=>' ', 'E'=>'e', 'E'=>'e', 'e'=>'e', 'e'=>'e', 'X'=>'x', 'X'=>'x', 'x'=>'x', 'x'=>'x', 'P'=>'p', 'P'=>'p', 'p'=>'p', 'p'=>'p', 'S'=>'s', 'S'=>'s', 's'=>'s', 's'=>'s', 'I'=>'i', 'I'=>'i', 'i'=>'i', 'i'=>'i', 'O'=>'o', 'O'=>'o', 'o'=>'o', 'o'=>'o', 'N'=>'n', 'N'=>'n', 'n'=>'n', 'n'=>'n', 'U'=>'u', 'U'=>'u', 'u'=>'u', 'u'=>'u', 'R'=>'r', 'R'=>'r', 'r'=>'r', 'r'=>'r', 'L'=>'l', 'L'=>'l', 'l'=>'l', 'l'=>'l', '('=>'(', '('=>'(', ')'=>')', ')'=>')', ' '=>':', ' '=>':', '"'=>'"', '"'=>'"', '''=>"'", '''=>"'", '/'=>'/', '/'=>'/', '*'=>'*', '*'=>'*', '\'=>'\\', '\'=>'\\'); |
517 | 517 | $v = strtr($v, $sC); |
518 | 518 | } |
519 | 519 | $v = preg_replace_callback('`(url(?:\()(?: )*(?:\'|"|&(?:quot|apos);)?)(.+?)((?:\'|"|&(?:quot|apos);)?(?: )*(?:\)))`iS', 'htmLawed::hl_prot', $v); |
520 | 520 | $v = !$C['css_expression'] ? preg_replace('`expression`i', ' ', preg_replace('`\\\\\S|(/|(%2f))(\*|(%2a))`i', ' ', $v)) : $v; |
521 | - }elseif(isset($aNP[$k]) or isset($aNO[$k])){ |
|
521 | + }elseif (isset($aNP[$k]) or isset($aNO[$k])) { |
|
522 | 522 | $v = str_replace("", ' ', (strpos($v, '&') !== false ? str_replace(array('­', '­', '­'), ' ', $v) : $v)); # double-quoted char: soft-hyphen; appears here as "" or hyphen or something else depending on viewing software |
523 | - if($k == 'srcset'){ |
|
523 | + if ($k == 'srcset') { |
|
524 | 524 | $v2 = ''; |
525 | - foreach(explode(',', $v) as $k1=>$v1){ |
|
525 | + foreach (explode(',', $v) as $k1=>$v1) { |
|
526 | 526 | $v1 = explode(' ', ltrim($v1), 2); |
527 | 527 | $k1 = isset($v1[1]) ? trim($v1[1]) : ''; |
528 | 528 | $v1 = trim($v1[0]); |
529 | - if(isset($v1[0])){$v2 .= htmLawed::hl_prot($v1, $k). (empty($k1) ? '' : ' '. $k1). ', ';} |
|
529 | + if (isset($v1[0])) {$v2 .= htmLawed::hl_prot($v1, $k).(empty($k1) ? '' : ' '.$k1).', '; } |
|
530 | 530 | } |
531 | 531 | $v = trim($v2, ', '); |
532 | 532 | } |
533 | - if($k == 'itemtype'){ |
|
533 | + if ($k == 'itemtype') { |
|
534 | 534 | $v2 = ''; |
535 | - foreach(explode(' ', $v) as $v1){ |
|
536 | - if(isset($v1[0])){$v2 .= htmLawed::hl_prot($v1, $k). ' ';} |
|
535 | + foreach (explode(' ', $v) as $v1) { |
|
536 | + if (isset($v1[0])) {$v2 .= htmLawed::hl_prot($v1, $k).' '; } |
|
537 | 537 | } |
538 | 538 | $v = trim($v2, ' '); |
539 | 539 | } |
540 | - else{$v = htmLawed::hl_prot($v, $k);} |
|
541 | - if($k == 'href'){ // X-spam |
|
542 | - if($C['anti_mail_spam'] && strpos($v, 'mailto:') === 0){ |
|
540 | + else {$v = htmLawed::hl_prot($v, $k); } |
|
541 | + if ($k == 'href') { // X-spam |
|
542 | + if ($C['anti_mail_spam'] && strpos($v, 'mailto:') === 0) { |
|
543 | 543 | $v = str_replace('@', htmlspecialchars($C['anti_mail_spam']), $v); |
544 | - }elseif($C['anti_link_spam']){ |
|
544 | + }elseif ($C['anti_link_spam']) { |
|
545 | 545 | $r1 = $C['anti_link_spam'][1]; |
546 | - if(!empty($r1) && preg_match($r1, $v)){continue;} |
|
546 | + if (!empty($r1) && preg_match($r1, $v)) {continue; } |
|
547 | 547 | $r0 = $C['anti_link_spam'][0]; |
548 | - if(!empty($r0) && preg_match($r0, $v)){ |
|
549 | - if(isset($a['rel'])){ |
|
550 | - if(!preg_match('`\bnofollow\b`i', $a['rel'])){$a['rel'] .= ' nofollow';} |
|
551 | - }elseif(isset($aA['rel'])){ |
|
552 | - if(!preg_match('`\bnofollow\b`i', $aA['rel'])){$nfr = 1;} |
|
553 | - }else{$a['rel'] = 'nofollow';} |
|
548 | + if (!empty($r0) && preg_match($r0, $v)) { |
|
549 | + if (isset($a['rel'])) { |
|
550 | + if (!preg_match('`\bnofollow\b`i', $a['rel'])) {$a['rel'] .= ' nofollow'; } |
|
551 | + }elseif (isset($aA['rel'])) { |
|
552 | + if (!preg_match('`\bnofollow\b`i', $aA['rel'])) {$nfr = 1; } |
|
553 | + } else {$a['rel'] = 'nofollow'; } |
|
554 | 554 | } |
555 | 555 | } |
556 | 556 | } |
557 | 557 | } |
558 | - if(isset($rl[$k]) && is_array($rl[$k]) && ($v = htmLawed::hl_attrval($k, $v, $rl[$k])) === 0){continue;} |
|
558 | + if (isset($rl[$k]) && is_array($rl[$k]) && ($v = htmLawed::hl_attrval($k, $v, $rl[$k])) === 0) {continue; } |
|
559 | 559 | $a[$k] = str_replace('"', '"', $v); |
560 | 560 | } |
561 | 561 | } |
562 | -if($nfr){$a['rel'] = isset($a['rel']) ? $a['rel']. ' nofollow' : 'nofollow';} |
|
562 | +if ($nfr) {$a['rel'] = isset($a['rel']) ? $a['rel'].' nofollow' : 'nofollow'; } |
|
563 | 563 | |
564 | 564 | // rqd attr |
565 | 565 | static $eAR = array('area'=>array('alt'=>'area'), 'bdo'=>array('dir'=>'ltr'), 'command'=>array('label'=>''), 'form'=>array('action'=>''), 'img'=>array('src'=>'', 'alt'=>'image'), 'map'=>array('name'=>''), 'optgroup'=>array('label'=>''), 'param'=>array('name'=>''), 'style'=>array('scoped'=>''), 'textarea'=>array('rows'=>'10', 'cols'=>'50')); |
566 | -if(isset($eAR[$e])){ |
|
567 | - foreach($eAR[$e] as $k=>$v){ |
|
568 | - if(!isset($a[$k])){$a[$k] = isset($v[0]) ? $v : $k;} |
|
566 | +if (isset($eAR[$e])) { |
|
567 | + foreach ($eAR[$e] as $k=>$v) { |
|
568 | + if (!isset($a[$k])) {$a[$k] = isset($v[0]) ? $v : $k; } |
|
569 | 569 | } |
570 | 570 | } |
571 | 571 | |
572 | 572 | // depr attr |
573 | -if($depTr){ |
|
573 | +if ($depTr) { |
|
574 | 574 | $c = array(); |
575 | - foreach($a as $k=>$v){ |
|
576 | - if($k == 'style' or !isset($aND[$k][$e])){continue;} |
|
575 | + foreach ($a as $k=>$v) { |
|
576 | + if ($k == 'style' or !isset($aND[$k][$e])) {continue; } |
|
577 | 577 | $v = str_replace(array('\\', ':', ';', '&#'), '', $v); |
578 | - if($k == 'align'){ |
|
578 | + if ($k == 'align') { |
|
579 | 579 | unset($a['align']); |
580 | - if($e == 'img' && ($v == 'left' or $v == 'right')){$c[] = 'float: '. $v;} |
|
581 | - elseif(($e == 'div' or $e == 'table') && $v == 'center'){$c[] = 'margin: auto';} |
|
582 | - else{$c[] = 'text-align: '. $v;} |
|
583 | - }elseif($k == 'bgcolor'){ |
|
580 | + if ($e == 'img' && ($v == 'left' or $v == 'right')) {$c[] = 'float: '.$v; } |
|
581 | + elseif (($e == 'div' or $e == 'table') && $v == 'center') {$c[] = 'margin: auto'; } |
|
582 | + else {$c[] = 'text-align: '.$v; } |
|
583 | + }elseif ($k == 'bgcolor') { |
|
584 | 584 | unset($a['bgcolor']); |
585 | - $c[] = 'background-color: '. $v; |
|
586 | - }elseif($k == 'border'){ |
|
585 | + $c[] = 'background-color: '.$v; |
|
586 | + }elseif ($k == 'border') { |
|
587 | 587 | unset($a['border']); $c[] = "border: {$v}px"; |
588 | - }elseif($k == 'bordercolor'){ |
|
589 | - unset($a['bordercolor']); $c[] = 'border-color: '. $v; |
|
590 | - }elseif($k == 'cellspacing'){ |
|
588 | + }elseif ($k == 'bordercolor') { |
|
589 | + unset($a['bordercolor']); $c[] = 'border-color: '.$v; |
|
590 | + }elseif ($k == 'cellspacing') { |
|
591 | 591 | unset($a['cellspacing']); $c[] = "border-spacing: {$v}px"; |
592 | - }elseif($k == 'clear'){ |
|
593 | - unset($a['clear']); $c[] = 'clear: '. ($v != 'all' ? $v : 'both'); |
|
594 | - }elseif($k == 'compact'){ |
|
592 | + }elseif ($k == 'clear') { |
|
593 | + unset($a['clear']); $c[] = 'clear: '.($v != 'all' ? $v : 'both'); |
|
594 | + }elseif ($k == 'compact') { |
|
595 | 595 | unset($a['compact']); $c[] = 'font-size: 85%'; |
596 | - }elseif($k == 'height' or $k == 'width'){ |
|
597 | - unset($a[$k]); $c[] = $k. ': '. ($v[0] != '*' ? $v. (ctype_digit($v) ? 'px' : '') : 'auto'); |
|
598 | - }elseif($k == 'hspace'){ |
|
596 | + }elseif ($k == 'height' or $k == 'width') { |
|
597 | + unset($a[$k]); $c[] = $k.': '.($v[0] != '*' ? $v.(ctype_digit($v) ? 'px' : '') : 'auto'); |
|
598 | + }elseif ($k == 'hspace') { |
|
599 | 599 | unset($a['hspace']); $c[] = "margin-left: {$v}px; margin-right: {$v}px"; |
600 | - }elseif($k == 'language' && !isset($a['type'])){ |
|
600 | + }elseif ($k == 'language' && !isset($a['type'])) { |
|
601 | 601 | unset($a['language']); |
602 | - $a['type'] = 'text/'. strtolower($v); |
|
603 | - }elseif($k == 'name'){ |
|
604 | - if($C['no_deprecated_attr'] == 2 or ($e != 'a' && $e != 'map')){unset($a['name']);} |
|
605 | - if(!isset($a['id']) && !preg_match('`\W`', $v)){$a['id'] = $v;} |
|
606 | - }elseif($k == 'noshade'){ |
|
602 | + $a['type'] = 'text/'.strtolower($v); |
|
603 | + }elseif ($k == 'name') { |
|
604 | + if ($C['no_deprecated_attr'] == 2 or ($e != 'a' && $e != 'map')) {unset($a['name']); } |
|
605 | + if (!isset($a['id']) && !preg_match('`\W`', $v)) {$a['id'] = $v; } |
|
606 | + }elseif ($k == 'noshade') { |
|
607 | 607 | unset($a['noshade']); $c[] = 'border-style: none; border: 0; background-color: gray; color: gray'; |
608 | - }elseif($k == 'nowrap'){ |
|
608 | + }elseif ($k == 'nowrap') { |
|
609 | 609 | unset($a['nowrap']); $c[] = 'white-space: nowrap'; |
610 | - }elseif($k == 'size'){ |
|
611 | - unset($a['size']); $c[] = 'size: '. $v. 'px'; |
|
612 | - }elseif($k == 'vspace'){ |
|
610 | + }elseif ($k == 'size') { |
|
611 | + unset($a['size']); $c[] = 'size: '.$v.'px'; |
|
612 | + }elseif ($k == 'vspace') { |
|
613 | 613 | unset($a['vspace']); $c[] = "margin-top: {$v}px; margin-bottom: {$v}px"; |
614 | 614 | } |
615 | 615 | } |
616 | - if(count($c)){ |
|
616 | + if (count($c)) { |
|
617 | 617 | $c = implode('; ', $c); |
618 | - $a['style'] = isset($a['style']) ? rtrim($a['style'], ' ;'). '; '. $c. ';': $c. ';'; |
|
618 | + $a['style'] = isset($a['style']) ? rtrim($a['style'], ' ;').'; '.$c.';' : $c.';'; |
|
619 | 619 | } |
620 | 620 | } |
621 | 621 | // unique ID |
622 | -if($C['unique_ids'] && isset($a['id'])){ |
|
623 | - if(preg_match('`\s`', ($id = $a['id'])) or (isset($GLOBALS['hl_Ids'][$id]) && $C['unique_ids'] == 1)){unset($a['id']); |
|
624 | - }else{ |
|
625 | - while(isset($GLOBALS['hl_Ids'][$id])){$id = $C['unique_ids']. $id;} |
|
622 | +if ($C['unique_ids'] && isset($a['id'])) { |
|
623 | + if (preg_match('`\s`', ($id = $a['id'])) or (isset($GLOBALS['hl_Ids'][$id]) && $C['unique_ids'] == 1)) {unset($a['id']); |
|
624 | + } else { |
|
625 | + while (isset($GLOBALS['hl_Ids'][$id])) {$id = $C['unique_ids'].$id; } |
|
626 | 626 | $GLOBALS['hl_Ids'][($a['id'] = $id)] = 1; |
627 | 627 | } |
628 | 628 | } |
629 | 629 | // xml:lang |
630 | -if($C['xml:lang'] && isset($a['lang'])){ |
|
630 | +if ($C['xml:lang'] && isset($a['lang'])) { |
|
631 | 631 | $a['xml:lang'] = isset($a['xml:lang']) ? $a['xml:lang'] : $a['lang']; |
632 | - if($C['xml:lang'] == 2){unset($a['lang']);} |
|
632 | + if ($C['xml:lang'] == 2) {unset($a['lang']); } |
|
633 | 633 | } |
634 | 634 | // for transformed tag |
635 | -if(!empty($trt)){ |
|
636 | - $a['style'] = isset($a['style']) ? rtrim($a['style'], ' ;'). '; '. $trt : $trt; |
|
635 | +if (!empty($trt)) { |
|
636 | + $a['style'] = isset($a['style']) ? rtrim($a['style'], ' ;').'; '.$trt : $trt; |
|
637 | 637 | } |
638 | 638 | // return with empty ele / |
639 | -if(empty($C['hook_tag'])){ |
|
639 | +if (empty($C['hook_tag'])) { |
|
640 | 640 | $aA = ''; |
641 | - foreach($a as $k=>$v){$aA .= " {$k}=\"{$v}\"";} |
|
642 | - return "<{$e}{$aA}". (isset($eE[$e]) ? ' /' : ''). '>'; |
|
641 | + foreach ($a as $k=>$v) {$aA .= " {$k}=\"{$v}\""; } |
|
642 | + return "<{$e}{$aA}".(isset($eE[$e]) ? ' /' : '').'>'; |
|
643 | 643 | } |
644 | -else{return $C['hook_tag']($e, $a);} |
|
644 | +else {return $C['hook_tag']($e, $a); } |
|
645 | 645 | } |
646 | 646 | |
647 | -public static function hl_tag2(&$e, &$a, $t=1){ |
|
647 | +public static function hl_tag2(&$e, &$a, $t = 1) { |
|
648 | 648 | // transform tag |
649 | -if($e == 'big'){$e = 'span'; return 'font-size: larger;';} |
|
650 | -if($e == 's' or $e == 'strike'){$e = 'span'; return 'text-decoration: line-through;';} |
|
651 | -if($e == 'tt'){$e = 'code'; return '';} |
|
652 | -if($e == 'center'){$e = 'div'; return 'text-align: center;';} |
|
649 | +if ($e == 'big') {$e = 'span'; return 'font-size: larger;'; } |
|
650 | +if ($e == 's' or $e == 'strike') {$e = 'span'; return 'text-decoration: line-through;'; } |
|
651 | +if ($e == 'tt') {$e = 'code'; return ''; } |
|
652 | +if ($e == 'center') {$e = 'div'; return 'text-align: center;'; } |
|
653 | 653 | static $fs = array('0'=>'xx-small', '1'=>'xx-small', '2'=>'small', '3'=>'medium', '4'=>'large', '5'=>'x-large', '6'=>'xx-large', '7'=>'300%', '-1'=>'smaller', '-2'=>'60%', '+1'=>'larger', '+2'=>'150%', '+3'=>'200%', '+4'=>'300%'); |
654 | -if($e == 'font'){ |
|
654 | +if ($e == 'font') { |
|
655 | 655 | $a2 = ''; |
656 | - while(preg_match('`(^|\s)(color|size)\s*=\s*(\'|")?(.+?)(\\3|\s|$)`i', $a, $m)){ |
|
656 | + while (preg_match('`(^|\s)(color|size)\s*=\s*(\'|")?(.+?)(\\3|\s|$)`i', $a, $m)) { |
|
657 | 657 | $a = str_replace($m[0], ' ', $a); |
658 | - $a2 .= strtolower($m[2]) == 'color' ? (' color: '. str_replace('"', '\'', trim($m[4])). ';') : (isset($fs[($m = trim($m[4]))]) ? ($a2 .= ' font-size: '. str_replace('"', '\'', $fs[$m]). ';') : ''); |
|
658 | + $a2 .= strtolower($m[2]) == 'color' ? (' color: '.str_replace('"', '\'', trim($m[4])).';') : (isset($fs[($m = trim($m[4]))]) ? ($a2 .= ' font-size: '.str_replace('"', '\'', $fs[$m]).';') : ''); |
|
659 | 659 | } |
660 | - while(preg_match('`(^|\s)face\s*=\s*(\'|")?([^=]+?)\\2`i', $a, $m) or preg_match('`(^|\s)face\s*=(\s*)(\S+)`i', $a, $m)){ |
|
660 | + while (preg_match('`(^|\s)face\s*=\s*(\'|")?([^=]+?)\\2`i', $a, $m) or preg_match('`(^|\s)face\s*=(\s*)(\S+)`i', $a, $m)) { |
|
661 | 661 | $a = str_replace($m[0], ' ', $a); |
662 | - $a2 .= ' font-family: '. str_replace('"', '\'', trim($m[3])). ';'; |
|
662 | + $a2 .= ' font-family: '.str_replace('"', '\'', trim($m[3])).';'; |
|
663 | 663 | } |
664 | 664 | $e = 'span'; return ltrim(str_replace('<', '', $a2)); |
665 | 665 | } |
666 | -if($e == 'acronym'){$e = 'abbr'; return '';} |
|
667 | -if($e == 'dir'){$e = 'ul'; return '';} |
|
668 | -if($t == 2){$e = 0; return 0;} |
|
666 | +if ($e == 'acronym') {$e = 'abbr'; return ''; } |
|
667 | +if ($e == 'dir') {$e = 'ul'; return ''; } |
|
668 | +if ($t == 2) {$e = 0; return 0; } |
|
669 | 669 | return ''; |
670 | 670 | } |
671 | 671 | |
672 | -public static function hl_tidy($t, $w, $p){ |
|
672 | +public static function hl_tidy($t, $w, $p) { |
|
673 | 673 | // tidy/compact HTM |
674 | -if(strpos(' pre,script,textarea', "$p,")){return $t;} |
|
675 | -if(!function_exists('hl_aux2')){function hl_aux2($m){ |
|
676 | - return $m[1]. str_replace(array("<", ">", "\n", "\r", "\t", ' '), array("\x01", "\x02", "\x03", "\x04", "\x05", "\x07"), $m[3]). $m[4]; |
|
674 | +if (strpos(' pre,script,textarea', "$p,")) {return $t; } |
|
675 | +if (!function_exists('hl_aux2')) {function hl_aux2($m) { |
|
676 | + return $m[1].str_replace(array("<", ">", "\n", "\r", "\t", ' '), array("\x01", "\x02", "\x03", "\x04", "\x05", "\x07"), $m[3]).$m[4]; |
|
677 | 677 | }} |
678 | 678 | $t = preg_replace(array('`(<\w[^>]*(?<!/)>)\s+`', '`\s+`', '`(<\w[^>]*(?<!/)>) `'), array(' $1', ' ', '$1'), preg_replace_callback(array('`(<(!\[CDATA\[))(.+?)(\]\]>)`sm', '`(<(!--))(.+?)(-->)`sm', '`(<(pre|script|textarea)[^>]*?>)(.+?)(</\2>)`sm'), 'hl_aux2', $t)); |
679 | -if(($w = strtolower($w)) == -1){ |
|
679 | +if (($w = strtolower($w)) == -1) { |
|
680 | 680 | return str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05", "\x07"), array('<', '>', "\n", "\r", "\t", ' '), $t); |
681 | 681 | } |
682 | 682 | $s = strpos(" $w", 't') ? "\t" : ' '; |
@@ -688,45 +688,45 @@ discard block |
||
688 | 688 | $d = array('address'=>1, 'article'=>1, 'aside'=>1, 'blockquote'=>1, 'center'=>1, 'colgroup'=>1, 'datalist'=>1, 'details'=>1, 'dir'=>1, 'div'=>1, 'dl'=>1, 'fieldset'=>1, 'figure'=>1, 'footer'=>1, 'form'=>1, 'header'=>1, 'hgroup'=>1, 'hr'=>1, 'iframe'=>1, 'main'=>1, 'map'=>1, 'menu'=>1, 'nav'=>1, 'noscript'=>1, 'ol'=>1, 'optgroup'=>1, 'rbc'=>1, 'rtc'=>1, 'ruby'=>1, 'script'=>1, 'section'=>1, 'select'=>1, 'table'=>1, 'tbody'=>1, 'tfoot'=>1, 'thead'=>1, 'tr'=>1, 'ul'=>1); |
689 | 689 | $T = explode('<', $t); |
690 | 690 | $X = 1; |
691 | -while($X){ |
|
691 | +while ($X) { |
|
692 | 692 | $n = $N; |
693 | 693 | $t = $T; |
694 | 694 | ob_start(); |
695 | - if(isset($d[$p])){echo str_repeat($s, ++$n);} |
|
695 | + if (isset($d[$p])) {echo str_repeat($s, ++$n); } |
|
696 | 696 | echo ltrim(array_shift($t)); |
697 | - for($i=-1, $j=count($t); ++$i<$j;){ |
|
697 | + for ($i = -1, $j = count($t); ++$i < $j;) { |
|
698 | 698 | $r = ''; list($e, $r) = explode('>', $t[$i]); |
699 | 699 | $x = $e[0] == '/' ? 0 : (substr($e, -1) == '/' ? 1 : ($e[0] != '!' ? 2 : -1)); |
700 | 700 | $y = !$x ? ltrim($e, '/') : ($x > 0 ? substr($e, 0, strcspn($e, ' ')) : 0); |
701 | 701 | $e = "<$e>"; |
702 | - if(isset($d[$y])){ |
|
703 | - if(!$x){ |
|
704 | - if($n){echo "\n", str_repeat($s, --$n), "$e\n", str_repeat($s, $n);} |
|
705 | - else{++$N; ob_end_clean(); continue 2;} |
|
702 | + if (isset($d[$y])) { |
|
703 | + if (!$x) { |
|
704 | + if ($n) {echo "\n", str_repeat($s, --$n), "$e\n", str_repeat($s, $n); } |
|
705 | + else {++$N; ob_end_clean(); continue 2; } |
|
706 | 706 | } |
707 | - else{echo "\n", str_repeat($s, $n), "$e\n", str_repeat($s, ($x != 1 ? ++$n : $n));} |
|
707 | + else {echo "\n", str_repeat($s, $n), "$e\n", str_repeat($s, ($x != 1 ? ++$n : $n)); } |
|
708 | 708 | echo $r; continue; |
709 | 709 | } |
710 | - $f = "\n". str_repeat($s, $n); |
|
711 | - if(isset($c[$y])){ |
|
712 | - if(!$x){echo $e, $f, $r;} |
|
713 | - else{echo $f, $e, $r;} |
|
714 | - }elseif(isset($b[$y])){echo $f, $e, $r; |
|
715 | - }elseif(isset($a[$y])){echo $e, $f, $r; |
|
716 | - }elseif(!$y){echo $f, $e, $f, $r; |
|
717 | - }else{echo $e, $r;} |
|
710 | + $f = "\n".str_repeat($s, $n); |
|
711 | + if (isset($c[$y])) { |
|
712 | + if (!$x) {echo $e, $f, $r; } |
|
713 | + else {echo $f, $e, $r; } |
|
714 | + }elseif (isset($b[$y])) {echo $f, $e, $r; |
|
715 | + }elseif (isset($a[$y])) {echo $e, $f, $r; |
|
716 | + }elseif (!$y) {echo $f, $e, $f, $r; |
|
717 | + } else {echo $e, $r; } |
|
718 | 718 | } |
719 | 719 | $X = 0; |
720 | 720 | } |
721 | 721 | $t = str_replace(array("\n ", " \n"), "\n", preg_replace('`[\n]\s*?[\n]+`', "\n", ob_get_contents())); |
722 | 722 | ob_end_clean(); |
723 | -if(($l = strpos(" $w", 'r') ? (strpos(" $w", 'n') ? "\r\n" : "\r") : 0)){ |
|
723 | +if (($l = strpos(" $w", 'r') ? (strpos(" $w", 'n') ? "\r\n" : "\r") : 0)) { |
|
724 | 724 | $t = str_replace("\n", $l, $t); |
725 | 725 | } |
726 | 726 | return str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05", "\x07"), array('<', '>', "\n", "\r", "\t", ' '), $t); |
727 | 727 | } |
728 | 728 | |
729 | -public static function hl_version(){ |
|
729 | +public static function hl_version() { |
|
730 | 730 | // version |
731 | 731 | return '1.2.4.1'; |
732 | 732 | } |
@@ -26,9 +26,7 @@ discard block |
||
26 | 26 | unset($e['applet'], $e['audio'], $e['canvas'], $e['embed'], $e['iframe'], $e['object'], $e['script'], $e['video']); |
27 | 27 | } |
28 | 28 | $x = !empty($C['elements']) ? str_replace(array("\n", "\r", "\t", ' '), '', $C['elements']) : '*'; |
29 | -if($x == '-*'){$e = array();} |
|
30 | -elseif(strpos($x, '*') === false){$e = array_flip(explode(',', $x));} |
|
31 | -else{ |
|
29 | +if($x == '-*'){$e = array();} elseif(strpos($x, '*') === false){$e = array_flip(explode(',', $x));} else{ |
|
32 | 30 | if(isset($x[1])){ |
33 | 31 | preg_match_all('`(?:^|-|\+)[^\-+]+?(?=-|\+|$)`', $x, $m, PREG_SET_ORDER); |
34 | 32 | for($i=count($m); --$i>=0;){$m[$i] = $m[$i][0];} |
@@ -176,10 +174,7 @@ discard block |
||
176 | 174 | if(isset($cE[$in])){ |
177 | 175 | return (!$do ? '' : str_replace(array('<', '>'), array('<', '>'), $t)); |
178 | 176 | } |
179 | -if(isset($cS[$in])){$inOk = $cS[$in];} |
|
180 | -elseif(isset($cI[$in])){$inOk = $eI; $cI['del'] = 1; $cI['ins'] = 1;} |
|
181 | -elseif(isset($cF[$in])){$inOk = $eF; unset($cI['del'], $cI['ins']);} |
|
182 | -elseif(isset($cB[$in])){$inOk = $eB; unset($cI['del'], $cI['ins']);} |
|
177 | +if(isset($cS[$in])){$inOk = $cS[$in];} elseif(isset($cI[$in])){$inOk = $eI; $cI['del'] = 1; $cI['ins'] = 1;} elseif(isset($cF[$in])){$inOk = $eF; unset($cI['del'], $cI['ins']);} elseif(isset($cB[$in])){$inOk = $eB; unset($cI['del'], $cI['ins']);} |
|
183 | 178 | if(isset($cO[$in])){$inOk = $inOk + $cO[$in];} |
184 | 179 | if(isset($cN[$in])){$inOk = array_diff_assoc($inOk, $cN[$in]);} |
185 | 180 | |
@@ -192,13 +187,10 @@ discard block |
||
192 | 187 | if($ql = count($q)){ |
193 | 188 | $p = array_pop($q); |
194 | 189 | $q[] = $p; |
195 | - if(isset($cS[$p])){$ok = $cS[$p];} |
|
196 | - elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} |
|
197 | - elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} |
|
198 | - elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} |
|
190 | + if(isset($cS[$p])){$ok = $cS[$p];} elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} |
|
199 | 191 | if(isset($cO[$p])){$ok = $ok + $cO[$p];} |
200 | 192 | if(isset($cN[$p])){$ok = array_diff_assoc($ok, $cN[$p]);} |
201 | - }else{$ok = $inOk; unset($cI['del'], $cI['ins']);} |
|
193 | + } else{$ok = $inOk; unset($cI['del'], $cI['ins']);} |
|
202 | 194 | // bad tags, & ele content |
203 | 195 | if(isset($e) && ($do == 1 or (isset($ok['#pcdata']) && ($do == 3 or $do == 5)))){ |
204 | 196 | echo '<', $s, $e, $a, '>'; |
@@ -206,13 +198,11 @@ discard block |
||
206 | 198 | if(isset($x[0])){ |
207 | 199 | if(strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))){ |
208 | 200 | echo '<div>', $x, '</div>'; |
209 | - } |
|
210 | - elseif($do < 3 or isset($ok['#pcdata'])){echo $x;} |
|
211 | - elseif(strpos($x, "\x02\x04")){ |
|
201 | + } elseif($do < 3 or isset($ok['#pcdata'])){echo $x;} elseif(strpos($x, "\x02\x04")){ |
|
212 | 202 | foreach(preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $v){ |
213 | 203 | echo (substr($v, 0, 2) == "\x01\x02" ? $v : ($do > 4 ? preg_replace('`\S`', '', $v) : '')); |
214 | 204 | } |
215 | - }elseif($do > 4){echo preg_replace('`\S`', '', $x);} |
|
205 | + } elseif($do > 4){echo preg_replace('`\S`', '', $x);} |
|
216 | 206 | } |
217 | 207 | // get markup |
218 | 208 | if(!preg_match('`^(/?)([a-z1-6]+)([^>]*)>(.*)`sm', $t[$i], $r)){$x = $t[$i]; continue;} |
@@ -223,8 +213,7 @@ discard block |
||
223 | 213 | if($p == $e){array_pop($q); echo '</', $e, '>'; unset($e); continue;} // Last open |
224 | 214 | $add = ''; // Nesting - close open tags that need to be |
225 | 215 | for($j=-1, $cj=count($q); ++$j<$cj;){ |
226 | - if(($d = array_pop($q)) == $e){break;} |
|
227 | - else{$add .= "</{$d}>";} |
|
216 | + if(($d = array_pop($q)) == $e){break;} else{$add .= "</{$d}>";} |
|
228 | 217 | } |
229 | 218 | echo $add, '</', $e, '>'; unset($e); continue; |
230 | 219 | } |
@@ -266,8 +255,7 @@ discard block |
||
266 | 255 | $add = "</{$d}>"; |
267 | 256 | for(;++$k<$kc;){$add = "</{$q[$k]}>{$add}";} |
268 | 257 | break; |
269 | - } |
|
270 | - else{$q2[] = $d;} |
|
258 | + } else{$q2[] = $d;} |
|
271 | 259 | } |
272 | 260 | $q = $q2; |
273 | 261 | if(!isset($cE[$e])){$q[] = $e;} |
@@ -278,26 +266,21 @@ discard block |
||
278 | 266 | if($ql = count($q)){ |
279 | 267 | $p = array_pop($q); |
280 | 268 | $q[] = $p; |
281 | - if(isset($cS[$p])){$ok = $cS[$p];} |
|
282 | - elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} |
|
283 | - elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} |
|
284 | - elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} |
|
269 | + if(isset($cS[$p])){$ok = $cS[$p];} elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} |
|
285 | 270 | if(isset($cO[$p])){$ok = $ok + $cO[$p];} |
286 | 271 | if(isset($cN[$p])){$ok = array_diff_assoc($ok, $cN[$p]);} |
287 | -}else{$ok = $inOk; unset($cI['del'], $cI['ins']);} |
|
272 | +} else{$ok = $inOk; unset($cI['del'], $cI['ins']);} |
|
288 | 273 | if(isset($e) && ($do == 1 or (isset($ok['#pcdata']) && ($do == 3 or $do == 5)))){ |
289 | 274 | echo '<', $s, $e, $a, '>'; |
290 | 275 | } |
291 | 276 | if(isset($x[0])){ |
292 | 277 | if(strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))){ |
293 | 278 | echo '<div>', $x, '</div>'; |
294 | - } |
|
295 | - elseif($do < 3 or isset($ok['#pcdata'])){echo $x;} |
|
296 | - elseif(strpos($x, "\x02\x04")){ |
|
279 | + } elseif($do < 3 or isset($ok['#pcdata'])){echo $x;} elseif(strpos($x, "\x02\x04")){ |
|
297 | 280 | foreach(preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $v){ |
298 | 281 | echo (substr($v, 0, 2) == "\x01\x02" ? $v : ($do > 4 ? preg_replace('`\S`', '', $v) : '')); |
299 | 282 | } |
300 | - }elseif($do > 4){echo preg_replace('`\S`', '', $x);} |
|
283 | + } elseif($do > 4){echo preg_replace('`\S`', '', $x);} |
|
301 | 284 | } |
302 | 285 | while(!empty($q) && ($e = array_pop($q))){echo '</', $e, '>';} |
303 | 286 | $o = ob_get_contents(); |
@@ -313,8 +296,7 @@ discard block |
||
313 | 296 | if($v == 1){return '';} |
314 | 297 | if($n == 'comment' && $v < 4){ |
315 | 298 | if(substr(($t = preg_replace('`--+`', '-', substr($t, 4, -3))), -1) != ' '){$t .= ' ';} |
316 | -} |
|
317 | -else{$t = substr($t, 1, -1);} |
|
299 | +} else{$t = substr($t, 1, -1);} |
|
318 | 300 | $t = $v == 2 ? str_replace(array('&', '<', '>'), array('&', '<', '>'), $t) : $t; |
319 | 301 | return str_replace(array('&', '<', '>'), array("\x03", "\x04", "\x05"), ($n == 'comment' ? "\x01\x02\x04!--$t--\x05\x02\x01" : "\x01\x01\x04$t\x05\x01\x01")); |
320 | 302 | } |
@@ -349,11 +331,8 @@ discard block |
||
349 | 331 | if($C['abs_url']){ |
350 | 332 | if($C['abs_url'] == -1 && strpos($p, $C['base_url']) === 0){ // Make url rel |
351 | 333 | $p = substr($p, strlen($C['base_url'])); |
352 | - }elseif(empty($m[1])){ // Make URL abs |
|
353 | - if(substr($p, 0, 2) == '//'){$p = substr($C['base_url'], 0, strpos($C['base_url'], ':')+1). $p;} |
|
354 | - elseif($p[0] == '/'){$p = preg_replace('`(^.+?://[^/]+)(.*)`', '$1', $C['base_url']). $p;} |
|
355 | - elseif(strcspn($p, './')){$p = $C['base_url']. $p;} |
|
356 | - else{ |
|
334 | + } elseif(empty($m[1])){ // Make URL abs |
|
335 | + if(substr($p, 0, 2) == '//'){$p = substr($C['base_url'], 0, strpos($C['base_url'], ':')+1). $p;} elseif($p[0] == '/'){$p = preg_replace('`(^.+?://[^/]+)(.*)`', '$1', $C['base_url']). $p;} elseif(strcspn($p, './')){$p = $C['base_url']. $p;} else{ |
|
357 | 336 | preg_match('`^([a-zA-Z\d\-+.]+://[^/]+)(.*)`', $C['base_url'], $m); |
358 | 337 | $p = preg_replace('`(?<=/)\./`', '', $m[2]. $p); |
359 | 338 | while(preg_match('`(?<=/)([^/]{3,}|[^/.]+?|\.[^/.]|[^/.]\.)/\.\./`', $p)){ |
@@ -369,19 +348,15 @@ discard block |
||
369 | 348 | public static function hl_regex($p){ |
370 | 349 | // check regex |
371 | 350 | if(empty($p)){return 0;} |
372 | -if($v = function_exists('error_clear_last') && function_exists('error_get_last')){error_clear_last();} |
|
373 | -else{ |
|
374 | - if($t = ini_get('track_errors')){$o = isset($php_errormsg) ? $php_errormsg : null;} |
|
375 | - else{ini_set('track_errors', 1);} |
|
351 | +if($v = function_exists('error_clear_last') && function_exists('error_get_last')){error_clear_last();} else{ |
|
352 | + if($t = ini_get('track_errors')){$o = isset($php_errormsg) ? $php_errormsg : null;} else{ini_set('track_errors', 1);} |
|
376 | 353 | unset($php_errormsg); |
377 | 354 | } |
378 | 355 | if(($d = ini_get('display_errors'))){ini_set('display_errors', 0);} |
379 | 356 | preg_match($p, ''); |
380 | -if($v){$r = error_get_last() == null ? 1 : 0; } |
|
381 | -else{ |
|
357 | +if($v){$r = error_get_last() == null ? 1 : 0; } else{ |
|
382 | 358 | $r = isset($php_errormsg) ? 0 : 1; |
383 | - if($t){$php_errormsg = isset($o) ? $o : null;} |
|
384 | - else{ini_set('track_errors', 0);} |
|
359 | + if($t){$php_errormsg = isset($o) ? $o : null;} else{ini_set('track_errors', 0);} |
|
385 | 360 | } |
386 | 361 | if($d){ini_set('display_errors', 1);} |
387 | 362 | return $r; |
@@ -429,7 +404,7 @@ discard block |
||
429 | 404 | if($t == '>'){return '>';} |
430 | 405 | if(!preg_match('`^<(/?)([a-zA-Z][a-zA-Z1-6]*)([^>]*?)\s?>$`m', $t, $m)){ |
431 | 406 | return str_replace(array('<', '>'), array('<', '>'), $t); |
432 | -}elseif(!isset($C['elements'][($e = strtolower($m[2]))])){ |
|
407 | +} elseif(!isset($C['elements'][($e = strtolower($m[2]))])){ |
|
433 | 408 | return (($C['keep_bad']%2) ? str_replace(array('<', '>'), array('<', '>'), $t) : ''); |
434 | 409 | } |
435 | 410 | // attr string |
@@ -483,7 +458,7 @@ discard block |
||
483 | 458 | break; case 1: |
484 | 459 | if($a[0] == '='){ // = |
485 | 460 | $w = 1; $mode = 2; $a = ltrim($a, '= '); |
486 | - }else{ // No val |
|
461 | + } else{ // No val |
|
487 | 462 | $w = 1; $mode = 0; $a = ltrim($a); |
488 | 463 | $aA[$nm] = ''; |
489 | 464 | } |
@@ -507,8 +482,7 @@ discard block |
||
507 | 482 | $a = array(); $nfr = 0; $d = $C['deny_attribute']; |
508 | 483 | foreach($aA as $k=>$v){ |
509 | 484 | if(((isset($d['*']) ? isset($d[$k]) : !isset($d[$k])) && (isset($aN[$k][$e]) or isset($aNU[$k]) or (isset($aNO[$k]) && !isset($d['on*'])) or (isset($aNA[$k]) && !isset($d['aria*'])) or (!isset($d['data*']) && preg_match('`data-((?!xml)[^:]+$)`', $k))) && !isset($rl['n'][$k]) && !isset($rl['n']['*'])) or isset($rl[$k])){ |
510 | - if(isset($aNE[$k])){$v = $k;} |
|
511 | - elseif(!empty($lcase) && (($e != 'button' or $e != 'input') or $k == 'type')){ // Rather loose but ?not cause issues |
|
485 | + if(isset($aNE[$k])){$v = $k;} elseif(!empty($lcase) && (($e != 'button' or $e != 'input') or $k == 'type')){ // Rather loose but ?not cause issues |
|
512 | 486 | $v = (isset($aNL[($v2 = strtolower($v))])) ? $v2 : $v; |
513 | 487 | } |
514 | 488 | if($k == 'style' && !$C['style_pass']){ |
@@ -518,7 +492,7 @@ discard block |
||
518 | 492 | } |
519 | 493 | $v = preg_replace_callback('`(url(?:\()(?: )*(?:\'|"|&(?:quot|apos);)?)(.+?)((?:\'|"|&(?:quot|apos);)?(?: )*(?:\)))`iS', 'htmLawed::hl_prot', $v); |
520 | 494 | $v = !$C['css_expression'] ? preg_replace('`expression`i', ' ', preg_replace('`\\\\\S|(/|(%2f))(\*|(%2a))`i', ' ', $v)) : $v; |
521 | - }elseif(isset($aNP[$k]) or isset($aNO[$k])){ |
|
495 | + } elseif(isset($aNP[$k]) or isset($aNO[$k])){ |
|
522 | 496 | $v = str_replace("", ' ', (strpos($v, '&') !== false ? str_replace(array('­', '­', '­'), ' ', $v) : $v)); # double-quoted char: soft-hyphen; appears here as "" or hyphen or something else depending on viewing software |
523 | 497 | if($k == 'srcset'){ |
524 | 498 | $v2 = ''; |
@@ -536,21 +510,20 @@ discard block |
||
536 | 510 | if(isset($v1[0])){$v2 .= htmLawed::hl_prot($v1, $k). ' ';} |
537 | 511 | } |
538 | 512 | $v = trim($v2, ' '); |
539 | - } |
|
540 | - else{$v = htmLawed::hl_prot($v, $k);} |
|
513 | + } else{$v = htmLawed::hl_prot($v, $k);} |
|
541 | 514 | if($k == 'href'){ // X-spam |
542 | 515 | if($C['anti_mail_spam'] && strpos($v, 'mailto:') === 0){ |
543 | 516 | $v = str_replace('@', htmlspecialchars($C['anti_mail_spam']), $v); |
544 | - }elseif($C['anti_link_spam']){ |
|
517 | + } elseif($C['anti_link_spam']){ |
|
545 | 518 | $r1 = $C['anti_link_spam'][1]; |
546 | 519 | if(!empty($r1) && preg_match($r1, $v)){continue;} |
547 | 520 | $r0 = $C['anti_link_spam'][0]; |
548 | 521 | if(!empty($r0) && preg_match($r0, $v)){ |
549 | 522 | if(isset($a['rel'])){ |
550 | 523 | if(!preg_match('`\bnofollow\b`i', $a['rel'])){$a['rel'] .= ' nofollow';} |
551 | - }elseif(isset($aA['rel'])){ |
|
524 | + } elseif(isset($aA['rel'])){ |
|
552 | 525 | if(!preg_match('`\bnofollow\b`i', $aA['rel'])){$nfr = 1;} |
553 | - }else{$a['rel'] = 'nofollow';} |
|
526 | + } else{$a['rel'] = 'nofollow';} |
|
554 | 527 | } |
555 | 528 | } |
556 | 529 | } |
@@ -577,39 +550,37 @@ discard block |
||
577 | 550 | $v = str_replace(array('\\', ':', ';', '&#'), '', $v); |
578 | 551 | if($k == 'align'){ |
579 | 552 | unset($a['align']); |
580 | - if($e == 'img' && ($v == 'left' or $v == 'right')){$c[] = 'float: '. $v;} |
|
581 | - elseif(($e == 'div' or $e == 'table') && $v == 'center'){$c[] = 'margin: auto';} |
|
582 | - else{$c[] = 'text-align: '. $v;} |
|
583 | - }elseif($k == 'bgcolor'){ |
|
553 | + if($e == 'img' && ($v == 'left' or $v == 'right')){$c[] = 'float: '. $v;} elseif(($e == 'div' or $e == 'table') && $v == 'center'){$c[] = 'margin: auto';} else{$c[] = 'text-align: '. $v;} |
|
554 | + } elseif($k == 'bgcolor'){ |
|
584 | 555 | unset($a['bgcolor']); |
585 | 556 | $c[] = 'background-color: '. $v; |
586 | - }elseif($k == 'border'){ |
|
557 | + } elseif($k == 'border'){ |
|
587 | 558 | unset($a['border']); $c[] = "border: {$v}px"; |
588 | - }elseif($k == 'bordercolor'){ |
|
559 | + } elseif($k == 'bordercolor'){ |
|
589 | 560 | unset($a['bordercolor']); $c[] = 'border-color: '. $v; |
590 | - }elseif($k == 'cellspacing'){ |
|
561 | + } elseif($k == 'cellspacing'){ |
|
591 | 562 | unset($a['cellspacing']); $c[] = "border-spacing: {$v}px"; |
592 | - }elseif($k == 'clear'){ |
|
563 | + } elseif($k == 'clear'){ |
|
593 | 564 | unset($a['clear']); $c[] = 'clear: '. ($v != 'all' ? $v : 'both'); |
594 | - }elseif($k == 'compact'){ |
|
565 | + } elseif($k == 'compact'){ |
|
595 | 566 | unset($a['compact']); $c[] = 'font-size: 85%'; |
596 | - }elseif($k == 'height' or $k == 'width'){ |
|
567 | + } elseif($k == 'height' or $k == 'width'){ |
|
597 | 568 | unset($a[$k]); $c[] = $k. ': '. ($v[0] != '*' ? $v. (ctype_digit($v) ? 'px' : '') : 'auto'); |
598 | - }elseif($k == 'hspace'){ |
|
569 | + } elseif($k == 'hspace'){ |
|
599 | 570 | unset($a['hspace']); $c[] = "margin-left: {$v}px; margin-right: {$v}px"; |
600 | - }elseif($k == 'language' && !isset($a['type'])){ |
|
571 | + } elseif($k == 'language' && !isset($a['type'])){ |
|
601 | 572 | unset($a['language']); |
602 | 573 | $a['type'] = 'text/'. strtolower($v); |
603 | - }elseif($k == 'name'){ |
|
574 | + } elseif($k == 'name'){ |
|
604 | 575 | if($C['no_deprecated_attr'] == 2 or ($e != 'a' && $e != 'map')){unset($a['name']);} |
605 | 576 | if(!isset($a['id']) && !preg_match('`\W`', $v)){$a['id'] = $v;} |
606 | - }elseif($k == 'noshade'){ |
|
577 | + } elseif($k == 'noshade'){ |
|
607 | 578 | unset($a['noshade']); $c[] = 'border-style: none; border: 0; background-color: gray; color: gray'; |
608 | - }elseif($k == 'nowrap'){ |
|
579 | + } elseif($k == 'nowrap'){ |
|
609 | 580 | unset($a['nowrap']); $c[] = 'white-space: nowrap'; |
610 | - }elseif($k == 'size'){ |
|
581 | + } elseif($k == 'size'){ |
|
611 | 582 | unset($a['size']); $c[] = 'size: '. $v. 'px'; |
612 | - }elseif($k == 'vspace'){ |
|
583 | + } elseif($k == 'vspace'){ |
|
613 | 584 | unset($a['vspace']); $c[] = "margin-top: {$v}px; margin-bottom: {$v}px"; |
614 | 585 | } |
615 | 586 | } |
@@ -621,7 +592,7 @@ discard block |
||
621 | 592 | // unique ID |
622 | 593 | if($C['unique_ids'] && isset($a['id'])){ |
623 | 594 | if(preg_match('`\s`', ($id = $a['id'])) or (isset($GLOBALS['hl_Ids'][$id]) && $C['unique_ids'] == 1)){unset($a['id']); |
624 | - }else{ |
|
595 | + } else{ |
|
625 | 596 | while(isset($GLOBALS['hl_Ids'][$id])){$id = $C['unique_ids']. $id;} |
626 | 597 | $GLOBALS['hl_Ids'][($a['id'] = $id)] = 1; |
627 | 598 | } |
@@ -640,8 +611,7 @@ discard block |
||
640 | 611 | $aA = ''; |
641 | 612 | foreach($a as $k=>$v){$aA .= " {$k}=\"{$v}\"";} |
642 | 613 | return "<{$e}{$aA}". (isset($eE[$e]) ? ' /' : ''). '>'; |
643 | -} |
|
644 | -else{return $C['hook_tag']($e, $a);} |
|
614 | +} else{return $C['hook_tag']($e, $a);} |
|
645 | 615 | } |
646 | 616 | |
647 | 617 | public static function hl_tag2(&$e, &$a, $t=1){ |
@@ -701,20 +671,17 @@ discard block |
||
701 | 671 | $e = "<$e>"; |
702 | 672 | if(isset($d[$y])){ |
703 | 673 | if(!$x){ |
704 | - if($n){echo "\n", str_repeat($s, --$n), "$e\n", str_repeat($s, $n);} |
|
705 | - else{++$N; ob_end_clean(); continue 2;} |
|
706 | - } |
|
707 | - else{echo "\n", str_repeat($s, $n), "$e\n", str_repeat($s, ($x != 1 ? ++$n : $n));} |
|
674 | + if($n){echo "\n", str_repeat($s, --$n), "$e\n", str_repeat($s, $n);} else{++$N; ob_end_clean(); continue 2;} |
|
675 | + } else{echo "\n", str_repeat($s, $n), "$e\n", str_repeat($s, ($x != 1 ? ++$n : $n));} |
|
708 | 676 | echo $r; continue; |
709 | 677 | } |
710 | 678 | $f = "\n". str_repeat($s, $n); |
711 | 679 | if(isset($c[$y])){ |
712 | - if(!$x){echo $e, $f, $r;} |
|
713 | - else{echo $f, $e, $r;} |
|
714 | - }elseif(isset($b[$y])){echo $f, $e, $r; |
|
715 | - }elseif(isset($a[$y])){echo $e, $f, $r; |
|
716 | - }elseif(!$y){echo $f, $e, $f, $r; |
|
717 | - }else{echo $e, $r;} |
|
680 | + if(!$x){echo $e, $f, $r;} else{echo $f, $e, $r;} |
|
681 | + } elseif(isset($b[$y])){echo $f, $e, $r; |
|
682 | + } elseif(isset($a[$y])){echo $e, $f, $r; |
|
683 | + } elseif(!$y){echo $f, $e, $f, $r; |
|
684 | + } else{echo $e, $r;} |
|
718 | 685 | } |
719 | 686 | $X = 0; |
720 | 687 | } |
@@ -77,7 +77,7 @@ |
||
77 | 77 | { |
78 | 78 | |
79 | 79 | if ($tablename != '') { |
80 | - return $this->prefix . '_' . $tablename; |
|
80 | + return $this->prefix.'_'.$tablename; |
|
81 | 81 | } else { |
82 | 82 | return $this->prefix; |
83 | 83 | } |
@@ -330,7 +330,7 @@ |
||
330 | 330 | * Checks to see if table exists |
331 | 331 | * |
332 | 332 | * @param string $table name of database table looking for |
333 | - * |
|
333 | + * |
|
334 | 334 | * @return bool true if exists or false if doesnt |
335 | 335 | */ |
336 | 336 | public function tableExists($table) |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | { |
105 | 105 | $this->db->connect(false); |
106 | 106 | |
107 | - $result = $this->db->query("CREATE DATABASE " . \XoopsBaseConfig::get('db-name')); |
|
107 | + $result = $this->db->query("CREATE DATABASE ".\XoopsBaseConfig::get('db-name')); |
|
108 | 108 | |
109 | 109 | return ($result != false) ? true : false; |
110 | 110 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | } |
172 | 172 | } else { |
173 | 173 | if ($prefixed_query[1] === 'DROP TABLE') { |
174 | - if ($this->db->$queryFunc('DROP TABLE ' . $table) != false) { |
|
174 | + if ($this->db->$queryFunc('DROP TABLE '.$table) != false) { |
|
175 | 175 | if (!isset($this->s_tables['drop'][$table])) { |
176 | 176 | $this->s_tables['drop'][$table] = 1; |
177 | 177 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | { |
276 | 276 | $this->db->connect(); |
277 | 277 | $table = $this->db->prefix($table); |
278 | - $query = 'INSERT INTO ' . $table . ' ' . $query; |
|
278 | + $query = 'INSERT INTO '.$table.' '.$query; |
|
279 | 279 | if (!$this->db->queryF($query)) { |
280 | 280 | if (!isset($this->f_tables['insert'][$table])) { |
281 | 281 | $this->f_tables['insert'][$table] = 1; |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | $this->db->connect(); |
320 | 320 | foreach ($tables as $key => $val) { |
321 | 321 | //was: if (!$this->db->query("DROP TABLE " . $this->db->prefix($key))) { |
322 | - if (!$this->db->query("DROP TABLE " . $this->db->prefix($val))) { |
|
322 | + if (!$this->db->query("DROP TABLE ".$this->db->prefix($val))) { |
|
323 | 323 | $deleted[] = $val; |
324 | 324 | } |
325 | 325 | } |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | $ret = false; |
340 | 340 | if ($table != '') { |
341 | 341 | $this->db->connect(); |
342 | - $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix($table); |
|
342 | + $sql = 'SELECT COUNT(*) FROM '.$this->db->prefix($table); |
|
343 | 343 | $ret = (false != $this->db->query($sql)) ? true : false; |
344 | 344 | } |
345 | 345 | return $ret; |
@@ -362,22 +362,22 @@ discard block |
||
362 | 362 | $nTableName, |
363 | 363 | $dropTable = false |
364 | 364 | ) { |
365 | - $sql = "SHOW COLUMNS FROM " . $this->db->prefix($oTableName); |
|
365 | + $sql = "SHOW COLUMNS FROM ".$this->db->prefix($oTableName); |
|
366 | 366 | $result = $this->db->queryF($sql); |
367 | 367 | if (($rows = $this->db->getRowsNum($result)) == count($fieldsMap)) { |
368 | - $sql = "SELECT * FROM " . $this->db->prefix($oTableName); |
|
368 | + $sql = "SELECT * FROM ".$this->db->prefix($oTableName); |
|
369 | 369 | $result = $this->db->queryF($sql); |
370 | 370 | while (false !== ($myrow = $this->db->fetchArray($result))) { |
371 | 371 | ksort($fieldsMap); |
372 | 372 | ksort($myrow); |
373 | - $sql = "INSERT INTO `" . $this->db->prefix($nTableName) |
|
374 | - . "` " . "(`" . implode("`,`", $fieldsMap) . "`)" . |
|
375 | - " VALUES ('" . implode("','", $myrow) . "')"; |
|
373 | + $sql = "INSERT INTO `".$this->db->prefix($nTableName) |
|
374 | + . "` "."(`".implode("`,`", $fieldsMap)."`)". |
|
375 | + " VALUES ('".implode("','", $myrow)."')"; |
|
376 | 376 | |
377 | 377 | $this->db->queryF($sql); |
378 | 378 | } |
379 | 379 | if ($dropTable) { |
380 | - $sql = "DROP TABLE " . $this->db->prefix($oTableName); |
|
380 | + $sql = "DROP TABLE ".$this->db->prefix($oTableName); |
|
381 | 381 | $this->db->queryF($sql); |
382 | 382 | } |
383 | 383 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $frame = $stack[1]; |
71 | 71 | Xoops::getInstance()->deprecated( |
72 | 72 | 'Legacy XoopsDB is deprecated since 2.6.0; all calls should be using Doctrine through $xoops->db(). ' |
73 | - . 'Called from ' . $frame['function'] . '() in ' . $frame['file'] . ' line '. $frame['line'] |
|
73 | + . 'Called from '.$frame['function'].'() in '.$frame['file'].' line '.$frame['line'] |
|
74 | 74 | ); |
75 | 75 | } |
76 | 76 | } |
@@ -342,14 +342,14 @@ discard block |
||
342 | 342 | if (empty($start)) { |
343 | 343 | $start = 0; |
344 | 344 | } |
345 | - $sql = $sql . ' LIMIT ' . (int) $start . ', ' . (int) $limit; |
|
345 | + $sql = $sql.' LIMIT '.(int)$start.', '.(int)$limit; |
|
346 | 346 | } |
347 | 347 | $events = \Xoops::getInstance()->events(); |
348 | 348 | $events->triggerEvent('core.database.query.start'); |
349 | 349 | try { |
350 | 350 | $result = $this->conn->query($sql); |
351 | 351 | } catch (Exception $e) { |
352 | - $result=false; |
|
352 | + $result = false; |
|
353 | 353 | } |
354 | 354 | $this->lastResult = $result; |
355 | 355 | $events->triggerEvent('core.database.query.end'); |
@@ -451,19 +451,19 @@ discard block |
||
451 | 451 | $t = $temp['native_type']; |
452 | 452 | |
453 | 453 | $temp = (string)( |
454 | - ((($t === 'STRING') || ($t === 'VAR_STRING') ) ? 'string' : '' ) . |
|
455 | - ( (in_array($t, array('TINY', 'SHORT', 'LONG', 'LONGLONG', 'INT24'))) ? 'int' : '' ) . |
|
456 | - ( (in_array($t, array('FLOAT', 'DOUBLE', 'DECIMAL', 'NEWDECIMAL'))) ? 'real' : '' ) . |
|
457 | - ( ($t === 'TIMESTAMP') ? 'timestamp' : '' ) . |
|
458 | - ( ($t === 'YEAR') ? 'year' : '') . |
|
459 | - ( (($t === 'DATE') || ($t === 'NEWDATE') ) ? 'date' : '' ) . |
|
460 | - ( ($t === 'TIME') ? 'time' : '' ) . |
|
461 | - ( ($t === 'SET') ? 'set' : '' ) . |
|
462 | - ( ($t === 'ENUM') ? 'enum' : '' ) . |
|
463 | - ( ($t === 'GEOMETRY') ? 'geometry' : '' ) . |
|
464 | - ( ($t === 'DATETIME') ? 'datetime' : '' ) . |
|
465 | - ( (in_array($t, array('TINY_BLOB', 'BLOB', 'MEDIUM_BLOB', 'LONG_BLOB' ))) ? 'blob' : '' ) . |
|
466 | - ( ($t === 'NULL') ? 'null' : '' ) |
|
454 | + ((($t === 'STRING') || ($t === 'VAR_STRING')) ? 'string' : ''). |
|
455 | + ((in_array($t, array('TINY', 'SHORT', 'LONG', 'LONGLONG', 'INT24'))) ? 'int' : ''). |
|
456 | + ((in_array($t, array('FLOAT', 'DOUBLE', 'DECIMAL', 'NEWDECIMAL'))) ? 'real' : ''). |
|
457 | + (($t === 'TIMESTAMP') ? 'timestamp' : ''). |
|
458 | + (($t === 'YEAR') ? 'year' : ''). |
|
459 | + ((($t === 'DATE') || ($t === 'NEWDATE')) ? 'date' : ''). |
|
460 | + (($t === 'TIME') ? 'time' : ''). |
|
461 | + (($t === 'SET') ? 'set' : ''). |
|
462 | + (($t === 'ENUM') ? 'enum' : ''). |
|
463 | + (($t === 'GEOMETRY') ? 'geometry' : ''). |
|
464 | + (($t === 'DATETIME') ? 'datetime' : ''). |
|
465 | + ((in_array($t, array('TINY_BLOB', 'BLOB', 'MEDIUM_BLOB', 'LONG_BLOB'))) ? 'blob' : ''). |
|
466 | + (($t === 'NULL') ? 'null' : '') |
|
467 | 467 | ); |
468 | 468 | return $temp; |
469 | 469 | } catch (PDOException $e) { |
@@ -46,7 +46,7 @@ |
||
46 | 46 | { |
47 | 47 | static $legacy; |
48 | 48 | |
49 | - $file = \XoopsBaseConfig::get('root-path') . '/class/database/mysqldatabase.php'; |
|
49 | + $file = \XoopsBaseConfig::get('root-path').'/class/database/mysqldatabase.php'; |
|
50 | 50 | if (!isset($legacy) && file_exists($file)) { |
51 | 51 | require_once $file; |
52 | 52 | if (!defined('XOOPS_DB_PROXY')) { |
@@ -92,14 +92,14 @@ discard block |
||
92 | 92 | $in_string = true; |
93 | 93 | $string_start = $char; |
94 | 94 | } else { |
95 | - if ($char === '#' || ($char === ' ' && $i > 1 && $sql[$i - 2] . $sql[$i - 1] == '--')) { |
|
95 | + if ($char === '#' || ($char === ' ' && $i > 1 && $sql[$i - 2].$sql[$i - 1] == '--')) { |
|
96 | 96 | $start_of_comment = (($sql[$i] === '#') ? $i : $i - 2); |
97 | - $end_of_comment = (strpos(' ' . $sql, "\012", $i + 2)) ? strpos(' ' . $sql, "\012", $i + 2) |
|
98 | - : strpos(' ' . $sql, "\015", $i + 2); |
|
97 | + $end_of_comment = (strpos(' '.$sql, "\012", $i + 2)) ? strpos(' '.$sql, "\012", $i + 2) |
|
98 | + : strpos(' '.$sql, "\015", $i + 2); |
|
99 | 99 | if (!$end_of_comment) { |
100 | 100 | return true; |
101 | 101 | } else { |
102 | - $sql = substr($sql, 0, $start_of_comment) . ltrim(substr($sql, $end_of_comment)); |
|
102 | + $sql = substr($sql, 0, $start_of_comment).ltrim(substr($sql, $end_of_comment)); |
|
103 | 103 | $sql_len = strlen($sql); |
104 | 104 | $i--; |
105 | 105 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | if (preg_match($pattern, $query, $matches) |
131 | 131 | || preg_match($pattern2, $query, $matches) |
132 | 132 | ) { |
133 | - $replace = "\\1 " . $prefix . "_\\4\\5"; |
|
133 | + $replace = "\\1 ".$prefix."_\\4\\5"; |
|
134 | 134 | $matches[0] = preg_replace($pattern, $replace, $query); |
135 | 135 | return $matches; |
136 | 136 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | { |
35 | 35 | if (is_array($data)) { |
36 | 36 | $return = array_map(array('XoopsUtility', 'recursive'), |
37 | - array_fill(0, count($data), $handler), $data); |
|
37 | + array_fill(0, count($data), $handler), $data); |
|
38 | 38 | return $return; |
39 | 39 | } |
40 | 40 | // single function |
@@ -117,15 +117,15 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | return true; |
120 | - } elseif (self::fileExists($file = \XoopsBaseConfig::get('root-path') . '/class/' . $name . '.php')) { |
|
120 | + } elseif (self::fileExists($file = \XoopsBaseConfig::get('root-path').'/class/'.$name.'.php')) { |
|
121 | 121 | //attempt loading from file |
122 | 122 | include_once $file; |
123 | - $class = 'Xoops' . ucfirst($name); |
|
123 | + $class = 'Xoops'.ucfirst($name); |
|
124 | 124 | if (class_exists($class)) { |
125 | 125 | return $class; |
126 | 126 | } else { |
127 | 127 | trigger_error( |
128 | - 'Class ' . $name . ' not found in file ' . __FILE__ . 'at line ' . __LINE__, |
|
128 | + 'Class '.$name.' not found in file '.__FILE__.'at line '.__LINE__, |
|
129 | 129 | E_USER_WARNING |
130 | 130 | ); |
131 | 131 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | private static function loadFramework($name) |
145 | 145 | { |
146 | - if (!self::fileExists($file = \XoopsBaseConfig::get('root-path') . '/Frameworks/' . $name . '/xoops' . $name . '.php')) { |
|
146 | + if (!self::fileExists($file = \XoopsBaseConfig::get('root-path').'/Frameworks/'.$name.'/xoops'.$name.'.php')) { |
|
147 | 147 | /* |
148 | 148 | trigger_error( |
149 | 149 | 'File ' . str_replace(\XoopsBaseConfig::get('root-path'), '', $file) |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | return false; |
155 | 155 | } |
156 | 156 | include_once $file; |
157 | - $class = 'Xoops' . ucfirst($name); |
|
157 | + $class = 'Xoops'.ucfirst($name); |
|
158 | 158 | if (class_exists($class, false)) { |
159 | 159 | return $class; |
160 | 160 | } |
@@ -175,9 +175,9 @@ discard block |
||
175 | 175 | if (empty($dirname)) { |
176 | 176 | return false; |
177 | 177 | } |
178 | - if (self::fileExists($file = \XoopsBaseConfig::get('root-path') . '/modules/' . $dirname . '/class/' . $name . '.php')) { |
|
178 | + if (self::fileExists($file = \XoopsBaseConfig::get('root-path').'/modules/'.$dirname.'/class/'.$name.'.php')) { |
|
179 | 179 | include_once $file; |
180 | - if (class_exists(ucfirst($dirname) . ucfirst($name))) { |
|
180 | + if (class_exists(ucfirst($dirname).ucfirst($name))) { |
|
181 | 181 | return true; |
182 | 182 | } |
183 | 183 | } |
@@ -195,50 +195,50 @@ discard block |
||
195 | 195 | { |
196 | 196 | $xoops_root_path = \XoopsBaseConfig::get('root-path'); |
197 | 197 | return array( |
198 | - 'bloggerapi' => $xoops_root_path . '/class/xml/rpc/bloggerapi.php', |
|
199 | - 'criteria' => $xoops_root_path . '/class/criteria.php', |
|
200 | - 'criteriacompo' => $xoops_root_path . '/class/criteria.php', |
|
201 | - 'criteriaelement' => $xoops_root_path . '/class/criteria.php', |
|
202 | - 'formdhtmltextarea' => $xoops_root_path . '/class/xoopseditor/dhtmltextarea/dhtmltextarea.php', |
|
203 | - 'formtextarea' => $xoops_root_path . '/class/xoopseditor/textarea/textarea.php', |
|
204 | - 'htmlawed' => $xoops_root_path . '/class/vendor/htmLawed.php', |
|
205 | - 'metaweblogapi' => $xoops_root_path . '/class/xml/rpc/metaweblogapi.php', |
|
206 | - 'movabletypeapi' => $xoops_root_path . '/class/xml/rpc/movabletypeapi.php', |
|
207 | - 'mytextsanitizer' => $xoops_root_path . '/class/module.textsanitizer.php', |
|
198 | + 'bloggerapi' => $xoops_root_path.'/class/xml/rpc/bloggerapi.php', |
|
199 | + 'criteria' => $xoops_root_path.'/class/criteria.php', |
|
200 | + 'criteriacompo' => $xoops_root_path.'/class/criteria.php', |
|
201 | + 'criteriaelement' => $xoops_root_path.'/class/criteria.php', |
|
202 | + 'formdhtmltextarea' => $xoops_root_path.'/class/xoopseditor/dhtmltextarea/dhtmltextarea.php', |
|
203 | + 'formtextarea' => $xoops_root_path.'/class/xoopseditor/textarea/textarea.php', |
|
204 | + 'htmlawed' => $xoops_root_path.'/class/vendor/htmLawed.php', |
|
205 | + 'metaweblogapi' => $xoops_root_path.'/class/xml/rpc/metaweblogapi.php', |
|
206 | + 'movabletypeapi' => $xoops_root_path.'/class/xml/rpc/movabletypeapi.php', |
|
207 | + 'mytextsanitizer' => $xoops_root_path.'/class/module.textsanitizer.php', |
|
208 | 208 | //'mytextsanitizerextension' => $xoops_root_path . '/class/module.textsanitizer.php', |
209 | 209 | //'phpmailer' => $xoops_root_path . '/class/mail/phpmailer/class.phpmailer.php', |
210 | - 'rssauthorhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
211 | - 'rsscategoryhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
212 | - 'rsscommentshandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
213 | - 'rsscopyrighthandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
214 | - 'rssdescriptionhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
215 | - 'rssdocshandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
216 | - 'rssgeneratorhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
217 | - 'rssguidhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
218 | - 'rssheighthandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
219 | - 'rssimagehandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
220 | - 'rssitemhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
221 | - 'rsslanguagehandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
222 | - 'rsslastbuilddatehandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
223 | - 'rsslinkhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
224 | - 'rssmanagingeditorhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
225 | - 'rssnamehandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
226 | - 'rsspubdatehandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
227 | - 'rsssourcehandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
228 | - 'rsstextinputhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
229 | - 'rsstitlehandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
230 | - 'rssttlhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
231 | - 'rssurlhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
232 | - 'rsswebmasterhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
233 | - 'rsswidthhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
234 | - 'saxparser' => $xoops_root_path . '/class/xml/saxparser.php', |
|
210 | + 'rssauthorhandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
211 | + 'rsscategoryhandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
212 | + 'rsscommentshandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
213 | + 'rsscopyrighthandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
214 | + 'rssdescriptionhandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
215 | + 'rssdocshandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
216 | + 'rssgeneratorhandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
217 | + 'rssguidhandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
218 | + 'rssheighthandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
219 | + 'rssimagehandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
220 | + 'rssitemhandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
221 | + 'rsslanguagehandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
222 | + 'rsslastbuilddatehandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
223 | + 'rsslinkhandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
224 | + 'rssmanagingeditorhandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
225 | + 'rssnamehandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
226 | + 'rsspubdatehandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
227 | + 'rsssourcehandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
228 | + 'rsstextinputhandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
229 | + 'rsstitlehandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
230 | + 'rssttlhandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
231 | + 'rssurlhandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
232 | + 'rsswebmasterhandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
233 | + 'rsswidthhandler' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
234 | + 'saxparser' => $xoops_root_path.'/class/xml/saxparser.php', |
|
235 | 235 | //'smarty' => $xoops_root_path . '/smarty/Smarty.class.php', |
236 | - 'snoopy' => $xoops_root_path . '/class/vendor/snoopy.php', |
|
237 | - 'sqlutility' => $xoops_root_path . '/class/database/sqlutility.php', |
|
238 | - 'tar' => $xoops_root_path . '/class/class.tar.php', |
|
239 | - 'xmltaghandler' => $xoops_root_path . '/class/xml/xmltaghandler.php', |
|
240 | - 'xoopsadminthemefactory' => $xoops_root_path . '/class/theme.php', |
|
241 | - 'xoopsapi' => $xoops_root_path . '/class/xml/rpc/xoopsapi.php', |
|
236 | + 'snoopy' => $xoops_root_path.'/class/vendor/snoopy.php', |
|
237 | + 'sqlutility' => $xoops_root_path.'/class/database/sqlutility.php', |
|
238 | + 'tar' => $xoops_root_path.'/class/class.tar.php', |
|
239 | + 'xmltaghandler' => $xoops_root_path.'/class/xml/xmltaghandler.php', |
|
240 | + 'xoopsadminthemefactory' => $xoops_root_path.'/class/theme.php', |
|
241 | + 'xoopsapi' => $xoops_root_path.'/class/xml/rpc/xoopsapi.php', |
|
242 | 242 | //'xoopsauth' => $xoops_root_path . '/class/auth/auth.php', |
243 | 243 | //'xoopsauthfactory' => $xoops_root_path . '/class/auth/authfactory.php', |
244 | 244 | //'xoopsauthads' => $xoops_root_path . '/class/auth/auth_ads.php', |
@@ -255,12 +255,12 @@ discard block |
||
255 | 255 | //'xoopsblockmodulelink' => $xoops_root_path . '/kernel/blockmodulelink.php', |
256 | 256 | //'xoopsblockmodulelinkhandler' => $xoops_root_path . '/kernel/blockmodulelink.php', |
257 | 257 | //'xoopscalendar' => $xoops_root_path . '/class/calendar/xoopscalendar.php', |
258 | - 'xoopscaptcha' => $xoops_root_path . '/class/captcha/xoopscaptcha.php', |
|
259 | - 'xoopscaptchamethod' => $xoops_root_path . '/class/captcha/xoopscaptchamethod.php', |
|
260 | - 'xoopscaptchaimage' => $xoops_root_path . '/class/captcha/image.php', |
|
261 | - 'xoopscaptcharecaptcha' => $xoops_root_path . '/class/captcha/recaptcha.php', |
|
262 | - 'xoopscaptchatext' => $xoops_root_path . '/class/captcha/text.php', |
|
263 | - 'xoopscaptchaimagehandler' => $xoops_root_path . '/class/captcha/image/scripts/imageclass.php', |
|
258 | + 'xoopscaptcha' => $xoops_root_path.'/class/captcha/xoopscaptcha.php', |
|
259 | + 'xoopscaptchamethod' => $xoops_root_path.'/class/captcha/xoopscaptchamethod.php', |
|
260 | + 'xoopscaptchaimage' => $xoops_root_path.'/class/captcha/image.php', |
|
261 | + 'xoopscaptcharecaptcha' => $xoops_root_path.'/class/captcha/recaptcha.php', |
|
262 | + 'xoopscaptchatext' => $xoops_root_path.'/class/captcha/text.php', |
|
263 | + 'xoopscaptchaimagehandler' => $xoops_root_path.'/class/captcha/image/scripts/imageclass.php', |
|
264 | 264 | //'xoopscomment' => $xoops_root_path . '/kernel/comment.php', |
265 | 265 | //'xoopscommenthandler' => $xoops_root_path . '/kernel/comment.php', |
266 | 266 | //'xoopscommentrenderer' => $xoops_root_path . '/class/commentrenderer.php', |
@@ -271,15 +271,15 @@ discard block |
||
271 | 271 | //'xoopsconfigitemhandler' => $xoops_root_path . '/kernel/configitem.php', |
272 | 272 | //'xoopsconfigoption' => $xoops_root_path . '/kernel/configoption.php', |
273 | 273 | //'xoopsconfigoptionhandler' => $xoops_root_path . '/kernel/configoption.php', |
274 | - 'xoopsdatabase' => $xoops_root_path . '/class/database/database.php', |
|
274 | + 'xoopsdatabase' => $xoops_root_path.'/class/database/database.php', |
|
275 | 275 | //'xoopsconnection' => $xoops_root_path . '/class/database/connection.php', |
276 | 276 | //'xoopsquerybuilder' => $xoops_root_path . '/class/database/querybuilder.php', |
277 | - 'xoopsdatabasefactory' => $xoops_root_path . '/class/database/databasefactory.php', |
|
278 | - 'xoopsdatabasemanager' => $xoops_root_path . '/class/database/manager.php', |
|
279 | - 'xoopsdownloader' => $xoops_root_path . '/class/downloader.php', |
|
280 | - 'xoopsmysqldatabase' => $xoops_root_path . '/class/database/mysqldatabase.php', |
|
281 | - 'xoopsmysqldatabaseproxy' => $xoops_root_path . '/class/database/mysqldatabaseproxy.php', |
|
282 | - 'xoopsmysqldatabasesafe' => $xoops_root_path . '/class/database/mysqldatabasesafe.php', |
|
277 | + 'xoopsdatabasefactory' => $xoops_root_path.'/class/database/databasefactory.php', |
|
278 | + 'xoopsdatabasemanager' => $xoops_root_path.'/class/database/manager.php', |
|
279 | + 'xoopsdownloader' => $xoops_root_path.'/class/downloader.php', |
|
280 | + 'xoopsmysqldatabase' => $xoops_root_path.'/class/database/mysqldatabase.php', |
|
281 | + 'xoopsmysqldatabaseproxy' => $xoops_root_path.'/class/database/mysqldatabaseproxy.php', |
|
282 | + 'xoopsmysqldatabasesafe' => $xoops_root_path.'/class/database/mysqldatabasesafe.php', |
|
283 | 283 | //'xoopsgroup' => $xoops_root_path . '/kernel/group.php', |
284 | 284 | //'xoopsgrouphandler' => $xoops_root_path . '/kernel/group.php', |
285 | 285 | //'xoopsgroupperm' => $xoops_root_path . '/kernel/groupperm.php', |
@@ -292,61 +292,61 @@ discard block |
||
292 | 292 | //'xoopsimagesethandler' => $xoops_root_path . '/kernel/imageset.php', |
293 | 293 | //'xoopsimagesetimg' => $xoops_root_path . '/kernel/imagesetimg.php', |
294 | 294 | //'xoopsimagesetimghandler' => $xoops_root_path . '/kernel/imagesetimg.php', |
295 | - 'xoopslists' => $xoops_root_path . '/class/xoopslists.php', |
|
295 | + 'xoopslists' => $xoops_root_path.'/class/xoopslists.php', |
|
296 | 296 | //'xoopslocal' => $xoops_root_path . '/include/xoopslocal.php', |
297 | - 'xoopslocalabstract' => $xoops_root_path . '/class/xoopslocal.php', |
|
298 | - 'xoopslogger' => $xoops_root_path . '/class/logger/xoopslogger.php', |
|
299 | - 'xoopseditor' => $xoops_root_path . '/class/xoopseditor/xoopseditor.php', |
|
300 | - 'xoopseditorhandler' => $xoops_root_path . '/class/xoopseditor/xoopseditor.php', |
|
301 | - 'xoopsfile' => $xoops_root_path . '/class/file/xoopsfile.php', |
|
302 | - 'xoopsfilehandler' => $xoops_root_path . '/class/file/file.php', |
|
303 | - 'xoopsfilterinput' => $xoops_root_path . '/class/xoopsfilterinput.php', |
|
304 | - 'xoopsfolderhandler' => $xoops_root_path . '/class/file/folder.php', |
|
305 | - 'xoopsform' => $xoops_root_path . '/class/xoopsform/form.php', |
|
306 | - 'xoopsformbutton' => $xoops_root_path . '/class/xoopsform/formbutton.php', |
|
307 | - 'xoopsformbuttontray' => $xoops_root_path . '/class/xoopsform/formbuttontray.php', |
|
297 | + 'xoopslocalabstract' => $xoops_root_path.'/class/xoopslocal.php', |
|
298 | + 'xoopslogger' => $xoops_root_path.'/class/logger/xoopslogger.php', |
|
299 | + 'xoopseditor' => $xoops_root_path.'/class/xoopseditor/xoopseditor.php', |
|
300 | + 'xoopseditorhandler' => $xoops_root_path.'/class/xoopseditor/xoopseditor.php', |
|
301 | + 'xoopsfile' => $xoops_root_path.'/class/file/xoopsfile.php', |
|
302 | + 'xoopsfilehandler' => $xoops_root_path.'/class/file/file.php', |
|
303 | + 'xoopsfilterinput' => $xoops_root_path.'/class/xoopsfilterinput.php', |
|
304 | + 'xoopsfolderhandler' => $xoops_root_path.'/class/file/folder.php', |
|
305 | + 'xoopsform' => $xoops_root_path.'/class/xoopsform/form.php', |
|
306 | + 'xoopsformbutton' => $xoops_root_path.'/class/xoopsform/formbutton.php', |
|
307 | + 'xoopsformbuttontray' => $xoops_root_path.'/class/xoopsform/formbuttontray.php', |
|
308 | 308 | //'xoopsformcalendar' => $xoops_root_path . '/class/xoopsform/formcalendar.php', |
309 | - 'xoopsformcaptcha' => $xoops_root_path . '/class/xoopsform/formcaptcha.php', |
|
310 | - 'xoopsformcheckbox' => $xoops_root_path . '/class/xoopsform/formcheckbox.php', |
|
311 | - 'xoopsformcolorpicker' => $xoops_root_path . '/class/xoopsform/formcolorpicker.php', |
|
309 | + 'xoopsformcaptcha' => $xoops_root_path.'/class/xoopsform/formcaptcha.php', |
|
310 | + 'xoopsformcheckbox' => $xoops_root_path.'/class/xoopsform/formcheckbox.php', |
|
311 | + 'xoopsformcolorpicker' => $xoops_root_path.'/class/xoopsform/formcolorpicker.php', |
|
312 | 312 | //'xoopsformcontainer' => $xoops_root_path . '/class/xoopsform/formcontainer.php', |
313 | - 'xoopsformdatetime' => $xoops_root_path . '/class/xoopsform/formdatetime.php', |
|
314 | - 'xoopsformdhtmltextarea' => $xoops_root_path . '/class/xoopsform/formdhtmltextarea.php', |
|
315 | - 'xoopsformeditor' => $xoops_root_path . '/class/xoopsform/formeditor.php', |
|
316 | - 'xoopsformelement' => $xoops_root_path . '/class/xoopsform/formelement.php', |
|
317 | - 'xoopsformelementtray' => $xoops_root_path . '/class/xoopsform/formelementtray.php', |
|
318 | - 'xoopsformfile' => $xoops_root_path . '/class/xoopsform/formfile.php', |
|
319 | - 'xoopsformhidden' => $xoops_root_path . '/class/xoopsform/formhidden.php', |
|
320 | - 'xoopsformhiddentoken' => $xoops_root_path . '/class/xoopsform/formhiddentoken.php', |
|
321 | - 'xoopsformlabel' => $xoops_root_path . '/class/xoopsform/formlabel.php', |
|
322 | - 'xoopsformloader' => $xoops_root_path . '/class/xoopsformloader.php', |
|
323 | - 'xoopsformpassword' => $xoops_root_path . '/class/xoopsform/formpassword.php', |
|
324 | - 'xoopsformradio' => $xoops_root_path . '/class/xoopsform/formradio.php', |
|
325 | - 'xoopsformradioyn' => $xoops_root_path . '/class/xoopsform/formradioyn.php', |
|
313 | + 'xoopsformdatetime' => $xoops_root_path.'/class/xoopsform/formdatetime.php', |
|
314 | + 'xoopsformdhtmltextarea' => $xoops_root_path.'/class/xoopsform/formdhtmltextarea.php', |
|
315 | + 'xoopsformeditor' => $xoops_root_path.'/class/xoopsform/formeditor.php', |
|
316 | + 'xoopsformelement' => $xoops_root_path.'/class/xoopsform/formelement.php', |
|
317 | + 'xoopsformelementtray' => $xoops_root_path.'/class/xoopsform/formelementtray.php', |
|
318 | + 'xoopsformfile' => $xoops_root_path.'/class/xoopsform/formfile.php', |
|
319 | + 'xoopsformhidden' => $xoops_root_path.'/class/xoopsform/formhidden.php', |
|
320 | + 'xoopsformhiddentoken' => $xoops_root_path.'/class/xoopsform/formhiddentoken.php', |
|
321 | + 'xoopsformlabel' => $xoops_root_path.'/class/xoopsform/formlabel.php', |
|
322 | + 'xoopsformloader' => $xoops_root_path.'/class/xoopsformloader.php', |
|
323 | + 'xoopsformpassword' => $xoops_root_path.'/class/xoopsform/formpassword.php', |
|
324 | + 'xoopsformradio' => $xoops_root_path.'/class/xoopsform/formradio.php', |
|
325 | + 'xoopsformradioyn' => $xoops_root_path.'/class/xoopsform/formradioyn.php', |
|
326 | 326 | //'xoopsformraw' => $xoops_root_path . '/class/xoopsform/formraw.php', |
327 | - 'xoopsformselect' => $xoops_root_path . '/class/xoopsform/formselect.php', |
|
328 | - 'xoopsformselectcheckgroup' => $xoops_root_path . '/class/xoopsform/formselectcheckgroup.php', |
|
329 | - 'xoopsformselectcountry' => $xoops_root_path . '/class/xoopsform/formselectcountry.php', |
|
330 | - 'xoopsformselecteditor' => $xoops_root_path . '/class/xoopsform/formselecteditor.php', |
|
331 | - 'xoopsformselectgroup' => $xoops_root_path . '/class/xoopsform/formselectgroup.php', |
|
332 | - 'xoopsformselectlang' => $xoops_root_path . '/class/xoopsform/formselectlang.php', |
|
327 | + 'xoopsformselect' => $xoops_root_path.'/class/xoopsform/formselect.php', |
|
328 | + 'xoopsformselectcheckgroup' => $xoops_root_path.'/class/xoopsform/formselectcheckgroup.php', |
|
329 | + 'xoopsformselectcountry' => $xoops_root_path.'/class/xoopsform/formselectcountry.php', |
|
330 | + 'xoopsformselecteditor' => $xoops_root_path.'/class/xoopsform/formselecteditor.php', |
|
331 | + 'xoopsformselectgroup' => $xoops_root_path.'/class/xoopsform/formselectgroup.php', |
|
332 | + 'xoopsformselectlang' => $xoops_root_path.'/class/xoopsform/formselectlang.php', |
|
333 | 333 | //'xoopsformselectlocale' => $xoops_root_path . '/class/xoopsform/formselectlocale.php', |
334 | - 'xoopsformselectmatchoption' => $xoops_root_path . '/class/xoopsform/formselectmatchoption.php', |
|
335 | - 'xoopsformselecttheme' => $xoops_root_path . '/class/xoopsform/formselecttheme.php', |
|
336 | - 'xoopsformselecttimezone' => $xoops_root_path . '/class/xoopsform/formselecttimezone.php', |
|
337 | - 'xoopsformselectuser' => $xoops_root_path . '/class/xoopsform/formselectuser.php', |
|
334 | + 'xoopsformselectmatchoption' => $xoops_root_path.'/class/xoopsform/formselectmatchoption.php', |
|
335 | + 'xoopsformselecttheme' => $xoops_root_path.'/class/xoopsform/formselecttheme.php', |
|
336 | + 'xoopsformselecttimezone' => $xoops_root_path.'/class/xoopsform/formselecttimezone.php', |
|
337 | + 'xoopsformselectuser' => $xoops_root_path.'/class/xoopsform/formselectuser.php', |
|
338 | 338 | //'xoopsformtab' => $xoops_root_path . '/class/xoopsform/formtab.php', |
339 | 339 | //'xoopsformtabtray' => $xoops_root_path . '/class/xoopsform/formtabtray.php', |
340 | - 'xoopsformtext' => $xoops_root_path . '/class/xoopsform/formtext.php', |
|
341 | - 'xoopsformtextarea' => $xoops_root_path . '/class/xoopsform/formtextarea.php', |
|
342 | - 'xoopsformtextdateselect' => $xoops_root_path . '/class/xoopsform/formtextdateselect.php', |
|
340 | + 'xoopsformtext' => $xoops_root_path.'/class/xoopsform/formtext.php', |
|
341 | + 'xoopsformtextarea' => $xoops_root_path.'/class/xoopsform/formtextarea.php', |
|
342 | + 'xoopsformtextdateselect' => $xoops_root_path.'/class/xoopsform/formtextdateselect.php', |
|
343 | 343 | //'xoopsformmail' => $xoops_root_path . '/class/xoopsform/formmail.php', |
344 | 344 | //'xoopsformurl' => $xoops_root_path . '/class/xoopsform/formurl.php', |
345 | - 'xoopsgroupformcheckbox' => $xoops_root_path . '/class/xoopsform/grouppermform.php', |
|
346 | - 'xoopsgrouppermform' => $xoops_root_path . '/class/xoopsform/grouppermform.php', |
|
345 | + 'xoopsgroupformcheckbox' => $xoops_root_path.'/class/xoopsform/grouppermform.php', |
|
346 | + 'xoopsgrouppermform' => $xoops_root_path.'/class/xoopsform/grouppermform.php', |
|
347 | 347 | //'xoopsguestuser' => $xoops_root_path . '/kernel/user.php', |
348 | - 'xoopsmailer' => $xoops_root_path . '/class/xoopsmailer.php', |
|
349 | - 'xoopsmediauploader' => $xoops_root_path . '/class/uploader.php', |
|
348 | + 'xoopsmailer' => $xoops_root_path.'/class/xoopsmailer.php', |
|
349 | + 'xoopsmediauploader' => $xoops_root_path.'/class/uploader.php', |
|
350 | 350 | //'xoopsmemberhandler' => $xoops_root_path . '/kernel/member.php', |
351 | 351 | //'xoopsmembership' => $xoops_root_path . '/kernel/membership.php', |
352 | 352 | //'xoopsmembershiphandler' => $xoops_root_path . '/kernel/membership.php', |
@@ -354,35 +354,35 @@ discard block |
||
354 | 354 | //'xoopsmoduleadmin' => $xoops_root_path . '/class/moduleadmin.php', |
355 | 355 | //'xoopsmodule' => $xoops_root_path . '/kernel/module.php', |
356 | 356 | //'xoopsmodulehandler' => $xoops_root_path . '/kernel/module.php', |
357 | - 'xoopsmultimailer' => $xoops_root_path . '/class/xoopsmultimailer.php', |
|
357 | + 'xoopsmultimailer' => $xoops_root_path.'/class/xoopsmultimailer.php', |
|
358 | 358 | //'xoopsnotification' => $xoops_root_path . '/kernel/notification.php', |
359 | 359 | //'xoopsnotificationhandler' => $xoops_root_path . '/kernel/notification.php', |
360 | - 'xoopsobject' => $xoops_root_path . '/kernel/object.php', |
|
361 | - 'xoopsobjecthandler' => $xoops_root_path . '/kernel/object.php', |
|
362 | - 'xoopsobjecttree' => $xoops_root_path . '/class/tree.php', |
|
360 | + 'xoopsobject' => $xoops_root_path.'/kernel/object.php', |
|
361 | + 'xoopsobjecthandler' => $xoops_root_path.'/kernel/object.php', |
|
362 | + 'xoopsobjecttree' => $xoops_root_path.'/class/tree.php', |
|
363 | 363 | //'xoopsonline' => $xoops_root_path . '/kernel/online.php', |
364 | 364 | //'xoopsonlinehandler' => $xoops_root_path . '/kernel/online.php', |
365 | - 'xoopspagenav' => $xoops_root_path . '/class/pagenav.php', |
|
366 | - 'xoopspersistableobjecthandler' => $xoops_root_path . '/kernel/object.php', |
|
367 | - 'xoopspreload' => $xoops_root_path . '/class/preload.php', |
|
368 | - 'xoopspreloaditem' => $xoops_root_path . '/class/preload.php', |
|
365 | + 'xoopspagenav' => $xoops_root_path.'/class/pagenav.php', |
|
366 | + 'xoopspersistableobjecthandler' => $xoops_root_path.'/kernel/object.php', |
|
367 | + 'xoopspreload' => $xoops_root_path.'/class/preload.php', |
|
368 | + 'xoopspreloaditem' => $xoops_root_path.'/class/preload.php', |
|
369 | 369 | //'xoopsprivmessage' => $xoops_root_path . '/kernel/privmessage.php', |
370 | 370 | //'xoopsprivmessagehandler' => $xoops_root_path . '/kernel/privmessage.php', |
371 | 371 | //'xoopsranks' => $xoops_root_path . '/kernel/ranks.php', |
372 | 372 | //'xoopsrankshandler' => $xoops_root_path . '/kernel/ranks.php', |
373 | 373 | // 'xoopsregistry' => $xoops_root_path . '/class/registry.php', |
374 | - 'xoopsrequest' => $xoops_root_path . '/class/xoopsrequest.php', |
|
374 | + 'xoopsrequest' => $xoops_root_path.'/class/xoopsrequest.php', |
|
375 | 375 | // 'xoopssecurity' => $xoops_root_path . '/class/xoopssecurity.php', |
376 | 376 | // 'xoopssessionhandler' => $xoops_root_path . '/kernel/session.php', |
377 | - 'xoopssimpleform' => $xoops_root_path . '/class/xoopsform/simpleform.php', |
|
378 | - 'xoopstableform' => $xoops_root_path . '/class/xoopsform/tableform.php', |
|
379 | - 'xoopstardownloader' => $xoops_root_path . '/class/tardownloader.php', |
|
380 | - 'xoopstheme' => $xoops_root_path . '/class/theme.php', |
|
381 | - 'xoopsthemeblocksplugin' => $xoops_root_path . '/class/theme_blocks.php', |
|
382 | - 'xoopsthemefactory' => $xoops_root_path . '/class/theme.php', |
|
383 | - 'xoopsthemeform' => $xoops_root_path . '/class/xoopsform/themeform.php', |
|
384 | - 'xoopsthemeplugin' => $xoops_root_path . '/class/theme.php', |
|
385 | - 'xoopsthemesetparser' => $xoops_root_path . '/class/xml/themesetparser.php', |
|
377 | + 'xoopssimpleform' => $xoops_root_path.'/class/xoopsform/simpleform.php', |
|
378 | + 'xoopstableform' => $xoops_root_path.'/class/xoopsform/tableform.php', |
|
379 | + 'xoopstardownloader' => $xoops_root_path.'/class/tardownloader.php', |
|
380 | + 'xoopstheme' => $xoops_root_path.'/class/theme.php', |
|
381 | + 'xoopsthemeblocksplugin' => $xoops_root_path.'/class/theme_blocks.php', |
|
382 | + 'xoopsthemefactory' => $xoops_root_path.'/class/theme.php', |
|
383 | + 'xoopsthemeform' => $xoops_root_path.'/class/xoopsform/themeform.php', |
|
384 | + 'xoopsthemeplugin' => $xoops_root_path.'/class/theme.php', |
|
385 | + 'xoopsthemesetparser' => $xoops_root_path.'/class/xml/themesetparser.php', |
|
386 | 386 | //'xoopstpl' => $xoops_root_path . '/class/template.php', |
387 | 387 | //'xoopstplfile' => $xoops_root_path . '/kernel/tplfile.php', |
388 | 388 | //'xoopstplfilehandler' => $xoops_root_path . '/kernel/tplfile.php', |
@@ -390,26 +390,26 @@ discard block |
||
390 | 390 | //'xoopstplsethandler' => $xoops_root_path . '/kernel/tplset.php', |
391 | 391 | //'xoopsuser' => $xoops_root_path . '/kernel/user.php', |
392 | 392 | //'xoopsuserhandler' => $xoops_root_path . '/kernel/user.php', |
393 | - 'xoopsuserutility' => $xoops_root_path . '/class/userutility.php', |
|
394 | - 'xoopsutility' => $xoops_root_path . '/class/utility/xoopsutility.php', |
|
395 | - 'xoopsxmlrpcapi' => $xoops_root_path . '/class/xml/rpc/xmlrpcapi.php', |
|
396 | - 'xoopsxmlrpcarray' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php', |
|
397 | - 'xoopsxmlrpcbase64'=> $xoops_root_path . '/class/xml/rpc/xmlrpctag.php', |
|
398 | - 'xoopsxmlrpcboolean' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php', |
|
399 | - 'xoopsxmlrpcdatetime' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php', |
|
400 | - 'xoopsxmlrpcdocument' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php', |
|
401 | - 'xoopsxmlrpcdouble' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php', |
|
402 | - 'xoopsxmlrpcfault' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php', |
|
403 | - 'xoopsxmlrpcint' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php', |
|
404 | - 'xoopsxmlrpcparser' => $xoops_root_path . '/class/xml/rpc/xmlrpcparser.php', |
|
405 | - 'xoopsxmlrpcrequest' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php', |
|
406 | - 'xoopsxmlrpcresponse' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php', |
|
407 | - 'xoopsxmlrpcstring' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php', |
|
408 | - 'xoopsxmlrpcstruct' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php', |
|
409 | - 'xoopsxmlrpctag' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php', |
|
410 | - 'xoopsxmlrss2parser' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php', |
|
411 | - 'xoopszipdownloader' => $xoops_root_path . '/class/zipdownloader.php', |
|
412 | - 'zipfile' => $xoops_root_path . '/class/class.zipfile.php', |
|
393 | + 'xoopsuserutility' => $xoops_root_path.'/class/userutility.php', |
|
394 | + 'xoopsutility' => $xoops_root_path.'/class/utility/xoopsutility.php', |
|
395 | + 'xoopsxmlrpcapi' => $xoops_root_path.'/class/xml/rpc/xmlrpcapi.php', |
|
396 | + 'xoopsxmlrpcarray' => $xoops_root_path.'/class/xml/rpc/xmlrpctag.php', |
|
397 | + 'xoopsxmlrpcbase64'=> $xoops_root_path.'/class/xml/rpc/xmlrpctag.php', |
|
398 | + 'xoopsxmlrpcboolean' => $xoops_root_path.'/class/xml/rpc/xmlrpctag.php', |
|
399 | + 'xoopsxmlrpcdatetime' => $xoops_root_path.'/class/xml/rpc/xmlrpctag.php', |
|
400 | + 'xoopsxmlrpcdocument' => $xoops_root_path.'/class/xml/rpc/xmlrpctag.php', |
|
401 | + 'xoopsxmlrpcdouble' => $xoops_root_path.'/class/xml/rpc/xmlrpctag.php', |
|
402 | + 'xoopsxmlrpcfault' => $xoops_root_path.'/class/xml/rpc/xmlrpctag.php', |
|
403 | + 'xoopsxmlrpcint' => $xoops_root_path.'/class/xml/rpc/xmlrpctag.php', |
|
404 | + 'xoopsxmlrpcparser' => $xoops_root_path.'/class/xml/rpc/xmlrpcparser.php', |
|
405 | + 'xoopsxmlrpcrequest' => $xoops_root_path.'/class/xml/rpc/xmlrpctag.php', |
|
406 | + 'xoopsxmlrpcresponse' => $xoops_root_path.'/class/xml/rpc/xmlrpctag.php', |
|
407 | + 'xoopsxmlrpcstring' => $xoops_root_path.'/class/xml/rpc/xmlrpctag.php', |
|
408 | + 'xoopsxmlrpcstruct' => $xoops_root_path.'/class/xml/rpc/xmlrpctag.php', |
|
409 | + 'xoopsxmlrpctag' => $xoops_root_path.'/class/xml/rpc/xmlrpctag.php', |
|
410 | + 'xoopsxmlrss2parser' => $xoops_root_path.'/class/xml/rss/xmlrss2parser.php', |
|
411 | + 'xoopszipdownloader' => $xoops_root_path.'/class/zipdownloader.php', |
|
412 | + 'zipfile' => $xoops_root_path.'/class/class.zipfile.php', |
|
413 | 413 | ); |
414 | 414 | } |
415 | 415 | |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | } else { |
435 | 435 | return false; |
436 | 436 | } |
437 | - if (self::fileExists($file = \XoopsBaseConfig::get('root-path') . '/modules/' . $dirname . '/include/autoload.php')) { |
|
437 | + if (self::fileExists($file = \XoopsBaseConfig::get('root-path').'/modules/'.$dirname.'/include/autoload.php')) { |
|
438 | 438 | if (!$configs = include $file) { |
439 | 439 | return false; |
440 | 440 | } |
@@ -481,8 +481,8 @@ discard block |
||
481 | 481 | return true; |
482 | 482 | } |
483 | 483 | |
484 | - $file = str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php'; |
|
485 | - if (!self::loadFile(\XoopsBaseConfig::get('lib-path') . DIRECTORY_SEPARATOR . $file)) { |
|
484 | + $file = str_replace('_', DIRECTORY_SEPARATOR, $class).'.php'; |
|
485 | + if (!self::loadFile(\XoopsBaseConfig::get('lib-path').DIRECTORY_SEPARATOR.$file)) { |
|
486 | 486 | return false; |
487 | 487 | } |
488 | 488 | |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | static $libPath = null; |
544 | 544 | |
545 | 545 | if ($libPath === null) { |
546 | - $loaderPath = $path . '/vendor/autoload.php'; |
|
546 | + $loaderPath = $path.'/vendor/autoload.php'; |
|
547 | 547 | if (self::fileExists($loaderPath)) { |
548 | 548 | $libPath = $path; |
549 | 549 | include $loaderPath; |
@@ -113,18 +113,18 @@ discard block |
||
113 | 113 | $stop = ''; |
114 | 114 | // Invalid email address |
115 | 115 | if (!$xoops->checkEmail($email)) { |
116 | - $stop .= XoopsLocale::E_INVALID_EMAIL . '<br />'; |
|
116 | + $stop .= XoopsLocale::E_INVALID_EMAIL.'<br />'; |
|
117 | 117 | } |
118 | 118 | if (strrpos($email, ' ') > 0) { |
119 | - $stop .= XoopsLocale::E_EMAIL_SHOULD_NOT_CONTAIN_SPACES . '<br />'; |
|
119 | + $stop .= XoopsLocale::E_EMAIL_SHOULD_NOT_CONTAIN_SPACES.'<br />'; |
|
120 | 120 | } |
121 | 121 | // Check forbidden email address if current operator is not an administrator |
122 | 122 | if (!$xoops->userIsAdmin) { |
123 | 123 | $bad_emails = $xoops->getConfig('bad_emails'); |
124 | 124 | if (!empty($bad_emails)) { |
125 | 125 | foreach ($bad_emails as $be) { |
126 | - if (!empty($be) && preg_match('/' . $be . '/i', $email)) { |
|
127 | - $stop .= XoopsLocale::E_INVALID_EMAIL . '<br />'; |
|
126 | + if (!empty($be) && preg_match('/'.$be.'/i', $email)) { |
|
127 | + $stop .= XoopsLocale::E_INVALID_EMAIL.'<br />'; |
|
128 | 128 | break; |
129 | 129 | } |
130 | 130 | } |
@@ -133,23 +133,23 @@ discard block |
||
133 | 133 | // $uname = XoopsLocale::trim($uname); |
134 | 134 | // no controls, puctuation, symbols, spaces or invisible separators |
135 | 135 | if (!preg_match('/^[^\p{C}\p{P}\p{S}\p{Z}]+$/u', $uname)) { |
136 | - $stop .= XoopsLocale::E_INVALID_USERNAME . '<br />'; |
|
136 | + $stop .= XoopsLocale::E_INVALID_USERNAME.'<br />'; |
|
137 | 137 | } |
138 | 138 | // Check uname settings if current operator is not an administrator |
139 | 139 | if (!$xoops->userIsAdmin) { |
140 | 140 | $maxuname = $xoops->getConfig('maxuname'); |
141 | 141 | if (!empty($maxuname) && mb_strlen($uname) > $maxuname) { |
142 | - $stop .= sprintf(XoopsLocale::EF_USERNAME_MUST_BE_LESS_THAN, $maxuname) . '<br />'; |
|
142 | + $stop .= sprintf(XoopsLocale::EF_USERNAME_MUST_BE_LESS_THAN, $maxuname).'<br />'; |
|
143 | 143 | } |
144 | 144 | $minuname = $xoops->getConfig('minuname'); |
145 | 145 | if (!empty($minuname) && mb_strlen($uname) < $minuname) { |
146 | - $stop .= sprintf(XoopsLocale::EF_USERNAME_MUST_BE_MORE_THAN, $minuname) . '<br />'; |
|
146 | + $stop .= sprintf(XoopsLocale::EF_USERNAME_MUST_BE_MORE_THAN, $minuname).'<br />'; |
|
147 | 147 | } |
148 | 148 | $bad_unames = $xoops->getConfig('bad_unames'); |
149 | 149 | if (!empty($bad_unames)) { |
150 | 150 | foreach ($bad_unames as $bu) { |
151 | - if (!empty($bu) && preg_match('/' . $bu . '/i', $uname)) { |
|
152 | - $stop .= XoopsLocale::E_NAME_IS_RESERVED . '<br />'; |
|
151 | + if (!empty($bu) && preg_match('/'.$bu.'/i', $uname)) { |
|
152 | + $stop .= XoopsLocale::E_NAME_IS_RESERVED.'<br />'; |
|
153 | 153 | break; |
154 | 154 | } |
155 | 155 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | } |
167 | 167 | $count = $user_handler->getCount($criteria); |
168 | 168 | if ($count > 0) { |
169 | - $stop .= XoopsLocale::E_USERNAME_TAKEN . '<br />'; |
|
169 | + $stop .= XoopsLocale::E_USERNAME_TAKEN.'<br />'; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | $criteria = new CriteriaCompo(new Criteria('email', $email)); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | } |
176 | 176 | $count = $user_handler->getCount($criteria); |
177 | 177 | if ($count > 0) { |
178 | - $stop .= XoopsLocale::E_EMAIL_TAKEN . '<br />'; |
|
178 | + $stop .= XoopsLocale::E_EMAIL_TAKEN.'<br />'; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | // If password is not set, skip password validation |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | } |
185 | 185 | |
186 | 186 | if (empty($pass) || empty($vpass)) { |
187 | - $stop .= XoopsLocale::E_MUST_PROVIDE_PASSWORD . '<br />'; |
|
187 | + $stop .= XoopsLocale::E_MUST_PROVIDE_PASSWORD.'<br />'; |
|
188 | 188 | } |
189 | 189 | if (isset($pass) && isset($vpass) && ($pass != $vpass)) { |
190 | - $stop .= XoopsLocale::E_PASSWORDS_MUST_MATCH . '<br />'; |
|
190 | + $stop .= XoopsLocale::E_PASSWORDS_MUST_MATCH.'<br />'; |
|
191 | 191 | } else { |
192 | 192 | $minpass = $xoops->getConfig('minpass'); |
193 | 193 | if (($pass != '') && (!empty($minpass)) && (mb_strlen($pass) < $minpass)) { |
194 | - $stop .= sprintf(XoopsLocale::EF_PASSWORD_MUST_BE_GREATER_THAN, $minpass) . '<br />'; |
|
194 | + $stop .= sprintf(XoopsLocale::EF_PASSWORD_MUST_BE_GREATER_THAN, $minpass).'<br />'; |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | return $stop; |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | $users = array(); |
270 | 270 | if (count($userids) > 0) { |
271 | 271 | $criteria = new CriteriaCompo(new Criteria('level', 0, '>')); |
272 | - $criteria->add(new Criteria('uid', "('" . implode(',', array_unique($userids)) . "')", 'IN')); |
|
272 | + $criteria->add(new Criteria('uid', "('".implode(',', array_unique($userids))."')", 'IN')); |
|
273 | 273 | |
274 | 274 | $user_handler = $xoops->getHandlerUser(); |
275 | 275 | if (!$rows = $user_handler->getAll($criteria, array('uid', 'uname', 'name'), false, true)) { |
@@ -282,8 +282,8 @@ discard block |
||
282 | 282 | $users[$uid] = $myts->htmlSpecialChars($row['uname']); |
283 | 283 | } |
284 | 284 | if ($linked) { |
285 | - $users[$uid] = '<a href="' . \XoopsBaseConfig::get('url') . '/userinfo.php?uid=' |
|
286 | - . $uid . '" title="' . $users[$uid] . '">' . $users[$uid] . '</a>'; |
|
285 | + $users[$uid] = '<a href="'.\XoopsBaseConfig::get('url').'/userinfo.php?uid=' |
|
286 | + . $uid.'" title="'.$users[$uid].'">'.$users[$uid].'</a>'; |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | } |
@@ -318,8 +318,8 @@ discard block |
||
318 | 318 | $username = $user->getVar('uname'); |
319 | 319 | } |
320 | 320 | if (!empty($linked)) { |
321 | - $username = '<a href="' . \XoopsBaseConfig::get('url') . '/userinfo.php?uid=' |
|
322 | - . $userid . '" title="' . $username . '">' . $username . '</a>'; |
|
321 | + $username = '<a href="'.\XoopsBaseConfig::get('url').'/userinfo.php?uid=' |
|
322 | + . $userid.'" title="'.$username.'">'.$username.'</a>'; |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | } |