1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-17 13:01:14 +02:00

Issue #1349 MySQL class fixes and install.php corrections.

This commit is contained in:
Cameron
2016-02-11 20:57:30 -08:00
parent 9fe58ba256
commit ad0bc1376d
6 changed files with 184 additions and 88 deletions

View File

@@ -1057,7 +1057,7 @@ class admin_shortcodes
<br /><br /> <br /><br />
<b>".FOOTLAN_12."</b> <b>".FOOTLAN_12."</b>
<br /> <br />
".e107::getDB()->mySqlServerInfo. ".e107::getDB()->getServerInfo(). // mySqlServerInfo.
"<br /> "<br />
".FOOTLAN_16.": ".$mySQLdefaultdb." ".FOOTLAN_16.": ".$mySQLdefaultdb."
<br /><br /> <br /><br />

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<e107Export version="0.8.0 (cvs)" timestamp="1251856226"> <e107Export version="2.0" timestamp="1251856226">
<prefs> <prefs>
<core name="admin_alerts_ok">1</core> <core name="admin_alerts_ok">1</core>
<core name="admin_alerts_uniquemenu">0</core> <core name="admin_alerts_uniquemenu">0</core>

View File

@@ -68,10 +68,10 @@ class e_db_mysql
// TODO switch to protected vars where needed // TODO switch to protected vars where needed
public $mySQLserver; public $mySQLserver;
public $mySQLuser; public $mySQLuser;
public $mySQLpassword; protected $mySQLpassword;
public $mySQLdefaultdb; protected $mySQLdefaultdb;
public $mySQLPrefix; public $mySQLPrefix;
public $mySQLaccess; protected $mySQLaccess;
public $mySQLresult; public $mySQLresult;
public $mySQLrows; public $mySQLrows;
public $mySQLerror = ''; // Error reporting mode - TRUE shows messages public $mySQLerror = ''; // Error reporting mode - TRUE shows messages
@@ -135,8 +135,19 @@ class e_db_mysql
if(defined('e_LANGUAGE')) $this->mySQLlanguage = e107::getLanguage()->e_language; if(defined('e_LANGUAGE')) $this->mySQLlanguage = e107::getLanguage()->e_language;
} }
function getPDO()
{
return $this->pdo;
}
function getMode()
{
$this->gen('SELECT @@sql_mode');
$row = $this->fetch();
return $row['@@sql_mode'];
}
/** /**
* Connects to mySQL server and selects database - generally not required if your table is in the main DB.<br /> * Connects to mySQL server and selects database - generally not required if your table is in the main DB.<br />
* <br /> * <br />
@@ -166,16 +177,14 @@ class e_db_mysql
$this->mySQLpassword = $mySQLpassword; $this->mySQLpassword = $mySQLpassword;
$this->mySQLdefaultdb = $mySQLdefaultdb; $this->mySQLdefaultdb = $mySQLdefaultdb;
$this->mySQLPrefix = $mySQLPrefix; $this->mySQLPrefix = $mySQLPrefix;
$this->mySQLerror = false;
$temp = $this->mySQLerror;
$this->mySQLerror = FALSE;
if($this->pdo) if($this->pdo)
{ {
try try
{ {
$this->mySQLaccess = new PDO("mysql:host=".$this->mySQLserver, $this->mySQLuser, $this->mySQLpassword, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); $this->mySQLaccess = new PDO("mysql:host=".$this->mySQLserver."; port=3307", $this->mySQLuser, $this->mySQLpassword, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
} }
catch(PDOException $ex) catch(PDOException $ex)
{ {
@@ -203,7 +212,7 @@ class e_db_mysql
} }
} }
$this->mySqlServerInfo = ($this->pdo) ? $this->mySQLaccess->getAttribute(PDO::ATTR_SERVER_INFO) : mysql_get_server_info(); // We always need this for db_Set_Charset() - so make generally available $this->mySqlServerInfo = ($this->pdo) ? $this->mySQLaccess->query('select version()')->fetchColumn() : mysql_get_server_info(); // We always need this for db_Set_Charset() - so make generally available
// Set utf8 connection? // Set utf8 connection?
//@TODO: simplify when yet undiscovered side-effects will be fixed //@TODO: simplify when yet undiscovered side-effects will be fixed
@@ -219,9 +228,12 @@ class e_db_mysql
$this->dbError('dbConnect/SelectDB'); $this->dbError('dbConnect/SelectDB');
// Save the connection resource // Save the connection resource
if ($db_ConnectionID == NULL) if ($db_ConnectionID == null)
{
$db_ConnectionID = $this->mySQLaccess; $db_ConnectionID = $this->mySQLaccess;
return TRUE; }
return true;
} }
@@ -254,16 +266,17 @@ class e_db_mysql
{ {
try try
{ {
$this->mySQLaccess = new PDO("mysql:host=".$this->mySQLserver, $this->mySQLuser, $this->mySQLpassword, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); $this->mySQLaccess = new PDO("mysql:host=".$this->mySQLserver."; port=3307", $this->mySQLuser, $this->mySQLpassword, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
} }
catch(PDOException $ex) catch(PDOException $ex)
{ {
$this->mySQLlastErrText = $ex->getMessage(); $this->mySQLlastErrText = $ex->getMessage();
// echo "<pre>".print_r($ex,true)."</pre>"; // Useful for Debug. echo "<pre>".print_r($ex,true)."</pre>"; // Useful for Debug.
return false; return false;
} }
$this->mySqlServerInfo = $this->mySQLaccess->getAttribute(PDO::ATTR_SERVER_INFO); // $this->mySqlServerInfo = $this->mySQLaccess->getAttribute(PDO::ATTR_SERVER_INFO);
$this->mySqlServerInfo = $this->mySQLaccess->query('select version()')->fetchColumn();
} }
else // Legacy. else // Legacy.
@@ -285,6 +298,16 @@ class e_db_mysql
} }
/**
* Get Server Info
* @return mixed
*/
public function getServerInfo()
{
return $this->mySqlServerInfo;
}
/** /**
* Select the database to use. * Select the database to use.
@@ -349,13 +372,15 @@ class e_db_mysql
/** /**
* @deprecated
* @return void * @return void
* @desc Enter description here... * @desc Enter description here...
* @access private * @access private
*/ */
function db_Show_Performance() function db_Show_Performance()
{ {
return $db_debug->Show_Performance(); // e107::getDebug()-Show_P
// return $db_debug->Show_Performance();
} }
@@ -423,7 +448,15 @@ class e_db_mysql
// print_a($prep); // print_a($prep);
// echo "<hr>"; // echo "<hr>";
// $sQryRes = $prep->execute($query); // $sQryRes = $prep->execute($query);
$sQryRes = $this->mySQLaccess->query($query); try
{
$sQryRes = is_null($rli) ? $this->mySQLaccess->query($query) : $rli->query($query);
}
catch(PDOException $ex)
{
// $sQryRes = null;
}
} }
else else
{ {
@@ -437,6 +470,7 @@ class e_db_mysql
$db_time += $mytime; $db_time += $mytime;
$this->mySQLresult = $sQryRes; $this->mySQLresult = $sQryRes;
$this->total_results = false; $this->total_results = false;
// Need to get the total record count as well. Return code is a resource identifier // Need to get the total record count as well. Return code is a resource identifier
@@ -449,7 +483,7 @@ class e_db_mysql
$rc = $fr->fetchColumn(); $rc = $fr->fetchColumn();
$this->total_results = (int) $rc; $this->total_results = (int) $rc;
} }
else else /* @XXX Subject of Removal. */
{ {
$fr = mysql_query('SELECT FOUND_ROWS()', $this->mySQLaccess); $fr = mysql_query('SELECT FOUND_ROWS()', $this->mySQLaccess);
$rc = mysql_fetch_array($fr); $rc = mysql_fetch_array($fr);
@@ -461,6 +495,7 @@ class e_db_mysql
if (E107_DEBUG_LEVEL) if (E107_DEBUG_LEVEL)
{ {
global $db_debug; global $db_debug;
$aTrace = debug_backtrace(); $aTrace = debug_backtrace();
$pTable = $this->mySQLcurTable; $pTable = $this->mySQLcurTable;
@@ -1102,9 +1137,8 @@ class e_db_mysql
/** /**
* @return array MySQL row * @return array MySQL row
* @param string $mode
* @desc Fetch an array containing row data (see PHP's mysql_fetch_array() docs)<br /> * @desc Fetch an array containing row data (see PHP's mysql_fetch_array() docs)<br />
* <br /> * @example
* Example :<br /> * Example :<br />
* <code>while($row = $sql->fetch()){ * <code>while($row = $sql->fetch()){
* $text .= $row['username']; * $text .= $row['username'];
@@ -1123,15 +1157,15 @@ class e_db_mysql
{ {
switch ($type) switch ($type)
{ {
case MYSQL_BOTH: case MYSQL_BOTH: // 3
$type = PDO::FETCH_BOTH; $type = PDO::FETCH_BOTH;
break; break;
case MYSQL_NUM: case MYSQL_NUM: // 2
$type = PDO::FETCH_NUM; $type = PDO::FETCH_NUM;
break; break;
case MYSQL_ASSOC: case MYSQL_ASSOC: // 1
default: default:
$type = PDO::FETCH_ASSOC; $type = PDO::FETCH_ASSOC;
break; break;
@@ -2220,6 +2254,29 @@ class e_db_mysql
*/ */
function dbError($from) function dbError($from)
{ {
// $this->mySQLaccess->getMessage();
if($this->pdo)
{
// $this->mySQLlastErrNum =;
$this->mySQLerror = true;
if(is_object($this->mySQLaccess))
{
$errInfo= $this->mySQLaccess->errorInfo();
$this->mySQLlastErrNum = $errInfo[1];
$this->mySQLlastErrText = $errInfo[2]; // $ex->getMessage();
}
if($this->mySQLlastErrNum == 0)
{
return null;
}
return $this->mySQLlastErrText;
}
$this->mySQLlastErrNum = mysql_errno(); $this->mySQLlastErrNum = mysql_errno();
$this->mySQLlastErrText = ''; $this->mySQLlastErrText = '';
if ($this->mySQLlastErrNum == 0) if ($this->mySQLlastErrNum == 0)
@@ -2262,7 +2319,6 @@ class e_db_mysql
* Check if MySQL version is utf8 compatible and may be used as it accordingly to the user choice * Check if MySQL version is utf8 compatible and may be used as it accordingly to the user choice
* *
* @TODO Simplify when the conversion script will be available * @TODO Simplify when the conversion script will be available
*
* @access public * @access public
* @param string MySQL charset may be forced in special circumstances * @param string MySQL charset may be forced in special circumstances
* UTF-8 encoding and decoding is left to the progammer * UTF-8 encoding and decoding is left to the progammer
@@ -2328,7 +2384,6 @@ class e_db_mysql
* fields which are 'NOT NULL' but have no default are added to the '_NOTNULL' list * fields which are 'NOT NULL' but have no default are added to the '_NOTNULL' list
*</code> *</code>
* @param string $tableName - table name, without any prefixes (language or general) * @param string $tableName - table name, without any prefixes (language or general)
*
* @return boolean|array - FALSE if not found/not to be used. Array of field names and processing types and null overrides if found * @return boolean|array - FALSE if not found/not to be used. Array of field names and processing types and null overrides if found
*/ */
public function getFieldDefs($tableName) public function getFieldDefs($tableName)
@@ -2375,15 +2430,12 @@ class e_db_mysql
} }
/* /**
* Search the specified file for a field type definition of the specified table. * Search the specified file for a field type definition of the specified table.
*
* If found, generate and save a cache file in the e_CACHE_DB directory, * If found, generate and save a cache file in the e_CACHE_DB directory,
* Always also update $this->dbFieldDefs[$tableName] - FALSE if not found, data if found * Always also update $this->dbFieldDefs[$tableName] - FALSE if not found, data if found
*
* @param string $defFile - file name, including path * @param string $defFile - file name, including path
* @param string $tableName - name of table sought * @param string $tableName - name of table sought
*
* @return boolean TRUE on success, FALSE on not found (some errors intentionally ignored) * @return boolean TRUE on success, FALSE on not found (some errors intentionally ignored)
*/ */
protected function loadTableDef($defFile, $tableName) protected function loadTableDef($defFile, $tableName)
@@ -2424,12 +2476,9 @@ class e_db_mysql
/** /**
* Creates a field type definition from the structure of the table in the DB * Creates a field type definition from the structure of the table in the DB
*
* Generate and save a cache file in the e_CACHE_DB directory, * Generate and save a cache file in the e_CACHE_DB directory,
* Also update $this->dbFieldDefs[$tableName] - FALSE if error, data if found * Also update $this->dbFieldDefs[$tableName] - FALSE if error, data if found
*
* @param string $tableName - name of table sought * @param string $tableName - name of table sought
*
* @return boolean TRUE on success, FALSE on not found (some errors intentionally ignored) * @return boolean TRUE on success, FALSE on not found (some errors intentionally ignored)
*/ */
protected function makeTableDef($tableName) protected function makeTableDef($tableName)

View File

@@ -457,7 +457,7 @@ class e_session
if (empty($this->_options['domain'])) if (empty($this->_options['domain']))
{ {
// MULTILANG_SUBDOMAIN set during initial language detection in language handler // MULTILANG_SUBDOMAIN set during initial language detection in language handler
$doma = ((!e_SUBDOMAIN || deftrue('MULTILANG_SUBDOMAIN')) && e_DOMAIN != FALSE) ? ".".e_DOMAIN : FALSE; // from v1.x $doma = ((deftrue('e_SUBDOMAIN') || deftrue('MULTILANG_SUBDOMAIN')) && e_DOMAIN != FALSE) ? ".".e_DOMAIN : FALSE; // from v1.x
$this->_options['domain'] = $doma; $this->_options['domain'] = $doma;
} }

View File

@@ -67,7 +67,11 @@ class themeHandler
//enable inner tabindex counter //enable inner tabindex counter
if(!deftrue("E107_INSTALL"))
{
$this->frm = new e_form(); $this->frm = new e_form();
}
$this->fl = e107::getFile(); $this->fl = e107::getFile();

View File

@@ -21,6 +21,7 @@ define('MAKE_INSTALL_LOG', false);
/* Default Options and Paths for Installer */ /* Default Options and Paths for Installer */
$MySQLprefix = 'e107_'; $MySQLprefix = 'e107_';
$HANDLERS_DIRECTORY = "e107_handlers/"; // needed for e107 class init $HANDLERS_DIRECTORY = "e107_handlers/"; // needed for e107 class init
header('Content-type: text/html; charset=utf-8');
define("e107_INIT", TRUE); define("e107_INIT", TRUE);
require_once("e107_admin/ver.php"); require_once("e107_admin/ver.php");
@@ -35,7 +36,7 @@ define("e_UC_MEMBER", 253);
define("e_UC_ADMIN", 254); define("e_UC_ADMIN", 254);
define("e_UC_NOBODY", 255);*/ define("e_UC_NOBODY", 255);*/
define("E107_INSTALL",TRUE); define("E107_INSTALL",true);
if($_SERVER['QUERY_STRING'] != "debug") if($_SERVER['QUERY_STRING'] != "debug")
{ {
@@ -46,6 +47,11 @@ else
error_reporting(E_ALL); error_reporting(E_ALL);
} }
if($_SERVER['QUERY_STRING'] == 'clear')
{
unset($_SESSION);
}
//error_reporting(E_ALL); //error_reporting(E_ALL);
function e107_ini_set($var, $value) function e107_ini_set($var, $value)
@@ -86,9 +92,9 @@ if($inc_path[0] != ".")
} }
unset($inc_path); unset($inc_path);
if(!function_exists("mysql_connect")) //FIXME Adjust this once PDO is fully functional. if(!function_exists("mysql_connect") && !defined('PDO::ATTR_DRIVER_NAME'))
{ {
die_fatal_error("e107 requires PHP to be installed or compiled with the MySQL extension to work correctly, please see the MySQL manual for more information."); die_fatal_error("e107 requires PHP to be installed or compiled with PDO or the MySQL extension to work correctly, please see the MySQL manual for more information.");
} }
# Check for the realpath(). Some hosts (I'm looking at you, Awardspace) are totally dumb and # Check for the realpath(). Some hosts (I'm looking at you, Awardspace) are totally dumb and
@@ -167,7 +173,7 @@ e107::getSession(); // starts session, creates default namespace
function include_lan($path, $force = false) function include_lan($path, $force = false)
{ {
return e107::includeLan($path, $force); return include($path);
} }
//obsolete $e107->e107_dirs['INSTALLER'] = "{$installer_folder_name}/"; //obsolete $e107->e107_dirs['INSTALLER'] = "{$installer_folder_name}/";
@@ -177,7 +183,7 @@ if(isset($_GET['create_tables']))
exit; exit;
} }
header('Content-type: text/html; charset=utf-8');
$e_install = new e_install(); $e_install = new e_install();
$e_forms = new e_forms(); $e_forms = new e_forms();
@@ -217,6 +223,7 @@ class e_install
var $logFile; // Name of log file, empty string if logging disabled var $logFile; // Name of log file, empty string if logging disabled
var $dbLink = NULL; // DB link - needed for PHP5.3 bug var $dbLink = NULL; // DB link - needed for PHP5.3 bug
var $session = null; var $session = null;
protected $pdo = false;
// public function __construct() // public function __construct()
function e_install() function e_install()
@@ -225,6 +232,19 @@ class e_install
define('USERID', 1); define('USERID', 1);
define('USER', true); define('USER', true);
define('ADMIN', true); define('ADMIN', true);
define('e_UC_MAINADMIN', 250);
define('E107_DEBUG_LEVEL',0);
if(defined('PDO::ATTR_DRIVER_NAME')) // TODO Uncomment when ready.
{
// $this->pdo = true;
// define('e_PDO', true);
}
if(!empty($this->previous_steps['mysql']['prefix']))
{
define('MPREFIX', $this->previous_steps['mysql']['prefix']);
}
$tp = e107::getParser(); $tp = e107::getParser();
@@ -247,7 +267,7 @@ class e_install
if(isset($_POST['previous_steps'])) if(isset($_POST['previous_steps']))
{ {
$this->previous_steps = unserialize(base64_decode($_POST['previous_steps'])); $this->previous_steps = unserialize(base64_decode($_POST['previous_steps']));
$this->previous_steps = $tp->toDB($this->previous_steps); $this->previous_steps = $tp->filter($this->previous_steps);
unset($_POST['previous_steps']); unset($_POST['previous_steps']);
} }
else else
@@ -255,7 +275,7 @@ class e_install
$this->previous_steps = array(); $this->previous_steps = array();
} }
$this->get_lan_file(); $this->get_lan_file();
$this->post_data = $tp->toDB($_POST); $this->post_data = $tp->filter($_POST);
@@ -626,15 +646,18 @@ class e_install
{ {
$this->template->SetTag("stage_title", LANINS_037.($this->previous_steps['mysql']['createdb'] == 1 ? LANINS_038 : "")); $this->template->SetTag("stage_title", LANINS_037.($this->previous_steps['mysql']['createdb'] == 1 ? LANINS_038 : ""));
if (!$res = @mysql_connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password'])) $sql = e107::getDb();
if (!$res = $sql->connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password']))
// if (!$res = @mysql_connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password']))
{ {
$success = FALSE; $success = FALSE;
$e_forms->start_form("versions", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $e_forms->start_form("versions", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : ""));
$page_content = LANINS_041.nl2br("\n\n<b>".LANINS_083."\n</b><i>".mysql_error()."</i>"); $page_content = LANINS_041.nl2br("\n\n<b>".LANINS_083."\n</b><i>".$sql->getLastErrorText()."</i>");
$alertType = 'error'; $alertType = 'error';
} }
elseif(($this->previous_steps['mysql']['createdb'] == 1) && empty($this->previous_steps['mysql']['overwritedb']) && mysql_select_db($this->previous_steps['mysql']['db'], $res)) elseif(($this->previous_steps['mysql']['createdb'] == 1) && empty($this->previous_steps['mysql']['overwritedb']) && $sql->database($this->previous_steps['mysql']['db'], $this->previous_steps['mysql']['server']))
{ {
$success = false; $success = false;
$e_forms->start_form("versions", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $e_forms->start_form("versions", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : ""));
@@ -675,7 +698,7 @@ class e_install
else else
{ {
$success = false; $success = false;
$page_content .= "<br /><br />".LANINS_043.nl2br("\n\n<b>".LANINS_083."\n</b><i>".mysql_error()."</i>"); $page_content .= "<br /><br />".LANINS_043.nl2br("\n\n<b>".LANINS_083."\n</b><i>".e107::getDb()->getLastErrorText()."</i>");
} }
} }
@@ -700,7 +723,7 @@ class e_install
$page_content .= (empty($this->previous_steps['mysql']['createdb'])) ? LANINS_129 : LANINS_043; $page_content .= (empty($this->previous_steps['mysql']['createdb'])) ? LANINS_129 : LANINS_043;
$page_content .= nl2br("\n\n<b>".LANINS_083."\n</b><i>".mysql_error()."</i>"); $page_content .= nl2br("\n\n<b>".LANINS_083."\n</b><i>".e107::getDb()->getLastErrorText()."</i>");
} }
else else
{ {
@@ -783,20 +806,28 @@ class e_install
$perms_notes = "<span class='glyphicon glyphicon-ok'></span> ".LANINS_017; $perms_notes = "<span class='glyphicon glyphicon-ok'></span> ".LANINS_017;
} }
if(!function_exists("mysql_connect")) if(!function_exists("mysql_connect") && !defined('PDO::ATTR_DRIVER_NAME'))
{ {
$version_fail = true; $version_fail = true;
$mysql_note = LAN_ERROR; $mysql_note = LAN_ERROR;
$mysql_help = LANINS_012; $mysql_help = LANINS_012;
} }
elseif (!@mysql_connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password'])) elseif (!e107::getDb()->connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password']))
// elseif (!@mysql_connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password']))
{ {
$mysql_note = LAN_ERROR; $mysql_note = LAN_ERROR;
$mysql_help = LANINS_013; $mysql_help = LANINS_013;
} }
else else
{ {
$mysql_note = mysql_get_server_info(); // $mysql_note = mysql_get_server_info();
$mysql_note = e107::getDb()->getServerInfo();
if($this->pdo == true)
{
$mysql_note .= " (PDO)";
}
if (version_compare($mysql_note, MIN_MYSQL_VERSION, '>=')) if (version_compare($mysql_note, MIN_MYSQL_VERSION, '>='))
{ {
$mysql_help = "<span class='glyphicon glyphicon-ok'></span> ".LANINS_017; $mysql_help = "<span class='glyphicon glyphicon-ok'></span> ".LANINS_017;
@@ -807,26 +838,17 @@ class e_install
$mysql_help = "<span class='glyphicon glyphicon-remove'></span> ".LANINS_105; $mysql_help = "<span class='glyphicon glyphicon-remove'></span> ".LANINS_105;
} }
} }
if(!function_exists('utf8_encode'))
{
$xml_installed = false;
}
else
{
$xml_installed = true;
}
if(!function_exists('exif_imagetype'))
{ $xml_installed = (!function_exists('utf8_encode')) ? false : true;
$exif_installed = false; $exif_installed = (!function_exists('exif_imagetype')) ? false : true;
} $gdlib_installed = (extension_loaded('gd') && function_exists('gd_info')) ? true : false;
else
{
$exif_installed = true;
}
$exifExtensionLink = "<a href='http://php.net/manual/en/book.exif.php'>php.net</a>"; $exifExtensionLink = "<a href='http://php.net/manual/en/book.exif.php'>php.net</a>";
$php_version = phpversion(); $php_version = phpversion();
if(version_compare($php_version, MIN_PHP_VERSION, ">=")) if(version_compare($php_version, MIN_PHP_VERSION, ">="))
{ {
$php_help = "<span class='glyphicon glyphicon-ok'></span> ".LANINS_017; $php_help = "<span class='glyphicon glyphicon-ok'></span> ".LANINS_017;
@@ -835,7 +857,9 @@ class e_install
{ {
$php_help = "<span class='glyphicon glyphicon-remove'></span> ".LANINS_019; $php_help = "<span class='glyphicon glyphicon-remove'></span> ".LANINS_019;
} }
$e_forms->start_form("versions", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $e_forms->start_form("versions", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : ""));
if(!$perms_pass) if(!$perms_pass)
{ {
$this->add_button("retest_perms", LANINS_009); $this->add_button("retest_perms", LANINS_009);
@@ -852,6 +876,8 @@ class e_install
$exifColor = ($exif_installed == true) ? "text-success" : "text-error"; $exifColor = ($exif_installed == true) ? "text-success" : "text-error";
$mysqlColor = ($mysql_pass == true) ? "text-success" : "text-error"; $mysqlColor = ($mysql_pass == true) ? "text-success" : "text-error";
$gdLibColor = ($gdlib_installed == true) ? "text-success" : "text-error";
$xmlExtensionLink = "<a href='http://php.net/manual/en/ref.xml.php'>php.net</a>"; $xmlExtensionLink = "<a href='http://php.net/manual/en/ref.xml.php'>php.net</a>";
$output = " $output = "
@@ -874,6 +900,12 @@ class e_install
<td class='{$mysqlColor}'>{$mysql_help}</td> <td class='{$mysqlColor}'>{$mysql_help}</td>
</tr> </tr>
<tr>
<td>GD Extension</td>
<td>".($gdlib_installed ? LANINS_051 : LANINS_052)."</td>
<td class='{$gdLibColor}'>".($gdlib_installed ? "<i class='glyphicon glyphicon-ok'></i> ".LANINS_017 : str_replace("[x]",$xmlExtensionLink, LANINS_053) )."</td>
</tr>
<tr> <tr>
<td>".LANINS_050."</td> <td>".LANINS_050."</td>
<td>".($xml_installed ? LANINS_051 : LANINS_052)."</td> <td>".($xml_installed ? LANINS_051 : LANINS_052)."</td>
@@ -1197,7 +1229,7 @@ class e_install
* *
* e107 configuration file * e107 configuration file
* *
* This file has been generated by the installation script. * This file has been generated by the installation script on ".date('r').".
*/ */
\$mySQLserver = '{$this->previous_steps['mysql']['server']}'; \$mySQLserver = '{$this->previous_steps['mysql']['server']}';
@@ -1220,6 +1252,13 @@ class e_install
"; ";
if($this->pdo == true)
{
$config_file .= 'define("e_PDO", true);';
$config_file .= "\n\n";
}
$config_result = $this->write_config($config_file); $config_result = $this->write_config($config_file);
if ($config_result) if ($config_result)
@@ -1357,7 +1396,7 @@ class e_install
} }
elseif(file_exists("e107.htaccess")) elseif(file_exists("e107.htaccess"))
{ {
$error = LANINS_144; $error = e107::getParser()->toHtml(LANINS_144,true);
} }
return $error; return $error;
} }
@@ -1523,7 +1562,8 @@ class e_install
$extendedQuery = "REPLACE INTO `{$this->previous_steps['mysql']['prefix']}user_extended` (`user_extended_id` , `user_hidden_fields`) VALUES ('1', NULL );"; $extendedQuery = "REPLACE INTO `{$this->previous_steps['mysql']['prefix']}user_extended` (`user_extended_id` , `user_hidden_fields`) VALUES ('1', NULL );";
$this->dbqry($extendedQuery); $this->dbqry($extendedQuery);
mysql_close($this->dbLink); e107::getDb()->close();
// mysql_close($this->dbLink);
e107::getMessage()->reset(false, false, true); e107::getMessage()->reset(false, false, true);
@@ -1539,7 +1579,7 @@ class e_install
public function install_plugin($plugpath) //FIXME - requires default plugin table entries, see above. public function install_plugin($plugpath) //FIXME - requires default plugin table entries, see above.
{ {
e107::getDb()->gen("SELECT * FROM #plugin WHERE plugin_path = '".$plugpath."' LIMIT 1"); e107::getDb()->gen("SELECT * FROM #plugin WHERE plugin_path = '".$plugpath."' LIMIT 1");
$row = e107::getDb()->fetch(MYSQL_ASSOC); $row = e107::getDb()->fetch();
e107::getPlugin()->install_plugin($row['plugin_id']); e107::getPlugin()->install_plugin($row['plugin_id']);
e107::getMessage()->reset(false, false, true); e107::getMessage()->reset(false, false, true);
@@ -1719,7 +1759,7 @@ class e_install
$data['must_write'] = 'e107_config.php|{$MEDIA_DIRECTORY}|{$SYSTEM_DIRECTORY}'; // all-sub folders are created on-the-fly $data['must_write'] = 'e107_config.php|{$MEDIA_DIRECTORY}|{$SYSTEM_DIRECTORY}'; // all-sub folders are created on-the-fly
$data['can_write'] = '{$PLUGINS_DIRECTORY}|{$THEMES_DIRECTORY}'; $data['can_write'] = '{$PLUGINS_DIRECTORY}|{$THEMES_DIRECTORY}|{$WEB_DIRECTORY}cache|{$WEB_DIRECTORY}lib';
if (!isset($data[$list])) return $bad_files; if (!isset($data[$list])) return $bad_files;
foreach ($system_dirs as $dir_name => $value) foreach ($system_dirs as $dir_name => $value)
{ {
@@ -1745,17 +1785,21 @@ class e_install
*/ */
public function create_tables() public function create_tables()
{ {
$link = mysql_connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password']); // $link = mysql_connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password']);
$link = e107::getDb()->connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password']);
if(!$link) if(!$link)
{ {
return nl2br(LANINS_084."\n\n<b>".LANINS_083."\n</b><i>".mysql_error($link)."</i>"); return nl2br(LANINS_084."\n\n<b>".LANINS_083."\n</b><i>".mysql_error($link)."</i>");
} }
$this->dbLink = $link; // Needed for mysql_close() to work round bug in PHP 5.3 $this->dbLink = $link; // Needed for mysql_close() to work round bug in PHP 5.3
$db_selected = mysql_select_db($this->previous_steps['mysql']['db'], $link); // $db_selected = mysql_select_db($this->previous_steps['mysql']['db'], $link);
$db_selected = e107::getDb()->database($this->previous_steps['mysql']['db'],$this->previous_steps['mysql']['prefix']);
if(!$db_selected) if(!$db_selected)
{ {
return nl2br(LANINS_085." '{$this->previous_steps['mysql']['db']}'\n\n<b>".LANINS_083."\n</b><i>".mysql_error($link)."</i>"); return nl2br(LANINS_085." '{$this->previous_steps['mysql']['db']}'\n\n<b>".LANINS_083."\n</b><i>".e107::getDb()->getLastErrorText()."</i>");
} }
$filename = "{$this->e107->e107_dirs['CORE_DIRECTORY']}sql/core_sql.php"; $filename = "{$this->e107->e107_dirs['CORE_DIRECTORY']}sql/core_sql.php";
@@ -1788,7 +1832,7 @@ class e_install
if (!$this->dbqry($sql_table, $link)) if (!$this->dbqry($sql_table, $link))
{ {
return nl2br(LANINS_061."\n\n<b>".LANINS_083."\n</b><i>".mysql_error($link)."</i>"); return nl2br(LANINS_061."\n\n<b>".LANINS_083."\n</b><i>".e107::getDb()->getLastErrorText()."</i>");
} }
} }
@@ -1813,17 +1857,16 @@ class e_install
function dbqry($qry) function dbqry($qry)
{ {
mysql_query($qry); mysql_query($qry);
$sql = e107::getDb();
$sql->db_Query($qry);
if(mysql_errno()) if($error = $sql->getLastErrorNumber())
{ {
$errorInfo = 'Query Error [#'.mysql_errno().']: '.mysql_error()."\nQuery: {$qry}"; $errorInfo = 'Query Error [#'.$error.']: '.$sql->getLastErrorText()."\nQuery: {$qry}";
// echo $errorInfo."<br />";
//exit;
$this->debug_db_info['db_error_log'][] = $errorInfo; $this->debug_db_info['db_error_log'][] = $errorInfo;
//$this->debug_db_info['db_log'][] = $qry;
return false; return false;
} }
//$this->debug_db_info['db_log'][] = $qry;
return true; return true;
} }
} }