diff --git a/src-php/EMT.Lib.php b/src-php/EMT.Lib.php index 0e780eb..f83a900 100644 --- a/src-php/EMT.Lib.php +++ b/src-php/EMT.Lib.php @@ -197,9 +197,9 @@ public static function remove_html_tags($text, $allowableTag = null) public static function safe_tag_chars($text, $way) { if ($way) - $text = preg_replace_callback('/(\<\/?)([^<>]+?)(\>)/s', create_function('$m','return (strlen($m[1])==1 && substr(trim($m[2]), 0, 1) == \'-\' && substr(trim($m[2]), 1, 1) != \'-\')? $m[0] : $m[1].( substr(trim($m[2]), 0, 1) === "a" ? "%%___" : "" ) . EMT_Lib::encrypt_tag(trim($m[2])) . $m[3];'), $text); + $text = preg_replace_callback('/(\<\/?)([^<>]+?)(\>)/s', function($m) {return (strlen($m[1])==1 && substr(trim($m[2]), 0, 1) == '-' && substr(trim($m[2]), 1, 1) != '-')? $m[0] : $m[1].( substr(trim($m[2]), 0, 1) === "a" ? "%%___" : "" ) . EMT_Lib::encrypt_tag(trim($m[2])) . $m[3]; }, $text); else - $text = preg_replace_callback('/(\<\/?)([^<>]+?)(\>)/s', create_function('$m','return (strlen($m[1])==1 && substr(trim($m[2]), 0, 1) == \'-\' && substr(trim($m[2]), 1, 1) != \'-\')? $m[0] : $m[1].( substr(trim($m[2]), 0, 3) === "%%___" ? EMT_Lib::decrypt_tag(substr(trim($m[2]), 4)) : EMT_Lib::decrypt_tag(trim($m[2])) ) . $m[3];'), $text); + $text = preg_replace_callback('/(\<\/?)([^<>]+?)(\>)/s', function($m) {return (strlen($m[1])==1 && substr(trim($m[2]), 0, 1) == '-' && substr(trim($m[2]), 1, 1) != '-')? $m[0] : $m[1].( substr(trim($m[2]), 0, 3) === "%%___" ? EMT_Lib::decrypt_tag(substr(trim($m[2]), 4)) : EMT_Lib::decrypt_tag(trim($m[2])) ) . $m[3];} , $text); return $text; } @@ -212,7 +212,7 @@ public static function safe_tag_chars($text, $way) */ public static function decode_internal_blocks($text) { - $text = preg_replace_callback('/'.EMT_Lib::INTERNAL_BLOCK_OPEN.'([a-zA-Z0-9\/=]+?)'.EMT_Lib::INTERNAL_BLOCK_CLOSE.'/s', create_function('$m','return EMT_Lib::decrypt_tag($m[1]);'), $text); + $text = preg_replace_callback('/'.EMT_Lib::INTERNAL_BLOCK_OPEN.'([a-zA-Z0-9\/=]+?)'.EMT_Lib::INTERNAL_BLOCK_CLOSE.'/s', function($m) {return EMT_Lib::decrypt_tag($m[1]);}, $text); return $text; } @@ -649,13 +649,13 @@ public static function html_char_entity_to_unicode($entity) public static function convert_html_entities_to_unicode(&$text) { $text = preg_replace_callback("/\&#([0-9]+)\;/", - create_function('$m', 'return EMT_Lib::_getUnicodeChar(intval($m[1]));') + function($m) {return EMT_Lib::_getUnicodeChar(intval($m[1])); } , $text); $text = preg_replace_callback("/\&#x([0-9A-F]+)\;/", - create_function('$m', 'return EMT_Lib::_getUnicodeChar(hexdec($m[1]));') + function($m) {return EMT_Lib::_getUnicodeChar(hexdec($m[1])); } , $text); $text = preg_replace_callback("/\&([a-zA-Z0-9]+)\;/", - create_function('$m', '$r = EMT_Lib::html_char_entity_to_unicode($m[1]); return $r ? $r : $m[0];') + function($m) { $r = EMT_Lib::html_char_entity_to_unicode($m[1]); return $r ? $r : $m[0]; } , $text); } diff --git a/src-php/EMT.Tret.Quote.php b/src-php/EMT.Tret.Quote.php index 9f41e1c..67b65c4 100644 --- a/src-php/EMT.Tret.Quote.php +++ b/src-php/EMT.Tret.Quote.php @@ -130,7 +130,7 @@ protected function build_sub_quotations() if($__ax) { $k = preg_replace_callback("/(^|[^0-9])([0-9]+)\»\;/ui", - create_function('$m','global $__ax,$__ay; $__ay++; if($__ay==$__ax){ return $m[1].$m[2]."″";} return $m[0];'), + function($m) {global $__ax,$__ay; $__ay++; if($__ay==$__ax){ return $m[1].$m[2]."″";} return $m[0];}, $k); $amount = 1; } diff --git a/src-php/EMT.Tret.php b/src-php/EMT.Tret.php index 51c1d07..01dad9d 100644 --- a/src-php/EMT.Tret.php +++ b/src-php/EMT.Tret.php @@ -208,7 +208,7 @@ private function apply_rule($rule) } $this->error('Функция '.$rule['function'].' из правила '.$rule['id']. " не найдена"); } else { - $this->_text = preg_replace_callback($rule['pattern'], create_function('$m', $rule['function']), $this->_text); + $this->_text = preg_replace_callback($rule['pattern'], function($m) use($rule) { $rule['function']; }, $this->_text); $this->log('Замена с использованием preg_replace_callback с инлайн функцией из правила '.$rule['id']); return; } diff --git a/src-php/EMT.php b/src-php/EMT.php index 56124da..861ed03 100644 --- a/src-php/EMT.php +++ b/src-php/EMT.php @@ -253,7 +253,7 @@ public function safe_blocks($text, $way, $show = true) $safeblocks = true === $way ? $this->_safe_blocks : array_reverse($this->_safe_blocks); foreach ($safeblocks as $block) { - $text = preg_replace_callback("/({$block['open']})(.+?)({$block['close']})/s", create_function('$m','return $m[1].'.$safeType . '.$m[3];') , $text); + $text = preg_replace_callback("/({$block['open']})(.+?)({$block['close']})/s", function($m) {return $m[1].'.$safeType . '.$m[3];}, $text); } }