修复ecshop专题商品unserialize函数计算错误

2016-09-07 22:02 来源:www.chinab4c.com 作者:ecshop专家

ecshop 专题添加商品不显示,因为编码差异引起unserialize函数长度计算错误,以下chinab4c分享该解决方法

1、ecshop文件admin/topic.php

找到:
        $topic['data'] = addcslashes($topic['data'], "'");
        $topic['data'] = $json->encode(@unserialize($topic['data']));
        $topic['data'] = addcslashes($topic['data'], "'");

替换为:

        $topic['data']= preg_replace('!s:(\\d+):"(.*?)";!se', "'s:'.strlen('$2').':\\"$2\\";'", $topic['data'] );
        $topic['data']= str_replace("\\r", "",$topic['data']);   
        $topic['data'] = addcslashes($topic['data'], "'");
        $topic['data'] = $json->encode(@unserialize($topic['data']));
        $topic['data'] = addcslashes($topic['data'], "'");

 

2、找到topic.php
找到:

$topic['data'] = addcslashes($topic['data'], "'");

替换为:


    $topic['data']= preg_replace('!s:(\\d+):"(.*?)";!se', "'s:'.strlen('$2').':\\"$2\\";'", $topic['data'] );
    $topic['data']= str_replace("\\r", "",$topic['data']);   
    $topic['data'] = addcslashes($topic['data'], "'");

(责任编辑:chinab4c)