Ecshop This system, so far did not see how to launch a new version, if it is a new project, not very recommended to use it. However, since I have always been in use, I have to change it to adapt to the new version of PHP. Now that PHP 7 is out of the distribution, change to continue using it. Specific changes have the following aspects:
(1) Replace the use of MySQL extensions, using mysqli or PDO instead:
Starting with php5.5, MySQL extensions will be discarded.
The specific change of the file is includes/cls_mysql.php. This is not a small project, the file code is too long ...
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;
Maximum cache time, in seconds 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;
Transaction instruction number protected $transTimes = 0;
var $mysql _config_cache_file_time = 0; var $mysql _disable_cache_tables = Array (); Tables not allowed to be cached, encountered will not be cached function __construct ($dbhost, $dbuser, $DBPW, $dbname = ', $charset = ' GBK ', $pconnect = 0, $qui
ET = 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 de
Fined (' 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, ' chars
Et ' => $charset, ' pconnect ' => $pconnect); The 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 Pconne
CT 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 Connec
T MySQL Server ($dbhost)! ");}
return false;
}} $this->dbhash = MD5 ($this->root_path. $dbhost. $dbuser. $dbpw. $dbname);
$this->version = $this->link_id->server_version;
/* Initialize the character set * * * $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 [']{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 Ti Meline, 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 [' t
Imezone ']; }} $content = ' < '.
"? php\r\n". ' $this->mysql_config_cache_file_time = '. $this->starttime.
"; \ r \ n". ' $this->timeline = '. $this->timeline.
"; \ r \ n". ' $this->timezone = '. $this->timezone.
"; \ r \ n". ' $this->platform = '. "'" . $this->platform. "'; \ r \ n?".
' > ';
@file_put_contents ($sqlcache _config_file, $content);
/* Select database */if ($dbname) {if ($this->link_id->select_db ($dbname) = = False) {
if (! $quiet) {$this->errormsg ("Can ' 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 (' GBK ', ' Big5 ', ' utf-8 ', ' UTF8 ')
) {$charset = Str_replace ('-', ', ', $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 = ') {if ($this->link_id = = NULL) {$this->connect ($this->sett ings[' Dbhost ', $this->settings[' Dbuser '], $this->settings[' DBPW '], $this->settings[' dbname '), $this->
Settings[' CharSet '], $this->settings[' pconnect ']);
$this->settings = Array (); } if ($this->querycount++ <=) {$this->queRylog[] = $sql; } if ($this->querytime = = ") {if (php_version >= ' 5.0.0 ') {$this->querytime = MICR
Otime (TRUE);
else {$this->querytime = Microtime (); }/* Automatically ping this automatic reconnection operation if the current time is greater than the class initialization time * * (Time () > $this->starttime + 1) {$this-&
Gt;link_id->ping (); } if (! ( $query = $this->link_id->query ($sql)) && $type!= ' silent ') {$this->error_message[][' message ']
= ' MySQL Query Error ';
$this->error_message[][' sql '] = $sql;
$this->error_message[][' ERROR '] = $this->link_id->error;
$this->error_message[][' errno '] = $this->link_id->errno;
$this->errormsg ();
return false; } if (defined (' Debug_mode ') && (Debug_mode & 8) = = 8) {$logfilename = $this->root_path. Data_dir. '/mysql_query_ '. $this->dbhash. '_' . Date (' Y_m_d ').
'. log '; $str = $sql.
"\ n";
if (php_version >= ' 5.0 ') {file_put_contents ($logfilename, $str, file_append);
else {$fp = @fopen ($logfilename, ' ab+ ');
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 = ', $sql = ') {if ($message) {echo <b>dtxb info</b>: $me
Ssage\n\n<br/><br/> "; Print (' <a href= "http://faq.comsenz.com/?type=mysql&dberrno=2003&dberror=Can%27t%20connect%20to%
20mysql%20server%20on "target=" _blank ">http://faq.comsenz.com/</a>");
else {echo "<b>mysql server error:";
Print_r ($this->error_message); echo "<br/><br/><a href= ' http://faq.comsenz.com/?type=mYsql&dberrno= ". $this->error_message[3][' errno ']. "&dberror=". UrlEncode ($this->error_message[2][' error ').
"' target= ' _blank ' >http://faq.comsenz.com/</a>";
} exit; //* Simulation Adodb function * * SELECTLIMIT ($sql, $num, $start = 0) {if ($start = = 0) {$sql. = ' LIMIT ' .
$num; else {$sql. = ' LIMIT '. $start. ', ' .
$num;
return $this->query ($sql); The function GetOne ($sql, $limited = False) {if ($limited = = true) {$sql = Trim ($sql.
' LIMIT 1 ');
$res = $this->query ($sql);
if ($res!== false) {$row = $res->fetch_row ();
$res->free ();
if ($row!== false) {return $row [0];
else {return ';
} else {return false; The function getonecached ($sql, $cached = ' Filefirst ') {$sql = Trim ($sql.
' LIMIT 1 '); $cachefirst = ($cached = = ' Filefirst ' | | ($cached = = ' Mysqlfirst ' && $this->platform!= ' WINDOWS ') && $this->max_cache_time;
if (! $cachefirst) {return $this->getone ($sql, true);
else {$result = $this->getsqlcachedata ($sql, $cached);
if (Empty ($result [' storecache ']) = = True) {return $result [' data '];
} $arr = $this->getone ($sql, true);
if ($arr!== false && $cachefirst) {$this->setsqlcachedata ($result, $arr);
return $arr;
The function GetAll ($sql) {$res = $this->query ($sql);
if ($res!== false) {$arr = $res->fetch_all (MYSQLI_ASSOC);
$res->free ();
return $arr;
else {return false; The function getallcached ($sql, $cached = ' Filefirst ') {$cachefirst = ($cached = = ' Filefirst ' | | ($cached = = ' Mysqlfirst ' && $this->platform!= ' WINDOWS '))
&& $this->max_cache_time;
if (! $cachefirst) { return $this->getall ($sql); else {$result = $this->getsqlcachedata
The above is a small series for everyone to bring ecshop adaptation in the PHP7 modification method to solve the error of the implementation of the full content, I hope that we support cloud-Habitat Community ~