有趣的事

Discuz X1.5 转换编码后 Diy页面的部分无法显示的解决

discuz的数据存储中,使用了很多serialize的形式存储。

在转换编码后,会出现serialize结果中标识的长度不统一的情况。

校正长度就可以了。方法:

文件:source/function/function_core.php

行数:2070

修改前:

function updatediytemplate($targettplname = '') {
        global $_G;
        $r = false;
        $where = empty($targettplname) ? '' : " WHERE targettplname='$targettplname'";
        $query = DB::query("SELECT * FROM ".DB::table('common_diy_data')."$where");
        require_once libfile('function/portalcp');
        while($value = DB::fetch($query)) {
                $r = save_diy_data($value['primaltplname'], $value['targettplname'], unserialize($value['diycontent']));
        }
        return $r;
}
```

修改后:

function updatediytemplate($targettplname = '') {
        global $_G;
        $r = false;
        $where = empty($targettplname) ? '' : " WHERE targettplname='$targettplname'";
        $query = DB::query("SELECT * FROM ".DB::table('common_diy_data')."$where");
        require_once libfile('function/portalcp');
        while($value = DB::fetch($query)) {
                $value['diycontent'] = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $value['diycontent'] );
                $r = save_diy_data($value['primaltplname'], $value['targettplname'], unserialize($value['diycontent']));
        }
        return $r;
}
```

Discuz X1.5 转换 编码 Diy 页面 无法 显示 解决 serialize 长度 匹配

相关阅读