diff --git a/src/include/arc.archives.class.php b/src/include/arc.archives.class.php index fec810eb..42dc1b92 100755 --- a/src/include/arc.archives.class.php +++ b/src/include/arc.archives.class.php @@ -1230,7 +1230,12 @@ class Archives // 这里可能会有错误 if (version_compare(PHP_VERSION, '5.5.0', '>=')) { - $body = @preg_replace_callback("#(^|>)([^<]+)(?=<|$)#sU", "_highlight('\\2', \$karr, \$kaarr, '\\1')", $body); + if (version_compare(PHP_VERSION, '8', '>=')) { + $body = @preg_replace_callback("#(^|>)([^<]+)(?=<|$)#sU", "_highlight8", $body); + } else { + $body = @preg_replace_callback("#(^|>)([^<]+)(?=<|$)#sU", "_highlight('\\2', \$karr, \$kaarr, '\\1')", $body); + } + } else { $body = @preg_replace("#(^|>)([^<]+)(?=<|$)#sUe", "_highlight('\\2', \$karr, \$kaarr, '\\1')", $body); } @@ -1243,6 +1248,10 @@ class Archives }//End Archives +function _highlight8($matches) { + // TODO +} + //高亮专用, 替换多次是可能不能达到最多次 function _highlight($string, $words, $result, $pre) { diff --git a/src/include/control.class.php b/src/include/control.class.php index c678f452..66c94545 100755 --- a/src/include/control.class.php +++ b/src/include/control.class.php @@ -1,4 +1,4 @@ -Control(); } - + // 析构函数 function Control() { global $dsql; - $this->tpl = isset($this->tpl)? $this->tpl : new DedeTemplate(); + $this->tpl = isset($this->tpl) ? $this->tpl : new DedeTemplate(); $sqltype = "DedeSql"; if ($GLOBALS['cfg_mysql_type'] == 'mysqli' && function_exists("mysqli_init")) $sqltype = "DedeSql"; else $sqltype = "DedeSqli"; - $this->dsql = isset($dsql)? $dsql : new $sqltype(FALSE); + $this->dsql = isset($dsql) ? $dsql : new $sqltype(FALSE); } - + //设置模板 //如果想要使用模板中指定的pagesize,必须在调用模板后才调用 SetSource($sql) function SetTemplate($tplfile) { - $tplfile = DEDEAPPTPL.'/'.$this->style.'/'.$tplfile; + $tplfile = DEDEAPPTPL . '/' . $this->style . '/' . $tplfile; $this->tpl->LoadTemplate($tplfile); } function SetTemplet($tplfile) { - $tplfile = DEDEAPPTPL.'/'.$this->style.'/'.$tplfile; + $tplfile = DEDEAPPTPL . '/' . $this->style . '/' . $tplfile; $this->tpl->LoadTemplate($tplfile); } - + //设置/获取文档相关的各种变量 function SetVar($k, $v) { @@ -59,76 +59,70 @@ class Control global $_vars; return isset($_vars[$k]) ? $_vars[$k] : ''; } - - function Model($name='') + + function Model($name = '') { $name = preg_replace("#[^\w]#", "", $name); - $modelfile = DEDEMODEL.'/'.$name.'.php'; - if (file_exists($modelfile)) - { + $modelfile = DEDEMODEL . '/' . $name . '.php'; + if (file_exists($modelfile)) { require_once $modelfile; } - if (!empty($name) && class_exists($name)) - { + if (!empty($name) && class_exists($name)) { return new $name; - } + } return false; } - - function Libraries($name='',$data = '') + + function Libraries($name = '', $data = '') { - if(defined('APPNAME')) - { - $classfile = 'MY_'.$name.'.class.php'; - if ( file_exists ( '../'.APPNAME.'/libraries/'.$classfile ) ) - { - require '../'.APPNAME.'/libraries/'.$classfile; - return new $name($data); - }else{ - if (!empty($name) && class_exists($name)) - { - return new $name($data); - } - } - return FALSE; - }else{ - if (!empty($name) && class_exists($name)) - { - return new $name($data); - } - return FALSE; - } - } - + if (defined('APPNAME')) { + $classfile = 'MY_' . $name . '.class.php'; + if (file_exists('../' . APPNAME . '/libraries/' . $classfile)) { + require '../' . APPNAME . '/libraries/' . $classfile; + return new $name($data); + } else { + if (!empty($name) && class_exists($name)) { + return new $name($data); + } + } + return FALSE; + } else { + if (!empty($name) && class_exists($name)) { + return new $name($data); + } + return FALSE; + } + } + //载入helper - function helper($helper = "",$path) - { - $help_path = $path.'/data/helper/'.$helper.".helper.php"; - if (file_exists($help_path)) - { + function helper($helper, $path) + { + $help_path = $path . '/data/helper/' . $helper . ".helper.php"; + if (file_exists($help_path)) { include_once($help_path); - }else{ - exit('Unable to load the requested file: '.$helper.".helper.php"); - } + } else { + exit('Unable to load the requested file: ' . $helper . ".helper.php"); + } } - + //显示数据 function Display() { $this->tpl->SetObject($this); $this->tpl->Display(); } - + //保存为HTML function SaveTo($filename) { $this->tpl->SetObject($this); $this->tpl->SaveTo($filename); } - + // 释放资源 - function __destruct() { + function __destruct() + { unset($this->tpl); $this->dsql->Close(TRUE); } -} \ No newline at end of file +} diff --git a/src/include/dedehttpdown.class.php b/src/include/dedehttpdown.class.php index f391af9d..90cfc367 100755 --- a/src/include/dedehttpdown.class.php +++ b/src/include/dedehttpdown.class.php @@ -546,10 +546,13 @@ class DedeHttpDown */ function Close() { - if (function_exists('curl_init') && function_exists('curl_exec')) { + if (function_exists('curl_init') && function_exists('curl_exec') && $this->m_ch) { @curl_close($this->m_ch); } - @fclose($this->m_fp); + if ($this->m_fp) { + @fclose($this->m_fp); + } + } /** diff --git a/src/include/dedesqli.class.php b/src/include/dedesqli.class.php index e4525429..57888446 100755 --- a/src/include/dedesqli.class.php +++ b/src/include/dedesqli.class.php @@ -156,7 +156,10 @@ class DedeSqli //为了防止采集等需要较长运行时间的程序超时,在运行这类程序时设置系统等待和交互时间 function SetLongLink() { - @mysqli_query("SET interactive_timeout=3600, wait_timeout=3600 ;", $this->linkID); + if ($this->linkID) { + @mysqli_query($this->linkID, "SET interactive_timeout=3600, wait_timeout=3600 ;"); + } + } //获得错误描述