Xiuno BBS4.0.4不支持php7.4及以上方法

魔王  (UID: 1) 2023-11-24 [复制链接]
帖子链接已复制到剪贴板

727 0

解决xiuno4.0.4不支持php7.4及以上

1、/xiunophp/xiunophp.min.php 第20行

$get_magic_quotes_gpc = get_magic_quotes_gpc();

改成

$get_magic_quotes_gpc = 0;

 

2、/xiunophp/xiunophp.php 第20行

$get_magic_quotes_gpc = get_magic_quotes_gpc();

改成

$get_magic_quotes_gpc = 0;

 

3、/xiunophp/xn_html_safe.func.php 第785行、第938行、第951行

把这三行的

rawtext{}

大括号{}改为中括号[],PHP高版本数组不再支持大括号{}
实测PHP7.4和PHP8.0可以正常使用。

 

xiunophp/db.func.php  306行

$v = addslashes($v);
改成:
$v = addslashes($v ?? '');

 

model/user.func.php  

 (如果有) 3处。

$g_static_users[$user['uid']] = $user;

改成:

if ($user !== null && is_array($user)) {
    $g_static_users[$user['uid']] = $user;
}

 

 

解决php8.1下http_url_path报错方法:
xiunophp/misc.func.php文件大约1034行

源代码:

// 获取 http://xxx.com/path/
function http_url_path() {
    $port = _SERVER("SERVER_PORT");
    //$portadd = ($port == 80 ? "" : ":".$port);
    $host = _SERVER("HTTP_HOST");  // host 里包含 port
    $https = strtolower(_SERVER("HTTPS", "off"));
    $proto = strtolower(_SERVER("HTTP_X_FORWARDED_PROTO"));
    $path = substr($_SERVER["PHP_SELF"], 0, strrpos($_SERVER["PHP_SELF"], "/"));
    $http = (($port == 443) || $proto == "https" || ($https && $https != "off")) ? "https" : "http";
    return  "$http://$host$path/";
}

更改后:

// 获取 http://xxx.com/path/
function http_url_path() {
    $port = _SERVER("SERVER_PORT");
    //$portadd = ($port == 80 ? "" : ":".$port);
    $host = _SERVER("HTTP_HOST");  // host 里包含 port
    $https = strtolower(_SERVER("HTTPS", "off"));
    $proto = _SERVER("HTTP_X_FORWARDED_PROTO") ? strtolower(_SERVER("HTTP_X_FORWARDED_PROTO")) : ""; //此处加判断
    $path = substr($_SERVER["PHP_SELF"], 0, strrpos($_SERVER["PHP_SELF"], "/"));
    $http = (($port == 443) || $proto == "https" || ($https && $https != "off")) ? "https" : "http";
    return  "$http://$host$path/";
}

打开根目录/model/plugin.func.php 然后在第74行和第75行,前面加 // 斜杠,大功告成!

//$official_plugins = plugin_official_list_cache();
//empty($official_plugins) AND $official_plugins = array();

 

db.func.php

242行改成:

function db_cond_to_sqladd($cond) {
    $s = '';
    if (!empty($cond)) {
        $s = ' WHERE ';
        foreach ($cond as $k => $v) {
            if (!is_array($v)) {
                $v = ($v !== null && !is_array($v)) ? (is_int($v) || is_float($v) ? $v : "'" . addslashes($v) . "'") : 'NULL';
                $s .= "`$k`=$v AND ";
            } elseif (isset($v[0])) {
                $s .= '(';
                foreach ($v as $v1) {
                    $v1 = ($v1 !== null) ? (is_int($v1) || is_float($v1) ? $v1 : "'" . addslashes($v1) . "'") : 'NULL';
                    $s .= "`$k`=$v1 OR ";
                }
                $s = substr($s, 0, -4);
                $s .= ') AND ';
            } else {
                foreach ($v as $k1 => $v1) {
                    if ($k1 == 'LIKE') {
                        $k1 = ' LIKE ';
                        $v1 = "%$v1%";
                    }
                    $v1 = ($v1 !== null) ? (is_int($v1) || is_float($v1) ? $v1 : "'" . addslashes($v1) . "'") : 'NULL';
                    $s .= "`$k`$k1$v1 AND ";
                }
            }
        }
        $s = substr($s, 0, -4);
    }
    return $s;
}
已有评论 (0)
提示:您必须 登录 才能查看此内容。
创建新帖