summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schneider2012-02-13 14:46:59 +0000
committerChristian Schneider2012-02-13 14:46:59 +0000
commitca407bc3f8e3e6d5f042be787f96304687af097e (patch)
tree52b8dd84fd1037e92171917f5dbdb95f51e5b237
parent3207842eeab9de8c558d23506ecc38cbe1ad8035 (diff)
downloaditools-ca407bc3f8e3e6d5f042be787f96304687af097e.tar.gz
itools-ca407bc3f8e3e6d5f042be787f96304687af097e.tar.bz2
itools-ca407bc3f8e3e6d5f042be787f96304687af097e.zip
Replace preg_replace /e modifier with preg_replace_callback: Modified planned to be removed. ITools now requires PHP 5.3 or newer
-rw-r--r--it_debug.class2
-rw-r--r--it_html.class4
-rw-r--r--it_mail.class2
-rw-r--r--it_xml.class2
-rw-r--r--itjs.class2
5 files changed, 6 insertions, 6 deletions
diff --git a/it_debug.class b/it_debug.class
index c558f52..ec6de07 100644
--- a/it_debug.class
+++ b/it_debug.class
@@ -133,7 +133,7 @@ function dump($args)
$item = $head . "class $classname { $values }$tail";
}
- $item = preg_replace('/\b(1[234]\d\d\d\d\d\d\d\d)\b(.*)/e', "'$1$2 # ' . date('Y-m-d H:i:s', '$1')", $item);
+ $item = preg_replace_callback('/\b(1[234]\d\d\d\d\d\d\d\d)\b(.*)/', function($m) { return $m[1] . $m[2] . " # " . date('Y-m-d H:i:s', $m[1]); }, $item);
$item = preg_replace("#(=>?)\s*\n\s*(array|class)#", '$1 $2', $item); # array( and class on same line as key
$item = preg_replace('#array \(\s+([^({,;]+),\s+\)#', 'array( $1 )', $item); # 1-element arrays on 1 line
$item = preg_replace('#class (\S+) \{\s+([^({,;]+;)?\s+\}#', 'class $1 { $2 }', $item); # 1-element objects on 1 line
diff --git a/it_html.class b/it_html.class
index 0951e6b..68ca04a 100644
--- a/it_html.class
+++ b/it_html.class
@@ -455,8 +455,8 @@ function sanitize($html)
function entity_decode($string)
{
$string = preg_replace('/&#(8217|65533);/', "'", html_entity_decode($string));
- $string = preg_replace('/&#x0*([0-9a-f]+);/ei', 'hexdec("\\1") <= 255 ? chr(hexdec("\\1")) : " "', $string);
- $string = preg_replace('/&#0*([0-9]+);/e', '\\1 <= 255 ? chr(\\1) : " "', $string);
+ $string = preg_replace_callback('/&#x0*([0-9a-f]+);/i', function($m) { return hexdec($m[1]) <= 255 ? chr(hexdec($m[1])) : " "; }, $string);
+ $string = preg_replace_callback('/&#0*([0-9]+);/', function($m) { return $m[1] <= 255 ? chr($m[1]) : " "; }, $string);
return $string;
}
diff --git a/it_mail.class b/it_mail.class
index b7f42bd..20aa43a 100644
--- a/it_mail.class
+++ b/it_mail.class
@@ -313,7 +313,7 @@ function header_escape($string, $emailmode = false)
{
# Encode if not email address and contains special chars
$result .= !preg_match($emailpattern, $part) && preg_match('/[\x00-\x1f\x7f-\xff]/', $part)
- ? ("=?{$this->charset}?Q?" . str_replace(" ", "_", preg_replace('/[\x00-\x1f=\x7f-\xff]/e', "sprintf('=%02X', ord('\\0'))", $part)) . "?=")
+ ? ("=?{$this->charset}?Q?" . str_replace(" ", "_", preg_replace_callback('/[\x00-\x1f=\x7f-\xff]/', function($m) { return sprintf('=%02X', ord($m[0])); }, $part)) . "?=")
: $part;
}
diff --git a/it_xml.class b/it_xml.class
index 2401b7b..4e34c81 100644
--- a/it_xml.class
+++ b/it_xml.class
@@ -131,7 +131,7 @@ function _sanitize($xmldata, $isutf8 = null)
# If should be utf-8 and can't be decoded as such, fix it, even if mixed between both
if ($isutf8 && preg_match('/[^\x80-\xff][\x80-\xff][^\x80-\xff]/', $xmldata))
- $xmldata = preg_replace('/[\x80-\xff]{1,4}/e', "it_xml::_utf8_fix('\\0')", $xmldata);
+ $xmldata = preg_replace_callback('/[\x80-\xff]{1,4}/', function($m) { return it_xml::_utf8_fix($m[0]); }, $xmldata);
# If not utf-8, remove characters illegal for latin-1
if (!$isutf8 && preg_match('/[\x00-\x08\x0b-\x0c\x0e-\x1f\x80-\x9f]/', $xmldata))
diff --git a/itjs.class b/itjs.class
index 91ebd74..a7a6a15 100644
--- a/itjs.class
+++ b/itjs.class
@@ -92,7 +92,7 @@ function encode($values)
{
$quote = (strval(intval($value)) === strval($value)) ? "" : '"';
$string = strtr($value, array("\0" => '\\0', "\x84" => '\\"', "\x93" => '\\"',"\x94" => '\\"', '"' => '\\"', "</"=>"<\\/", "\n" => '\\n', "\r" => '\\r', "\t" => '\\t', "\\" => '\\\\'));
- $string = $GLOBALS['itjs_defaultconfig']['latin2unicode'] ? preg_replace('/([\xa0-\xff])/e', 'sprintf("\\u%04x", ord("\\1"))', $string) : $string;
+ $string = $GLOBALS['itjs_defaultconfig']['latin2unicode'] ? preg_replace_callback('/([\xa0-\xff])/', function($m) { return sprintf("\\u%04x", ord($m[1])); }, $string) : $string;
$result .= $quote . $string . $quote;
}
else