Ecshop 專用響應式模板特價中:5800

網址自動快速安裝,完全不須手動修改,HTML5+CSS3+Bootstrap4+Font Awesome5,依照設備多圖顯示與支援手指撥動的廣告輪播,自動適應設備寬度,提供免費局部修改支援,手機與PC內容一致,維護容易節省成本【響應式模板展示
目前位置: 首頁 > Ecshop 綜合文章 > ecshop2.7.3從PHP5升級到PHP7.3修改方法(20200629更新)

ecshop2.7.3從PHP5升級到PHP7.3修改方法(20200629更新) 超大 稍大 微大

Ecshop For PHP7.3::繁體中文全支援-原來如此 By we-shop.net 發表於: 2020-06-11 最後更新: 最後更新時間:2020-06-29 10:07:09

php5.2 升級到 php5.4

修改改前記得備份喔!

1、Strict standards: Only variables should be passed by reference in **********includes\lib_main.php on line 1316
   $ext = end(explode('.', $tmp));
改成
	$tmp_ext = explode('.', $tmp);
	$ext = end($tmp_ext);
2、Strict standards: Only variables should be passed by reference in **********includes\cls_template.php on line 406
	$tag_sel = array_shift(explode(' ', $tag));
改成
	$tagsel = explode(' ', $tag);
	$tag_sel = array_shift($tagsel);
3-1、Strict standards: Non-static method cls_sql_dump::get_random_name() should not be called statically in **********admin\database.php on line 64
	修改 admin\includes\cls_sql_dump.php
	function get_random_name()
改成
	static function get_random_name()
3-2、Strict standards: Non-static method cls_sql_dump::get_head() should not be called statically in **********admin\database.php on line 124
	修改 admin\includes\cls_sql_dump.php
	function get_head($path)
改成
	static function get_head($path)
3-3、includes/lib_base.php on line 346 將cls_image.php 中
	function gd_version()
改成
	static function gd_version()
4、PHP Strict Standards: Redefining already defined c**tructor for class captcha in **********includes\cls_captcha.php on line 120 此問題會造成驗證碼無法顯示,修改 includes/cls_captcha.php 找到
	function __construct($folder = '', $width = 145, $height = 20)
	{
		$this->captcha($folder, $width, $height);
	}
將它移到
	function captcha($folder = '', $width = 145, $height = 20)
的上面 5、Strict Standards: mktime(): You should be using the time() function instead in **********admin/sms_url.php on line 31 Strict standards: mktime(): You should be using the time() function instead in **********admin\shop_config.php on line 32
	$auth = mktime();
改成
	$auth = time();
6、底下的錯誤不一定你有,但是修改方法都一樣 資料庫備份還原 Strict standards: Redefining already defined constructor for class cls_sql_dump in **********admin\includes\cls_sql_dump.php on line 90
付款模組
Strict Standards: Redefining already defined constructor for class chinabank in **********includes/modules/payment/chinabank.php on line 85
Strict Standards: Redefining already defined constructor for class paypal_ec in **********includes/modules/payment/paypal_ec.php on line 96
Strict Standards: Redefining already defined constructor for class shenzhou in **********includes/modules/payment/shenzhou.php on line 81
Strict Standards: Redefining already defined constructor for class ips in **********includes/modules/payment/ips.php on line 82
Strict Standards: Redefining already defined constructor for class balance in **********includes/modules/payment/balance.php on line 79
Strict Standards: Redefining already defined constructor for class alipay in **********includes/modules/payment/alipay.php on line 85
Strict Standards: Redefining already defined constructor for class tenpay in **********includes/modules/payment/tenpay.php on line 83
Strict Standards: Redefining already defined constructor for class post in **********includes/modules/payment/post.php on line 79
Strict Standards: Redefining already defined constructor for class paypal in **********includes/modules/payment/paypal.php on line 82
Strict Standards: Redefining already defined constructor for class tenpayc2c in **********includes/modules/payment/tenpayc2c.php on line 83
Strict Standards: Redefining already defined constructor for class cappay in **********includes/modules/payment/cappay.php on line 81
Strict Standards: Redefining already defined constructor for class bank in **********includes/modules/payment/bank.php on line 79
Strict Standards: Redefining already defined constructor for class kuaiqian in **********includes/modules/payment/kuaiqian.php on line 83
Strict Standards: Redefining already defined constructor for class cod in **********includes/modules/payment/cod.php on line 82
解決辦法:
將所有的構造函數放到前面:
例如:alipay.php 將
    function __construct()
    {
        $this->alipay();
    }
將它移到
    function alipay()
    {
    .....
    }
的上面 7、includes/modules/integrates/ucenter.php add_user() 錯誤
   /*增加會員*/
    function add_user($username, $password, $email)
改成
    /*增加會員*/
    function add_user($username, $password, $email, $gender = -1, $bday = 0, $reg_date=0, $md5password='')
********** 前面是錯誤提示,後面是錯誤的檔案路徑與行號

php5.4 升級到 php5.6

如果你的 ECSHOP 使用 PHP5.4 的話,只需編輯 includes/cls_template.php 即可支援 PHP5.6,共四處,為防出錯修改請先備份,改好之後登入 cpanel 更改PHP版本
includes/cls_template.php 約 288 行找到
return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);
改為
//return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);
return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->select($r[1]); }, $source);
約 480 找到
$out = "_echash . $k[\'name\'] . \'|\' . serialize($k) . $this->_echash;' . "\n?>";
約 541 找到
$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);
改為
//$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);
$val = preg_replace_callback("/\[([^\[\]]*)\]/is", function($r) { return '.'.$r[1]; }, $val);
約 1059 找到
$pattern = '/.*?/se';
$replacement = "'{include file='.strtolower('\\1'). '}'";
$source  = preg_replace($pattern, $replacement, $source);
改為
//$pattern = '/.*?/se';
//$replacement = "'{include file='.strtolower('\\1'). '}'";
//$source  = preg_replace($pattern, $replacement, $source);
$pattern = '/.*?/s';
$replacement = function ($r) { return '{include file='.strtolower($r[1]). '}'; };
$source  = preg_replace_callback($pattern, $replacement, $source);

php5.6 升級到 php7.3

includes/cls_ecshop.php
尋找 function ECS
includes/modules/integrates/integrate.php
尋找 function integrate
	
includes/modules/integrates/ecshop.php
尋找 parent::integrate
admin/includes/cls_iconv.php
尋找 function Chinese
includes/cls_smtp.php
尋找 function smtp
	
admin/includes/cls_exchange.php
尋找 function exchange
和其他類名與函數名相同的函數名全部換成 function __construct
admin/flow_stats.php 找到
$start_date 改成 intval($start_date)
$end_date 改成 intval($end_date)
$timezone 改成 intval($timezone)
$_GET['start_date'] 改成 intval($_GET['start_date'])
$_GET['end_date'] 改成 intval($_GET['end_date'])
總共七處如下:
約 97     $val['access_date'] = gmdate('m-d',$val['access_time'] +  intval($timezone) * 3600);
約 352    $filename = gmdate($_CFG['date_format'], intval($start_date) + intval($timezone) * 3600) . '_' .
約 353    gmdate($_CFG['date_format'], intval($end_date) + intval($timezone) * 3600);
約 371    $start_date = empty($_GET['start_date']) ? strtotime('-20 day') : intval($_GET['start_date']);
約 372    $end_date   = empty($_GET['end_date']) ? time() : intval($_GET['end_date']);
includes/lib_clips.php 將
$cmp = create_function('$a, $b', 'if($a["add_time"] == $b["add_time"]){return 0;};return $a["add_time"] < $b["add_time"] ? 1 : -1;'); 改成 $cmp = function($a,$b){ if($a["add_time"] == $b["add_time"]){ return 0; } return $a["add_time"] < $b["add_time"] ? 1 : -1; }; 
最後將原本的 Mysql 資料庫改成 Mysqli 資料庫即大功告成 上述是目前將ECSHOP升級至PHP7所修改的地方,僅供參考。PHP5在2018年底已經停止維護更新,假若駭客未來發現舊版漏洞,將面臨無以修補的狀況,而成為資安孤兒,PHP7比PHP5速度至少快兩倍,安全性也相對更高,雖然ECSHOP2.7.3也不再更新,但仍有不少的使用者,因此升級至php7除了延續ECSHOP2.7.3的使用壽命,也提升了整體效能與安全性DEMO.
本站提供ECSHOP技術支援, 是網路開店最佳選擇 ,最後更新時間: 最後更新時間:2020-06-29 10:07:09