一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

DEDECMS|帝國CMS|Discuz|PHPCMS|Wordpress|ZBLOG|ECSHOP|蘋果CMS|極致CMS|CMS系統(tǒng)|

服務(wù)器之家 - 建站程序 - ECSHOP - ecshop適應(yīng)在PHP7的修改方法解決報(bào)錯(cuò)的實(shí)現(xiàn)

ecshop適應(yīng)在PHP7的修改方法解決報(bào)錯(cuò)的實(shí)現(xiàn)

2021-03-17 16:37ECSHOP教程網(wǎng) ECSHOP

下面小編就為大家?guī)硪黄猠cshop適應(yīng)在PHP7的修改方法解決報(bào)錯(cuò)的實(shí)現(xiàn)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧

ecshop這個(gè)系統(tǒng),到目前也沒見怎么推出新版本,如果是新項(xiàng)目,不太建議使用它。不過,因?yàn)槲乙恢币詠矶荚谑褂弥校圆坏貌桓淖屍溥m應(yīng)PHP新版本。現(xiàn)在PHP 7已經(jīng)出發(fā)行版了,所以更改來繼續(xù)使用吧。具體的更改有以下方面:

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

從php5.5開始,mysql擴(kuò)展將廢棄了。

具體更改的文件在于includes/cls_mysql.php。這是個(gè)不小的工程,文件代碼太長……

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
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; // 最大的緩存時(shí)間,以秒為單位
 
  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(); // 不允許被緩存的表,遇到將不會(huì)進(jìn)行緩存
 
  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;
 
    /* 對(duì)字符集進(jìn)行初始化 */
    $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 = '<' . "?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);
    }
 
    /* 選擇數(shù)據(jù)庫 */
    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->settings['dbhost'], $this->settings['dbuser'], $this->settings['dbpw'], $this->settings['dbname'], $this->settings['charset'], $this->settings['pconnect']);
      $this->settings = array();
    }
 
    if ($this->queryCount++ <= 99)
    {
      $this->queryLog[] = $sql;
    }
    if ($this->queryTime == '')
    {
      if (PHP_VERSION >= '5.0.0')
      {
        $this->queryTime = microtime(true);
      }
      else
      {
        $this->queryTime = microtime();
      }
    }
 
    /* 當(dāng)當(dāng)前的時(shí)間大于類初始化時(shí)間的時(shí)候,自動(dòng)執(zhí)行 ping 這個(gè)自動(dòng)重新連接操作 */
    if (time() > $this->starttime + 1)
    {
      $this->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\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>: $message\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 report:";
      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;
  }
 
/* 仿真 Adodb 函數(shù) */
  function selectLimit($sql, $num, $start = 0)
  {
    if ($start == 0)
    {
      $sql .= ' LIMIT ' . $num;
    }
    else
    {
      $sql .= ' LIMIT ' . $start . ', ' . $num;
    }
 
    return $this->query($sql);
  }
 
  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;
    }
  }
 
  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;
  }
 
  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 = 'FILEFIRST')
  {
    $cachefirst = ($cached == 'FILEFIRST' || ($cached == 'MYSQLFIRST' && $this->platform != 'WINDOWS')) && $this->max_cache_time;
    if (!$cachefirst)
    {
      return $this->getAll($sql);
    }
    else
    {
      $result = $this->getSqlCacheData

以上就是小編為大家?guī)淼膃cshop適應(yīng)在PHP7的修改方法解決報(bào)錯(cuò)的實(shí)現(xiàn)全部內(nèi)容了,希望大家多多支持服務(wù)器之家~

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 91制片厂制作果冻传媒破解 | 欧美一级片在线看 | 国产精品麻豆免费版 | 日本xxxx18vr69 | 轻轻色在线视频中文字幕 | tiny4k欧美极品在线 | 青草视频网址 | 日韩在线观看免费 | 国产在视频线在精品 | 乳女教师欲乱动漫无修版动画3d | 国产精品aaa | 五月婷婷在线免费观看 | 国产午夜精品久久理论片小说 | 美女张开腿让男人桶的 视频 | 99久精品| 91av导航| 人体欣赏孕妇季玥图片 | 美女和男生搞基 | 国产成人亚洲精品91专区手机 | 日朝欧美亚洲精品 | 粗了大了 整进去好爽视频 刺激一区仑乱 | 青春草视频免费观看 | 好大好深好舒服 | 天天爱天天做天天爽天天躁 | 涩涩屋视频在线观看 | 免费观看美景之屋 | 色播导航 | 狠狠色婷婷狠狠狠亚洲综合 | 国产午夜精品福利久久 | 日本在线一区 | 99精品视频免费在线观看 | 国产欧美一区二区三区免费 | 日本一区二区三区国产 | 欧美精品一区二区三区免费播放 | 久久久久久久久人体 | 免费又爽又黄禁片视频在线播放 | 特黄特色一级aa毛片免费观看 | 美女逼逼软件 | 精品亚洲视频在线 | 久久热这里只有 精品 | 久久婷婷五月综合色丁香花 |