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,
|
`id` int(11) NOT NULL auto_increment,
|
||||||
`email` varchar(255) NOT NULL default '',
|
`email` varchar(255) NOT NULL default '',
|
||||||
`email_full` 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',
|
`domainid` int(11) NOT NULL default '0',
|
||||||
`customerid` int(11) NOT NULL default '0',
|
`customerid` int(11) NOT NULL default '0',
|
||||||
`popaccountid` int(11) NOT NULL default '0',
|
`popaccountid` int(11) NOT NULL default '0',
|
||||||
|
|||||||
@@ -74,10 +74,17 @@ class FroxlorInstall
|
|||||||
/**
|
/**
|
||||||
* currently used language
|
* currently used language
|
||||||
*
|
*
|
||||||
* @var unknown
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_activelng = 'english';
|
private $_activelng = 'english';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check whether to abort due to errors
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private $_abort = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class constructor
|
* Class constructor
|
||||||
*/
|
*/
|
||||||
@@ -238,36 +245,37 @@ class FroxlorInstall
|
|||||||
$content .= $this->_createDatabaseAndUser($db_root);
|
$content .= $this->_createDatabaseAndUser($db_root);
|
||||||
// importing data to new database
|
// importing data to new database
|
||||||
$content .= $this->_importDatabaseData();
|
$content .= $this->_importDatabaseData();
|
||||||
// create DB object for new database
|
if (! $this->_abort) {
|
||||||
$options = array(
|
// create DB object for new database
|
||||||
'PDO::MYSQL_ATTR_INIT_COMMAND' => 'SET names utf8,sql_mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"'
|
$options = array(
|
||||||
);
|
'PDO::MYSQL_ATTR_INIT_COMMAND' => 'SET names utf8,sql_mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"'
|
||||||
$dsn = "mysql:host=" . $this->_data['mysql_host'] . ";dbname=" . $this->_data['mysql_database'] . ";";
|
);
|
||||||
$another_fail = false;
|
$dsn = "mysql:host=" . $this->_data['mysql_host'] . ";dbname=" . $this->_data['mysql_database'] . ";";
|
||||||
try {
|
$another_fail = false;
|
||||||
$db = new PDO($dsn, $this->_data['mysql_unpriv_user'], $this->_data['mysql_unpriv_pass'], $options);
|
try {
|
||||||
} catch (PDOException $e) {
|
$db = new PDO($dsn, $this->_data['mysql_unpriv_user'], $this->_data['mysql_unpriv_pass'], $options);
|
||||||
// dafuq? this should have happened in _importDatabaseData()
|
} catch (PDOException $e) {
|
||||||
$content .= $this->_status_message('red', $e->getMessage());
|
// dafuq? this should have happened in _importDatabaseData()
|
||||||
$another_fail = true;
|
$content .= $this->_status_message('red', $e->getMessage());
|
||||||
}
|
$another_fail = true;
|
||||||
;
|
}
|
||||||
|
|
||||||
if (! $another_fail) {
|
if (! $another_fail) {
|
||||||
// change settings accordingly
|
// change settings accordingly
|
||||||
$content .= $this->_doSettings($db);
|
$content .= $this->_doSettings($db);
|
||||||
// create entries
|
// create entries
|
||||||
$content .= $this->_doDataEntries($db);
|
$content .= $this->_doDataEntries($db);
|
||||||
$db = null;
|
$db = null;
|
||||||
// create config-file
|
// create config-file
|
||||||
$content .= $this->_createUserdataConf();
|
$content .= $this->_createUserdataConf();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$content .= "</table>";
|
$content .= "</table>";
|
||||||
|
|
||||||
// check if we have unrecoverable errors
|
// check if we have unrecoverable errors
|
||||||
if ($fatal_fail || $another_fail) {
|
if ($fatal_fail || $another_fai || $this->_abort) {
|
||||||
// D'oh
|
// D'oh
|
||||||
$navigation = '';
|
$navigation = '';
|
||||||
$msgcolor = 'red';
|
$msgcolor = 'red';
|
||||||
@@ -517,11 +525,17 @@ class FroxlorInstall
|
|||||||
$fatal_fail = false;
|
$fatal_fail = false;
|
||||||
try {
|
try {
|
||||||
$db = new PDO($dsn, $this->_data['mysql_unpriv_user'], $this->_data['mysql_unpriv_pass'], $options);
|
$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) {
|
} catch (PDOException $e) {
|
||||||
$content .= $this->_status_message('red', $e->getMessage());
|
$content .= $this->_status_message('red', $e->getMessage());
|
||||||
$fatal_fail = true;
|
$fatal_fail = true;
|
||||||
}
|
}
|
||||||
;
|
|
||||||
|
|
||||||
if (! $fatal_fail) {
|
if (! $fatal_fail) {
|
||||||
|
|
||||||
@@ -534,12 +548,21 @@ class FroxlorInstall
|
|||||||
$sql_query = $this->_split_sql_file($sql_query, ';');
|
$sql_query = $this->_split_sql_file($sql_query, ';');
|
||||||
for ($i = 0; $i < sizeof($sql_query); $i ++) {
|
for ($i = 0; $i < sizeof($sql_query); $i ++) {
|
||||||
if (trim($sql_query[$i]) != '') {
|
if (trim($sql_query[$i]) != '') {
|
||||||
$result = $db->query($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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db = null;
|
|
||||||
|
|
||||||
$content .= $this->_status_message('green', 'OK');
|
if (! $fatal_fail) {
|
||||||
|
$content .= $this->_status_message('green', 'OK');
|
||||||
|
}
|
||||||
|
$db = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
@@ -913,7 +936,7 @@ class FroxlorInstall
|
|||||||
$_die = true;
|
$_die = true;
|
||||||
} else {
|
} else {
|
||||||
if (version_compare("5.6.0", PHP_VERSION, ">=")) {
|
if (version_compare("5.6.0", PHP_VERSION, ">=")) {
|
||||||
$content .= $this->_status_message('orange', $this->_lng['requirements']['newerphpprefered'] . ' (' .PHP_VERSION . ')');
|
$content .= $this->_status_message('orange', $this->_lng['requirements']['newerphpprefered'] . ' (' . PHP_VERSION . ')');
|
||||||
} else {
|
} else {
|
||||||
$content .= $this->_status_message('green', PHP_VERSION);
|
$content .= $this->_status_message('green', PHP_VERSION);
|
||||||
}
|
}
|
||||||
@@ -1168,14 +1191,13 @@ class FroxlorInstall
|
|||||||
$this->_data['servername'] = $_POST['servername'];
|
$this->_data['servername'] = $_POST['servername'];
|
||||||
return;
|
return;
|
||||||
// from $_SERVER
|
// from $_SERVER
|
||||||
} else
|
} else if (! empty($_SERVER['SERVER_NAME'])) {
|
||||||
if (! empty($_SERVER['SERVER_NAME'])) {
|
// no ips
|
||||||
// no ips
|
if ($this->_validate_ip($_SERVER['SERVER_NAME']) == false) {
|
||||||
if ($this->_validate_ip($_SERVER['SERVER_NAME']) == false) {
|
$this->_data['servername'] = $_SERVER['SERVER_NAME'];
|
||||||
$this->_data['servername'] = $_SERVER['SERVER_NAME'];
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// empty
|
// empty
|
||||||
$this->_data['servername'] = '';
|
$this->_data['servername'] = '';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user