安裝ECshop廣泛問題的解決方法

安裝時的問題:php

1.Strict Standards: Non-static method cls_image::gd_version() should not be called statically in /usr/local/httpd2/htdocs/upload/install/includes/lib_installer.php on line 31數組

  解決:找到install/includes/lib_installer.php中的第31行   return cls_image::gd_version();服務器

  而後在找到include/cls_image.php中的678行,發現gd_version()方法未聲明靜態static,因此會出錯。ide

  這時候只要:函數

  1)將function gd_version()改爲static function gd_version()便可(嚴重建議使用此方法!!!)。ui

  2)或者將install/includes/lib_installer.php中的第31行return cls_image::gd_version();改爲:this

$p = new cls_image();
return $p->gd_version();

 

2.檢測環境的時候提示:是否支持 JPEG是不支持的。url

  解決:查看發現有libjpeg.lib庫,GD2庫也有,都加載了,也都正常。查看ecshop源代碼發現install/includes/lib_installer.php中第100行,JPEG寫成了JPG,正確的應該是:spa

$jpeg_enabled = ($gd_info['JPEG Support']=== true) ? $_LANG['support'] : $_LANG['not_support'];

  爲什麼說Ecshop寫錯了,由於打印數組$gd_info的時候,裏面的鍵名是:JPEG Support。而$gd_info數組裏的值都是直接調用系統環境變量的。code

 

3.默認時區問題:Warning:date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /usr/local/httpd2/htdocs/upload/install/includes/lib_installer.php on line 223

  解決:

  方法1,修改PHP配置文件。若是你服務器的主要時區是亞洲上海,那麼修改這裏是比較穩當的,固然更穩妥的辦法是經過.htaccess導入PHP設置。 
      打開PHP.INI大概在958找到; date.timezone =去掉前面的註釋;號,而後改爲date.timezone =Asia/Shanghai,保存配置文件,重啓你的服務器。

  方法2,在頁頭使用 

ini_set('date.timezone','Asia/Shanghai');

  方法3,修改\install\includes\lib_installer.php文件。在這個文件頂部<?php以內加上以下PHP代碼:

date_default_timezone_set ('Asia/Shanghai');

 

登陸使用時問題

一,ECshop是基於PHP5.3如下版本開發的,因爲PHP5.5版本已廢除了e模式修飾符,所以若是你使用的是PHP5.5以上環境安裝,可能會出現相似如下3種報錯

PHP 5.5.0 起, 傳入 "\e" 修飾符的時候,會產生一個 E_DEPRECATED 錯誤; PHP 7.0.0 起,會產生 E_WARNING 錯誤,同時 "\e" 也沒法起效。
可使用 preg_replace_callback() 代替 

1,Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /usr/local/httpd2/htdocs/upload/includes/cls_template.php on line 288

 解決方法已經在報錯提示中,打開/usr/local/httpd2/htdocs/upload/includes/cls_template.php 定位至300行,將本來

return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);
改成
return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->select($r[1]); }, $source);

2,Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in F:\php_act\11_ec\upload\includes\cls_template.php on line 555

定位到upload\includes\cls_template.php第555行,將

$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);
改成
$val=preg_replace_callback("/\[([^\[\]]*)\]/is",function($r){return '.'.str_replace('$','\$',$r[1]);},$val);

3,Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in F:\php_act\11_ec\upload\includes\cls_template.php on line 1075

定位到 upload\includes\cls_template.php on line 1075,將

$pattern     = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/se';
$replacement = "'{include file='.strtolower('\\1'). '}'";
$source      = preg_replace($pattern, $replacement, $source);
改成一行
$source      = preg_replace_callback('/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/s', function($r){return '{include file='.strtolower($r[1]). '}';}, $source);

4,Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in F:\php_act\11_ec\upload\includes\cls_template.php on line 496

定位到upload\includes\cls_template.php on line 496

$out = "<?php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n";
改成
$out = "<?php \n" . '$k = ' . preg_replace_callback("/(\'\\$[^,]+)/" , function($r){return stripslashes(trim($r[1],'\''));}, var_export($t, true)) . ";\n";

 

 

二,PHP5.3以上默認只能傳遞具體的變量,而不能經過函數返回值傳遞

1,Strict standards: Only variables should be passed by reference in /usr/local/httpd2/htdocs/upload/includes/cls_template.php on line 423

  定位upload/includes/cls_template.php on line 423

$tag_sel = array_shift(explode(' ', $tag));
改成
$tag_sel = explode(' ', $tag);
$tag_sel = array_shift($tag_sel);

2,Strict standards: Only variables should be passed by reference in F:\php_act\11_ec\upload\includes\lib_main.php on line 1329

定位到upload\includes\lib_main.php on line 1329

$ext = end(explode('.', $tmp));
改成
$_end=explode('.', $tmp);
$ext = end($_end);

 

三,Strict standards: Redefining already defined constructor for class XXX

  此報錯是使用PHP5.4以上版本安裝ecshop可能出現的,例如本人安裝後登陸管理後臺顯示不出驗證碼這個狀況:

      

  右鍵驗證碼處點擊「複製圖片網址」後打開,便能看到這個錯誤。

  打開報錯所在文件看到以下代碼:

 1     function captcha($folder = '', $width = 145, $height = 20)
 2     {
 3         if (!empty($folder))
 4         {
 5             $this->folder = $folder;
 6         }
 7 
 8         $this->width    = $width;
 9         $this->height   = $height;
10 
11         /* 檢查是否支持 GD */
12         if (PHP_VERSION >= '4.3')
13         {
14 
15             return (function_exists('imagecreatetruecolor') || function_exists('imagecreate'));
16         }
17         else
18         {
19 
20             return (((imagetypes() & IMG_GIF) > 0) || ((imagetypes() & IMG_JPG)) > 0 );
21         }
22     }
23 
24  
25     function __construct($folder = '', $width = 145, $height = 20)
26     {
27         $this->captcha($folder, $width, $height);
28     }

  能夠看到其中使用和類名相同點函數名做爲構造函數是php4時代的寫法,php5時代的構造函數是 __construct(),ecshop爲了兼容老版本的php,因此採用了上面的寫法,可是從php5.4開始,對於這樣的兩種寫法同時出現的狀況,要求必須__construct()在前,同名函數在後,因此只須要對調兩個函數的位置便可。

 

四,mktime()問題 

1,Strict standards: mktime(): You should be using the time() function instead in F:\php_act\11_ec\upload\admin\sms_url.php on line 31

定位到upload\admin\sms_url.php on line 31

$auth = mktime();
改成
$auth = time();

2, Strict standards: mktime(): You should be using the time() function instead in F:\php_act\11_ec\upload\admin\shop_config.php on line 32

定位到upload\admin\shop_config.php on line 32,修改同上

相關文章
相關標籤/搜索