Database Err: SQLSTATE[HY000] [2002] Connection refused
- /www/wwwroot/52xuexi.icu/protected/lib/speed.php on line 465
460.
try {
461.
if (!class_exists("PDO") || !in_array("mysql", PDO::getAvailableDrivers(), true)) {
462.
err('Database Err: PDO or PDO_MYSQL doesn\'t exist!');
463.
}
464.
$GLOBALS['mysql_instances'][$db_config_key] = new PDO('mysql:dbname=' . $db_config['MYSQL_DB'] . ';host=' . $db_config['MYSQL_HOST'] . ';port=' . $db_config['MYSQL_PORT'], $db_config['MYSQL_USER'], $db_config['MYSQL_PASS'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'' . $db_config['MYSQL_CHARSET'] . '\''));
465.
466.
} catch (PDOException $e) {err('Database Err: ' . $e->getMessage());}
}
467.
return $GLOBALS['mysql_instances'][$db_config_key];
468.
}
469.
470.
private function _where($conditions) {
- /www/wwwroot/52xuexi.icu/protected/lib/speed.php on line 432
427.
428.
if ($readonly && !empty($GLOBALS['mysql']['MYSQL_SLAVE'])) {
429.
$slave_key = array_rand($GLOBALS['mysql']['MYSQL_SLAVE']);
430.
$sth = $this->dbInstance($GLOBALS['mysql']['MYSQL_SLAVE'][$slave_key], 'slave_' . $slave_key)->prepare($sql);
431.
} else {
432.
433.
$sth = $this->dbInstance($GLOBALS['mysql'], 'master')->prepare($sql);
}
434.
435.
if (is_array($params) && !empty($params)) {
436.
foreach ($params as $k => &$v) {
437.
if (is_int($v)) {
- /www/wwwroot/52xuexi.icu/protected/lib/speed.php on line 424
419.
}
420.
}
421.
return $this->page;
422.
}
423.
424.
425.
public function query($sql, $params = array()) {return $this->execute($sql, $params, true);}
public function execute($sql, $params = array(), $readonly = false) {
426.
$this->sql[] = $sql;
427.
428.
if ($readonly && !empty($GLOBALS['mysql']['MYSQL_SLAVE'])) {
429.
$slave_key = array_rand($GLOBALS['mysql']['MYSQL_SLAVE']);
- /www/wwwroot/52xuexi.icu/protected/lib/speed.php on line 326
321.
$limit = $this->pager($limit[0], $limit[1], $limit[2], $total[0]['M_COUNTER']);
322.
$limit = empty($limit) ? '' : ' LIMIT ' . $limit['offset'] . ',' . $limit['limit'];
323.
} else {
324.
$limit = !empty($limit) ? ' LIMIT ' . $limit : '';
325.
}
326.
327.
return $this->query('SELECT ' . $fields . $sql . $sort . $limit, $conditions["_bindParams"]);
}
328.
329.
public function find($conditions = array(), $sort = null, $fields = '*') {
330.
$res = $this->findAll($conditions, $sort, $fields, 1);
331.
return !empty($res) ? array_pop($res) : false;
- /www/wwwroot/52xuexi.icu/protected/controller/BaseController.php on line 5
1.
<?php
2.
class BaseController extends Controller{
3.
function conf(){
4.
$Config = new Config();
5.
6.
$Config = $Config->findAll();//获取系统配置
$this->conf = array();
7.
foreach($Config as $crow){
8.
//print_r($v);
9.
$this->conf[ $crow['k'] ] = $crow['v'];
10.
}
- /www/wwwroot/52xuexi.icu/protected/controller/MainController.php on line 4
1.
<?php
2.
class MainController extends BaseController {
3.
function actionIndex(){
4.
5.
$this->conf();
$template = $this->conf['template']?$this->conf['template']:'default';
6.
$filename = TEMPLATE_ROOT.$template.'/index.html';
7.
if(file_exists($filename)){
8.
$this->assets = TEMPLATE_ROOT.$template.'/assets/';
9.
$template_index = $template.'/index.html';
- /www/wwwroot/52xuexi.icu/protected/lib/speed.php on line 149
144.
if (!method_exists($controller_name, $action_name)) {
145.
_err_router("Err: Method '$action_name' of '$controller_name' is not exists!");
146.
}
147.
148.
$controller_obj = new $controller_name();
149.
150.
$controller_obj->$action_name();
151.
if ($controller_obj->_auto_display) {
152.
$auto_tpl_name = (empty($__module) ? '' : $__module . DS) . $__controller . '_' . $__action . '.html';
153.
if (file_exists(APP_DIR . DS . 'protected' . DS . 'view' . DS . $auto_tpl_name)) {
154.
$controller_obj->display($auto_tpl_name);
- /www/wwwroot/52xuexi.icu/index.php on line 41
36.
}
37.
38.
define('APP_DIR', realpath('./'));
39.
require(APP_DIR.'/protected/Version.php');
40.
require(APP_DIR.'/protected/lib/Common.php');
41.
42.
require(APP_DIR.'/protected/lib/speed.php');
43.
if($_GET['runcron']){
44.
//云端防止监控自动停止
45.
$ch = curl_init();curl_setopt($ch, CURLOPT_URL, ((int)$_SERVER['SERVER_PORT'] == 80 ? 'http://'.$_SERVER['HTTP_HOST'] : 'https://'.$_SERVER['HTTP_HOST']).'/Crontab/Tim/Run?r='.time());curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);curl_setopt($ch, CURLOPT_TIMEOUT, 1);curl_exec($ch);curl_close($ch);
46.
exit('站点正常哦');