国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

首頁 CMS教程 ECShop ecshop如何修改並支援PHP7

ecshop如何修改並支援PHP7

Jul 11, 2020 am 09:54 AM
ecshop

ecshop修改php的方法:首先將mysql擴展的使用替換掉,改為使用mysqli或pdo;然后更改“cls_image.php”的“gd_version()”方法,將這個方法改為靜態(tài)方法;最后去除使用類名的構(gòu)造函數(shù)。

ecshop如何修改並支援PHP7

ecshop支持PHP7的修改方法

(1)將mysql擴展的使用替換掉,改為使用mysqli或pdo(推薦使用mysqli):

推薦:《ECShop教程

從php5.5開始,mysql擴展將廢棄了。 具體更改的文件在于includes/cls_mysql.php。這是個不小的工程,文件代碼太長……

if (!defined('DITAN_ECS'))
{
die('Hacking attempt');
}
class cls_mysql
{
var $link_id = NULL;
var $settings = array();
var $queryCount = 0;
var $queryTime = '';
var $queryLog = array();
var $max_cache_time = 300; // 最大的緩存時間,以秒為單位
var $cache_data_dir = 'temp/query_caches/';
var $root_path = '';
var $error_message = array();
var $platform = '';
var $version = '';
var $dbhash = '';
var $starttime = 0;
var $timeline = 0;
var $timezone = 0;
// 事務(wù)指令數(shù)
protected $transTimes = 0;
var $mysql_config_cache_file_time = 0;
var $mysql_disable_cache_tables = array(); // 不允許被緩存的表,遇到將不會進行緩存
function __construct($dbhost, $dbuser, $dbpw, $dbname = '', $charset = 'gbk', $pconnect = 0, $quiet = 0)
{
$this->cls_mysql($dbhost, $dbuser, $dbpw, $dbname, $charset, $pconnect, $quiet);
}
function cls_mysql($dbhost, $dbuser, $dbpw, $dbname = '', $charset = 'gbk', $pconnect = 0, $quiet = 0)
{
if (defined('EC_CHARSET'))
{
$charset = strtolower(str_replace('-', '', EC_CHARSET));
}
if (defined('ROOT_PATH') && !$this->root_path)
{
$this->root_path = ROOT_PATH;
}
if ($quiet)
{
$this->connect($dbhost, $dbuser, $dbpw, $dbname, $charset, $pconnect, $quiet);
}
else
{
$this->settings = array(
'dbhost' => $dbhost,
'dbuser' => $dbuser,
'dbpw' => $dbpw,
'dbname' => $dbname,
'charset' => $charset,
'pconnect' => $pconnect
);
}
}
function connect($dbhost, $dbuser, $dbpw, $dbname = '', $charset = 'utf8', $pconnect = 0, $quiet = 0)
{
if ($pconnect)
{
$this->link_id = new mysqli('p:'.$dbhost, $dbuser, $dbpw);
if ($this->link_id->connect_error)
{
if (!$quiet)
{
$this->ErrorMsg("Can't pConnect MySQL Server($dbhost)!");
}
return false;
}
}
else
{
$this->link_id = new mysqli($dbhost, $dbuser, $dbpw);
if ($this->link_id->connect_error)
{
if (!$quiet)
{
$this->ErrorMsg("Can't Connect MySQL Server($dbhost)!");
}
return false;
}
}
$this->dbhash = md5($this->root_path . $dbhost . $dbuser . $dbpw . $dbname);
$this->version = $this->link_id->server_version;
/* 對字符集進行初始化 */
$this->link_id->set_charset($charset);
$this->link_id->query("SET sql_mode=''");
$sqlcache_config_file = $this->root_path . $this->cache_data_dir . 'sqlcache_config_file_' . $this->dbhash . '.php';
@include($sqlcache_config_file);
$this->starttime = time();
if ($this->max_cache_time && $this->starttime > $this->mysql_config_cache_file_time + $this->max_cache_time)
{
if ($dbhost != '.')
{
$result = $this->link_id->query("SHOW VARIABLES LIKE 'basedir'");
$row = $result->fetch_array(MYSQLI_ASSOC);
$result->free();
if (!empty($row['Value']{1}) && $row['Value']{1} == ':' && !empty($row['Value']{2}) && $row['Value']{2} == "/")
{
$this->platform = 'WINDOWS';
}
else
{
$this->platform = 'OTHER';
}
}
else
{
$this->platform = 'WINDOWS';
}
if ($this->platform == 'OTHER' &&
($dbhost != '.' && strtolower($dbhost) != 'localhost:3306' && $dbhost != '127.0.0.1:3306') ||
date_default_timezone_get() == 'UTC')
{
$result = $this->link_id->query("SELECT UNIX_TIMESTAMP() AS timeline, UNIX_TIMESTAMP('" . date('Y-m-d H:i:s', $this->starttime) . "') AS timezone");
$row = $result->fetch_array(MYSQLI_ASSOC);
$result->free();
if ($dbhost != '.' && strtolower($dbhost) != 'localhost:3306' && $dbhost != '127.0.0.1:3306')
{
$this->timeline = $this->starttime - $row['timeline'];
}
if (date_default_timezone_get() == 'UTC')
{
$this->timezone = $this->starttime - $row['timezone'];
}
}
$content = &#39;<&#39; . "?php\r\n" .
&#39;$this->mysql_config_cache_file_time = &#39; . $this->starttime . ";\r\n" .
&#39;$this->timeline = &#39; . $this->timeline . ";\r\n" .
&#39;$this->timezone = &#39; . $this->timezone . ";\r\n" .
&#39;$this->platform = &#39; . "&#39;" . $this->platform . "&#39;;\r\n?" . &#39;>&#39;;
@file_put_contents($sqlcache_config_file, $content);
}
/* 選擇數(shù)據(jù)庫 */
if ($dbname)
{
if ($this->link_id->select_db($dbname) === false )
{
if (!$quiet)
{
$this->ErrorMsg("Can&#39;t select MySQL database($dbname)!");
}
return false;
}
else
{
return true;
}
}
else
{
return true;
}
}
function select_database($dbname)
{
return $this->link_id->select_db($dbname);
}
function set_mysql_charset($charset)
{
if (in_array(strtolower($charset), array(&#39;gbk&#39;, &#39;big5&#39;, &#39;utf-8&#39;, &#39;utf8&#39;)))
{
$charset = str_replace(&#39;-&#39;, &#39;&#39;, $charset);
}
$this->link_id->set_charset($charset);
}
function fetch_array($query, $result_type = MYSQLI_ASSOC)
{
$row = $query->fetch_array($result_type);
$query->free();
return $row;
}
function query($sql, $type = &#39;&#39;)
{
if ($this->link_id === NULL)
{
$this->connect($this->settings[&#39;dbhost&#39;], $this->settings[&#39;dbuser&#39;], $this->settings[&#39;dbpw&#39;], $this->settings[&#39;dbname&#39;], $this->settings[&#39;charset&#39;], $this->settings[&#39;pconnect&#39;]);
$this->settings = array();
}
if ($this->queryCount++ <= 99)
{
$this->queryLog[] = $sql;
}
if ($this->queryTime == &#39;&#39;)
{
if (PHP_VERSION >= &#39;5.0.0&#39;)
{
$this->queryTime = microtime(true);
}
else
{
$this->queryTime = microtime();
}
}
/* 當當前的時間大于類初始化時間的時候,自動執(zhí)行 ping 這個自動重新連接操作 */
if (time() > $this->starttime + 1)
{
$this->link_id->ping();
}
if (!($query = $this->link_id->query($sql)) && $type != &#39;SILENT&#39;)
{
$this->error_message[][&#39;message&#39;] = &#39;MySQL Query Error&#39;;
$this->error_message[][&#39;sql&#39;] = $sql;
$this->error_message[][&#39;error&#39;] = $this->link_id->error;
$this->error_message[][&#39;errno&#39;] = $this->link_id->errno;
$this->ErrorMsg();
return false;
}
if (defined(&#39;DEBUG_MODE&#39;) && (DEBUG_MODE & 8) == 8)
{
$logfilename = $this->root_path . DATA_DIR . &#39;/mysql_query_&#39; . $this->dbhash . &#39;_&#39; . date(&#39;Y_m_d&#39;) . &#39;.log&#39;;
$str = $sql . "\n\n";
if (PHP_VERSION >= &#39;5.0&#39;)
{
file_put_contents($logfilename, $str, FILE_APPEND);
}
else
{
$fp = @fopen($logfilename, &#39;ab+&#39;);
if ($fp)
{
fwrite($fp, $str);
fclose($fp);
}
}
}
return $query;
}
function affected_rows()
{
return $this->link_id->affected_rows;
}
function error()
{
return $this->link_id->error;
}
function errno()
{
return $this->link_id->errno;
}
function result($query, $row)
{
$query->data_seek($row);
$result = $query->fetch_row();
$query->free();
return $result;
}
function num_rows($query)
{
return $query->num_rows;
}
function num_fields($query)
{
return $this->link_id->field_count;
}
function free_result($query)
{
return $query->free();
}
function insert_id()
{
return $this->link_id->insert_id;
}
function fetchRow($query)
{
return $query->fetch_assoc();
}
function fetch_fields($query)
{
return $query->fetch_field();
}
function version()
{
return $this->version;
}
function ping()
{
return $this->link_id->ping();
}
function escape_string($unescaped_string)
{
return $this->link_id->real_escape_string($unescaped_string);
}
function close()
{
return $this->link_id->close();
}
function ErrorMsg($message = &#39;&#39;, $sql = &#39;&#39;)
{
if ($message)
{
echo "DTXB info: $message\n\n
";
//print(&#39;http://faq.comsenz.com/&#39;);
}
else
{
echo "MySQL server error report:";
print_r($this->error_message);
//echo "
http://faq.comsenz.com/";
}
exit;
}
/* 仿真 Adodb 函數(shù) */
function selectLimit($sql, $num, $start = 0)
{
if ($start == 0)
{
$sql .= &#39; LIMIT &#39; . $num;
}
else
{
$sql .= &#39; LIMIT &#39; . $start . &#39;, &#39; . $num;
}
return $this->query($sql);
}
function getOne($sql, $limited = false)
{
if ($limited == true)
{
$sql = trim($sql . &#39; LIMIT 1&#39;);
}
$res = $this->query($sql);
if ($res !== false)
{
$row = $res->fetch_row();
$res->free();
if ($row !== false)
{
return $row[0];
}
else
{
return &#39;&#39;;
}
}
else
{
return false;
}
}
function getOneCached($sql, $cached = &#39;FILEFIRST&#39;)
{
$sql = trim($sql . &#39; LIMIT 1&#39;);
$cachefirst = ($cached == &#39;FILEFIRST&#39; || ($cached == &#39;MYSQLFIRST&#39; && $this->platform != &#39;WINDOWS&#39;)) && $this->max_cache_time;
if (!$cachefirst)
{
return $this->getOne($sql, true);
}
else
{
$result = $this->getSqlCacheData($sql, $cached);
if (empty($result[&#39;storecache&#39;]) == true)
{
return $result[&#39;data&#39;];
}
}
$arr = $this->getOne($sql, true);
if ($arr !== false && $cachefirst)
{
$this->setSqlCacheData($result, $arr);
}
return $arr;
}
function getAll($sql)
{
$res = $this->query($sql);
if ($res !== false)
{
$arr = $res->fetch_all(MYSQLI_ASSOC);
$res->free();
return $arr;
}
else
{
return false;
}
}
function getAllCached($sql, $cached = &#39;FILEFIRST&#39;)
{
$cachefirst = ($cached == &#39;FILEFIRST&#39; || ($cached == &#39;MYSQLFIRST&#39; && $this->platform != &#39;WINDOWS&#39;)) && $this->max_cache_time;
if (!$cachefirst)
{
return $this->getAll($sql);
}
else
{
$result = $this->getSqlCacheData($sql, $cached);
if (empty($result[&#39;storecache&#39;]) == true)
{
return $result[&#39;data&#39;];
}
}
$arr = $this->getAll($sql);
if ($arr !== false && $cachefirst)
{
$this->setSqlCacheData($result, $arr);
}
return $arr;
}
function getRow($sql, $limited = false)
{
if ($limited == true)
{
$sql = trim($sql . &#39; LIMIT 1&#39;);
}
$res = $this->query($sql);
if ($res !== false)
{
$result = $res->fetch_assoc();
$res->free();
return $result;
}
else
{
return false;
}
}
function getRowCached($sql, $cached = &#39;FILEFIRST&#39;)
{
$cachefirst = ($cached == &#39;FILEFIRST&#39; || ($cached == &#39;MYSQLFIRST&#39; && $this->platform != &#39;WINDOWS&#39;)) && $this->max_cache_time;
if (!$cachefirst)
{
return $this->getRow($sql, true);
}
else
{
$result = $this->getSqlCacheData($sql, $cached);
if (empty($result[&#39;storecache&#39;]) == true)
{
return $result[&#39;data&#39;];
}
}
$arr = $this->getRow($sql, true);
if ($arr !== false && $cachefirst)
{
$this->setSqlCacheData($result, $arr);
}
return $arr;
}
function getCol($sql)
{
$res = $this->query($sql);
if ($res !== false)
{
$arr = array();
while ($row = $res->fetch_row())
{
$arr[] = $row[0];
}
$res->free();
return $arr;
}
else
{
return false;
}
}
function getColCached($sql, $cached = &#39;FILEFIRST&#39;)
{
$cachefirst = ($cached == &#39;FILEFIRST&#39; || ($cached == &#39;MYSQLFIRST&#39; && $this->platform != &#39;WINDOWS&#39;)) && $this->max_cache_time;
if (!$cachefirst)
{
return $this->getCol($sql);
}
else
{
$result = $this->getSqlCacheData($sql, $cached);
if (empty($result[&#39;storecache&#39;]) == true)
{
return $result[&#39;data&#39;];
}
}
$arr = $this->getCol($sql);
if ($arr !== false && $cachefirst)
{
$this->setSqlCacheData($result, $arr);
}
return $arr;
}
function autoExecute($table, $field_values, $mode = &#39;INSERT&#39;, $where = &#39;&#39;, $querymode = &#39;&#39;)
{
$field_names = $this->getCol(&#39;DESC &#39; . $table);
$sql = &#39;&#39;;
if ($mode == &#39;INSERT&#39;)
{
$fields = $values = array();
foreach ($field_names AS $value)
{
if (array_key_exists($value, $field_values) == true)
{
$fields[] = $value;
$values[] = "&#39;" . $field_values[$value] . "&#39;";
}
}
if (!empty($fields))
{
$sql = &#39;INSERT INTO &#39; . $table . &#39; (&#39; . implode(&#39;, &#39;, $fields) . &#39;) VALUES (&#39; . implode(&#39;, &#39;, $values) . &#39;)&#39;;
}
}
else
{
$sets = array();
foreach ($field_names AS $value)
{
if (array_key_exists($value, $field_values) == true)
{
$sets[] = $value . " = &#39;" . $field_values[$value] . "&#39;";
}
}
if (!empty($sets))
{
$sql = &#39;UPDATE &#39; . $table . &#39; SET &#39; . implode(&#39;, &#39;, $sets) . &#39; WHERE &#39; . $where;
}
}
if ($sql)
{
return $this->query($sql, $querymode);
}
else
{
return false;
}
}
function autoReplace($table, $field_values, $update_values, $where = &#39;&#39;, $querymode = &#39;&#39;)
{
$field_descs = $this->getAll(&#39;DESC &#39; . $table);
$primary_keys = array();
foreach ($field_descs AS $value)
{
$field_names[] = $value[&#39;Field&#39;];
if ($value[&#39;Key&#39;] == &#39;PRI&#39;)
{
$primary_keys[] = $value[&#39;Field&#39;];
}
}
$fields = $values = array();
foreach ($field_names AS $value)
{
if (array_key_exists($value, $field_values) == true)
{
$fields[] = $value;
$values[] = "&#39;" . $field_values[$value] . "&#39;";
}
}
$sets = array();
foreach ($update_values AS $key => $value)
{
if (array_key_exists($key, $field_values) == true)
{
if (is_int($value) || is_float($value))
{
$sets[] = $key . &#39; = &#39; . $key . &#39; + &#39; . $value;
}
else
{
$sets[] = $key . " = &#39;" . $value . "&#39;";
}
}
}
$sql = &#39;&#39;;
if (empty($primary_keys))
{
if (!empty($fields))
{
$sql = &#39;INSERT INTO &#39; . $table . &#39; (&#39; . implode(&#39;, &#39;, $fields) . &#39;) VALUES (&#39; . implode(&#39;, &#39;, $values) . &#39;)&#39;;
}
}
else
{
if ($this->version() >= &#39;4.1&#39;)
{
if (!empty($fields))
{
$sql = &#39;INSERT INTO &#39; . $table . &#39; (&#39; . implode(&#39;, &#39;, $fields) . &#39;) VALUES (&#39; . implode(&#39;, &#39;, $values) . &#39;)&#39;;
if (!empty($sets))
{
$sql .= &#39;ON DUPLICATE KEY UPDATE &#39; . implode(&#39;, &#39;, $sets);
}
}
}
else
{
if (empty($where))
{
$where = array();
foreach ($primary_keys AS $value)
{
if (is_numeric($value))
{
$where[] = $value . &#39; = &#39; . $field_values[$value];
}
else
{
$where[] = $value . " = &#39;" . $field_values[$value] . "&#39;";
}
}
$where = implode(&#39; AND &#39;, $where);
}
if ($where && (!empty($sets) || !empty($fields)))
{
if (intval($this->getOne("SELECT COUNT(*) FROM $table WHERE $where")) > 0)
{
if (!empty($sets))
{
$sql = &#39;UPDATE &#39; . $table . &#39; SET &#39; . implode(&#39;, &#39;, $sets) . &#39; WHERE &#39; . $where;
}
}
else
{
if (!empty($fields))
{
$sql = &#39;REPLACE INTO &#39; . $table . &#39; (&#39; . implode(&#39;, &#39;, $fields) . &#39;) VALUES (&#39; . implode(&#39;, &#39;, $values) . &#39;)&#39;;
}
}
}
}
}
if ($sql)
{
return $this->query($sql, $querymode);
}
else
{
return false;
}
}
function setMaxCacheTime($second)
{
$this->max_cache_time = $second;
}
function getMaxCacheTime()
{
return $this->max_cache_time;
}
function getSqlCacheData($sql, $cached = &#39;&#39;)
{
$sql = trim($sql);
$result = array();
$result[&#39;filename&#39;] = $this->root_path . $this->cache_data_dir . &#39;sqlcache_&#39; . abs(crc32($this->dbhash . $sql)) . &#39;_&#39; . md5($this->dbhash . $sql) . &#39;.php&#39;;
$data = @file_get_contents($result[&#39;filename&#39;]);
if (isset($data{23}))
{
$filetime = substr($data, 13, 10);
$data = substr($data, 23);
if (($cached == &#39;FILEFIRST&#39; && time() > $filetime + $this->max_cache_time) || ($cached == &#39;MYSQLFIRST&#39; && $this->table_lastupdate($this->get_table_name($sql)) > $filetime))
{
$result[&#39;storecache&#39;] = true;
}
else
{
$result[&#39;data&#39;] = @unserialize($data);
if ($result[&#39;data&#39;] === false)
{
$result[&#39;storecache&#39;] = true;
}
else
{
$result[&#39;storecache&#39;] = false;
}
}
}
else
{
$result[&#39;storecache&#39;] = true;
}
return $result;
}
function setSqlCacheData($result, $data)
{
if ($result[&#39;storecache&#39;] === true && $result[&#39;filename&#39;])
{
@file_put_contents($result[&#39;filename&#39;], &#39;&#39; . time() . serialize($data));
clearstatcache();
}
}
/* 獲取 SQL 語句中最后更新的表的時間,有多個表的情況下,返回最新的表的時間 */
function table_lastupdate($tables)
{
if ($this->link_id === NULL)
{
$this->connect($this->settings[&#39;dbhost&#39;], $this->settings[&#39;dbuser&#39;], $this->settings[&#39;dbpw&#39;], $this->settings[&#39;dbname&#39;], $this->settings[&#39;charset&#39;], $this->settings[&#39;pconnect&#39;]);
$this->settings = array();
}
$lastupdatetime = &#39;0000-00-00 00:00:00&#39;;
$tables = str_replace(&#39;`&#39;, &#39;&#39;, $tables);
$this->mysql_disable_cache_tables = str_replace(&#39;`&#39;, &#39;&#39;, $this->mysql_disable_cache_tables);
foreach ($tables AS $table)
{
if (in_array($table, $this->mysql_disable_cache_tables) == true)
{
$lastupdatetime = &#39;2037-12-31 23:59:59&#39;;
break;
}
if (strstr($table, &#39;.&#39;) != NULL)
{
$tmp = explode(&#39;.&#39;, $table);
$sql = &#39;SHOW TABLE STATUS FROM `&#39; . trim($tmp[0]) . "` LIKE &#39;" . trim($tmp[1]) . "&#39;";
}
else
{
$sql = "SHOW TABLE STATUS LIKE &#39;" . trim($table) . "&#39;";
}
$result = $this->link_id->query($sql);
$row = $result->fetch_assoc();
if ($row[&#39;Update_time&#39;] > $lastupdatetime)
{
$lastupdatetime = $row[&#39;Update_time&#39;];
}
}
$lastupdatetime = strtotime($lastupdatetime) - $this->timezone + $this->timeline;
return $lastupdatetime;
}
function get_table_name($query_item)
{
$query_item = trim($query_item);
$table_names = array();
/* 判斷語句中是不是含有 JOIN */
if (stristr($query_item, &#39; JOIN &#39;) == &#39;&#39;)
{
/* 解析一般的 SELECT FROM 語句 */
if (preg_match(&#39;/^SELECT.*?FROM\s*((?:`?\w+`?\s*\.\s*)?`?\w+`?(?:(?:\s*AS)?\s*`?\w+`?)?(?:\s*,\s*(?:`?\w+`?\s*\.\s*)?`?\w+`?(?:(?:\s*AS)?\s*`?\w+`?)?)*)/is&#39;, $query_item, $table_names))
{
$table_names = preg_replace(&#39;/((?:`?\w+`?\s*\.\s*)?`?\w+`?)[^,]*/&#39;, &#39;\1&#39;, $table_names[1]);
return preg_split(&#39;/\s*,\s*/&#39;, $table_names);
}
}
else
{
/* 對含有 JOIN 的語句進行解析 */
if (preg_match(&#39;/^SELECT.*?FROM\s*((?:`?\w+`?\s*\.\s*)?`?\w+`?)(?:(?:\s*AS)?\s*`?\w+`?)?.*?JOIN.*$/is&#39;, $query_item, $table_names))
{
$other_table_names = array();
preg_match_all(&#39;/JOIN\s*((?:`?\w+`?\s*\.\s*)?`?\w+`?)\s*/i&#39;, $query_item, $other_table_names);
return array_merge(array($table_names[1]), $other_table_names[1]);
}
}
return $table_names;
}
/* 設(shè)置不允許進行緩存的表 */
function set_disable_cache_tables($tables)
{
if (!is_array($tables))
{
$tables = explode(&#39;,&#39;, $tables);
}
foreach ($tables AS $table)
{
$this->mysql_disable_cache_tables[] = $table;
}
array_unique($this->mysql_disable_cache_tables);
}
/**
+----------------------------------------------------------
* 啟動事務(wù)
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @return void
+----------------------------------------------------------
*/
public function startTrans() {
//$this->initConnect(true);
if ( !$this->link_id ) return false;
//數(shù)據(jù)rollback 支持
if ($this->transTimes == 0) {
$this->link_id->autocommit(FALSE);
}
$this->transTimes++;
return ;
}
/**
+----------------------------------------------------------
* 用于非自動提交狀態(tài)下面的查詢提交
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @return boolen
+----------------------------------------------------------
*/
public function commit()
{
if ($this->transTimes > 0) {
$result = $this->link_id->commit();
$this->transTimes = 0;
if(!$result){
$this->error_message[][&#39;message&#39;] = &#39;MySQL Query Error&#39;;
$this->error_message[][&#39;sql&#39;] = $sql;
$this->error_message[][&#39;error&#39;] = $this->link_id->error;
$this->error_message[][&#39;errno&#39;] = $this->link_id->errno;
$this->ErrorMsg();
return false;
}
}
return true;
}
/**
+----------------------------------------------------------
* 事務(wù)回滾
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @return boolen
+----------------------------------------------------------
*/
public function rollback()
{
if ($this->transTimes > 0) {
$result = $this->link_id->rollback();
$this->transTimes = 0;
if(!$result){
$this->error_message[][&#39;message&#39;] = &#39;MySQL Query Error&#39;;
$this->error_message[][&#39;sql&#39;] = $sql;
$this->error_message[][&#39;error&#39;] = $this->link_id->error;
$this->error_message[][&#39;errno&#39;] = $this->link_id->errno;
$this->ErrorMsg();
return false;
}
}
return true;
}
}

代碼當中加了幾個方法,用于支持事務(wù)。

(2)更改cls_image.php的gd_version()方法,將這個方法改為靜態(tài)方法,并且所有調(diào)用此方法的地方,都改為靜態(tài)調(diào)用。

PHP5.6開始,已經(jīng)不支持不兼容的上下文調(diào)用方法,并且產(chǎn)生 E_DEPRECATED 錯誤(以前是 E_STRICT)。

更改如下:

includes/cls_images.php,(gd_version方法體添加static關(guān)鍵字)
/**
* 獲得服務(wù)器上的 GD 版本
*
* @access public
* @return int 可能的值為0,1,2
*/
static function gd_version()
{
....
}

在好幾處調(diào)用此方法的地方都改為靜態(tài)調(diào)用,比如includes/cls_images.php的好幾個方法在調(diào)用時使用類對象調(diào)用:

function make_thumb($img, $thumb_width = 0, $thumb_height = 0, $path = &#39;&#39;, $bgcolor=&#39;&#39;)
{
$gd = $this->gd_version(); //獲取 GD 版本。0 表示沒有 GD 庫,1 表示 GD 1.x,2 表示 GD 2.x
。。。
}

將其改為:

function make_thumb($img, $thumb_width = 0, $thumb_height = 0, $path = &#39;&#39;, $bgcolor=&#39;&#39;)
{
$gd = self::gd_version(); //獲取 GD 版本。0 表示沒有 GD 庫,1 表示 GD 1.x,2 表示 GD 2.x
。。。
}

還有includes/lib_base.php文件的gd_version函數(shù),改為:

function gd_version()
{
include_once(ROOT_PATH . &#39;includes/cls_image.php&#39;);
return cls_image::gd_version();
}

其他文件代碼在調(diào)用時,最好改為調(diào)用lib_base文件的gd_version的函數(shù)??梢运阉鞲?。

(3)更改includes/lib_main.php文件的get_dyna_libs函數(shù),該第一行的代碼:

function get_dyna_libs($theme, $tmp)
{
$ext = end(explode(&#39;.&#39;, $tmp));
。。。
}

更改為:

function get_dyna_libs($theme, $tmp)
{
$tmp_ext = explode(&#39;.&#39;, $tmp);
$ext = end($tmp_ext);
}

end方法的接受的參數(shù)必須是引用傳遞值,這里使用了explode方法返回值,不可以直接套用。

(4)includes/cls_template.php代碼:

preg_replace方法,自PHP5.5開始 /e修飾符已經(jīng)廢棄,所以要使用preg_replace_callback代替。此代替有多處:

fetch_str方法:

fetch_str($source)
{
。。。
return preg_replace_callback("/{([^\}\{\n]*)}/",&#39;self::select_replace&#39;, $source);
}
//新增的方法
private function select_replace($matches){
return $this->select($matches[1]);
}

select方法:

function select($tag)
{
。。。
$pregReplace = preg_replace_callback("/(\&#39;\\$[^,]+)/" , function($matches){
return stripslashes(trim($matches[1],&#39;\&#39;&#39;));
}, var_export($t, true));
。。。
}
smarty_prefilter_preCompile方法:
$source = preg_replace_callback($pattern, function($matches){
return &#39;{include file=&#39;.strtolower($matches[1]). &#39;}&#39;;
}, $source);

(5)將所有類的構(gòu)造函數(shù),都去除使用類名的構(gòu)造函數(shù),保留__construct():

涉及此改動的超多,用搜索一一找到并改動吧……這個就不列舉了。

以上是ecshop如何修改並支援PHP7的詳細內(nèi)容。更多資訊請關(guān)注PHP中文網(wǎng)其他相關(guān)文章!

本網(wǎng)站聲明
本文內(nèi)容由網(wǎng)友自願投稿,版權(quán)歸原作者所有。本站不承擔相應(yīng)的法律責任。如發(fā)現(xiàn)涉嫌抄襲或侵權(quán)的內(nèi)容,請聯(lián)絡(luò)admin@php.cn

熱AI工具

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅(qū)動的應(yīng)用程序,用於創(chuàng)建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發(fā)環(huán)境

Dreamweaver CS6

Dreamweaver CS6

視覺化網(wǎng)頁開發(fā)工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

熱門話題

Laravel 教程
1600
29
PHP教程
1502
276
ecshop文章排序方法有哪些 ecshop文章排序方法有哪些 Jun 16, 2023 am 11:30 AM

ecshop文章排序方法:1、依照發(fā)佈時間排序,可以透過修改文章的發(fā)佈時間來控製文章在列表中的排列順序;2、依照點擊量排序,可以透過安裝「文章點擊排行榜」外掛程式來實現(xiàn)該排序功能,該插件可以統(tǒng)計文章的點擊量;3、按照評論數(shù)排序,可以透過安裝「文章評論排行榜」插件來實現(xiàn)該排序功能,該插件可以統(tǒng)計文章的評論數(shù);4、按照相關(guān)度排序,可以透過安裝「搜尋排名」外掛程式來實現(xiàn)此排序功能。

ecshop是什麼架構(gòu) ecshop是什麼架構(gòu) Feb 23, 2023 am 09:32 AM

ecshop是「B2C」架構(gòu);ecshop是一款B2C獨立網(wǎng)路商店系統(tǒng),適合企業(yè)及個人快速建置個人化網(wǎng)路商店;此系統(tǒng)是基於PHP語言及MYSQL資料庫架構(gòu)開發(fā)的跨平臺開源程式。

ecshop有什麼特點 ecshop有什麼特點 Feb 13, 2023 am 09:43 AM

特點:1、開源系統(tǒng),具有靈活性、可自訂性和高拓展性;2、支援自主二次開發(fā);3、豐富的模版、插件;4、產(chǎn)業(yè)適應(yīng)能力強;5、避免被軟體商束縛; 6.更強的可靠性、穩(wěn)定性;7、移動H5框架升級,基於VUE全面換代,更加靈活開放;8、多級返傭功能,支援二維碼、海報等推廣方式,無限裂變發(fā)展分銷商;8.管理端視覺互動全面煥新,UI簡潔美觀,操作體驗升級;9、支援PHP7.2,效能提升一倍。

Ecshop商品管理進階:學習如何增加字段 Ecshop商品管理進階:學習如何增加字段 Mar 12, 2024 pm 02:06 PM

Ecshop商品管理進階:學習如何增加字段,需要具體程式碼範例在使用Ecshop進行商品管理時,經(jīng)常會遇到需要增加一些自訂欄位的情況,以滿足特定的需求。透過增加字段,可以實現(xiàn)更精確的商品管理和更好的用戶體驗。本文將介紹如何在Ecshop中增加字段,並提供具體的程式碼範例。首先,我們需要明確增加字段的需求。例如,我們需要在商品詳情頁增加一個「生產(chǎn)日期」字段,以

ecshop是什麼程序 ecshop是什麼程序 Feb 16, 2023 am 10:38 AM

ECShop是B2C獨立網(wǎng)路商店系統(tǒng),是基於PHP語言及MYSQL資料庫架構(gòu)開發(fā)的跨平臺開源程序,適合企業(yè)及個人快速建立個人化網(wǎng)路商店。 ecshop商城系統(tǒng)的特色:1.支援自主二次開發(fā);2、豐富的模版、插件;3、產(chǎn)業(yè)適應(yīng)力強;4、避免被軟體商束縛;5、更強的可靠性、穩(wěn)定性。

ecshop有什麼功能 ecshop有什麼功能 Feb 23, 2023 am 09:29 AM

ecshop的功能有:1、商品管理;2、促銷管理;3、訂單管理;4、廣告管理;5、報表統(tǒng)計;6、文章管理;7、會員管理;8、權(quán)限管理;9、系統(tǒng)設(shè)定; 10、範本管理;11、資料庫管理;12、簡訊管理等。

怎麼去掉ecshop底部版權(quán) 怎麼去掉ecshop底部版權(quán) Aug 08, 2023 pm 02:42 PM

去掉ecshop底部版權(quán)的方法:1、修改模板文件,具體位置為:themes/your_theme目錄,在該目錄下找到footer.html文件,用文本編輯器打開,找到包含版權(quán)信息的代碼段,將其刪除或註解掉。儲存檔案並關(guān)閉即可;2、使用插件,登入後臺,點擊插件管理,搜尋底部版權(quán)等相關(guān)關(guān)鍵字,選擇一個適合的插件安裝並啟用它即可;3、購買主題,在ECShop的官方網(wǎng)站購買等等。

ecshop是什麼模式 ecshop是什麼模式 Feb 22, 2023 am 09:37 AM

ecshop是B2C模式。 ECShop是B2C獨立網(wǎng)路商店系統(tǒng),適合企業(yè)及個人快速建置個人化網(wǎng)路商店。 B2C是指電子商務(wù)的一種模式,也是直接面向消費者銷售產(chǎn)品和服務(wù)商業(yè)的零售模式;B2C電子商務(wù)的付款方式是貨到付款與網(wǎng)上支付相結(jié)合,而大多數(shù)企業(yè)的配送選擇物流外包方式以節(jié)約營運成本。

See all articles