get rid of storeSetting*-functions
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace Froxlor\Database;
|
||||
|
||||
use \Froxlor\Settings;
|
||||
use Froxlor\Settings;
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
@@ -11,14 +11,14 @@ use \Froxlor\Settings;
|
||||
* 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 Classes
|
||||
*
|
||||
* @since 0.9.31
|
||||
*
|
||||
* @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 Classes
|
||||
*
|
||||
* @since 0.9.31
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -27,22 +27,25 @@ use \Froxlor\Settings;
|
||||
* Wrapper-class for database-management like creating
|
||||
* and removing databases, users and permissions
|
||||
*
|
||||
* @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 Classes
|
||||
* @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 Classes
|
||||
*/
|
||||
class DbManager {
|
||||
class DbManager
|
||||
{
|
||||
|
||||
/**
|
||||
* FroxlorLogger object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
private $_log = null;
|
||||
|
||||
/**
|
||||
* Manager object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
private $_manager = null;
|
||||
@@ -52,7 +55,8 @@ class DbManager {
|
||||
*
|
||||
* @param \Froxlor\FroxlorLogger $log
|
||||
*/
|
||||
public function __construct($log = null) {
|
||||
public function __construct($log = null)
|
||||
{
|
||||
$this->_log = $log;
|
||||
$this->_setManager();
|
||||
}
|
||||
@@ -69,8 +73,8 @@ class DbManager {
|
||||
*
|
||||
* @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);
|
||||
|
||||
// check whether we shall create a random username
|
||||
@@ -80,7 +84,7 @@ class DbManager {
|
||||
// generate random username
|
||||
$username = $loginname . '-' . substr(md5(uniqid(microtime(), 1)), 20, 3);
|
||||
// check whether it exists on the DBMS
|
||||
while (in_array($username , $allsqlusers)) {
|
||||
while (in_array($username, $allsqlusers)) {
|
||||
$username = $loginname . '-' . substr(md5(uniqid(microtime(), 1)), 20, 3);
|
||||
}
|
||||
} else {
|
||||
@@ -113,7 +117,8 @@ class DbManager {
|
||||
* returns the manager-object
|
||||
* from where we can control it
|
||||
*/
|
||||
public function getManager() {
|
||||
public function getManager()
|
||||
{
|
||||
return $this->_manager;
|
||||
}
|
||||
|
||||
@@ -123,8 +128,71 @@ class DbManager {
|
||||
*
|
||||
* sets private $_manager variable
|
||||
*/
|
||||
private function _setManager() {
|
||||
private function _setManager()
|
||||
{
|
||||
// TODO read different dbms from settings later
|
||||
$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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user