require php-curl

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2016-04-11 08:00:38 +02:00
parent 252b42ee57
commit 72d1282651
4 changed files with 296 additions and 277 deletions

View File

@@ -30,10 +30,12 @@
* @package Install * @package Install
* *
*/ */
class FroxlorInstall { class FroxlorInstall
{
/** /**
* define froxlor basepath e.g. /var/www/froxlor * define froxlor basepath e.g.
* /var/www/froxlor
* *
* @var string * @var string
*/ */
@@ -71,6 +73,7 @@ class FroxlorInstall {
/** /**
* currently used language * currently used language
*
* @var unknown * @var unknown
*/ */
private $_activelng = 'english'; private $_activelng = 'english';
@@ -78,7 +81,8 @@ class FroxlorInstall {
/** /**
* Class constructor * Class constructor
*/ */
public function __construct() { public function __construct()
{
$this->_basepath = dirname(dirname(dirname(__FILE__))); $this->_basepath = dirname(dirname(dirname(__FILE__)));
$this->_data = array(); $this->_data = array();
} }
@@ -86,7 +90,8 @@ class FroxlorInstall {
/** /**
* FC * FC
*/ */
public function run() { public function run()
{
// send headers // send headers
$this->_sendHeaders(); $this->_sendHeaders();
// check if we have a valid installation already // check if we have a valid installation already
@@ -104,15 +109,13 @@ class FroxlorInstall {
/** /**
* build up and show the install-process-pages * build up and show the install-process-pages
*/ */
private function _showPage() { private function _showPage()
{
// set theme for templates // set theme for templates
$theme = $this->_theme; $theme = $this->_theme;
eval("echo \"" . $this->_getTemplate("header") . "\";"); eval("echo \"" . $this->_getTemplate("header") . "\";");
// check install-state // check install-state
if ((isset($_POST['installstep']) if ((isset($_POST['installstep']) && $_POST['installstep'] == '1') || (isset($_GET['check']) && $_GET['check'] == '1')) {
&& $_POST['installstep'] == '1')
|| (isset($_GET['check']) && $_GET['check'] == '1')
) {
$pagetitle = $this->_lng['install']['title']; $pagetitle = $this->_lng['install']['title'];
if ($this->_checkPostData()) { if ($this->_checkPostData()) {
// ceck data and create userdata etc.etc.etc. // ceck data and create userdata etc.etc.etc.
@@ -146,7 +149,8 @@ class FroxlorInstall {
* *
* @return boolean * @return boolean
*/ */
private function _checkPostData() { private function _checkPostData()
{
$this->_guessServerName(); $this->_guessServerName();
$this->_guessServerIP(); $this->_guessServerIP();
$this->_guessWebserver(); $this->_guessWebserver();
@@ -166,9 +170,7 @@ class FroxlorInstall {
$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' if ($this->_data['mysql_host'] == 'localhost' || $this->_data['mysql_host'] == '127.0.0.1') {
|| $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'];
@@ -179,19 +181,7 @@ class FroxlorInstall {
$this->_data['servername'] = ''; $this->_data['servername'] = '';
} }
if (isset($_POST['installstep']) 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']) {
&& $_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;
} }
return false; return false;
@@ -202,31 +192,31 @@ class FroxlorInstall {
* *
* @return array * @return array
*/ */
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('PDO::MYSQL_ATTR_INIT_COMMAND' => 'set names utf8'); $options = array(
'PDO::MYSQL_ATTR_INIT_COMMAND' => 'set names utf8'
);
$dsn = "mysql:host=" . $this->_data['mysql_host'] . ";"; $dsn = "mysql:host=" . $this->_data['mysql_host'] . ";";
$fatal_fail = false; $fatal_fail = false;
try { try {
$db_root = new PDO( $db_root = new PDO($dsn, $this->_data['mysql_root_user'], $this->_data['mysql_root_pass'], $options);
$dsn, $this->_data['mysql_root_user'], $this->_data['mysql_root_pass'], $options
);
} catch (PDOException $e) { } catch (PDOException $e) {
// possibly without passwd? // possibly without passwd?
try { try {
$db_root = new PDO( $db_root = new PDO($dsn, $this->_data['mysql_root_user'], '', $options);
$dsn, $this->_data['mysql_root_user'], '', $options
);
// set the given password // set the given password
$passwd_stmt = $db_root->prepare(" $passwd_stmt = $db_root->prepare("
SET PASSWORD = PASSWORD(:passwd) SET PASSWORD = PASSWORD(:passwd)
"); ");
$passwd_stmt->execute(array('passwd' => $this->_data['mysql_root_pass'])); $passwd_stmt->execute(array(
'passwd' => $this->_data['mysql_root_pass']
));
} catch (PDOException $e) { } catch (PDOException $e) {
// nope // nope
$content .= $this->_status_message('red', $e->getMessage()); $content .= $this->_status_message('red', $e->getMessage());
@@ -245,18 +235,19 @@ class FroxlorInstall {
// importing data to new database // importing data to new database
$content .= $this->_importDatabaseData(); $content .= $this->_importDatabaseData();
// create DB object for new database // create DB object for new database
$options = array('PDO::MYSQL_ATTR_INIT_COMMAND' => 'set names utf8'); $options = array(
'PDO::MYSQL_ATTR_INIT_COMMAND' => 'set names utf8'
);
$dsn = "mysql:host=" . $this->_data['mysql_host'] . ";dbname=" . $this->_data['mysql_database'] . ";"; $dsn = "mysql:host=" . $this->_data['mysql_host'] . ";dbname=" . $this->_data['mysql_database'] . ";";
$another_fail = false; $another_fail = false;
try { try {
$db = new PDO( $db = new PDO($dsn, $this->_data['mysql_unpriv_user'], $this->_data['mysql_unpriv_pass'], $options);
$dsn, $this->_data['mysql_unpriv_user'], $this->_data['mysql_unpriv_pass'], $options
);
} catch (PDOException $e) { } catch (PDOException $e) {
// dafuq? this should have happened in _importDatabaseData() // dafuq? this should have happened in _importDatabaseData()
$content .= $this->_status_message('red', $e->getMessage()); $content .= $this->_status_message('red', $e->getMessage());
$another_fail = true; $another_fail = true;
}; }
;
if (! $another_fail) { if (! $another_fail) {
// change settings accordingly // change settings accordingly
@@ -290,14 +281,17 @@ class FroxlorInstall {
eval("\$navigation .= \"" . $this->_getTemplate("pagebottom") . "\";"); eval("\$navigation .= \"" . $this->_getTemplate("pagebottom") . "\";");
return array('pagecontent' => $content, 'pagenavigation' => $navigation); return array(
'pagecontent' => $content,
'pagenavigation' => $navigation
);
} }
/** /**
* Create userdata.inc.php file * Create userdata.inc.php file
*/ */
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']);
@@ -319,8 +313,7 @@ class FroxlorInstall {
@fclose($fp); @fclose($fp);
$content .= $this->_status_message('green', 'OK'); $content .= $this->_status_message('green', 'OK');
chmod('../lib/userdata.inc.php', 0440); chmod('../lib/userdata.inc.php', 0440);
} } elseif ($fp = @fopen('/tmp/userdata.inc.php', 'w')) {
elseif ($fp = @fopen('/tmp/userdata.inc.php', 'w')) {
$result = @fputs($fp, $userdata, strlen($userdata)); $result = @fputs($fp, $userdata, strlen($userdata));
@fclose($fp); @fclose($fp);
$content .= $this->_status_message('orange', $this->_lng['install']['creating_configfile_temp']); $content .= $this->_status_message('orange', $this->_lng['install']['creating_configfile_temp']);
@@ -341,8 +334,8 @@ class FroxlorInstall {
* *
* @return string status messages * @return string status messages
*/ */
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']);
@@ -356,7 +349,9 @@ class FroxlorInstall {
`vhostcontainer` = '1', `vhostcontainer` = '1',
`vhostcontainer_servername_statement` = '1' `vhostcontainer_servername_statement` = '1'
"); ");
$stmt->execute(array('serverip' => $this->_data['serverip'])); $stmt->execute(array(
'serverip' => $this->_data['serverip']
));
$defaultip = $db->lastInsertId(); $defaultip = $db->lastInsertId();
// insert the defaultip // insert the defaultip
@@ -365,7 +360,9 @@ class FroxlorInstall {
`value` = :defaultip `value` = :defaultip
WHERE `settinggroup` = 'system' AND `varname` = 'defaultip' WHERE `settinggroup` = 'system' AND `varname` = 'defaultip'
"); ");
$upd_stmt->execute(array('defaultip' => $defaultip)); $upd_stmt->execute(array(
'defaultip' => $defaultip
));
$content .= $this->_status_message('green', 'OK'); $content .= $this->_status_message('green', 'OK');
@@ -419,7 +416,8 @@ class FroxlorInstall {
* @param string $varname * @param string $varname
* @param string $value * @param string $value
*/ */
private function _updateSetting(&$stmt = null, $value = null, $group = null, $varname = null) { private function _updateSetting(&$stmt = null, $value = null, $group = null, $varname = null)
{
$stmt->execute(array( $stmt->execute(array(
'group' => $group, 'group' => $group,
'varname' => $varname, 'varname' => $varname,
@@ -434,8 +432,8 @@ class FroxlorInstall {
* *
* @return string status messages * @return string status messages
*/ */
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']);
@@ -502,21 +500,22 @@ class FroxlorInstall {
* *
* @return string status messages * @return string status messages
*/ */
private function _importDatabaseData() { private function _importDatabaseData()
{
$content = ""; $content = "";
$content .= $this->_status_message('begin', $this->_lng['install']['testing_new_db']); $content .= $this->_status_message('begin', $this->_lng['install']['testing_new_db']);
$options = array('PDO::MYSQL_ATTR_INIT_COMMAND' => 'set names utf8'); $options = array(
'PDO::MYSQL_ATTR_INIT_COMMAND' => 'set names utf8'
);
$dsn = "mysql:host=" . $this->_data['mysql_host'] . ";dbname=" . $this->_data['mysql_database'] . ";"; $dsn = "mysql:host=" . $this->_data['mysql_host'] . ";dbname=" . $this->_data['mysql_database'] . ";";
$fatal_fail = false; $fatal_fail = false;
try { try {
$db = new PDO( $db = new PDO($dsn, $this->_data['mysql_unpriv_user'], $this->_data['mysql_unpriv_pass'], $options);
$dsn, $this->_data['mysql_unpriv_user'], $this->_data['mysql_unpriv_pass'], $options
);
} 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) {
@@ -547,8 +546,8 @@ class FroxlorInstall {
* *
* @return string status messages * @return string status messages
*/ */
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
@@ -556,16 +555,28 @@ class FroxlorInstall {
$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('user' => $this->_data['mysql_unpriv_user'], 'accesshost' => $this->_data['mysql_access_host'])); $del_stmt->execute(array(
'user' => $this->_data['mysql_unpriv_user'],
'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('user' => $this->_data['mysql_unpriv_user'], 'accesshost' => $this->_data['mysql_access_host'])); $del_stmt->execute(array(
'user' => $this->_data['mysql_unpriv_user'],
'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('user' => $this->_data['mysql_unpriv_user'], 'accesshost' => $this->_data['mysql_access_host'])); $del_stmt->execute(array(
'user' => $this->_data['mysql_unpriv_user'],
'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('user' => $this->_data['mysql_unpriv_user'], 'accesshost' => $this->_data['mysql_access_host'])); $del_stmt->execute(array(
'user' => $this->_data['mysql_unpriv_user'],
'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();
@@ -580,15 +591,11 @@ class FroxlorInstall {
$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) if (in_array('127.0.0.1', $mysql_access_host_array) && ! in_array('localhost', $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) if (! in_array('127.0.0.1', $mysql_access_host_array) && in_array('localhost', $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';
} }
@@ -598,11 +605,17 @@ class FroxlorInstall {
$stmt = $db_root->prepare(" $stmt = $db_root->prepare("
GRANT ALL PRIVILEGES ON `" . $_db . "`.* GRANT ALL PRIVILEGES ON `" . $_db . "`.*
TO :username@:host TO :username@:host
IDENTIFIED BY 'password'" IDENTIFIED BY 'password'");
); $stmt->execute(array(
$stmt->execute(array("username" => $this->_data['mysql_unpriv_user'], "host" => $mysql_access_host)); "username" => $this->_data['mysql_unpriv_user'],
"host" => $mysql_access_host
));
$stmt = $db_root->prepare("SET PASSWORD FOR :username@:host = PASSWORD(:password)"); $stmt = $db_root->prepare("SET PASSWORD FOR :username@:host = PASSWORD(:password)");
$stmt->execute(array("username" => $this->_data['mysql_unpriv_user'], "host" => $mysql_access_host, "password" => $this->_data['mysql_unpriv_pass'])); $stmt->execute(array(
"username" => $this->_data['mysql_unpriv_user'],
"host" => $mysql_access_host,
"password" => $this->_data['mysql_unpriv_pass']
));
} }
$db_root->query("FLUSH PRIVILEGES;"); $db_root->query("FLUSH PRIVILEGES;");
@@ -619,15 +632,17 @@ class FroxlorInstall {
* *
* @return string status messages * @return string status messages
*/ */
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";
$result_stmt = $db_root->prepare($sql); $result_stmt = $db_root->prepare($sql);
$result_stmt->execute(array('database' => $this->_data['mysql_database'])); $result_stmt->execute(array(
'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
@@ -671,8 +686,8 @@ class FroxlorInstall {
/** /**
* show form to collect all needed data for the install * show form to collect all needed data for the install
*/ */
private function _showDataForm() { private function _showDataForm()
{
$content = ""; $content = "";
// form action // form action
$formaction = htmlspecialchars($_SERVER['PHP_SELF']); $formaction = htmlspecialchars($_SERVER['PHP_SELF']);
@@ -701,25 +716,29 @@ class FroxlorInstall {
// unpriv-user has to be different from root // unpriv-user has to be different from root
if ($this->_data['mysql_unpriv_user'] == $this->_data['mysql_root_user']) { if ($this->_data['mysql_unpriv_user'] == $this->_data['mysql_root_user']) {
$style = 'blue'; $style = 'blue';
} else { $style = ''; } else {
$style = '';
} }
$formdata .= $this->_getSectionItemString('mysql_unpriv_user', true, $style); $formdata .= $this->_getSectionItemString('mysql_unpriv_user', true, $style);
// is we posted and no password was given -> red // is we posted and no password was given -> red
if (! empty($_POST['installstep']) && $this->_data['mysql_unpriv_pass'] == '') { if (! empty($_POST['installstep']) && $this->_data['mysql_unpriv_pass'] == '') {
$style = 'red'; $style = 'red';
} else { $style = ''; } else {
$style = '';
} }
$formdata .= $this->_getSectionItemString('mysql_unpriv_pass', true, $style, 'password'); $formdata .= $this->_getSectionItemString('mysql_unpriv_pass', true, $style, 'password');
// unpriv-user has to be different from root // unpriv-user has to be different from root
if ($this->_data['mysql_unpriv_user'] == $this->_data['mysql_root_user']) { if ($this->_data['mysql_unpriv_user'] == $this->_data['mysql_root_user']) {
$style = 'blue'; $style = 'blue';
} else { $style = ''; } else {
$style = '';
} }
$formdata .= $this->_getSectionItemString('mysql_root_user', true, $style); $formdata .= $this->_getSectionItemString('mysql_root_user', true, $style);
// is we posted and no password was given -> red // is we posted and no password was given -> red
if (! empty($_POST['installstep']) && $this->_data['mysql_root_pass'] == '') { if (! empty($_POST['installstep']) && $this->_data['mysql_root_pass'] == '') {
$style = 'red'; $style = 'red';
} else { $style = ''; } else {
$style = '';
} }
$formdata .= $this->_getSectionItemString('mysql_root_pass', true, $style, 'password'); $formdata .= $this->_getSectionItemString('mysql_root_pass', true, $style, 'password');
@@ -731,21 +750,17 @@ class FroxlorInstall {
// user // user
$formdata .= $this->_getSectionItemString('admin_user', true); $formdata .= $this->_getSectionItemString('admin_user', true);
// check for admin passwords to be equal // check for admin passwords to be equal
if (!empty($_POST['installstep']) && if (! empty($_POST['installstep']) && ($this->_data['admin_pass1'] == '' || $this->_data['admin_pass1'] != $this->_data['admin_pass2'])) {
($this->_data['admin_pass1'] == ''
|| $this->_data['admin_pass1'] != $this->_data['admin_pass2'])
) {
$style = 'color:red;'; $style = 'color:red;';
} else { $style = ''; } else {
$style = '';
} }
$formdata .= $this->_getSectionItemString('admin_pass1', true, $style, 'password'); $formdata .= $this->_getSectionItemString('admin_pass1', true, $style, 'password');
// check for admin passwords to be equal // check for admin passwords to be equal
if (!empty($_POST['installstep']) && if (! empty($_POST['installstep']) && ($this->_data['admin_pass2'] == '' || $this->_data['admin_pass1'] != $this->_data['admin_pass2'])) {
($this->_data['admin_pass2'] == ''
|| $this->_data['admin_pass1'] != $this->_data['admin_pass2'])
) {
$style = 'color:red;'; $style = 'color:red;';
} else { $style = ''; } else {
$style = '';
} }
$formdata .= $this->_getSectionItemString('admin_pass2', true, $style, 'password'); $formdata .= $this->_getSectionItemString('admin_pass2', true, $style, 'password');
// activate newsfeed? // activate newsfeed?
@@ -759,19 +774,22 @@ class FroxlorInstall {
// servername // servername
if (! empty($_POST['installstep']) && $this->_data['servername'] == '') { if (! empty($_POST['installstep']) && $this->_data['servername'] == '') {
$style = 'color:red;'; $style = 'color:red;';
} else { $style = ''; } else {
$style = '';
} }
$formdata .= $this->_getSectionItemString('servername', true, $style); $formdata .= $this->_getSectionItemString('servername', true, $style);
// serverip // serverip
if (! empty($_POST['installstep']) && $this->_data['serverip'] == '') { if (! empty($_POST['installstep']) && $this->_data['serverip'] == '') {
$style = 'color:red;'; $style = 'color:red;';
} else { $style = ''; } else {
$style = '';
} }
$formdata .= $this->_getSectionItemString('serverip', true, $style); $formdata .= $this->_getSectionItemString('serverip', true, $style);
// webserver // webserver
if (! empty($_POST['installstep']) && $this->_data['webserver'] == '') { if (! empty($_POST['installstep']) && $this->_data['webserver'] == '') {
$websrvstyle = 'color:red;'; $websrvstyle = 'color:red;';
} else { $websrvstyle = ''; } else {
$websrvstyle = '';
} }
// apache // apache
$formdata .= $this->_getSectionItemCheckbox('apache2', ($this->_data['webserver'] == 'apache2'), $websrvstyle); $formdata .= $this->_getSectionItemCheckbox('apache2', ($this->_data['webserver'] == 'apache2'), $websrvstyle);
@@ -783,13 +801,15 @@ class FroxlorInstall {
// webserver-user // webserver-user
if (! empty($_POST['installstep']) && $this->_data['httpuser'] == '') { if (! empty($_POST['installstep']) && $this->_data['httpuser'] == '') {
$style = 'color:red;'; $style = 'color:red;';
} else { $style = ''; } else {
$style = '';
} }
$formdata .= $this->_getSectionItemString('httpuser', true, $style); $formdata .= $this->_getSectionItemString('httpuser', true, $style);
// webserver-group // webserver-group
if (! empty($_POST['installstep']) && $this->_data['httpgroup'] == '') { if (! empty($_POST['installstep']) && $this->_data['httpgroup'] == '') {
$style = 'color:red;'; $style = 'color:red;';
} else { $style = ''; } else {
$style = '';
} }
$formdata .= $this->_getSectionItemString('httpgroup', true, $style); $formdata .= $this->_getSectionItemString('httpgroup', true, $style);
@@ -798,7 +818,10 @@ class FroxlorInstall {
eval("\$content .= \"" . $this->_getTemplate("dataform2") . "\";"); eval("\$content .= \"" . $this->_getTemplate("dataform2") . "\";");
$navigation = ''; $navigation = '';
return array('pagecontent' => $content, 'pagenavigation' => $navigation); return array(
'pagecontent' => $content,
'pagenavigation' => $navigation
);
} }
/** /**
@@ -806,12 +829,15 @@ class FroxlorInstall {
* *
* @param string $fieldname * @param string $fieldname
* @param boolean $required * @param boolean $required
* @param string $style optional css * @param string $style
* @param string $type optional type of input-box (default: text) * optional css
* @param string $type
* 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')
{
$fieldlabel = $this->_lng['install'][$fieldname]; $fieldlabel = $this->_lng['install'][$fieldname];
$fieldvalue = htmlspecialchars($this->_data[$fieldname]); $fieldvalue = htmlspecialchars($this->_data[$fieldname]);
if ($required) { if ($required) {
@@ -831,7 +857,8 @@ class FroxlorInstall {
* *
* @return string * @return string
*/ */
private function _getSectionItemCheckbox($fieldname = null, $checked = false, $style = "") { private function _getSectionItemCheckbox($fieldname = null, $checked = false, $style = "")
{
$fieldlabel = $this->_lng['install'][$fieldname]; $fieldlabel = $this->_lng['install'][$fieldname];
if ($checked) { if ($checked) {
$checked = 'checked="checked"'; $checked = 'checked="checked"';
@@ -850,7 +877,8 @@ class FroxlorInstall {
* *
* @return string * @return string
*/ */
private function _getSectionItemYesNo($fieldname = null, $checked = false, $style = "") { private function _getSectionItemYesNo($fieldname = null, $checked = false, $style = "")
{
$fieldlabel = $this->_lng['install'][$fieldname]; $fieldlabel = $this->_lng['install'][$fieldname];
if ($checked) { if ($checked) {
$checked = 'checked="checked"'; $checked = 'checked="checked"';
@@ -863,7 +891,8 @@ class FroxlorInstall {
/** /**
* check for requirements froxlor needs * check for requirements froxlor needs
*/ */
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;
@@ -942,6 +971,16 @@ class FroxlorInstall {
$content .= $this->_status_message('green', $this->_lng['requirements']['installed']); $content .= $this->_status_message('green', $this->_lng['requirements']['installed']);
} }
// check for curl extension
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpcurl']);
if (! extension_loaded('curl')) {
$content .= $this->_status_message('red', $this->_lng['requirements']['notinstalled']);
$_die = true;
} else {
$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']);
@@ -951,15 +990,6 @@ class FroxlorInstall {
$content .= $this->_status_message('green', $this->_lng['requirements']['installed']); $content .= $this->_status_message('green', $this->_lng['requirements']['installed']);
} }
// check for curl extension
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpcurl']);
if (!extension_loaded('curl')) {
$content .= $this->_status_message('orange', $this->_lng['requirements']['notinstalled'] . "<br />" . $this->_lng['requirements']['curldescription']);
} else {
$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");
@@ -985,13 +1015,17 @@ class FroxlorInstall {
} }
eval("\$navigation .= \"" . $this->_getTemplate("pagebottom") . "\";"); eval("\$navigation .= \"" . $this->_getTemplate("pagebottom") . "\";");
return array('pagecontent' => $content, 'pagenavigation' => $navigation); return array(
'pagecontent' => $content,
'pagenavigation' => $navigation
);
} }
/** /**
* send no-caching headers and set the default timezone * send no-caching headers and set the default timezone
*/ */
private function _sendHeaders() { private function _sendHeaders()
{
// no caching // no caching
header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: no-store, no-cache, must-revalidate");
header("Pragma: no-cache"); header("Pragma: no-cache");
@@ -999,9 +1033,7 @@ class FroxlorInstall {
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") if (function_exists("date_default_timezone_set") && function_exists("date_default_timezone_get")) {
&& function_exists("date_default_timezone_get")
) {
@date_default_timezone_set(@date_default_timezone_get()); @date_default_timezone_set(@date_default_timezone_get());
} }
} }
@@ -1010,16 +1042,15 @@ class FroxlorInstall {
* check for the userdata - if it exists then froxlor is * check for the userdata - if it exists then froxlor is
* already installed and we show a nice note * already installed and we show a nice note
*/ */
private function _checkUserDataFile() { private function _checkUserDataFile()
{
$userdata = $this->_basepath . '/lib/userdata.inc.php'; $userdata = $this->_basepath . '/lib/userdata.inc.php';
if (file_exists($userdata)) { if (file_exists($userdata)) {
// 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) if (isset($sql) && is_array($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');
$installed_hint = str_replace("<CURRENT_YEAR>", date('Y', time()), $installed_hint); $installed_hint = str_replace("<CURRENT_YEAR>", date('Y', time()), $installed_hint);
@@ -1031,18 +1062,15 @@ class FroxlorInstall {
/** /**
* include the chose language or else default (english) * include the chose language or else default (english)
*/ */
private function _includeLanguageFile() { private function _includeLanguageFile()
{
// set default // set default
$standardlanguage = 'english'; $standardlanguage = 'english';
// check either _GET or _POST // check either _GET or _POST
if (isset($_GET['language']) if (isset($_GET['language']) && isset($this->_languages[$_GET['language']])) {
&& isset($this->_languages[$_GET['language']])
) {
$this->_activelng = $_GET['language']; $this->_activelng = $_GET['language'];
} elseif (isset($_POST['language']) } elseif (isset($_POST['language']) && isset($this->_languages[$_POST['language']])) {
&& isset($this->_languages[$_POST['language']])
) {
$this->_activelng = $_POST['language']; $this->_activelng = $_POST['language'];
} else { } else {
// try to guess the right language // try to guess the right language
@@ -1071,17 +1099,17 @@ class FroxlorInstall {
/** /**
* Get template from filesystem * Get template from filesystem
* *
* @param string $template name of the template including subdirectory * @param string $template
* name of the template including subdirectory
* *
* @return string * @return string
*/ */
private function _getTemplate($template = null) { private function _getTemplate($template = null)
{
// build filename // build filename
$filename = $this->_basepath . '/install/templates/' . $template . '.tpl'; $filename = $this->_basepath . '/install/templates/' . $template . '.tpl';
// check existence // check existence
if(file_exists($filename) if (file_exists($filename) && is_readable($filename)) {
&& is_readable($filename)
) {
$templatefile = addcslashes(file_get_contents($filename), '"\\'); $templatefile = addcslashes(file_get_contents($filename), '"\\');
// loop through template more than once in case we have an "if"-statement in another one // loop through template more than once in case we have an "if"-statement in another one
while (preg_match('/<if[ \t]*(.*)>(.*)(<\/if>|<else>(.*)<\/if>)/Uis', $templatefile)) { while (preg_match('/<if[ \t]*(.*)>(.*)(<\/if>|<else>(.*)<\/if>)/Uis', $templatefile)) {
@@ -1102,7 +1130,8 @@ class FroxlorInstall {
* *
* @return string * @return string
*/ */
private function _status_message($case, $text) { private function _status_message($case, $text)
{
if ($case == 'begin') { if ($case == 'begin') {
return '<tr><td class="install-step">' . $text; return '<tr><td class="install-step">' . $text;
} else { } else {
@@ -1113,13 +1142,15 @@ class FroxlorInstall {
/** /**
* get/guess servername * get/guess servername
*/ */
private function _guessServerName() { private function _guessServerName()
{
// from form? // from form?
if (! empty($_POST['servername'])) { if (! empty($_POST['servername'])) {
$this->_data['servername'] = $_POST['servername']; $this->_data['servername'] = $_POST['servername'];
return; return;
// from $_SERVER // from $_SERVER
} else if (!empty($_SERVER['SERVER_NAME'])) { } else
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'];
@@ -1133,7 +1164,8 @@ class FroxlorInstall {
/** /**
* get/guess serverip * get/guess serverip
*/ */
private function _guessServerIP() { private function _guessServerIP()
{
// from form // from form
if (! empty($_POST['serverip'])) { if (! empty($_POST['serverip'])) {
$this->_data['serverip'] = $_POST['serverip']; $this->_data['serverip'] = $_POST['serverip'];
@@ -1150,22 +1182,17 @@ class FroxlorInstall {
/** /**
* get/guess webserver-software * get/guess webserver-software
*/ */
private function _guessWebserver() { private function _guessWebserver()
{
// post // post
if (! empty($_POST['webserver'])) { if (! empty($_POST['webserver'])) {
$this->_data['webserver'] = $_POST['webserver']; $this->_data['webserver'] = $_POST['webserver'];
} else { } else {
if (strtoupper(@php_sapi_name()) == "APACHE2HANDLER" if (strtoupper(@php_sapi_name()) == "APACHE2HANDLER" || stristr($_SERVER['SERVER_SOFTWARE'], "apache/2")) {
|| stristr($_SERVER['SERVER_SOFTWARE'], "apache/2")
) {
$this->_data['webserver'] = 'apache2'; $this->_data['webserver'] = 'apache2';
} elseif(substr(strtoupper(@php_sapi_name()), 0, 8) == "LIGHTTPD" } elseif (substr(strtoupper(@php_sapi_name()), 0, 8) == "LIGHTTPD" || stristr($_SERVER['SERVER_SOFTWARE'], "lighttpd")) {
|| stristr($_SERVER['SERVER_SOFTWARE'], "lighttpd")
) {
$this->_data['webserver'] = 'lighttpd'; $this->_data['webserver'] = 'lighttpd';
} elseif(substr(strtoupper(@php_sapi_name()), 0, 8) == "NGINX" } elseif (substr(strtoupper(@php_sapi_name()), 0, 8) == "NGINX" || stristr($_SERVER['SERVER_SOFTWARE'], "nginx")) {
|| stristr($_SERVER['SERVER_SOFTWARE'], "nginx")
) {
$this->_data['webserver'] = 'nginx'; $this->_data['webserver'] = 'nginx';
} else { } else {
// we don't need to bail out, since unknown does not affect any critical installation routines // we don't need to bail out, since unknown does not affect any critical installation routines
@@ -1182,7 +1209,8 @@ class FroxlorInstall {
* @param string $default * @param string $default
* *
*/ */
private function _getPostField($fieldname = null, $default = null) { private function _getPostField($fieldname = null, $default = null)
{
// initialize // initialize
$this->_data[$fieldname] = ''; $this->_data[$fieldname] = '';
// set default // set default
@@ -1202,11 +1230,9 @@ class FroxlorInstall {
* *
* @return boolean|string * @return boolean|string
*/ */
private function _validate_ip($ip = null) { private function _validate_ip($ip = null)
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false {
&& filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false && filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false && filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE) === false) {
&& filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE) === false
) {
return false; return false;
} }
return $ip; return $ip;
@@ -1219,17 +1245,15 @@ class FroxlorInstall {
* *
* @return string * @return string
*/ */
private function _remove_remarks($sql) { private function _remove_remarks($sql)
{
$lines = explode("\n", $sql); $lines = explode("\n", $sql);
// try to keep mem. use down // try to keep mem. use down
$sql = ""; $sql = "";
$linecount = count($lines); $linecount = count($lines);
$output = ""; $output = "";
for ($i = 0; $i < $linecount; $i ++) { for ($i = 0; $i < $linecount; $i ++) {
if ($i != ($linecount - 1) if ($i != ($linecount - 1) || strlen($lines[$i]) > 0) {
|| strlen($lines[$i]) > 0
) {
if (substr($lines[$i], 0, 1) != "#") { if (substr($lines[$i], 0, 1) != "#") {
$output .= $lines[$i] . "\n"; $output .= $lines[$i] . "\n";
} else { } else {
@@ -1249,7 +1273,8 @@ class FroxlorInstall {
* The whole function has been taken from the phpbb installer, * The whole function has been taken from the phpbb installer,
* copyright by the phpbb team, phpbb in summer 2004. * copyright by the phpbb team, phpbb in summer 2004.
*/ */
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);
@@ -1265,9 +1290,7 @@ class FroxlorInstall {
$token_count = count($tokens); $token_count = count($tokens);
for ($i = 0; $i < $token_count; $i ++) { for ($i = 0; $i < $token_count; $i ++) {
// Don't want to add an empty string as the last thing in the array. // Don't want to add an empty string as the last thing in the array.
if (($i != ($token_count - 1)) if (($i != ($token_count - 1)) || (strlen($tokens[$i] > 0))) {
|| (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);
@@ -1323,5 +1346,4 @@ class FroxlorInstall {
} }
return $output; return $output;
} }
} }

View File

@@ -34,7 +34,6 @@ $lng['requirements']['phpbcmath'] = 'PHP bcmath-extension...';
$lng['requirements']['phpcurl'] = 'PHP curl-extension...'; $lng['requirements']['phpcurl'] = 'PHP curl-extension...';
$lng['requirements']['phpmbstring'] = 'PHP mbstring-extension...'; $lng['requirements']['phpmbstring'] = 'PHP mbstring-extension...';
$lng['requirements']['bcmathdescription'] = 'Traffic-calculation related functions will not work correctly!'; $lng['requirements']['bcmathdescription'] = 'Traffic-calculation related functions will not work correctly!';
$lng['requirements']['curldescription'] = 'Version-check and news-feed may not work correctly!';
$lng['requirements']['openbasedir'] = 'open_basedir...'; $lng['requirements']['openbasedir'] = 'open_basedir...';
$lng['requirements']['openbasedirenabled'] = 'Froxlor will not work properly with open_basedir enabled. Please disable open_basedir for Froxlor in the coresponding php.ini'; $lng['requirements']['openbasedirenabled'] = 'Froxlor will not work properly with open_basedir enabled. Please disable open_basedir for Froxlor in the coresponding php.ini';
$lng['requirements']['diedbecauseofrequirements'] = 'Cannot install Froxlor without these requirements! Try to fix them and retry.'; $lng['requirements']['diedbecauseofrequirements'] = 'Cannot install Froxlor without these requirements! Try to fix them and retry.';

View File

@@ -34,7 +34,6 @@ $lng['requirements']['phpbcmath'] = 'extension PHP bcmath ...';
$lng['requirements']['phpcurl'] = 'extension PHP curl...'; $lng['requirements']['phpcurl'] = 'extension PHP curl...';
$lng['requirements']['phpmbstring'] = 'extension PHP mbstring...'; $lng['requirements']['phpmbstring'] = 'extension PHP mbstring...';
$lng['requirements']['bcmathdescription'] = 'Les fonctions de calcul de traffic ne fonctionneront pas correctement!'; $lng['requirements']['bcmathdescription'] = 'Les fonctions de calcul de traffic ne fonctionneront pas correctement!';
$lng['requirements']['curldescription'] = 'Les vérifications de version et les flux d\'information peuvent ne pas fonctionner correctement!';
$lng['requirements']['openbasedir'] = 'open_basedir...'; $lng['requirements']['openbasedir'] = 'open_basedir...';
$lng['requirements']['openbasedirenabled'] = 'Froxlor ne fonctionnera pas correctement avec open_basedir activé. Merci de désactiver open_basedir pour Froxlor dans le php.ini correspondant'; $lng['requirements']['openbasedirenabled'] = 'Froxlor ne fonctionnera pas correctement avec open_basedir activé. Merci de désactiver open_basedir pour Froxlor dans le php.ini correspondant';
$lng['requirements']['diedbecauseofrequirements'] = 'Impossible d\'installer Froxlor sans ces prérequis! Essayez de les corriger et essayez à nouveau.'; $lng['requirements']['diedbecauseofrequirements'] = 'Impossible d\'installer Froxlor sans ces prérequis! Essayez de les corriger et essayez à nouveau.';

View File

@@ -34,7 +34,6 @@ $lng['requirements']['phpbcmath'] = 'PHP bcmath-Erweiterung...';
$lng['requirements']['phpcurl'] = 'PHP curl-Erweiterung...'; $lng['requirements']['phpcurl'] = 'PHP curl-Erweiterung...';
$lng['requirements']['phpmbstring'] = 'PHP mbstring-Erweiterung...'; $lng['requirements']['phpmbstring'] = 'PHP mbstring-Erweiterung...';
$lng['requirements']['bcmathdescription'] = 'Traffic-Berechnungs bezogene Funktionen stehen nicht vollständig zur Verfügung!'; $lng['requirements']['bcmathdescription'] = 'Traffic-Berechnungs bezogene Funktionen stehen nicht vollständig zur Verfügung!';
$lng['requirements']['curldescription'] = 'Versions-Prüfung und News-Feed stehen nicht vollständig zur Verfügung!';
$lng['requirements']['openbasedir'] = 'open_basedir genutzt wird...'; $lng['requirements']['openbasedir'] = 'open_basedir genutzt wird...';
$lng['requirements']['openbasedirenabled'] = 'Froxlor wird mit aktiviertem open_basedir nicht vollständig funktionieren. Bitte deaktivieren Sie open_basedir für Froxlor in der entsprechenden php.ini'; $lng['requirements']['openbasedirenabled'] = 'Froxlor wird mit aktiviertem open_basedir nicht vollständig funktionieren. Bitte deaktivieren Sie open_basedir für Froxlor in der entsprechenden php.ini';
$lng['requirements']['diedbecauseofrequirements'] = 'Kann Froxlor ohne diese Voraussetzungen nicht installieren! Beheben Sie die angezeigten Probleme und versuchen Sie es erneut.'; $lng['requirements']['diedbecauseofrequirements'] = 'Kann Froxlor ohne diese Voraussetzungen nicht installieren! Beheben Sie die angezeigten Probleme und versuchen Sie es erneut.';