77范文网 - 专业文章范例文档资料分享平台

ecshop适应PHP7的修改

来源:网络收集 时间:2018-11-25 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

ecshop适应PHP7的修改

说实话,ecshop这个系统,到目前也没见怎么推出新版本,如果是新项目,不太建议使用它。不过,因为我一直以来都在使用中,所以不得不更改让其适应PHP新版本。现在PHP 7已经出发行版了,所以更改来继续使用吧。具体的更改有以下方面:

1、将mysql扩展的使用替换掉,改为使用mysqli或pdo:

从php5.5开始,mysql扩展将废弃了。

具体更改的文件在于includes/cls_mysql.php。这是个不小的工程,文件代码太长……

if(!defined('DITAN_ECS')) {

die('Hacking attempt'); }

classcls_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; // 事务指令数

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); }

functioncls_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 ); } }

functionconnect($dbhost, $dbuser, $dbpw, $dbname = '', $charset = 'utf8', $pconnect = 0, $quiet = 0) { if ($pconnect) {

$this->link_id = newmysqli('p:'.$dbhost, $dbuser, $dbpw); if ($this->link_id->connect_error) { if(!$quiet)

{

$this->ErrorMsg(\$dbhost)!\ }

returnfalse; } } else {

$this->link_id = newmysqli($dbhost, $dbuser, $dbpw);

if ($this->link_id->connect_error) { if(!$quiet)

{

$this->ErrorMsg(\$dbhost)!\ }

returnfalse; } }

$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(\

$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(\$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(\date('Y-m-d H:i:s', $this->starttime) . \$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 = '<' .\

'$this->mysql_config_cache_file_time = ' .$this->starttime .\ '$this->timeline = ' .$this->timeline .\ '$this->timezone = ' .$this->timezone .\ '$this->platform = ' . \$this->platform . \

@file_put_contents($sqlcache_config_file, $content); }

/* 选择数据库 */

if ($dbname) {

if ($this->link_id->select_db($dbname) === false ) { if(!$quiet)

{

$this->ErrorMsg(\$dbname)!\ }

returnfalse; } else

{ returntrue; } } else { returntrue; } }

functionselect_database($dbname) {

return$this->link_id->select_db($dbname); }

functionset_mysql_charset($charset) {

if (in_array(strtolower($charset), array('gbk', 'big5', 'utf-8', 'utf8'))) {

$charset = str_replace('-', '', $charset); }

$this->link_id->set_charset($charset); }

functionfetch_array($query, $result_type = MYSQLI_ASSOC) {

$row = $query->fetch_array($result_type); $query->free(); return$row; }

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库ecshop适应PHP7的修改在线全文阅读。

ecshop适应PHP7的修改.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/309530.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: