@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | { |
22 | 22 | return implode( |
23 | 23 | $break, |
24 | - array_map(function (string $line) use ($width, $break) { |
|
24 | + array_map(function(string $line) use ($width, $break) { |
|
25 | 25 | $line = rtrim($line); |
26 | 26 | if (mb_strlen($line) <= $width) { |
27 | 27 | return $line; |
@@ -31,16 +31,16 @@ discard block |
||
31 | 31 | $line = ''; |
32 | 32 | $actual = ''; |
33 | 33 | foreach ($words as $word) { |
34 | - if (mb_strlen($actual . $word) <= $width) { |
|
35 | - $actual .= $word . ' '; |
|
34 | + if (mb_strlen($actual.$word) <= $width) { |
|
35 | + $actual .= $word.' '; |
|
36 | 36 | } else { |
37 | 37 | if ($actual !== '') { |
38 | - $line .= rtrim($actual) . $break; |
|
38 | + $line .= rtrim($actual).$break; |
|
39 | 39 | } |
40 | - $actual = $word . ' '; |
|
40 | + $actual = $word.' '; |
|
41 | 41 | } |
42 | 42 | } |
43 | - return $line . trim($actual); |
|
43 | + return $line.trim($actual); |
|
44 | 44 | }, explode("\n", $string)) |
45 | 45 | ); |
46 | 46 | } |
@@ -21,7 +21,8 @@ |
||
21 | 21 | { |
22 | 22 | return implode( |
23 | 23 | $break, |
24 | - array_map(function (string $line) use ($width, $break) { |
|
24 | + array_map(function (string $line) use ($width, $break) |
|
25 | + { |
|
25 | 26 | $line = rtrim($line); |
26 | 27 | if (mb_strlen($line) <= $width) { |
27 | 28 | return $line; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | public static function loadClassLoader($class) |
16 | 16 | { |
17 | 17 | if ('Composer\Autoload\ClassLoader' === $class) { |
18 | - require __DIR__ . '/ClassLoader.php'; |
|
18 | + require __DIR__.'/ClassLoader.php'; |
|
19 | 19 | } |
20 | 20 | } |
21 | 21 | |
@@ -31,21 +31,21 @@ discard block |
||
31 | 31 | |
32 | 32 | $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); |
33 | 33 | if ($useStaticLoader) { |
34 | - require_once __DIR__ . '/autoload_static.php'; |
|
34 | + require_once __DIR__.'/autoload_static.php'; |
|
35 | 35 | |
36 | 36 | call_user_func(\Composer\Autoload\ComposerStaticInit6670dab4b71421eb4b91561314912df5::getInitializer($loader)); |
37 | 37 | } else { |
38 | - $map = require __DIR__ . '/autoload_namespaces.php'; |
|
38 | + $map = require __DIR__.'/autoload_namespaces.php'; |
|
39 | 39 | foreach ($map as $namespace => $path) { |
40 | 40 | $loader->set($namespace, $path); |
41 | 41 | } |
42 | 42 | |
43 | - $map = require __DIR__ . '/autoload_psr4.php'; |
|
43 | + $map = require __DIR__.'/autoload_psr4.php'; |
|
44 | 44 | foreach ($map as $namespace => $path) { |
45 | 45 | $loader->setPsr4($namespace, $path); |
46 | 46 | } |
47 | 47 | |
48 | - $classMap = require __DIR__ . '/autoload_classmap.php'; |
|
48 | + $classMap = require __DIR__.'/autoload_classmap.php'; |
|
49 | 49 | if ($classMap) { |
50 | 50 | $loader->addClassMap($classMap); |
51 | 51 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | if ($useStaticLoader) { |
57 | 57 | $includeFiles = Composer\Autoload\ComposerStaticInit6670dab4b71421eb4b91561314912df5::$files; |
58 | 58 | } else { |
59 | - $includeFiles = require __DIR__ . '/autoload_files.php'; |
|
59 | + $includeFiles = require __DIR__.'/autoload_files.php'; |
|
60 | 60 | } |
61 | 61 | foreach ($includeFiles as $fileIdentifier => $file) { |
62 | 62 | composerRequire6670dab4b71421eb4b91561314912df5($fileIdentifier, $file); |
@@ -12,7 +12,7 @@ |
||
12 | 12 | $baseDir = dirname($vendorDir); |
13 | 13 | |
14 | 14 | return array( |
15 | - 'PhpSchool\\Terminal\\' => array($vendorDir . '/php-school/terminal/src'), |
|
16 | - 'PhpSchool\\CliMenu\\' => array($vendorDir . '/php-school/cli-menu/src'), |
|
17 | - 'Assert\\' => array($vendorDir . '/beberlei/assert/lib/Assert'), |
|
15 | + 'PhpSchool\\Terminal\\' => array($vendorDir.'/php-school/terminal/src'), |
|
16 | + 'PhpSchool\\CliMenu\\' => array($vendorDir.'/php-school/cli-menu/src'), |
|
17 | + 'Assert\\' => array($vendorDir.'/beberlei/assert/lib/Assert'), |
|
18 | 18 | ); |
@@ -12,40 +12,40 @@ |
||
12 | 12 | |
13 | 13 | class ComposerStaticInit6670dab4b71421eb4b91561314912df5 |
14 | 14 | { |
15 | - public static $files = array ( |
|
16 | - 'a4ecaeafb8cfb009ad0e052c90355e98' => __DIR__ . '/..' . '/beberlei/assert/lib/Assert/functions.php', |
|
15 | + public static $files = array( |
|
16 | + 'a4ecaeafb8cfb009ad0e052c90355e98' => __DIR__.'/..'.'/beberlei/assert/lib/Assert/functions.php', |
|
17 | 17 | ); |
18 | 18 | |
19 | - public static $prefixLengthsPsr4 = array ( |
|
19 | + public static $prefixLengthsPsr4 = array( |
|
20 | 20 | 'P' => |
21 | - array ( |
|
21 | + array( |
|
22 | 22 | 'PhpSchool\\Terminal\\' => 19, |
23 | 23 | 'PhpSchool\\CliMenu\\' => 18, |
24 | 24 | ), |
25 | 25 | 'A' => |
26 | - array ( |
|
26 | + array( |
|
27 | 27 | 'Assert\\' => 7, |
28 | 28 | ), |
29 | 29 | ); |
30 | 30 | |
31 | - public static $prefixDirsPsr4 = array ( |
|
31 | + public static $prefixDirsPsr4 = array( |
|
32 | 32 | 'PhpSchool\\Terminal\\' => |
33 | - array ( |
|
34 | - 0 => __DIR__ . '/..' . '/php-school/terminal/src', |
|
33 | + array( |
|
34 | + 0 => __DIR__.'/..'.'/php-school/terminal/src', |
|
35 | 35 | ), |
36 | 36 | 'PhpSchool\\CliMenu\\' => |
37 | - array ( |
|
38 | - 0 => __DIR__ . '/..' . '/php-school/cli-menu/src', |
|
37 | + array( |
|
38 | + 0 => __DIR__.'/..'.'/php-school/cli-menu/src', |
|
39 | 39 | ), |
40 | 40 | 'Assert\\' => |
41 | - array ( |
|
42 | - 0 => __DIR__ . '/..' . '/beberlei/assert/lib/Assert', |
|
41 | + array( |
|
42 | + 0 => __DIR__.'/..'.'/beberlei/assert/lib/Assert', |
|
43 | 43 | ), |
44 | 44 | ); |
45 | 45 | |
46 | 46 | public static function getInitializer(ClassLoader $loader) |
47 | 47 | { |
48 | - return \Closure::bind(function () use ($loader) { |
|
48 | + return \Closure::bind(function() use ($loader) { |
|
49 | 49 | $loader->prefixLengthsPsr4 = ComposerStaticInit6670dab4b71421eb4b91561314912df5::$prefixLengthsPsr4; |
50 | 50 | $loader->prefixDirsPsr4 = ComposerStaticInit6670dab4b71421eb4b91561314912df5::$prefixDirsPsr4; |
51 | 51 |
@@ -45,7 +45,8 @@ |
||
45 | 45 | |
46 | 46 | public static function getInitializer(ClassLoader $loader) |
47 | 47 | { |
48 | - return \Closure::bind(function () use ($loader) { |
|
48 | + return \Closure::bind(function () use ($loader) |
|
49 | + { |
|
49 | 50 | $loader->prefixLengthsPsr4 = ComposerStaticInit6670dab4b71421eb4b91561314912df5::$prefixLengthsPsr4; |
50 | 51 | $loader->prefixDirsPsr4 = ComposerStaticInit6670dab4b71421eb4b91561314912df5::$prefixDirsPsr4; |
51 | 52 |
@@ -12,5 +12,5 @@ |
||
12 | 12 | $baseDir = dirname($vendorDir); |
13 | 13 | |
14 | 14 | return array( |
15 | - 'a4ecaeafb8cfb009ad0e052c90355e98' => $vendorDir . '/beberlei/assert/lib/Assert/functions.php', |
|
15 | + 'a4ecaeafb8cfb009ad0e052c90355e98' => $vendorDir.'/beberlei/assert/lib/Assert/functions.php', |
|
16 | 16 | ); |
@@ -367,18 +367,18 @@ discard block |
||
367 | 367 | private function findFileWithExtension($class, $ext) |
368 | 368 | { |
369 | 369 | // PSR-4 lookup |
370 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
370 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
371 | 371 | |
372 | 372 | $first = $class[0]; |
373 | 373 | if (isset($this->prefixLengthsPsr4[$first])) { |
374 | 374 | $subPath = $class; |
375 | 375 | while (false !== $lastPos = strrpos($subPath, '\\')) { |
376 | 376 | $subPath = substr($subPath, 0, $lastPos); |
377 | - $search = $subPath . '\\'; |
|
377 | + $search = $subPath.'\\'; |
|
378 | 378 | if (isset($this->prefixDirsPsr4[$search])) { |
379 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
379 | + $pathEnd = DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $lastPos + 1); |
|
380 | 380 | foreach ($this->prefixDirsPsr4[$search] as $dir) { |
381 | - if (file_exists($file = $dir . $pathEnd)) { |
|
381 | + if (file_exists($file = $dir.$pathEnd)) { |
|
382 | 382 | return $file; |
383 | 383 | } |
384 | 384 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | |
389 | 389 | // PSR-4 fallback dirs |
390 | 390 | foreach ($this->fallbackDirsPsr4 as $dir) { |
391 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
391 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
392 | 392 | return $file; |
393 | 393 | } |
394 | 394 | } |
@@ -400,14 +400,14 @@ discard block |
||
400 | 400 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
401 | 401 | } else { |
402 | 402 | // PEAR-like class name |
403 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
403 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | if (isset($this->prefixesPsr0[$first])) { |
407 | 407 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
408 | 408 | if (0 === strpos($class, $prefix)) { |
409 | 409 | foreach ($dirs as $dir) { |
410 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
410 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
411 | 411 | return $file; |
412 | 412 | } |
413 | 413 | } |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | |
418 | 418 | // PSR-0 fallback dirs |
419 | 419 | foreach ($this->fallbackDirsPsr0 as $dir) { |
420 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
420 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
421 | 421 | return $file; |
422 | 422 | } |
423 | 423 | } |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | */ |
520 | 520 | public static function digit($value, $message = null, string $propertyPath = null): bool |
521 | 521 | { |
522 | - if (!\ctype_digit((string)$value)) { |
|
522 | + if (!\ctype_digit((string) $value)) { |
|
523 | 523 | $message = \sprintf( |
524 | 524 | static::generateMessage($message ?: 'Value "%s" is not a digit.'), |
525 | 525 | static::stringify($value) |
@@ -2772,7 +2772,7 @@ discard block |
||
2772 | 2772 | if (\is_bool($value)) { |
2773 | 2773 | $result = $value ? '<TRUE>' : '<FALSE>'; |
2774 | 2774 | } elseif (\is_scalar($value)) { |
2775 | - $val = (string)$value; |
|
2775 | + $val = (string) $value; |
|
2776 | 2776 | |
2777 | 2777 | if (\mb_strlen($val) > 100) { |
2778 | 2778 | $val = \mb_substr($val, 0, 97).'...'; |
@@ -2826,6 +2826,6 @@ discard block |
||
2826 | 2826 | } // @codeCoverageIgnoreEnd |
2827 | 2827 | } |
2828 | 2828 | |
2829 | - return (string)$message; |
|
2829 | + return (string) $message; |
|
2830 | 2830 | } |
2831 | 2831 | } |
@@ -776,11 +776,11 @@ discard block |
||
776 | 776 | } |
777 | 777 | |
778 | 778 | /** |
779 | - * Returns true if $string is valid UTF-8 and false otherwise. |
|
780 | - * |
|
781 | - * @param mixed $str String to be tested |
|
782 | - * @return boolean |
|
783 | - */ |
|
779 | + * Returns true if $string is valid UTF-8 and false otherwise. |
|
780 | + * |
|
781 | + * @param mixed $str String to be tested |
|
782 | + * @return boolean |
|
783 | + */ |
|
784 | 784 | static function is_utf8($str) |
785 | 785 | { |
786 | 786 | $c=0; $b=0; |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | $attributes = array(); |
857 | 857 | preg_match_all("/([\w-]+)\s*:\s*([^;]+)\s*;?/", $this->attr['style'], $matches, PREG_SET_ORDER); |
858 | 858 | foreach ($matches as $match) { |
859 | - $attributes[$match[1]] = $match[2]; |
|
859 | + $attributes[$match[1]] = $match[2]; |
|
860 | 860 | } |
861 | 861 | |
862 | 862 | // If there is a width in the style attributes: |
@@ -977,7 +977,7 @@ discard block |
||
977 | 977 | 'p'=>array('p'=>1), |
978 | 978 | 'nobr'=>array('nobr'=>1), |
979 | 979 | 'b'=>array('b'=>1), |
980 | - 'option'=>array('option'=>1), |
|
980 | + 'option'=>array('option'=>1), |
|
981 | 981 | ); |
982 | 982 | |
983 | 983 | function __construct($str=null, $lowercase=true, $forceTagsClosed=true, $target_charset=DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) |
@@ -12,21 +12,21 @@ discard block |
||
12 | 12 | */ |
13 | 13 | define('HDOM_TYPE_ELEMENT', 1); |
14 | 14 | define('HDOM_TYPE_COMMENT', 2); |
15 | -define('HDOM_TYPE_TEXT', 3); |
|
16 | -define('HDOM_TYPE_ENDTAG', 4); |
|
17 | -define('HDOM_TYPE_ROOT', 5); |
|
15 | +define('HDOM_TYPE_TEXT', 3); |
|
16 | +define('HDOM_TYPE_ENDTAG', 4); |
|
17 | +define('HDOM_TYPE_ROOT', 5); |
|
18 | 18 | define('HDOM_TYPE_UNKNOWN', 6); |
19 | 19 | define('HDOM_QUOTE_DOUBLE', 0); |
20 | 20 | define('HDOM_QUOTE_SINGLE', 1); |
21 | -define('HDOM_QUOTE_NO', 3); |
|
22 | -define('HDOM_INFO_BEGIN', 0); |
|
23 | -define('HDOM_INFO_END', 1); |
|
24 | -define('HDOM_INFO_QUOTE', 2); |
|
25 | -define('HDOM_INFO_SPACE', 3); |
|
26 | -define('HDOM_INFO_TEXT', 4); |
|
27 | -define('HDOM_INFO_INNER', 5); |
|
28 | -define('HDOM_INFO_OUTER', 6); |
|
29 | -define('HDOM_INFO_ENDSPACE',7); |
|
21 | +define('HDOM_QUOTE_NO', 3); |
|
22 | +define('HDOM_INFO_BEGIN', 0); |
|
23 | +define('HDOM_INFO_END', 1); |
|
24 | +define('HDOM_INFO_QUOTE', 2); |
|
25 | +define('HDOM_INFO_SPACE', 3); |
|
26 | +define('HDOM_INFO_TEXT', 4); |
|
27 | +define('HDOM_INFO_INNER', 5); |
|
28 | +define('HDOM_INFO_OUTER', 6); |
|
29 | +define('HDOM_INFO_ENDSPACE', 7); |
|
30 | 30 | define('DEFAULT_TARGET_CHARSET', 'UTF-8'); |
31 | 31 | define('DEFAULT_BR_TEXT', "\r\n"); |
32 | 32 | define('DEFAULT_SPAN_TEXT', " "); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | // ----------------------------------------------------------------------------- |
36 | 36 | // get html dom from file |
37 | 37 | // $maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1. |
38 | -function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) |
|
38 | +function file_get_html($url, $use_include_path = false, $context = null, $offset = -1, $maxLen = -1, $lowercase = true, $forceTagsClosed = true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT) |
|
39 | 39 | { |
40 | 40 | // We DO force the tags to be terminated. |
41 | 41 | $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | // get html dom from string |
56 | -function str_get_html($str, $lowercase=true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) |
|
56 | +function str_get_html($str, $lowercase = true, $forceTagsClosed = true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT) |
|
57 | 57 | { |
58 | 58 | $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText); |
59 | 59 | if (empty($str) || strlen($str) > MAX_FILE_SIZE) |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | // dump html dom tree |
69 | -function dump_html_tree($node, $show_attr=true, $deep=0) |
|
69 | +function dump_html_tree($node, $show_attr = true, $deep = 0) |
|
70 | 70 | { |
71 | 71 | $node->dump($node); |
72 | 72 | } |
@@ -118,12 +118,12 @@ discard block |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | // dump node's tree |
121 | - function dump($show_attr=true, $deep=0) |
|
121 | + function dump($show_attr = true, $deep = 0) |
|
122 | 122 | { |
123 | 123 | $lead = str_repeat(' ', $deep); |
124 | 124 | |
125 | 125 | echo $lead.$this->tag; |
126 | - if ($show_attr && count($this->attr)>0) |
|
126 | + if ($show_attr && count($this->attr) > 0) |
|
127 | 127 | { |
128 | 128 | echo '('; |
129 | 129 | foreach ($this->attr as $k=>$v) |
@@ -136,18 +136,18 @@ discard block |
||
136 | 136 | { |
137 | 137 | foreach ($this->nodes as $c) |
138 | 138 | { |
139 | - $c->dump($show_attr, $deep+1); |
|
139 | + $c->dump($show_attr, $deep + 1); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
144 | 144 | |
145 | 145 | // Debugging function to dump a single dom node with a bunch of information about it. |
146 | - function dump_node($echo=true) |
|
146 | + function dump_node($echo = true) |
|
147 | 147 | { |
148 | 148 | |
149 | 149 | $string = $this->tag; |
150 | - if (count($this->attr)>0) |
|
150 | + if (count($this->attr) > 0) |
|
151 | 151 | { |
152 | 152 | $string .= '('; |
153 | 153 | foreach ($this->attr as $k=>$v) |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | } |
157 | 157 | $string .= ')'; |
158 | 158 | } |
159 | - if (count($this->_)>0) |
|
159 | + if (count($this->_) > 0) |
|
160 | 160 | { |
161 | 161 | $string .= ' $_ ('; |
162 | 162 | foreach ($this->_ as $k=>$v) |
@@ -178,22 +178,22 @@ discard block |
||
178 | 178 | |
179 | 179 | if (isset($this->text)) |
180 | 180 | { |
181 | - $string .= " text: (" . $this->text . ")"; |
|
181 | + $string .= " text: (".$this->text.")"; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | $string .= " HDOM_INNER_INFO: '"; |
185 | 185 | if (isset($node->_[HDOM_INFO_INNER])) |
186 | 186 | { |
187 | - $string .= $node->_[HDOM_INFO_INNER] . "'"; |
|
187 | + $string .= $node->_[HDOM_INFO_INNER]."'"; |
|
188 | 188 | } |
189 | 189 | else |
190 | 190 | { |
191 | 191 | $string .= ' NULL '; |
192 | 192 | } |
193 | 193 | |
194 | - $string .= " children: " . count($this->children); |
|
195 | - $string .= " nodes: " . count($this->nodes); |
|
196 | - $string .= " tag_start: " . $this->tag_start; |
|
194 | + $string .= " children: ".count($this->children); |
|
195 | + $string .= " nodes: ".count($this->nodes); |
|
196 | + $string .= " tag_start: ".$this->tag_start; |
|
197 | 197 | $string .= "\n"; |
198 | 198 | |
199 | 199 | if ($echo) |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | |
210 | 210 | // returns the parent of node |
211 | 211 | // If a node is passed in, it will reset the parent of the current node to that one. |
212 | - function parent($parent=null) |
|
212 | + function parent($parent = null) |
|
213 | 213 | { |
214 | 214 | // I am SURE that this doesn't work properly. |
215 | 215 | // It fails to unset the current node from it's current parents nodes or children list first. |
@@ -230,9 +230,9 @@ discard block |
||
230 | 230 | } |
231 | 231 | |
232 | 232 | // returns children of node |
233 | - function children($idx=-1) |
|
233 | + function children($idx = -1) |
|
234 | 234 | { |
235 | - if ($idx===-1) |
|
235 | + if ($idx === -1) |
|
236 | 236 | { |
237 | 237 | return $this->children; |
238 | 238 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | // returns the first child of node |
244 | 244 | function first_child() |
245 | 245 | { |
246 | - if (count($this->children)>0) |
|
246 | + if (count($this->children) > 0) |
|
247 | 247 | { |
248 | 248 | return $this->children[0]; |
249 | 249 | } |
@@ -253,9 +253,9 @@ discard block |
||
253 | 253 | // returns the last child of node |
254 | 254 | function last_child() |
255 | 255 | { |
256 | - if (($count=count($this->children))>0) |
|
256 | + if (($count = count($this->children)) > 0) |
|
257 | 257 | { |
258 | - return $this->children[$count-1]; |
|
258 | + return $this->children[$count - 1]; |
|
259 | 259 | } |
260 | 260 | return null; |
261 | 261 | } |
@@ -263,18 +263,18 @@ discard block |
||
263 | 263 | // returns the next sibling of node |
264 | 264 | function next_sibling() |
265 | 265 | { |
266 | - if ($this->parent===null) |
|
266 | + if ($this->parent === null) |
|
267 | 267 | { |
268 | 268 | return null; |
269 | 269 | } |
270 | 270 | |
271 | 271 | $idx = 0; |
272 | 272 | $count = count($this->parent->children); |
273 | - while ($idx<$count && $this!==$this->parent->children[$idx]) |
|
273 | + while ($idx < $count && $this !== $this->parent->children[$idx]) |
|
274 | 274 | { |
275 | 275 | ++$idx; |
276 | 276 | } |
277 | - if (++$idx>=$count) |
|
277 | + if (++$idx >= $count) |
|
278 | 278 | { |
279 | 279 | return null; |
280 | 280 | } |
@@ -284,12 +284,12 @@ discard block |
||
284 | 284 | // returns the previous sibling of node |
285 | 285 | function prev_sibling() |
286 | 286 | { |
287 | - if ($this->parent===null) return null; |
|
287 | + if ($this->parent === null) return null; |
|
288 | 288 | $idx = 0; |
289 | 289 | $count = count($this->parent->children); |
290 | - while ($idx<$count && $this!==$this->parent->children[$idx]) |
|
290 | + while ($idx < $count && $this !== $this->parent->children[$idx]) |
|
291 | 291 | ++$idx; |
292 | - if (--$idx<0) return null; |
|
292 | + if (--$idx < 0) return null; |
|
293 | 293 | return $this->parent->children[$idx]; |
294 | 294 | } |
295 | 295 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | |
305 | 305 | while (!is_null($returnDom)) |
306 | 306 | { |
307 | - if (is_object($debugObject)) { $debugObject->debugLog(2, "Current tag is: " . $returnDom->tag); } |
|
307 | + if (is_object($debugObject)) { $debugObject->debugLog(2, "Current tag is: ".$returnDom->tag); } |
|
308 | 308 | |
309 | 309 | if ($returnDom->tag == $tag) |
310 | 310 | { |
@@ -338,16 +338,16 @@ discard block |
||
338 | 338 | { |
339 | 339 | if (!empty($this->text)) |
340 | 340 | { |
341 | - $text = " with text: " . $this->text; |
|
341 | + $text = " with text: ".$this->text; |
|
342 | 342 | } |
343 | 343 | } |
344 | - $debugObject->debugLog(1, 'Innertext of tag: ' . $this->tag . $text); |
|
344 | + $debugObject->debugLog(1, 'Innertext of tag: '.$this->tag.$text); |
|
345 | 345 | } |
346 | 346 | |
347 | - if ($this->tag==='root') return $this->innertext(); |
|
347 | + if ($this->tag === 'root') return $this->innertext(); |
|
348 | 348 | |
349 | 349 | // trigger callback |
350 | - if ($this->dom && $this->dom->callback!==null) |
|
350 | + if ($this->dom && $this->dom->callback !== null) |
|
351 | 351 | { |
352 | 352 | call_user_func_array($this->dom->callback, array($this)); |
353 | 353 | } |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | } |
383 | 383 | |
384 | 384 | // render end tag |
385 | - if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0) |
|
385 | + if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END] != 0) |
|
386 | 386 | $ret .= '</'.$this->tag.'>'; |
387 | 387 | return $ret; |
388 | 388 | } |
@@ -397,8 +397,8 @@ discard block |
||
397 | 397 | case HDOM_TYPE_COMMENT: return ''; |
398 | 398 | case HDOM_TYPE_UNKNOWN: return ''; |
399 | 399 | } |
400 | - if (strcasecmp($this->tag, 'script')===0) return ''; |
|
401 | - if (strcasecmp($this->tag, 'style')===0) return ''; |
|
400 | + if (strcasecmp($this->tag, 'script') === 0) return ''; |
|
401 | + if (strcasecmp($this->tag, 'style') === 0) return ''; |
|
402 | 402 | |
403 | 403 | $ret = ''; |
404 | 404 | // In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL. |
@@ -444,12 +444,12 @@ discard block |
||
444 | 444 | ++$i; |
445 | 445 | |
446 | 446 | // skip removed attribute |
447 | - if ($val===null || $val===false) |
|
447 | + if ($val === null || $val === false) |
|
448 | 448 | continue; |
449 | 449 | |
450 | 450 | $ret .= $this->_[HDOM_INFO_SPACE][$i][0]; |
451 | 451 | //no value attr: nowrap, checked selected... |
452 | - if ($val===true) |
|
452 | + if ($val === true) |
|
453 | 453 | $ret .= $key; |
454 | 454 | else { |
455 | 455 | switch ($this->_[HDOM_INFO_QUOTE][$i]) |
@@ -462,34 +462,34 @@ discard block |
||
462 | 462 | } |
463 | 463 | } |
464 | 464 | $ret = $this->dom->restore_noise($ret); |
465 | - return $ret . $this->_[HDOM_INFO_ENDSPACE] . '>'; |
|
465 | + return $ret.$this->_[HDOM_INFO_ENDSPACE].'>'; |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | // find elements by css selector |
469 | 469 | //PaperG - added ability for find to lowercase the value of the selector. |
470 | - function find($selector, $idx=null, $lowercase=false) |
|
470 | + function find($selector, $idx = null, $lowercase = false) |
|
471 | 471 | { |
472 | 472 | $selectors = $this->parse_selector($selector); |
473 | - if (($count=count($selectors))===0) return array(); |
|
473 | + if (($count = count($selectors)) === 0) return array(); |
|
474 | 474 | $found_keys = array(); |
475 | 475 | |
476 | 476 | // find each selector |
477 | - for ($c=0; $c<$count; ++$c) |
|
477 | + for ($c = 0; $c < $count; ++$c) |
|
478 | 478 | { |
479 | 479 | // The change on the below line was documented on the sourceforge code tracker id 2788009 |
480 | 480 | // used to be: if (($levle=count($selectors[0]))===0) return array(); |
481 | - if (($levle=count($selectors[$c]))===0) return array(); |
|
481 | + if (($levle = count($selectors[$c])) === 0) return array(); |
|
482 | 482 | if (!isset($this->_[HDOM_INFO_BEGIN])) return array(); |
483 | 483 | |
484 | 484 | $head = array($this->_[HDOM_INFO_BEGIN]=>1); |
485 | 485 | |
486 | 486 | // handle descendant selectors, no recursive! |
487 | - for ($l=0; $l<$levle; ++$l) |
|
487 | + for ($l = 0; $l < $levle; ++$l) |
|
488 | 488 | { |
489 | 489 | $ret = array(); |
490 | 490 | foreach ($head as $k=>$v) |
491 | 491 | { |
492 | - $n = ($k===-1) ? $this->dom->root : $this->dom->nodes[$k]; |
|
492 | + $n = ($k === -1) ? $this->dom->root : $this->dom->nodes[$k]; |
|
493 | 493 | //PaperG - Pass this optional parameter on to the seek function. |
494 | 494 | $n->seek($selectors[$c][$l], $ret, $lowercase); |
495 | 495 | } |
@@ -512,13 +512,13 @@ discard block |
||
512 | 512 | |
513 | 513 | // return nth-element or array |
514 | 514 | if (is_null($idx)) return $found; |
515 | - else if ($idx<0) $idx = count($found) + $idx; |
|
515 | + else if ($idx < 0) $idx = count($found) + $idx; |
|
516 | 516 | return (isset($found[$idx])) ? $found[$idx] : null; |
517 | 517 | } |
518 | 518 | |
519 | 519 | // seek for given conditions |
520 | 520 | // PaperG - added parameter to allow for case insensitive testing of the value of a selector. |
521 | - protected function seek($selector, &$ret, $lowercase=false) |
|
521 | + protected function seek($selector, &$ret, $lowercase = false) |
|
522 | 522 | { |
523 | 523 | global $debugObject; |
524 | 524 | if (is_object($debugObject)) { $debugObject->debugLogEntry(1); } |
@@ -531,8 +531,8 @@ discard block |
||
531 | 531 | $count = 0; |
532 | 532 | foreach ($this->children as $c) |
533 | 533 | { |
534 | - if ($tag==='*' || $tag===$c->tag) { |
|
535 | - if (++$count==$key) { |
|
534 | + if ($tag === '*' || $tag === $c->tag) { |
|
535 | + if (++$count == $key) { |
|
536 | 536 | $ret[$c->_[HDOM_INFO_BEGIN]] = 1; |
537 | 537 | return; |
538 | 538 | } |
@@ -542,38 +542,38 @@ discard block |
||
542 | 542 | } |
543 | 543 | |
544 | 544 | $end = (!empty($this->_[HDOM_INFO_END])) ? $this->_[HDOM_INFO_END] : 0; |
545 | - if ($end==0) { |
|
545 | + if ($end == 0) { |
|
546 | 546 | $parent = $this->parent; |
547 | - while (!isset($parent->_[HDOM_INFO_END]) && $parent!==null) { |
|
547 | + while (!isset($parent->_[HDOM_INFO_END]) && $parent !== null) { |
|
548 | 548 | $end -= 1; |
549 | 549 | $parent = $parent->parent; |
550 | 550 | } |
551 | 551 | $end += $parent->_[HDOM_INFO_END]; |
552 | 552 | } |
553 | 553 | |
554 | - for ($i=$this->_[HDOM_INFO_BEGIN]+1; $i<$end; ++$i) { |
|
554 | + for ($i = $this->_[HDOM_INFO_BEGIN] + 1; $i < $end; ++$i) { |
|
555 | 555 | $node = $this->dom->nodes[$i]; |
556 | 556 | |
557 | 557 | $pass = true; |
558 | 558 | |
559 | - if ($tag==='*' && !$key) { |
|
559 | + if ($tag === '*' && !$key) { |
|
560 | 560 | if (in_array($node, $this->children, true)) |
561 | 561 | $ret[$i] = 1; |
562 | 562 | continue; |
563 | 563 | } |
564 | 564 | |
565 | 565 | // compare tag |
566 | - if ($tag && $tag!=$node->tag && $tag!=='*') {$pass=false;} |
|
566 | + if ($tag && $tag != $node->tag && $tag !== '*') {$pass = false; } |
|
567 | 567 | // compare key |
568 | 568 | if ($pass && $key) { |
569 | 569 | if ($no_key) { |
570 | - if (isset($node->attr[$key])) $pass=false; |
|
570 | + if (isset($node->attr[$key])) $pass = false; |
|
571 | 571 | } else { |
572 | - if (($key != "plaintext") && !isset($node->attr[$key])) $pass=false; |
|
572 | + if (($key != "plaintext") && !isset($node->attr[$key])) $pass = false; |
|
573 | 573 | } |
574 | 574 | } |
575 | 575 | // compare value |
576 | - if ($pass && $key && $val && $val!=='*') { |
|
576 | + if ($pass && $key && $val && $val !== '*') { |
|
577 | 577 | // If they have told us that this is a "plaintext" search then we want the plaintext of the node - right? |
578 | 578 | if ($key == "plaintext") { |
579 | 579 | // $node->plaintext actually returns $node->text(); |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | // this is a normal search, we want the value of that attribute of the tag. |
583 | 583 | $nodeKeyValue = $node->attr[$key]; |
584 | 584 | } |
585 | - if (is_object($debugObject)) {$debugObject->debugLog(2, "testing node: " . $node->tag . " for attribute: " . $key . $exp . $val . " where nodes value is: " . $nodeKeyValue);} |
|
585 | + if (is_object($debugObject)) {$debugObject->debugLog(2, "testing node: ".$node->tag." for attribute: ".$key.$exp.$val." where nodes value is: ".$nodeKeyValue); } |
|
586 | 586 | |
587 | 587 | //PaperG - If lowercase is set, do a case insensitive test of the value of the selector. |
588 | 588 | if ($lowercase) { |
@@ -590,11 +590,11 @@ discard block |
||
590 | 590 | } else { |
591 | 591 | $check = $this->match($exp, $val, $nodeKeyValue); |
592 | 592 | } |
593 | - if (is_object($debugObject)) {$debugObject->debugLog(2, "after match: " . ($check ? "true" : "false"));} |
|
593 | + if (is_object($debugObject)) {$debugObject->debugLog(2, "after match: ".($check ? "true" : "false")); } |
|
594 | 594 | |
595 | 595 | // handle multiple class |
596 | - if (!$check && strcasecmp($key, 'class')===0) { |
|
597 | - foreach (explode(' ',$node->attr[$key]) as $k) { |
|
596 | + if (!$check && strcasecmp($key, 'class') === 0) { |
|
597 | + foreach (explode(' ', $node->attr[$key]) as $k) { |
|
598 | 598 | // Without this, there were cases where leading, trailing, or double spaces lead to our comparing blanks - bad form. |
599 | 599 | if (!empty($k)) { |
600 | 600 | if ($lowercase) { |
@@ -612,24 +612,24 @@ discard block |
||
612 | 612 | unset($node); |
613 | 613 | } |
614 | 614 | // It's passed by reference so this is actually what this function returns. |
615 | - if (is_object($debugObject)) {$debugObject->debugLog(1, "EXIT - ret: ", $ret);} |
|
615 | + if (is_object($debugObject)) {$debugObject->debugLog(1, "EXIT - ret: ", $ret); } |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | protected function match($exp, $pattern, $value) { |
619 | 619 | global $debugObject; |
620 | - if (is_object($debugObject)) {$debugObject->debugLogEntry(1);} |
|
620 | + if (is_object($debugObject)) {$debugObject->debugLogEntry(1); } |
|
621 | 621 | |
622 | 622 | switch ($exp) { |
623 | 623 | case '=': |
624 | - return ($value===$pattern); |
|
624 | + return ($value === $pattern); |
|
625 | 625 | case '!=': |
626 | - return ($value!==$pattern); |
|
626 | + return ($value !== $pattern); |
|
627 | 627 | case '^=': |
628 | - return preg_match("/^".preg_quote($pattern,'/')."/", $value); |
|
628 | + return preg_match("/^".preg_quote($pattern, '/')."/", $value); |
|
629 | 629 | case '$=': |
630 | - return preg_match("/".preg_quote($pattern,'/')."$/", $value); |
|
630 | + return preg_match("/".preg_quote($pattern, '/')."$/", $value); |
|
631 | 631 | case '*=': |
632 | - if ($pattern[0]=='/') { |
|
632 | + if ($pattern[0] == '/') { |
|
633 | 633 | return preg_match($pattern, $value); |
634 | 634 | } |
635 | 635 | return preg_match("/".$pattern."/i", $value); |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | |
640 | 640 | protected function parse_selector($selector_string) { |
641 | 641 | global $debugObject; |
642 | - if (is_object($debugObject)) {$debugObject->debugLogEntry(1);} |
|
642 | + if (is_object($debugObject)) {$debugObject->debugLogEntry(1); } |
|
643 | 643 | |
644 | 644 | // pattern of CSS selectors, modified from mootools |
645 | 645 | // Paperg: Add the colon to the attrbute, so that it properly finds <tag attr:ibute="something" > like google does. |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | // $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is"; |
651 | 651 | $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-:]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is"; |
652 | 652 | preg_match_all($pattern, trim($selector_string).' ', $matches, PREG_SET_ORDER); |
653 | - if (is_object($debugObject)) {$debugObject->debugLog(2, "Matches Array: ", $matches);} |
|
653 | + if (is_object($debugObject)) {$debugObject->debugLog(2, "Matches Array: ", $matches); } |
|
654 | 654 | |
655 | 655 | $selectors = array(); |
656 | 656 | $result = array(); |
@@ -658,29 +658,29 @@ discard block |
||
658 | 658 | |
659 | 659 | foreach ($matches as $m) { |
660 | 660 | $m[0] = trim($m[0]); |
661 | - if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue; |
|
661 | + if ($m[0] === '' || $m[0] === '/' || $m[0] === '//') continue; |
|
662 | 662 | // for browser generated xpath |
663 | - if ($m[1]==='tbody') continue; |
|
663 | + if ($m[1] === 'tbody') continue; |
|
664 | 664 | |
665 | 665 | list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false); |
666 | - if (!empty($m[2])) {$key='id'; $val=$m[2];} |
|
667 | - if (!empty($m[3])) {$key='class'; $val=$m[3];} |
|
668 | - if (!empty($m[4])) {$key=$m[4];} |
|
669 | - if (!empty($m[5])) {$exp=$m[5];} |
|
670 | - if (!empty($m[6])) {$val=$m[6];} |
|
666 | + if (!empty($m[2])) {$key = 'id'; $val = $m[2]; } |
|
667 | + if (!empty($m[3])) {$key = 'class'; $val = $m[3]; } |
|
668 | + if (!empty($m[4])) {$key = $m[4]; } |
|
669 | + if (!empty($m[5])) {$exp = $m[5]; } |
|
670 | + if (!empty($m[6])) {$val = $m[6]; } |
|
671 | 671 | |
672 | 672 | // convert to lowercase |
673 | - if ($this->dom->lowercase) {$tag=strtolower($tag); $key=strtolower($key);} |
|
673 | + if ($this->dom->lowercase) {$tag = strtolower($tag); $key = strtolower($key); } |
|
674 | 674 | //elements that do NOT have the specified attribute |
675 | - if (isset($key[0]) && $key[0]==='!') {$key=substr($key, 1); $no_key=true;} |
|
675 | + if (isset($key[0]) && $key[0] === '!') {$key = substr($key, 1); $no_key = true; } |
|
676 | 676 | |
677 | 677 | $result[] = array($tag, $key, $val, $exp, $no_key); |
678 | - if (trim($m[7])===',') { |
|
678 | + if (trim($m[7]) === ',') { |
|
679 | 679 | $selectors[] = $result; |
680 | 680 | $result = array(); |
681 | 681 | } |
682 | 682 | } |
683 | - if (count($result)>0) |
|
683 | + if (count($result) > 0) |
|
684 | 684 | $selectors[] = $result; |
685 | 685 | return $selectors; |
686 | 686 | } |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | function convert_text($text) |
733 | 733 | { |
734 | 734 | global $debugObject; |
735 | - if (is_object($debugObject)) {$debugObject->debugLogEntry(1);} |
|
735 | + if (is_object($debugObject)) {$debugObject->debugLogEntry(1); } |
|
736 | 736 | |
737 | 737 | $converted_text = $text; |
738 | 738 | |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | $sourceCharset = strtoupper($this->dom->_charset); |
745 | 745 | $targetCharset = strtoupper($this->dom->_target_charset); |
746 | 746 | } |
747 | - if (is_object($debugObject)) {$debugObject->debugLog(3, "source charset: " . $sourceCharset . " target charaset: " . $targetCharset);} |
|
747 | + if (is_object($debugObject)) {$debugObject->debugLog(3, "source charset: ".$sourceCharset." target charaset: ".$targetCharset); } |
|
748 | 748 | |
749 | 749 | if (!empty($sourceCharset) && !empty($targetCharset) && (strcasecmp($sourceCharset, $targetCharset) != 0)) |
750 | 750 | { |
@@ -783,27 +783,27 @@ discard block |
||
783 | 783 | */ |
784 | 784 | static function is_utf8($str) |
785 | 785 | { |
786 | - $c=0; $b=0; |
|
787 | - $bits=0; |
|
788 | - $len=strlen($str); |
|
789 | - for($i=0; $i<$len; $i++) |
|
786 | + $c = 0; $b = 0; |
|
787 | + $bits = 0; |
|
788 | + $len = strlen($str); |
|
789 | + for ($i = 0; $i < $len; $i++) |
|
790 | 790 | { |
791 | - $c=ord($str[$i]); |
|
792 | - if($c > 128) |
|
791 | + $c = ord($str[$i]); |
|
792 | + if ($c > 128) |
|
793 | 793 | { |
794 | - if(($c >= 254)) return false; |
|
795 | - elseif($c >= 252) $bits=6; |
|
796 | - elseif($c >= 248) $bits=5; |
|
797 | - elseif($c >= 240) $bits=4; |
|
798 | - elseif($c >= 224) $bits=3; |
|
799 | - elseif($c >= 192) $bits=2; |
|
794 | + if (($c >= 254)) return false; |
|
795 | + elseif ($c >= 252) $bits = 6; |
|
796 | + elseif ($c >= 248) $bits = 5; |
|
797 | + elseif ($c >= 240) $bits = 4; |
|
798 | + elseif ($c >= 224) $bits = 3; |
|
799 | + elseif ($c >= 192) $bits = 2; |
|
800 | 800 | else return false; |
801 | - if(($i+$bits) > $len) return false; |
|
802 | - while($bits > 1) |
|
801 | + if (($i + $bits) > $len) return false; |
|
802 | + while ($bits > 1) |
|
803 | 803 | { |
804 | 804 | $i++; |
805 | - $b=ord($str[$i]); |
|
806 | - if($b < 128 || $b > 191) return false; |
|
805 | + $b = ord($str[$i]); |
|
806 | + if ($b < 128 || $b > 191) return false; |
|
807 | 807 | $bits--; |
808 | 808 | } |
809 | 809 | } |
@@ -907,24 +907,24 @@ discard block |
||
907 | 907 | } |
908 | 908 | |
909 | 909 | // camel naming conventions |
910 | - function getAllAttributes() {return $this->attr;} |
|
911 | - function getAttribute($name) {return $this->__get($name);} |
|
912 | - function setAttribute($name, $value) {$this->__set($name, $value);} |
|
913 | - function hasAttribute($name) {return $this->__isset($name);} |
|
914 | - function removeAttribute($name) {$this->__set($name, null);} |
|
915 | - function getElementById($id) {return $this->find("#$id", 0);} |
|
916 | - function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);} |
|
917 | - function getElementByTagName($name) {return $this->find($name, 0);} |
|
918 | - function getElementsByTagName($name, $idx=null) {return $this->find($name, $idx);} |
|
919 | - function parentNode() {return $this->parent();} |
|
920 | - function childNodes($idx=-1) {return $this->children($idx);} |
|
921 | - function firstChild() {return $this->first_child();} |
|
922 | - function lastChild() {return $this->last_child();} |
|
923 | - function nextSibling() {return $this->next_sibling();} |
|
924 | - function previousSibling() {return $this->prev_sibling();} |
|
925 | - function hasChildNodes() {return $this->has_child();} |
|
926 | - function nodeName() {return $this->tag;} |
|
927 | - function appendChild($node) {$node->parent($this); return $node;} |
|
910 | + function getAllAttributes() {return $this->attr; } |
|
911 | + function getAttribute($name) {return $this->__get($name); } |
|
912 | + function setAttribute($name, $value) {$this->__set($name, $value); } |
|
913 | + function hasAttribute($name) {return $this->__isset($name); } |
|
914 | + function removeAttribute($name) {$this->__set($name, null); } |
|
915 | + function getElementById($id) {return $this->find("#$id", 0); } |
|
916 | + function getElementsById($id, $idx = null) {return $this->find("#$id", $idx); } |
|
917 | + function getElementByTagName($name) {return $this->find($name, 0); } |
|
918 | + function getElementsByTagName($name, $idx = null) {return $this->find($name, $idx); } |
|
919 | + function parentNode() {return $this->parent(); } |
|
920 | + function childNodes($idx = -1) {return $this->children($idx); } |
|
921 | + function firstChild() {return $this->first_child(); } |
|
922 | + function lastChild() {return $this->last_child(); } |
|
923 | + function nextSibling() {return $this->next_sibling(); } |
|
924 | + function previousSibling() {return $this->prev_sibling(); } |
|
925 | + function hasChildNodes() {return $this->has_child(); } |
|
926 | + function nodeName() {return $this->tag; } |
|
927 | + function appendChild($node) {$node->parent($this); return $node; } |
|
928 | 928 | |
929 | 929 | } |
930 | 930 | |
@@ -980,11 +980,11 @@ discard block |
||
980 | 980 | 'option'=>array('option'=>1), |
981 | 981 | ); |
982 | 982 | |
983 | - function __construct($str=null, $lowercase=true, $forceTagsClosed=true, $target_charset=DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) |
|
983 | + function __construct($str = null, $lowercase = true, $forceTagsClosed = true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT) |
|
984 | 984 | { |
985 | 985 | if ($str) |
986 | 986 | { |
987 | - if (preg_match("/^http:\/\//i",$str) || is_file($str)) |
|
987 | + if (preg_match("/^http:\/\//i", $str) || is_file($str)) |
|
988 | 988 | { |
989 | 989 | $this->load_file($str); |
990 | 990 | } |
@@ -995,7 +995,7 @@ discard block |
||
995 | 995 | } |
996 | 996 | // Forcing tags to be closed implies that we don't trust the html, but it can lead to parsing errors if we SHOULD trust the html. |
997 | 997 | if (!$forceTagsClosed) { |
998 | - $this->optional_closing_array=array(); |
|
998 | + $this->optional_closing_array = array(); |
|
999 | 999 | } |
1000 | 1000 | $this->_target_charset = $target_charset; |
1001 | 1001 | } |
@@ -1006,7 +1006,7 @@ discard block |
||
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | // load html from string |
1009 | - function load($str, $lowercase=true, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) |
|
1009 | + function load($str, $lowercase = true, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT) |
|
1010 | 1010 | { |
1011 | 1011 | global $debugObject; |
1012 | 1012 | |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | $args = func_get_args(); |
1049 | 1049 | $this->load(call_user_func_array('file_get_contents', $args), true); |
1050 | 1050 | // Throw an error if we can't properly load the dom. |
1051 | - if (($error=error_get_last())!==null) { |
|
1051 | + if (($error = error_get_last()) !== null) { |
|
1052 | 1052 | $this->clear(); |
1053 | 1053 | return false; |
1054 | 1054 | } |
@@ -1067,16 +1067,16 @@ discard block |
||
1067 | 1067 | } |
1068 | 1068 | |
1069 | 1069 | // save dom as string |
1070 | - function save($filepath='') |
|
1070 | + function save($filepath = '') |
|
1071 | 1071 | { |
1072 | 1072 | $ret = $this->root->innertext(); |
1073 | - if ($filepath!=='') file_put_contents($filepath, $ret, LOCK_EX); |
|
1073 | + if ($filepath !== '') file_put_contents($filepath, $ret, LOCK_EX); |
|
1074 | 1074 | return $ret; |
1075 | 1075 | } |
1076 | 1076 | |
1077 | 1077 | // find dom node by css selector |
1078 | 1078 | // Paperg - allow us to specify that we want case insensitive testing of the value of the selector. |
1079 | - function find($selector, $idx=null, $lowercase=false) |
|
1079 | + function find($selector, $idx = null, $lowercase = false) |
|
1080 | 1080 | { |
1081 | 1081 | return $this->root->find($selector, $idx, $lowercase); |
1082 | 1082 | } |
@@ -1084,22 +1084,22 @@ discard block |
||
1084 | 1084 | // clean up memory due to php5 circular references memory leak... |
1085 | 1085 | function clear() |
1086 | 1086 | { |
1087 | - foreach ($this->nodes as $n) {$n->clear(); $n = null;} |
|
1087 | + foreach ($this->nodes as $n) {$n->clear(); $n = null; } |
|
1088 | 1088 | // This add next line is documented in the sourceforge repository. 2977248 as a fix for ongoing memory leaks that occur even with the use of clear. |
1089 | - if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null;} |
|
1090 | - if (isset($this->parent)) {$this->parent->clear(); unset($this->parent);} |
|
1091 | - if (isset($this->root)) {$this->root->clear(); unset($this->root);} |
|
1089 | + if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null; } |
|
1090 | + if (isset($this->parent)) {$this->parent->clear(); unset($this->parent); } |
|
1091 | + if (isset($this->root)) {$this->root->clear(); unset($this->root); } |
|
1092 | 1092 | unset($this->doc); |
1093 | 1093 | unset($this->noise); |
1094 | 1094 | } |
1095 | 1095 | |
1096 | - function dump($show_attr=true) |
|
1096 | + function dump($show_attr = true) |
|
1097 | 1097 | { |
1098 | 1098 | $this->root->dump($show_attr); |
1099 | 1099 | } |
1100 | 1100 | |
1101 | 1101 | // prepare HTML data and init everything |
1102 | - protected function prepare($str, $lowercase=true, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) |
|
1102 | + protected function prepare($str, $lowercase = true, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT) |
|
1103 | 1103 | { |
1104 | 1104 | $this->clear(); |
1105 | 1105 | |
@@ -1130,13 +1130,13 @@ discard block |
||
1130 | 1130 | $this->root->_[HDOM_INFO_BEGIN] = -1; |
1131 | 1131 | $this->root->nodetype = HDOM_TYPE_ROOT; |
1132 | 1132 | $this->parent = $this->root; |
1133 | - if ($this->size>0) $this->char = $this->doc[0]; |
|
1133 | + if ($this->size > 0) $this->char = $this->doc[0]; |
|
1134 | 1134 | } |
1135 | 1135 | |
1136 | 1136 | // parse html content |
1137 | 1137 | protected function parse() |
1138 | 1138 | { |
1139 | - if (($s = $this->copy_until_char('<'))==='') |
|
1139 | + if (($s = $this->copy_until_char('<')) === '') |
|
1140 | 1140 | { |
1141 | 1141 | return $this->read_tag(); |
1142 | 1142 | } |
@@ -1166,18 +1166,18 @@ discard block |
||
1166 | 1166 | if ($success) |
1167 | 1167 | { |
1168 | 1168 | $charset = $matches[1]; |
1169 | - if (is_object($debugObject)) {$debugObject->debugLog(2, 'header content-type found charset of: ' . $charset);} |
|
1169 | + if (is_object($debugObject)) {$debugObject->debugLog(2, 'header content-type found charset of: '.$charset); } |
|
1170 | 1170 | } |
1171 | 1171 | |
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | if (empty($charset)) |
1175 | 1175 | { |
1176 | - $el = $this->root->find('meta[http-equiv=Content-Type]',0); |
|
1176 | + $el = $this->root->find('meta[http-equiv=Content-Type]', 0); |
|
1177 | 1177 | if (!empty($el)) |
1178 | 1178 | { |
1179 | 1179 | $fullvalue = $el->content; |
1180 | - if (is_object($debugObject)) {$debugObject->debugLog(2, 'meta content-type tag found' . $fullvalue);} |
|
1180 | + if (is_object($debugObject)) {$debugObject->debugLog(2, 'meta content-type tag found'.$fullvalue); } |
|
1181 | 1181 | |
1182 | 1182 | if (!empty($fullvalue)) |
1183 | 1183 | { |
@@ -1189,7 +1189,7 @@ discard block |
||
1189 | 1189 | else |
1190 | 1190 | { |
1191 | 1191 | // If there is a meta tag, and they don't specify the character set, research says that it's typically ISO-8859-1 |
1192 | - if (is_object($debugObject)) {$debugObject->debugLog(2, 'meta content-type tag couldn\'t be parsed. using iso-8859 default.');} |
|
1192 | + if (is_object($debugObject)) {$debugObject->debugLog(2, 'meta content-type tag couldn\'t be parsed. using iso-8859 default.'); } |
|
1193 | 1193 | $charset = 'ISO-8859-1'; |
1194 | 1194 | } |
1195 | 1195 | } |
@@ -1200,13 +1200,13 @@ discard block |
||
1200 | 1200 | if (empty($charset)) |
1201 | 1201 | { |
1202 | 1202 | // Have php try to detect the encoding from the text given to us. |
1203 | - $charset = mb_detect_encoding($this->root->plaintext . "ascii", $encoding_list = array( "UTF-8", "CP1252" ) ); |
|
1204 | - if (is_object($debugObject)) {$debugObject->debugLog(2, 'mb_detect found: ' . $charset);} |
|
1203 | + $charset = mb_detect_encoding($this->root->plaintext."ascii", $encoding_list = array("UTF-8", "CP1252")); |
|
1204 | + if (is_object($debugObject)) {$debugObject->debugLog(2, 'mb_detect found: '.$charset); } |
|
1205 | 1205 | |
1206 | 1206 | // and if this doesn't work... then we need to just wrongheadedly assume it's UTF-8 so that we can move on - cause this will usually give us most of what we need... |
1207 | 1207 | if ($charset === false) |
1208 | 1208 | { |
1209 | - if (is_object($debugObject)) {$debugObject->debugLog(2, 'since mb_detect failed - using default of utf-8');} |
|
1209 | + if (is_object($debugObject)) {$debugObject->debugLog(2, 'since mb_detect failed - using default of utf-8'); } |
|
1210 | 1210 | $charset = 'UTF-8'; |
1211 | 1211 | } |
1212 | 1212 | } |
@@ -1214,11 +1214,11 @@ discard block |
||
1214 | 1214 | // Since CP1252 is a superset, if we get one of it's subsets, we want it instead. |
1215 | 1215 | if ((strtolower($charset) == strtolower('ISO-8859-1')) || (strtolower($charset) == strtolower('Latin1')) || (strtolower($charset) == strtolower('Latin-1'))) |
1216 | 1216 | { |
1217 | - if (is_object($debugObject)) {$debugObject->debugLog(2, 'replacing ' . $charset . ' with CP1252 as its a superset');} |
|
1217 | + if (is_object($debugObject)) {$debugObject->debugLog(2, 'replacing '.$charset.' with CP1252 as its a superset'); } |
|
1218 | 1218 | $charset = 'CP1252'; |
1219 | 1219 | } |
1220 | 1220 | |
1221 | - if (is_object($debugObject)) {$debugObject->debugLog(1, 'EXIT - ' . $charset);} |
|
1221 | + if (is_object($debugObject)) {$debugObject->debugLog(1, 'EXIT - '.$charset); } |
|
1222 | 1222 | |
1223 | 1223 | return $this->_charset = $charset; |
1224 | 1224 | } |
@@ -1226,41 +1226,41 @@ discard block |
||
1226 | 1226 | // read tag info |
1227 | 1227 | protected function read_tag() |
1228 | 1228 | { |
1229 | - if ($this->char!=='<') |
|
1229 | + if ($this->char !== '<') |
|
1230 | 1230 | { |
1231 | 1231 | $this->root->_[HDOM_INFO_END] = $this->cursor; |
1232 | 1232 | return false; |
1233 | 1233 | } |
1234 | 1234 | $begin_tag_pos = $this->pos; |
1235 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1235 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1236 | 1236 | |
1237 | 1237 | // end tag |
1238 | - if ($this->char==='/') |
|
1238 | + if ($this->char === '/') |
|
1239 | 1239 | { |
1240 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1240 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1241 | 1241 | // This represents the change in the simple_html_dom trunk from revision 180 to 181. |
1242 | 1242 | // $this->skip($this->token_blank_t); |
1243 | 1243 | $this->skip($this->token_blank); |
1244 | 1244 | $tag = $this->copy_until_char('>'); |
1245 | 1245 | |
1246 | 1246 | // skip attributes in end tag |
1247 | - if (($pos = strpos($tag, ' '))!==false) |
|
1247 | + if (($pos = strpos($tag, ' ')) !== false) |
|
1248 | 1248 | $tag = substr($tag, 0, $pos); |
1249 | 1249 | |
1250 | 1250 | $parent_lower = strtolower($this->parent->tag); |
1251 | 1251 | $tag_lower = strtolower($tag); |
1252 | 1252 | |
1253 | - if ($parent_lower!==$tag_lower) |
|
1253 | + if ($parent_lower !== $tag_lower) |
|
1254 | 1254 | { |
1255 | 1255 | if (isset($this->optional_closing_tags[$parent_lower]) && isset($this->block_tags[$tag_lower])) |
1256 | 1256 | { |
1257 | 1257 | $this->parent->_[HDOM_INFO_END] = 0; |
1258 | 1258 | $org_parent = $this->parent; |
1259 | 1259 | |
1260 | - while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) |
|
1260 | + while (($this->parent->parent) && strtolower($this->parent->tag) !== $tag_lower) |
|
1261 | 1261 | $this->parent = $this->parent->parent; |
1262 | 1262 | |
1263 | - if (strtolower($this->parent->tag)!==$tag_lower) { |
|
1263 | + if (strtolower($this->parent->tag) !== $tag_lower) { |
|
1264 | 1264 | $this->parent = $org_parent; // restore origonal parent |
1265 | 1265 | if ($this->parent->parent) $this->parent = $this->parent->parent; |
1266 | 1266 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
@@ -1272,17 +1272,17 @@ discard block |
||
1272 | 1272 | $this->parent->_[HDOM_INFO_END] = 0; |
1273 | 1273 | $org_parent = $this->parent; |
1274 | 1274 | |
1275 | - while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) |
|
1275 | + while (($this->parent->parent) && strtolower($this->parent->tag) !== $tag_lower) |
|
1276 | 1276 | $this->parent = $this->parent->parent; |
1277 | 1277 | |
1278 | - if (strtolower($this->parent->tag)!==$tag_lower) |
|
1278 | + if (strtolower($this->parent->tag) !== $tag_lower) |
|
1279 | 1279 | { |
1280 | 1280 | $this->parent = $org_parent; // restore origonal parent |
1281 | 1281 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
1282 | 1282 | return $this->as_text_node($tag); |
1283 | 1283 | } |
1284 | 1284 | } |
1285 | - else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower) |
|
1285 | + else if (($this->parent->parent) && strtolower($this->parent->parent->tag) === $tag_lower) |
|
1286 | 1286 | { |
1287 | 1287 | $this->parent->_[HDOM_INFO_END] = 0; |
1288 | 1288 | $this->parent = $this->parent->parent; |
@@ -1294,7 +1294,7 @@ discard block |
||
1294 | 1294 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
1295 | 1295 | if ($this->parent->parent) $this->parent = $this->parent->parent; |
1296 | 1296 | |
1297 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1297 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1298 | 1298 | return true; |
1299 | 1299 | } |
1300 | 1300 | |
@@ -1305,25 +1305,25 @@ discard block |
||
1305 | 1305 | $node->tag_start = $begin_tag_pos; |
1306 | 1306 | |
1307 | 1307 | // doctype, cdata & comments... |
1308 | - if (isset($tag[0]) && $tag[0]==='!') { |
|
1309 | - $node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until_char('>'); |
|
1308 | + if (isset($tag[0]) && $tag[0] === '!') { |
|
1309 | + $node->_[HDOM_INFO_TEXT] = '<'.$tag.$this->copy_until_char('>'); |
|
1310 | 1310 | |
1311 | - if (isset($tag[2]) && $tag[1]==='-' && $tag[2]==='-') { |
|
1311 | + if (isset($tag[2]) && $tag[1] === '-' && $tag[2] === '-') { |
|
1312 | 1312 | $node->nodetype = HDOM_TYPE_COMMENT; |
1313 | 1313 | $node->tag = 'comment'; |
1314 | 1314 | } else { |
1315 | 1315 | $node->nodetype = HDOM_TYPE_UNKNOWN; |
1316 | 1316 | $node->tag = 'unknown'; |
1317 | 1317 | } |
1318 | - if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>'; |
|
1318 | + if ($this->char === '>') $node->_[HDOM_INFO_TEXT] .= '>'; |
|
1319 | 1319 | $this->link_nodes($node, true); |
1320 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1320 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1321 | 1321 | return true; |
1322 | 1322 | } |
1323 | 1323 | |
1324 | 1324 | // text |
1325 | - if ($pos=strpos($tag, '<')!==false) { |
|
1326 | - $tag = '<' . substr($tag, 0, -1); |
|
1325 | + if ($pos = strpos($tag, '<') !== false) { |
|
1326 | + $tag = '<'.substr($tag, 0, -1); |
|
1327 | 1327 | $node->_[HDOM_INFO_TEXT] = $tag; |
1328 | 1328 | $this->link_nodes($node, false); |
1329 | 1329 | $this->char = $this->doc[--$this->pos]; // prev |
@@ -1331,15 +1331,15 @@ discard block |
||
1331 | 1331 | } |
1332 | 1332 | |
1333 | 1333 | if (!preg_match("/^[\w-:]+$/", $tag)) { |
1334 | - $node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until('<>'); |
|
1335 | - if ($this->char==='<') { |
|
1334 | + $node->_[HDOM_INFO_TEXT] = '<'.$tag.$this->copy_until('<>'); |
|
1335 | + if ($this->char === '<') { |
|
1336 | 1336 | $this->link_nodes($node, false); |
1337 | 1337 | return true; |
1338 | 1338 | } |
1339 | 1339 | |
1340 | - if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>'; |
|
1340 | + if ($this->char === '>') $node->_[HDOM_INFO_TEXT] .= '>'; |
|
1341 | 1341 | $this->link_nodes($node, false); |
1342 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1342 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1343 | 1343 | return true; |
1344 | 1344 | } |
1345 | 1345 | |
@@ -1349,7 +1349,7 @@ discard block |
||
1349 | 1349 | $node->tag = ($this->lowercase) ? $tag_lower : $tag; |
1350 | 1350 | |
1351 | 1351 | // handle optional closing tags |
1352 | - if (isset($this->optional_closing_tags[$tag_lower]) ) |
|
1352 | + if (isset($this->optional_closing_tags[$tag_lower])) |
|
1353 | 1353 | { |
1354 | 1354 | while (isset($this->optional_closing_tags[$tag_lower][strtolower($this->parent->tag)])) |
1355 | 1355 | { |
@@ -1365,67 +1365,67 @@ discard block |
||
1365 | 1365 | // attributes |
1366 | 1366 | do |
1367 | 1367 | { |
1368 | - if ($this->char!==null && $space[0]==='') |
|
1368 | + if ($this->char !== null && $space[0] === '') |
|
1369 | 1369 | { |
1370 | 1370 | break; |
1371 | 1371 | } |
1372 | 1372 | $name = $this->copy_until($this->token_equal); |
1373 | - if ($guard===$this->pos) |
|
1373 | + if ($guard === $this->pos) |
|
1374 | 1374 | { |
1375 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1375 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1376 | 1376 | continue; |
1377 | 1377 | } |
1378 | 1378 | $guard = $this->pos; |
1379 | 1379 | |
1380 | 1380 | // handle endless '<' |
1381 | - if ($this->pos>=$this->size-1 && $this->char!=='>') { |
|
1381 | + if ($this->pos >= $this->size - 1 && $this->char !== '>') { |
|
1382 | 1382 | $node->nodetype = HDOM_TYPE_TEXT; |
1383 | 1383 | $node->_[HDOM_INFO_END] = 0; |
1384 | - $node->_[HDOM_INFO_TEXT] = '<'.$tag . $space[0] . $name; |
|
1384 | + $node->_[HDOM_INFO_TEXT] = '<'.$tag.$space[0].$name; |
|
1385 | 1385 | $node->tag = 'text'; |
1386 | 1386 | $this->link_nodes($node, false); |
1387 | 1387 | return true; |
1388 | 1388 | } |
1389 | 1389 | |
1390 | 1390 | // handle mismatch '<' |
1391 | - if ($this->doc[$this->pos-1]=='<') { |
|
1391 | + if ($this->doc[$this->pos - 1] == '<') { |
|
1392 | 1392 | $node->nodetype = HDOM_TYPE_TEXT; |
1393 | 1393 | $node->tag = 'text'; |
1394 | 1394 | $node->attr = array(); |
1395 | 1395 | $node->_[HDOM_INFO_END] = 0; |
1396 | - $node->_[HDOM_INFO_TEXT] = substr($this->doc, $begin_tag_pos, $this->pos-$begin_tag_pos-1); |
|
1396 | + $node->_[HDOM_INFO_TEXT] = substr($this->doc, $begin_tag_pos, $this->pos - $begin_tag_pos - 1); |
|
1397 | 1397 | $this->pos -= 2; |
1398 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1398 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1399 | 1399 | $this->link_nodes($node, false); |
1400 | 1400 | return true; |
1401 | 1401 | } |
1402 | 1402 | |
1403 | - if ($name!=='/' && $name!=='') { |
|
1403 | + if ($name !== '/' && $name !== '') { |
|
1404 | 1404 | $space[1] = $this->copy_skip($this->token_blank); |
1405 | 1405 | $name = $this->restore_noise($name); |
1406 | 1406 | if ($this->lowercase) $name = strtolower($name); |
1407 | - if ($this->char==='=') { |
|
1408 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1407 | + if ($this->char === '=') { |
|
1408 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1409 | 1409 | $this->parse_attr($node, $name, $space); |
1410 | 1410 | } |
1411 | 1411 | else { |
1412 | 1412 | //no value attr: nowrap, checked selected... |
1413 | 1413 | $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO; |
1414 | 1414 | $node->attr[$name] = true; |
1415 | - if ($this->char!='>') $this->char = $this->doc[--$this->pos]; // prev |
|
1415 | + if ($this->char != '>') $this->char = $this->doc[--$this->pos]; // prev |
|
1416 | 1416 | } |
1417 | 1417 | $node->_[HDOM_INFO_SPACE][] = $space; |
1418 | 1418 | $space = array($this->copy_skip($this->token_blank), '', ''); |
1419 | 1419 | } |
1420 | 1420 | else |
1421 | 1421 | break; |
1422 | - } while ($this->char!=='>' && $this->char!=='/'); |
|
1422 | + } while ($this->char !== '>' && $this->char !== '/'); |
|
1423 | 1423 | |
1424 | 1424 | $this->link_nodes($node, true); |
1425 | 1425 | $node->_[HDOM_INFO_ENDSPACE] = $space[0]; |
1426 | 1426 | |
1427 | 1427 | // check self closing |
1428 | - if ($this->copy_until_char_escape('>')==='/') |
|
1428 | + if ($this->copy_until_char_escape('>') === '/') |
|
1429 | 1429 | { |
1430 | 1430 | $node->_[HDOM_INFO_ENDSPACE] .= '/'; |
1431 | 1431 | $node->_[HDOM_INFO_END] = 0; |
@@ -1435,7 +1435,7 @@ discard block |
||
1435 | 1435 | // reset parent |
1436 | 1436 | if (!isset($this->self_closing_tags[strtolower($node->tag)])) $this->parent = $node; |
1437 | 1437 | } |
1438 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1438 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1439 | 1439 | |
1440 | 1440 | // If it's a BR tag, we need to set it's text to the default text. |
1441 | 1441 | // This way when we see it in plaintext, we can generate formatting that the user wants. |
@@ -1462,15 +1462,15 @@ discard block |
||
1462 | 1462 | switch ($this->char) { |
1463 | 1463 | case '"': |
1464 | 1464 | $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE; |
1465 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1465 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1466 | 1466 | $node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('"')); |
1467 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1467 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1468 | 1468 | break; |
1469 | 1469 | case '\'': |
1470 | 1470 | $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_SINGLE; |
1471 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1471 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1472 | 1472 | $node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('\'')); |
1473 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1473 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1474 | 1474 | break; |
1475 | 1475 | default: |
1476 | 1476 | $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO; |
@@ -1501,16 +1501,16 @@ discard block |
||
1501 | 1501 | { |
1502 | 1502 | $node = new simple_html_dom_node($this); |
1503 | 1503 | ++$this->cursor; |
1504 | - $node->_[HDOM_INFO_TEXT] = '</' . $tag . '>'; |
|
1504 | + $node->_[HDOM_INFO_TEXT] = '</'.$tag.'>'; |
|
1505 | 1505 | $this->link_nodes($node, false); |
1506 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1506 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1507 | 1507 | return true; |
1508 | 1508 | } |
1509 | 1509 | |
1510 | 1510 | protected function skip($chars) |
1511 | 1511 | { |
1512 | 1512 | $this->pos += strspn($this->doc, $chars, $this->pos); |
1513 | - $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1513 | + $this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1514 | 1514 | } |
1515 | 1515 | |
1516 | 1516 | protected function copy_skip($chars) |
@@ -1518,8 +1518,8 @@ discard block |
||
1518 | 1518 | $pos = $this->pos; |
1519 | 1519 | $len = strspn($this->doc, $chars, $pos); |
1520 | 1520 | $this->pos += $len; |
1521 | - $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1522 | - if ($len===0) return ''; |
|
1521 | + $this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1522 | + if ($len === 0) return ''; |
|
1523 | 1523 | return substr($this->doc, $pos, $len); |
1524 | 1524 | } |
1525 | 1525 | |
@@ -1528,70 +1528,70 @@ discard block |
||
1528 | 1528 | $pos = $this->pos; |
1529 | 1529 | $len = strcspn($this->doc, $chars, $pos); |
1530 | 1530 | $this->pos += $len; |
1531 | - $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
1531 | + $this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
1532 | 1532 | return substr($this->doc, $pos, $len); |
1533 | 1533 | } |
1534 | 1534 | |
1535 | 1535 | protected function copy_until_char($char) |
1536 | 1536 | { |
1537 | - if ($this->char===null) return ''; |
|
1537 | + if ($this->char === null) return ''; |
|
1538 | 1538 | |
1539 | - if (($pos = strpos($this->doc, $char, $this->pos))===false) { |
|
1540 | - $ret = substr($this->doc, $this->pos, $this->size-$this->pos); |
|
1539 | + if (($pos = strpos($this->doc, $char, $this->pos)) === false) { |
|
1540 | + $ret = substr($this->doc, $this->pos, $this->size - $this->pos); |
|
1541 | 1541 | $this->char = null; |
1542 | 1542 | $this->pos = $this->size; |
1543 | 1543 | return $ret; |
1544 | 1544 | } |
1545 | 1545 | |
1546 | - if ($pos===$this->pos) return ''; |
|
1546 | + if ($pos === $this->pos) return ''; |
|
1547 | 1547 | $pos_old = $this->pos; |
1548 | 1548 | $this->char = $this->doc[$pos]; |
1549 | 1549 | $this->pos = $pos; |
1550 | - return substr($this->doc, $pos_old, $pos-$pos_old); |
|
1550 | + return substr($this->doc, $pos_old, $pos - $pos_old); |
|
1551 | 1551 | } |
1552 | 1552 | |
1553 | 1553 | protected function copy_until_char_escape($char) |
1554 | 1554 | { |
1555 | - if ($this->char===null) return ''; |
|
1555 | + if ($this->char === null) return ''; |
|
1556 | 1556 | |
1557 | 1557 | $start = $this->pos; |
1558 | 1558 | while (1) |
1559 | 1559 | { |
1560 | - if (($pos = strpos($this->doc, $char, $start))===false) |
|
1560 | + if (($pos = strpos($this->doc, $char, $start)) === false) |
|
1561 | 1561 | { |
1562 | - $ret = substr($this->doc, $this->pos, $this->size-$this->pos); |
|
1562 | + $ret = substr($this->doc, $this->pos, $this->size - $this->pos); |
|
1563 | 1563 | $this->char = null; |
1564 | 1564 | $this->pos = $this->size; |
1565 | 1565 | return $ret; |
1566 | 1566 | } |
1567 | 1567 | |
1568 | - if ($pos===$this->pos) return ''; |
|
1568 | + if ($pos === $this->pos) return ''; |
|
1569 | 1569 | |
1570 | - if ($this->doc[$pos-1]==='\\') { |
|
1571 | - $start = $pos+1; |
|
1570 | + if ($this->doc[$pos - 1] === '\\') { |
|
1571 | + $start = $pos + 1; |
|
1572 | 1572 | continue; |
1573 | 1573 | } |
1574 | 1574 | |
1575 | 1575 | $pos_old = $this->pos; |
1576 | 1576 | $this->char = $this->doc[$pos]; |
1577 | 1577 | $this->pos = $pos; |
1578 | - return substr($this->doc, $pos_old, $pos-$pos_old); |
|
1578 | + return substr($this->doc, $pos_old, $pos - $pos_old); |
|
1579 | 1579 | } |
1580 | 1580 | } |
1581 | 1581 | |
1582 | 1582 | // remove noise from html content |
1583 | 1583 | // save the noise in the $this->noise array. |
1584 | - protected function remove_noise($pattern, $remove_tag=false) |
|
1584 | + protected function remove_noise($pattern, $remove_tag = false) |
|
1585 | 1585 | { |
1586 | 1586 | global $debugObject; |
1587 | 1587 | if (is_object($debugObject)) { $debugObject->debugLogEntry(1); } |
1588 | 1588 | |
1589 | - $count = preg_match_all($pattern, $this->doc, $matches, PREG_SET_ORDER|PREG_OFFSET_CAPTURE); |
|
1589 | + $count = preg_match_all($pattern, $this->doc, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE); |
|
1590 | 1590 | |
1591 | - for ($i=$count-1; $i>-1; --$i) |
|
1591 | + for ($i = $count - 1; $i > -1; --$i) |
|
1592 | 1592 | { |
1593 | - $key = '___noise___'.sprintf('% 5d', count($this->noise)+1000); |
|
1594 | - if (is_object($debugObject)) { $debugObject->debugLog(2, 'key is: ' . $key); } |
|
1593 | + $key = '___noise___'.sprintf('% 5d', count($this->noise) + 1000); |
|
1594 | + if (is_object($debugObject)) { $debugObject->debugLog(2, 'key is: '.$key); } |
|
1595 | 1595 | $idx = ($remove_tag) ? 0 : 1; |
1596 | 1596 | $this->noise[$key] = $matches[$i][$idx][0]; |
1597 | 1597 | $this->doc = substr_replace($this->doc, $key, $matches[$i][$idx][1], strlen($matches[$i][$idx][0])); |
@@ -1599,7 +1599,7 @@ discard block |
||
1599 | 1599 | |
1600 | 1600 | // reset the length of content |
1601 | 1601 | $this->size = strlen($this->doc); |
1602 | - if ($this->size>0) |
|
1602 | + if ($this->size > 0) |
|
1603 | 1603 | { |
1604 | 1604 | $this->char = $this->doc[0]; |
1605 | 1605 | } |
@@ -1611,28 +1611,28 @@ discard block |
||
1611 | 1611 | global $debugObject; |
1612 | 1612 | if (is_object($debugObject)) { $debugObject->debugLogEntry(1); } |
1613 | 1613 | |
1614 | - while (($pos=strpos($text, '___noise___'))!==false) |
|
1614 | + while (($pos = strpos($text, '___noise___')) !== false) |
|
1615 | 1615 | { |
1616 | 1616 | // Sometimes there is a broken piece of markup, and we don't GET the pos+11 etc... token which indicates a problem outside of us... |
1617 | - if (strlen($text) > $pos+15) |
|
1617 | + if (strlen($text) > $pos + 15) |
|
1618 | 1618 | { |
1619 | - $key = '___noise___'.$text[$pos+11].$text[$pos+12].$text[$pos+13].$text[$pos+14].$text[$pos+15]; |
|
1620 | - if (is_object($debugObject)) { $debugObject->debugLog(2, 'located key of: ' . $key); } |
|
1619 | + $key = '___noise___'.$text[$pos + 11].$text[$pos + 12].$text[$pos + 13].$text[$pos + 14].$text[$pos + 15]; |
|
1620 | + if (is_object($debugObject)) { $debugObject->debugLog(2, 'located key of: '.$key); } |
|
1621 | 1621 | |
1622 | 1622 | if (isset($this->noise[$key])) |
1623 | 1623 | { |
1624 | - $text = substr($text, 0, $pos).$this->noise[$key].substr($text, $pos+16); |
|
1624 | + $text = substr($text, 0, $pos).$this->noise[$key].substr($text, $pos + 16); |
|
1625 | 1625 | } |
1626 | 1626 | else |
1627 | 1627 | { |
1628 | 1628 | // do this to prevent an infinite loop. |
1629 | - $text = substr($text, 0, $pos).'UNDEFINED NOISE FOR KEY: '.$key . substr($text, $pos+16); |
|
1629 | + $text = substr($text, 0, $pos).'UNDEFINED NOISE FOR KEY: '.$key.substr($text, $pos + 16); |
|
1630 | 1630 | } |
1631 | 1631 | } |
1632 | 1632 | else |
1633 | 1633 | { |
1634 | 1634 | // There is no valid key being given back to us... We must get rid of the ___noise___ or we will have a problem. |
1635 | - $text = substr($text, 0, $pos).'NO NUMERIC NOISE KEY' . substr($text, $pos+11); |
|
1635 | + $text = substr($text, 0, $pos).'NO NUMERIC NOISE KEY'.substr($text, $pos + 11); |
|
1636 | 1636 | } |
1637 | 1637 | } |
1638 | 1638 | return $text; |
@@ -1644,9 +1644,9 @@ discard block |
||
1644 | 1644 | global $debugObject; |
1645 | 1645 | if (is_object($debugObject)) { $debugObject->debugLogEntry(1); } |
1646 | 1646 | |
1647 | - foreach($this->noise as $noiseElement) |
|
1647 | + foreach ($this->noise as $noiseElement) |
|
1648 | 1648 | { |
1649 | - if (strpos($noiseElement, $text)!==false) |
|
1649 | + if (strpos($noiseElement, $text) !== false) |
|
1650 | 1650 | { |
1651 | 1651 | return $noiseElement; |
1652 | 1652 | } |
@@ -1675,16 +1675,16 @@ discard block |
||
1675 | 1675 | } |
1676 | 1676 | |
1677 | 1677 | // camel naming conventions |
1678 | - function childNodes($idx=-1) {return $this->root->childNodes($idx);} |
|
1679 | - function firstChild() {return $this->root->first_child();} |
|
1680 | - function lastChild() {return $this->root->last_child();} |
|
1681 | - function createElement($name, $value=null) {return @str_get_html("<$name>$value</$name>")->first_child();} |
|
1682 | - function createTextNode($value) {return @end(str_get_html($value)->nodes);} |
|
1683 | - function getElementById($id) {return $this->find("#$id", 0);} |
|
1684 | - function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);} |
|
1685 | - function getElementByTagName($name) {return $this->find($name, 0);} |
|
1686 | - function getElementsByTagName($name, $idx=-1) {return $this->find($name, $idx);} |
|
1687 | - function loadFile() {$args = func_get_args();$this->load_file($args);} |
|
1678 | + function childNodes($idx = -1) {return $this->root->childNodes($idx); } |
|
1679 | + function firstChild() {return $this->root->first_child(); } |
|
1680 | + function lastChild() {return $this->root->last_child(); } |
|
1681 | + function createElement($name, $value = null) {return @str_get_html("<$name>$value</$name>")->first_child(); } |
|
1682 | + function createTextNode($value) {return @end(str_get_html($value)->nodes); } |
|
1683 | + function getElementById($id) {return $this->find("#$id", 0); } |
|
1684 | + function getElementsById($id, $idx = null) {return $this->find("#$id", $idx); } |
|
1685 | + function getElementByTagName($name) {return $this->find($name, 0); } |
|
1686 | + function getElementsByTagName($name, $idx = -1) {return $this->find($name, $idx); } |
|
1687 | + function loadFile() {$args = func_get_args(); $this->load_file($args); } |
|
1688 | 1688 | } |
1689 | 1689 | |
1690 | 1690 | ?> |
1691 | 1691 | \ No newline at end of file |
@@ -126,8 +126,9 @@ discard block |
||
126 | 126 | if ($show_attr && count($this->attr)>0) |
127 | 127 | { |
128 | 128 | echo '('; |
129 | - foreach ($this->attr as $k=>$v) |
|
130 | - echo "[$k]=>\"".$this->$k.'", '; |
|
129 | + foreach ($this->attr as $k=>$v) { |
|
130 | + echo "[$k]=>\"".$this->$k.'", '; |
|
131 | + } |
|
131 | 132 | echo ')'; |
132 | 133 | } |
133 | 134 | echo "\n"; |
@@ -185,8 +186,7 @@ discard block |
||
185 | 186 | if (isset($node->_[HDOM_INFO_INNER])) |
186 | 187 | { |
187 | 188 | $string .= $node->_[HDOM_INFO_INNER] . "'"; |
188 | - } |
|
189 | - else |
|
189 | + } else |
|
190 | 190 | { |
191 | 191 | $string .= ' NULL '; |
192 | 192 | } |
@@ -200,8 +200,7 @@ discard block |
||
200 | 200 | { |
201 | 201 | echo $string; |
202 | 202 | return; |
203 | - } |
|
204 | - else |
|
203 | + } else |
|
205 | 204 | { |
206 | 205 | return $string; |
207 | 206 | } |
@@ -236,7 +235,9 @@ discard block |
||
236 | 235 | { |
237 | 236 | return $this->children; |
238 | 237 | } |
239 | - if (isset($this->children[$idx])) return $this->children[$idx]; |
|
238 | + if (isset($this->children[$idx])) { |
|
239 | + return $this->children[$idx]; |
|
240 | + } |
|
240 | 241 | return null; |
241 | 242 | } |
242 | 243 | |
@@ -284,12 +285,17 @@ discard block |
||
284 | 285 | // returns the previous sibling of node |
285 | 286 | function prev_sibling() |
286 | 287 | { |
287 | - if ($this->parent===null) return null; |
|
288 | + if ($this->parent===null) { |
|
289 | + return null; |
|
290 | + } |
|
288 | 291 | $idx = 0; |
289 | 292 | $count = count($this->parent->children); |
290 | - while ($idx<$count && $this!==$this->parent->children[$idx]) |
|
291 | - ++$idx; |
|
292 | - if (--$idx<0) return null; |
|
293 | + while ($idx<$count && $this!==$this->parent->children[$idx]) { |
|
294 | + ++$idx; |
|
295 | + } |
|
296 | + if (--$idx<0) { |
|
297 | + return null; |
|
298 | + } |
|
293 | 299 | return $this->parent->children[$idx]; |
294 | 300 | } |
295 | 301 | |
@@ -318,12 +324,17 @@ discard block |
||
318 | 324 | // get dom node's inner html |
319 | 325 | function innertext() |
320 | 326 | { |
321 | - if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER]; |
|
322 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
327 | + if (isset($this->_[HDOM_INFO_INNER])) { |
|
328 | + return $this->_[HDOM_INFO_INNER]; |
|
329 | + } |
|
330 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
331 | + return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
332 | + } |
|
323 | 333 | |
324 | 334 | $ret = ''; |
325 | - foreach ($this->nodes as $n) |
|
326 | - $ret .= $n->outertext(); |
|
335 | + foreach ($this->nodes as $n) { |
|
336 | + $ret .= $n->outertext(); |
|
337 | + } |
|
327 | 338 | return $ret; |
328 | 339 | } |
329 | 340 | |
@@ -344,7 +355,9 @@ discard block |
||
344 | 355 | $debugObject->debugLog(1, 'Innertext of tag: ' . $this->tag . $text); |
345 | 356 | } |
346 | 357 | |
347 | - if ($this->tag==='root') return $this->innertext(); |
|
358 | + if ($this->tag==='root') { |
|
359 | + return $this->innertext(); |
|
360 | + } |
|
348 | 361 | |
349 | 362 | // trigger callback |
350 | 363 | if ($this->dom && $this->dom->callback!==null) |
@@ -352,8 +365,12 @@ discard block |
||
352 | 365 | call_user_func_array($this->dom->callback, array($this)); |
353 | 366 | } |
354 | 367 | |
355 | - if (isset($this->_[HDOM_INFO_OUTER])) return $this->_[HDOM_INFO_OUTER]; |
|
356 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
368 | + if (isset($this->_[HDOM_INFO_OUTER])) { |
|
369 | + return $this->_[HDOM_INFO_OUTER]; |
|
370 | + } |
|
371 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
372 | + return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
373 | + } |
|
357 | 374 | |
358 | 375 | // render begin tag |
359 | 376 | if ($this->dom && $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]) |
@@ -382,23 +399,30 @@ discard block |
||
382 | 399 | } |
383 | 400 | |
384 | 401 | // render end tag |
385 | - if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0) |
|
386 | - $ret .= '</'.$this->tag.'>'; |
|
402 | + if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0) { |
|
403 | + $ret .= '</'.$this->tag.'>'; |
|
404 | + } |
|
387 | 405 | return $ret; |
388 | 406 | } |
389 | 407 | |
390 | 408 | // get dom node's plain text |
391 | 409 | function text() |
392 | 410 | { |
393 | - if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER]; |
|
411 | + if (isset($this->_[HDOM_INFO_INNER])) { |
|
412 | + return $this->_[HDOM_INFO_INNER]; |
|
413 | + } |
|
394 | 414 | switch ($this->nodetype) |
395 | 415 | { |
396 | 416 | case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
397 | 417 | case HDOM_TYPE_COMMENT: return ''; |
398 | 418 | case HDOM_TYPE_UNKNOWN: return ''; |
399 | 419 | } |
400 | - if (strcasecmp($this->tag, 'script')===0) return ''; |
|
401 | - if (strcasecmp($this->tag, 'style')===0) return ''; |
|
420 | + if (strcasecmp($this->tag, 'script')===0) { |
|
421 | + return ''; |
|
422 | + } |
|
423 | + if (strcasecmp($this->tag, 'style')===0) { |
|
424 | + return ''; |
|
425 | + } |
|
402 | 426 | |
403 | 427 | $ret = ''; |
404 | 428 | // In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL. |
@@ -434,7 +458,9 @@ discard block |
||
434 | 458 | function makeup() |
435 | 459 | { |
436 | 460 | // text, comment, unknown |
437 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
461 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
462 | + return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
463 | + } |
|
438 | 464 | |
439 | 465 | $ret = '<'.$this->tag; |
440 | 466 | $i = -1; |
@@ -444,14 +470,15 @@ discard block |
||
444 | 470 | ++$i; |
445 | 471 | |
446 | 472 | // skip removed attribute |
447 | - if ($val===null || $val===false) |
|
448 | - continue; |
|
473 | + if ($val===null || $val===false) { |
|
474 | + continue; |
|
475 | + } |
|
449 | 476 | |
450 | 477 | $ret .= $this->_[HDOM_INFO_SPACE][$i][0]; |
451 | 478 | //no value attr: nowrap, checked selected... |
452 | - if ($val===true) |
|
453 | - $ret .= $key; |
|
454 | - else { |
|
479 | + if ($val===true) { |
|
480 | + $ret .= $key; |
|
481 | + } else { |
|
455 | 482 | switch ($this->_[HDOM_INFO_QUOTE][$i]) |
456 | 483 | { |
457 | 484 | case HDOM_QUOTE_DOUBLE: $quote = '"'; break; |
@@ -470,7 +497,9 @@ discard block |
||
470 | 497 | function find($selector, $idx=null, $lowercase=false) |
471 | 498 | { |
472 | 499 | $selectors = $this->parse_selector($selector); |
473 | - if (($count=count($selectors))===0) return array(); |
|
500 | + if (($count=count($selectors))===0) { |
|
501 | + return array(); |
|
502 | + } |
|
474 | 503 | $found_keys = array(); |
475 | 504 | |
476 | 505 | // find each selector |
@@ -478,8 +507,12 @@ discard block |
||
478 | 507 | { |
479 | 508 | // The change on the below line was documented on the sourceforge code tracker id 2788009 |
480 | 509 | // used to be: if (($levle=count($selectors[0]))===0) return array(); |
481 | - if (($levle=count($selectors[$c]))===0) return array(); |
|
482 | - if (!isset($this->_[HDOM_INFO_BEGIN])) return array(); |
|
510 | + if (($levle=count($selectors[$c]))===0) { |
|
511 | + return array(); |
|
512 | + } |
|
513 | + if (!isset($this->_[HDOM_INFO_BEGIN])) { |
|
514 | + return array(); |
|
515 | + } |
|
483 | 516 | |
484 | 517 | $head = array($this->_[HDOM_INFO_BEGIN]=>1); |
485 | 518 | |
@@ -498,8 +531,9 @@ discard block |
||
498 | 531 | |
499 | 532 | foreach ($head as $k=>$v) |
500 | 533 | { |
501 | - if (!isset($found_keys[$k])) |
|
502 | - $found_keys[$k] = 1; |
|
534 | + if (!isset($found_keys[$k])) { |
|
535 | + $found_keys[$k] = 1; |
|
536 | + } |
|
503 | 537 | } |
504 | 538 | } |
505 | 539 | |
@@ -507,12 +541,16 @@ discard block |
||
507 | 541 | ksort($found_keys); |
508 | 542 | |
509 | 543 | $found = array(); |
510 | - foreach ($found_keys as $k=>$v) |
|
511 | - $found[] = $this->dom->nodes[$k]; |
|
544 | + foreach ($found_keys as $k=>$v) { |
|
545 | + $found[] = $this->dom->nodes[$k]; |
|
546 | + } |
|
512 | 547 | |
513 | 548 | // return nth-element or array |
514 | - if (is_null($idx)) return $found; |
|
515 | - else if ($idx<0) $idx = count($found) + $idx; |
|
549 | + if (is_null($idx)) { |
|
550 | + return $found; |
|
551 | + } else if ($idx<0) { |
|
552 | + $idx = count($found) + $idx; |
|
553 | + } |
|
516 | 554 | return (isset($found[$idx])) ? $found[$idx] : null; |
517 | 555 | } |
518 | 556 | |
@@ -557,8 +595,9 @@ discard block |
||
557 | 595 | $pass = true; |
558 | 596 | |
559 | 597 | if ($tag==='*' && !$key) { |
560 | - if (in_array($node, $this->children, true)) |
|
561 | - $ret[$i] = 1; |
|
598 | + if (in_array($node, $this->children, true)) { |
|
599 | + $ret[$i] = 1; |
|
600 | + } |
|
562 | 601 | continue; |
563 | 602 | } |
564 | 603 | |
@@ -567,9 +606,13 @@ discard block |
||
567 | 606 | // compare key |
568 | 607 | if ($pass && $key) { |
569 | 608 | if ($no_key) { |
570 | - if (isset($node->attr[$key])) $pass=false; |
|
609 | + if (isset($node->attr[$key])) { |
|
610 | + $pass=false; |
|
611 | + } |
|
571 | 612 | } else { |
572 | - if (($key != "plaintext") && !isset($node->attr[$key])) $pass=false; |
|
613 | + if (($key != "plaintext") && !isset($node->attr[$key])) { |
|
614 | + $pass=false; |
|
615 | + } |
|
573 | 616 | } |
574 | 617 | } |
575 | 618 | // compare value |
@@ -602,20 +645,27 @@ discard block |
||
602 | 645 | } else { |
603 | 646 | $check = $this->match($exp, $val, $k); |
604 | 647 | } |
605 | - if ($check) break; |
|
648 | + if ($check) { |
|
649 | + break; |
|
650 | + } |
|
606 | 651 | } |
607 | 652 | } |
608 | 653 | } |
609 | - if (!$check) $pass = false; |
|
654 | + if (!$check) { |
|
655 | + $pass = false; |
|
656 | + } |
|
657 | + } |
|
658 | + if ($pass) { |
|
659 | + $ret[$i] = 1; |
|
610 | 660 | } |
611 | - if ($pass) $ret[$i] = 1; |
|
612 | 661 | unset($node); |
613 | 662 | } |
614 | 663 | // It's passed by reference so this is actually what this function returns. |
615 | 664 | if (is_object($debugObject)) {$debugObject->debugLog(1, "EXIT - ret: ", $ret);} |
616 | 665 | } |
617 | 666 | |
618 | - protected function match($exp, $pattern, $value) { |
|
667 | + protected function match($exp, $pattern, $value) |
|
668 | + { |
|
619 | 669 | global $debugObject; |
620 | 670 | if (is_object($debugObject)) {$debugObject->debugLogEntry(1);} |
621 | 671 | |
@@ -637,7 +687,8 @@ discard block |
||
637 | 687 | return false; |
638 | 688 | } |
639 | 689 | |
640 | - protected function parse_selector($selector_string) { |
|
690 | + protected function parse_selector($selector_string) |
|
691 | + { |
|
641 | 692 | global $debugObject; |
642 | 693 | if (is_object($debugObject)) {$debugObject->debugLogEntry(1);} |
643 | 694 | |
@@ -658,9 +709,13 @@ discard block |
||
658 | 709 | |
659 | 710 | foreach ($matches as $m) { |
660 | 711 | $m[0] = trim($m[0]); |
661 | - if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue; |
|
712 | + if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') { |
|
713 | + continue; |
|
714 | + } |
|
662 | 715 | // for browser generated xpath |
663 | - if ($m[1]==='tbody') continue; |
|
716 | + if ($m[1]==='tbody') { |
|
717 | + continue; |
|
718 | + } |
|
664 | 719 | |
665 | 720 | list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false); |
666 | 721 | if (!empty($m[2])) {$key='id'; $val=$m[2];} |
@@ -680,12 +735,14 @@ discard block |
||
680 | 735 | $result = array(); |
681 | 736 | } |
682 | 737 | } |
683 | - if (count($result)>0) |
|
684 | - $selectors[] = $result; |
|
738 | + if (count($result)>0) { |
|
739 | + $selectors[] = $result; |
|
740 | + } |
|
685 | 741 | return $selectors; |
686 | 742 | } |
687 | 743 | |
688 | - function __get($name) { |
|
744 | + function __get($name) |
|
745 | + { |
|
689 | 746 | if (isset($this->attr[$name])) |
690 | 747 | { |
691 | 748 | return $this->convert_text($this->attr[$name]); |
@@ -699,11 +756,14 @@ discard block |
||
699 | 756 | } |
700 | 757 | } |
701 | 758 | |
702 | - function __set($name, $value) { |
|
759 | + function __set($name, $value) |
|
760 | + { |
|
703 | 761 | switch ($name) { |
704 | 762 | case 'outertext': return $this->_[HDOM_INFO_OUTER] = $value; |
705 | 763 | case 'innertext': |
706 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->_[HDOM_INFO_TEXT] = $value; |
|
764 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
765 | + return $this->_[HDOM_INFO_TEXT] = $value; |
|
766 | + } |
|
707 | 767 | return $this->_[HDOM_INFO_INNER] = $value; |
708 | 768 | } |
709 | 769 | if (!isset($this->attr[$name])) { |
@@ -713,7 +773,8 @@ discard block |
||
713 | 773 | $this->attr[$name] = $value; |
714 | 774 | } |
715 | 775 | |
716 | - function __isset($name) { |
|
776 | + function __isset($name) |
|
777 | + { |
|
717 | 778 | switch ($name) { |
718 | 779 | case 'outertext': return true; |
719 | 780 | case 'innertext': return true; |
@@ -723,9 +784,11 @@ discard block |
||
723 | 784 | return (array_key_exists($name, $this->attr)) ? true : isset($this->attr[$name]); |
724 | 785 | } |
725 | 786 | |
726 | - function __unset($name) { |
|
727 | - if (isset($this->attr[$name])) |
|
728 | - unset($this->attr[$name]); |
|
787 | + function __unset($name) |
|
788 | + { |
|
789 | + if (isset($this->attr[$name])) { |
|
790 | + unset($this->attr[$name]); |
|
791 | + } |
|
729 | 792 | } |
730 | 793 | |
731 | 794 | // PaperG - Function to convert the text from one character set to another if the two sets are not the same. |
@@ -752,8 +815,7 @@ discard block |
||
752 | 815 | if ((strcasecmp($targetCharset, 'UTF-8') == 0) && ($this->is_utf8($text))) |
753 | 816 | { |
754 | 817 | $converted_text = $text; |
755 | - } |
|
756 | - else |
|
818 | + } else |
|
757 | 819 | { |
758 | 820 | $converted_text = iconv($sourceCharset, $targetCharset, $text); |
759 | 821 | } |
@@ -791,19 +853,31 @@ discard block |
||
791 | 853 | $c=ord($str[$i]); |
792 | 854 | if($c > 128) |
793 | 855 | { |
794 | - if(($c >= 254)) return false; |
|
795 | - elseif($c >= 252) $bits=6; |
|
796 | - elseif($c >= 248) $bits=5; |
|
797 | - elseif($c >= 240) $bits=4; |
|
798 | - elseif($c >= 224) $bits=3; |
|
799 | - elseif($c >= 192) $bits=2; |
|
800 | - else return false; |
|
801 | - if(($i+$bits) > $len) return false; |
|
856 | + if(($c >= 254)) { |
|
857 | + return false; |
|
858 | + } elseif($c >= 252) { |
|
859 | + $bits=6; |
|
860 | + } elseif($c >= 248) { |
|
861 | + $bits=5; |
|
862 | + } elseif($c >= 240) { |
|
863 | + $bits=4; |
|
864 | + } elseif($c >= 224) { |
|
865 | + $bits=3; |
|
866 | + } elseif($c >= 192) { |
|
867 | + $bits=2; |
|
868 | + } else { |
|
869 | + return false; |
|
870 | + } |
|
871 | + if(($i+$bits) > $len) { |
|
872 | + return false; |
|
873 | + } |
|
802 | 874 | while($bits > 1) |
803 | 875 | { |
804 | 876 | $i++; |
805 | 877 | $b=ord($str[$i]); |
806 | - if($b < 128 || $b > 191) return false; |
|
878 | + if($b < 128 || $b > 191) { |
|
879 | + return false; |
|
880 | + } |
|
807 | 881 | $bits--; |
808 | 882 | } |
809 | 883 | } |
@@ -907,24 +981,60 @@ discard block |
||
907 | 981 | } |
908 | 982 | |
909 | 983 | // camel naming conventions |
910 | - function getAllAttributes() {return $this->attr;} |
|
911 | - function getAttribute($name) {return $this->__get($name);} |
|
912 | - function setAttribute($name, $value) {$this->__set($name, $value);} |
|
913 | - function hasAttribute($name) {return $this->__isset($name);} |
|
914 | - function removeAttribute($name) {$this->__set($name, null);} |
|
915 | - function getElementById($id) {return $this->find("#$id", 0);} |
|
916 | - function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);} |
|
917 | - function getElementByTagName($name) {return $this->find($name, 0);} |
|
918 | - function getElementsByTagName($name, $idx=null) {return $this->find($name, $idx);} |
|
919 | - function parentNode() {return $this->parent();} |
|
920 | - function childNodes($idx=-1) {return $this->children($idx);} |
|
921 | - function firstChild() {return $this->first_child();} |
|
922 | - function lastChild() {return $this->last_child();} |
|
923 | - function nextSibling() {return $this->next_sibling();} |
|
924 | - function previousSibling() {return $this->prev_sibling();} |
|
925 | - function hasChildNodes() {return $this->has_child();} |
|
926 | - function nodeName() {return $this->tag;} |
|
927 | - function appendChild($node) {$node->parent($this); return $node;} |
|
984 | + function getAllAttributes() |
|
985 | + { |
|
986 | +return $this->attr;} |
|
987 | + function getAttribute($name) |
|
988 | + { |
|
989 | +return $this->__get($name);} |
|
990 | + function setAttribute($name, $value) |
|
991 | + { |
|
992 | +$this->__set($name, $value);} |
|
993 | + function hasAttribute($name) |
|
994 | + { |
|
995 | +return $this->__isset($name);} |
|
996 | + function removeAttribute($name) |
|
997 | + { |
|
998 | +$this->__set($name, null);} |
|
999 | + function getElementById($id) |
|
1000 | + { |
|
1001 | +return $this->find("#$id", 0);} |
|
1002 | + function getElementsById($id, $idx=null) |
|
1003 | + { |
|
1004 | +return $this->find("#$id", $idx);} |
|
1005 | + function getElementByTagName($name) |
|
1006 | + { |
|
1007 | +return $this->find($name, 0);} |
|
1008 | + function getElementsByTagName($name, $idx=null) |
|
1009 | + { |
|
1010 | +return $this->find($name, $idx);} |
|
1011 | + function parentNode() |
|
1012 | + { |
|
1013 | +return $this->parent();} |
|
1014 | + function childNodes($idx=-1) |
|
1015 | + { |
|
1016 | +return $this->children($idx);} |
|
1017 | + function firstChild() |
|
1018 | + { |
|
1019 | +return $this->first_child();} |
|
1020 | + function lastChild() |
|
1021 | + { |
|
1022 | +return $this->last_child();} |
|
1023 | + function nextSibling() |
|
1024 | + { |
|
1025 | +return $this->next_sibling();} |
|
1026 | + function previousSibling() |
|
1027 | + { |
|
1028 | +return $this->prev_sibling();} |
|
1029 | + function hasChildNodes() |
|
1030 | + { |
|
1031 | +return $this->has_child();} |
|
1032 | + function nodeName() |
|
1033 | + { |
|
1034 | +return $this->tag;} |
|
1035 | + function appendChild($node) |
|
1036 | + { |
|
1037 | +$node->parent($this); return $node;} |
|
928 | 1038 | |
929 | 1039 | } |
930 | 1040 | |
@@ -987,8 +1097,7 @@ discard block |
||
987 | 1097 | if (preg_match("/^http:\/\//i",$str) || is_file($str)) |
988 | 1098 | { |
989 | 1099 | $this->load_file($str); |
990 | - } |
|
991 | - else |
|
1100 | + } else |
|
992 | 1101 | { |
993 | 1102 | $this->load($str, $lowercase, $stripRN, $defaultBRText, $defaultSpanText); |
994 | 1103 | } |
@@ -1070,7 +1179,9 @@ discard block |
||
1070 | 1179 | function save($filepath='') |
1071 | 1180 | { |
1072 | 1181 | $ret = $this->root->innertext(); |
1073 | - if ($filepath!=='') file_put_contents($filepath, $ret, LOCK_EX); |
|
1182 | + if ($filepath!=='') { |
|
1183 | + file_put_contents($filepath, $ret, LOCK_EX); |
|
1184 | + } |
|
1074 | 1185 | return $ret; |
1075 | 1186 | } |
1076 | 1187 | |
@@ -1086,7 +1197,10 @@ discard block |
||
1086 | 1197 | { |
1087 | 1198 | foreach ($this->nodes as $n) {$n->clear(); $n = null;} |
1088 | 1199 | // This add next line is documented in the sourceforge repository. 2977248 as a fix for ongoing memory leaks that occur even with the use of clear. |
1089 | - if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null;} |
|
1200 | + if (isset($this->children)) { |
|
1201 | + foreach ($this->children as $n) {$n->clear(); |
|
1202 | + } |
|
1203 | + $n = null;} |
|
1090 | 1204 | if (isset($this->parent)) {$this->parent->clear(); unset($this->parent);} |
1091 | 1205 | if (isset($this->root)) {$this->root->clear(); unset($this->root);} |
1092 | 1206 | unset($this->doc); |
@@ -1130,7 +1244,9 @@ discard block |
||
1130 | 1244 | $this->root->_[HDOM_INFO_BEGIN] = -1; |
1131 | 1245 | $this->root->nodetype = HDOM_TYPE_ROOT; |
1132 | 1246 | $this->parent = $this->root; |
1133 | - if ($this->size>0) $this->char = $this->doc[0]; |
|
1247 | + if ($this->size>0) { |
|
1248 | + $this->char = $this->doc[0]; |
|
1249 | + } |
|
1134 | 1250 | } |
1135 | 1251 | |
1136 | 1252 | // parse html content |
@@ -1185,8 +1301,7 @@ discard block |
||
1185 | 1301 | if ($success) |
1186 | 1302 | { |
1187 | 1303 | $charset = $matches[1]; |
1188 | - } |
|
1189 | - else |
|
1304 | + } else |
|
1190 | 1305 | { |
1191 | 1306 | // If there is a meta tag, and they don't specify the character set, research says that it's typically ISO-8859-1 |
1192 | 1307 | if (is_object($debugObject)) {$debugObject->debugLog(2, 'meta content-type tag couldn\'t be parsed. using iso-8859 default.');} |
@@ -1244,8 +1359,9 @@ discard block |
||
1244 | 1359 | $tag = $this->copy_until_char('>'); |
1245 | 1360 | |
1246 | 1361 | // skip attributes in end tag |
1247 | - if (($pos = strpos($tag, ' '))!==false) |
|
1248 | - $tag = substr($tag, 0, $pos); |
|
1362 | + if (($pos = strpos($tag, ' '))!==false) { |
|
1363 | + $tag = substr($tag, 0, $pos); |
|
1364 | + } |
|
1249 | 1365 | |
1250 | 1366 | $parent_lower = strtolower($this->parent->tag); |
1251 | 1367 | $tag_lower = strtolower($tag); |
@@ -1257,23 +1373,26 @@ discard block |
||
1257 | 1373 | $this->parent->_[HDOM_INFO_END] = 0; |
1258 | 1374 | $org_parent = $this->parent; |
1259 | 1375 | |
1260 | - while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) |
|
1261 | - $this->parent = $this->parent->parent; |
|
1376 | + while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) { |
|
1377 | + $this->parent = $this->parent->parent; |
|
1378 | + } |
|
1262 | 1379 | |
1263 | 1380 | if (strtolower($this->parent->tag)!==$tag_lower) { |
1264 | 1381 | $this->parent = $org_parent; // restore origonal parent |
1265 | - if ($this->parent->parent) $this->parent = $this->parent->parent; |
|
1382 | + if ($this->parent->parent) { |
|
1383 | + $this->parent = $this->parent->parent; |
|
1384 | + } |
|
1266 | 1385 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
1267 | 1386 | return $this->as_text_node($tag); |
1268 | 1387 | } |
1269 | - } |
|
1270 | - else if (($this->parent->parent) && isset($this->block_tags[$tag_lower])) |
|
1388 | + } else if (($this->parent->parent) && isset($this->block_tags[$tag_lower])) |
|
1271 | 1389 | { |
1272 | 1390 | $this->parent->_[HDOM_INFO_END] = 0; |
1273 | 1391 | $org_parent = $this->parent; |
1274 | 1392 | |
1275 | - while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) |
|
1276 | - $this->parent = $this->parent->parent; |
|
1393 | + while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) { |
|
1394 | + $this->parent = $this->parent->parent; |
|
1395 | + } |
|
1277 | 1396 | |
1278 | 1397 | if (strtolower($this->parent->tag)!==$tag_lower) |
1279 | 1398 | { |
@@ -1281,18 +1400,19 @@ discard block |
||
1281 | 1400 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
1282 | 1401 | return $this->as_text_node($tag); |
1283 | 1402 | } |
1284 | - } |
|
1285 | - else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower) |
|
1403 | + } else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower) |
|
1286 | 1404 | { |
1287 | 1405 | $this->parent->_[HDOM_INFO_END] = 0; |
1288 | 1406 | $this->parent = $this->parent->parent; |
1407 | + } else { |
|
1408 | + return $this->as_text_node($tag); |
|
1289 | 1409 | } |
1290 | - else |
|
1291 | - return $this->as_text_node($tag); |
|
1292 | 1410 | } |
1293 | 1411 | |
1294 | 1412 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
1295 | - if ($this->parent->parent) $this->parent = $this->parent->parent; |
|
1413 | + if ($this->parent->parent) { |
|
1414 | + $this->parent = $this->parent->parent; |
|
1415 | + } |
|
1296 | 1416 | |
1297 | 1417 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1298 | 1418 | return true; |
@@ -1315,7 +1435,9 @@ discard block |
||
1315 | 1435 | $node->nodetype = HDOM_TYPE_UNKNOWN; |
1316 | 1436 | $node->tag = 'unknown'; |
1317 | 1437 | } |
1318 | - if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>'; |
|
1438 | + if ($this->char==='>') { |
|
1439 | + $node->_[HDOM_INFO_TEXT].='>'; |
|
1440 | + } |
|
1319 | 1441 | $this->link_nodes($node, true); |
1320 | 1442 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1321 | 1443 | return true; |
@@ -1337,7 +1459,9 @@ discard block |
||
1337 | 1459 | return true; |
1338 | 1460 | } |
1339 | 1461 | |
1340 | - if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>'; |
|
1462 | + if ($this->char==='>') { |
|
1463 | + $node->_[HDOM_INFO_TEXT].='>'; |
|
1464 | + } |
|
1341 | 1465 | $this->link_nodes($node, false); |
1342 | 1466 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1343 | 1467 | return true; |
@@ -1403,22 +1527,26 @@ discard block |
||
1403 | 1527 | if ($name!=='/' && $name!=='') { |
1404 | 1528 | $space[1] = $this->copy_skip($this->token_blank); |
1405 | 1529 | $name = $this->restore_noise($name); |
1406 | - if ($this->lowercase) $name = strtolower($name); |
|
1530 | + if ($this->lowercase) { |
|
1531 | + $name = strtolower($name); |
|
1532 | + } |
|
1407 | 1533 | if ($this->char==='=') { |
1408 | 1534 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1409 | 1535 | $this->parse_attr($node, $name, $space); |
1410 | - } |
|
1411 | - else { |
|
1536 | + } else { |
|
1412 | 1537 | //no value attr: nowrap, checked selected... |
1413 | 1538 | $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO; |
1414 | 1539 | $node->attr[$name] = true; |
1415 | - if ($this->char!='>') $this->char = $this->doc[--$this->pos]; // prev |
|
1540 | + if ($this->char!='>') { |
|
1541 | + $this->char = $this->doc[--$this->pos]; |
|
1542 | + } |
|
1543 | + // prev |
|
1416 | 1544 | } |
1417 | 1545 | $node->_[HDOM_INFO_SPACE][] = $space; |
1418 | 1546 | $space = array($this->copy_skip($this->token_blank), '', ''); |
1547 | + } else { |
|
1548 | + break; |
|
1419 | 1549 | } |
1420 | - else |
|
1421 | - break; |
|
1422 | 1550 | } while ($this->char!=='>' && $this->char!=='/'); |
1423 | 1551 | |
1424 | 1552 | $this->link_nodes($node, true); |
@@ -1429,11 +1557,12 @@ discard block |
||
1429 | 1557 | { |
1430 | 1558 | $node->_[HDOM_INFO_ENDSPACE] .= '/'; |
1431 | 1559 | $node->_[HDOM_INFO_END] = 0; |
1432 | - } |
|
1433 | - else |
|
1560 | + } else |
|
1434 | 1561 | { |
1435 | 1562 | // reset parent |
1436 | - if (!isset($this->self_closing_tags[strtolower($node->tag)])) $this->parent = $node; |
|
1563 | + if (!isset($this->self_closing_tags[strtolower($node->tag)])) { |
|
1564 | + $this->parent = $node; |
|
1565 | + } |
|
1437 | 1566 | } |
1438 | 1567 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1439 | 1568 | |
@@ -1519,7 +1648,9 @@ discard block |
||
1519 | 1648 | $len = strspn($this->doc, $chars, $pos); |
1520 | 1649 | $this->pos += $len; |
1521 | 1650 | $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1522 | - if ($len===0) return ''; |
|
1651 | + if ($len===0) { |
|
1652 | + return ''; |
|
1653 | + } |
|
1523 | 1654 | return substr($this->doc, $pos, $len); |
1524 | 1655 | } |
1525 | 1656 | |
@@ -1534,7 +1665,9 @@ discard block |
||
1534 | 1665 | |
1535 | 1666 | protected function copy_until_char($char) |
1536 | 1667 | { |
1537 | - if ($this->char===null) return ''; |
|
1668 | + if ($this->char===null) { |
|
1669 | + return ''; |
|
1670 | + } |
|
1538 | 1671 | |
1539 | 1672 | if (($pos = strpos($this->doc, $char, $this->pos))===false) { |
1540 | 1673 | $ret = substr($this->doc, $this->pos, $this->size-$this->pos); |
@@ -1543,7 +1676,9 @@ discard block |
||
1543 | 1676 | return $ret; |
1544 | 1677 | } |
1545 | 1678 | |
1546 | - if ($pos===$this->pos) return ''; |
|
1679 | + if ($pos===$this->pos) { |
|
1680 | + return ''; |
|
1681 | + } |
|
1547 | 1682 | $pos_old = $this->pos; |
1548 | 1683 | $this->char = $this->doc[$pos]; |
1549 | 1684 | $this->pos = $pos; |
@@ -1552,7 +1687,9 @@ discard block |
||
1552 | 1687 | |
1553 | 1688 | protected function copy_until_char_escape($char) |
1554 | 1689 | { |
1555 | - if ($this->char===null) return ''; |
|
1690 | + if ($this->char===null) { |
|
1691 | + return ''; |
|
1692 | + } |
|
1556 | 1693 | |
1557 | 1694 | $start = $this->pos; |
1558 | 1695 | while (1) |
@@ -1565,7 +1702,9 @@ discard block |
||
1565 | 1702 | return $ret; |
1566 | 1703 | } |
1567 | 1704 | |
1568 | - if ($pos===$this->pos) return ''; |
|
1705 | + if ($pos===$this->pos) { |
|
1706 | + return ''; |
|
1707 | + } |
|
1569 | 1708 | |
1570 | 1709 | if ($this->doc[$pos-1]==='\\') { |
1571 | 1710 | $start = $pos+1; |
@@ -1622,14 +1761,12 @@ discard block |
||
1622 | 1761 | if (isset($this->noise[$key])) |
1623 | 1762 | { |
1624 | 1763 | $text = substr($text, 0, $pos).$this->noise[$key].substr($text, $pos+16); |
1625 | - } |
|
1626 | - else |
|
1764 | + } else |
|
1627 | 1765 | { |
1628 | 1766 | // do this to prevent an infinite loop. |
1629 | 1767 | $text = substr($text, 0, $pos).'UNDEFINED NOISE FOR KEY: '.$key . substr($text, $pos+16); |
1630 | 1768 | } |
1631 | - } |
|
1632 | - else |
|
1769 | + } else |
|
1633 | 1770 | { |
1634 | 1771 | // There is no valid key being given back to us... We must get rid of the ___noise___ or we will have a problem. |
1635 | 1772 | $text = substr($text, 0, $pos).'NO NUMERIC NOISE KEY' . substr($text, $pos+11); |
@@ -1675,16 +1812,36 @@ discard block |
||
1675 | 1812 | } |
1676 | 1813 | |
1677 | 1814 | // camel naming conventions |
1678 | - function childNodes($idx=-1) {return $this->root->childNodes($idx);} |
|
1679 | - function firstChild() {return $this->root->first_child();} |
|
1680 | - function lastChild() {return $this->root->last_child();} |
|
1681 | - function createElement($name, $value=null) {return @str_get_html("<$name>$value</$name>")->first_child();} |
|
1682 | - function createTextNode($value) {return @end(str_get_html($value)->nodes);} |
|
1683 | - function getElementById($id) {return $this->find("#$id", 0);} |
|
1684 | - function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);} |
|
1685 | - function getElementByTagName($name) {return $this->find($name, 0);} |
|
1686 | - function getElementsByTagName($name, $idx=-1) {return $this->find($name, $idx);} |
|
1687 | - function loadFile() {$args = func_get_args();$this->load_file($args);} |
|
1815 | + function childNodes($idx=-1) |
|
1816 | + { |
|
1817 | +return $this->root->childNodes($idx);} |
|
1818 | + function firstChild() |
|
1819 | + { |
|
1820 | +return $this->root->first_child();} |
|
1821 | + function lastChild() |
|
1822 | + { |
|
1823 | +return $this->root->last_child();} |
|
1824 | + function createElement($name, $value=null) |
|
1825 | + { |
|
1826 | +return @str_get_html("<$name>$value</$name>")->first_child();} |
|
1827 | + function createTextNode($value) |
|
1828 | + { |
|
1829 | +return @end(str_get_html($value)->nodes);} |
|
1830 | + function getElementById($id) |
|
1831 | + { |
|
1832 | +return $this->find("#$id", 0);} |
|
1833 | + function getElementsById($id, $idx=null) |
|
1834 | + { |
|
1835 | +return $this->find("#$id", $idx);} |
|
1836 | + function getElementByTagName($name) |
|
1837 | + { |
|
1838 | +return $this->find($name, 0);} |
|
1839 | + function getElementsByTagName($name, $idx=-1) |
|
1840 | + { |
|
1841 | +return $this->find($name, $idx);} |
|
1842 | + function loadFile() |
|
1843 | + { |
|
1844 | +$args = func_get_args();$this->load_file($args);} |
|
1688 | 1845 | } |
1689 | 1846 | |
1690 | 1847 | ?> |
1691 | 1848 | \ No newline at end of file |
@@ -1064,10 +1064,10 @@ discard block |
||
1064 | 1064 | $list = imap_rfc822_parse_adrlist($addrstr, ''); |
1065 | 1065 | foreach ($list as $address) { |
1066 | 1066 | if ('.SYNTAX-ERROR.' != $address->host) { |
1067 | - if (static::validateAddress($address->mailbox . '@' . $address->host)) { |
|
1067 | + if (static::validateAddress($address->mailbox.'@'.$address->host)) { |
|
1068 | 1068 | $addresses[] = [ |
1069 | 1069 | 'name' => (property_exists($address, 'personal') ? $address->personal : ''), |
1070 | - 'address' => $address->mailbox . '@' . $address->host, |
|
1070 | + 'address' => $address->mailbox.'@'.$address->host, |
|
1071 | 1071 | ]; |
1072 | 1072 | } |
1073 | 1073 | } |
@@ -1213,14 +1213,14 @@ discard block |
||
1213 | 1213 | * Feel free to use and redistribute this code. But please keep this copyright notice. |
1214 | 1214 | */ |
1215 | 1215 | return (bool) preg_match( |
1216 | - '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' . |
|
1217 | - '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' . |
|
1218 | - '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' . |
|
1219 | - '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' . |
|
1220 | - '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' . |
|
1221 | - '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' . |
|
1222 | - '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' . |
|
1223 | - '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' . |
|
1216 | + '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)'. |
|
1217 | + '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)'. |
|
1218 | + '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)'. |
|
1219 | + '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*'. |
|
1220 | + '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)'. |
|
1221 | + '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}'. |
|
1222 | + '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:'. |
|
1223 | + '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}'. |
|
1224 | 1224 | '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD', |
1225 | 1225 | $address |
1226 | 1226 | ); |
@@ -1231,7 +1231,7 @@ discard block |
||
1231 | 1231 | * @see http://www.whatwg.org/specs/web-apps/current-work/#e-mail-state-(type=email) |
1232 | 1232 | */ |
1233 | 1233 | return (bool) preg_match( |
1234 | - '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}' . |
|
1234 | + '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}'. |
|
1235 | 1235 | '[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD', |
1236 | 1236 | $address |
1237 | 1237 | ); |
@@ -1282,7 +1282,7 @@ discard block |
||
1282 | 1282 | $errorcode = 0; |
1283 | 1283 | $punycode = idn_to_ascii($domain, $errorcode, INTL_IDNA_VARIANT_UTS46); |
1284 | 1284 | if (false !== $punycode) { |
1285 | - return substr($address, 0, $pos) . $punycode; |
|
1285 | + return substr($address, 0, $pos).$punycode; |
|
1286 | 1286 | } |
1287 | 1287 | } |
1288 | 1288 | } |
@@ -1346,8 +1346,8 @@ discard block |
||
1346 | 1346 | and version_compare(PHP_VERSION, '7.1.3', '<'))) |
1347 | 1347 | ) { |
1348 | 1348 | trigger_error( |
1349 | - 'Your version of PHP is affected by a bug that may result in corrupted messages.' . |
|
1350 | - ' To fix it, switch to sending using SMTP, disable the mail.add_x_header option in' . |
|
1349 | + 'Your version of PHP is affected by a bug that may result in corrupted messages.'. |
|
1350 | + ' To fix it, switch to sending using SMTP, disable the mail.add_x_header option in'. |
|
1351 | 1351 | ' your php.ini, switch to MacOS or Linux, or upgrade your PHP to version 7.0.17+ or 7.1.3+.', |
1352 | 1352 | E_USER_WARNING |
1353 | 1353 | ); |
@@ -1431,12 +1431,12 @@ discard block |
||
1431 | 1431 | ) |
1432 | 1432 | ) { |
1433 | 1433 | $header_dkim = $this->DKIM_Add( |
1434 | - $this->MIMEHeader . $this->mailHeader, |
|
1434 | + $this->MIMEHeader.$this->mailHeader, |
|
1435 | 1435 | $this->encodeHeader($this->secureHeader($this->Subject)), |
1436 | 1436 | $this->MIMEBody |
1437 | 1437 | ); |
1438 | - $this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ") . static::$LE . |
|
1439 | - static::normalizeBreaks($header_dkim) . static::$LE; |
|
1438 | + $this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ").static::$LE. |
|
1439 | + static::normalizeBreaks($header_dkim).static::$LE; |
|
1440 | 1440 | } |
1441 | 1441 | |
1442 | 1442 | return true; |
@@ -1470,7 +1470,7 @@ discard block |
||
1470 | 1470 | case 'mail': |
1471 | 1471 | return $this->mailSend($this->MIMEHeader, $this->MIMEBody); |
1472 | 1472 | default: |
1473 | - $sendMethod = $this->Mailer . 'Send'; |
|
1473 | + $sendMethod = $this->Mailer.'Send'; |
|
1474 | 1474 | if (method_exists($this, $sendMethod)) { |
1475 | 1475 | return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody); |
1476 | 1476 | } |
@@ -1523,9 +1523,9 @@ discard block |
||
1523 | 1523 | foreach ($this->SingleToArray as $toAddr) { |
1524 | 1524 | $mail = @popen($sendmail, 'w'); |
1525 | 1525 | if (!$mail) { |
1526 | - throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); |
|
1526 | + throw new Exception($this->lang('execute').$this->Sendmail, self::STOP_CRITICAL); |
|
1527 | 1527 | } |
1528 | - fwrite($mail, 'To: ' . $toAddr . "\n"); |
|
1528 | + fwrite($mail, 'To: '.$toAddr."\n"); |
|
1529 | 1529 | fwrite($mail, $header); |
1530 | 1530 | fwrite($mail, $body); |
1531 | 1531 | $result = pclose($mail); |
@@ -1540,13 +1540,13 @@ discard block |
||
1540 | 1540 | [] |
1541 | 1541 | ); |
1542 | 1542 | if (0 !== $result) { |
1543 | - throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); |
|
1543 | + throw new Exception($this->lang('execute').$this->Sendmail, self::STOP_CRITICAL); |
|
1544 | 1544 | } |
1545 | 1545 | } |
1546 | 1546 | } else { |
1547 | 1547 | $mail = @popen($sendmail, 'w'); |
1548 | 1548 | if (!$mail) { |
1549 | - throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); |
|
1549 | + throw new Exception($this->lang('execute').$this->Sendmail, self::STOP_CRITICAL); |
|
1550 | 1550 | } |
1551 | 1551 | fwrite($mail, $header); |
1552 | 1552 | fwrite($mail, $body); |
@@ -1562,7 +1562,7 @@ discard block |
||
1562 | 1562 | [] |
1563 | 1563 | ); |
1564 | 1564 | if (0 !== $result) { |
1565 | - throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); |
|
1565 | + throw new Exception($this->lang('execute').$this->Sendmail, self::STOP_CRITICAL); |
|
1566 | 1566 | } |
1567 | 1567 | } |
1568 | 1568 | |
@@ -1720,7 +1720,7 @@ discard block |
||
1720 | 1720 | $smtp_from = $this->Sender; |
1721 | 1721 | } |
1722 | 1722 | if (!$this->smtp->mail($smtp_from)) { |
1723 | - $this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError())); |
|
1723 | + $this->setError($this->lang('from_failed').$smtp_from.' : '.implode(',', $this->smtp->getError())); |
|
1724 | 1724 | throw new Exception($this->ErrorInfo, self::STOP_CRITICAL); |
1725 | 1725 | } |
1726 | 1726 | |
@@ -1741,7 +1741,7 @@ discard block |
||
1741 | 1741 | } |
1742 | 1742 | |
1743 | 1743 | // Only send the DATA command if we have viable recipients |
1744 | - if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header . $body)) { |
|
1744 | + if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header.$body)) { |
|
1745 | 1745 | throw new Exception($this->lang('data_not_accepted'), self::STOP_CRITICAL); |
1746 | 1746 | } |
1747 | 1747 | |
@@ -1771,10 +1771,10 @@ discard block |
||
1771 | 1771 | if (count($bad_rcpt) > 0) { |
1772 | 1772 | $errstr = ''; |
1773 | 1773 | foreach ($bad_rcpt as $bad) { |
1774 | - $errstr .= $bad['to'] . ': ' . $bad['error']; |
|
1774 | + $errstr .= $bad['to'].': '.$bad['error']; |
|
1775 | 1775 | } |
1776 | 1776 | throw new Exception( |
1777 | - $this->lang('recipients_failed') . $errstr, |
|
1777 | + $this->lang('recipients_failed').$errstr, |
|
1778 | 1778 | self::STOP_CONTINUE |
1779 | 1779 | ); |
1780 | 1780 | } |
@@ -1824,7 +1824,7 @@ discard block |
||
1824 | 1824 | trim($hostentry), |
1825 | 1825 | $hostinfo |
1826 | 1826 | )) { |
1827 | - static::edebug($this->lang('connect_host') . ' ' . $hostentry); |
|
1827 | + static::edebug($this->lang('connect_host').' '.$hostentry); |
|
1828 | 1828 | // Not a valid host entry |
1829 | 1829 | continue; |
1830 | 1830 | } |
@@ -1836,7 +1836,7 @@ discard block |
||
1836 | 1836 | |
1837 | 1837 | //Check the host name is a valid name or IP address before trying to use it |
1838 | 1838 | if (!static::isValidHost($hostinfo[3])) { |
1839 | - static::edebug($this->lang('connect_host') . ' ' . $hostentry); |
|
1839 | + static::edebug($this->lang('connect_host').' '.$hostentry); |
|
1840 | 1840 | continue; |
1841 | 1841 | } |
1842 | 1842 | $prefix = ''; |
@@ -1856,7 +1856,7 @@ discard block |
||
1856 | 1856 | if ('tls' === $secure or 'ssl' === $secure) { |
1857 | 1857 | //Check for an OpenSSL constant rather than using extension_loaded, which is sometimes disabled |
1858 | 1858 | if (!$sslext) { |
1859 | - throw new Exception($this->lang('extension_missing') . 'openssl', self::STOP_CRITICAL); |
|
1859 | + throw new Exception($this->lang('extension_missing').'openssl', self::STOP_CRITICAL); |
|
1860 | 1860 | } |
1861 | 1861 | } |
1862 | 1862 | $host = $hostinfo[3]; |
@@ -1865,7 +1865,7 @@ discard block |
||
1865 | 1865 | if ($tport > 0 and $tport < 65536) { |
1866 | 1866 | $port = $tport; |
1867 | 1867 | } |
1868 | - if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) { |
|
1868 | + if ($this->smtp->connect($prefix.$host, $port, $this->Timeout, $options)) { |
|
1869 | 1869 | try { |
1870 | 1870 | if ($this->Helo) { |
1871 | 1871 | $hello = $this->Helo; |
@@ -1982,14 +1982,14 @@ discard block |
||
1982 | 1982 | ]; |
1983 | 1983 | if (empty($lang_path)) { |
1984 | 1984 | // Calculate an absolute path so it can work if CWD is not here |
1985 | - $lang_path = __DIR__ . DIRECTORY_SEPARATOR . 'language' . DIRECTORY_SEPARATOR; |
|
1985 | + $lang_path = __DIR__.DIRECTORY_SEPARATOR.'language'.DIRECTORY_SEPARATOR; |
|
1986 | 1986 | } |
1987 | 1987 | //Validate $langcode |
1988 | 1988 | if (!preg_match('/^[a-z]{2}(?:_[a-zA-Z]{2})?$/', $langcode)) { |
1989 | 1989 | $langcode = 'en'; |
1990 | 1990 | } |
1991 | 1991 | $foundlang = true; |
1992 | - $lang_file = $lang_path . 'phpmailer.lang-' . $langcode . '.php'; |
|
1992 | + $lang_file = $lang_path.'phpmailer.lang-'.$langcode.'.php'; |
|
1993 | 1993 | // There is no English translation file |
1994 | 1994 | if ('en' != $langcode) { |
1995 | 1995 | // Make sure language file path is readable |
@@ -2034,7 +2034,7 @@ discard block |
||
2034 | 2034 | $addresses[] = $this->addrFormat($address); |
2035 | 2035 | } |
2036 | 2036 | |
2037 | - return $type . ': ' . implode(', ', $addresses) . static::$LE; |
|
2037 | + return $type.': '.implode(', ', $addresses).static::$LE; |
|
2038 | 2038 | } |
2039 | 2039 | |
2040 | 2040 | /** |
@@ -2051,9 +2051,9 @@ discard block |
||
2051 | 2051 | return $this->secureHeader($addr[0]); |
2052 | 2052 | } |
2053 | 2053 | |
2054 | - return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase') . ' <' . $this->secureHeader( |
|
2054 | + return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase').' <'.$this->secureHeader( |
|
2055 | 2055 | $addr[0] |
2056 | - ) . '>'; |
|
2056 | + ).'>'; |
|
2057 | 2057 | } |
2058 | 2058 | |
2059 | 2059 | /** |
@@ -2110,10 +2110,10 @@ discard block |
||
2110 | 2110 | } |
2111 | 2111 | $part = substr($word, 0, $len); |
2112 | 2112 | $word = substr($word, $len); |
2113 | - $buf .= ' ' . $part; |
|
2114 | - $message .= $buf . sprintf('=%s', static::$LE); |
|
2113 | + $buf .= ' '.$part; |
|
2114 | + $message .= $buf.sprintf('=%s', static::$LE); |
|
2115 | 2115 | } else { |
2116 | - $message .= $buf . $soft_break; |
|
2116 | + $message .= $buf.$soft_break; |
|
2117 | 2117 | } |
2118 | 2118 | $buf = ''; |
2119 | 2119 | } |
@@ -2133,7 +2133,7 @@ discard block |
||
2133 | 2133 | $word = substr($word, $len); |
2134 | 2134 | |
2135 | 2135 | if (strlen($word) > 0) { |
2136 | - $message .= $part . sprintf('=%s', static::$LE); |
|
2136 | + $message .= $part.sprintf('=%s', static::$LE); |
|
2137 | 2137 | } else { |
2138 | 2138 | $buf = $part; |
2139 | 2139 | } |
@@ -2146,13 +2146,13 @@ discard block |
||
2146 | 2146 | $buf .= $word; |
2147 | 2147 | |
2148 | 2148 | if (strlen($buf) > $length and '' != $buf_o) { |
2149 | - $message .= $buf_o . $soft_break; |
|
2149 | + $message .= $buf_o.$soft_break; |
|
2150 | 2150 | $buf = $word; |
2151 | 2151 | } |
2152 | 2152 | } |
2153 | 2153 | $firstword = false; |
2154 | 2154 | } |
2155 | - $message .= $buf . static::$LE; |
|
2155 | + $message .= $buf.static::$LE; |
|
2156 | 2156 | } |
2157 | 2157 | |
2158 | 2158 | return $message; |
@@ -2298,7 +2298,7 @@ discard block |
||
2298 | 2298 | if ('' == $this->XMailer) { |
2299 | 2299 | $result .= $this->headerLine( |
2300 | 2300 | 'X-Mailer', |
2301 | - 'PHPMailer ' . self::VERSION . ' (https://github.com/PHPMailer/PHPMailer)' |
|
2301 | + 'PHPMailer '.self::VERSION.' (https://github.com/PHPMailer/PHPMailer)' |
|
2302 | 2302 | ); |
2303 | 2303 | } else { |
2304 | 2304 | $myXmailer = trim($this->XMailer); |
@@ -2308,7 +2308,7 @@ discard block |
||
2308 | 2308 | } |
2309 | 2309 | |
2310 | 2310 | if ('' != $this->ConfirmReadingTo) { |
2311 | - $result .= $this->headerLine('Disposition-Notification-To', '<' . $this->ConfirmReadingTo . '>'); |
|
2311 | + $result .= $this->headerLine('Disposition-Notification-To', '<'.$this->ConfirmReadingTo.'>'); |
|
2312 | 2312 | } |
2313 | 2313 | |
2314 | 2314 | // Add custom headers |
@@ -2338,23 +2338,23 @@ discard block |
||
2338 | 2338 | switch ($this->message_type) { |
2339 | 2339 | case 'inline': |
2340 | 2340 | $result .= $this->headerLine('Content-Type', 'multipart/related;'); |
2341 | - $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"'); |
|
2341 | + $result .= $this->textLine("\tboundary=\"".$this->boundary[1].'"'); |
|
2342 | 2342 | break; |
2343 | 2343 | case 'attach': |
2344 | 2344 | case 'inline_attach': |
2345 | 2345 | case 'alt_attach': |
2346 | 2346 | case 'alt_inline_attach': |
2347 | 2347 | $result .= $this->headerLine('Content-Type', 'multipart/mixed;'); |
2348 | - $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"'); |
|
2348 | + $result .= $this->textLine("\tboundary=\"".$this->boundary[1].'"'); |
|
2349 | 2349 | break; |
2350 | 2350 | case 'alt': |
2351 | 2351 | case 'alt_inline': |
2352 | 2352 | $result .= $this->headerLine('Content-Type', 'multipart/alternative;'); |
2353 | - $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"'); |
|
2353 | + $result .= $this->textLine("\tboundary=\"".$this->boundary[1].'"'); |
|
2354 | 2354 | break; |
2355 | 2355 | default: |
2356 | 2356 | // Catches case 'plain': and case '': |
2357 | - $result .= $this->textLine('Content-Type: ' . $this->ContentType . '; charset=' . $this->CharSet); |
|
2357 | + $result .= $this->textLine('Content-Type: '.$this->ContentType.'; charset='.$this->CharSet); |
|
2358 | 2358 | $ismultipart = false; |
2359 | 2359 | break; |
2360 | 2360 | } |
@@ -2389,7 +2389,7 @@ discard block |
||
2389 | 2389 | */ |
2390 | 2390 | public function getSentMIMEMessage() |
2391 | 2391 | { |
2392 | - return rtrim($this->MIMEHeader . $this->mailHeader, "\n\r") . static::$LE . static::$LE . $this->MIMEBody; |
|
2392 | + return rtrim($this->MIMEHeader.$this->mailHeader, "\n\r").static::$LE.static::$LE.$this->MIMEBody; |
|
2393 | 2393 | } |
2394 | 2394 | |
2395 | 2395 | /** |
@@ -2426,12 +2426,12 @@ discard block |
||
2426 | 2426 | $body = ''; |
2427 | 2427 | //Create unique IDs and preset boundaries |
2428 | 2428 | $this->uniqueid = $this->generateId(); |
2429 | - $this->boundary[1] = 'b1_' . $this->uniqueid; |
|
2430 | - $this->boundary[2] = 'b2_' . $this->uniqueid; |
|
2431 | - $this->boundary[3] = 'b3_' . $this->uniqueid; |
|
2429 | + $this->boundary[1] = 'b1_'.$this->uniqueid; |
|
2430 | + $this->boundary[2] = 'b2_'.$this->uniqueid; |
|
2431 | + $this->boundary[3] = 'b3_'.$this->uniqueid; |
|
2432 | 2432 | |
2433 | 2433 | if ($this->sign_key_file) { |
2434 | - $body .= $this->getMailMIME() . static::$LE; |
|
2434 | + $body .= $this->getMailMIME().static::$LE; |
|
2435 | 2435 | } |
2436 | 2436 | |
2437 | 2437 | $this->setWordWrap(); |
@@ -2464,7 +2464,7 @@ discard block |
||
2464 | 2464 | $altBodyEncoding = 'quoted-printable'; |
2465 | 2465 | } |
2466 | 2466 | //Use this as a preamble in all multipart message types |
2467 | - $mimepre = 'This is a multi-part message in MIME format.' . static::$LE; |
|
2467 | + $mimepre = 'This is a multi-part message in MIME format.'.static::$LE; |
|
2468 | 2468 | switch ($this->message_type) { |
2469 | 2469 | case 'inline': |
2470 | 2470 | $body .= $mimepre; |
@@ -2482,9 +2482,9 @@ discard block |
||
2482 | 2482 | break; |
2483 | 2483 | case 'inline_attach': |
2484 | 2484 | $body .= $mimepre; |
2485 | - $body .= $this->textLine('--' . $this->boundary[1]); |
|
2485 | + $body .= $this->textLine('--'.$this->boundary[1]); |
|
2486 | 2486 | $body .= $this->headerLine('Content-Type', 'multipart/related;'); |
2487 | - $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"'); |
|
2487 | + $body .= $this->textLine("\tboundary=\"".$this->boundary[2].'"'); |
|
2488 | 2488 | $body .= static::$LE; |
2489 | 2489 | $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, '', $bodyEncoding); |
2490 | 2490 | $body .= $this->encodeString($this->Body, $bodyEncoding); |
@@ -2513,9 +2513,9 @@ discard block |
||
2513 | 2513 | $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding); |
2514 | 2514 | $body .= $this->encodeString($this->AltBody, $altBodyEncoding); |
2515 | 2515 | $body .= static::$LE; |
2516 | - $body .= $this->textLine('--' . $this->boundary[1]); |
|
2516 | + $body .= $this->textLine('--'.$this->boundary[1]); |
|
2517 | 2517 | $body .= $this->headerLine('Content-Type', 'multipart/related;'); |
2518 | - $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"'); |
|
2518 | + $body .= $this->textLine("\tboundary=\"".$this->boundary[2].'"'); |
|
2519 | 2519 | $body .= static::$LE; |
2520 | 2520 | $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, 'text/html', $bodyEncoding); |
2521 | 2521 | $body .= $this->encodeString($this->Body, $bodyEncoding); |
@@ -2526,9 +2526,9 @@ discard block |
||
2526 | 2526 | break; |
2527 | 2527 | case 'alt_attach': |
2528 | 2528 | $body .= $mimepre; |
2529 | - $body .= $this->textLine('--' . $this->boundary[1]); |
|
2529 | + $body .= $this->textLine('--'.$this->boundary[1]); |
|
2530 | 2530 | $body .= $this->headerLine('Content-Type', 'multipart/alternative;'); |
2531 | - $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"'); |
|
2531 | + $body .= $this->textLine("\tboundary=\"".$this->boundary[2].'"'); |
|
2532 | 2532 | $body .= static::$LE; |
2533 | 2533 | $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding); |
2534 | 2534 | $body .= $this->encodeString($this->AltBody, $altBodyEncoding); |
@@ -2546,16 +2546,16 @@ discard block |
||
2546 | 2546 | break; |
2547 | 2547 | case 'alt_inline_attach': |
2548 | 2548 | $body .= $mimepre; |
2549 | - $body .= $this->textLine('--' . $this->boundary[1]); |
|
2549 | + $body .= $this->textLine('--'.$this->boundary[1]); |
|
2550 | 2550 | $body .= $this->headerLine('Content-Type', 'multipart/alternative;'); |
2551 | - $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"'); |
|
2551 | + $body .= $this->textLine("\tboundary=\"".$this->boundary[2].'"'); |
|
2552 | 2552 | $body .= static::$LE; |
2553 | 2553 | $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding); |
2554 | 2554 | $body .= $this->encodeString($this->AltBody, $altBodyEncoding); |
2555 | 2555 | $body .= static::$LE; |
2556 | - $body .= $this->textLine('--' . $this->boundary[2]); |
|
2556 | + $body .= $this->textLine('--'.$this->boundary[2]); |
|
2557 | 2557 | $body .= $this->headerLine('Content-Type', 'multipart/related;'); |
2558 | - $body .= $this->textLine("\tboundary=\"" . $this->boundary[3] . '"'); |
|
2558 | + $body .= $this->textLine("\tboundary=\"".$this->boundary[3].'"'); |
|
2559 | 2559 | $body .= static::$LE; |
2560 | 2560 | $body .= $this->getBoundary($this->boundary[3], $bodyCharSet, 'text/html', $bodyEncoding); |
2561 | 2561 | $body .= $this->encodeString($this->Body, $bodyEncoding); |
@@ -2582,12 +2582,12 @@ discard block |
||
2582 | 2582 | } elseif ($this->sign_key_file) { |
2583 | 2583 | try { |
2584 | 2584 | if (!defined('PKCS7_TEXT')) { |
2585 | - throw new Exception($this->lang('extension_missing') . 'openssl'); |
|
2585 | + throw new Exception($this->lang('extension_missing').'openssl'); |
|
2586 | 2586 | } |
2587 | 2587 | // @TODO would be nice to use php://temp streams here |
2588 | 2588 | $file = tempnam(sys_get_temp_dir(), 'mail'); |
2589 | 2589 | if (false === file_put_contents($file, $body)) { |
2590 | - throw new Exception($this->lang('signing') . ' Could not write temp file'); |
|
2590 | + throw new Exception($this->lang('signing').' Could not write temp file'); |
|
2591 | 2591 | } |
2592 | 2592 | $signed = tempnam(sys_get_temp_dir(), 'signed'); |
2593 | 2593 | //Workaround for PHP bug https://bugs.php.net/bug.php?id=69197 |
@@ -2595,16 +2595,16 @@ discard block |
||
2595 | 2595 | $sign = @openssl_pkcs7_sign( |
2596 | 2596 | $file, |
2597 | 2597 | $signed, |
2598 | - 'file://' . realpath($this->sign_cert_file), |
|
2599 | - ['file://' . realpath($this->sign_key_file), $this->sign_key_pass], |
|
2598 | + 'file://'.realpath($this->sign_cert_file), |
|
2599 | + ['file://'.realpath($this->sign_key_file), $this->sign_key_pass], |
|
2600 | 2600 | [] |
2601 | 2601 | ); |
2602 | 2602 | } else { |
2603 | 2603 | $sign = @openssl_pkcs7_sign( |
2604 | 2604 | $file, |
2605 | 2605 | $signed, |
2606 | - 'file://' . realpath($this->sign_cert_file), |
|
2607 | - ['file://' . realpath($this->sign_key_file), $this->sign_key_pass], |
|
2606 | + 'file://'.realpath($this->sign_cert_file), |
|
2607 | + ['file://'.realpath($this->sign_key_file), $this->sign_key_pass], |
|
2608 | 2608 | [], |
2609 | 2609 | PKCS7_DETACHED, |
2610 | 2610 | $this->sign_extracerts_file |
@@ -2616,11 +2616,11 @@ discard block |
||
2616 | 2616 | @unlink($signed); |
2617 | 2617 | //The message returned by openssl contains both headers and body, so need to split them up |
2618 | 2618 | $parts = explode("\n\n", $body, 2); |
2619 | - $this->MIMEHeader .= $parts[0] . static::$LE . static::$LE; |
|
2619 | + $this->MIMEHeader .= $parts[0].static::$LE.static::$LE; |
|
2620 | 2620 | $body = $parts[1]; |
2621 | 2621 | } else { |
2622 | 2622 | @unlink($signed); |
2623 | - throw new Exception($this->lang('signing') . openssl_error_string()); |
|
2623 | + throw new Exception($this->lang('signing').openssl_error_string()); |
|
2624 | 2624 | } |
2625 | 2625 | } catch (Exception $exc) { |
2626 | 2626 | $body = ''; |
@@ -2655,7 +2655,7 @@ discard block |
||
2655 | 2655 | if ('' == $encoding) { |
2656 | 2656 | $encoding = $this->Encoding; |
2657 | 2657 | } |
2658 | - $result .= $this->textLine('--' . $boundary); |
|
2658 | + $result .= $this->textLine('--'.$boundary); |
|
2659 | 2659 | $result .= sprintf('Content-Type: %s; charset=%s', $contentType, $charSet); |
2660 | 2660 | $result .= static::$LE; |
2661 | 2661 | // RFC1341 part 5 says 7bit is assumed if not specified |
@@ -2676,7 +2676,7 @@ discard block |
||
2676 | 2676 | */ |
2677 | 2677 | protected function endBoundary($boundary) |
2678 | 2678 | { |
2679 | - return static::$LE . '--' . $boundary . '--' . static::$LE; |
|
2679 | + return static::$LE.'--'.$boundary.'--'.static::$LE; |
|
2680 | 2680 | } |
2681 | 2681 | |
2682 | 2682 | /** |
@@ -2712,7 +2712,7 @@ discard block |
||
2712 | 2712 | */ |
2713 | 2713 | public function headerLine($name, $value) |
2714 | 2714 | { |
2715 | - return $name . ': ' . $value . static::$LE; |
|
2715 | + return $name.': '.$value.static::$LE; |
|
2716 | 2716 | } |
2717 | 2717 | |
2718 | 2718 | /** |
@@ -2724,7 +2724,7 @@ discard block |
||
2724 | 2724 | */ |
2725 | 2725 | public function textLine($value) |
2726 | 2726 | { |
2727 | - return $value . static::$LE; |
|
2727 | + return $value.static::$LE; |
|
2728 | 2728 | } |
2729 | 2729 | |
2730 | 2730 | /** |
@@ -2746,7 +2746,7 @@ discard block |
||
2746 | 2746 | { |
2747 | 2747 | try { |
2748 | 2748 | if (!@is_file($path)) { |
2749 | - throw new Exception($this->lang('file_access') . $path, self::STOP_CONTINUE); |
|
2749 | + throw new Exception($this->lang('file_access').$path, self::STOP_CONTINUE); |
|
2750 | 2750 | } |
2751 | 2751 | |
2752 | 2752 | // If a MIME type is not specified, try to work it out from the file name |
@@ -2873,7 +2873,7 @@ discard block |
||
2873 | 2873 | 'Content-Disposition: %s; filename="%s"%s', |
2874 | 2874 | $disposition, |
2875 | 2875 | $encoded_name, |
2876 | - static::$LE . static::$LE |
|
2876 | + static::$LE.static::$LE |
|
2877 | 2877 | ); |
2878 | 2878 | } else { |
2879 | 2879 | if (!empty($encoded_name)) { |
@@ -2881,13 +2881,13 @@ discard block |
||
2881 | 2881 | 'Content-Disposition: %s; filename=%s%s', |
2882 | 2882 | $disposition, |
2883 | 2883 | $encoded_name, |
2884 | - static::$LE . static::$LE |
|
2884 | + static::$LE.static::$LE |
|
2885 | 2885 | ); |
2886 | 2886 | } else { |
2887 | 2887 | $mime[] = sprintf( |
2888 | 2888 | 'Content-Disposition: %s%s', |
2889 | 2889 | $disposition, |
2890 | - static::$LE . static::$LE |
|
2890 | + static::$LE.static::$LE |
|
2891 | 2891 | ); |
2892 | 2892 | } |
2893 | 2893 | } |
@@ -2928,11 +2928,11 @@ discard block |
||
2928 | 2928 | { |
2929 | 2929 | try { |
2930 | 2930 | if (!file_exists($path)) { |
2931 | - throw new Exception($this->lang('file_open') . $path, self::STOP_CONTINUE); |
|
2931 | + throw new Exception($this->lang('file_open').$path, self::STOP_CONTINUE); |
|
2932 | 2932 | } |
2933 | 2933 | $file_buffer = file_get_contents($path); |
2934 | 2934 | if (false === $file_buffer) { |
2935 | - throw new Exception($this->lang('file_open') . $path, self::STOP_CONTINUE); |
|
2935 | + throw new Exception($this->lang('file_open').$path, self::STOP_CONTINUE); |
|
2936 | 2936 | } |
2937 | 2937 | $file_buffer = $this->encodeString($file_buffer, $encoding); |
2938 | 2938 | |
@@ -2979,7 +2979,7 @@ discard block |
||
2979 | 2979 | $encoded = $this->encodeQP($str); |
2980 | 2980 | break; |
2981 | 2981 | default: |
2982 | - $this->setError($this->lang('encoding') . $encoding); |
|
2982 | + $this->setError($this->lang('encoding').$encoding); |
|
2983 | 2983 | break; |
2984 | 2984 | } |
2985 | 2985 | |
@@ -3045,7 +3045,7 @@ discard block |
||
3045 | 3045 | $maxlen -= $maxlen % 4; |
3046 | 3046 | $encoded = trim(chunk_split($encoded, $maxlen, "\n")); |
3047 | 3047 | } |
3048 | - $encoded = preg_replace('/^(.*)$/m', ' =?' . $this->CharSet . "?$encoding?\\1?=", $encoded); |
|
3048 | + $encoded = preg_replace('/^(.*)$/m', ' =?'.$this->CharSet."?$encoding?\\1?=", $encoded); |
|
3049 | 3049 | } elseif ($matchcount > 0) { |
3050 | 3050 | //1 or more chars need encoding, use Q-encode |
3051 | 3051 | $encoding = 'Q'; |
@@ -3053,8 +3053,8 @@ discard block |
||
3053 | 3053 | $maxlen = static::STD_LINE_LENGTH - $lengthsub - 8 - strlen($this->CharSet); |
3054 | 3054 | $encoded = $this->encodeQ($str, $position); |
3055 | 3055 | $encoded = $this->wrapText($encoded, $maxlen, true); |
3056 | - $encoded = str_replace('=' . static::$LE, "\n", trim($encoded)); |
|
3057 | - $encoded = preg_replace('/^(.*)$/m', ' =?' . $this->CharSet . "?$encoding?\\1?=", $encoded); |
|
3056 | + $encoded = str_replace('='.static::$LE, "\n", trim($encoded)); |
|
3057 | + $encoded = preg_replace('/^(.*)$/m', ' =?'.$this->CharSet."?$encoding?\\1?=", $encoded); |
|
3058 | 3058 | } elseif (strlen($str) > $maxlen) { |
3059 | 3059 | //No chars need encoding, but line is too long, so fold it |
3060 | 3060 | $encoded = trim($this->wrapText($str, $maxlen, false)); |
@@ -3115,7 +3115,7 @@ discard block |
||
3115 | 3115 | */ |
3116 | 3116 | public function base64EncodeWrapMB($str, $linebreak = null) |
3117 | 3117 | { |
3118 | - $start = '=?' . $this->CharSet . '?B?'; |
|
3118 | + $start = '=?'.$this->CharSet.'?B?'; |
|
3119 | 3119 | $end = '?='; |
3120 | 3120 | $encoded = ''; |
3121 | 3121 | if (null === $linebreak) { |
@@ -3138,7 +3138,7 @@ discard block |
||
3138 | 3138 | $chunk = base64_encode($chunk); |
3139 | 3139 | ++$lookBack; |
3140 | 3140 | } while (strlen($chunk) > $length); |
3141 | - $encoded .= $chunk . $linebreak; |
|
3141 | + $encoded .= $chunk.$linebreak; |
|
3142 | 3142 | } |
3143 | 3143 | |
3144 | 3144 | // Chomp the last linefeed |
@@ -3191,7 +3191,7 @@ discard block |
||
3191 | 3191 | // RFC 2047 section 5.1 |
3192 | 3192 | // Replace every high ascii, control, =, ? and _ characters |
3193 | 3193 | /** @noinspection SuspiciousAssignmentsInspection */ |
3194 | - $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern; |
|
3194 | + $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377'.$pattern; |
|
3195 | 3195 | break; |
3196 | 3196 | } |
3197 | 3197 | $matches = []; |
@@ -3204,7 +3204,7 @@ discard block |
||
3204 | 3204 | array_unshift($matches[0], '='); |
3205 | 3205 | } |
3206 | 3206 | foreach (array_unique($matches[0]) as $char) { |
3207 | - $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded); |
|
3207 | + $encoded = str_replace($char, '='.sprintf('%02X', ord($char)), $encoded); |
|
3208 | 3208 | } |
3209 | 3209 | } |
3210 | 3210 | // Replace spaces with _ (more readable than =20) |
@@ -3269,7 +3269,7 @@ discard block |
||
3269 | 3269 | public function addEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = '', $disposition = 'inline') |
3270 | 3270 | { |
3271 | 3271 | if (!@is_file($path)) { |
3272 | - $this->setError($this->lang('file_access') . $path); |
|
3272 | + $this->setError($this->lang('file_access').$path); |
|
3273 | 3273 | |
3274 | 3274 | return false; |
3275 | 3275 | } |
@@ -3413,7 +3413,7 @@ discard block |
||
3413 | 3413 | { |
3414 | 3414 | $this->RecipientsQueue = array_filter( |
3415 | 3415 | $this->RecipientsQueue, |
3416 | - function ($params) use ($kind) { |
|
3416 | + function($params) use ($kind) { |
|
3417 | 3417 | return $params[0] != $kind; |
3418 | 3418 | } |
3419 | 3419 | ); |
@@ -3503,15 +3503,15 @@ discard block |
||
3503 | 3503 | if ('smtp' == $this->Mailer and null !== $this->smtp) { |
3504 | 3504 | $lasterror = $this->smtp->getError(); |
3505 | 3505 | if (!empty($lasterror['error'])) { |
3506 | - $msg .= $this->lang('smtp_error') . $lasterror['error']; |
|
3506 | + $msg .= $this->lang('smtp_error').$lasterror['error']; |
|
3507 | 3507 | if (!empty($lasterror['detail'])) { |
3508 | - $msg .= ' Detail: ' . $lasterror['detail']; |
|
3508 | + $msg .= ' Detail: '.$lasterror['detail']; |
|
3509 | 3509 | } |
3510 | 3510 | if (!empty($lasterror['smtp_code'])) { |
3511 | - $msg .= ' SMTP code: ' . $lasterror['smtp_code']; |
|
3511 | + $msg .= ' SMTP code: '.$lasterror['smtp_code']; |
|
3512 | 3512 | } |
3513 | 3513 | if (!empty($lasterror['smtp_code_ex'])) { |
3514 | - $msg .= ' Additional SMTP info: ' . $lasterror['smtp_code_ex']; |
|
3514 | + $msg .= ' Additional SMTP info: '.$lasterror['smtp_code_ex']; |
|
3515 | 3515 | } |
3516 | 3516 | } |
3517 | 3517 | } |
@@ -3584,7 +3584,7 @@ discard block |
||
3584 | 3584 | //Is it a valid IPv4 address? |
3585 | 3585 | return (bool) filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); |
3586 | 3586 | } |
3587 | - if (filter_var('http://' . $host, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED)) { |
|
3587 | + if (filter_var('http://'.$host, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED)) { |
|
3588 | 3588 | //Is it a syntactically valid hostname? |
3589 | 3589 | return true; |
3590 | 3590 | } |
@@ -3610,7 +3610,7 @@ discard block |
||
3610 | 3610 | //Include a link to troubleshooting docs on SMTP connection failure |
3611 | 3611 | //this is by far the biggest cause of support questions |
3612 | 3612 | //but it's usually not PHPMailer's fault. |
3613 | - return $this->language[$key] . ' https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting'; |
|
3613 | + return $this->language[$key].' https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting'; |
|
3614 | 3614 | } |
3615 | 3615 | |
3616 | 3616 | return $this->language[$key]; |
@@ -3698,14 +3698,14 @@ discard block |
||
3698 | 3698 | } |
3699 | 3699 | //Hash the decoded data, not the URL so that the same data-URI image used in multiple places |
3700 | 3700 | //will only be embedded once, even if it used a different encoding |
3701 | - $cid = hash('sha256', $data) . '@phpmailer.0'; // RFC2392 S 2 |
|
3701 | + $cid = hash('sha256', $data).'@phpmailer.0'; // RFC2392 S 2 |
|
3702 | 3702 | |
3703 | 3703 | if (!$this->cidExists($cid)) { |
3704 | - $this->addStringEmbeddedImage($data, $cid, 'embed' . $imgindex, 'base64', $match[1]); |
|
3704 | + $this->addStringEmbeddedImage($data, $cid, 'embed'.$imgindex, 'base64', $match[1]); |
|
3705 | 3705 | } |
3706 | 3706 | $message = str_replace( |
3707 | 3707 | $images[0][$imgindex], |
3708 | - $images[1][$imgindex] . '="cid:' . $cid . '"', |
|
3708 | + $images[1][$imgindex].'="cid:'.$cid.'"', |
|
3709 | 3709 | $message |
3710 | 3710 | ); |
3711 | 3711 | continue; |
@@ -3724,7 +3724,7 @@ discard block |
||
3724 | 3724 | if ('.' == $directory) { |
3725 | 3725 | $directory = ''; |
3726 | 3726 | } |
3727 | - $cid = hash('sha256', $url) . '@phpmailer.0'; // RFC2392 S 2 |
|
3727 | + $cid = hash('sha256', $url).'@phpmailer.0'; // RFC2392 S 2 |
|
3728 | 3728 | if (strlen($basedir) > 1 and '/' != substr($basedir, -1)) { |
3729 | 3729 | $basedir .= '/'; |
3730 | 3730 | } |
@@ -3732,7 +3732,7 @@ discard block |
||
3732 | 3732 | $directory .= '/'; |
3733 | 3733 | } |
3734 | 3734 | if ($this->addEmbeddedImage( |
3735 | - $basedir . $directory . $filename, |
|
3735 | + $basedir.$directory.$filename, |
|
3736 | 3736 | $cid, |
3737 | 3737 | $filename, |
3738 | 3738 | 'base64', |
@@ -3740,8 +3740,8 @@ discard block |
||
3740 | 3740 | ) |
3741 | 3741 | ) { |
3742 | 3742 | $message = preg_replace( |
3743 | - '/' . $images[1][$imgindex] . '=["\']' . preg_quote($url, '/') . '["\']/Ui', |
|
3744 | - $images[1][$imgindex] . '="cid:' . $cid . '"', |
|
3743 | + '/'.$images[1][$imgindex].'=["\']'.preg_quote($url, '/').'["\']/Ui', |
|
3744 | + $images[1][$imgindex].'="cid:'.$cid.'"', |
|
3745 | 3745 | $message |
3746 | 3746 | ); |
3747 | 3747 | } |
@@ -4002,7 +4002,7 @@ discard block |
||
4002 | 4002 | |
4003 | 4003 | return true; |
4004 | 4004 | } |
4005 | - $this->setError($this->lang('variable_set') . $name); |
|
4005 | + $this->setError($this->lang('variable_set').$name); |
|
4006 | 4006 | |
4007 | 4007 | return false; |
4008 | 4008 | } |
@@ -4096,7 +4096,7 @@ discard block |
||
4096 | 4096 | if (((0x21 <= $ord) and ($ord <= 0x3A)) or $ord == 0x3C or ((0x3E <= $ord) and ($ord <= 0x7E))) { |
4097 | 4097 | $line .= $txt[$i]; |
4098 | 4098 | } else { |
4099 | - $line .= '=' . sprintf('%02X', $ord); |
|
4099 | + $line .= '='.sprintf('%02X', $ord); |
|
4100 | 4100 | } |
4101 | 4101 | } |
4102 | 4102 | |
@@ -4116,14 +4116,13 @@ discard block |
||
4116 | 4116 | { |
4117 | 4117 | if (!defined('PKCS7_TEXT')) { |
4118 | 4118 | if ($this->exceptions) { |
4119 | - throw new Exception($this->lang('extension_missing') . 'openssl'); |
|
4119 | + throw new Exception($this->lang('extension_missing').'openssl'); |
|
4120 | 4120 | } |
4121 | 4121 | |
4122 | 4122 | return ''; |
4123 | 4123 | } |
4124 | 4124 | $privKeyStr = !empty($this->DKIM_private_string) ? |
4125 | - $this->DKIM_private_string : |
|
4126 | - file_get_contents($this->DKIM_private); |
|
4125 | + $this->DKIM_private_string : file_get_contents($this->DKIM_private); |
|
4127 | 4126 | if ('' != $this->DKIM_passphrase) { |
4128 | 4127 | $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase); |
4129 | 4128 | } else { |
@@ -4175,7 +4174,7 @@ discard block |
||
4175 | 4174 | //But then says to delete space before and after the colon. |
4176 | 4175 | //Net result is the same as trimming both ends of the value. |
4177 | 4176 | //by elimination, the same applies to the field name |
4178 | - $lines[$key] = trim($heading, " \t") . ':' . trim($value, " \t"); |
|
4177 | + $lines[$key] = trim($heading, " \t").':'.trim($value, " \t"); |
|
4179 | 4178 | } |
4180 | 4179 | |
4181 | 4180 | return implode("\r\n", $lines); |
@@ -4201,7 +4200,7 @@ discard block |
||
4201 | 4200 | $body = static::normalizeBreaks($body, "\r\n"); |
4202 | 4201 | |
4203 | 4202 | //Reduce multiple trailing line breaks to a single one |
4204 | - return rtrim($body, "\r\n") . "\r\n"; |
|
4203 | + return rtrim($body, "\r\n")."\r\n"; |
|
4205 | 4204 | } |
4206 | 4205 | |
4207 | 4206 | /** |
@@ -4257,33 +4256,33 @@ discard block |
||
4257 | 4256 | if ('' == $this->DKIM_identity) { |
4258 | 4257 | $ident = ''; |
4259 | 4258 | } else { |
4260 | - $ident = ' i=' . $this->DKIM_identity . ';'; |
|
4261 | - } |
|
4262 | - $dkimhdrs = 'DKIM-Signature: v=1; a=' . |
|
4263 | - $DKIMsignatureType . '; q=' . |
|
4264 | - $DKIMquery . '; l=' . |
|
4265 | - $DKIMlen . '; s=' . |
|
4266 | - $this->DKIM_selector . |
|
4267 | - ";\r\n" . |
|
4268 | - "\tt=" . $DKIMtime . '; c=' . $DKIMcanonicalization . ";\r\n" . |
|
4269 | - "\th=From:To:Date:Subject;\r\n" . |
|
4270 | - "\td=" . $this->DKIM_domain . ';' . $ident . "\r\n" . |
|
4271 | - "\tz=$from\r\n" . |
|
4272 | - "\t|$to\r\n" . |
|
4273 | - "\t|$date\r\n" . |
|
4274 | - "\t|$subject;\r\n" . |
|
4275 | - "\tbh=" . $DKIMb64 . ";\r\n" . |
|
4259 | + $ident = ' i='.$this->DKIM_identity.';'; |
|
4260 | + } |
|
4261 | + $dkimhdrs = 'DKIM-Signature: v=1; a='. |
|
4262 | + $DKIMsignatureType.'; q='. |
|
4263 | + $DKIMquery.'; l='. |
|
4264 | + $DKIMlen.'; s='. |
|
4265 | + $this->DKIM_selector. |
|
4266 | + ";\r\n". |
|
4267 | + "\tt=".$DKIMtime.'; c='.$DKIMcanonicalization.";\r\n". |
|
4268 | + "\th=From:To:Date:Subject;\r\n". |
|
4269 | + "\td=".$this->DKIM_domain.';'.$ident."\r\n". |
|
4270 | + "\tz=$from\r\n". |
|
4271 | + "\t|$to\r\n". |
|
4272 | + "\t|$date\r\n". |
|
4273 | + "\t|$subject;\r\n". |
|
4274 | + "\tbh=".$DKIMb64.";\r\n". |
|
4276 | 4275 | "\tb="; |
4277 | 4276 | $toSign = $this->DKIM_HeaderC( |
4278 | - $from_header . "\r\n" . |
|
4279 | - $to_header . "\r\n" . |
|
4280 | - $date_header . "\r\n" . |
|
4281 | - $subject_header . "\r\n" . |
|
4277 | + $from_header."\r\n". |
|
4278 | + $to_header."\r\n". |
|
4279 | + $date_header."\r\n". |
|
4280 | + $subject_header."\r\n". |
|
4282 | 4281 | $dkimhdrs |
4283 | 4282 | ); |
4284 | 4283 | $signed = $this->DKIM_Sign($toSign); |
4285 | 4284 | |
4286 | - return static::normalizeBreaks($dkimhdrs . $signed) . static::$LE; |
|
4285 | + return static::normalizeBreaks($dkimhdrs.$signed).static::$LE; |
|
4287 | 4286 | } |
4288 | 4287 | |
4289 | 4288 | /** |
@@ -4296,7 +4295,7 @@ discard block |
||
4296 | 4295 | */ |
4297 | 4296 | public static function hasLineLongerThanMax($str) |
4298 | 4297 | { |
4299 | - return (bool) preg_match('/^(.{' . (self::MAX_LINE_LENGTH + strlen(static::$LE)) . ',})/m', $str); |
|
4298 | + return (bool) preg_match('/^(.{'.(self::MAX_LINE_LENGTH + strlen(static::$LE)).',})/m', $str); |
|
4300 | 4299 | } |
4301 | 4300 | |
4302 | 4301 | /** |
@@ -3413,7 +3413,8 @@ |
||
3413 | 3413 | { |
3414 | 3414 | $this->RecipientsQueue = array_filter( |
3415 | 3415 | $this->RecipientsQueue, |
3416 | - function ($params) use ($kind) { |
|
3416 | + function ($params) use ($kind) |
|
3417 | + { |
|
3417 | 3418 | return $params[0] != $kind; |
3418 | 3419 | } |
3419 | 3420 | ); |