From bfe8271e6efbe2e3fc94b935c69b64821a6ee34f Mon Sep 17 00:00:00 2001 From: earnolmartin Date: Thu, 13 Jul 2023 12:58:54 -0600 Subject: [PATCH] PHP 8.x Fixes --- ehcp/adodb5/drivers/adodb-mssql.inc.php | 4 +++- ehcp/adodb5/drivers/adodb-mssqlnative.inc.php | 4 +++- ehcp/classapp.php | 2 +- ehcp/extplorer/libraries/geshi/geshi.php | 14 ++++---------- ehcp/net2ftp/plugins/luminous/languages/bnf.php | 3 +-- .../net2ftp/plugins/luminous/languages/ruby.php | 3 +-- .../src/formatters/htmlformatter.class.php | 9 ++++----- .../src/formatters/latexformatter.class.php | 17 ++++++++++++++--- 8 files changed, 31 insertions(+), 25 deletions(-) diff --git a/ehcp/adodb5/drivers/adodb-mssql.inc.php b/ehcp/adodb5/drivers/adodb-mssql.inc.php index fb87a4a..fb6330f 100644 --- a/ehcp/adodb5/drivers/adodb-mssql.inc.php +++ b/ehcp/adodb5/drivers/adodb-mssql.inc.php @@ -680,7 +680,9 @@ order by constraint_name, referenced_table_name, keyno"; $arr = $args; } - array_walk($arr, create_function('&$v', '$v = "CAST(" . $v . " AS VARCHAR(255))";')); + array_walk($arr, function(&$v){ + $v = "CAST(" . $v . " AS VARCHAR(255))"; + }); $s = implode('+',$arr); if (sizeof($arr) > 0) return "$s"; diff --git a/ehcp/adodb5/drivers/adodb-mssqlnative.inc.php b/ehcp/adodb5/drivers/adodb-mssqlnative.inc.php index 08cdcf6..a5b663e 100644 --- a/ehcp/adodb5/drivers/adodb-mssqlnative.inc.php +++ b/ehcp/adodb5/drivers/adodb-mssqlnative.inc.php @@ -530,7 +530,9 @@ class ADODB_mssqlnative extends ADOConnection { $arr = $args; } - array_walk($arr, create_function('&$v', '$v = "CAST(" . $v . " AS VARCHAR(255))";')); + array_walk($arr, function(&$v){ + $v = "CAST(" . $v . " AS VARCHAR(255))"; + }); $s = implode('+',$arr); if (sizeof($arr) > 0) return "$s"; diff --git a/ehcp/classapp.php b/ehcp/classapp.php index b23d896..1c08a4a 100755 --- a/ehcp/classapp.php +++ b/ehcp/classapp.php @@ -13693,7 +13693,7 @@ function syncDomains($file='',$domainname='') { if(isset($sslInfo["lets_enc_additional_hosts"]) && !empty($sslInfo["lets_enc_additional_hosts"])){ $subdoms=$this->getSubDomains("domainname = '" . $dom['domainname'] . "'"); if(is_array($subdoms) && count($subdoms) > 0){ - $subdomsDomain = array_map(create_function('$ar', 'return $ar["subdomain"];'), $subdoms); + $subdomsDomain = array_map(function($ar){ return $ar["subdomain"]; }, $subdoms); }else{ $subdomsDomain = array(); } diff --git a/ehcp/extplorer/libraries/geshi/geshi.php b/ehcp/extplorer/libraries/geshi/geshi.php index a7b2453..dd82668 100755 --- a/ehcp/extplorer/libraries/geshi/geshi.php +++ b/ehcp/extplorer/libraries/geshi/geshi.php @@ -4568,18 +4568,12 @@ class GeSHi { if (!$recursed) { // do some optimizations // common trailing strings - // BUGGY! - //$list = preg_replace_callback('#(?<=^|\:|\|)\w+?(\w+)(?:\|.+\1)+(?=\|)#', create_function( - // '$matches', 'return "(?:" . preg_replace("#" . preg_quote($matches[1], "#") . "(?=\||$)#", "", $matches[0]) . ")" . $matches[1];'), $list); - // (?:p)? => p? $list = preg_replace('#\(\?\:(.)\)\?#', '\1?', $list); // (?:a|b|c|d|...)? => [abcd...]? // TODO: a|bb|c => [ac]|bb - static $callback_2; - if (!isset($callback_2)) { - $callback_2 = create_function('$matches', 'return "[" . str_replace("|", "", $matches[1]) . "]";'); - } - $list = preg_replace_callback('#\(\?\:((?:.\|)+.)\)#', $callback_2, $list); + $list = preg_replace_callback('#\(\?\:((?:.\|)+.)\)#', function($matches){ + return "[" . str_replace("|", "", $matches[1]) . "]"; + }, $list); } // return $list without trailing pipe return substr($list, 0, -1); @@ -4616,4 +4610,4 @@ if (!function_exists('geshi_highlight')) { } } -?> \ No newline at end of file +?> diff --git a/ehcp/net2ftp/plugins/luminous/languages/bnf.php b/ehcp/net2ftp/plugins/luminous/languages/bnf.php index 3c4a5b3..378db52 100644 --- a/ehcp/net2ftp/plugins/luminous/languages/bnf.php +++ b/ehcp/net2ftp/plugins/luminous/languages/bnf.php @@ -45,8 +45,7 @@ class LuminousBNFScanner extends LuminousStatefulScanner { // table, but here we are anyway $all = array('COMMENT', 'OPTION', 'REPETITION', 'GROUP', 'SPECIAL', 'STRING', 'IDENT', 'OPERATOR'); - $almost_all = array_filter($all, create_function('$x', - 'return $x !== "SPECIAL";')); + $almost_all = array_filter($all, function($x){ return $x !== "SPECIAL";}); $this->transitions = array( 'initial' => array_merge(array('RULE'), $all), 'OPTION' => $all, diff --git a/ehcp/net2ftp/plugins/luminous/languages/ruby.php b/ehcp/net2ftp/plugins/luminous/languages/ruby.php index 5df2ab4..c4590ec 100644 --- a/ehcp/net2ftp/plugins/luminous/languages/ruby.php +++ b/ehcp/net2ftp/plugins/luminous/languages/ruby.php @@ -134,8 +134,7 @@ class LuminousRubyScanner extends LuminousScanner { // don't want this. $this->remove_filter('comment-to-doc'); - $this->add_filter('REGEX', create_function('$tok', - 'return LuminousFilters::pcre($tok, (isset($tok[1][0]) && $tok[1][0] === "/"));')); + $this->add_filter('REGEX', function($tok){return LuminousFilters::pcre($tok, (isset($tok[1][0]) && $tok[1][0] === "/"));}); } diff --git a/ehcp/net2ftp/plugins/luminous/src/formatters/htmlformatter.class.php b/ehcp/net2ftp/plugins/luminous/src/formatters/htmlformatter.class.php index 154ac75..5a91428 100644 --- a/ehcp/net2ftp/plugins/luminous/src/formatters/htmlformatter.class.php +++ b/ehcp/net2ftp/plugins/luminous/src/formatters/htmlformatter.class.php @@ -179,11 +179,10 @@ class LuminousFormatterHTML extends LuminousFormatter { $code_block = preg_replace('/(?<=<\/)[A-Z_0-9]+(?=>)/S', 'span', $code_block); // convert to - $cb = create_function('$matches', - '$m1 = strtolower($matches[1]); - return ""; - '); - $code_block = preg_replace_callback('/<([A-Z_0-9]+)>/', $cb, $code_block); + $code_block = preg_replace_callback('/<([A-Z_0-9]+)>/', function($matches){ + $m1 = strtolower($matches[1]); + return ""; + }, $code_block); $format_data = array( 'language' => ($this->language === null)? '' : htmlentities($this->language), diff --git a/ehcp/net2ftp/plugins/luminous/src/formatters/latexformatter.class.php b/ehcp/net2ftp/plugins/luminous/src/formatters/latexformatter.class.php index af43bcf..87eaa7c 100644 --- a/ehcp/net2ftp/plugins/luminous/src/formatters/latexformatter.class.php +++ b/ehcp/net2ftp/plugins/luminous/src/formatters/latexformatter.class.php @@ -125,23 +125,34 @@ EOF; $str_ = preg_split('/(<[^>]+>)/', $str, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); + // orig code that no longer works in php 8+... + // Not sure if I converted it properly to anonymous functions or not... + /* $f1 = create_function('$matches', ' return "\\\lms" . str_replace("_", "", $matches[1]) . "{"; '); $f2 = create_function('$matches', ' if ($matches[0][0] == "\\\") return "{\\\textbackslash}"; return "\\\" . $matches[0];'); + */ foreach($str_ as $s_) { if ($s_[0] === '<') { $s_ = preg_replace('%]+>%', '}', $s_); - $s_ = preg_replace_callback('%<([^>]+)>%', $f1 - ,$s_); + $s_ = preg_replace_callback('%<([^>]+)>%', function($matches){ + return '\\\lms' . str_replace("_", "", $matches[1]) . "{"; + }, $s_); + } else { $s_ = str_replace('>', '>', $s_); $s_ = str_replace('<', '<', $s_); $s_ = str_replace('&', '&', $s_); - $s_ = preg_replace_callback('/[#{}_$\\\&]|&(?=amp;)/', $f2, $s_); + $s_ = preg_replace_callback('/[#{}_$\\\&]|&(?=amp;)/', function($matches){ + if ($matches[0][0] == "\\\\"){ + return '{\\\textbackslash}'; + } + return "\\\\" . $matches[0]; + }, $s_); } $s .= $s_;