Merge pull request #601 from fermionic/20130204-100-percent-CPU-usage-on-xmlify
move mb_strlen call out of for loop definition
This commit is contained in:
commit
a0e18a0ff8
1 changed files with 19 additions and 6 deletions
|
@ -173,10 +173,11 @@ function autoname($len) {
|
||||||
|
|
||||||
if(! function_exists('xmlify')) {
|
if(! function_exists('xmlify')) {
|
||||||
function xmlify($str) {
|
function xmlify($str) {
|
||||||
$buffer = '';
|
/* $buffer = '';
|
||||||
|
|
||||||
for($x = 0; $x < mb_strlen($str); $x ++) {
|
$len = mb_strlen($str);
|
||||||
$char = $str[$x];
|
for($x = 0; $x < $len; $x ++) {
|
||||||
|
$char = mb_substr($str,$x,1);
|
||||||
|
|
||||||
switch( $char ) {
|
switch( $char ) {
|
||||||
|
|
||||||
|
@ -204,7 +205,14 @@ function xmlify($str) {
|
||||||
$buffer .= $char;
|
$buffer .= $char;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
$buffer = mb_ereg_replace("&", "&", $str);
|
||||||
|
$buffer = mb_ereg_replace("'", "'", $buffer);
|
||||||
|
$buffer = mb_ereg_replace("\"", """, $buffer);
|
||||||
|
$buffer = mb_ereg_replace("<", "<", $buffer);
|
||||||
|
$buffer = mb_ereg_replace(">", ">", $buffer);
|
||||||
|
|
||||||
$buffer = trim($buffer);
|
$buffer = trim($buffer);
|
||||||
return($buffer);
|
return($buffer);
|
||||||
}}
|
}}
|
||||||
|
@ -214,8 +222,13 @@ function xmlify($str) {
|
||||||
|
|
||||||
if(! function_exists('unxmlify')) {
|
if(! function_exists('unxmlify')) {
|
||||||
function unxmlify($s) {
|
function unxmlify($s) {
|
||||||
$ret = str_replace('&','&', $s);
|
// $ret = str_replace('&','&', $s);
|
||||||
$ret = str_replace(array('<','>','"','''),array('<','>','"',"'"),$ret);
|
// $ret = str_replace(array('<','>','"','''),array('<','>','"',"'"),$ret);
|
||||||
|
$ret = mb_ereg_replace('&', '&', $s);
|
||||||
|
$ret = mb_ereg_replace(''', "'", $ret);
|
||||||
|
$ret = mb_ereg_replace('"', '"', $ret);
|
||||||
|
$ret = mb_ereg_replace('<', "<", $ret);
|
||||||
|
$ret = mb_ereg_replace('>', ">", $ret);
|
||||||
return $ret;
|
return $ret;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue