From 070cf80a6951178d82a1409600c5f1ffe4d8451b Mon Sep 17 00:00:00 2001 From: orzi! <1063614727@qq.com> Date: Tue, 22 Jun 2021 19:09:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20function=20=E5=86=85?= =?UTF-8?q?=E9=83=A8=E5=88=86=20eval?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- upload/source/function/function_delete.php | 2 +- upload/source/function/function_forum.php | 4 +-- upload/source/function/function_preg.php | 33 +++++++++------------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/upload/source/function/function_delete.php b/upload/source/function/function_delete.php index 29fb02680..b6651f422 100644 --- a/upload/source/function/function_delete.php +++ b/upload/source/function/function_delete.php @@ -125,7 +125,7 @@ function deletepost($ids, $idtype = 'pid', $credit = false, $posttableid = false $idsstr = dimplode($ids); if($credit) { - $tuidarray = $ruidarray = $_G['deleteauthorids'] = array(); + $replycredit_list = $tuidarray = $ruidarray = $_G['deleteauthorids'] = array(); foreach($posttableids as $id) { $postlist = array(); if($idtype == 'pid') { diff --git a/upload/source/function/function_forum.php b/upload/source/function/function_forum.php index 363a43fde..e10456292 100644 --- a/upload/source/function/function_forum.php +++ b/upload/source/function/function_forum.php @@ -128,7 +128,7 @@ function formulaperm($formula) { } } } - @eval("\$formulaperm = ($formula) ? TRUE : FALSE;"); + $formulaperm = @eval($formula) ? true : false; if(!$formulaperm) { if(!$permmessage) { $language = lang('forum/misc'); @@ -235,7 +235,7 @@ function medalformulaperm($formula, $type) { } } } - @eval("\$formulaperm = ($formula) ? TRUE : FALSE;"); + $formulaperm = @eval($formula) ? true : false; if(!$formulaperm || $type == 2) { if(!$permmessage) { $language = lang('forum/misc'); diff --git a/upload/source/function/function_preg.php b/upload/source/function/function_preg.php index fec9583bd..b9417fdef 100644 --- a/upload/source/function/function_preg.php +++ b/upload/source/function/function_preg.php @@ -4,15 +4,12 @@ if(!defined('IN_DISCUZ') || (PHP_VERSION < '7.0.0')) { exit('Access Denied'); } - -eval(' - function dpreg_replace_impl($pattern, $replacement, $subject, $limit, &$count) { $eval = false; $delimiter = $pattern[0]; if(($position_of_modifier = (int) strrpos($pattern, $delimiter)) > 0) { - if(($position_of_eval = strpos($pattern, \'e\', $position_of_modifier)) !== false) { + if(($position_of_eval = strpos($pattern, 'e', $position_of_modifier)) !== false) { $eval = true; $pattern = substr($pattern, 0, $position_of_eval).substr($pattern, $position_of_eval + 1); } @@ -20,18 +17,18 @@ function dpreg_replace_impl($pattern, $replacement, $subject, $limit, &$count) { if($eval) { return preg_replace_callback($pattern, function($matches) use ($replacement) { - $result = \'\'; + $result = ''; $instance = false; for($i = 0, $j = strlen($replacement); $i < $j; $i ++) { - if(($replacement[$i] == \'$\') || ($replacement[$i] == \'\\\\\')) { - if((($i == 0) || ($replacement[$i - 1] != \'\\\\\')) && isset($replacement[$i + 1])) { + if(($replacement[$i] == '$') || ($replacement[$i] == '\\')) { + if((($i == 0) || ($replacement[$i - 1] != '\\')) && isset($replacement[$i + 1])) { $get_backref_string = substr($replacement, $i + 1); - if($get_backref_string[0] == \'{\') { - $get_backref_result = preg_match(\'/^\\{([0-9]{1,2})\}/\', $get_backref_string, $get_backref_match); + if($get_backref_string[0] == '{') { + $get_backref_result = preg_match('/^\{([0-9]{1,2})}/', $get_backref_string, $get_backref_match); } else { - $get_backref_result = preg_match(\'/^([0-9]{1,2})/\', $get_backref_string, $get_backref_match); + $get_backref_result = preg_match('/^([0-9]{1,2})/', $get_backref_string, $get_backref_match); } if($get_backref_result) { @@ -45,8 +42,8 @@ function dpreg_replace_impl($pattern, $replacement, $subject, $limit, &$count) { continue; } else { - if(preg_match(\'/^this([^a-z0-9_]+)/i\', $get_backref_string)) { - $result .= \'$_\'; + if(preg_match('/^this([^a-z0-9_]+)/i', $get_backref_string)) { + $result .= '$_'; $instance = true; continue; @@ -62,9 +59,9 @@ function dpreg_replace_impl($pattern, $replacement, $subject, $limit, &$count) { $_this = null; @$stack = (array) debug_backtrace(); - if(isset($stack[6]) && isset($stack[6][\'object\'])) { - if(is_object($stack[6][\'object\'])) { - $_this = $stack[6][\'object\']; + if(isset($stack[6]) && isset($stack[6]['object'])) { + if(is_object($stack[6]['object'])) { + $_this = $stack[6]['object']; } } } @@ -87,7 +84,7 @@ function dpreg_replace_in_subject($pattern, $replacement, $subject, $limit, &$co foreach($pattern as $pattern_value) { if(is_array($replacement)) { if(key($replacement) === null) { - $replacement_value = \'\'; + $replacement_value = ''; } else { $replacement_value = current($replacement); next($replacement); @@ -120,6 +117,4 @@ function _dpreg_replace($pattern, $replacement, $subject, $limit = -1, &$count = } else { return dpreg_replace_in_subject($pattern, $replacement, $subject, $limit, $count); } -} - -'); \ No newline at end of file +} \ No newline at end of file -- Gitee