本站Emlog6.0.0升级PHP8思路和解决方案
- A
今天折腾了一个小时研究了一下,本站升级到了PHP8.1,把本身不支持PHP8的emlog程序实现了兼容,记录一下操作流程。
1.找到include/lib/function.base.php文件,转到第20行,将:
/**
* 去除多余的转义字符
*/
function doStripslashes() {
if (get_magic_quotes_gpc()) {
$_GET = stripslashesDeep($_GET);
$_POST = stripslashesDeep($_POST);
$_COOKIE = stripslashesDeep($_COOKIE);
$_REQUEST = stripslashesDeep($_REQUEST);
}
}
替换为:
/**
* 去除多余的转义字符
*/
function doStripslashes() {
$_GET = stripslashesDeep($_GET);
$_POST = stripslashesDeep($_POST);
$_COOKIE = stripslashesDeep($_COOKIE);
$_REQUEST = stripslashesDeep($_REQUEST);
}
2.找到include/lib/function.base.php文件,转到第294行,将:
/**
* 该函数在插件中调用,挂载插件函数到预留的钩子上
*
* @param string $hook
* @param string $actionFunc
* @return boolearn
*/
function addAction($hook, $actionFunc) {
global $emHooks;
if (!@in_array($actionFunc, $emHooks[$hook])) {
$emHooks[$hook][] = $actionFunc;
}
return true;
}
替换为:
/**
* 该函数在插件中调用,挂载插件函数到预留的钩子上
*
* @param string $hook
* @param string $actionFunc
* @return boolearn
*/
function addAction($hook, $actionFunc) {
global $emHooks;
if (!isset($emHooks[$hook]) || !in_array($actionFunc, $emHooks[$hook])) {
$emHooks[$hook][] = $actionFunc;
}
return true;
}
3.找到include/model/tag_model.php文件,转到第318行,将:
/**
* 从TagId获取到BlogId列表 (获取到一个Tag下所有的文章)
* @param int $tagId 标签ID
* @return array 文章ID列表
*/
function getBlogIdsFromTagId($tagId) {
$blogs = array();
$sql = "SELECT `gid` FROM `" . DB_PREFIX . "tag` WHERE `tid` = " . $tagId;
$query = $this->db->query($sql);
if ($this->db->num_rows($query) > 0) {
$result = $this->db->fetch_array($query);
if ( ! empty($result['gid']))
{
$blogs = explode(',', $result['gid']);
}else{
return false;
}
}
return $blogs;
}
替换为:
/**
* 从TagId获取到BlogId列表 (获取到一个Tag下所有的文章)
* @param int $tagId 标签ID
* @return array 文章ID列表
*/
function getBlogIdsFromTagId($tagId) {
$blogs = array();
$sql = "SELECT `gid` FROM `" . DB_PREFIX . "tag` WHERE `tid` = " . $tagId;
$query = $this->db->query($sql);
if ($this->db->num_rows($query) > 0) {
$result = $this->db->fetch_array($query);
if ( ! empty($result['gid']))
{
$blogs = explode(',', $result['gid']);
}else{
return [];
}
}
return $blogs;
}
自此,关于程序核心部分导致的报错就解决了,如果网站还是无法正常运行,则需要根据自己所使用的模板再进一步兼容
版权声明:若无特殊注明,本文为《傲世》原创,转载请保留文章出处。
本文链接:https://www.recho.cn/237.html
如您对本文章内容有所疑问、反馈或补充,欢迎通过邮箱:admin@h2fast.cn 联系我们!
正文到此结束






