From 84d66979a4dc9d10cec8fab9f56d06e8c85a0f45 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 7 Jul 2016 15:09:38 -0700 Subject: [PATCH] Issue #1768 Partial fix for running on non-standard MySQL port. Added $mySQLport = 3306; to e107_config.php and modify as required. --- class2.php | 2 +- e107_handlers/mysql_class.php | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/class2.php b/class2.php index 21d3ec376..cf380eb03 100644 --- a/class2.php +++ b/class2.php @@ -226,7 +226,7 @@ e107_require_once($tmp.'/e107_class.php'); unset($tmp); $e107_paths = compact('ADMIN_DIRECTORY', 'FILES_DIRECTORY', 'IMAGES_DIRECTORY', 'THEMES_DIRECTORY', 'PLUGINS_DIRECTORY', 'HANDLERS_DIRECTORY', 'LANGUAGES_DIRECTORY', 'HELP_DIRECTORY', 'DOWNLOADS_DIRECTORY','UPLOADS_DIRECTORY','SYSTEM_DIRECTORY', 'MEDIA_DIRECTORY','CACHE_DIRECTORY','LOGS_DIRECTORY', 'CORE_DIRECTORY', 'WEB_DIRECTORY'); -$sql_info = compact('mySQLserver', 'mySQLuser', 'mySQLpassword', 'mySQLdefaultdb', 'mySQLprefix'); +$sql_info = compact('mySQLserver', 'mySQLuser', 'mySQLpassword', 'mySQLdefaultdb', 'mySQLprefix', 'mySQLport'); $e107 = e107::getInstance()->initCore($e107_paths, realpath(dirname(__FILE__)), $sql_info, varset($E107_CONFIG, array())); e107::getSingleton('eIPHandler'); // This auto-handles bans etc diff --git a/e107_handlers/mysql_class.php b/e107_handlers/mysql_class.php index 67ed5e5c8..0636e700a 100644 --- a/e107_handlers/mysql_class.php +++ b/e107_handlers/mysql_class.php @@ -69,9 +69,10 @@ class e_db_mysql { // TODO switch to protected vars where needed public $mySQLserver; - public $mySQLuser; + public $mySQLuser; protected $mySQLpassword; protected $mySQLdefaultdb; + protected $mySQLport = 3306; public $mySQLPrefix; protected $mySQLaccess; public $mySQLresult; @@ -83,7 +84,7 @@ class e_db_mysql protected $mySQLlastQuery = ''; public $mySQLcurTable; - public $mySQLlanguage; + public $mySQLlanguage; public $mySQLinfo; public $tabset; public $mySQLtableList = array(); // list of all Db tables. @@ -99,6 +100,7 @@ class e_db_mysql private $pdo = false; // using PDO or not. + /** * Constructor - gets language options from the cookie or session * @access public @@ -113,11 +115,16 @@ class e_db_mysql { $this->pdo = true; } - + e107::getSingleton('e107_traffic')->BumpWho('Create db object', 1); $this->mySQLPrefix = MPREFIX; // Set the default prefix - may be overridden + if($port = e107::getMySQLConfig('port')) + { + $this->mySQLport = intval($port); + } + /*$langid = (isset($pref['cookie_name'])) ? 'e107language_'.$pref['cookie_name'] : 'e107language_temp'; if (isset($pref['user_tracking']) && ($pref['user_tracking'] == 'session')) { @@ -182,7 +189,7 @@ class e_db_mysql { try { - $this->mySQLaccess = new PDO("mysql:host=".$this->mySQLserver."; port=3306", $this->mySQLuser, $this->mySQLpassword, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); + $this->mySQLaccess = new PDO("mysql:host=".$this->mySQLserver."; port=".$this->mySQLport, $this->mySQLuser, $this->mySQLpassword, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); } catch(PDOException $ex) @@ -271,7 +278,7 @@ class e_db_mysql { try { - $this->mySQLaccess = new PDO("mysql:host=".$this->mySQLserver."; port=3306", $this->mySQLuser, $this->mySQLpassword, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); + $this->mySQLaccess = new PDO("mysql:host=".$this->mySQLserver."; port=".$this->mySQLport, $this->mySQLuser, $this->mySQLpassword, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); } catch(PDOException $ex) {