Merge branch 'master' of git://github.com/Froxlor/Froxlor
This commit is contained in:
@@ -1415,7 +1415,7 @@ if ($page == 'customers'
|
||||
// Disable or enable IMAP Login for customers Mail Accounts
|
||||
if ($email_imap != $result['imap']) {
|
||||
$upd_stmt = Database::prepare("UPDATE `" . TABLE_MAIL_USERS . "` SET `imap` = :imap WHERE `customerid` = :customerid");
|
||||
Database::pexecute($upd_stmt, array('pop3' => $email_imap, 'customerid' => $id));
|
||||
Database::pexecute($upd_stmt, array('imap' => $email_imap, 'customerid' => $id));
|
||||
}
|
||||
|
||||
$upd_data = array(
|
||||
|
||||
@@ -143,7 +143,6 @@ if ($page == 'overview') {
|
||||
|
||||
if ($result['popaccountid'] != 0) {
|
||||
// Free the Quota used by the email account
|
||||
|
||||
if ($settings['system']['mail_quota_enabled'] == 1) {
|
||||
$stmt = Database::prepare("SELECT `quota` FROM `" . TABLE_MAIL_USERS . "`
|
||||
WHERE `customerid`= :customerid
|
||||
@@ -167,7 +166,8 @@ if ($page == 'overview') {
|
||||
}
|
||||
|
||||
if (isset($_POST['delete_userfiles'])
|
||||
&& (int)$_POST['delete_userfiles'] == 1) {
|
||||
&& (int)$_POST['delete_userfiles'] == 1
|
||||
) {
|
||||
inserttask('7', $userinfo['loginname'], $result['email_full']);
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ if ($page == 'overview') {
|
||||
$log->logAction(USR_ACTION, LOG_INFO, "deleted email address '" . $result['email'] . "'");
|
||||
redirectTo($filename, array('page' => $page, 's' => $s));
|
||||
} else {
|
||||
if (maildirExists($result)) {
|
||||
if ($result['popaccountid'] != '0') {
|
||||
$show_checkbox = true;
|
||||
} else {
|
||||
$show_checkbox = false;
|
||||
@@ -403,12 +403,17 @@ if ($page == 'overview') {
|
||||
} elseif ($page == 'accounts') {
|
||||
if ($action == 'add' && $id != 0) {
|
||||
// ensure the int is a positive one
|
||||
|
||||
if (isset($_POST['email_quota'])) {
|
||||
$quota = validate($_POST['email_quota'], 'email_quota', '/^\d+$/', 'vmailquotawrong');
|
||||
}
|
||||
|
||||
if ($userinfo['email_accounts'] == '-1' || ($userinfo['email_accounts_used'] < $userinfo['email_accounts'])) {
|
||||
|
||||
// check for imap||pop3 == 1, see #1298
|
||||
if ($userinfo['imap'] != '1' && $userinfo['pop3'] != '1') {
|
||||
standard_error('notallowedtouseaccounts');
|
||||
}
|
||||
|
||||
$stmt = Database::prepare("SELECT `id`, `email`, `email_full`, `iscatchall`, `destination`, `customerid`, `popaccountid`, `domainid` FROM `" . TABLE_MAIL_VIRTUAL . "`
|
||||
WHERE `customerid`= :cid
|
||||
AND `id`= :id"
|
||||
|
||||
@@ -207,12 +207,29 @@ class FroxlorInstall {
|
||||
// check for mysql-root-connection
|
||||
$content .= $this->_status_message('begin', $this->_lng['install']['testing_mysql']);
|
||||
|
||||
$db_root = new db(
|
||||
$this->_data['mysql_host'],
|
||||
$this->_data['mysql_root_user'],
|
||||
$this->_data['mysql_root_pass'],
|
||||
''
|
||||
);
|
||||
$options = array('PDO::MYSQL_ATTR_INIT_COMMAND' => 'set names utf8');
|
||||
$dsn = "mysql:host=".$this->_data['mysql_host'].";";
|
||||
try {
|
||||
$db_root = new PDO(
|
||||
$dsn, $this->_data['mysql_root_user'], $this->_data['mysql_root_pass'], $options
|
||||
);
|
||||
} catch (PDOException $e) {
|
||||
// possibly without passwd?
|
||||
try {
|
||||
$db_root = new PDO(
|
||||
$dsn, $this->_data['mysql_root_user'], '', $options
|
||||
);
|
||||
// set the given password
|
||||
$passwd_stmt = $db_root->prepare("
|
||||
SET PASSWORD = PASSWORD(:passwd)
|
||||
");
|
||||
$passwd_stmt->execute(array('passwd' => $this->_data['mysql_root_pass']));
|
||||
} catch (PDOException $e) {
|
||||
// nope
|
||||
$content .= $this->_status_message('red', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ok, if we are here, the database class is build up
|
||||
// (otherwise it would have already die'd this script)
|
||||
$content .= $this->_status_message('green', "OK");
|
||||
@@ -223,18 +240,25 @@ class FroxlorInstall {
|
||||
// importing data to new database
|
||||
$content .= $this->_importDatabaseData();
|
||||
// create DB object for new database
|
||||
$db = new db(
|
||||
$this->_data['mysql_host'],
|
||||
$this->_data['mysql_unpriv_user'],
|
||||
$this->_data['mysql_unpriv_pass'],
|
||||
$this->_data['mysql_database']
|
||||
);
|
||||
$options = array('PDO::MYSQL_ATTR_INIT_COMMAND' => 'set names utf8');
|
||||
$dsn = "mysql:host=".$this->_data['mysql_host'].";dbname=".$this->_data['mysql_database'].";";
|
||||
try {
|
||||
$db = new PDO(
|
||||
$dsn, $this->_data['mysql_unpriv_user'], $this->_data['mysql_unpriv_pass'], $options
|
||||
);
|
||||
} catch (PDOException $e) {
|
||||
// dafuq? this should have happened in _importDatabaseData()
|
||||
$content .= $this->_status_message('red', $e->getMessage());
|
||||
die;
|
||||
};
|
||||
|
||||
// change settings accordingly
|
||||
$content .= $this->_doSettings($db);
|
||||
// create entries
|
||||
$content .= $this->_doDataEntries($db);
|
||||
$db = null;
|
||||
// create config-file
|
||||
$content .= $this->_createUserdataConf($db);
|
||||
$content .= $this->_createUserdataConf();
|
||||
|
||||
$content .= "</table>";
|
||||
|
||||
@@ -305,31 +329,42 @@ class FroxlorInstall {
|
||||
$content .= $this->_status_message('begin', $this->_lng['install']['creating_entries']);
|
||||
|
||||
// and lets insert the default ip and port
|
||||
$query = "INSERT INTO `".TABLE_PANEL_IPSANDPORTS."`
|
||||
SET `ip`= '".$db->escape($this->_data['serverip'])."',
|
||||
`port` = '80',
|
||||
`namevirtualhost_statement` = '1',
|
||||
`vhostcontainer` = '1',
|
||||
`vhostcontainer_servername_statement` = '1'";
|
||||
$db->query($query);
|
||||
$defaultip = $db->insert_id();
|
||||
$stmt = $db->prepare("
|
||||
INSERT INTO `".TABLE_PANEL_IPSANDPORTS."` SET
|
||||
`ip`= :serverip,
|
||||
`port` = '80',
|
||||
`namevirtualhost_statement` = '1',
|
||||
`vhostcontainer` = '1',
|
||||
`vhostcontainer_servername_statement` = '1'
|
||||
");
|
||||
$stmt->execute(array('serverip' => $this->_data['serverip']));
|
||||
$defaultip = $db->lastInsertId();
|
||||
|
||||
// insert the defaultip
|
||||
$query = "UPDATE `".TABLE_PANEL_SETTINGS."`
|
||||
SET `value` = '".$defaultip."'
|
||||
WHERE `settinggroup` = 'system' AND `varname` = 'defaultip'";
|
||||
$db->query($query);
|
||||
$upd_stmt = $db->prepare("
|
||||
UPDATE `".TABLE_PANEL_SETTINGS."` SET
|
||||
`value` = :defaultip
|
||||
WHERE `settinggroup` = 'system' AND `varname` = 'defaultip'
|
||||
");
|
||||
$upd_stmt->execute(array('defaultip' => $defaultip));
|
||||
|
||||
$content .= $this->_status_message('green', 'OK');
|
||||
|
||||
//last but not least create the main admin
|
||||
$content .= $this->_status_message('begin', $this->_lng['install']['adding_admin_user']);
|
||||
$db->query("INSERT INTO `" . TABLE_PANEL_ADMINS . "` SET
|
||||
`loginname` = '" . $db->escape($this->_data['admin_user']) . "',
|
||||
`password` = '" . md5($this->_data['admin_pass1']) . "',
|
||||
$ins_data = array(
|
||||
'loginname' => $this->_data['admin_user'],
|
||||
'password' => md5($this->_data['admin_pass1']),
|
||||
'email' => 'admin@' . $this->_data['servername'],
|
||||
'deflang' => $this->_languages[$this->_activelng]
|
||||
);
|
||||
$ins_stmt = $db->prepare("
|
||||
INSERT INTO `" . TABLE_PANEL_ADMINS . "` SET
|
||||
`loginname` = :loginname,
|
||||
`password` = :password,
|
||||
`name` = 'Froxlor-Administrator',
|
||||
`email` = 'admin@" . $db->escape($this->_data['servername']) . "',
|
||||
`def_language` = '". $db->escape($this->_languages[$this->_activelng]) . "',
|
||||
`email` = :email,
|
||||
`def_language` = :deflang,
|
||||
`customers` = -1,
|
||||
`customers_see_all` = 1,
|
||||
`caneditphpsettings` = 1,
|
||||
@@ -352,11 +387,29 @@ class FroxlorInstall {
|
||||
`email_autoresponder` = -1
|
||||
");
|
||||
|
||||
$ins_stmt->execute($ins_data);
|
||||
|
||||
$content .= $this->_status_message('green', 'OK');
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* execute prepared statement to update settings
|
||||
*
|
||||
* @param PDOStatement $stmt
|
||||
* @param string $group
|
||||
* @param string $varname
|
||||
* @param string $value
|
||||
*/
|
||||
private function _updateSetting(&$stmt = null, $value = null, $group = null, $varname = null) {
|
||||
$stmt->exceute(array(
|
||||
'group' => $group,
|
||||
'varname' => $varname,
|
||||
'value' => $value
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* change settings according to users input
|
||||
*
|
||||
@@ -369,36 +422,40 @@ class FroxlorInstall {
|
||||
$content = "";
|
||||
|
||||
$content .= $this->_status_message('begin', $this->_lng['install']['changing_data']);
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = 'admin@" . $db->escape($this->_data['servername']) . "' WHERE `settinggroup` = 'panel' AND `varname` = 'adminmail'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '" . $db->escape($this->_data['serverip']) . "' WHERE `settinggroup` = 'system' AND `varname` = 'ipaddress'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '" . $db->escape($this->_data['servername']) . "' WHERE `settinggroup` = 'system' AND `varname` = 'hostname'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '" . $db->escape($this->_languages[$this->_activelng]) . "' WHERE `settinggroup` = 'panel' AND `varname` = 'standardlanguage'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '" . $db->escape($this->_data['mysql_access_host']) . "' WHERE `settinggroup` = 'system' AND `varname` = 'mysql_access_host'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '" . $db->escape($this->_data['webserver']) . "' WHERE `settinggroup` = 'system' AND `varname` = 'webserver'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '" . $db->escape($this->_data['httpuser']) . "' WHERE `settinggroup` = 'system' AND `varname` = 'httpuser'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '" . $db->escape($this->_data['httpgroup']) . "' WHERE `settinggroup` = 'system' AND `varname` = 'httpgroup'");
|
||||
$upd_stmt = $db->prepare("
|
||||
UPDATE `" . TABLE_PANEL_SETTINGS . "` SET
|
||||
`value` = :value
|
||||
WHERE `settinggroup` = :group AND `varname` = :varname
|
||||
");
|
||||
|
||||
$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['servername'], 'system', 'hostname');
|
||||
$this->_updateSetting($upd_stmt, $this->_languages[$this->_activelng], 'panel', 'standardlanguage');
|
||||
$this->_updateSetting($upd_stmt, $this->_data['mysql_access_host'], 'system', 'mysql_access_host');
|
||||
$this->_updateSetting($upd_stmt, $this->_data['webserver'], 'system', 'webserver');
|
||||
$this->_updateSetting($upd_stmt, $this->_data['httpuser'], 'system', 'httpuser');
|
||||
$this->_updateSetting($upd_stmt, $this->_data['httpgroup'], 'system', 'httpgroup');
|
||||
|
||||
// necessary changes for webservers != apache2
|
||||
if ($this->_data['webserver'] == "lighttpd") {
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '/etc/lighttpd/conf-enabled/' WHERE `settinggroup` = 'system' AND `varname` = 'apacheconf_vhost'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '/etc/lighttpd/froxlor-diroptions/' WHERE `settinggroup` = 'system' AND `varname` = 'apacheconf_diroptions'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '/etc/lighttpd/froxlor-htpasswd/' WHERE `settinggroup` = 'system' AND `varname` = 'apacheconf_htpasswddir'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '/etc/init.d/lighttpd reload' WHERE `settinggroup` = 'system' AND `varname` = 'apachereload_command'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '/etc/lighttpd/lighttpd.pem' WHERE `settinggroup` = 'system' AND `varname` = 'ssl_cert_file'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '/var/run/lighttpd/' WHERE `settinggroup` = 'phpfpm' AND `varname` = 'fastcgi_ipcdir'");
|
||||
$this->_updateSetting($upd_stmt, '/etc/lighttpd/conf-enabled/', 'system', 'apacheconf_vhost');
|
||||
$this->_updateSetting($upd_stmt, '/etc/lighttpd/froxlor-diroptions/', 'system', 'apacheconf_diroptions');
|
||||
$this->_updateSetting($upd_stmt, '/etc/lighttpd/froxlor-htpasswd/', 'system', 'apacheconf_htpasswddir');
|
||||
$this->_updateSetting($upd_stmt, '/etc/init.d/lighttpd reload', 'system', 'apachereload_command');
|
||||
$this->_updateSetting($upd_stmt, '/etc/lighttpd/lighttpd.pem', 'system', 'ssl_cert_file');
|
||||
$this->_updateSetting($upd_stmt, '/var/run/lighttpd/', 'phpfpm', 'fastcgi_ipcdir');
|
||||
} elseif ($this->_data['webserver'] == "nginx") {
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '/etc/nginx/sites-enabled/' WHERE `settinggroup` = 'system' AND `varname` = 'apacheconf_vhost'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '/etc/nginx/sites-enabled/' WHERE `settinggroup` = 'system' AND `varname` = 'apacheconf_diroptions'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '/etc/nginx/froxlor-htpasswd/' WHERE `settinggroup` = 'system' AND `varname` = 'apacheconf_htpasswddir'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '/etc/init.d/nginx reload' WHERE `settinggroup` = 'system' AND `varname` = 'apachereload_command'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '/etc/nginx/nginx.pem' WHERE `settinggroup` = 'system' AND `varname` = 'ssl_cert_file'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '/var/run/nginx/' WHERE `settinggroup` = 'phpfpm' AND `varname` = 'fastcgi_ipcdir'");
|
||||
$this->_updateSetting($upd_stmt, '/etc/nginx/sites-enabled/', 'system', 'apacheconf_vhost');
|
||||
$this->_updateSetting($upd_stmt, '/etc/nginx/sites-enabled/', 'system', 'apacheconf_diroptions');
|
||||
$this->_updateSetting($upd_stmt, '/etc/nginx/froxlor-htpasswd/', 'system', 'apacheconf_htpasswddir');
|
||||
$this->_updateSetting($upd_stmt, '/etc/init.d/nginx reload', 'system', 'apachereload_command');
|
||||
$this->_updateSetting($upd_stmt, '/etc/nginx/nginx.pem', 'system', 'ssl_cert_file');
|
||||
$this->_updateSetting($upd_stmt, '/var/run/nginx/', 'phpfpm', 'fastcgi_ipcdir');
|
||||
}
|
||||
|
||||
// insert the lastcronrun to be the installation date
|
||||
$query = "UPDATE `".TABLE_PANEL_SETTINGS."` SET `value` = UNIX_TIMESTAMP()
|
||||
WHERE `settinggroup` = 'system' AND `varname` = 'lastcronrun'";
|
||||
$db->query($query);
|
||||
$this->_updateSetting($upd_stmt, time(), 'system', 'lastcronrun');
|
||||
|
||||
// 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()));
|
||||
@@ -423,12 +480,16 @@ class FroxlorInstall {
|
||||
$content = "";
|
||||
|
||||
$content .= $this->_status_message('begin', $this->_lng['install']['testing_new_db']);
|
||||
$db = new db(
|
||||
$this->_data['mysql_host'],
|
||||
$this->_data['mysql_unpriv_user'],
|
||||
$this->_data['mysql_unpriv_pass'],
|
||||
$this->_data['mysql_database']
|
||||
);
|
||||
$options = array('PDO::MYSQL_ATTR_INIT_COMMAND' => 'set names utf8');
|
||||
$dsn = "mysql:host=".$this->_data['mysql_host'].";dbname=".$this->_data['mysql_database'].";";
|
||||
try {
|
||||
$db = new PDO(
|
||||
$dsn, $this->_data['mysql_unpriv_user'], $this->_data['mysql_unpriv_pass'], $options
|
||||
);
|
||||
} catch (PDOException $e) {
|
||||
$content .= $this->_status_message('red', $e->getMessage());
|
||||
die;
|
||||
};
|
||||
$content .= $this->_status_message('green', 'OK');
|
||||
|
||||
$content .= $this->_status_message('begin', $this->_lng['install']['importing_data']);
|
||||
@@ -441,7 +502,7 @@ class FroxlorInstall {
|
||||
$result = $db->query($sql_query[$i]);
|
||||
}
|
||||
}
|
||||
$db->close();
|
||||
$db = null;
|
||||
|
||||
$content .= $this->_status_message('green', 'OK');
|
||||
}
|
||||
@@ -460,17 +521,30 @@ class FroxlorInstall {
|
||||
// so first we have to delete the database and
|
||||
// the user given for the unpriv-user if they exit
|
||||
$content .= $this->_status_message('begin', $this->_lng['install']['prepare_db']);
|
||||
$db_root->query("DELETE FROM `mysql`.`user` WHERE `User` = '" . $db_root->escape($this->_data['mysql_unpriv_user']) . "' AND `Host` = '" . $db_root->escape($this->_data['mysql_access_host']) . "'");
|
||||
$db_root->query("DELETE FROM `mysql`.`db` WHERE `User` = '" . $db_root->escape($this->_data['mysql_unpriv_user']) . "' AND `Host` = '" . $db_root->escape($this->_data['mysql_access_host']) . "'");
|
||||
$db_root->query("DELETE FROM `mysql`.`tables_priv` WHERE `User` = '" . $db_root->escape($this->_data['mysql_unpriv_user']) . "' AND `Host` = '" . $db_root->escape($this->_data['mysql_access_host']) . "'");
|
||||
$db_root->query("DELETE FROM `mysql`.`columns_priv` WHERE `User` = '" . $db_root->escape($this->_data['mysql_unpriv_user']) . "' AND `Host` = '" . $db_root->escape($this->_data['mysql_access_host']) . "'");
|
||||
$db_root->query("DROP DATABASE IF EXISTS `" . $db_root->escape(str_replace('`', '', $this->_data['mysql_database'])) . "` ;");
|
||||
|
||||
$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 = $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 = $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 = $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 = $db_root->prepare("DROP DATABASE IF EXISTS :database;");
|
||||
$del_stmt->execute(array('database' => str_replace('`', '', $this->_data['mysql_database'])));
|
||||
|
||||
$db_root->query("FLUSH PRIVILEGES;");
|
||||
$content .= $this->_status_message('green', 'OK');
|
||||
|
||||
// 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']);
|
||||
$db_root->query("CREATE DATABASE `" . $db_root->escape(str_replace('`', '', $this->_data['mysql_database'])) . "`");
|
||||
$ins_stmt = $db_root->prepare("CREATE DATABASE :database");
|
||||
$ins_stmt->execute(array('database' => str_replace('`', '', $this->_data['mysql_database'])));
|
||||
|
||||
$mysql_access_host_array = array_map('trim', explode(',', $this->_data['mysql_access_host']));
|
||||
|
||||
if (in_array('127.0.0.1', $mysql_access_host_array)
|
||||
@@ -487,8 +561,15 @@ class FroxlorInstall {
|
||||
|
||||
$mysql_access_host_array[] = $this->_data['serverip'];
|
||||
foreach ($mysql_access_host_array as $mysql_access_host) {
|
||||
$db_root->query("GRANT ALL PRIVILEGES ON `" . $db_root->escape(str_replace('`', '', $this->_data['mysql_database'])) . "`.* TO '" . $db_root->escape($this->_data['mysql_unpriv_user']) . "'@'" . $db_root->escape($mysql_access_host) . "' IDENTIFIED BY 'password'");
|
||||
$db_root->query("SET PASSWORD FOR '" . $db_root->escape($this->_data['mysql_unpriv_user']) . "'@'" . $db_root->escape($mysql_access_host) . "' = PASSWORD('" . $db_root->escape($this->_data['mysql_unpriv_pass']) . "')");
|
||||
$_db = str_replace('`', '', $this->_data['mysql_database']);
|
||||
$stmt = $db_root->prepare("
|
||||
GRANT ALL PRIVILEGES ON `" . $_db . "`.*
|
||||
TO :username@:host
|
||||
IDENTIFIED BY 'password'"
|
||||
);
|
||||
$stmt->execute(array("username" => $this->_data['mysql_unpriv_user'], "host" => $mysql_access_host));
|
||||
$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']));
|
||||
}
|
||||
|
||||
$db_root->query("FLUSH PRIVILEGES;");
|
||||
@@ -511,11 +592,13 @@ class FroxlorInstall {
|
||||
|
||||
// check for existing of former database
|
||||
$tables_exist = false;
|
||||
$sql = "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '".$this->_data['mysql_database']."'";
|
||||
$result = $db_root->query($sql);
|
||||
$sql = "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = :database";
|
||||
$result_stmt = $db_root->prepare($sql);
|
||||
$result_stmt->execute(array('database' => $this->_data['mysql_database']));
|
||||
$rows = $db_root->query("SELECT FOUND_ROWS()")->fetchColumn();
|
||||
|
||||
// check result
|
||||
if ($result !== false && $db_root->num_rows($result) > 0) {
|
||||
if ($result !== false && $rows > 0) {
|
||||
$tables_exist = true;
|
||||
}
|
||||
|
||||
@@ -752,17 +835,6 @@ class FroxlorInstall {
|
||||
$content .= $this->_status_message('green', 'off');
|
||||
}
|
||||
|
||||
// check for mysql-extension
|
||||
// @FIXME mysql extension will soon be deprecated and removed!!!
|
||||
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpmysql']);
|
||||
|
||||
if (!extension_loaded('mysql') && !extension_loaded('mysqlnd')) {
|
||||
$content .= $this->_status_message('red', $this->_lng['requirements']['notinstalled']);
|
||||
$_die = true;
|
||||
} else {
|
||||
$content .= $this->_status_message('green', $this->_lng['requirements']['installed']);
|
||||
}
|
||||
|
||||
// check for php_pdo and pdo_mysql
|
||||
$content .= $this->_status_message('begin', $this->_lng['requirements']['phppdo']);
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ $lng['requirements']['activated'] = 'enabled';
|
||||
$lng['requirements']['phpversion'] = 'PHP version >= 5.2';
|
||||
$lng['requirements']['phpmagic_quotes_runtime'] = 'magic_quotes_runtime...';
|
||||
$lng['requirements']['phpmagic_quotes_runtime_description'] = 'PHP setting "magic_quotes_runtime" must be set to "Off". We have disabled it temporary for now please fix the coresponding php.ini.';
|
||||
$lng['requirements']['phpmysql'] = 'MySQL-extension...';
|
||||
$lng['requirements']['phppdo'] = 'PHP PDO extension and PDO-MySQL driver...';
|
||||
$lng['requirements']['phpxml'] = 'PHP XML-extension...';
|
||||
$lng['requirements']['phpfilter'] = 'PHP filter-extension...';
|
||||
|
||||
@@ -26,7 +26,6 @@ $lng['requirements']['activated'] = 'ist aktiviert.';
|
||||
$lng['requirements']['phpversion'] = 'PHP Version >= 5.2';
|
||||
$lng['requirements']['phpmagic_quotes_runtime'] = 'magic_quotes_runtime';
|
||||
$lng['requirements']['phpmagic_quotes_runtime_description'] = 'Die PHP Einstellung "magic_quotes_runtime" muss deaktiviert sein ("Off"). Die Einstellung wurde temporär deaktiviert, bitte ändern Sie diese in der entsprechenden php.ini.';
|
||||
$lng['requirements']['phpmysql'] = 'PHP MySQL-Erweiterung...';
|
||||
$lng['requirements']['phppdo'] = 'PHP PDO Erweiterung und PDO-MySQL Treiber...';
|
||||
$lng['requirements']['phpxml'] = 'PHP XML-Erweiterung...';
|
||||
$lng['requirements']['phpfilter'] = 'PHP filter-Erweiterung...';
|
||||
|
||||
@@ -1,321 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2003-2009 the SysCP Team (see authors).
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* For the full copyright and license information, please view the COPYING
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Florian Lippert <flo@syscp.org> (2003-2009)
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Classes
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class to manage the connection to the Database
|
||||
* @package Functions
|
||||
*/
|
||||
class db {
|
||||
|
||||
/**
|
||||
* Link ID for every connection
|
||||
* @var int
|
||||
*/
|
||||
public $link_id = 0;
|
||||
|
||||
/**
|
||||
* Query ID for every query
|
||||
* @var int
|
||||
*/
|
||||
private $query_id = 0;
|
||||
|
||||
/**
|
||||
* Errordescription, if an error occures
|
||||
* @var string
|
||||
*/
|
||||
public $errdesc = '';
|
||||
|
||||
/**
|
||||
* Errornumber, if an error occures
|
||||
* @var int
|
||||
*/
|
||||
public $errno = 0;
|
||||
|
||||
/**
|
||||
* Servername
|
||||
* @var string
|
||||
*/
|
||||
private $server = '';
|
||||
|
||||
/**
|
||||
* Username
|
||||
* @var string
|
||||
*/
|
||||
private $user = '';
|
||||
|
||||
/**
|
||||
* Password
|
||||
* @var string
|
||||
*/
|
||||
private $password = '';
|
||||
|
||||
/**
|
||||
* Database
|
||||
* @var string
|
||||
*/
|
||||
private $database = '';
|
||||
|
||||
/**
|
||||
* Class constructor. Connects to Databaseserver and selects Database
|
||||
*
|
||||
* @param string Servername
|
||||
* @param string Username
|
||||
* @param string Password
|
||||
* @param string Database
|
||||
*/
|
||||
public function __construct($server, $user, $password, $database = '') {
|
||||
|
||||
// check for mysql extension
|
||||
if (!extension_loaded('mysql')) {
|
||||
$this->_showerror('You should install the PHP MySQL extension!', false);
|
||||
}
|
||||
|
||||
$this->server = $server;
|
||||
$this->user = $user;
|
||||
$this->password = $password;
|
||||
$this->database = $database;
|
||||
$this->link_id = @mysql_connect($this->server, $this->user, $this->password, 1);
|
||||
|
||||
if (!$this->link_id) {
|
||||
|
||||
//try to connect with no password and change it afterwards. only for root user
|
||||
if ($this->user == 'root') {
|
||||
$this->link_id = @mysql_connect($this->server, $this->user, '', 1);
|
||||
|
||||
if ($this->link_id) {
|
||||
$this->query("SET PASSWORD = PASSWORD('" . $this->escape($this->password) . "')");
|
||||
} else {
|
||||
$this->_showerror('Establishing connection failed, exiting');
|
||||
}
|
||||
} else {
|
||||
$this->_showerror('Establishing connection failed, exiting');
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->database != '') {
|
||||
if (!@mysql_select_db($this->database, $this->link_id)) {
|
||||
$this->_showerror('Trying to use database ' . $this->database . ' failed, exiting');
|
||||
}
|
||||
}
|
||||
|
||||
mysql_set_charset('utf8', $this->link_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes connection to Databaseserver
|
||||
*/
|
||||
public function close() {
|
||||
return @mysql_close($this->link_id);
|
||||
}
|
||||
|
||||
public function getDbName() {
|
||||
return $this->database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes user input to be used in mysql queries
|
||||
*
|
||||
* @param string $input
|
||||
* @return string escaped string
|
||||
*/
|
||||
public function escape($input) {
|
||||
if (is_int($input)) {
|
||||
return (int)$input;
|
||||
} elseif(is_float($input)) {
|
||||
return (float)$input;
|
||||
} else {
|
||||
return mysql_real_escape_string($input, $this->link_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the Database
|
||||
*
|
||||
* @param string Querystring
|
||||
* @param bool Unbuffered query?
|
||||
* @return string RessourceId
|
||||
*/
|
||||
public function query($query_str, $unbuffered = false, $suppress_error = false) {
|
||||
|
||||
global $numbqueries, $theme;
|
||||
|
||||
// check if connection is still alive
|
||||
if (!mysql_ping($this->link_id)) {
|
||||
$this->link_id = mysql_connect($this->server,$this->user,$this->password);
|
||||
if (!$this->database) {
|
||||
return false;
|
||||
}
|
||||
mysql_select_db($this->database);
|
||||
}
|
||||
|
||||
if (!$unbuffered) {
|
||||
if ($suppress_error) {
|
||||
$this->query_id = @mysql_query($query_str, $this->link_id);
|
||||
} else {
|
||||
$this->query_id = mysql_query($query_str, $this->link_id);
|
||||
}
|
||||
} else {
|
||||
if ($suppress_error) {
|
||||
$this->query_id = @mysql_unbuffered_query($query_str, $this->link_id);
|
||||
} else {
|
||||
$this->query_id = mysql_unbuffered_query($query_str, $this->link_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->query_id && !$suppress_error) {
|
||||
$this->_showerror('Invalid SQL: ' . $query_str);
|
||||
} elseif(!$this->query_id && $suppress_error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$numbqueries++;
|
||||
return $this->query_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches Row from Query and returns it as array
|
||||
*
|
||||
* @param string RessourceId
|
||||
* @param string Datatype, num or assoc
|
||||
* @return array The row
|
||||
*/
|
||||
public function fetch_array($query_id = - 1, $_datatype = 'assoc') {
|
||||
if ($query_id != - 1) {
|
||||
$this->query_id = $query_id;
|
||||
}
|
||||
|
||||
$datatype = MYSQL_ASSOC;
|
||||
if ($_datatype == 'num') {
|
||||
$datatype = MYSQL_NUM;
|
||||
}
|
||||
|
||||
$this->record = mysql_fetch_array($this->query_id, $datatype);
|
||||
return $this->record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query Database and fetche the first row from Query and returns it as array
|
||||
*
|
||||
* @param string Querystring
|
||||
* @param string Datatype, num or assoc
|
||||
* @return array The first row
|
||||
*/
|
||||
public function query_first($query_string, $datatype = 'assoc') {
|
||||
$this->query($query_string);
|
||||
return $this->fetch_array($this->query_id, $datatype);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns how many rows have been selected
|
||||
*
|
||||
* @param string RessourceId
|
||||
* @return int Number of rows
|
||||
*/
|
||||
public function num_rows($query_id = - 1) {
|
||||
if ($query_id != - 1) {
|
||||
$this->query_id = $query_id;
|
||||
}
|
||||
return mysql_num_rows($this->query_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the auto_incremental-Value of the inserted row
|
||||
*
|
||||
* @return int auto_incremental-Value
|
||||
*/
|
||||
public function insert_id() {
|
||||
return mysql_insert_id($this->link_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of rows affected by last query
|
||||
*
|
||||
* @return int affected rows
|
||||
*/
|
||||
public function affected_rows() {
|
||||
return mysql_affected_rows($this->link_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns errordescription and errornumber if an error occured.
|
||||
*
|
||||
* @return int Errornumber
|
||||
*/
|
||||
private function _geterrdescno() {
|
||||
if ($this->link_id != 0) {
|
||||
$this->errdesc = mysql_error($this->link_id);
|
||||
$this->errno = mysql_errno($this->link_id);
|
||||
} else {
|
||||
// Maybe we don't have any linkid so let's try to catch at least anything
|
||||
$this->errdesc = mysql_error();
|
||||
$this->errno = mysql_errno();
|
||||
}
|
||||
return $this->errno;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dies with an errormessage
|
||||
*
|
||||
* @param string Errormessage
|
||||
*/
|
||||
private function _showerror($errormsg, $mysqlActive = true) {
|
||||
global $filename, $theme;
|
||||
|
||||
$text = 'MySQL - Error: ' . $errormsg;
|
||||
|
||||
if ($mysqlActive) {
|
||||
$this->_geterrdescno();
|
||||
$text .= "; ErrNo: " . $this->errno . "; Desc: " . $this->errdesc;
|
||||
}
|
||||
|
||||
if ($filename != 'froxlor_master_cronjob.php') {
|
||||
$text .= "; Script: " . getenv('REQUEST_URI') . "; Ref: " . getenv('HTTP_REFERER');
|
||||
} else {
|
||||
$text .= "; Script: cronscript";
|
||||
}
|
||||
$md5 = md5($text . time());
|
||||
openlog("Froxlor", LOG_NDELAY, LOG_USER);
|
||||
syslog(LOG_ERR, $text . "; $md5");
|
||||
closelog();
|
||||
|
||||
/**
|
||||
* log to a file, so we can actually ask people for the error
|
||||
* (no one seems to find the stuff in the syslog)
|
||||
*/
|
||||
$sl_dir = makeCorrectDir(dirname(dirname(dirname(dirname(__FILE__))))."/logs/");
|
||||
if (!file_exists($sl_dir)) {
|
||||
@mkdir($sl_dir, 0755);
|
||||
}
|
||||
$sl_file = makeCorrectFile($sl_dir."/sql-error.log");
|
||||
$sqllog = @fopen($sl_file, 'a');
|
||||
@fwrite($sqllog, date('d.m.Y H:i', time())." --- ".$text."\n");
|
||||
@fclose($sqllog);
|
||||
|
||||
if (!isset($_SERVER['SHELL']) || (isset($_SERVER['SHELL']) && $_SERVER['SHELL'] == '')) {
|
||||
// if we're not on the shell, output a nicer error-message
|
||||
$err_hint = file_get_contents(dirname($sl_dir).'/templates/'.$theme.'/misc/dberrornice.tpl');
|
||||
// replace values
|
||||
$err_hint = str_replace("<TEXT>", $errormsg, $err_hint);
|
||||
$err_hint = str_replace("<DEBUG>", $text, $err_hint);
|
||||
// show
|
||||
die($err_hint);
|
||||
}
|
||||
die("We are sorry, but a MySQL - error occurred. The administrator may find more information in syslog with the ID ".$md5." or in the sql-error.log in the logs/ directory");
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* For the full copyright and license information, please view the COPYING
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Functions
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* check whether a maildir exists on the filesystem
|
||||
*
|
||||
* @param array $result all mail-info of customer
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function maildirExists($result = null)
|
||||
{
|
||||
global $settings;
|
||||
|
||||
if(is_array($result))
|
||||
{
|
||||
$loginname = getCustomerDetail($result['customerid'], 'loginname');
|
||||
if($loginname !== false) {
|
||||
$email_user=substr($result['email_full'],0,strrpos($result['email_full'],"@"));
|
||||
$email_domain=substr($result['email_full'],strrpos($result['email_full'],"@")+1);
|
||||
$maildirname=trim($settings['system']['vmail_maildirname']);
|
||||
$maildir = makeCorrectDir($settings['system']['vmail_homedir'] .'/'. $loginname .'/'. $email_domain .'/'. $email_user . (!empty($maildirname)?'/'.$maildirname:''));
|
||||
if(@file_exists($maildir)) {
|
||||
return true;
|
||||
} else {
|
||||
// backward-compatibility for old folder-structure
|
||||
$maildir_old = makeCorrectDir($settings['system']['vmail_homedir'] .'/'. $loginname .'/'. $email_user);
|
||||
if (@file_exists($maildir_old)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1982,6 +1982,7 @@ $lng['error']['fcgidstillenableddeadlock'] = 'FCGID is currently active.<br />Pl
|
||||
$lng['error']['send_report_title'] = 'Send error report';
|
||||
$lng['error']['send_report_desc'] = 'Thank you for reporting this error and helping us to froxlor improve froxlor.<br />This is the email which will be sent to the froxlor developer team:';
|
||||
$lng['error']['send_report'] = 'Send report';
|
||||
$lng['error']['notallowedtouseaccounts'] = 'Your account does not allow using IMAP/POP3. You cannot add email accounts.';
|
||||
$lng['pwdreminder']['changed'] = 'Your password has been successfully changed. You can now login using this password.';
|
||||
$lng['pwdreminder']['wrongcode'] = 'Sorry, the used activationcode does not exist or is already expired.';
|
||||
$lng['admin']['templates']['LINK'] = 'Replaced with the customers password reset link.';
|
||||
|
||||
@@ -1708,7 +1708,9 @@ $lng['error']['fcgidstillenableddeadlock'] = 'FCGID ist derzeit aktiviert.<br />
|
||||
$lng['error']['send_report_title'] = 'Fehler melden';
|
||||
$lng['error']['send_report_desc'] = 'Danke, dass Sie uns diesen Fehler melden und damit helfen Froxlor zu verbessern.<br />Folgender Bericht wird per Mail an das Froxlor Entwickler Team gesendet.';
|
||||
$lng['error']['send_report'] = 'Fehlerbericht senden';
|
||||
$lng['error']['notallowedtouseaccounts'] = 'Ihrem Konto ist die Nutzung von IMAP/POP3 nicht erlaubt, daher können keine E-Mail Konten angelegt werden';
|
||||
$lng['pwdreminder']['changed'] = 'Ihr Passwort wurde erfolgreich geändert. Sie können sich nun damit ';
|
||||
$lng['pwdreminder']['wrongcode'] = 'Der verwendete Aktivierungscode ist entweder nicht gültig oder bereits abgelaufen.';
|
||||
$lng['admin']['templates']['LINK'] = 'Wird mit dem Link zum Zurücksetzen des Passworts ersetzt.';
|
||||
$lng['pwdreminder']['choosenew'] = 'Neues Passwort auswählen';
|
||||
$lng['pwdreminder']['choosenew'] = 'Neues Passwort auswählen';
|
||||
$lng['error']['notallowedtouseaccounts'] = 'Ihrem Konto ist die Nutzung von IMAP/POP3 nicht erlaubt, daher können keine E-Mail Konten angelegt werden';
|
||||
|
||||
Reference in New Issue
Block a user