fix mysql-strict-mode issue (hopefully for good), enhance error-reporting when importing froxlor.sql on installation
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -66,7 +66,7 @@ CREATE TABLE `mail_virtual` (
|
||||
`id` int(11) NOT NULL auto_increment,
|
||||
`email` varchar(255) NOT NULL default '',
|
||||
`email_full` varchar(255) NOT NULL default '',
|
||||
`destination` text NOT NULL default '',
|
||||
`destination` text,
|
||||
`domainid` int(11) NOT NULL default '0',
|
||||
`customerid` int(11) NOT NULL default '0',
|
||||
`popaccountid` int(11) NOT NULL default '0',
|
||||
|
||||
@@ -74,10 +74,17 @@ class FroxlorInstall
|
||||
/**
|
||||
* currently used language
|
||||
*
|
||||
* @var unknown
|
||||
* @var string
|
||||
*/
|
||||
private $_activelng = 'english';
|
||||
|
||||
/**
|
||||
* check whether to abort due to errors
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $_abort = false;
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*/
|
||||
@@ -238,6 +245,7 @@ class FroxlorInstall
|
||||
$content .= $this->_createDatabaseAndUser($db_root);
|
||||
// importing data to new database
|
||||
$content .= $this->_importDatabaseData();
|
||||
if (! $this->_abort) {
|
||||
// create DB object for new database
|
||||
$options = array(
|
||||
'PDO::MYSQL_ATTR_INIT_COMMAND' => 'SET names utf8,sql_mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"'
|
||||
@@ -251,7 +259,6 @@ class FroxlorInstall
|
||||
$content .= $this->_status_message('red', $e->getMessage());
|
||||
$another_fail = true;
|
||||
}
|
||||
;
|
||||
|
||||
if (! $another_fail) {
|
||||
// change settings accordingly
|
||||
@@ -263,11 +270,12 @@ class FroxlorInstall
|
||||
$content .= $this->_createUserdataConf();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$content .= "</table>";
|
||||
|
||||
// check if we have unrecoverable errors
|
||||
if ($fatal_fail || $another_fail) {
|
||||
if ($fatal_fail || $another_fai || $this->_abort) {
|
||||
// D'oh
|
||||
$navigation = '';
|
||||
$msgcolor = 'red';
|
||||
@@ -517,11 +525,17 @@ class FroxlorInstall
|
||||
$fatal_fail = false;
|
||||
try {
|
||||
$db = new PDO($dsn, $this->_data['mysql_unpriv_user'], $this->_data['mysql_unpriv_pass'], $options);
|
||||
$attributes = array(
|
||||
'ATTR_ERRMODE' => 'ERRMODE_EXCEPTION'
|
||||
);
|
||||
// set attributes
|
||||
foreach ($attributes as $k => $v) {
|
||||
$db->setAttribute(constant("PDO::" . $k), constant("PDO::" . $v));
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
$content .= $this->_status_message('red', $e->getMessage());
|
||||
$fatal_fail = true;
|
||||
}
|
||||
;
|
||||
|
||||
if (! $fatal_fail) {
|
||||
|
||||
@@ -534,12 +548,21 @@ class FroxlorInstall
|
||||
$sql_query = $this->_split_sql_file($sql_query, ';');
|
||||
for ($i = 0; $i < sizeof($sql_query); $i ++) {
|
||||
if (trim($sql_query[$i]) != '') {
|
||||
try {
|
||||
$result = $db->query($sql_query[$i]);
|
||||
} catch (\PDOException $e) {
|
||||
$content .= $this->_status_message('red', $e->getMessage());
|
||||
$fatal_fail = true;
|
||||
$this->_abort = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! $fatal_fail) {
|
||||
$content .= $this->_status_message('green', 'OK');
|
||||
}
|
||||
$db = null;
|
||||
|
||||
$content .= $this->_status_message('green', 'OK');
|
||||
}
|
||||
|
||||
return $content;
|
||||
@@ -1168,8 +1191,7 @@ class FroxlorInstall
|
||||
$this->_data['servername'] = $_POST['servername'];
|
||||
return;
|
||||
// from $_SERVER
|
||||
} else
|
||||
if (! empty($_SERVER['SERVER_NAME'])) {
|
||||
} else if (! empty($_SERVER['SERVER_NAME'])) {
|
||||
// no ips
|
||||
if ($this->_validate_ip($_SERVER['SERVER_NAME']) == false) {
|
||||
$this->_data['servername'] = $_SERVER['SERVER_NAME'];
|
||||
|
||||
Reference in New Issue
Block a user