diff options
Diffstat (limited to 'lib/plugins')
-rw-r--r-- | lib/plugins/config/settings/config.class.php | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/lib/plugins/config/settings/config.class.php b/lib/plugins/config/settings/config.class.php index e5e09d8f8..427178c40 100644 --- a/lib/plugins/config/settings/config.class.php +++ b/lib/plugins/config/settings/config.class.php @@ -1083,97 +1083,3 @@ if (!class_exists('setting_multicheckbox')) { } } } - -/** - * Provide php_strip_whitespace (php5 function) functionality - * - * @author Chris Smith <chris@jalakai.co.uk> - */ -if (!function_exists('php_strip_whitespace')) { - - if (function_exists('token_get_all')) { - - if (!defined('T_ML_COMMENT')) { - define('T_ML_COMMENT', T_COMMENT); - } else { - define('T_DOC_COMMENT', T_ML_COMMENT); - } - - /** - * modified from original - * source Google Groups, php.general, by David Otton - */ - function php_strip_whitespace($file) { - if (!@is_readable($file)) return ''; - - $in = join('',@file($file)); - $out = ''; - - $tokens = token_get_all($in); - - foreach ($tokens as $token) { - if (is_string ($token)) { - $out .= $token; - } else { - list ($id, $text) = $token; - switch ($id) { - case T_COMMENT : // fall thru - case T_ML_COMMENT : // fall thru - case T_DOC_COMMENT : // fall thru - case T_WHITESPACE : - break; - default : $out .= $text; break; - } - } - } - return ($out); - } - - } else { - - function is_whitespace($c) { return (strpos("\t\n\r ",$c) !== false); } - function is_quote($c) { return (strpos("\"'",$c) !== false); } - function is_escaped($s,$i) { - $idx = $i-1; - while(($idx>=0) && ($s{$idx} == '\\')) $idx--; - return (($i - $idx + 1) % 2); - } - - function is_commentopen($str, $i) { - if ($str{$i} == '#') return "\n"; - if ($str{$i} == '/') { - if ($str{$i+1} == '/') return "\n"; - if ($str{$i+1} == '*') return "*/"; - } - - return false; - } - - function php_strip_whitespace($file) { - - if (!@is_readable($file)) return ''; - - $contents = join('',@file($file)); - $out = ''; - - $state = 0; - for ($i=0; $i<strlen($contents); $i++) { - if (!$state && is_whitespace($contents{$i})) continue; - - if (!$state && ($c_close = is_commentopen($contents, $i))) { - $c_open_len = ($contents{$i} == '/') ? 2 : 1; - $i = strpos($contents, $c_close, $i+$c_open_len)+strlen($c_close)-1; - continue; - } - - $out .= $contents{$i}; - if (is_quote($contents{$i})) { - if (($state == $contents{$i}) && !is_escaped($contents, $i)) { $state = 0; continue; } - if (!$state) {$state = $contents{$i}; continue; } - } - } - - return $out; - } - } -} |