@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | function xoops_getHandler($name, $optional = false) |
| 67 | 67 | { |
| 68 | - xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 68 | + xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 69 | 69 | // Also can use: dedicated alias, i.e. $handler = $xoops->getHandlerConfig($optional); |
| 70 | - $handler = Factory::newSpec()->scheme('kernel')->name($name)->optional((bool) $optional)->build(); |
|
| 70 | + $handler = Factory::newSpec()->scheme('kernel')->name($name)->optional((bool)$optional)->build(); |
|
| 71 | 71 | return $handler; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | function xoops_getModuleHandler($name = null, $module_dir = null, $optional = false) |
| 82 | 82 | { |
| 83 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 83 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 84 | 84 | return $xoops->getModuleHandler($name, $module_dir, $optional); |
| 85 | 85 | } |
| 86 | 86 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | function xoops_load($name, $type = 'core') |
| 97 | 97 | { |
| 98 | - xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 98 | + xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 99 | 99 | // Note: most classes will autoload (i.e. $nav = new XoopsPageNav();) with no need for xoops_load() |
| 100 | 100 | return XoopsLoad::load($name, $type); |
| 101 | 101 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | function xoops_loadLanguage($name, $domain = '', $language = null) |
| 112 | 112 | { |
| 113 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 113 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 114 | 114 | return $xoops->loadLanguage($name, $domain, $language); |
| 115 | 115 | } |
| 116 | 116 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | function xoops_getActiveModules() |
| 122 | 122 | { |
| 123 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 123 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 124 | 124 | return $xoops->getActiveModules(); |
| 125 | 125 | } |
| 126 | 126 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | function xoops_setActiveModules() |
| 132 | 132 | { |
| 133 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 133 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 134 | 134 | return $xoops->setActiveModules(); |
| 135 | 135 | } |
| 136 | 136 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | function xoops_isActiveModule($dirname) |
| 143 | 143 | { |
| 144 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 144 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 145 | 145 | return $xoops->isActiveModule($dirname); |
| 146 | 146 | } |
| 147 | 147 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | function xoops_header($closehead = true) |
| 154 | 154 | { |
| 155 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 155 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 156 | 156 | $xoops->simpleHeader($closehead); |
| 157 | 157 | } |
| 158 | 158 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | function xoops_footer() |
| 164 | 164 | { |
| 165 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 165 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 166 | 166 | $xoops->simpleFooter(); |
| 167 | 167 | } |
| 168 | 168 | |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | function xoops_error($msg, $title = '') |
| 176 | 176 | { |
| 177 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 177 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 178 | 178 | echo $xoops->alert('error', $msg, $title); |
| 179 | 179 | } |
| 180 | 180 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | function xoops_result($msg, $title = '') |
| 188 | 188 | { |
| 189 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 189 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 190 | 190 | echo $xoops->alert('info', $msg, $title); |
| 191 | 191 | } |
| 192 | 192 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | function xoops_confirm($hiddens, $action, $msg, $submit = '', $addtoken = true) |
| 203 | 203 | { |
| 204 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 204 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 205 | 205 | echo $xoops->confirm($hiddens, $action, $msg, $submit, $addtoken); |
| 206 | 206 | } |
| 207 | 207 | |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | function xoops_getUserTimestamp($time, $timeoffset = '') |
| 215 | 215 | { |
| 216 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 216 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 217 | 217 | return $xoops->getUserTimestamp($time); |
| 218 | 218 | } |
| 219 | 219 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | function formatTimestamp($time, $format = 'l', $timeoffset = '') |
| 228 | 228 | { |
| 229 | - xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 229 | + xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 230 | 230 | return XoopsLocale::formatTimestamp($time, $format); |
| 231 | 231 | } |
| 232 | 232 | |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | function userTimeToServerTime($timestamp, $userTZ = null) |
| 240 | 240 | { |
| 241 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 241 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 242 | 242 | return $xoops->userTimeToServerTime($timestamp, $userTZ); |
| 243 | 243 | } |
| 244 | 244 | |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | */ |
| 249 | 249 | function xoops_makepass() |
| 250 | 250 | { |
| 251 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 251 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 252 | 252 | return $xoops->makePass(); |
| 253 | 253 | } |
| 254 | 254 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | function checkEmail($email, $antispam = false) |
| 262 | 262 | { |
| 263 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 263 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 264 | 264 | return $xoops->checkEmail($email, $antispam); |
| 265 | 265 | } |
| 266 | 266 | |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | */ |
| 272 | 272 | function formatURL($url) |
| 273 | 273 | { |
| 274 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 274 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 275 | 275 | return $xoops->formatURL($url); |
| 276 | 276 | } |
| 277 | 277 | |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | */ |
| 282 | 282 | function xoops_getbanner() |
| 283 | 283 | { |
| 284 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 284 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 285 | 285 | return $xoops->getBanner(); |
| 286 | 286 | } |
| 287 | 287 | |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | */ |
| 298 | 298 | function redirect_header($url, $time = 3, $message = '', $addredirect = true, $allowExternalLink = false) |
| 299 | 299 | { |
| 300 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 300 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 301 | 301 | $xoops->redirect($url, $time, $message, $addredirect, $allowExternalLink); |
| 302 | 302 | } |
| 303 | 303 | |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | */ |
| 309 | 309 | function xoops_getenv($key) |
| 310 | 310 | { |
| 311 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 311 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 312 | 312 | return $xoops->getEnv($key); |
| 313 | 313 | } |
| 314 | 314 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | */ |
| 320 | 320 | function xoops_getcss($theme = '') |
| 321 | 321 | { |
| 322 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 322 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 323 | 323 | return $xoops->getCss($theme); |
| 324 | 324 | } |
| 325 | 325 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | */ |
| 330 | 330 | function xoops_getMailer() |
| 331 | 331 | { |
| 332 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 332 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 333 | 333 | return $xoops->getMailer(); |
| 334 | 334 | } |
| 335 | 335 | |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | function xoops_getrank($rank_id = 0, $posts = 0) |
| 343 | 343 | { |
| 344 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 344 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 345 | 345 | return $xoops->service('userrank')->getUserRank(['rank' => $rank_id, 'posts' => $posts, 'uid' => 0])->getValue(); |
| 346 | 346 | } |
| 347 | 347 | |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | */ |
| 356 | 356 | function xoops_substr($str, $start, $length, $trimmarker = '...') |
| 357 | 357 | { |
| 358 | - xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 358 | + xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 359 | 359 | return XoopsLocale::substr($str, $start, $length, $trimmarker); |
| 360 | 360 | } |
| 361 | 361 | |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | */ |
| 423 | 423 | function xoops_groupperm_deletebymoditem($module_id, $perm_name, $item_id = null) |
| 424 | 424 | { |
| 425 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 425 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 426 | 426 | return $xoops->getHandlerGroupPermission()->deleteByModule($module_id, $perm_name, $item_id); |
| 427 | 427 | } |
| 428 | 428 | |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | */ |
| 434 | 434 | function xoops_utf8_encode(&$text) |
| 435 | 435 | { |
| 436 | - xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 436 | + xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 437 | 437 | $text = XoopsLocale::utf8_encode($text); |
| 438 | 438 | } |
| 439 | 439 | |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | */ |
| 445 | 445 | function xoops_convert_encoding(&$text) |
| 446 | 446 | { |
| 447 | - xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 447 | + xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 448 | 448 | $text = XoopsLocale::utf8_encode($text); |
| 449 | 449 | } |
| 450 | 450 | |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | */ |
| 456 | 456 | function xoops_trim($text) |
| 457 | 457 | { |
| 458 | - xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 458 | + xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 459 | 459 | return XoopsLocale::trim($text); |
| 460 | 460 | } |
| 461 | 461 | |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | */ |
| 467 | 467 | function xoops_getOption($option) |
| 468 | 468 | { |
| 469 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 469 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 470 | 470 | return $xoops->getOption($option); |
| 471 | 471 | } |
| 472 | 472 | |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | */ |
| 479 | 479 | function xoops_getConfigOption($option, $type = 'XOOPS_CONF') |
| 480 | 480 | { |
| 481 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 481 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 482 | 482 | return $xoops->getConfig($option); |
| 483 | 483 | } |
| 484 | 484 | |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | */ |
| 491 | 491 | function xoops_setConfigOption($option, $new = null) |
| 492 | 492 | { |
| 493 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 493 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 494 | 494 | $xoops->setConfig($option, $new); |
| 495 | 495 | } |
| 496 | 496 | |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | */ |
| 503 | 503 | function xoops_getModuleOption($option, $dirname = '') |
| 504 | 504 | { |
| 505 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 505 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 506 | 506 | return $xoops->getModuleConfig($option, $dirname); |
| 507 | 507 | } |
| 508 | 508 | |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | */ |
| 515 | 515 | function xoops_getBaseDomain($url, $debug = 0) |
| 516 | 516 | { |
| 517 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 517 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 518 | 518 | return $xoops->getBaseDomain($url); |
| 519 | 519 | } |
| 520 | 520 | |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | */ |
| 526 | 526 | function xoops_getUrlDomain($url) |
| 527 | 527 | { |
| 528 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 528 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 529 | 529 | return $xoops->getBaseDomain($url, true); |
| 530 | 530 | } |
| 531 | 531 | |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | */ |
| 539 | 539 | function xoops_template_touch($tpl_id, $clear_old = true) |
| 540 | 540 | { |
| 541 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 541 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 542 | 542 | return $xoops->templateTouch($tpl_id); |
| 543 | 543 | } |
| 544 | 544 | |
@@ -550,6 +550,6 @@ discard block |
||
| 550 | 550 | */ |
| 551 | 551 | function xoops_template_clear_module_cache($mid) |
| 552 | 552 | { |
| 553 | - $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ + 1)); |
|
| 553 | + $xoops = xoops_functions_php_deprecated(__FUNCTION__, __FILE__, (__LINE__ +1)); |
|
| 554 | 554 | $xoops->templateClearModuleCache($mid); |
| 555 | 555 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | function xoops_cp_header() |
| 27 | 27 | { |
| 28 | 28 | $xoops = Xoops::getInstance(); |
| 29 | - $xoops->deprecated('xoops_cp_header() is deprecated. See how to replace it in file ' . __FILE__ . ' line ' . __LINE__); |
|
| 29 | + $xoops->deprecated('xoops_cp_header() is deprecated. See how to replace it in file '.__FILE__.' line '.__LINE__); |
|
| 30 | 30 | $xoops->header($xoops->getOption('template_main')); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -38,6 +38,6 @@ discard block |
||
| 38 | 38 | function xoops_cp_footer() |
| 39 | 39 | { |
| 40 | 40 | $xoops = Xoops::getInstance(); |
| 41 | - $xoops->deprecated('xoops_cp_footer() is deprecated. See how to replace it in file ' . __FILE__ . ' line ' . __LINE__); |
|
| 41 | + $xoops->deprecated('xoops_cp_footer() is deprecated. See how to replace it in file '.__FILE__.' line '.__LINE__); |
|
| 42 | 42 | $xoops->footer(); |
| 43 | 43 | } |
@@ -19,5 +19,5 @@ |
||
| 19 | 19 | * Define XOOPS version |
| 20 | 20 | * @todo This should be eliminated in favor of \Xoops::VERSION, but it is still required in installer |
| 21 | 21 | */ |
| 22 | -$XoopsIncludeVersionString = class_exists('\Xoops', false) ? \Xoops::VERSION : 'XOOPS 2.6.0'; |
|
| 22 | +$XoopsIncludeVersionString = class_exists('\Xoops', false) ? \Xoops::VERSION : 'XOOPS 2.6.0'; |
|
| 23 | 23 | define('XOOPS_VERSION', $XoopsIncludeVersionString); |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | $xoops_url = \XoopsBaseConfig::get('url'); |
| 3 | 3 | ?> |
| 4 | -<link rel="stylesheet" type="text/css" media="all" href="<?php echo $xoops_url;?>/include/calendar-blue.css"/> |
|
| 5 | -<script type="text/javascript" src="<?php echo $xoops_url . '/include/calendar.js';?>"></script> |
|
| 4 | +<link rel="stylesheet" type="text/css" media="all" href="<?php echo $xoops_url; ?>/include/calendar-blue.css"/> |
|
| 5 | +<script type="text/javascript" src="<?php echo $xoops_url.'/include/calendar.js'; ?>"></script> |
|
| 6 | 6 | <script type="text/javascript"> |
| 7 | 7 | <!-- |
| 8 | 8 | var calendar = null; |
@@ -54,47 +54,47 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | Calendar._DN = new Array |
| 57 | - ("<?php echo XoopsLocale::L_DAY_SUNDAY;?>", |
|
| 58 | - "<?php echo XoopsLocale::L_DAY_MONDAY;?>", |
|
| 59 | - "<?php echo XoopsLocale::L_DAY_TUESDAY;?>", |
|
| 60 | - "<?php echo XoopsLocale::L_DAY_WEDNESDAY;?>", |
|
| 61 | - "<?php echo XoopsLocale::L_DAY_THURSDAY;?>", |
|
| 62 | - "<?php echo XoopsLocale::L_DAY_FRIDAY;?>", |
|
| 63 | - "<?php echo XoopsLocale::L_DAY_SATURDAY;?>", |
|
| 64 | - "<?php echo XoopsLocale::L_DAY_SUNDAY;?>"); |
|
| 57 | + ("<?php echo XoopsLocale::L_DAY_SUNDAY; ?>", |
|
| 58 | + "<?php echo XoopsLocale::L_DAY_MONDAY; ?>", |
|
| 59 | + "<?php echo XoopsLocale::L_DAY_TUESDAY; ?>", |
|
| 60 | + "<?php echo XoopsLocale::L_DAY_WEDNESDAY; ?>", |
|
| 61 | + "<?php echo XoopsLocale::L_DAY_THURSDAY; ?>", |
|
| 62 | + "<?php echo XoopsLocale::L_DAY_FRIDAY; ?>", |
|
| 63 | + "<?php echo XoopsLocale::L_DAY_SATURDAY; ?>", |
|
| 64 | + "<?php echo XoopsLocale::L_DAY_SUNDAY; ?>"); |
|
| 65 | 65 | Calendar._MN = new Array |
| 66 | - ("<?php echo XoopsLocale::L_MONTH_JANUARY;?>", |
|
| 67 | - "<?php echo XoopsLocale::L_MONTH_FEBRUARY;?>", |
|
| 68 | - "<?php echo XoopsLocale::L_MONTH_MARCH;?>", |
|
| 69 | - "<?php echo XoopsLocale::L_MONTH_APRIL;?>", |
|
| 70 | - "<?php echo XoopsLocale::L_MONTH_MAY;?>", |
|
| 71 | - "<?php echo XoopsLocale::L_MONTH_JUNE;?>", |
|
| 72 | - "<?php echo XoopsLocale::L_MONTH_JULY;?>", |
|
| 73 | - "<?php echo XoopsLocale::L_MONTH_AUGUST;?>", |
|
| 74 | - "<?php echo XoopsLocale::L_MONTH_SEPTEMBER;?>", |
|
| 75 | - "<?php echo XoopsLocale::L_MONTH_OCTOBER;?>", |
|
| 76 | - "<?php echo XoopsLocale::L_MONTH_NOVEMBER;?>", |
|
| 77 | - "<?php echo XoopsLocale::L_MONTH_DECEMBER;?>"); |
|
| 66 | + ("<?php echo XoopsLocale::L_MONTH_JANUARY; ?>", |
|
| 67 | + "<?php echo XoopsLocale::L_MONTH_FEBRUARY; ?>", |
|
| 68 | + "<?php echo XoopsLocale::L_MONTH_MARCH; ?>", |
|
| 69 | + "<?php echo XoopsLocale::L_MONTH_APRIL; ?>", |
|
| 70 | + "<?php echo XoopsLocale::L_MONTH_MAY; ?>", |
|
| 71 | + "<?php echo XoopsLocale::L_MONTH_JUNE; ?>", |
|
| 72 | + "<?php echo XoopsLocale::L_MONTH_JULY; ?>", |
|
| 73 | + "<?php echo XoopsLocale::L_MONTH_AUGUST; ?>", |
|
| 74 | + "<?php echo XoopsLocale::L_MONTH_SEPTEMBER; ?>", |
|
| 75 | + "<?php echo XoopsLocale::L_MONTH_OCTOBER; ?>", |
|
| 76 | + "<?php echo XoopsLocale::L_MONTH_NOVEMBER; ?>", |
|
| 77 | + "<?php echo XoopsLocale::L_MONTH_DECEMBER; ?>"); |
|
| 78 | 78 | |
| 79 | 79 | Calendar._TT = {}; |
| 80 | - Calendar._TT["TOGGLE"] = "<?php echo XoopsLocale::TOGGLE_FIRST_DAY_OF_WEEK;?>"; |
|
| 81 | - Calendar._TT["PREV_YEAR"] = "<?php echo XoopsLocale::PREVIOUS_YEAR;?>"; |
|
| 82 | - Calendar._TT["PREV_MONTH"] = "<?php echo XoopsLocale::PREVIOUS_MONTH;?>"; |
|
| 83 | - Calendar._TT["GO_TODAY"] = "<?php echo XoopsLocale::GO_TODAY;?>"; |
|
| 84 | - Calendar._TT["NEXT_MONTH"] = "<?php echo XoopsLocale::NEXT_MONTH;?>"; |
|
| 85 | - Calendar._TT["NEXT_YEAR"] = "<?php echo XoopsLocale::NEXT_YEAR;?>"; |
|
| 86 | - Calendar._TT["SEL_DATE"] = "<?php echo XoopsLocale::SELECT_DATE;?>"; |
|
| 87 | - Calendar._TT["DRAG_TO_MOVE"] = "<?php echo XoopsLocale::DRAG_TO_MOVE;?>"; |
|
| 88 | - Calendar._TT["PART_TODAY"] = "(<?php echo XoopsLocale::TODAY;?>)"; |
|
| 89 | - Calendar._TT["MON_FIRST"] = "<?php echo XoopsLocale::DISPLAY_MONDAY_FIRST;?>"; |
|
| 90 | - Calendar._TT["SUN_FIRST"] = "<?php echo XoopsLocale::DISPLAY_SUNDAY_FIRST;?>"; |
|
| 91 | - Calendar._TT["CLOSE"] = "<?php echo XoopsLocale::A_CLOSE;?>"; |
|
| 92 | - Calendar._TT["TODAY"] = "<?php echo XoopsLocale::TODAY;?>"; |
|
| 80 | + Calendar._TT["TOGGLE"] = "<?php echo XoopsLocale::TOGGLE_FIRST_DAY_OF_WEEK; ?>"; |
|
| 81 | + Calendar._TT["PREV_YEAR"] = "<?php echo XoopsLocale::PREVIOUS_YEAR; ?>"; |
|
| 82 | + Calendar._TT["PREV_MONTH"] = "<?php echo XoopsLocale::PREVIOUS_MONTH; ?>"; |
|
| 83 | + Calendar._TT["GO_TODAY"] = "<?php echo XoopsLocale::GO_TODAY; ?>"; |
|
| 84 | + Calendar._TT["NEXT_MONTH"] = "<?php echo XoopsLocale::NEXT_MONTH; ?>"; |
|
| 85 | + Calendar._TT["NEXT_YEAR"] = "<?php echo XoopsLocale::NEXT_YEAR; ?>"; |
|
| 86 | + Calendar._TT["SEL_DATE"] = "<?php echo XoopsLocale::SELECT_DATE; ?>"; |
|
| 87 | + Calendar._TT["DRAG_TO_MOVE"] = "<?php echo XoopsLocale::DRAG_TO_MOVE; ?>"; |
|
| 88 | + Calendar._TT["PART_TODAY"] = "(<?php echo XoopsLocale::TODAY; ?>)"; |
|
| 89 | + Calendar._TT["MON_FIRST"] = "<?php echo XoopsLocale::DISPLAY_MONDAY_FIRST; ?>"; |
|
| 90 | + Calendar._TT["SUN_FIRST"] = "<?php echo XoopsLocale::DISPLAY_SUNDAY_FIRST; ?>"; |
|
| 91 | + Calendar._TT["CLOSE"] = "<?php echo XoopsLocale::A_CLOSE; ?>"; |
|
| 92 | + Calendar._TT["TODAY"] = "<?php echo XoopsLocale::TODAY; ?>"; |
|
| 93 | 93 | |
| 94 | 94 | // date formats |
| 95 | 95 | // todo, strings not defined bellow? |
| 96 | - Calendar._TT["DEF_DATE_FORMAT"] = "<?php echo _CAL_DEF_DATE_FORMAT;?>"; |
|
| 97 | - Calendar._TT["TT_DATE_FORMAT"] = "<?php echo _CAL_TT_DATE_FORMAT;?>"; |
|
| 96 | + Calendar._TT["DEF_DATE_FORMAT"] = "<?php echo _CAL_DEF_DATE_FORMAT; ?>"; |
|
| 97 | + Calendar._TT["TT_DATE_FORMAT"] = "<?php echo _CAL_TT_DATE_FORMAT; ?>"; |
|
| 98 | 98 | |
| 99 | 99 | Calendar._TT["WK"] = ""; |
| 100 | 100 | //--> |
@@ -1,8 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -define('_AM_XMF_MODULE_NOTFOUND','Please install or reactivate %1$s module. Minimum version required: %2$s'); |
|
| 4 | -define('_AM_XMF_MODULE_VERSION','Minimum %1$s module version required: %2$s (your version is %3$s)'); |
|
| 3 | +define('_AM_XMF_MODULE_NOTFOUND', 'Please install or reactivate %1$s module. Minimum version required: %2$s'); |
|
| 4 | +define('_AM_XMF_MODULE_VERSION', 'Minimum %1$s module version required: %2$s (your version is %3$s)'); |
|
| 5 | 5 | define('_AM_XMF_MODULE_INSTALLED', 'The module \'%s\' is installed!'); |
| 6 | 6 | define('_AM_XMF_MODULE_NOT_INSTALLED', 'The module \'%s\' is not installed!'); |
| 7 | 7 | |
| 8 | -define('_DB_XMF_TABLE_IS_NOT_DEFINED','Table is not defined'); |
|
| 8 | +define('_DB_XMF_TABLE_IS_NOT_DEFINED', 'Table is not defined'); |
|
@@ -156,7 +156,7 @@ |
||
| 156 | 156 | if (!isset($this->_tempArr[$name])) { |
| 157 | 157 | $this->_tempArr[$name] = $value; |
| 158 | 158 | } else { |
| 159 | - $this->_tempArr[$name] .= $delim . $value; |
|
| 159 | + $this->_tempArr[$name] .= $delim.$value; |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | // using proxy, send entire URI |
| 150 | 150 | $this->_httprequest($URI, $fp, $URI, $this->_httpmethod); |
| 151 | 151 | } else { |
| 152 | - $path = $URI_PARTS["path"] . ($URI_PARTS["query"] ? "?" . $URI_PARTS["query"] : ""); |
|
| 152 | + $path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : ""); |
|
| 153 | 153 | // no proxy, send only the path |
| 154 | 154 | $this->_httprequest($path, $fp, $URI, $this->_httpmethod); |
| 155 | 155 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | /* url was redirected, check if we've hit the max depth */ |
| 161 | 161 | if ($this->maxredirs > $this->_redirectdepth) { |
| 162 | 162 | // only follow redirect if it's on this site, or offsiteok is true |
| 163 | - if (preg_match("|^https?://" . preg_quote($this->host) . "|i", $this->_redirectaddr) || $this->offsiteok) { |
|
| 163 | + if (preg_match("|^https?://".preg_quote($this->host)."|i", $this->_redirectaddr) || $this->offsiteok) { |
|
| 164 | 164 | /* follow the redirect */ |
| 165 | 165 | $this->_redirectdepth++; |
| 166 | 166 | $this->lastredirectaddr = $this->_redirectaddr; |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | break; |
| 189 | 189 | default: |
| 190 | 190 | // not a valid protocol |
| 191 | - $this->error = 'Invalid protocol "' . $URI_PARTS["scheme"] . '"\n'; |
|
| 191 | + $this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n'; |
|
| 192 | 192 | return false; |
| 193 | 193 | break; |
| 194 | 194 | } |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | // using proxy, send entire URI |
| 240 | 240 | $this->_httprequest($URI, $fp, $URI, $this->_submit_method, $this->_submit_type, $postdata); |
| 241 | 241 | } else { |
| 242 | - $path = $URI_PARTS["path"] . ($URI_PARTS["query"] ? "?" . $URI_PARTS["query"] : ""); |
|
| 242 | + $path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : ""); |
|
| 243 | 243 | // no proxy, send only the path |
| 244 | 244 | $this->_httprequest($path, $fp, $URI, $this->_submit_method, $this->_submit_type, $postdata); |
| 245 | 245 | } |
@@ -249,11 +249,11 @@ discard block |
||
| 249 | 249 | if ($this->_redirectaddr) { |
| 250 | 250 | /* url was redirected, check if we've hit the max depth */ |
| 251 | 251 | if ($this->maxredirs > $this->_redirectdepth) { |
| 252 | - if (!preg_match("|^" . $URI_PARTS["scheme"] . "://|", $this->_redirectaddr)) |
|
| 253 | - $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr, $URI_PARTS["scheme"] . "://" . $URI_PARTS["host"]); |
|
| 252 | + if (!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr)) |
|
| 253 | + $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr, $URI_PARTS["scheme"]."://".$URI_PARTS["host"]); |
|
| 254 | 254 | |
| 255 | 255 | // only follow redirect if it's on this site, or offsiteok is true |
| 256 | - if (preg_match("|^https?://" . preg_quote($this->host) . "|i", $this->_redirectaddr) || $this->offsiteok) { |
|
| 256 | + if (preg_match("|^https?://".preg_quote($this->host)."|i", $this->_redirectaddr) || $this->offsiteok) { |
|
| 257 | 257 | /* follow the redirect */ |
| 258 | 258 | $this->_redirectdepth++; |
| 259 | 259 | $this->lastredirectaddr = $this->_redirectaddr; |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | break; |
| 286 | 286 | default: |
| 287 | 287 | // not a valid protocol |
| 288 | - $this->error = 'Invalid protocol "' . $URI_PARTS["scheme"] . '"\n'; |
|
| 288 | + $this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n'; |
|
| 289 | 289 | return false; |
| 290 | 290 | break; |
| 291 | 291 | } |
@@ -585,9 +585,9 @@ discard block |
||
| 585 | 585 | $match = preg_replace("|/$|", "", $match); |
| 586 | 586 | $match_part = parse_url($match); |
| 587 | 587 | $match_root = |
| 588 | - $match_part["scheme"] . "://" . $match_part["host"]; |
|
| 588 | + $match_part["scheme"]."://".$match_part["host"]; |
|
| 589 | 589 | |
| 590 | - $search = array("|^http://" . preg_quote($this->host) . "|i", |
|
| 590 | + $search = array("|^http://".preg_quote($this->host)."|i", |
|
| 591 | 591 | "|^(\/)|i", |
| 592 | 592 | "|^(?!http://)(?!mailto:)|i", |
| 593 | 593 | "|/\./|", |
@@ -595,8 +595,8 @@ discard block |
||
| 595 | 595 | ); |
| 596 | 596 | |
| 597 | 597 | $replace = array("", |
| 598 | - $match_root . "/", |
|
| 599 | - $match . "/", |
|
| 598 | + $match_root."/", |
|
| 599 | + $match."/", |
|
| 600 | 600 | "/", |
| 601 | 601 | "/" |
| 602 | 602 | ); |
@@ -625,17 +625,17 @@ discard block |
||
| 625 | 625 | $URI_PARTS = parse_url($URI); |
| 626 | 626 | if (empty($url)) |
| 627 | 627 | $url = "/"; |
| 628 | - $headers = $http_method . " " . $url . " " . $this->_httpversion . "\r\n"; |
|
| 628 | + $headers = $http_method." ".$url." ".$this->_httpversion."\r\n"; |
|
| 629 | 629 | if (!empty($this->host) && !isset($this->rawheaders['Host'])) { |
| 630 | - $headers .= "Host: " . $this->host; |
|
| 630 | + $headers .= "Host: ".$this->host; |
|
| 631 | 631 | if (!empty($this->port) && $this->port != '80') |
| 632 | - $headers .= ":" . $this->port; |
|
| 632 | + $headers .= ":".$this->port; |
|
| 633 | 633 | $headers .= "\r\n"; |
| 634 | 634 | } |
| 635 | 635 | if (!empty($this->agent)) |
| 636 | - $headers .= "User-Agent: " . $this->agent . "\r\n"; |
|
| 636 | + $headers .= "User-Agent: ".$this->agent."\r\n"; |
|
| 637 | 637 | if (!empty($this->accept)) |
| 638 | - $headers .= "Accept: " . $this->accept . "\r\n"; |
|
| 638 | + $headers .= "Accept: ".$this->accept."\r\n"; |
|
| 639 | 639 | if ($this->use_gzip) { |
| 640 | 640 | // make sure PHP was built with --with-zlib |
| 641 | 641 | // and we can handle gzipp'ed data |
@@ -643,13 +643,13 @@ discard block |
||
| 643 | 643 | $headers .= "Accept-encoding: gzip\r\n"; |
| 644 | 644 | } else { |
| 645 | 645 | trigger_error( |
| 646 | - "use_gzip is on, but PHP was built without zlib support." . |
|
| 646 | + "use_gzip is on, but PHP was built without zlib support.". |
|
| 647 | 647 | " Requesting file(s) without gzip encoding.", |
| 648 | 648 | E_USER_NOTICE); |
| 649 | 649 | } |
| 650 | 650 | } |
| 651 | 651 | if (!empty($this->referer)) |
| 652 | - $headers .= "Referer: " . $this->referer . "\r\n"; |
|
| 652 | + $headers .= "Referer: ".$this->referer."\r\n"; |
|
| 653 | 653 | if (!empty($this->cookies)) { |
| 654 | 654 | if (!is_array($this->cookies)) |
| 655 | 655 | $this->cookies = (array)$this->cookies; |
@@ -658,31 +658,31 @@ discard block |
||
| 658 | 658 | if (count($this->cookies) > 0) { |
| 659 | 659 | $cookie_headers .= 'Cookie: '; |
| 660 | 660 | foreach ($this->cookies as $cookieKey => $cookieVal) { |
| 661 | - $cookie_headers .= $cookieKey . "=" . urlencode($cookieVal) . "; "; |
|
| 661 | + $cookie_headers .= $cookieKey."=".urlencode($cookieVal)."; "; |
|
| 662 | 662 | } |
| 663 | - $headers .= substr($cookie_headers, 0, -2) . "\r\n"; |
|
| 663 | + $headers .= substr($cookie_headers, 0, -2)."\r\n"; |
|
| 664 | 664 | } |
| 665 | 665 | } |
| 666 | 666 | if (!empty($this->rawheaders)) { |
| 667 | 667 | if (!is_array($this->rawheaders)) |
| 668 | 668 | $this->rawheaders = (array)$this->rawheaders; |
| 669 | 669 | while (list($headerKey, $headerVal) = each($this->rawheaders)) |
| 670 | - $headers .= $headerKey . ": " . $headerVal . "\r\n"; |
|
| 670 | + $headers .= $headerKey.": ".$headerVal."\r\n"; |
|
| 671 | 671 | } |
| 672 | 672 | if (!empty($content_type)) { |
| 673 | 673 | $headers .= "Content-type: $content_type"; |
| 674 | 674 | if ($content_type == "multipart/form-data") |
| 675 | - $headers .= "; boundary=" . $this->_mime_boundary; |
|
| 675 | + $headers .= "; boundary=".$this->_mime_boundary; |
|
| 676 | 676 | $headers .= "\r\n"; |
| 677 | 677 | } |
| 678 | 678 | if (!empty($body)) |
| 679 | - $headers .= "Content-length: " . strlen($body) . "\r\n"; |
|
| 679 | + $headers .= "Content-length: ".strlen($body)."\r\n"; |
|
| 680 | 680 | if (!empty($this->user) || !empty($this->pass)) |
| 681 | - $headers .= "Authorization: Basic " . base64_encode($this->user . ":" . $this->pass) . "\r\n"; |
|
| 681 | + $headers .= "Authorization: Basic ".base64_encode($this->user.":".$this->pass)."\r\n"; |
|
| 682 | 682 | |
| 683 | 683 | //add proxy auth headers |
| 684 | 684 | if (!empty($this->proxy_user)) |
| 685 | - $headers .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode($this->proxy_user . ':' . $this->proxy_pass) . "\r\n"; |
|
| 685 | + $headers .= 'Proxy-Authorization: '.'Basic '.base64_encode($this->proxy_user.':'.$this->proxy_pass)."\r\n"; |
|
| 686 | 686 | |
| 687 | 687 | |
| 688 | 688 | $headers .= "\r\n"; |
@@ -692,7 +692,7 @@ discard block |
||
| 692 | 692 | socket_set_timeout($fp, $this->read_timeout); |
| 693 | 693 | $this->timed_out = false; |
| 694 | 694 | |
| 695 | - fwrite($fp, $headers . $body, strlen($headers . $body)); |
|
| 695 | + fwrite($fp, $headers.$body, strlen($headers.$body)); |
|
| 696 | 696 | |
| 697 | 697 | $this->_redirectaddr = false; |
| 698 | 698 | unset($this->headers); |
@@ -716,10 +716,10 @@ discard block |
||
| 716 | 716 | // look for :// in the Location header to see if hostname is included |
| 717 | 717 | if (!preg_match("|\:\/\/|", $matches[2])) { |
| 718 | 718 | // no host in the path, so prepend |
| 719 | - $this->_redirectaddr = $URI_PARTS["scheme"] . "://" . $this->host . ":" . $this->port; |
|
| 719 | + $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port; |
|
| 720 | 720 | // eliminate double slash |
| 721 | 721 | if (!preg_match("|^/|", $matches[2])) |
| 722 | - $this->_redirectaddr .= "/" . $matches[2]; |
|
| 722 | + $this->_redirectaddr .= "/".$matches[2]; |
|
| 723 | 723 | else |
| 724 | 724 | $this->_redirectaddr .= $matches[2]; |
| 725 | 725 | } else |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | if (($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i", $results, $match)) { |
| 772 | 772 | $this->results[] = $results; |
| 773 | 773 | for ($x = 0; $x < count($match[1]); $x++) |
| 774 | - $this->_frameurls[] = $this->_expandlinks($match[1][$x], $URI_PARTS["scheme"] . "://" . $this->host); |
|
| 774 | + $this->_frameurls[] = $this->_expandlinks($match[1][$x], $URI_PARTS["scheme"]."://".$this->host); |
|
| 775 | 775 | } // have we already fetched framed content? |
| 776 | 776 | elseif (is_array($this->results)) |
| 777 | 777 | $this->results[] = $results; |
@@ -858,14 +858,14 @@ discard block |
||
| 858 | 858 | $context_opts['ssl']['capath'] = $this->capath; |
| 859 | 859 | } |
| 860 | 860 | |
| 861 | - $host = 'ssl://' . $host; |
|
| 861 | + $host = 'ssl://'.$host; |
|
| 862 | 862 | } |
| 863 | 863 | |
| 864 | 864 | $context = stream_context_create($context_opts); |
| 865 | 865 | |
| 866 | 866 | if (version_compare(PHP_VERSION, '5.0.0', '>')) { |
| 867 | - if($this->scheme == 'http') |
|
| 868 | - $host = "tcp://" . $host; |
|
| 867 | + if ($this->scheme == 'http') |
|
| 868 | + $host = "tcp://".$host; |
|
| 869 | 869 | $fp = stream_socket_client( |
| 870 | 870 | "$host:$port", |
| 871 | 871 | $errno, |
@@ -897,7 +897,7 @@ discard block |
||
| 897 | 897 | case -5: |
| 898 | 898 | $this->error = "connection refused or timed out (-5)"; |
| 899 | 899 | default: |
| 900 | - $this->error = "connection failed (" . $errno . ")"; |
|
| 900 | + $this->error = "connection failed (".$errno.")"; |
|
| 901 | 901 | } |
| 902 | 902 | return false; |
| 903 | 903 | } |
@@ -938,26 +938,26 @@ discard block |
||
| 938 | 938 | while (list($key, $val) = each($formvars)) { |
| 939 | 939 | if (is_array($val) || is_object($val)) { |
| 940 | 940 | while (list($cur_key, $cur_val) = each($val)) { |
| 941 | - $postdata .= urlencode($key) . "[]=" . urlencode($cur_val) . "&"; |
|
| 941 | + $postdata .= urlencode($key)."[]=".urlencode($cur_val)."&"; |
|
| 942 | 942 | } |
| 943 | 943 | } else |
| 944 | - $postdata .= urlencode($key) . "=" . urlencode($val) . "&"; |
|
| 944 | + $postdata .= urlencode($key)."=".urlencode($val)."&"; |
|
| 945 | 945 | } |
| 946 | 946 | break; |
| 947 | 947 | |
| 948 | 948 | case "multipart/form-data": |
| 949 | - $this->_mime_boundary = "Snoopy" . md5(uniqid(microtime())); |
|
| 949 | + $this->_mime_boundary = "Snoopy".md5(uniqid(microtime())); |
|
| 950 | 950 | |
| 951 | 951 | reset($formvars); |
| 952 | 952 | while (list($key, $val) = each($formvars)) { |
| 953 | 953 | if (is_array($val) || is_object($val)) { |
| 954 | 954 | while (list($cur_key, $cur_val) = each($val)) { |
| 955 | - $postdata .= "--" . $this->_mime_boundary . "\r\n"; |
|
| 955 | + $postdata .= "--".$this->_mime_boundary."\r\n"; |
|
| 956 | 956 | $postdata .= "Content-Disposition: form-data; name=\"$key\[\]\"\r\n\r\n"; |
| 957 | 957 | $postdata .= "$cur_val\r\n"; |
| 958 | 958 | } |
| 959 | 959 | } else { |
| 960 | - $postdata .= "--" . $this->_mime_boundary . "\r\n"; |
|
| 960 | + $postdata .= "--".$this->_mime_boundary."\r\n"; |
|
| 961 | 961 | $postdata .= "Content-Disposition: form-data; name=\"$key\"\r\n\r\n"; |
| 962 | 962 | $postdata .= "$val\r\n"; |
| 963 | 963 | } |
@@ -974,12 +974,12 @@ discard block |
||
| 974 | 974 | fclose($fp); |
| 975 | 975 | $base_name = basename($file_name); |
| 976 | 976 | |
| 977 | - $postdata .= "--" . $this->_mime_boundary . "\r\n"; |
|
| 977 | + $postdata .= "--".$this->_mime_boundary."\r\n"; |
|
| 978 | 978 | $postdata .= "Content-Disposition: form-data; name=\"$field_name\"; filename=\"$base_name\"\r\n\r\n"; |
| 979 | 979 | $postdata .= "$file_content\r\n"; |
| 980 | 980 | } |
| 981 | 981 | } |
| 982 | - $postdata .= "--" . $this->_mime_boundary . "--\r\n"; |
|
| 982 | + $postdata .= "--".$this->_mime_boundary."--\r\n"; |
|
| 983 | 983 | break; |
| 984 | 984 | } |
| 985 | 985 | |
@@ -121,14 +121,18 @@ discard block |
||
| 121 | 121 | { |
| 122 | 122 | |
| 123 | 123 | $URI_PARTS = parse_url($URI); |
| 124 | - if (!empty($URI_PARTS["user"])) |
|
| 125 | - $this->user = $URI_PARTS["user"]; |
|
| 126 | - if (!empty($URI_PARTS["pass"])) |
|
| 127 | - $this->pass = $URI_PARTS["pass"]; |
|
| 128 | - if (empty($URI_PARTS["query"])) |
|
| 129 | - $URI_PARTS["query"] = ''; |
|
| 130 | - if (empty($URI_PARTS["path"])) |
|
| 131 | - $URI_PARTS["path"] = ''; |
|
| 124 | + if (!empty($URI_PARTS["user"])) { |
|
| 125 | + $this->user = $URI_PARTS["user"]; |
|
| 126 | + } |
|
| 127 | + if (!empty($URI_PARTS["pass"])) { |
|
| 128 | + $this->pass = $URI_PARTS["pass"]; |
|
| 129 | + } |
|
| 130 | + if (empty($URI_PARTS["query"])) { |
|
| 131 | + $URI_PARTS["query"] = ''; |
|
| 132 | + } |
|
| 133 | + if (empty($URI_PARTS["path"])) { |
|
| 134 | + $URI_PARTS["path"] = ''; |
|
| 135 | + } |
|
| 132 | 136 | |
| 133 | 137 | $fp = null; |
| 134 | 138 | |
@@ -142,8 +146,9 @@ discard block |
||
| 142 | 146 | case "http": |
| 143 | 147 | $this->scheme = strtolower($URI_PARTS["scheme"]); |
| 144 | 148 | $this->host = $URI_PARTS["host"]; |
| 145 | - if (!empty($URI_PARTS["port"])) |
|
| 146 | - $this->port = $URI_PARTS["port"]; |
|
| 149 | + if (!empty($URI_PARTS["port"])) { |
|
| 150 | + $this->port = $URI_PARTS["port"]; |
|
| 151 | + } |
|
| 147 | 152 | if ($this->_connect($fp)) { |
| 148 | 153 | if ($this->_isproxy) { |
| 149 | 154 | // using proxy, send entire URI |
@@ -177,8 +182,9 @@ discard block |
||
| 177 | 182 | if ($this->_framedepth < $this->maxframes) { |
| 178 | 183 | $this->fetch($frameurl); |
| 179 | 184 | $this->_framedepth++; |
| 180 | - } else |
|
| 181 | - break; |
|
| 185 | + } else { |
|
| 186 | + break; |
|
| 187 | + } |
|
| 182 | 188 | } |
| 183 | 189 | } |
| 184 | 190 | } else { |
@@ -213,14 +219,18 @@ discard block |
||
| 213 | 219 | $postdata = $this->_prepare_post_body($formvars, $formfiles); |
| 214 | 220 | |
| 215 | 221 | $URI_PARTS = parse_url($URI); |
| 216 | - if (!empty($URI_PARTS["user"])) |
|
| 217 | - $this->user = $URI_PARTS["user"]; |
|
| 218 | - if (!empty($URI_PARTS["pass"])) |
|
| 219 | - $this->pass = $URI_PARTS["pass"]; |
|
| 220 | - if (empty($URI_PARTS["query"])) |
|
| 221 | - $URI_PARTS["query"] = ''; |
|
| 222 | - if (empty($URI_PARTS["path"])) |
|
| 223 | - $URI_PARTS["path"] = ''; |
|
| 222 | + if (!empty($URI_PARTS["user"])) { |
|
| 223 | + $this->user = $URI_PARTS["user"]; |
|
| 224 | + } |
|
| 225 | + if (!empty($URI_PARTS["pass"])) { |
|
| 226 | + $this->pass = $URI_PARTS["pass"]; |
|
| 227 | + } |
|
| 228 | + if (empty($URI_PARTS["query"])) { |
|
| 229 | + $URI_PARTS["query"] = ''; |
|
| 230 | + } |
|
| 231 | + if (empty($URI_PARTS["path"])) { |
|
| 232 | + $URI_PARTS["path"] = ''; |
|
| 233 | + } |
|
| 224 | 234 | |
| 225 | 235 | switch (strtolower($URI_PARTS["scheme"])) { |
| 226 | 236 | case "https": |
@@ -232,8 +242,9 @@ discard block |
||
| 232 | 242 | case "http": |
| 233 | 243 | $this->scheme = strtolower($URI_PARTS["scheme"]); |
| 234 | 244 | $this->host = $URI_PARTS["host"]; |
| 235 | - if (!empty($URI_PARTS["port"])) |
|
| 236 | - $this->port = $URI_PARTS["port"]; |
|
| 245 | + if (!empty($URI_PARTS["port"])) { |
|
| 246 | + $this->port = $URI_PARTS["port"]; |
|
| 247 | + } |
|
| 237 | 248 | if ($this->_connect($fp)) { |
| 238 | 249 | if ($this->_isproxy) { |
| 239 | 250 | // using proxy, send entire URI |
@@ -249,18 +260,22 @@ discard block |
||
| 249 | 260 | if ($this->_redirectaddr) { |
| 250 | 261 | /* url was redirected, check if we've hit the max depth */ |
| 251 | 262 | if ($this->maxredirs > $this->_redirectdepth) { |
| 252 | - if (!preg_match("|^" . $URI_PARTS["scheme"] . "://|", $this->_redirectaddr)) |
|
| 253 | - $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr, $URI_PARTS["scheme"] . "://" . $URI_PARTS["host"]); |
|
| 263 | + if (!preg_match("|^" . $URI_PARTS["scheme"] . "://|", $this->_redirectaddr)) { |
|
| 264 | + $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr, $URI_PARTS["scheme"] . "://" . $URI_PARTS["host"]); |
|
| 265 | + } |
|
| 254 | 266 | |
| 255 | 267 | // only follow redirect if it's on this site, or offsiteok is true |
| 256 | 268 | if (preg_match("|^https?://" . preg_quote($this->host) . "|i", $this->_redirectaddr) || $this->offsiteok) { |
| 257 | 269 | /* follow the redirect */ |
| 258 | 270 | $this->_redirectdepth++; |
| 259 | 271 | $this->lastredirectaddr = $this->_redirectaddr; |
| 260 | - if (strpos($this->_redirectaddr, "?") > 0) |
|
| 261 | - $this->fetch($this->_redirectaddr); // the redirect has changed the request method from post to get |
|
| 262 | - else |
|
| 263 | - $this->submit($this->_redirectaddr, $formvars, $formfiles); |
|
| 272 | + if (strpos($this->_redirectaddr, "?") > 0) { |
|
| 273 | + $this->fetch($this->_redirectaddr); |
|
| 274 | + } |
|
| 275 | + // the redirect has changed the request method from post to get |
|
| 276 | + else { |
|
| 277 | + $this->submit($this->_redirectaddr, $formvars, $formfiles); |
|
| 278 | + } |
|
| 264 | 279 | } |
| 265 | 280 | } |
| 266 | 281 | } |
@@ -273,8 +288,9 @@ discard block |
||
| 273 | 288 | if ($this->_framedepth < $this->maxframes) { |
| 274 | 289 | $this->fetch($frameurl); |
| 275 | 290 | $this->_framedepth++; |
| 276 | - } else |
|
| 277 | - break; |
|
| 291 | + } else { |
|
| 292 | + break; |
|
| 293 | + } |
|
| 278 | 294 | } |
| 279 | 295 | } |
| 280 | 296 | |
@@ -302,19 +318,24 @@ discard block |
||
| 302 | 318 | function fetchlinks($URI) |
| 303 | 319 | { |
| 304 | 320 | if ($this->fetch($URI) !== false) { |
| 305 | - if ($this->lastredirectaddr) |
|
| 306 | - $URI = $this->lastredirectaddr; |
|
| 321 | + if ($this->lastredirectaddr) { |
|
| 322 | + $URI = $this->lastredirectaddr; |
|
| 323 | + } |
|
| 307 | 324 | if (is_array($this->results)) { |
| 308 | - for ($x = 0; $x < count($this->results); $x++) |
|
| 309 | - $this->results[$x] = $this->_striplinks($this->results[$x]); |
|
| 310 | - } else |
|
| 311 | - $this->results = $this->_striplinks($this->results); |
|
| 325 | + for ($x = 0; $x < count($this->results); $x++) { |
|
| 326 | + $this->results[$x] = $this->_striplinks($this->results[$x]); |
|
| 327 | + } |
|
| 328 | + } else { |
|
| 329 | + $this->results = $this->_striplinks($this->results); |
|
| 330 | + } |
|
| 312 | 331 | |
| 313 | - if ($this->expandlinks) |
|
| 314 | - $this->results = $this->_expandlinks($this->results, $URI); |
|
| 332 | + if ($this->expandlinks) { |
|
| 333 | + $this->results = $this->_expandlinks($this->results, $URI); |
|
| 334 | + } |
|
| 315 | 335 | return $this; |
| 316 | - } else |
|
| 317 | - return false; |
|
| 336 | + } else { |
|
| 337 | + return false; |
|
| 338 | + } |
|
| 318 | 339 | } |
| 319 | 340 | |
| 320 | 341 | /*======================================================================*\ |
@@ -330,14 +351,17 @@ discard block |
||
| 330 | 351 | if ($this->fetch($URI) !== false) { |
| 331 | 352 | |
| 332 | 353 | if (is_array($this->results)) { |
| 333 | - for ($x = 0; $x < count($this->results); $x++) |
|
| 334 | - $this->results[$x] = $this->_stripform($this->results[$x]); |
|
| 335 | - } else |
|
| 336 | - $this->results = $this->_stripform($this->results); |
|
| 354 | + for ($x = 0; $x < count($this->results); $x++) { |
|
| 355 | + $this->results[$x] = $this->_stripform($this->results[$x]); |
|
| 356 | + } |
|
| 357 | + } else { |
|
| 358 | + $this->results = $this->_stripform($this->results); |
|
| 359 | + } |
|
| 337 | 360 | |
| 338 | 361 | return $this; |
| 339 | - } else |
|
| 340 | - return false; |
|
| 362 | + } else { |
|
| 363 | + return false; |
|
| 364 | + } |
|
| 341 | 365 | } |
| 342 | 366 | |
| 343 | 367 | |
@@ -352,13 +376,16 @@ discard block |
||
| 352 | 376 | { |
| 353 | 377 | if ($this->fetch($URI) !== false) { |
| 354 | 378 | if (is_array($this->results)) { |
| 355 | - for ($x = 0; $x < count($this->results); $x++) |
|
| 356 | - $this->results[$x] = $this->_striptext($this->results[$x]); |
|
| 357 | - } else |
|
| 358 | - $this->results = $this->_striptext($this->results); |
|
| 379 | + for ($x = 0; $x < count($this->results); $x++) { |
|
| 380 | + $this->results[$x] = $this->_striptext($this->results[$x]); |
|
| 381 | + } |
|
| 382 | + } else { |
|
| 383 | + $this->results = $this->_striptext($this->results); |
|
| 384 | + } |
|
| 359 | 385 | return $this; |
| 360 | - } else |
|
| 361 | - return false; |
|
| 386 | + } else { |
|
| 387 | + return false; |
|
| 388 | + } |
|
| 362 | 389 | } |
| 363 | 390 | |
| 364 | 391 | /*======================================================================*\ |
@@ -371,22 +398,26 @@ discard block |
||
| 371 | 398 | function submitlinks($URI, $formvars = "", $formfiles = "") |
| 372 | 399 | { |
| 373 | 400 | if ($this->submit($URI, $formvars, $formfiles) !== false) { |
| 374 | - if ($this->lastredirectaddr) |
|
| 375 | - $URI = $this->lastredirectaddr; |
|
| 401 | + if ($this->lastredirectaddr) { |
|
| 402 | + $URI = $this->lastredirectaddr; |
|
| 403 | + } |
|
| 376 | 404 | if (is_array($this->results)) { |
| 377 | 405 | for ($x = 0; $x < count($this->results); $x++) { |
| 378 | 406 | $this->results[$x] = $this->_striplinks($this->results[$x]); |
| 379 | - if ($this->expandlinks) |
|
| 380 | - $this->results[$x] = $this->_expandlinks($this->results[$x], $URI); |
|
| 407 | + if ($this->expandlinks) { |
|
| 408 | + $this->results[$x] = $this->_expandlinks($this->results[$x], $URI); |
|
| 409 | + } |
|
| 381 | 410 | } |
| 382 | 411 | } else { |
| 383 | 412 | $this->results = $this->_striplinks($this->results); |
| 384 | - if ($this->expandlinks) |
|
| 385 | - $this->results = $this->_expandlinks($this->results, $URI); |
|
| 413 | + if ($this->expandlinks) { |
|
| 414 | + $this->results = $this->_expandlinks($this->results, $URI); |
|
| 415 | + } |
|
| 386 | 416 | } |
| 387 | 417 | return $this; |
| 388 | - } else |
|
| 389 | - return false; |
|
| 418 | + } else { |
|
| 419 | + return false; |
|
| 420 | + } |
|
| 390 | 421 | } |
| 391 | 422 | |
| 392 | 423 | /*======================================================================*\ |
@@ -399,22 +430,26 @@ discard block |
||
| 399 | 430 | function submittext($URI, $formvars = "", $formfiles = "") |
| 400 | 431 | { |
| 401 | 432 | if ($this->submit($URI, $formvars, $formfiles) !== false) { |
| 402 | - if ($this->lastredirectaddr) |
|
| 403 | - $URI = $this->lastredirectaddr; |
|
| 433 | + if ($this->lastredirectaddr) { |
|
| 434 | + $URI = $this->lastredirectaddr; |
|
| 435 | + } |
|
| 404 | 436 | if (is_array($this->results)) { |
| 405 | 437 | for ($x = 0; $x < count($this->results); $x++) { |
| 406 | 438 | $this->results[$x] = $this->_striptext($this->results[$x]); |
| 407 | - if ($this->expandlinks) |
|
| 408 | - $this->results[$x] = $this->_expandlinks($this->results[$x], $URI); |
|
| 439 | + if ($this->expandlinks) { |
|
| 440 | + $this->results[$x] = $this->_expandlinks($this->results[$x], $URI); |
|
| 441 | + } |
|
| 409 | 442 | } |
| 410 | 443 | } else { |
| 411 | 444 | $this->results = $this->_striptext($this->results); |
| 412 | - if ($this->expandlinks) |
|
| 413 | - $this->results = $this->_expandlinks($this->results, $URI); |
|
| 445 | + if ($this->expandlinks) { |
|
| 446 | + $this->results = $this->_expandlinks($this->results, $URI); |
|
| 447 | + } |
|
| 414 | 448 | } |
| 415 | 449 | return $this; |
| 416 | - } else |
|
| 417 | - return false; |
|
| 450 | + } else { |
|
| 451 | + return false; |
|
| 452 | + } |
|
| 418 | 453 | } |
| 419 | 454 | |
| 420 | 455 | |
@@ -468,13 +503,15 @@ discard block |
||
| 468 | 503 | // catenate the non-empty matches from the conditional subpattern |
| 469 | 504 | |
| 470 | 505 | while (list($key, $val) = each($links[2])) { |
| 471 | - if (!empty($val)) |
|
| 472 | - $match[] = $val; |
|
| 506 | + if (!empty($val)) { |
|
| 507 | + $match[] = $val; |
|
| 508 | + } |
|
| 473 | 509 | } |
| 474 | 510 | |
| 475 | 511 | while (list($key, $val) = each($links[3])) { |
| 476 | - if (!empty($val)) |
|
| 477 | - $match[] = $val; |
|
| 512 | + if (!empty($val)) { |
|
| 513 | + $match[] = $val; |
|
| 514 | + } |
|
| 478 | 515 | } |
| 479 | 516 | |
| 480 | 517 | // return the links |
@@ -619,23 +656,28 @@ discard block |
||
| 619 | 656 | function _httprequest($url, $fp, $URI, $http_method, $content_type = "", $body = "") |
| 620 | 657 | { |
| 621 | 658 | $cookie_headers = ''; |
| 622 | - if ($this->passcookies && $this->_redirectaddr) |
|
| 623 | - $this->setcookies(); |
|
| 659 | + if ($this->passcookies && $this->_redirectaddr) { |
|
| 660 | + $this->setcookies(); |
|
| 661 | + } |
|
| 624 | 662 | |
| 625 | 663 | $URI_PARTS = parse_url($URI); |
| 626 | - if (empty($url)) |
|
| 627 | - $url = "/"; |
|
| 664 | + if (empty($url)) { |
|
| 665 | + $url = "/"; |
|
| 666 | + } |
|
| 628 | 667 | $headers = $http_method . " " . $url . " " . $this->_httpversion . "\r\n"; |
| 629 | 668 | if (!empty($this->host) && !isset($this->rawheaders['Host'])) { |
| 630 | 669 | $headers .= "Host: " . $this->host; |
| 631 | - if (!empty($this->port) && $this->port != '80') |
|
| 632 | - $headers .= ":" . $this->port; |
|
| 670 | + if (!empty($this->port) && $this->port != '80') { |
|
| 671 | + $headers .= ":" . $this->port; |
|
| 672 | + } |
|
| 633 | 673 | $headers .= "\r\n"; |
| 634 | 674 | } |
| 635 | - if (!empty($this->agent)) |
|
| 636 | - $headers .= "User-Agent: " . $this->agent . "\r\n"; |
|
| 637 | - if (!empty($this->accept)) |
|
| 638 | - $headers .= "Accept: " . $this->accept . "\r\n"; |
|
| 675 | + if (!empty($this->agent)) { |
|
| 676 | + $headers .= "User-Agent: " . $this->agent . "\r\n"; |
|
| 677 | + } |
|
| 678 | + if (!empty($this->accept)) { |
|
| 679 | + $headers .= "Accept: " . $this->accept . "\r\n"; |
|
| 680 | + } |
|
| 639 | 681 | if ($this->use_gzip) { |
| 640 | 682 | // make sure PHP was built with --with-zlib |
| 641 | 683 | // and we can handle gzipp'ed data |
@@ -648,11 +690,13 @@ discard block |
||
| 648 | 690 | E_USER_NOTICE); |
| 649 | 691 | } |
| 650 | 692 | } |
| 651 | - if (!empty($this->referer)) |
|
| 652 | - $headers .= "Referer: " . $this->referer . "\r\n"; |
|
| 693 | + if (!empty($this->referer)) { |
|
| 694 | + $headers .= "Referer: " . $this->referer . "\r\n"; |
|
| 695 | + } |
|
| 653 | 696 | if (!empty($this->cookies)) { |
| 654 | - if (!is_array($this->cookies)) |
|
| 655 | - $this->cookies = (array)$this->cookies; |
|
| 697 | + if (!is_array($this->cookies)) { |
|
| 698 | + $this->cookies = (array)$this->cookies; |
|
| 699 | + } |
|
| 656 | 700 | |
| 657 | 701 | reset($this->cookies); |
| 658 | 702 | if (count($this->cookies) > 0) { |
@@ -664,32 +708,39 @@ discard block |
||
| 664 | 708 | } |
| 665 | 709 | } |
| 666 | 710 | if (!empty($this->rawheaders)) { |
| 667 | - if (!is_array($this->rawheaders)) |
|
| 668 | - $this->rawheaders = (array)$this->rawheaders; |
|
| 669 | - while (list($headerKey, $headerVal) = each($this->rawheaders)) |
|
| 670 | - $headers .= $headerKey . ": " . $headerVal . "\r\n"; |
|
| 711 | + if (!is_array($this->rawheaders)) { |
|
| 712 | + $this->rawheaders = (array)$this->rawheaders; |
|
| 713 | + } |
|
| 714 | + while (list($headerKey, $headerVal) = each($this->rawheaders)) { |
|
| 715 | + $headers .= $headerKey . ": " . $headerVal . "\r\n"; |
|
| 716 | + } |
|
| 671 | 717 | } |
| 672 | 718 | if (!empty($content_type)) { |
| 673 | 719 | $headers .= "Content-type: $content_type"; |
| 674 | - if ($content_type == "multipart/form-data") |
|
| 675 | - $headers .= "; boundary=" . $this->_mime_boundary; |
|
| 720 | + if ($content_type == "multipart/form-data") { |
|
| 721 | + $headers .= "; boundary=" . $this->_mime_boundary; |
|
| 722 | + } |
|
| 676 | 723 | $headers .= "\r\n"; |
| 677 | 724 | } |
| 678 | - if (!empty($body)) |
|
| 679 | - $headers .= "Content-length: " . strlen($body) . "\r\n"; |
|
| 680 | - if (!empty($this->user) || !empty($this->pass)) |
|
| 681 | - $headers .= "Authorization: Basic " . base64_encode($this->user . ":" . $this->pass) . "\r\n"; |
|
| 725 | + if (!empty($body)) { |
|
| 726 | + $headers .= "Content-length: " . strlen($body) . "\r\n"; |
|
| 727 | + } |
|
| 728 | + if (!empty($this->user) || !empty($this->pass)) { |
|
| 729 | + $headers .= "Authorization: Basic " . base64_encode($this->user . ":" . $this->pass) . "\r\n"; |
|
| 730 | + } |
|
| 682 | 731 | |
| 683 | 732 | //add proxy auth headers |
| 684 | - if (!empty($this->proxy_user)) |
|
| 685 | - $headers .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode($this->proxy_user . ':' . $this->proxy_pass) . "\r\n"; |
|
| 733 | + if (!empty($this->proxy_user)) { |
|
| 734 | + $headers .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode($this->proxy_user . ':' . $this->proxy_pass) . "\r\n"; |
|
| 735 | + } |
|
| 686 | 736 | |
| 687 | 737 | |
| 688 | 738 | $headers .= "\r\n"; |
| 689 | 739 | |
| 690 | 740 | // set the read timeout if needed |
| 691 | - if ($this->read_timeout > 0) |
|
| 692 | - socket_set_timeout($fp, $this->read_timeout); |
|
| 741 | + if ($this->read_timeout > 0) { |
|
| 742 | + socket_set_timeout($fp, $this->read_timeout); |
|
| 743 | + } |
|
| 693 | 744 | $this->timed_out = false; |
| 694 | 745 | |
| 695 | 746 | fwrite($fp, $headers . $body, strlen($headers . $body)); |
@@ -706,8 +757,9 @@ discard block |
||
| 706 | 757 | return false; |
| 707 | 758 | } |
| 708 | 759 | |
| 709 | - if ($currentHeader == "\r\n") |
|
| 710 | - break; |
|
| 760 | + if ($currentHeader == "\r\n") { |
|
| 761 | + break; |
|
| 762 | + } |
|
| 711 | 763 | |
| 712 | 764 | // if a header begins with Location: or URI:, set the redirect |
| 713 | 765 | if (preg_match("/^(Location:|URI:)/i", $currentHeader)) { |
@@ -718,12 +770,14 @@ discard block |
||
| 718 | 770 | // no host in the path, so prepend |
| 719 | 771 | $this->_redirectaddr = $URI_PARTS["scheme"] . "://" . $this->host . ":" . $this->port; |
| 720 | 772 | // eliminate double slash |
| 721 | - if (!preg_match("|^/|", $matches[2])) |
|
| 722 | - $this->_redirectaddr .= "/" . $matches[2]; |
|
| 723 | - else |
|
| 724 | - $this->_redirectaddr .= $matches[2]; |
|
| 725 | - } else |
|
| 726 | - $this->_redirectaddr = $matches[2]; |
|
| 773 | + if (!preg_match("|^/|", $matches[2])) { |
|
| 774 | + $this->_redirectaddr .= "/" . $matches[2]; |
|
| 775 | + } else { |
|
| 776 | + $this->_redirectaddr .= $matches[2]; |
|
| 777 | + } |
|
| 778 | + } else { |
|
| 779 | + $this->_redirectaddr = $matches[2]; |
|
| 780 | + } |
|
| 727 | 781 | } |
| 728 | 782 | |
| 729 | 783 | if (preg_match("|^HTTP/|", $currentHeader)) { |
@@ -770,14 +824,17 @@ discard block |
||
| 770 | 824 | // have we hit our frame depth and is there frame src to fetch? |
| 771 | 825 | if (($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i", $results, $match)) { |
| 772 | 826 | $this->results[] = $results; |
| 773 | - for ($x = 0; $x < count($match[1]); $x++) |
|
| 774 | - $this->_frameurls[] = $this->_expandlinks($match[1][$x], $URI_PARTS["scheme"] . "://" . $this->host); |
|
| 827 | + for ($x = 0; $x < count($match[1]); $x++) { |
|
| 828 | + $this->_frameurls[] = $this->_expandlinks($match[1][$x], $URI_PARTS["scheme"] . "://" . $this->host); |
|
| 829 | + } |
|
| 775 | 830 | } // have we already fetched framed content? |
| 776 | - elseif (is_array($this->results)) |
|
| 777 | - $this->results[] = $results; |
|
| 831 | + elseif (is_array($this->results)) { |
|
| 832 | + $this->results[] = $results; |
|
| 833 | + } |
|
| 778 | 834 | // no framed content |
| 779 | - else |
|
| 780 | - $this->results = $results; |
|
| 835 | + else { |
|
| 836 | + $this->results = $results; |
|
| 837 | + } |
|
| 781 | 838 | |
| 782 | 839 | return $this; |
| 783 | 840 | } |
@@ -790,8 +847,9 @@ discard block |
||
| 790 | 847 | function setcookies() |
| 791 | 848 | { |
| 792 | 849 | for ($x = 0; $x < count($this->headers); $x++) { |
| 793 | - if (preg_match('/^set-cookie:[\s]+([^=]+)=([^;]+)/i', $this->headers[$x], $match)) |
|
| 794 | - $this->cookies[$match[1]] = urldecode($match[2]); |
|
| 850 | + if (preg_match('/^set-cookie:[\s]+([^=]+)=([^;]+)/i', $this->headers[$x], $match)) { |
|
| 851 | + $this->cookies[$match[1]] = urldecode($match[2]); |
|
| 852 | + } |
|
| 795 | 853 | } |
| 796 | 854 | return $this; |
| 797 | 855 | } |
@@ -852,10 +910,12 @@ discard block |
||
| 852 | 910 | 'disable_compression' => true, |
| 853 | 911 | ); |
| 854 | 912 | |
| 855 | - if (isset($this->cafile)) |
|
| 856 | - $context_opts['ssl']['cafile'] = $this->cafile; |
|
| 857 | - if (isset($this->capath)) |
|
| 858 | - $context_opts['ssl']['capath'] = $this->capath; |
|
| 913 | + if (isset($this->cafile)) { |
|
| 914 | + $context_opts['ssl']['cafile'] = $this->cafile; |
|
| 915 | + } |
|
| 916 | + if (isset($this->capath)) { |
|
| 917 | + $context_opts['ssl']['capath'] = $this->capath; |
|
| 918 | + } |
|
| 859 | 919 | } |
| 860 | 920 | |
| 861 | 921 | $host = 'ssl://' . $host; |
@@ -864,8 +924,9 @@ discard block |
||
| 864 | 924 | $context = stream_context_create($context_opts); |
| 865 | 925 | |
| 866 | 926 | if (version_compare(PHP_VERSION, '5.0.0', '>')) { |
| 867 | - if($this->scheme == 'http') |
|
| 868 | - $host = "tcp://" . $host; |
|
| 927 | + if($this->scheme == 'http') { |
|
| 928 | + $host = "tcp://" . $host; |
|
| 929 | + } |
|
| 869 | 930 | $fp = stream_socket_client( |
| 870 | 931 | "$host:$port", |
| 871 | 932 | $errno, |
@@ -929,8 +990,9 @@ discard block |
||
| 929 | 990 | settype($formfiles, "array"); |
| 930 | 991 | $postdata = ''; |
| 931 | 992 | |
| 932 | - if (count($formvars) == 0 && count($formfiles) == 0) |
|
| 933 | - return; |
|
| 993 | + if (count($formvars) == 0 && count($formfiles) == 0) { |
|
| 994 | + return; |
|
| 995 | + } |
|
| 934 | 996 | |
| 935 | 997 | switch ($this->_submit_type) { |
| 936 | 998 | case "application/x-www-form-urlencoded": |
@@ -940,8 +1002,9 @@ discard block |
||
| 940 | 1002 | while (list($cur_key, $cur_val) = each($val)) { |
| 941 | 1003 | $postdata .= urlencode($key) . "[]=" . urlencode($cur_val) . "&"; |
| 942 | 1004 | } |
| 943 | - } else |
|
| 944 | - $postdata .= urlencode($key) . "=" . urlencode($val) . "&"; |
|
| 1005 | + } else { |
|
| 1006 | + $postdata .= urlencode($key) . "=" . urlencode($val) . "&"; |
|
| 1007 | + } |
|
| 945 | 1008 | } |
| 946 | 1009 | break; |
| 947 | 1010 | |
@@ -967,7 +1030,9 @@ discard block |
||
| 967 | 1030 | while (list($field_name, $file_names) = each($formfiles)) { |
| 968 | 1031 | settype($file_names, "array"); |
| 969 | 1032 | while (list(, $file_name) = each($file_names)) { |
| 970 | - if (!is_readable($file_name)) continue; |
|
| 1033 | + if (!is_readable($file_name)) { |
|
| 1034 | + continue; |
|
| 1035 | + } |
|
| 971 | 1036 | |
| 972 | 1037 | $fp = fopen($file_name, "r"); |
| 973 | 1038 | $file_content = fread($fp, filesize($file_name)); |
@@ -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 | } |
@@ -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')) { |