get rid of storeSetting*-functions
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Froxlor\Database;
|
namespace Froxlor\Database;
|
||||||
|
|
||||||
use \Froxlor\Settings;
|
use Froxlor\Settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of the Froxlor project.
|
* This file is part of the Froxlor project.
|
||||||
@@ -33,16 +33,19 @@ use \Froxlor\Settings;
|
|||||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||||
* @package Classes
|
* @package Classes
|
||||||
*/
|
*/
|
||||||
class DbManager {
|
class DbManager
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FroxlorLogger object
|
* FroxlorLogger object
|
||||||
|
*
|
||||||
* @var object
|
* @var object
|
||||||
*/
|
*/
|
||||||
private $_log = null;
|
private $_log = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manager object
|
* Manager object
|
||||||
|
*
|
||||||
* @var object
|
* @var object
|
||||||
*/
|
*/
|
||||||
private $_manager = null;
|
private $_manager = null;
|
||||||
@@ -52,7 +55,8 @@ class DbManager {
|
|||||||
*
|
*
|
||||||
* @param \Froxlor\FroxlorLogger $log
|
* @param \Froxlor\FroxlorLogger $log
|
||||||
*/
|
*/
|
||||||
public function __construct($log = null) {
|
public function __construct($log = null)
|
||||||
|
{
|
||||||
$this->_log = $log;
|
$this->_log = $log;
|
||||||
$this->_setManager();
|
$this->_setManager();
|
||||||
}
|
}
|
||||||
@@ -69,8 +73,8 @@ class DbManager {
|
|||||||
*
|
*
|
||||||
* @return string|bool $username if successful or false of username is equal to the password
|
* @return string|bool $username if successful or false of username is equal to the password
|
||||||
*/
|
*/
|
||||||
public function createDatabase($loginname = null, $password = null, $last_accnumber = 0) {
|
public function createDatabase($loginname = null, $password = null, $last_accnumber = 0)
|
||||||
|
{
|
||||||
Database::needRoot(true);
|
Database::needRoot(true);
|
||||||
|
|
||||||
// check whether we shall create a random username
|
// check whether we shall create a random username
|
||||||
@@ -113,7 +117,8 @@ class DbManager {
|
|||||||
* returns the manager-object
|
* returns the manager-object
|
||||||
* from where we can control it
|
* from where we can control it
|
||||||
*/
|
*/
|
||||||
public function getManager() {
|
public function getManager()
|
||||||
|
{
|
||||||
return $this->_manager;
|
return $this->_manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,8 +128,71 @@ class DbManager {
|
|||||||
*
|
*
|
||||||
* sets private $_manager variable
|
* sets private $_manager variable
|
||||||
*/
|
*/
|
||||||
private function _setManager() {
|
private function _setManager()
|
||||||
|
{
|
||||||
// TODO read different dbms from settings later
|
// TODO read different dbms from settings later
|
||||||
$this->_manager = new \Froxlor\Database\Manager\DbManagerMySQL($this->_log);
|
$this->_manager = new \Froxlor\Database\Manager\DbManagerMySQL($this->_log);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function correctMysqlUsers($mysql_access_host_array)
|
||||||
|
{
|
||||||
|
// get sql-root access data
|
||||||
|
Database::needRoot(true);
|
||||||
|
Database::needSqlData();
|
||||||
|
$sql_root = Database::getSqlData();
|
||||||
|
Database::needRoot(false);
|
||||||
|
|
||||||
|
$dbservers_stmt = Database::query("SELECT DISTINCT `dbserver` FROM `" . TABLE_PANEL_DATABASES . "`");
|
||||||
|
while ($dbserver = $dbservers_stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
|
|
||||||
|
Database::needRoot(true, $dbserver['dbserver']);
|
||||||
|
Database::needSqlData();
|
||||||
|
$sql_root = Database::getSqlData();
|
||||||
|
|
||||||
|
$dbm = new DbManager(\Froxlor\FroxlorLogger::getInstanceOf());
|
||||||
|
$users = $dbm->getManager()->getAllSqlUsers(false);
|
||||||
|
|
||||||
|
$databases = array(
|
||||||
|
$sql_root['db']
|
||||||
|
);
|
||||||
|
$databases_result_stmt = Database::prepare("
|
||||||
|
SELECT * FROM `" . TABLE_PANEL_DATABASES . "`
|
||||||
|
WHERE `dbserver` = :mysqlserver
|
||||||
|
");
|
||||||
|
Database::pexecute($databases_result_stmt, array(
|
||||||
|
'mysqlserver' => $dbserver['dbserver']
|
||||||
|
));
|
||||||
|
|
||||||
|
while ($databases_row = $databases_result_stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
|
$databases[] = $databases_row['databasename'];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($databases as $username) {
|
||||||
|
|
||||||
|
if (isset($users[$username]) && is_array($users[$username]) && isset($users[$username]['hosts']) && is_array($users[$username]['hosts'])) {
|
||||||
|
|
||||||
|
$password = $users[$username]['password'];
|
||||||
|
|
||||||
|
foreach ($mysql_access_host_array as $mysql_access_host) {
|
||||||
|
|
||||||
|
$mysql_access_host = trim($mysql_access_host);
|
||||||
|
|
||||||
|
if (! in_array($mysql_access_host, $users[$username]['hosts'])) {
|
||||||
|
$dbm->getManager()->grantPrivilegesTo($username, $password, $mysql_access_host, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($users[$username]['hosts'] as $mysql_access_host) {
|
||||||
|
|
||||||
|
if (! in_array($mysql_access_host, $mysql_access_host_array)) {
|
||||||
|
$dbm->getManager()->deleteUser($username, $mysql_access_host);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$dbm->getManager()->flushPrivileges();
|
||||||
|
Database::needRoot(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
380
lib/Froxlor/Settings/Store.php
Normal file
380
lib/Froxlor/Settings/Store.php
Normal file
@@ -0,0 +1,380 @@
|
|||||||
|
<?php
|
||||||
|
namespace Froxlor\Settings;
|
||||||
|
|
||||||
|
use Froxlor\Database\Database;
|
||||||
|
use Froxlor\Settings;
|
||||||
|
|
||||||
|
class Store
|
||||||
|
{
|
||||||
|
|
||||||
|
public static function storeSettingClearCertificates($fieldname, $fielddata, $newfieldvalue)
|
||||||
|
{
|
||||||
|
$returnvalue = self::storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
||||||
|
|
||||||
|
if ($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'le_froxlor_enabled' && $newfieldvalue == '0') {
|
||||||
|
Database::query("
|
||||||
|
DELETE FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` WHERE `domainid` = '0'
|
||||||
|
");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $returnvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function storeSettingDefaultIp($fieldname, $fielddata, $newfieldvalue)
|
||||||
|
{
|
||||||
|
$defaultips_old = Settings::Get('system.defaultip');
|
||||||
|
|
||||||
|
$returnvalue = self::storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
||||||
|
|
||||||
|
if ($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'defaultip') {
|
||||||
|
|
||||||
|
$customerstddomains_result_stmt = Database::prepare("
|
||||||
|
SELECT `standardsubdomain` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `standardsubdomain` <> '0'
|
||||||
|
");
|
||||||
|
Database::pexecute($customerstddomains_result_stmt);
|
||||||
|
|
||||||
|
$ids = array();
|
||||||
|
|
||||||
|
while ($customerstddomains_row = $customerstddomains_result_stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
|
$ids[] = (int) $customerstddomains_row['standardsubdomain'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($ids) > 0) {
|
||||||
|
$defaultips_new = explode(',', $newfieldvalue);
|
||||||
|
|
||||||
|
// Delete the existing mappings linking to default IPs
|
||||||
|
$del_stmt = Database::prepare("
|
||||||
|
DELETE FROM `" . TABLE_DOMAINTOIP . "`
|
||||||
|
WHERE `id_domain` IN (" . implode(', ', $ids) . ")
|
||||||
|
AND `id_ipandports` IN (" . $defaultips_old . ", " . $newfieldvalue . ")
|
||||||
|
");
|
||||||
|
Database::pexecute($del_stmt);
|
||||||
|
|
||||||
|
// Insert the new mappings
|
||||||
|
$ins_stmt = Database::prepare("
|
||||||
|
INSERT INTO `" . TABLE_DOMAINTOIP . "`
|
||||||
|
SET `id_domain` = :domainid, `id_ipandports` = :ipandportid
|
||||||
|
");
|
||||||
|
|
||||||
|
foreach ($ids as $id) {
|
||||||
|
foreach ($defaultips_new as $defaultip_new) {
|
||||||
|
Database::pexecute($ins_stmt, array(
|
||||||
|
'domainid' => $id,
|
||||||
|
'ipandportid' => $defaultip_new
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $returnvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function storeSettingDefaultSslIp($fieldname, $fielddata, $newfieldvalue)
|
||||||
|
{
|
||||||
|
$defaultips_old = Settings::Get('system.defaultsslip');
|
||||||
|
|
||||||
|
$returnvalue = self::storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
||||||
|
|
||||||
|
if ($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'defaultsslip') {
|
||||||
|
|
||||||
|
$customerstddomains_result_stmt = Database::prepare("
|
||||||
|
SELECT `standardsubdomain` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `standardsubdomain` <> '0'
|
||||||
|
");
|
||||||
|
Database::pexecute($customerstddomains_result_stmt);
|
||||||
|
|
||||||
|
$ids = array();
|
||||||
|
|
||||||
|
while ($customerstddomains_row = $customerstddomains_result_stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
|
$ids[] = (int) $customerstddomains_row['standardsubdomain'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($ids) > 0) {
|
||||||
|
$defaultips_new = explode(',', $newfieldvalue);
|
||||||
|
|
||||||
|
if (! empty($defaultips_old) && ! empty($newfieldvalue)) {
|
||||||
|
$in_value = $defaultips_old . ", " . $newfieldvalue;
|
||||||
|
} elseif (! empty($defaultips_old) && empty($newfieldvalue)) {
|
||||||
|
$in_value = $defaultips_old;
|
||||||
|
} else {
|
||||||
|
$in_value = $newfieldvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the existing mappings linking to default IPs
|
||||||
|
$del_stmt = Database::prepare("
|
||||||
|
DELETE FROM `" . TABLE_DOMAINTOIP . "`
|
||||||
|
WHERE `id_domain` IN (" . implode(', ', $ids) . ")
|
||||||
|
AND `id_ipandports` IN (" . $in_value . ")
|
||||||
|
");
|
||||||
|
Database::pexecute($del_stmt);
|
||||||
|
|
||||||
|
if (count($defaultips_new) > 0) {
|
||||||
|
// Insert the new mappings
|
||||||
|
$ins_stmt = Database::prepare("
|
||||||
|
INSERT INTO `" . TABLE_DOMAINTOIP . "`
|
||||||
|
SET `id_domain` = :domainid, `id_ipandports` = :ipandportid
|
||||||
|
");
|
||||||
|
|
||||||
|
foreach ($ids as $id) {
|
||||||
|
foreach ($defaultips_new as $defaultip_new) {
|
||||||
|
Database::pexecute($ins_stmt, array(
|
||||||
|
'domainid' => $id,
|
||||||
|
'ipandportid' => $defaultip_new
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $returnvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updates the setting for the default panel-theme
|
||||||
|
* and also the user themes (customers and admins) if
|
||||||
|
* the changing of themes is disallowed for them
|
||||||
|
*
|
||||||
|
* @param string $fieldname
|
||||||
|
* @param array $fielddata
|
||||||
|
* @param mixed $newfieldvalue
|
||||||
|
*
|
||||||
|
* @return boolean|array
|
||||||
|
*/
|
||||||
|
public static function storeSettingDefaultTheme($fieldname, $fielddata, $newfieldvalue)
|
||||||
|
{
|
||||||
|
|
||||||
|
// first save the setting itself
|
||||||
|
$returnvalue = self::storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
||||||
|
|
||||||
|
if ($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'panel' && isset($fielddata['varname']) && $fielddata['varname'] == 'default_theme') {
|
||||||
|
// now, if changing themes is disabled we recursivly set
|
||||||
|
// the new theme (customers and admin, depending on settings)
|
||||||
|
if (Settings::Get('panel.allow_theme_change_customer') == '0') {
|
||||||
|
$upd_stmt = Database::prepare("
|
||||||
|
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `theme` = :theme
|
||||||
|
");
|
||||||
|
Database::pexecute($upd_stmt, array(
|
||||||
|
'theme' => $newfieldvalue
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if (Settings::Get('panel.allow_theme_change_admin') == '0') {
|
||||||
|
$upd_stmt = Database::prepare("
|
||||||
|
UPDATE `" . TABLE_PANEL_ADMINS . "` SET `theme` = :theme
|
||||||
|
");
|
||||||
|
Database::pexecute($upd_stmt, array(
|
||||||
|
'theme' => $newfieldvalue
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $returnvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function storeSettingField($fieldname, $fielddata, $newfieldvalue)
|
||||||
|
{
|
||||||
|
if (is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] != '' && isset($fielddata['varname']) && $fielddata['varname'] != '') {
|
||||||
|
if (Settings::Set($fielddata['settinggroup'] . '.' . $fielddata['varname'], $newfieldvalue) !== false) {
|
||||||
|
/*
|
||||||
|
* when fielddata[cronmodule] is set, this means enable/disable a cronjob
|
||||||
|
*/
|
||||||
|
if (isset($fielddata['cronmodule']) && $fielddata['cronmodule'] != '') {
|
||||||
|
toggleCronStatus($fielddata['cronmodule'], $newfieldvalue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* satisfy dependencies
|
||||||
|
*/
|
||||||
|
if (isset($fielddata['dependency']) && is_array($fielddata['dependency'])) {
|
||||||
|
if ((int) $fielddata['dependency']['onlyif'] == (int) $newfieldvalue) {
|
||||||
|
self::storeSettingField($fielddata['dependency']['fieldname'], $fielddata['dependency']['fielddata'], $newfieldvalue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return array(
|
||||||
|
$fielddata['settinggroup'] . '.' . $fielddata['varname'] => $newfieldvalue
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function storeSettingFieldInsertBindTask($fieldname, $fielddata, $newfieldvalue)
|
||||||
|
{
|
||||||
|
if (is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] != '' && isset($fielddata['varname']) && $fielddata['varname'] != '') {
|
||||||
|
if (Settings::Set($fielddata['settinggroup'] . '.' . $fielddata['varname'], $newfieldvalue) !== false) {
|
||||||
|
return array(
|
||||||
|
$fielddata['settinggroup'] . '.' . $fielddata['varname'] => $newfieldvalue
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function storeSettingHostname($fieldname, $fielddata, $newfieldvalue)
|
||||||
|
{
|
||||||
|
$returnvalue = self::storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
||||||
|
|
||||||
|
if ($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'hostname') {
|
||||||
|
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||||
|
$newfieldvalue = $idna_convert->encode($newfieldvalue);
|
||||||
|
|
||||||
|
$customerstddomains_result_stmt = Database::prepare("
|
||||||
|
SELECT `standardsubdomain` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `standardsubdomain` <> '0'
|
||||||
|
");
|
||||||
|
Database::pexecute($customerstddomains_result_stmt);
|
||||||
|
|
||||||
|
$ids = array();
|
||||||
|
|
||||||
|
while ($customerstddomains_row = $customerstddomains_result_stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
|
$ids[] = (int) $customerstddomains_row['standardsubdomain'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($ids) > 0) {
|
||||||
|
$upd_stmt = Database::prepare("
|
||||||
|
UPDATE `" . TABLE_PANEL_DOMAINS . "` SET
|
||||||
|
`domain` = REPLACE(`domain`, :host, :newval)
|
||||||
|
WHERE `id` IN ('" . implode(', ', $ids) . "')
|
||||||
|
");
|
||||||
|
Database::pexecute($upd_stmt, array(
|
||||||
|
'host' => Settings::Get('system.hostname'),
|
||||||
|
'newval' => $newfieldvalue
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $returnvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function storeSettingIpAddress($fieldname, $fielddata, $newfieldvalue)
|
||||||
|
{
|
||||||
|
$returnvalue = self::storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
||||||
|
|
||||||
|
if ($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'ipaddress') {
|
||||||
|
$mysql_access_host_array = array_map('trim', explode(',', Settings::Get('system.mysql_access_host')));
|
||||||
|
$mysql_access_host_array[] = $newfieldvalue;
|
||||||
|
$mysql_access_host_array = array_unique(array_trim($mysql_access_host_array));
|
||||||
|
$mysql_access_host = implode(',', $mysql_access_host_array);
|
||||||
|
\Froxlor\Database\DbManager::correctMysqlUsers($mysql_access_host_array);
|
||||||
|
Settings::Set('system.mysql_access_host', $mysql_access_host);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $returnvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function storeSettingMysqlAccessHost($fieldname, $fielddata, $newfieldvalue)
|
||||||
|
{
|
||||||
|
$returnvalue = self::storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
||||||
|
|
||||||
|
if ($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'mysql_access_host') {
|
||||||
|
$mysql_access_host_array = array_map('trim', explode(',', $newfieldvalue));
|
||||||
|
|
||||||
|
if (in_array('127.0.0.1', $mysql_access_host_array) && ! in_array('localhost', $mysql_access_host_array)) {
|
||||||
|
$mysql_access_host_array[] = 'localhost';
|
||||||
|
}
|
||||||
|
|
||||||
|
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';
|
||||||
|
}
|
||||||
|
|
||||||
|
// be aware that ipv6 addresses are enclosed in [ ] when passed here
|
||||||
|
$mysql_access_host_array = array_map(array(
|
||||||
|
self,
|
||||||
|
'cleanMySQLAccessHost'
|
||||||
|
), $mysql_access_host_array);
|
||||||
|
|
||||||
|
$mysql_access_host_array = array_unique(array_trim($mysql_access_host_array));
|
||||||
|
$newfieldvalue = implode(',', $mysql_access_host_array);
|
||||||
|
\Froxlor\Database\DbManager::correctMysqlUsers($mysql_access_host_array);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $returnvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function cleanMySQLAccessHost($value)
|
||||||
|
{
|
||||||
|
if (substr($value, 0, 1) == '[' && substr($value, - 1) == ']') {
|
||||||
|
return substr($value, 1, - 1);
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function storeSettingResetCatchall($fieldname, $fielddata, $newfieldvalue)
|
||||||
|
{
|
||||||
|
$returnvalue = self::storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
||||||
|
|
||||||
|
if ($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'catchall' && isset($fielddata['varname']) && $fielddata['varname'] == 'catchall_enabled' && $newfieldvalue == '0') {
|
||||||
|
|
||||||
|
$result_stmt = Database::query("
|
||||||
|
SELECT `id`, `email`, `email_full`, `iscatchall` FROM `" . TABLE_MAIL_VIRTUAL . "`
|
||||||
|
WHERE `iscatchall` = '1'
|
||||||
|
");
|
||||||
|
|
||||||
|
if (Database::num_rows() > 0) {
|
||||||
|
|
||||||
|
$upd_stmt = Database::prepare("
|
||||||
|
UPDATE `" . TABLE_MAIL_VIRTUAL . "` SET `email` = :email, `iscatchall` = '0' WHERE `id` = :id
|
||||||
|
");
|
||||||
|
|
||||||
|
while ($result_row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
|
Database::pexecute($upd_stmt, array(
|
||||||
|
'email' => $result_row['email_full'],
|
||||||
|
'id' => $result_row['id']
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $returnvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whenever the webserver- / FCGID- or FPM-user gets updated
|
||||||
|
* we need to update ftp_groups accordingly
|
||||||
|
*/
|
||||||
|
public static function storeSettingWebserverFcgidFpmUser($fieldname, $fielddata, $newfieldvalue)
|
||||||
|
{
|
||||||
|
if (is_array($fielddata) && isset($fielddata['settinggroup']) && isset($fielddata['varname'])) {
|
||||||
|
|
||||||
|
$update_user = null;
|
||||||
|
|
||||||
|
// webserver
|
||||||
|
if ($fielddata['settinggroup'] == 'system' && $fielddata['varname'] == 'httpuser') {
|
||||||
|
$update_user = Settings::Get('system.httpuser');
|
||||||
|
}
|
||||||
|
|
||||||
|
// fcgid
|
||||||
|
if ($fielddata['settinggroup'] == 'system' && $fielddata['varname'] == 'mod_fcgid_httpuser') {
|
||||||
|
$update_user = Settings::Get('system.mod_fcgid_httpuser');
|
||||||
|
}
|
||||||
|
|
||||||
|
// webserver
|
||||||
|
if ($fielddata['settinggroup'] == 'phpfpm' && $fielddata['varname'] == 'vhost_httpuser') {
|
||||||
|
$update_user = Settings::Get('phpfpm.vhost_httpuser');
|
||||||
|
}
|
||||||
|
|
||||||
|
$returnvalue = self::storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
||||||
|
|
||||||
|
if ($returnvalue !== false) {
|
||||||
|
/**
|
||||||
|
* only update if anything changed
|
||||||
|
*/
|
||||||
|
if ($update_user != null && $newfieldvalue != $update_user) {
|
||||||
|
$upd_stmt = Database::prepare("UPDATE `" . TABLE_FTP_GROUPS . "` SET `members` = REPLACE(`members`, :olduser, :newuser)");
|
||||||
|
Database::pexecute($upd_stmt, array(
|
||||||
|
'olduser' => $update_user,
|
||||||
|
'newuser' => $newfieldvalue
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $returnvalue;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,86 +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 Functions
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
function correctMysqlUsers($mysql_access_host_array) {
|
|
||||||
|
|
||||||
global $log;
|
|
||||||
|
|
||||||
// get sql-root access data
|
|
||||||
Database::needRoot(true);
|
|
||||||
Database::needSqlData();
|
|
||||||
$sql_root = Database::getSqlData();
|
|
||||||
Database::needRoot(false);
|
|
||||||
|
|
||||||
$dbservers_stmt = Database::query("SELECT DISTINCT `dbserver` FROM `".TABLE_PANEL_DATABASES."`");
|
|
||||||
$mysql_servers = '';
|
|
||||||
|
|
||||||
while ($dbserver = $dbservers_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
||||||
|
|
||||||
Database::needRoot(true, $dbserver['dbserver']);
|
|
||||||
Database::needSqlData();
|
|
||||||
$sql_root = Database::getSqlData();
|
|
||||||
|
|
||||||
$dbm = new DbManager($log);
|
|
||||||
$users = $dbm->getManager()->getAllSqlUsers(false);
|
|
||||||
|
|
||||||
$databases = array(
|
|
||||||
$sql_root['db']
|
|
||||||
);
|
|
||||||
$databases_result_stmt = Database::prepare("
|
|
||||||
SELECT * FROM `" . TABLE_PANEL_DATABASES . "`
|
|
||||||
WHERE `dbserver` = :mysqlserver
|
|
||||||
");
|
|
||||||
Database::pexecute($databases_result_stmt, array('mysqlserver' => $dbserver['dbserver']));
|
|
||||||
|
|
||||||
while ($databases_row = $databases_result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
||||||
$databases[] = $databases_row['databasename'];
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($databases as $username) {
|
|
||||||
|
|
||||||
if (isset($users[$username])
|
|
||||||
&& is_array($users[$username])
|
|
||||||
&& isset($users[$username]['hosts'])
|
|
||||||
&& is_array($users[$username]['hosts'])
|
|
||||||
) {
|
|
||||||
|
|
||||||
$password = $users[$username]['password'];
|
|
||||||
|
|
||||||
foreach ($mysql_access_host_array as $mysql_access_host) {
|
|
||||||
|
|
||||||
$mysql_access_host = trim($mysql_access_host);
|
|
||||||
|
|
||||||
if (!in_array($mysql_access_host, $users[$username]['hosts'])) {
|
|
||||||
$dbm->getManager()->grantPrivilegesTo($username, $password, $mysql_access_host, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($users[$username]['hosts'] as $mysql_access_host) {
|
|
||||||
|
|
||||||
if (!in_array($mysql_access_host, $mysql_access_host_array)) {
|
|
||||||
$dbm->getManager()->deleteUser($username, $mysql_access_host);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$dbm->getManager()->flushPrivileges();
|
|
||||||
Database::needRoot(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -20,9 +20,9 @@
|
|||||||
function saveForm($fielddata, $newfieldvalue)
|
function saveForm($fielddata, $newfieldvalue)
|
||||||
{
|
{
|
||||||
$returnvalue = '';
|
$returnvalue = '';
|
||||||
if(is_array($fielddata) && isset($fielddata['save_method']) && $fielddata['save_method'] != '' && function_exists($fielddata['save_method']))
|
if(is_array($fielddata) && isset($fielddata['save_method']) && $fielddata['save_method'] != '')
|
||||||
{
|
{
|
||||||
$returnvalue = call_user_func($fielddata['save_method'], $fielddata, $newfieldvalue);
|
$returnvalue = call_user_func(array('\\Froxlor\\Settings\\Store', $fielddata['save_method']), $fielddata, $newfieldvalue);
|
||||||
}
|
}
|
||||||
elseif(is_array($fielddata) && !isset($fielddata['save_method']))
|
elseif(is_array($fielddata) && !isset($fielddata['save_method']))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,20 +16,17 @@
|
|||||||
* @package Functions
|
* @package Functions
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function saveFormField($fieldname, $fielddata, $newfieldvalue)
|
function saveFormField($fieldname, $fielddata, $newfieldvalue)
|
||||||
{
|
{
|
||||||
$returnvalue = '';
|
$returnvalue = '';
|
||||||
if(is_array($fielddata) && isset($fielddata['save_method']) && $fielddata['save_method'] != '' && function_exists($fielddata['save_method']))
|
if (is_array($fielddata) && isset($fielddata['save_method']) && $fielddata['save_method'] != '') {
|
||||||
{
|
$returnvalue = call_user_func(array(
|
||||||
$returnvalue = call_user_func($fielddata['save_method'], $fieldname, $fielddata, $newfieldvalue);
|
'\\Froxlor\\Settings\\Store',
|
||||||
}
|
$fielddata['save_method']
|
||||||
elseif(is_array($fielddata) && !isset($fielddata['save_method']))
|
), $fieldname, $fielddata, $newfieldvalue);
|
||||||
{
|
} elseif (is_array($fielddata) && ! isset($fielddata['save_method'])) {
|
||||||
$returnvalue = array();
|
$returnvalue = array();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$returnvalue = false;
|
$returnvalue = false;
|
||||||
}
|
}
|
||||||
return $returnvalue;
|
return $returnvalue;
|
||||||
|
|||||||
@@ -16,13 +16,11 @@
|
|||||||
* @package Functions
|
* @package Functions
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function validateFieldDefinition($field)
|
function validateFieldDefinition($field)
|
||||||
{
|
{
|
||||||
$returnvalue = false;
|
$returnvalue = false;
|
||||||
|
|
||||||
if(is_array($field) && !empty($field) && isset($field['fields']) && is_array($field['fields']) && !empty($field['fields']))
|
if (is_array($field) && ! empty($field) && isset($field['fields']) && is_array($field['fields']) && ! empty($field['fields'])) {
|
||||||
{
|
|
||||||
$returnvalue = true;
|
$returnvalue = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +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 Froxlor team <team@froxlor.org> (2010-)
|
|
||||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
|
||||||
* @package Functions
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
function storeSettingClearCertificates($fieldname, $fielddata, $newfieldvalue) {
|
|
||||||
|
|
||||||
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
|
||||||
|
|
||||||
if ($returnvalue !== false
|
|
||||||
&& is_array($fielddata)
|
|
||||||
&& isset($fielddata['settinggroup'])
|
|
||||||
&& $fielddata['settinggroup'] == 'system'
|
|
||||||
&& isset($fielddata['varname'])
|
|
||||||
&& $fielddata['varname'] == 'le_froxlor_enabled'
|
|
||||||
&& $newfieldvalue == '0'
|
|
||||||
) {
|
|
||||||
Database::query("
|
|
||||||
DELETE FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` WHERE `domainid` = '0'
|
|
||||||
");
|
|
||||||
}
|
|
||||||
|
|
||||||
return $returnvalue;
|
|
||||||
}
|
|
||||||
@@ -1,133 +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 Functions
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function storeSettingDefaultIp($fieldname, $fielddata, $newfieldvalue) {
|
|
||||||
$defaultips_old = Settings::Get('system.defaultip');
|
|
||||||
|
|
||||||
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
|
||||||
|
|
||||||
if ($returnvalue !== false
|
|
||||||
&& is_array($fielddata)
|
|
||||||
&& isset($fielddata['settinggroup'])
|
|
||||||
&& $fielddata['settinggroup'] == 'system'
|
|
||||||
&& isset($fielddata['varname'])
|
|
||||||
&& $fielddata['varname'] == 'defaultip'
|
|
||||||
) {
|
|
||||||
|
|
||||||
$customerstddomains_result_stmt = Database::prepare("
|
|
||||||
SELECT `standardsubdomain` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `standardsubdomain` <> '0'
|
|
||||||
");
|
|
||||||
Database::pexecute($customerstddomains_result_stmt);
|
|
||||||
|
|
||||||
$ids = array();
|
|
||||||
|
|
||||||
while ($customerstddomains_row = $customerstddomains_result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
||||||
$ids[] = (int)$customerstddomains_row['standardsubdomain'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count($ids) > 0) {
|
|
||||||
$defaultips_new = explode(',', $newfieldvalue);
|
|
||||||
|
|
||||||
// Delete the existing mappings linking to default IPs
|
|
||||||
$del_stmt = Database::prepare("
|
|
||||||
DELETE FROM `" . TABLE_DOMAINTOIP . "`
|
|
||||||
WHERE `id_domain` IN (" . implode(', ', $ids) . ")
|
|
||||||
AND `id_ipandports` IN (" . $defaultips_old . ", " . $newfieldvalue . ")
|
|
||||||
");
|
|
||||||
Database::pexecute($del_stmt);
|
|
||||||
|
|
||||||
// Insert the new mappings
|
|
||||||
$ins_stmt = Database::prepare("
|
|
||||||
INSERT INTO `" . TABLE_DOMAINTOIP . "`
|
|
||||||
SET `id_domain` = :domainid, `id_ipandports` = :ipandportid
|
|
||||||
");
|
|
||||||
|
|
||||||
foreach ($ids as $id) {
|
|
||||||
foreach ($defaultips_new as $defaultip_new) {
|
|
||||||
Database::pexecute($ins_stmt, array('domainid' => $id, 'ipandportid' => $defaultip_new));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $returnvalue;
|
|
||||||
}
|
|
||||||
|
|
||||||
function storeSettingDefaultSslIp($fieldname, $fielddata, $newfieldvalue) {
|
|
||||||
$defaultips_old = Settings::Get('system.defaultsslip');
|
|
||||||
|
|
||||||
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
|
||||||
|
|
||||||
if ($returnvalue !== false
|
|
||||||
&& is_array($fielddata)
|
|
||||||
&& isset($fielddata['settinggroup'])
|
|
||||||
&& $fielddata['settinggroup'] == 'system'
|
|
||||||
&& isset($fielddata['varname'])
|
|
||||||
&& $fielddata['varname'] == 'defaultsslip'
|
|
||||||
) {
|
|
||||||
|
|
||||||
$customerstddomains_result_stmt = Database::prepare("
|
|
||||||
SELECT `standardsubdomain` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `standardsubdomain` <> '0'
|
|
||||||
");
|
|
||||||
Database::pexecute($customerstddomains_result_stmt);
|
|
||||||
|
|
||||||
$ids = array();
|
|
||||||
|
|
||||||
while ($customerstddomains_row = $customerstddomains_result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
||||||
$ids[] = (int)$customerstddomains_row['standardsubdomain'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count($ids) > 0) {
|
|
||||||
$defaultips_new = explode(',', $newfieldvalue);
|
|
||||||
|
|
||||||
if (!empty($defaultips_old) && !empty($newfieldvalue))
|
|
||||||
{
|
|
||||||
$in_value = $defaultips_old . ", " . $newfieldvalue;
|
|
||||||
} elseif (!empty($defaultips_old) && empty($newfieldvalue))
|
|
||||||
{
|
|
||||||
$in_value = $defaultips_old;
|
|
||||||
} else {
|
|
||||||
$in_value = $newfieldvalue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete the existing mappings linking to default IPs
|
|
||||||
$del_stmt = Database::prepare("
|
|
||||||
DELETE FROM `" . TABLE_DOMAINTOIP . "`
|
|
||||||
WHERE `id_domain` IN (" . implode(', ', $ids) . ")
|
|
||||||
AND `id_ipandports` IN (" . $in_value . ")
|
|
||||||
");
|
|
||||||
Database::pexecute($del_stmt);
|
|
||||||
|
|
||||||
if (count($defaultips_new) > 0) {
|
|
||||||
// Insert the new mappings
|
|
||||||
$ins_stmt = Database::prepare("
|
|
||||||
INSERT INTO `" . TABLE_DOMAINTOIP . "`
|
|
||||||
SET `id_domain` = :domainid, `id_ipandports` = :ipandportid
|
|
||||||
");
|
|
||||||
|
|
||||||
foreach ($ids as $id) {
|
|
||||||
foreach ($defaultips_new as $defaultip_new) {
|
|
||||||
Database::pexecute($ins_stmt, array('domainid' => $id, 'ipandportid' => $defaultip_new));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $returnvalue;
|
|
||||||
}
|
|
||||||
@@ -1,61 +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 Michael Kaufmann <mkaufmann@nutime.de>
|
|
||||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
|
||||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
|
||||||
* @package Functions
|
|
||||||
*
|
|
||||||
* @since 0.9.29.1
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* updates the setting for the default panel-theme
|
|
||||||
* and also the user themes (customers and admins) if
|
|
||||||
* the changing of themes is disallowed for them
|
|
||||||
*
|
|
||||||
* @param string $fieldname
|
|
||||||
* @param array $fielddata
|
|
||||||
* @param mixed $newfieldvalue
|
|
||||||
*
|
|
||||||
* @return boolean|array
|
|
||||||
*/
|
|
||||||
function storeSettingDefaultTheme($fieldname, $fielddata, $newfieldvalue) {
|
|
||||||
|
|
||||||
// first save the setting itself
|
|
||||||
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
|
||||||
|
|
||||||
if ($returnvalue !== false
|
|
||||||
&& is_array($fielddata)
|
|
||||||
&& isset($fielddata['settinggroup'])
|
|
||||||
&& $fielddata['settinggroup'] == 'panel'
|
|
||||||
&& isset($fielddata['varname'])
|
|
||||||
&& $fielddata['varname'] == 'default_theme'
|
|
||||||
) {
|
|
||||||
// now, if changing themes is disabled we recursivly set
|
|
||||||
// the new theme (customers and admin, depending on settings)
|
|
||||||
if (Settings::Get('panel.allow_theme_change_customer') == '0') {
|
|
||||||
$upd_stmt = Database::prepare("
|
|
||||||
UPDATE `".TABLE_PANEL_CUSTOMERS."` SET `theme` = :theme
|
|
||||||
");
|
|
||||||
Database::pexecute($upd_stmt, array('theme' => $newfieldvalue));
|
|
||||||
}
|
|
||||||
if (Settings::Get('panel.allow_theme_change_admin') == '0') {
|
|
||||||
$upd_stmt = Database::prepare("
|
|
||||||
UPDATE `".TABLE_PANEL_ADMINS."` SET `theme` = :theme
|
|
||||||
");
|
|
||||||
Database::pexecute($upd_stmt, array('theme' => $newfieldvalue));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $returnvalue;
|
|
||||||
}
|
|
||||||
@@ -1,74 +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 Functions
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
function storeSettingField($fieldname, $fielddata, $newfieldvalue) {
|
|
||||||
|
|
||||||
if (is_array($fielddata)
|
|
||||||
&& isset($fielddata['settinggroup'])
|
|
||||||
&& $fielddata['settinggroup'] != ''
|
|
||||||
&& isset($fielddata['varname'])
|
|
||||||
&& $fielddata['varname'] != ''
|
|
||||||
) {
|
|
||||||
if (Settings::Set($fielddata['settinggroup'].'.'.$fielddata['varname'], $newfieldvalue) !== false) {
|
|
||||||
/*
|
|
||||||
* when fielddata[cronmodule] is set, this means enable/disable a cronjob
|
|
||||||
*/
|
|
||||||
if (isset($fielddata['cronmodule'])
|
|
||||||
&& $fielddata['cronmodule'] != ''
|
|
||||||
) {
|
|
||||||
toggleCronStatus($fielddata['cronmodule'], $newfieldvalue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* satisfy dependencies
|
|
||||||
*/
|
|
||||||
if (isset($fielddata['dependency'])
|
|
||||||
&& is_array($fielddata['dependency'])
|
|
||||||
) {
|
|
||||||
if ((int)$fielddata['dependency']['onlyif'] == (int)$newfieldvalue) {
|
|
||||||
storeSettingField($fielddata['dependency']['fieldname'], $fielddata['dependency']['fielddata'], $newfieldvalue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return array($fielddata['settinggroup'] . '.' . $fielddata['varname'] => $newfieldvalue);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function storeSettingFieldInsertBindTask($fieldname, $fielddata, $newfieldvalue) {
|
|
||||||
|
|
||||||
if (is_array($fielddata)
|
|
||||||
&& isset($fielddata['settinggroup'])
|
|
||||||
&& $fielddata['settinggroup'] != ''
|
|
||||||
&& isset($fielddata['varname'])
|
|
||||||
&& $fielddata['varname'] != ''
|
|
||||||
) {
|
|
||||||
if (Settings::Set($fielddata['settinggroup'].'.'.$fielddata['varname'], $newfieldvalue) !== false) {
|
|
||||||
return array($fielddata['settinggroup'] . '.' . $fielddata['varname'] => $newfieldvalue);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,57 +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 Functions
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
function storeSettingHostname($fieldname, $fielddata, $newfieldvalue) {
|
|
||||||
|
|
||||||
global $idna_convert;
|
|
||||||
|
|
||||||
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
|
||||||
|
|
||||||
if ($returnvalue !== false
|
|
||||||
&& is_array($fielddata)
|
|
||||||
&& isset($fielddata['settinggroup'])
|
|
||||||
&& $fielddata['settinggroup'] == 'system'
|
|
||||||
&& isset($fielddata['varname'])
|
|
||||||
&& $fielddata['varname'] == 'hostname'
|
|
||||||
) {
|
|
||||||
$newfieldvalue = $idna_convert->encode($newfieldvalue);
|
|
||||||
|
|
||||||
$customerstddomains_result_stmt = Database::prepare("
|
|
||||||
SELECT `standardsubdomain` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `standardsubdomain` <> '0'
|
|
||||||
");
|
|
||||||
Database::pexecute($customerstddomains_result_stmt);
|
|
||||||
|
|
||||||
$ids = array();
|
|
||||||
|
|
||||||
while ($customerstddomains_row = $customerstddomains_result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
||||||
$ids[] = (int)$customerstddomains_row['standardsubdomain'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count($ids) > 0) {
|
|
||||||
$upd_stmt = Database::prepare("
|
|
||||||
UPDATE `" . TABLE_PANEL_DOMAINS . "` SET
|
|
||||||
`domain` = REPLACE(`domain`, :host, :newval)
|
|
||||||
WHERE `id` IN ('" . implode(', ', $ids) . "')
|
|
||||||
");
|
|
||||||
Database::pexecute($upd_stmt, array('host' => Settings::Get('system.hostname'), 'newval' => $newfieldvalue));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $returnvalue;
|
|
||||||
}
|
|
||||||
@@ -1,40 +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 Functions
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
function storeSettingIpAddress($fieldname, $fielddata, $newfieldvalue) {
|
|
||||||
|
|
||||||
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
|
||||||
|
|
||||||
if ($returnvalue !== false
|
|
||||||
&& is_array($fielddata)
|
|
||||||
&& isset($fielddata['settinggroup'])
|
|
||||||
&& $fielddata['settinggroup'] == 'system'
|
|
||||||
&& isset($fielddata['varname'])
|
|
||||||
&& $fielddata['varname'] == 'ipaddress'
|
|
||||||
) {
|
|
||||||
$mysql_access_host_array = array_map('trim', explode(',', Settings::Get('system.mysql_access_host')));
|
|
||||||
$mysql_access_host_array[] = $newfieldvalue;
|
|
||||||
$mysql_access_host_array = array_unique(array_trim($mysql_access_host_array));
|
|
||||||
$mysql_access_host = implode(',', $mysql_access_host_array);
|
|
||||||
correctMysqlUsers($mysql_access_host_array);
|
|
||||||
Settings::Set('system.mysql_access_host', $mysql_access_host);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $returnvalue;
|
|
||||||
}
|
|
||||||
@@ -1,51 +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 Functions
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function storeSettingMysqlAccessHost($fieldname, $fielddata, $newfieldvalue)
|
|
||||||
{
|
|
||||||
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
|
||||||
|
|
||||||
if ($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'mysql_access_host') {
|
|
||||||
$mysql_access_host_array = array_map('trim', explode(',', $newfieldvalue));
|
|
||||||
|
|
||||||
if (in_array('127.0.0.1', $mysql_access_host_array) && ! in_array('localhost', $mysql_access_host_array)) {
|
|
||||||
$mysql_access_host_array[] = 'localhost';
|
|
||||||
}
|
|
||||||
|
|
||||||
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';
|
|
||||||
}
|
|
||||||
|
|
||||||
// be aware that ipv6 addresses are enclosed in [ ] when passed here
|
|
||||||
$mysql_access_host_array = array_map('cleanMySQLAccessHost', $mysql_access_host_array);
|
|
||||||
|
|
||||||
$mysql_access_host_array = array_unique(array_trim($mysql_access_host_array));
|
|
||||||
$newfieldvalue = implode(',', $mysql_access_host_array);
|
|
||||||
correctMysqlUsers($mysql_access_host_array);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $returnvalue;
|
|
||||||
}
|
|
||||||
|
|
||||||
function cleanMySQLAccessHost($value)
|
|
||||||
{
|
|
||||||
if (substr($value, 0, 1) == '[' && substr($value, - 1) == ']') {
|
|
||||||
return substr($value, 1, - 1);
|
|
||||||
}
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
@@ -1,50 +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 Froxlor team <team@froxlor.org> (2010-)
|
|
||||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
|
||||||
* @package Functions
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
function storeSettingResetCatchall($fieldname, $fielddata, $newfieldvalue) {
|
|
||||||
|
|
||||||
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
|
||||||
|
|
||||||
if ($returnvalue !== false
|
|
||||||
&& is_array($fielddata)
|
|
||||||
&& isset($fielddata['settinggroup'])
|
|
||||||
&& $fielddata['settinggroup'] == 'catchall'
|
|
||||||
&& isset($fielddata['varname'])
|
|
||||||
&& $fielddata['varname'] == 'catchall_enabled'
|
|
||||||
&& $newfieldvalue == '0'
|
|
||||||
) {
|
|
||||||
|
|
||||||
$result_stmt = Database::query("
|
|
||||||
SELECT `id`, `email`, `email_full`, `iscatchall` FROM `" . TABLE_MAIL_VIRTUAL . "`
|
|
||||||
WHERE `iscatchall` = '1'
|
|
||||||
");
|
|
||||||
|
|
||||||
if (Database::num_rows() > 0) {
|
|
||||||
|
|
||||||
$upd_stmt = Database::prepare("
|
|
||||||
UPDATE `" . TABLE_MAIL_VIRTUAL . "` SET `email` = :email, `iscatchall` = '0' WHERE `id` = :id
|
|
||||||
");
|
|
||||||
|
|
||||||
while ($result_row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
||||||
Database::pexecute($upd_stmt, array('email' => $result_row['email_full'], 'id' => $result_row['id']));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $returnvalue;
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This file is part of the Froxlor project.
|
|
||||||
* Copyright (c) 2015 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
|
|
||||||
*
|
|
||||||
* @since 0.9.34
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whenever the webserver- / FCGID- or FPM-user gets updated
|
|
||||||
* we need to update ftp_groups accordingly
|
|
||||||
*/
|
|
||||||
function storeSettingWebserverFcgidFpmUser($fieldname, $fielddata, $newfieldvalue)
|
|
||||||
{
|
|
||||||
if (is_array($fielddata) && isset($fielddata['settinggroup']) && isset($fielddata['varname'])) {
|
|
||||||
|
|
||||||
$update_user = null;
|
|
||||||
|
|
||||||
// webserver
|
|
||||||
if ($fielddata['settinggroup'] == 'system' && $fielddata['varname'] == 'httpuser') {
|
|
||||||
$update_user = Settings::Get('system.httpuser');
|
|
||||||
}
|
|
||||||
|
|
||||||
// fcgid
|
|
||||||
if ($fielddata['settinggroup'] == 'system' && $fielddata['varname'] == 'mod_fcgid_httpuser') {
|
|
||||||
$update_user = Settings::Get('system.mod_fcgid_httpuser');
|
|
||||||
}
|
|
||||||
|
|
||||||
// webserver
|
|
||||||
if ($fielddata['settinggroup'] == 'phpfpm' && $fielddata['varname'] == 'vhost_httpuser') {
|
|
||||||
$update_user = Settings::Get('phpfpm.vhost_httpuser');
|
|
||||||
}
|
|
||||||
|
|
||||||
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
|
||||||
|
|
||||||
if ($returnvalue !== false) {
|
|
||||||
/**
|
|
||||||
* only update if anything changed
|
|
||||||
*/
|
|
||||||
if ($update_user != null && $newfieldvalue != $update_user) {
|
|
||||||
$upd_stmt = Database::prepare("UPDATE `" . TABLE_FTP_GROUPS . "` SET `members` = REPLACE(`members`, :olduser, :newuser)");
|
|
||||||
Database::pexecute($upd_stmt, array('olduser' => $update_user, 'newuser' => $newfieldvalue));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $returnvalue;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user