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',
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||||
* @package Install
|
* @package Install
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class FroxlorInstall
|
class FroxlorInstall
|
||||||
{
|
{
|
||||||
@@ -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
|
||||||
*/
|
*/
|
||||||
@@ -154,7 +161,7 @@ class FroxlorInstall
|
|||||||
$this->_guessServerName();
|
$this->_guessServerName();
|
||||||
$this->_guessServerIP();
|
$this->_guessServerIP();
|
||||||
$this->_guessWebserver();
|
$this->_guessWebserver();
|
||||||
|
|
||||||
$this->_getPostField('mysql_host', '127.0.0.1');
|
$this->_getPostField('mysql_host', '127.0.0.1');
|
||||||
$this->_getPostField('mysql_database', 'froxlor');
|
$this->_getPostField('mysql_database', 'froxlor');
|
||||||
$this->_getPostField('mysql_unpriv_user', 'froxlor');
|
$this->_getPostField('mysql_unpriv_user', 'froxlor');
|
||||||
@@ -169,22 +176,22 @@ class FroxlorInstall
|
|||||||
$this->_getPostField('httpuser', $posixusername['name']);
|
$this->_getPostField('httpuser', $posixusername['name']);
|
||||||
$posixgroup = posix_getgrgid(posix_getgid());
|
$posixgroup = posix_getgrgid(posix_getgid());
|
||||||
$this->_getPostField('httpgroup', $posixgroup['name']);
|
$this->_getPostField('httpgroup', $posixgroup['name']);
|
||||||
|
|
||||||
if ($this->_data['mysql_host'] == 'localhost' || $this->_data['mysql_host'] == '127.0.0.1') {
|
if ($this->_data['mysql_host'] == 'localhost' || $this->_data['mysql_host'] == '127.0.0.1') {
|
||||||
$this->_data['mysql_access_host'] = $this->_data['mysql_host'];
|
$this->_data['mysql_access_host'] = $this->_data['mysql_host'];
|
||||||
} else {
|
} else {
|
||||||
$this->_data['mysql_access_host'] = $this->_data['serverip'];
|
$this->_data['mysql_access_host'] = $this->_data['serverip'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// check system-hostname to be a FQDN
|
// check system-hostname to be a FQDN
|
||||||
if ($this->_validate_ip($this->_data['servername']) !== false) {
|
if ($this->_validate_ip($this->_data['servername']) !== false) {
|
||||||
$this->_data['servername'] = '';
|
$this->_data['servername'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($this->_data['serverip']) || $this->_validate_ip($this->_data['serverip']) == false) {
|
if (empty($this->_data['serverip']) || $this->_validate_ip($this->_data['serverip']) == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_POST['installstep']) && $_POST['installstep'] == '1' && $this->_data['admin_pass1'] == $this->_data['admin_pass2'] && $this->_data['admin_pass1'] != '' && $this->_data['admin_pass2'] != '' && $this->_data['mysql_unpriv_pass'] != '' && $this->_data['mysql_root_pass'] != '' && $this->_data['servername'] != '' && $this->_data['serverip'] != '' && $this->_data['httpuser'] != '' && $this->_data['httpgroup'] != '' && $this->_data['mysql_unpriv_user'] != $this->_data['mysql_root_user']) {
|
if (isset($_POST['installstep']) && $_POST['installstep'] == '1' && $this->_data['admin_pass1'] == $this->_data['admin_pass2'] && $this->_data['admin_pass1'] != '' && $this->_data['admin_pass2'] != '' && $this->_data['mysql_unpriv_pass'] != '' && $this->_data['mysql_root_pass'] != '' && $this->_data['servername'] != '' && $this->_data['serverip'] != '' && $this->_data['httpuser'] != '' && $this->_data['httpgroup'] != '' && $this->_data['mysql_unpriv_user'] != $this->_data['mysql_root_user']) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -199,10 +206,10 @@ class FroxlorInstall
|
|||||||
private function _doInstall()
|
private function _doInstall()
|
||||||
{
|
{
|
||||||
$content = "<table class=\"noborder\">";
|
$content = "<table class=\"noborder\">";
|
||||||
|
|
||||||
// check for mysql-root-connection
|
// check for mysql-root-connection
|
||||||
$content .= $this->_status_message('begin', $this->_lng['install']['testing_mysql']);
|
$content .= $this->_status_message('begin', $this->_lng['install']['testing_mysql']);
|
||||||
|
|
||||||
$options = array(
|
$options = array(
|
||||||
'PDO::MYSQL_ATTR_INIT_COMMAND' => 'SET names utf8,sql_mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"'
|
'PDO::MYSQL_ATTR_INIT_COMMAND' => 'SET names utf8,sql_mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"'
|
||||||
);
|
);
|
||||||
@@ -227,9 +234,9 @@ class FroxlorInstall
|
|||||||
$fatal_fail = true;
|
$fatal_fail = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $fatal_fail) {
|
if (! $fatal_fail) {
|
||||||
|
|
||||||
// ok, if we are here, the database connection is up and running
|
// ok, if we are here, the database connection is up and running
|
||||||
$content .= $this->_status_message('green', "OK");
|
$content .= $this->_status_message('green', "OK");
|
||||||
// check for existing db and create backup if so
|
// check for existing db and create backup if so
|
||||||
@@ -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';
|
||||||
@@ -282,9 +290,9 @@ class FroxlorInstall
|
|||||||
$link = '../index.php';
|
$link = '../index.php';
|
||||||
$linktext = $this->_lng['click_here_to_login'];
|
$linktext = $this->_lng['click_here_to_login'];
|
||||||
}
|
}
|
||||||
|
|
||||||
eval("\$navigation .= \"" . $this->_getTemplate("pagebottom") . "\";");
|
eval("\$navigation .= \"" . $this->_getTemplate("pagebottom") . "\";");
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'pagecontent' => $content,
|
'pagecontent' => $content,
|
||||||
'pagenavigation' => $navigation
|
'pagenavigation' => $navigation
|
||||||
@@ -297,7 +305,7 @@ class FroxlorInstall
|
|||||||
private function _createUserdataConf()
|
private function _createUserdataConf()
|
||||||
{
|
{
|
||||||
$content = "";
|
$content = "";
|
||||||
|
|
||||||
$content .= $this->_status_message('begin', $this->_lng['install']['creating_configfile']);
|
$content .= $this->_status_message('begin', $this->_lng['install']['creating_configfile']);
|
||||||
$userdata = "<?php\n";
|
$userdata = "<?php\n";
|
||||||
$userdata .= "// automatically generated userdata.inc.php for Froxlor\n";
|
$userdata .= "// automatically generated userdata.inc.php for Froxlor\n";
|
||||||
@@ -312,7 +320,7 @@ class FroxlorInstall
|
|||||||
$userdata .= "// enable debugging to browser in case of SQL errors\n";
|
$userdata .= "// enable debugging to browser in case of SQL errors\n";
|
||||||
$userdata .= "\$sql['debug'] = false;\n";
|
$userdata .= "\$sql['debug'] = false;\n";
|
||||||
$userdata .= "?>";
|
$userdata .= "?>";
|
||||||
|
|
||||||
// test if we can store the userdata.inc.php in ../lib
|
// test if we can store the userdata.inc.php in ../lib
|
||||||
if ($fp = @fopen(dirname(dirname(dirname(__FILE__))) . '/lib/userdata.inc.php', 'w')) {
|
if ($fp = @fopen(dirname(dirname(dirname(__FILE__))) . '/lib/userdata.inc.php', 'w')) {
|
||||||
$result = @fputs($fp, $userdata, strlen($userdata));
|
$result = @fputs($fp, $userdata, strlen($userdata));
|
||||||
@@ -329,7 +337,7 @@ class FroxlorInstall
|
|||||||
$escpduserdata = nl2br(htmlspecialchars($userdata));
|
$escpduserdata = nl2br(htmlspecialchars($userdata));
|
||||||
eval("\$content .= \"" . $this->_getTemplate("textarea") . "\";");
|
eval("\$content .= \"" . $this->_getTemplate("textarea") . "\";");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,9 +351,9 @@ class FroxlorInstall
|
|||||||
private function _doDataEntries(&$db)
|
private function _doDataEntries(&$db)
|
||||||
{
|
{
|
||||||
$content = "";
|
$content = "";
|
||||||
|
|
||||||
$content .= $this->_status_message('begin', $this->_lng['install']['creating_entries']);
|
$content .= $this->_status_message('begin', $this->_lng['install']['creating_entries']);
|
||||||
|
|
||||||
// and lets insert the default ip and port
|
// and lets insert the default ip and port
|
||||||
$stmt = $db->prepare("
|
$stmt = $db->prepare("
|
||||||
INSERT INTO `" . TABLE_PANEL_IPSANDPORTS . "` SET
|
INSERT INTO `" . TABLE_PANEL_IPSANDPORTS . "` SET
|
||||||
@@ -359,7 +367,7 @@ class FroxlorInstall
|
|||||||
'serverip' => $this->_data['serverip']
|
'serverip' => $this->_data['serverip']
|
||||||
));
|
));
|
||||||
$defaultip = $db->lastInsertId();
|
$defaultip = $db->lastInsertId();
|
||||||
|
|
||||||
// insert the defaultip
|
// insert the defaultip
|
||||||
$upd_stmt = $db->prepare("
|
$upd_stmt = $db->prepare("
|
||||||
UPDATE `" . TABLE_PANEL_SETTINGS . "` SET
|
UPDATE `" . TABLE_PANEL_SETTINGS . "` SET
|
||||||
@@ -369,9 +377,9 @@ class FroxlorInstall
|
|||||||
$upd_stmt->execute(array(
|
$upd_stmt->execute(array(
|
||||||
'defaultip' => $defaultip
|
'defaultip' => $defaultip
|
||||||
));
|
));
|
||||||
|
|
||||||
$content .= $this->_status_message('green', 'OK');
|
$content .= $this->_status_message('green', 'OK');
|
||||||
|
|
||||||
// last but not least create the main admin
|
// last but not least create the main admin
|
||||||
$content .= $this->_status_message('begin', $this->_lng['install']['adding_admin_user']);
|
$content .= $this->_status_message('begin', $this->_lng['install']['adding_admin_user']);
|
||||||
$ins_data = array(
|
$ins_data = array(
|
||||||
@@ -406,11 +414,11 @@ class FroxlorInstall
|
|||||||
`subdomains` = -1,
|
`subdomains` = -1,
|
||||||
`traffic` = -1048576
|
`traffic` = -1048576
|
||||||
");
|
");
|
||||||
|
|
||||||
$ins_stmt->execute($ins_data);
|
$ins_stmt->execute($ins_data);
|
||||||
|
|
||||||
$content .= $this->_status_message('green', 'OK');
|
$content .= $this->_status_message('green', 'OK');
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -441,14 +449,14 @@ class FroxlorInstall
|
|||||||
private function _doSettings(&$db)
|
private function _doSettings(&$db)
|
||||||
{
|
{
|
||||||
$content = "";
|
$content = "";
|
||||||
|
|
||||||
$content .= $this->_status_message('begin', $this->_lng['install']['changing_data']);
|
$content .= $this->_status_message('begin', $this->_lng['install']['changing_data']);
|
||||||
$upd_stmt = $db->prepare("
|
$upd_stmt = $db->prepare("
|
||||||
UPDATE `" . TABLE_PANEL_SETTINGS . "` SET
|
UPDATE `" . TABLE_PANEL_SETTINGS . "` SET
|
||||||
`value` = :value
|
`value` = :value
|
||||||
WHERE `settinggroup` = :group AND `varname` = :varname
|
WHERE `settinggroup` = :group AND `varname` = :varname
|
||||||
");
|
");
|
||||||
|
|
||||||
$this->_updateSetting($upd_stmt, 'admin@' . $this->_data['servername'], 'panel', 'adminmail');
|
$this->_updateSetting($upd_stmt, 'admin@' . $this->_data['servername'], 'panel', 'adminmail');
|
||||||
$this->_updateSetting($upd_stmt, $this->_data['serverip'], 'system', 'ipaddress');
|
$this->_updateSetting($upd_stmt, $this->_data['serverip'], 'system', 'ipaddress');
|
||||||
$this->_updateSetting($upd_stmt, $this->_data['servername'], 'system', 'hostname');
|
$this->_updateSetting($upd_stmt, $this->_data['servername'], 'system', 'hostname');
|
||||||
@@ -457,7 +465,7 @@ class FroxlorInstall
|
|||||||
$this->_updateSetting($upd_stmt, $this->_data['webserver'], 'system', 'webserver');
|
$this->_updateSetting($upd_stmt, $this->_data['webserver'], 'system', 'webserver');
|
||||||
$this->_updateSetting($upd_stmt, $this->_data['httpuser'], 'system', 'httpuser');
|
$this->_updateSetting($upd_stmt, $this->_data['httpuser'], 'system', 'httpuser');
|
||||||
$this->_updateSetting($upd_stmt, $this->_data['httpgroup'], 'system', 'httpgroup');
|
$this->_updateSetting($upd_stmt, $this->_data['httpgroup'], 'system', 'httpgroup');
|
||||||
|
|
||||||
// necessary changes for webservers != apache2
|
// necessary changes for webservers != apache2
|
||||||
if ($this->_data['webserver'] == "apache24") {
|
if ($this->_data['webserver'] == "apache24") {
|
||||||
$this->_updateSetting($upd_stmt, 'apache2', 'system', 'webserver');
|
$this->_updateSetting($upd_stmt, 'apache2', 'system', 'webserver');
|
||||||
@@ -477,25 +485,25 @@ class FroxlorInstall
|
|||||||
$this->_updateSetting($upd_stmt, '/etc/nginx/nginx.pem', 'system', 'ssl_cert_file');
|
$this->_updateSetting($upd_stmt, '/etc/nginx/nginx.pem', 'system', 'ssl_cert_file');
|
||||||
$this->_updateSetting($upd_stmt, '/var/run/', 'phpfpm', 'fastcgi_ipcdir');
|
$this->_updateSetting($upd_stmt, '/var/run/', 'phpfpm', 'fastcgi_ipcdir');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_updateSetting($upd_stmt, $this->_data['activate_newsfeed'], 'admin', 'show_news_feed');
|
$this->_updateSetting($upd_stmt, $this->_data['activate_newsfeed'], 'admin', 'show_news_feed');
|
||||||
$this->_updateSetting($upd_stmt, dirname(dirname(dirname(__FILE__))), 'system', 'letsencryptchallengepath');
|
$this->_updateSetting($upd_stmt, dirname(dirname(dirname(__FILE__))), 'system', 'letsencryptchallengepath');
|
||||||
|
|
||||||
// insert the lastcronrun to be the installation date
|
// insert the lastcronrun to be the installation date
|
||||||
$this->_updateSetting($upd_stmt, time(), 'system', 'lastcronrun');
|
$this->_updateSetting($upd_stmt, time(), 'system', 'lastcronrun');
|
||||||
|
|
||||||
// set specific times for some crons (traffic only at night, etc.)
|
// set specific times for some crons (traffic only at night, etc.)
|
||||||
$ts = mktime(0, 0, 0, date('m', time()), date('d', time()), date('Y', time()));
|
$ts = mktime(0, 0, 0, date('m', time()), date('d', time()), date('Y', time()));
|
||||||
$db->query("UPDATE `" . TABLE_PANEL_CRONRUNS . "` SET `lastrun` = '" . $ts . "' WHERE `cronfile` ='cron_traffic.php';");
|
$db->query("UPDATE `" . TABLE_PANEL_CRONRUNS . "` SET `lastrun` = '" . $ts . "' WHERE `cronfile` ='cron_traffic.php';");
|
||||||
$ts = mktime(1, 0, 0, date('m', time()), date('d', time()), date('Y', time()));
|
$ts = mktime(1, 0, 0, date('m', time()), date('d', time()), date('Y', time()));
|
||||||
$db->query("UPDATE `" . TABLE_PANEL_CRONRUNS . "` SET `lastrun` = '" . $ts . "' WHERE `cronfile` ='cron_used_tickets_reset.php';");
|
$db->query("UPDATE `" . TABLE_PANEL_CRONRUNS . "` SET `lastrun` = '" . $ts . "' WHERE `cronfile` ='cron_used_tickets_reset.php';");
|
||||||
$db->query("UPDATE `" . TABLE_PANEL_CRONRUNS . "` SET `lastrun` = '" . $ts . "' WHERE `cronfile` ='cron_ticketarchive.php';");
|
$db->query("UPDATE `" . TABLE_PANEL_CRONRUNS . "` SET `lastrun` = '" . $ts . "' WHERE `cronfile` ='cron_ticketarchive.php';");
|
||||||
|
|
||||||
// insert task 99 to generate a correct cron.d-file automatically
|
// insert task 99 to generate a correct cron.d-file automatically
|
||||||
$db->query("INSERT INTO `" . TABLE_PANEL_TASKS . "` SET `type` = '99';");
|
$db->query("INSERT INTO `" . TABLE_PANEL_TASKS . "` SET `type` = '99';");
|
||||||
|
|
||||||
$content .= $this->_status_message('green', 'OK');
|
$content .= $this->_status_message('green', 'OK');
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -517,16 +525,22 @@ 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) {
|
||||||
|
|
||||||
$content .= $this->_status_message('green', 'OK');
|
$content .= $this->_status_message('green', 'OK');
|
||||||
|
|
||||||
$content .= $this->_status_message('begin', $this->_lng['install']['importing_data']);
|
$content .= $this->_status_message('begin', $this->_lng['install']['importing_data']);
|
||||||
$db_schema = dirname(dirname(__FILE__)) . '/froxlor.sql';
|
$db_schema = dirname(dirname(__FILE__)) . '/froxlor.sql';
|
||||||
$sql_query = @file_get_contents($db_schema);
|
$sql_query = @file_get_contents($db_schema);
|
||||||
@@ -534,14 +548,23 @@ 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! $fatal_fail) {
|
||||||
|
$content .= $this->_status_message('green', 'OK');
|
||||||
|
}
|
||||||
$db = null;
|
$db = null;
|
||||||
|
|
||||||
$content .= $this->_status_message('green', 'OK');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -555,56 +578,56 @@ class FroxlorInstall
|
|||||||
private function _createDatabaseAndUser(&$db_root)
|
private function _createDatabaseAndUser(&$db_root)
|
||||||
{
|
{
|
||||||
$content = "";
|
$content = "";
|
||||||
|
|
||||||
// so first we have to delete the database and
|
// so first we have to delete the database and
|
||||||
// the user given for the unpriv-user if they exit
|
// the user given for the unpriv-user if they exit
|
||||||
$content .= $this->_status_message('begin', $this->_lng['install']['prepare_db']);
|
$content .= $this->_status_message('begin', $this->_lng['install']['prepare_db']);
|
||||||
|
|
||||||
$del_stmt = $db_root->prepare("DELETE FROM `mysql`.`user` WHERE `User` = :user AND `Host` = :accesshost");
|
$del_stmt = $db_root->prepare("DELETE FROM `mysql`.`user` WHERE `User` = :user AND `Host` = :accesshost");
|
||||||
$del_stmt->execute(array(
|
$del_stmt->execute(array(
|
||||||
'user' => $this->_data['mysql_unpriv_user'],
|
'user' => $this->_data['mysql_unpriv_user'],
|
||||||
'accesshost' => $this->_data['mysql_access_host']
|
'accesshost' => $this->_data['mysql_access_host']
|
||||||
));
|
));
|
||||||
|
|
||||||
$del_stmt = $db_root->prepare("DELETE FROM `mysql`.`db` WHERE `User` = :user AND `Host` = :accesshost");
|
$del_stmt = $db_root->prepare("DELETE FROM `mysql`.`db` WHERE `User` = :user AND `Host` = :accesshost");
|
||||||
$del_stmt->execute(array(
|
$del_stmt->execute(array(
|
||||||
'user' => $this->_data['mysql_unpriv_user'],
|
'user' => $this->_data['mysql_unpriv_user'],
|
||||||
'accesshost' => $this->_data['mysql_access_host']
|
'accesshost' => $this->_data['mysql_access_host']
|
||||||
));
|
));
|
||||||
|
|
||||||
$del_stmt = $db_root->prepare("DELETE FROM `mysql`.`tables_priv` WHERE `User` = :user AND `Host` =:accesshost");
|
$del_stmt = $db_root->prepare("DELETE FROM `mysql`.`tables_priv` WHERE `User` = :user AND `Host` =:accesshost");
|
||||||
$del_stmt->execute(array(
|
$del_stmt->execute(array(
|
||||||
'user' => $this->_data['mysql_unpriv_user'],
|
'user' => $this->_data['mysql_unpriv_user'],
|
||||||
'accesshost' => $this->_data['mysql_access_host']
|
'accesshost' => $this->_data['mysql_access_host']
|
||||||
));
|
));
|
||||||
|
|
||||||
$del_stmt = $db_root->prepare("DELETE FROM `mysql`.`columns_priv` WHERE `User` = :user AND `Host` = :accesshost");
|
$del_stmt = $db_root->prepare("DELETE FROM `mysql`.`columns_priv` WHERE `User` = :user AND `Host` = :accesshost");
|
||||||
$del_stmt->execute(array(
|
$del_stmt->execute(array(
|
||||||
'user' => $this->_data['mysql_unpriv_user'],
|
'user' => $this->_data['mysql_unpriv_user'],
|
||||||
'accesshost' => $this->_data['mysql_access_host']
|
'accesshost' => $this->_data['mysql_access_host']
|
||||||
));
|
));
|
||||||
|
|
||||||
$del_stmt = $db_root->prepare("DROP DATABASE IF EXISTS `" . str_replace('`', '', $this->_data['mysql_database']) . "`;");
|
$del_stmt = $db_root->prepare("DROP DATABASE IF EXISTS `" . str_replace('`', '', $this->_data['mysql_database']) . "`;");
|
||||||
$del_stmt->execute();
|
$del_stmt->execute();
|
||||||
|
|
||||||
$db_root->query("FLUSH PRIVILEGES;");
|
$db_root->query("FLUSH PRIVILEGES;");
|
||||||
$content .= $this->_status_message('green', 'OK');
|
$content .= $this->_status_message('green', 'OK');
|
||||||
|
|
||||||
// we have to create a new user and database for the froxlor unprivileged mysql access
|
// we have to create a new user and database for the froxlor unprivileged mysql access
|
||||||
$content .= $this->_status_message('begin', $this->_lng['install']['create_mysqluser_and_db']);
|
$content .= $this->_status_message('begin', $this->_lng['install']['create_mysqluser_and_db']);
|
||||||
$ins_stmt = $db_root->prepare("CREATE DATABASE `" . str_replace('`', '', $this->_data['mysql_database']) . "` CHARACTER SET=utf8 COLLATE=utf8_general_ci");
|
$ins_stmt = $db_root->prepare("CREATE DATABASE `" . str_replace('`', '', $this->_data['mysql_database']) . "` CHARACTER SET=utf8 COLLATE=utf8_general_ci");
|
||||||
$ins_stmt->execute();
|
$ins_stmt->execute();
|
||||||
|
|
||||||
$mysql_access_host_array = array_map('trim', explode(',', $this->_data['mysql_access_host']));
|
$mysql_access_host_array = array_map('trim', explode(',', $this->_data['mysql_access_host']));
|
||||||
|
|
||||||
if (in_array('127.0.0.1', $mysql_access_host_array) && ! in_array('localhost', $mysql_access_host_array)) {
|
if (in_array('127.0.0.1', $mysql_access_host_array) && ! in_array('localhost', $mysql_access_host_array)) {
|
||||||
$mysql_access_host_array[] = 'localhost';
|
$mysql_access_host_array[] = 'localhost';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! in_array('127.0.0.1', $mysql_access_host_array) && in_array('localhost', $mysql_access_host_array)) {
|
if (! in_array('127.0.0.1', $mysql_access_host_array) && in_array('localhost', $mysql_access_host_array)) {
|
||||||
$mysql_access_host_array[] = '127.0.0.1';
|
$mysql_access_host_array[] = '127.0.0.1';
|
||||||
}
|
}
|
||||||
|
|
||||||
$mysql_access_host_array[] = $this->_data['serverip'];
|
$mysql_access_host_array[] = $this->_data['serverip'];
|
||||||
foreach ($mysql_access_host_array as $mysql_access_host) {
|
foreach ($mysql_access_host_array as $mysql_access_host) {
|
||||||
$_db = str_replace('`', '', $this->_data['mysql_database']);
|
$_db = str_replace('`', '', $this->_data['mysql_database']);
|
||||||
@@ -623,11 +646,11 @@ class FroxlorInstall
|
|||||||
"password" => $this->_data['mysql_unpriv_pass']
|
"password" => $this->_data['mysql_unpriv_pass']
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$db_root->query("FLUSH PRIVILEGES;");
|
$db_root->query("FLUSH PRIVILEGES;");
|
||||||
$this->_data['mysql_access_host'] = implode(',', $mysql_access_host_array);
|
$this->_data['mysql_access_host'] = implode(',', $mysql_access_host_array);
|
||||||
$content .= $this->_status_message('green', 'OK');
|
$content .= $this->_status_message('green', 'OK');
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -641,7 +664,7 @@ class FroxlorInstall
|
|||||||
private function _backupExistingDatabase(&$db_root)
|
private function _backupExistingDatabase(&$db_root)
|
||||||
{
|
{
|
||||||
$content = "";
|
$content = "";
|
||||||
|
|
||||||
// check for existing of former database
|
// check for existing of former database
|
||||||
$tables_exist = false;
|
$tables_exist = false;
|
||||||
$sql = "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = :database";
|
$sql = "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = :database";
|
||||||
@@ -650,19 +673,19 @@ class FroxlorInstall
|
|||||||
'database' => $this->_data['mysql_database']
|
'database' => $this->_data['mysql_database']
|
||||||
));
|
));
|
||||||
$rows = $db_root->query("SELECT FOUND_ROWS()")->fetchColumn();
|
$rows = $db_root->query("SELECT FOUND_ROWS()")->fetchColumn();
|
||||||
|
|
||||||
// check result
|
// check result
|
||||||
if ($result_stmt !== false && $rows > 0) {
|
if ($result_stmt !== false && $rows > 0) {
|
||||||
$tables_exist = true;
|
$tables_exist = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($tables_exist) {
|
if ($tables_exist) {
|
||||||
// tell whats going on
|
// tell whats going on
|
||||||
$content .= $this->_status_message('begin', $this->_lng['install']['backup_old_db']);
|
$content .= $this->_status_message('begin', $this->_lng['install']['backup_old_db']);
|
||||||
|
|
||||||
// create temporary backup-filename
|
// create temporary backup-filename
|
||||||
$filename = "/tmp/froxlor_backup_" . date('YmdHi') . ".sql";
|
$filename = "/tmp/froxlor_backup_" . date('YmdHi') . ".sql";
|
||||||
|
|
||||||
// look for mysqldump
|
// look for mysqldump
|
||||||
$do_backup = false;
|
$do_backup = false;
|
||||||
if (file_exists("/usr/bin/mysqldump")) {
|
if (file_exists("/usr/bin/mysqldump")) {
|
||||||
@@ -672,7 +695,7 @@ class FroxlorInstall
|
|||||||
$do_backup = true;
|
$do_backup = true;
|
||||||
$mysql_dump = '/usr/local/bin/mysqldump';
|
$mysql_dump = '/usr/local/bin/mysqldump';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($do_backup) {
|
if ($do_backup) {
|
||||||
$command = $mysql_dump . " " . $this->_data['mysql_database'] . " -u " . $this->_data['mysql_root_user'] . " --password='" . $this->_data['mysql_root_pass'] . "' --result-file=" . $filename;
|
$command = $mysql_dump . " " . $this->_data['mysql_database'] . " -u " . $this->_data['mysql_root_user'] . " --password='" . $this->_data['mysql_root_pass'] . "' --result-file=" . $filename;
|
||||||
$output = exec($command);
|
$output = exec($command);
|
||||||
@@ -685,7 +708,7 @@ class FroxlorInstall
|
|||||||
$content .= $this->_status_message('red', $this->_lng['install']['backup_binary_missing']);
|
$content .= $this->_status_message('red', $this->_lng['install']['backup_binary_missing']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -707,7 +730,7 @@ class FroxlorInstall
|
|||||||
}
|
}
|
||||||
// get language-form-template
|
// get language-form-template
|
||||||
eval("\$content .= \"" . $this->_getTemplate("lngform") . "\";");
|
eval("\$content .= \"" . $this->_getTemplate("lngform") . "\";");
|
||||||
|
|
||||||
// form-data
|
// form-data
|
||||||
$formdata = "";
|
$formdata = "";
|
||||||
/**
|
/**
|
||||||
@@ -747,7 +770,7 @@ class FroxlorInstall
|
|||||||
$style = '';
|
$style = '';
|
||||||
}
|
}
|
||||||
$formdata .= $this->_getSectionItemString('mysql_root_pass', true, $style, 'password');
|
$formdata .= $this->_getSectionItemString('mysql_root_pass', true, $style, 'password');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* admin data
|
* admin data
|
||||||
*/
|
*/
|
||||||
@@ -771,7 +794,7 @@ class FroxlorInstall
|
|||||||
$formdata .= $this->_getSectionItemString('admin_pass2', true, $style, 'password');
|
$formdata .= $this->_getSectionItemString('admin_pass2', true, $style, 'password');
|
||||||
// activate newsfeed?
|
// activate newsfeed?
|
||||||
$formdata .= $this->_getSectionItemYesNo('activate_newsfeed', true);
|
$formdata .= $this->_getSectionItemYesNo('activate_newsfeed', true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Server data
|
* Server data
|
||||||
*/
|
*/
|
||||||
@@ -818,11 +841,11 @@ class FroxlorInstall
|
|||||||
$style = '';
|
$style = '';
|
||||||
}
|
}
|
||||||
$formdata .= $this->_getSectionItemString('httpgroup', true, $style);
|
$formdata .= $this->_getSectionItemString('httpgroup', true, $style);
|
||||||
|
|
||||||
// get data-form-template
|
// get data-form-template
|
||||||
$language = htmlspecialchars($this->_activelng);
|
$language = htmlspecialchars($this->_activelng);
|
||||||
eval("\$content .= \"" . $this->_getTemplate("dataform2") . "\";");
|
eval("\$content .= \"" . $this->_getTemplate("dataform2") . "\";");
|
||||||
|
|
||||||
$navigation = '';
|
$navigation = '';
|
||||||
return array(
|
return array(
|
||||||
'pagecontent' => $content,
|
'pagecontent' => $content,
|
||||||
@@ -839,7 +862,7 @@ class FroxlorInstall
|
|||||||
* optional css
|
* optional css
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* optional type of input-box (default: text)
|
* optional type of input-box (default: text)
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function _getSectionItemString($fieldname = null, $required = false, $style = "", $type = 'text')
|
private function _getSectionItemString($fieldname = null, $required = false, $style = "", $type = 'text')
|
||||||
@@ -899,26 +922,26 @@ class FroxlorInstall
|
|||||||
*/
|
*/
|
||||||
private function _requirementCheck()
|
private function _requirementCheck()
|
||||||
{
|
{
|
||||||
|
|
||||||
// indicator whether we need to abort or not
|
// indicator whether we need to abort or not
|
||||||
$_die = false;
|
$_die = false;
|
||||||
|
|
||||||
$content = "<table class=\"noborder\">";
|
$content = "<table class=\"noborder\">";
|
||||||
|
|
||||||
// check for correct php version
|
// check for correct php version
|
||||||
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpversion']);
|
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpversion']);
|
||||||
|
|
||||||
if (version_compare("5.3.0", PHP_VERSION, ">=")) {
|
if (version_compare("5.3.0", PHP_VERSION, ">=")) {
|
||||||
$content .= $this->_status_message('red', $this->_lng['requirements']['notfound'] . ' (' . PHP_VERSION . ')');
|
$content .= $this->_status_message('red', $this->_lng['requirements']['notfound'] . ' (' . PHP_VERSION . ')');
|
||||||
$_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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if magic_quotes_runtime is active | get_magic_quotes_runtime() is always FALSE since 5.4
|
// Check if magic_quotes_runtime is active | get_magic_quotes_runtime() is always FALSE since 5.4
|
||||||
if (version_compare(PHP_VERSION, "5.4.0", "<")) {
|
if (version_compare(PHP_VERSION, "5.4.0", "<")) {
|
||||||
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpmagic_quotes_runtime']);
|
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpmagic_quotes_runtime']);
|
||||||
@@ -930,85 +953,85 @@ class FroxlorInstall
|
|||||||
$content .= $this->_status_message('green', 'off');
|
$content .= $this->_status_message('green', 'off');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for php_pdo and pdo_mysql
|
// check for php_pdo and pdo_mysql
|
||||||
$content .= $this->_status_message('begin', $this->_lng['requirements']['phppdo']);
|
$content .= $this->_status_message('begin', $this->_lng['requirements']['phppdo']);
|
||||||
|
|
||||||
if (! extension_loaded('pdo') || in_array("mysql", PDO::getAvailableDrivers()) == false) {
|
if (! extension_loaded('pdo') || in_array("mysql", PDO::getAvailableDrivers()) == false) {
|
||||||
$content .= $this->_status_message('red', $this->_lng['requirements']['notinstalled']);
|
$content .= $this->_status_message('red', $this->_lng['requirements']['notinstalled']);
|
||||||
$_die = true;
|
$_die = true;
|
||||||
} else {
|
} else {
|
||||||
$content .= $this->_status_message('green', $this->_lng['requirements']['installed']);
|
$content .= $this->_status_message('green', $this->_lng['requirements']['installed']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for xml-extension
|
// check for xml-extension
|
||||||
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpxml']);
|
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpxml']);
|
||||||
|
|
||||||
if (! extension_loaded('xml')) {
|
if (! extension_loaded('xml')) {
|
||||||
$content .= $this->_status_message('red', $this->_lng['requirements']['notinstalled']);
|
$content .= $this->_status_message('red', $this->_lng['requirements']['notinstalled']);
|
||||||
$_die = true;
|
$_die = true;
|
||||||
} else {
|
} else {
|
||||||
$content .= $this->_status_message('green', $this->_lng['requirements']['installed']);
|
$content .= $this->_status_message('green', $this->_lng['requirements']['installed']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for filter-extension
|
// check for filter-extension
|
||||||
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpfilter']);
|
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpfilter']);
|
||||||
|
|
||||||
if (! extension_loaded('filter')) {
|
if (! extension_loaded('filter')) {
|
||||||
$content .= $this->_status_message('red', $this->_lng['requirements']['notinstalled']);
|
$content .= $this->_status_message('red', $this->_lng['requirements']['notinstalled']);
|
||||||
$_die = true;
|
$_die = true;
|
||||||
} else {
|
} else {
|
||||||
$content .= $this->_status_message('green', $this->_lng['requirements']['installed']);
|
$content .= $this->_status_message('green', $this->_lng['requirements']['installed']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for posix-extension
|
// check for posix-extension
|
||||||
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpposix']);
|
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpposix']);
|
||||||
|
|
||||||
if (! extension_loaded('posix')) {
|
if (! extension_loaded('posix')) {
|
||||||
$content .= $this->_status_message('red', $this->_lng['requirements']['notinstalled']);
|
$content .= $this->_status_message('red', $this->_lng['requirements']['notinstalled']);
|
||||||
$_die = true;
|
$_die = true;
|
||||||
} else {
|
} else {
|
||||||
$content .= $this->_status_message('green', $this->_lng['requirements']['installed']);
|
$content .= $this->_status_message('green', $this->_lng['requirements']['installed']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for bstring-extension
|
// check for bstring-extension
|
||||||
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpmbstring']);
|
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpmbstring']);
|
||||||
|
|
||||||
if (! extension_loaded('mbstring')) {
|
if (! extension_loaded('mbstring')) {
|
||||||
$content .= $this->_status_message('red', $this->_lng['requirements']['notinstalled']);
|
$content .= $this->_status_message('red', $this->_lng['requirements']['notinstalled']);
|
||||||
$_die = true;
|
$_die = true;
|
||||||
} else {
|
} else {
|
||||||
$content .= $this->_status_message('green', $this->_lng['requirements']['installed']);
|
$content .= $this->_status_message('green', $this->_lng['requirements']['installed']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for curl extension
|
// check for curl extension
|
||||||
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpcurl']);
|
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpcurl']);
|
||||||
|
|
||||||
if (! extension_loaded('curl')) {
|
if (! extension_loaded('curl')) {
|
||||||
$content .= $this->_status_message('red', $this->_lng['requirements']['notinstalled']);
|
$content .= $this->_status_message('red', $this->_lng['requirements']['notinstalled']);
|
||||||
$_die = true;
|
$_die = true;
|
||||||
} else {
|
} else {
|
||||||
$content .= $this->_status_message('green', $this->_lng['requirements']['installed']);
|
$content .= $this->_status_message('green', $this->_lng['requirements']['installed']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for bcmath extension
|
// check for bcmath extension
|
||||||
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpbcmath']);
|
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpbcmath']);
|
||||||
|
|
||||||
if (! extension_loaded('bcmath')) {
|
if (! extension_loaded('bcmath')) {
|
||||||
$content .= $this->_status_message('orange', $this->_lng['requirements']['notinstalled'] . "<br />" . $this->_lng['requirements']['bcmathdescription']);
|
$content .= $this->_status_message('orange', $this->_lng['requirements']['notinstalled'] . "<br />" . $this->_lng['requirements']['bcmathdescription']);
|
||||||
} else {
|
} else {
|
||||||
$content .= $this->_status_message('green', $this->_lng['requirements']['installed']);
|
$content .= $this->_status_message('green', $this->_lng['requirements']['installed']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for zip extension
|
// check for zip extension
|
||||||
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpzip']);
|
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpzip']);
|
||||||
|
|
||||||
if (! extension_loaded('zip')) {
|
if (! extension_loaded('zip')) {
|
||||||
$content .= $this->_status_message('orange', $this->_lng['requirements']['notinstalled'] . "<br />" . $this->_lng['requirements']['zipdescription']);
|
$content .= $this->_status_message('orange', $this->_lng['requirements']['notinstalled'] . "<br />" . $this->_lng['requirements']['zipdescription']);
|
||||||
} else {
|
} else {
|
||||||
$content .= $this->_status_message('green', $this->_lng['requirements']['installed']);
|
$content .= $this->_status_message('green', $this->_lng['requirements']['installed']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for open_basedir
|
// check for open_basedir
|
||||||
$content .= $this->_status_message('begin', $this->_lng['requirements']['openbasedir']);
|
$content .= $this->_status_message('begin', $this->_lng['requirements']['openbasedir']);
|
||||||
$php_ob = @ini_get("open_basedir");
|
$php_ob = @ini_get("open_basedir");
|
||||||
@@ -1018,7 +1041,7 @@ class FroxlorInstall
|
|||||||
$content .= $this->_status_message('green', 'off');
|
$content .= $this->_status_message('green', 'off');
|
||||||
}
|
}
|
||||||
$content .= "</table>";
|
$content .= "</table>";
|
||||||
|
|
||||||
// check if we have unrecoverable errors
|
// check if we have unrecoverable errors
|
||||||
$navigation = '';
|
$navigation = '';
|
||||||
if ($_die) {
|
if ($_die) {
|
||||||
@@ -1033,7 +1056,7 @@ class FroxlorInstall
|
|||||||
$linktext = $this->_lng['click_here_to_continue'];
|
$linktext = $this->_lng['click_here_to_continue'];
|
||||||
}
|
}
|
||||||
eval("\$navigation .= \"" . $this->_getTemplate("pagebottom") . "\";");
|
eval("\$navigation .= \"" . $this->_getTemplate("pagebottom") . "\";");
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'pagecontent' => $content,
|
'pagecontent' => $content,
|
||||||
'pagenavigation' => $navigation
|
'pagenavigation' => $navigation
|
||||||
@@ -1050,7 +1073,7 @@ class FroxlorInstall
|
|||||||
header("Pragma: no-cache");
|
header("Pragma: no-cache");
|
||||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s \G\M\T', time()));
|
header('Last-Modified: ' . gmdate('D, d M Y H:i:s \G\M\T', time()));
|
||||||
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time()));
|
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time()));
|
||||||
|
|
||||||
// ensure that default timezone is set
|
// ensure that default timezone is set
|
||||||
if (function_exists("date_default_timezone_set") && function_exists("date_default_timezone_get")) {
|
if (function_exists("date_default_timezone_set") && function_exists("date_default_timezone_get")) {
|
||||||
@date_default_timezone_set(@date_default_timezone_get());
|
@date_default_timezone_set(@date_default_timezone_get());
|
||||||
@@ -1068,7 +1091,7 @@ class FroxlorInstall
|
|||||||
// includes the usersettings (MySQL-Username/Passwort)
|
// includes the usersettings (MySQL-Username/Passwort)
|
||||||
// to test if Froxlor is already installed
|
// to test if Froxlor is already installed
|
||||||
require $this->_basepath . '/lib/userdata.inc.php';
|
require $this->_basepath . '/lib/userdata.inc.php';
|
||||||
|
|
||||||
if (isset($sql) && is_array($sql)) {
|
if (isset($sql) && is_array($sql)) {
|
||||||
// use sparkle theme for the notice
|
// use sparkle theme for the notice
|
||||||
$installed_hint = file_get_contents($this->_basepath . '/templates/Sparkle/misc/alreadyinstalledhint.tpl');
|
$installed_hint = file_get_contents($this->_basepath . '/templates/Sparkle/misc/alreadyinstalledhint.tpl');
|
||||||
@@ -1085,7 +1108,7 @@ class FroxlorInstall
|
|||||||
{
|
{
|
||||||
// set default
|
// set default
|
||||||
$standardlanguage = 'english';
|
$standardlanguage = 'english';
|
||||||
|
|
||||||
// check either _GET or _POST
|
// check either _GET or _POST
|
||||||
if (isset($_GET['language']) && isset($this->_languages[$_GET['language']])) {
|
if (isset($_GET['language']) && isset($this->_languages[$_GET['language']])) {
|
||||||
$this->_activelng = $_GET['language'];
|
$this->_activelng = $_GET['language'];
|
||||||
@@ -1106,7 +1129,7 @@ class FroxlorInstall
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$lngfile = $this->_basepath . '/install/lng/' . $this->_activelng . '.lng.php';
|
$lngfile = $this->_basepath . '/install/lng/' . $this->_activelng . '.lng.php';
|
||||||
if (file_exists($lngfile)) {
|
if (file_exists($lngfile)) {
|
||||||
// includes file /lng/$language.lng.php if it exists
|
// includes file /lng/$language.lng.php if it exists
|
||||||
@@ -1120,7 +1143,7 @@ class FroxlorInstall
|
|||||||
*
|
*
|
||||||
* @param string $template
|
* @param string $template
|
||||||
* name of the template including subdirectory
|
* name of the template including subdirectory
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function _getTemplate($template = null)
|
private function _getTemplate($template = null)
|
||||||
@@ -1137,7 +1160,7 @@ class FroxlorInstall
|
|||||||
} else {
|
} else {
|
||||||
$templatefile = 'TEMPLATE NOT FOUND: ' . $filename;
|
$templatefile = 'TEMPLATE NOT FOUND: ' . $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $templatefile;
|
return $templatefile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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'] = '';
|
||||||
}
|
}
|
||||||
@@ -1294,17 +1316,17 @@ class FroxlorInstall
|
|||||||
*/
|
*/
|
||||||
private function _split_sql_file($sql, $delimiter)
|
private function _split_sql_file($sql, $delimiter)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Split up our string into "possible" SQL statements.
|
// Split up our string into "possible" SQL statements.
|
||||||
$tokens = explode($delimiter, $sql);
|
$tokens = explode($delimiter, $sql);
|
||||||
|
|
||||||
// try to save mem.
|
// try to save mem.
|
||||||
$sql = "";
|
$sql = "";
|
||||||
$output = array();
|
$output = array();
|
||||||
|
|
||||||
// we don't actually care about the matches preg gives us.
|
// we don't actually care about the matches preg gives us.
|
||||||
$matches = array();
|
$matches = array();
|
||||||
|
|
||||||
// this is faster than calling count($tokens) every time through the loop.
|
// this is faster than calling count($tokens) every time through the loop.
|
||||||
$token_count = count($tokens);
|
$token_count = count($tokens);
|
||||||
for ($i = 0; $i < $token_count; $i ++) {
|
for ($i = 0; $i < $token_count; $i ++) {
|
||||||
@@ -1312,12 +1334,12 @@ class FroxlorInstall
|
|||||||
if (($i != ($token_count - 1)) || (strlen($tokens[$i] > 0))) {
|
if (($i != ($token_count - 1)) || (strlen($tokens[$i] > 0))) {
|
||||||
// This is the total number of single quotes in the token.
|
// This is the total number of single quotes in the token.
|
||||||
$total_quotes = preg_match_all("/'/", $tokens[$i], $matches);
|
$total_quotes = preg_match_all("/'/", $tokens[$i], $matches);
|
||||||
|
|
||||||
// Counts single quotes that are preceded by an odd number of backslashes,
|
// Counts single quotes that are preceded by an odd number of backslashes,
|
||||||
// which means they're escaped quotes.
|
// which means they're escaped quotes.
|
||||||
$escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$i], $matches);
|
$escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$i], $matches);
|
||||||
$unescaped_quotes = $total_quotes - $escaped_quotes;
|
$unescaped_quotes = $total_quotes - $escaped_quotes;
|
||||||
|
|
||||||
// If the number of unescaped quotes is even, then the delimiter
|
// If the number of unescaped quotes is even, then the delimiter
|
||||||
// did NOT occur inside a string literal.
|
// did NOT occur inside a string literal.
|
||||||
if (($unescaped_quotes % 2) == 0) {
|
if (($unescaped_quotes % 2) == 0) {
|
||||||
@@ -1340,7 +1362,7 @@ class FroxlorInstall
|
|||||||
// which means they're escaped quotes.
|
// which means they're escaped quotes.
|
||||||
$escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$j], $matches);
|
$escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$j], $matches);
|
||||||
$unescaped_quotes = $total_quotes - $escaped_quotes;
|
$unescaped_quotes = $total_quotes - $escaped_quotes;
|
||||||
|
|
||||||
if (($unescaped_quotes % 2) == 1) {
|
if (($unescaped_quotes % 2) == 1) {
|
||||||
// odd number of unescaped quotes. In combination with the previous incomplete
|
// odd number of unescaped quotes. In combination with the previous incomplete
|
||||||
// statement(s), we now have a complete statement. (2 odds always make an even)
|
// statement(s), we now have a complete statement. (2 odds always make an even)
|
||||||
|
|||||||
Reference in New Issue
Block a user