Merge branch 'master' of github.com:Froxlor/Froxlor

This commit is contained in:
Roman Schmerold (BNoiZe)
2013-12-15 13:16:08 +01:00
35 changed files with 330 additions and 489 deletions

View File

@@ -297,7 +297,7 @@ class Database {
* @param bool $showerror if set to false, the error will be logged but we go on
*/
private static function _showerror($error, $showerror = true) {
global $userinfo, $settings, $theme, $linker;
global $userinfo, $theme, $linker;
/**
* log to a file, so we can actually ask people for the error
@@ -336,8 +336,8 @@ class Database {
$err_report_html = '';
if (is_array($userinfo) && (
($userinfo['adminsession'] == '1' && $settings['system']['allow_error_report_admin'] == '1')
|| ($userinfo['adminsession'] == '0' && $settings['system']['allow_error_report_customer'] == '1'))
($userinfo['adminsession'] == '1' && Settings::Get('system.allow_error_report_admin') == '1')
|| ($userinfo['adminsession'] == '0' && Settings::Get('system.allow_error_report_customer') == '1'))
) {
$err_report_html = '<a href="<LINK>" title="Click here to report error">Report error</a>';
$err_report_html = str_replace("<LINK>", $linker->getLink(array('section' => 'index', 'page' => 'send_error_report', 'errorid' => $errid)), $err_report_html);

View File

@@ -33,68 +33,65 @@ LOG_DEBUG debug-level message
*/
abstract class AbstractLogger
{
/**
* Settings array
* @var settings
*/
private $settings = array();
abstract class AbstractLogger {
/**
* Enable/Disable Logging
* @var logenabled
*/
private $logenabled = false;
/**
* Enable/Disable Cronjob-Logging
* @var logcronjob
*/
private $logcronjob = false;
/**
* Loggin-Severity
* @var severity
*/
private $severity = 1;
// normal
/**
* setup the main logger
*
* @param array settings
*/
protected function setupLogger($settings)
{
$this->settings = $settings;
$this->logenabled = $this->settings['logger']['enabled'];
$this->logcronjob = $this->settings['logger']['log_cron'];
$this->severity = $this->settings['logger']['severity'];
protected function setupLogger() {
$this->logenabled = Settings::Get('logger.enabled');
$this->logcronjob = Settings::Get('logger.log_cron');
$this->severity = Settings::Get('logger.severity');
}
protected function isEnabled()
{
/**
* return whether this logging is enabled
*
* @return bool
*/
protected function isEnabled() {
return $this->logenabled;
}
protected function getSeverity()
{
/**
* return the log severity
*
* @return int
*/
protected function getSeverity() {
return $this->severity;
}
protected function logCron()
{
/**
* whether to log cron-runs or not
*
* @return bool
*/
protected function logCron() {
return $this->logcronjob;
}
/**
* logs a given text
*/
abstract public function logAction();
}
?>
}

View File

@@ -16,69 +16,65 @@
* @package Logger
*
* @link http://www.nutime.de/
*
*
* Logger - File-Logger-Class
*/
class FileLogger extends AbstractLogger
{
class FileLogger extends AbstractLogger {
/**
* Userinfo
* @var array
*/
private $userinfo = array();
/**
/**
* Logfile
* @var logfile
*/
*/
private $logfile = null;
/**
* Syslogger Objects Array
* @var loggers
*/
static private $loggers = array();
/**
* Class constructor.
*
* @param array userinfo
* @param array settings
*/
protected function __construct($userinfo, $settings)
{
parent::setupLogger($settings);
*/
protected function __construct($userinfo) {
parent::setupLogger();
$this->userinfo = $userinfo;
$this->setLogFile($settings['logger']['logfile']);
$this->setLogFile(Settings::Get('logger.logfile'));
}
/**
* Singleton ftw ;-)
*
*/
static public function getInstanceOf($_usernfo, $_settings)
{
if(!isset(self::$loggers[$_usernfo['loginname']]))
{
self::$loggers[$_usernfo['loginname']] = new FileLogger($_usernfo, $_settings);
static public function getInstanceOf($_usernfo) {
if (!isset(self::$loggers[$_usernfo['loginname']])) {
self::$loggers[$_usernfo['loginname']] = new FileLogger($_usernfo);
}
return self::$loggers[$_usernfo['loginname']];
}
public function logAction($action = USR_ACTION, $type = LOG_NOTICE, $text = null)
{
if(parent::isEnabled())
{
if(parent::getSeverity() <= 1
&& $type == LOG_NOTICE)
{
/**
* logs a given text to all enabled logger-facilities
*
* @param int $action
* @param int $type
* @param string $text
*/
public function logAction($action = USR_ACTION, $type = LOG_NOTICE, $text = null) {
if (parent::isEnabled()) {
if (parent::getSeverity() <= 1
&& $type == LOG_NOTICE
) {
return;
}
@@ -87,22 +83,25 @@ class FileLogger extends AbstractLogger
switch($action)
{
case USR_ACTION:
$_action = 'customer';
$_action = $lng['admin']['customer'];
break;
case RES_ACTION:
$_action = 'reseller';
$_action = $lng['logger']['reseller'];
break;
case ADM_ACTION:
$_action = 'administrator';
$_action = $lng['logger']['admin'];
break;
case CRON_ACTION:
$_action = 'cronjob';
$_action = $lng['logger']['cron'];
break;
case LOGIN_ACTION:
$_action = $lng['logger']['login'];
break;
case LOG_ERROR:
$_action = 'internal';
$_action = $lng['logger']['intern'];
break;
default:
$_action = 'unknown';
$_action = $lng['logger']['unknown'];
break;
}
@@ -131,7 +130,7 @@ class FileLogger extends AbstractLogger
}
if(!isset($this->userinfo['loginname'])
|| $this->userinfo['loginname'] == '')
|| $this->userinfo['loginname'] == '')
{
$name = 'unknown';
}
@@ -147,7 +146,7 @@ class FileLogger extends AbstractLogger
$now = time();
if($text != null
&& $text != '')
&& $text != '')
{
fwrite($fp, date("d.m.Y H:i:s", $now) . " [" . $_type . "] [" . $_action . "-action" . $name . "] " . $text . "\n");
}
@@ -161,7 +160,7 @@ class FileLogger extends AbstractLogger
else
{
if($this->logfile != null
|| $this->logfile != '')
|| $this->logfile != '')
{
throw new Exception("Cannot open logfile '" . $this->logfile . "' for writing!");
}
@@ -172,10 +171,10 @@ class FileLogger extends AbstractLogger
public function setLogFile($filename = null)
{
if($filename != null
&& $filename != ''
&& $filename != "."
&& $filename != ".."
&& !is_dir($filename))
&& $filename != ''
&& $filename != "."
&& $filename != ".."
&& !is_dir($filename))
{
$this->logfile = $filename;
return true;

View File

@@ -16,24 +16,18 @@
* @package Logger
*
* @link http://www.nutime.de/
*
*
* Logger - Froxlor-Base-Logger-Class
*/
class FroxlorLogger
{
class FroxlorLogger {
/**
* Userinfo
* @var array
*/
private $userinfo = array();
/**
* Settings array
* @var settings
*/
private $settings = array();
/**
* LogTypes Array
* @var logtypes
@@ -50,25 +44,21 @@ class FroxlorLogger
* Class constructor.
*
* @param array userinfo
* @param array settings
*/
protected function __construct($userinfo, $settings) {
protected function __construct($userinfo) {
$this->userinfo = $userinfo;
$this->settings = $settings;
self::$logtypes = array();
if (!isset($this->settings['logger']['logtypes'])
&& (!isset($this->settings['logger']['logtypes']) || $this->settings['logger']['logtypes'] == '')
&& isset($this->settings['logger']['enabled'])
&& $this->settings['logger']['enabled']
if ((Settings::Get('logger.logtypes') == null || Settings::Get('logger.logtypes') == '')
&& (Settings::Get('logger.enabled') !== null && Settings::Get('logger.enabled'))
) {
self::$logtypes[0] = 'syslog';
self::$logtypes[1] = 'mysql';
} else {
if (isset($this->settings['logger']['logtypes'])
&& $this->settings['logger']['logtypes'] != ''
if (Settings::Get('logger.logtypes') !== null
&& Settings::Get('logger.logtypes') != ''
) {
self::$logtypes = explode(',', $this->settings['logger']['logtypes']);
self::$logtypes = explode(',', Settings::Get('logger.logtypes'));
} else {
self::$logtypes = null;
}
@@ -79,8 +69,8 @@ class FroxlorLogger
* Singleton ftw ;-)
*
*/
static public function getInstanceOf($_usernfo, $_settings)
{
static public function getInstanceOf($_usernfo) {
if (!isset($_usernfo)
|| $_usernfo == null
) {
@@ -89,19 +79,26 @@ class FroxlorLogger
}
if (!isset(self::$loggers[$_usernfo['loginname']])) {
self::$loggers[$_usernfo['loginname']] = new FroxlorLogger($_usernfo, $_settings);
self::$loggers[$_usernfo['loginname']] = new FroxlorLogger($_usernfo);
}
return self::$loggers[$_usernfo['loginname']];
}
/**
* logs a given text to all enabled logger-facilities
*
* @param int $action
* @param int $type
* @param string $text
*/
public function logAction ($action = USR_ACTION, $type = LOG_NOTICE, $text = null) {
if (self::$logtypes == null) {
return;
}
if ($this->settings['logger']['log_cron'] == '0'
if (Settings::Get('logger.log_cron') == '0'
&& $action == CRON_ACTION
) {
return;
@@ -112,12 +109,12 @@ class FroxlorLogger
switch ($logger)
{
case 'syslog':
$_log = SysLogger::getInstanceOf($this->userinfo, $this->settings);
$_log = SysLogger::getInstanceOf($this->userinfo);
break;
case 'file':
try
{
$_log = FileLogger::getInstanceOf($this->userinfo, $this->settings);
$_log = FileLogger::getInstanceOf($this->userinfo);
}
catch(Exception $e)
{
@@ -129,7 +126,7 @@ class FroxlorLogger
}
break;
case 'mysql':
$_log = MysqlLogger::getInstanceOf($this->userinfo, $this->settings);
$_log = MysqlLogger::getInstanceOf($this->userinfo);
break;
default:
$_log = null;
@@ -150,6 +147,13 @@ class FroxlorLogger
}
}
/**
* Set whether to log cron-runs
*
* @param bool $_cronlog
*
* @return boolean
*/
public function setCronLog($_cronlog = 0) {
$_cronlog = (int)$_cronlog;
@@ -159,13 +163,7 @@ class FroxlorLogger
) {
$_cronlog = 0;
}
$stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_SETTINGS . "` SET
`value` = :value
WHERE `settinggroup`='logger' AND `varname`='log_cron'"
);
Database::pexecute($stmt, array('value' => $_cronlog));
Settings::Set('logger.log_cron', $_cronlog);
return true;
}
}

View File

@@ -38,25 +38,29 @@ class MysqlLogger extends AbstractLogger {
* Class constructor.
*
* @param array userinfo
* @param array settings
*/
protected function __construct($userinfo, $settings) {
parent::setupLogger($settings);
protected function __construct($userinfo) {
parent::setupLogger();
$this->userinfo = $userinfo;
}
/**
* Singleton ftw ;-)
*
*/
static public function getInstanceOf($_usernfo, $_settings) {
static public function getInstanceOf($_usernfo) {
if (!isset(self::$loggers[$_usernfo['loginname']])) {
self::$loggers[$_usernfo['loginname']] = new MysqlLogger($_usernfo, $_settings);
self::$loggers[$_usernfo['loginname']] = new MysqlLogger($_usernfo);
}
return self::$loggers[$_usernfo['loginname']];
}
/**
* logs a given text to all enabled logger-facilities
*
* @param int $action
* @param int $type
* @param string $text
*/
public function logAction($action = USR_ACTION, $type = LOG_NOTICE, $text = null) {
if (parent::isEnabled()) {

View File

@@ -16,61 +16,58 @@
* @package Logger
*
* @link http://www.nutime.de/
*
*
* Logger - SysLog-Logger-Class
*/
class SysLogger extends AbstractLogger
{
class SysLogger extends AbstractLogger {
/**
* Userinfo
* @var array
*/
private $userinfo = array();
/**
* Syslogger Objects Array
* @var loggers
*/
*/
static private $loggers = array();
/**
* Class constructor.
*
* @param array userinfo
* @param array settings
*/
protected function __construct($userinfo, $settings)
{
parent::setupLogger($settings);
*/
protected function __construct($userinfo) {
parent::setupLogger();
$this->userinfo = $userinfo;
}
/**
* Singleton ftw ;-)
*
*/
static public function getInstanceOf($_usernfo, $_settings)
{
if(!isset(self::$loggers[$_usernfo['loginname']]))
{
self::$loggers[$_usernfo['loginname']] = new SysLogger($_usernfo, $_settings);
static public function getInstanceOf($_usernfo) {
if (!isset(self::$loggers[$_usernfo['loginname']])) {
self::$loggers[$_usernfo['loginname']] = new SysLogger($_usernfo);
}
return self::$loggers[$_usernfo['loginname']];
}
public function logAction($action = USR_ACTION, $type = LOG_NOTICE, $text = null)
{
if(parent::isEnabled())
{
if(parent::getSeverity() <= 1
&& $type == LOG_NOTICE)
{
/**
* logs a given text to all enabled logger-facilities
*
* @param int $action
* @param int $type
* @param string $text
*/
public function logAction($action = USR_ACTION, $type = LOG_NOTICE, $text = null) {
if (parent::isEnabled()) {
if (parent::getSeverity() <= 1
&& $type == LOG_NOTICE
) {
return;
}
@@ -79,28 +76,31 @@ class SysLogger extends AbstractLogger
switch($action)
{
case USR_ACTION:
$_action = 'customer';
$_action = $lng['admin']['customer'];
break;
case RES_ACTION:
$_action = 'reseller';
$_action = $lng['logger']['reseller'];
break;
case ADM_ACTION:
$_action = 'administrator';
$_action = $lng['logger']['admin'];
break;
case CRON_ACTION:
$_action = 'cronjob';
$_action = $lng['logger']['cron'];
break;
case LOGIN_ACTION:
$_action = $lng['logger']['login'];
break;
case LOG_ERROR:
$_action = 'internal';
$_action = $lng['logger']['intern'];
break;
default:
$_action = 'unknown';
$_action = $lng['logger']['unknown'];
break;
}
if(!isset($this->userinfo['loginname'])
|| $this->userinfo['loginname'] == '')
{
if (!isset($this->userinfo['loginname'])
|| $this->userinfo['loginname'] == ''
) {
$name = 'unknown';
}
else
@@ -110,13 +110,11 @@ class SysLogger extends AbstractLogger
openlog("Froxlor", LOG_NDELAY, LOG_USER);
if($text != null
&& $text != '')
{
if ($text != null
&& $text != ''
) {
syslog((int)$type, "[" . ucfirst($_action) . " Action" . $name . "] " . $text);
}
else
{
} else {
syslog((int)$type, "[" . ucfirst($_action) . " Action" . $name . "] No text given!!! Check scripts!");
}

View File

@@ -21,12 +21,6 @@
class phpinterface {
/**
* Settings array
* @var array
*/
private $_settings = array();
/**
* Domain-Data array
* @var array
@@ -48,8 +42,7 @@ class phpinterface {
/**
* main constructor
*/
public function __construct($settings, $domain) {
$this->_settings = $settings;
public function __construct($domain) {
$this->_domain = $domain;
$this->_setInterface();
}
@@ -69,11 +62,11 @@ class phpinterface {
*/
private function _setInterface() {
// php-fpm
if ((int)$this->_settings['phpfpm']['enabled'] == 1) {
$this->_interface = new phpinterface_fpm($this->_settings, $this->_domain);
if ((int)Settings::Get('phpfpm.enabled') == 1) {
$this->_interface = new phpinterface_fpm($this->_domain);
} elseif ((int)$this->_settings['system']['mod_fcgid'] == 1) {
$this->_interface = new phpinterface_fcgid($this->_settings, $this->_domain);
} elseif ((int)Settings::Get('system.mod_fcgid') == 1) {
$this->_interface = new phpinterface_fcgid($this->_domain);
}
}

View File

@@ -21,12 +21,6 @@
class phpinterface_fcgid {
/**
* Settings array
* @var array
*/
private $_settings = array();
/**
* Domain-Data array
* @var array
@@ -42,11 +36,14 @@ class phpinterface_fcgid {
/**
* main constructor
*/
public function __construct($settings, $domain) {
$this->_settings = $settings;
public function __construct($domain) {
$this->_domain = $domain;
}
/**
* create fcgid-starter-file
* @param array $phpconfig
*/
public function createConfig($phpconfig) {
// create starter
@@ -67,7 +64,7 @@ class phpinterface_fcgid {
if ((int)$phpconfig['mod_fcgid_starter'] != - 1) {
$starter_file.= "PHP_FCGI_CHILDREN=" . (int)$phpconfig['mod_fcgid_starter'] . "\n";
} else {
$starter_file.= "PHP_FCGI_CHILDREN=" . (int)$this->_settings['system']['mod_fcgid_starter'] . "\n";
$starter_file.= "PHP_FCGI_CHILDREN=" . (int)Settings::Get('system.mod_fcgid_starter') . "\n";
}
}
@@ -80,7 +77,7 @@ class phpinterface_fcgid {
if ((int)$phpconfig['mod_fcgid_maxrequests'] != - 1) {
$starter_file.= "PHP_FCGI_MAX_REQUESTS=" . (int)$phpconfig['mod_fcgid_maxrequests'] . "\n";
} else {
$starter_file.= "PHP_FCGI_MAX_REQUESTS=" . (int)$this->_settings['system']['mod_fcgid_maxrequests'] . "\n";
$starter_file.= "PHP_FCGI_MAX_REQUESTS=" . (int)Settings::Get('system.mod_fcgid_maxrequests') . "\n";
}
}
@@ -117,12 +114,12 @@ class phpinterface_fcgid {
$openbasedirc = '';
$_phpappendopenbasedir = '';
$_custom_openbasedir = explode(':', $this->_settings['system']['mod_fcgid_peardir']);
$_custom_openbasedir = explode(':', Settings::Get('system.mod_fcgid_peardir'));
foreach ($_custom_openbasedir as $cobd) {
$_phpappendopenbasedir .= appendOpenBasedirPath($cobd);
}
$_custom_openbasedir = explode(':', $this->_settings['system']['phpappendopenbasedir']);
$_custom_openbasedir = explode(':', Settings::Get('system.phpappendopenbasedir'));
foreach ($_custom_openbasedir as $cobd) {
$_phpappendopenbasedir .= appendOpenBasedirPath($cobd);
}
@@ -155,10 +152,10 @@ class phpinterface_fcgid {
$admin = $this->_getAdminData($this->_domain['adminid']);
$php_ini_variables = array(
'SAFE_MODE' => 'Off', // keep this for compatibility, just in case
'PEAR_DIR' => $this->_settings['system']['mod_fcgid_peardir'],
'PEAR_DIR' => Settings::Get('system.mod_fcgid_peardir'),
'OPEN_BASEDIR' => $openbasedir,
'OPEN_BASEDIR_C' => $openbasedirc,
'OPEN_BASEDIR_GLOBAL' => $this->_settings['system']['phpappendopenbasedir'],
'OPEN_BASEDIR_GLOBAL' => Settings::Get('system.hpappendopenbasedir'),
'TMP_DIR' => $this->getTempDir(),
'CUSTOMER_EMAIL' => $this->_domain['email'],
'ADMIN_EMAIL' => $admin['email'],
@@ -192,7 +189,7 @@ class phpinterface_fcgid {
*/
public function getConfigDir($createifnotexists = true) {
$configdir = makeCorrectDir($this->_settings['system']['mod_fcgid_configdir'] . '/' . $this->_domain['loginname'] . '/' . $this->_domain['domain'] . '/');
$configdir = makeCorrectDir(Settings::Get('system.mod_fcgid_configdir') . '/' . $this->_domain['loginname'] . '/' . $this->_domain['domain'] . '/');
if (!is_dir($configdir) && $createifnotexists) {
safe_exec('mkdir -p ' . escapeshellarg($configdir));
@@ -211,7 +208,7 @@ class phpinterface_fcgid {
*/
public function getTempDir($createifnotexists = true) {
$tmpdir = makeCorrectDir($this->_settings['system']['mod_fcgid_tmpdir'] . '/' . $this->_domain['loginname'] . '/');
$tmpdir = makeCorrectDir(Settings::Get('system.mod_fcgid_tmpdir') . '/' . $this->_domain['loginname'] . '/');
if (!is_dir($tmpdir) && $createifnotexists) {
safe_exec('mkdir -p ' . escapeshellarg($tmpdir));

View File

@@ -21,12 +21,6 @@
class phpinterface_fpm {
/**
* Settings array
* @var array
*/
private $_settings = array();
/**
* Domain-Data array
* @var array
@@ -96,8 +90,7 @@ class phpinterface_fpm {
/**
* main constructor
*/
public function __construct($settings, $domain) {
$this->_settings = $settings;
public function __construct($domain) {
$this->_domain = $domain;
}
@@ -111,13 +104,13 @@ class phpinterface_fpm {
$fh = @fopen($this->getConfigFile(), 'w');
if ($fh) {
$fpm_pm = $this->_settings['phpfpm']['pm'];
$fpm_children = (int)$this->_settings['phpfpm']['max_children'];
$fpm_start_servers = (int)$this->_settings['phpfpm']['start_servers'];
$fpm_min_spare_servers = (int)$this->_settings['phpfpm']['min_spare_servers'];
$fpm_max_spare_servers = (int)$this->_settings['phpfpm']['max_spare_servers'];
$fpm_requests = (int)$this->_settings['phpfpm']['max_requests'];
$fpm_process_idle_timeout = (int)$this->_settings['phpfpm']['idle_timeout'];
$fpm_pm = Settings::Get('phpfpm.pm');
$fpm_children = (int)Settings::Get('phpfpm.max_children');
$fpm_start_servers = (int)Settings::Get('phpfpm.start_servers');
$fpm_min_spare_servers = (int)Settings::Get('phpfpm.min_spare_servers');
$fpm_max_spare_servers = (int)Settings::Get('phpfpm.max_spare_servers');
$fpm_requests = (int)Settings::Get('phpfpm.max_requests');
$fpm_process_idle_timeout = (int)Settings::Get('phpfpm.idle_timeout');
if ($fpm_children == 0) {
$fpm_children = 1;
@@ -168,14 +161,14 @@ class phpinterface_fpm {
if ($phpconfig['fpm_slowlog'] == '1') {
$fpm_config.= 'request_terminate_timeout = ' . $phpconfig['fpm_reqterm'] . "\n";
$fpm_config.= 'request_slowlog_timeout = ' . $phpconfig['fpm_reqslow'] . "\n";
$slowlog = makeCorrectFile($this->_settings['system']['logfiles_directory'] . '/' . $this->_domain['loginname'] . '-php-slow.log');
$slowlog = makeCorrectFile(Settings::Get('system.logfiles_directory') . '/' . $this->_domain['loginname'] . '-php-slow.log');
$fpm_config.= 'slowlog = ' . $slowlog . "\n";
$fpm_config.= 'catch_workers_output = yes' . "\n";
}
$fpm_config.= ';chroot = '.makeCorrectDir($this->_domain['documentroot'])."\n";
$tmpdir = makeCorrectDir($this->_settings['phpfpm']['tmpdir'] . '/' . $this->_domain['loginname'] . '/');
$tmpdir = makeCorrectDir(Settings::Get('phpfpm.tmpdir') . '/' . $this->_domain['loginname'] . '/');
if (!is_dir($tmpdir)) {
$this->getTempDir();
}
@@ -188,12 +181,12 @@ class phpinterface_fpm {
if ($this->_domain['loginname'] != 'froxlor.panel') {
if ($this->_domain['openbasedir'] == '1') {
$_phpappendopenbasedir = '';
$_custom_openbasedir = explode(':', $this->_settings['phpfpm']['peardir']);
$_custom_openbasedir = explode(':', Settings::Get('phpfpm.peardir'));
foreach ($_custom_openbasedir as $cobd) {
$_phpappendopenbasedir .= appendOpenBasedirPath($cobd);
}
$_custom_openbasedir = explode(':', $this->_settings['system']['phpappendopenbasedir']);
$_custom_openbasedir = explode(':', Settings::Get('system.phpappendopenbasedir'));
foreach ($_custom_openbasedir as $cobd) {
$_phpappendopenbasedir .= appendOpenBasedirPath($cobd);
}
@@ -219,14 +212,14 @@ class phpinterface_fpm {
$openbasedir = implode(':', $clean_openbasedir);
}
}
$fpm_config.= 'php_admin_value[session.save_path] = ' . makeCorrectDir($this->_settings['phpfpm']['tmpdir'] . '/' . $this->_domain['loginname'] . '/') . "\n";
$fpm_config.= 'php_admin_value[upload_tmp_dir] = ' . makeCorrectDir($this->_settings['phpfpm']['tmpdir'] . '/' . $this->_domain['loginname'] . '/') . "\n";
$fpm_config.= 'php_admin_value[session.save_path] = ' . makeCorrectDir(Settings::Get('phpfpm.tmpdir') . '/' . $this->_domain['loginname'] . '/') . "\n";
$fpm_config.= 'php_admin_value[upload_tmp_dir] = ' . makeCorrectDir(Settings::Get('phpfpm.tmpdir') . '/' . $this->_domain['loginname'] . '/') . "\n";
$admin = $this->_getAdminData($this->_domain['adminid']);
$php_ini_variables = array(
'SAFE_MODE' => 'Off', // keep this for compatibility, just in case
'PEAR_DIR' => $this->_settings['system']['mod_fcgid_peardir'],
'PEAR_DIR' => Settings::Get('system.mod_fcgid_peardir'),
'TMP_DIR' => $this->getTempDir(),
'CUSTOMER_EMAIL' => $this->_domain['email'],
'ADMIN_EMAIL' => $admin['email'],
@@ -284,7 +277,7 @@ class phpinterface_fpm {
*/
public function getConfigFile($createifnotexists = true) {
$configdir = makeCorrectDir($this->_settings['phpfpm']['configdir']);
$configdir = makeCorrectDir(Settings::Get('phpfpm.configdir'));
$config = makeCorrectFile($configdir.'/'.$this->_domain['domain'].'.conf');
if (!is_dir($configdir) && $createifnotexists) {
@@ -303,14 +296,12 @@ class phpinterface_fpm {
*/
public function getSocketFile($createifnotexists = true) {
// see #1300 why this has changed
//$socketdir = makeCorrectDir('/var/run/'.$this->_settings['system']['webserver'].'/');
$socketdir = makeCorrectDir($this->_settings['phpfpm']['fastcgi_ipcdir']);
$socketdir = makeCorrectDir(Settings::Get('phpfpm.fastcgi_ipcdir'));
$socket = makeCorrectFile($socketdir.'/'.$this->_domain['loginname'].'-'.$this->_domain['domain'].'-php-fpm.socket');
if (!is_dir($socketdir) && $createifnotexists) {
safe_exec('mkdir -p '.escapeshellarg($socketdir));
safe_exec('chown -R '.$this->_settings['system']['httpuser'].':'.$this->_settings['system']['httpgroup'].' '.escapeshellarg($socketdir));
safe_exec('chown -R '.Settings::Get('system.httpuser').':'.Settings::Get('system.httpgroup').' '.escapeshellarg($socketdir));
}
return $socket;
@@ -325,7 +316,7 @@ class phpinterface_fpm {
*/
public function getTempDir($createifnotexists = true) {
$tmpdir = makeCorrectDir($this->_settings['phpfpm']['tmpdir'] . '/' . $this->_domain['loginname'] . '/');
$tmpdir = makeCorrectDir(Settings::Get('phpfpm.tmpdir') . '/' . $this->_domain['loginname'] . '/');
if (!is_dir($tmpdir) && $createifnotexists) {
safe_exec('mkdir -p ' . escapeshellarg($tmpdir));
@@ -346,11 +337,11 @@ class phpinterface_fpm {
public function getAliasConfigDir($createifnotexists = true) {
// ensure default...
if (!isset($this->_settings['phpfpm']['aliasconfigdir'])) {
$this->_settings['phpfpm']['aliasconfigdir'] = '/var/www/php-fpm';
if (Settings::Get('phpfpm.aliasconfigdir') == null) {
Settings::Set('phpfpm.aliasconfigdir', '/var/www/php-fpm');
}
$configdir = makeCorrectDir($this->_settings['phpfpm']['aliasconfigdir'] . '/' . $this->_domain['loginname'] . '/' . $this->_domain['domain'] . '/');
$configdir = makeCorrectDir(Settings::Get('phpfpm.aliasconfigdir') . '/' . $this->_domain['loginname'] . '/' . $this->_domain['domain'] . '/');
if (!is_dir($configdir) && $createifnotexists) {
safe_exec('mkdir -p ' . escapeshellarg($configdir));
safe_exec('chown ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($configdir));

View File

@@ -28,12 +28,6 @@ class ticket {
*/
private $userinfo = array();
/**
* Settings array
* @var settings
*/
private $settings = array();
/**
* Ticket ID
* @var tid
@@ -62,12 +56,10 @@ class ticket {
* Class constructor.
*
* @param array userinfo
* @param array settings
* @param int ticket id
*/
private function __construct($userinfo, $settings, $tid = - 1) {
private function __construct($userinfo, $tid = - 1) {
$this->userinfo = $userinfo;
$this->settings = $settings;
$this->tid = $tid;
// initialize purifier
@@ -88,12 +80,11 @@ class ticket {
* Singleton ftw ;-)
*
* @param array userinfo
* @param array settings
* @param int ticket id
*/
static public function getInstanceOf($_usernfo, $_settings, $_tid) {
static public function getInstanceOf($_usernfo, $_tid) {
if (!isset(self::$tickets[$_tid])) {
self::$tickets[$_tid] = new ticket($_usernfo, $_settings, $_tid);
self::$tickets[$_tid] = new ticket($_usernfo, $_tid);
}
return self::$tickets[$_tid];
}
@@ -310,7 +301,7 @@ class ticket {
if ($customerid != - 1) {
$_mailerror = false;
try {
$mail->SetFrom($this->settings['ticket']['noreply_email'], $this->settings['ticket']['noreply_name']);
$mail->SetFrom(Settings::Get('ticket.noreply_email'), Settings::Get('ticket.noreply_name'));
$mail->Subject = $mail_subject;
$mail->AltBody = $mail_body;
$mail->MsgHTML(str_replace("\n", "<br />", $mail_body));
@@ -325,7 +316,7 @@ class ticket {
}
if ($_mailerror) {
$rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'ticket_class'), $this->settings);
$rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'ticket_class'));
$rstlog->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
standard_error('errorsendingmail', $usr['email']);
}
@@ -340,7 +331,7 @@ class ticket {
$admin = Database::pexecute_first($admin_stmt, array('adminid' => $this->userinfo['adminid']));
$_mailerror = false;
try {
$mail->SetFrom($this->settings['ticket']['noreply_email'], $this->settings['ticket']['noreply_name']);
$mail->SetFrom(Settings::Get('ticket.noreply_email'), Settings::Get('ticket.noreply_name'));
$mail->Subject = $mail_subject;
$mail->AltBody = $mail_body;
$mail->MsgHTML(str_replace("\n", "<br />", $mail_body));
@@ -355,7 +346,7 @@ class ticket {
}
if ($_mailerror) {
$rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'ticket_class'), $this->settings);
$rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'ticket_class'));
$rstlog->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
standard_error('errorsendingmail', $admin['email']);
}

View File

@@ -21,19 +21,9 @@
class ConfigIO {
/**
* internal settings array
*
* @var array
* constructor
*/
private $_settings = null;
/**
* constructor gets the froxlor settings
* as array
*/
public function __construct(array $settings = null) {
$this->_settings = $settings;
}
public function __construct() {}
/**
* clean up former created configs, including (if enabled)
@@ -73,7 +63,7 @@ class ConfigIO {
/*
* only clean up if we're actually using SSL
*/
if ($this->_settings['system']['use_ssl'] == '1') {
if (Settings::Get('system.use_ssl') == '1') {
// get correct directory
$configdir = $this->_getFile('system', 'customer_ssl_path');
if ($configdir !== false) {
@@ -158,7 +148,7 @@ class ConfigIO {
*/
private function _cleanAwstatsFiles() {
if ($this->_settings['system']['awstats_enabled'] == '0') {
if (Settings::Get('system.awstats_enabled') == '0') {
return;
}
@@ -204,7 +194,7 @@ class ConfigIO {
*/
private function _cleanFcgidFiles() {
if ($this->_settings['system']['mod_fcgid'] == '0') {
if (Settings::Get('system.mod_fcgid') == '0') {
return;
}
@@ -246,7 +236,7 @@ class ConfigIO {
*/
private function _cleanFpmFiles() {
if ($this->_settings['phpfpm']['enabled'] == '0') {
if (Settings::Get('phpfpm.enabled') == '0') {
return;
}
@@ -276,7 +266,7 @@ class ConfigIO {
}
/**
* returns a file/direcotry from the settings array and checks whether it exists
* returns a file/direcotry from the settings and checks whether it exists
*
* @param string $group settings-group
* @param string $varname var-name
@@ -287,7 +277,7 @@ class ConfigIO {
private function _getFile($group, $varname, $check_exists = true) {
// read from settings
$file = $this->_settings[$group][$varname];
$file = Settings::Get($group.'.'.$varname);
// check whether it exists
if ($check_exists && @file_exists($file) == false) {

View File

@@ -21,18 +21,9 @@
class DomainSSL {
/**
* internal settings array
*
* @var array
* constructor
*/
private $_settings = null;
/**
* constructor gets the froxlor settings as array
*/
public function __construct(array $settings = null) {
$this->_settings = $settings;
}
public function __construct() {}
/**
* read domain-related (or if empty, parentdomain-related) ssl-certificates from the database
@@ -66,7 +57,7 @@ class DomainSSL {
&& $dom_certs['ssl_cert_file'] != ''
) {
// get destination path
$sslcertpath = makeCorrectDir($this->_settings['system']['customer_ssl_path']);
$sslcertpath = makeCorrectDir(Settings::Get('system.customer_ssl_path'));
// create path if it does not exist
if (!file_exists($sslcertpath)) {
safe_exec('mkdir -p '.escapeshellarg($sslcertpath));
@@ -77,7 +68,7 @@ class DomainSSL {
'ssl_key_file' => makeCorrectFile($sslcertpath.'/'.$domain['domain'].'.key')
);
if ($this->_settings['system']['webserver'] == 'lighttpd') {
if (Settings::Get('system.webserver') == 'lighttpd') {
// put my.crt and my.key together for lighty.
$dom_certs['ssl_cert_file'] = trim($dom_certs['ssl_cert_file'])."\n".trim($dom_certs['ssl_key_file'])."\n";
$ssl_files['ssl_key_file'] = '';
@@ -91,7 +82,7 @@ class DomainSSL {
$ssl_files['ssl_ca_file'] = makeCorrectFile($sslcertpath.'/'.$domain['domain'].'_CA.pem');
}
if ($dom_certs['ssl_cert_chainfile'] != '') {
if ($this->_settings['system']['webserver'] == 'nginx') {
if (Settings::Get('system.webserver') == 'nginx') {
// put ca.crt in my.crt, as nginx does not support a separate chain file.
$dom_certs['ssl_cert_file'] = trim($dom_certs['ssl_cert_file'])."\n".trim($dom_certs['ssl_cert_chainfile'])."\n";
} else {
@@ -117,4 +108,4 @@ class DomainSSL {
return;
}
}
}

View File

@@ -24,34 +24,30 @@
*
* @return void
*/
function makeChownWithNewStats($row)
{
global $settings;
function makeChownWithNewStats($row) {
// get correct user
if($settings['system']['mod_fcgid'] == '1' && isset($row['deactivated']) && $row['deactivated'] == '0')
{
if ((Settings::Get('system.mod_fcgid') == '1' || Settings::Get('phpfpm.enabled') == '1')
&& isset($row['deactivated'])
&& $row['deactivated'] == '0'
) {
$user = $row['loginname'];
$group = $row['loginname'];
}
else
{
} else {
$user = $row['guid'];
$group = $row['guid'];
}
// get correct directory
$dir = $row['documentroot'];
if($settings['system']['awstats_enabled'] == '1')
{
if (Settings::Get('system.awstats_enabled') == '1') {
$dir .= '/awstats/';
} else {
$dir .= '/webalizer/';
}
// only run chown if directory exists
if (file_exists($dir))
{
if (file_exists($dir)) {
// run chown
safe_exec('chown -R '.escapeshellarg($user).':'.escapeshellarg($group).' '.escapeshellarg(makeCorrectDir($dir)));
}

View File

@@ -27,10 +27,8 @@
*/
function storeDefaultIndex($loginname = null, $destination = null, $logger = null, $force = false) {
global $settings;
if ($force
|| (int)$settings['system']['store_index_file_subs'] == 1
|| (int)Settings::Get('system.store_index_file_subs') == 1
) {
$result_stmt = Database::prepare("
SELECT `t`.`value`, `c`.`email` AS `customer_email`, `a`.`email` AS `admin_email`, `c`.`loginname` AS `customer_login`, `a`.`loginname` AS `admin_login`
@@ -46,7 +44,7 @@ function storeDefaultIndex($loginname = null, $destination = null, $logger = nul
$template = $result_stmt->fetch(PDO::FETCH_ASSOC);
$replace_arr = array(
'SERVERNAME' => $settings['system']['hostname'],
'SERVERNAME' => Settings::Get('system.hostname'),
'CUSTOMER' => $template['customer_login'],
'ADMIN' => $template['admin_login'],
'CUSTOMER_EMAIL' => $template['customer_email'],
@@ -54,12 +52,12 @@ function storeDefaultIndex($loginname = null, $destination = null, $logger = nul
);
$htmlcontent = replace_variables($template['value'], $replace_arr);
$indexhtmlpath = makeCorrectFile($destination . '/index.' . $settings['system']['index_file_extension']);
$indexhtmlpath = makeCorrectFile($destination . '/index.' . Settings::Get('system.index_file_extension'));
$index_html_handler = fopen($indexhtmlpath, 'w');
fwrite($index_html_handler, $htmlcontent);
fclose($index_html_handler);
if ($logger !== null) {
$logger->logAction(CRON_ACTION, LOG_NOTICE, 'Creating \'index.' . $settings['system']['index_file_extension'] . '\' for Customer \'' . $template['customer_login'] . '\' based on template in directory ' . escapeshellarg($indexhtmlpath));
$logger->logAction(CRON_ACTION, LOG_NOTICE, 'Creating \'index.' . Settings::Get('system.index_file_extension') . '\' for Customer \'' . $template['customer_login'] . '\' based on template in directory ' . escapeshellarg($indexhtmlpath));
}
} else {

View File

@@ -26,7 +26,7 @@
*/
function correctErrorDocument($errdoc = null) {
global $settings, $idna_convert;
global $idna_convert;
if ($errdoc !== null && $errdoc != '') {
// not a URL
@@ -45,15 +45,14 @@ function correctErrorDocument($errdoc = null) {
// a string (check for ending ")
else {
// string won't work for lighty
if ($settings['system']['webserver'] == 'lighttpd') {
if (Settings::Get('system.webserver') == 'lighttpd') {
standard_error('stringerrordocumentnotvalidforlighty');
} elseif(substr($errdoc, -1) != '"') {
$errdoc .= '"';
}
}
} else {
if ($settings['system']['webserver'] == 'lighttpd') {
if (Settings::Get('system.webserver') == 'lighttpd') {
standard_error('urlerrordocumentnotvalidforlighty');
}
}

View File

@@ -28,8 +28,6 @@
*/
function createAWStatsConf($logFile, $siteDomain, $hostAliases, $customerDocroot, $awstats_params = array()) {
global $settings;
// Generation header
$header = "## GENERATED BY FROXLOR\n";
$header2 = "## Do not remove the line above! This tells Froxlor to update this configuration\n## If you wish to manually change this configuration file, remove the first line to make sure Froxlor won't rebuild this file\n## Generated for domain {SITE_DOMAIN} on " . date('l dS \of F Y h:i:s A') . "\n";
@@ -42,8 +40,8 @@ function createAWStatsConf($logFile, $siteDomain, $hostAliases, $customerDocroot
makeChownWithNewStats($awstats_params);
// weird but could happen...
if (!is_dir($settings['system']['awstats_conf'])) {
safe_exec('mkdir -p '.escapeshellarg($settings['system']['awstats_conf']));
if (!is_dir(Settings::Get('system.awstats_conf'))) {
safe_exec('mkdir -p '.escapeshellarg(Settings::Get('system.awstats_conf')));
}
// These are the variables we will replace
@@ -59,11 +57,11 @@ function createAWStatsConf($logFile, $siteDomain, $hostAliases, $customerDocroot
$siteDomain,
$hostAliases,
$awstats_dir,
makeCorrectDir($settings['system']['awstats_conf'])
makeCorrectDir(Settings::Get('system.awstats_conf'))
);
// File names
$domain_file = makeCorrectFile($settings['system']['awstats_conf'].'/awstats.' . $siteDomain . '.conf');
$domain_file = makeCorrectFile(Settings::Get('system.awstats_conf').'/awstats.' . $siteDomain . '.conf');
$model_file = FROXLOR_INSTALL_DIR.'/templates/misc/awstatsmodel/awstats.froxlor.model.conf';
$model_file = makeCorrectFile($model_file);

View File

@@ -1,49 +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
*
*/
/**
* This function generates the VHost configuration for AWStats
* This will enable the /awstats url and enable security on these folders
* @author Berend Dekens
*
* @param siteDomain Name of the domain we want stats for
*
* @return String with configuration for use in vhost file
*/
function createAWStatsVhost($siteDomain, $settings = null) {
if ($settings['system']['mod_fcgid'] != '1') {
$vhosts_file = ' # AWStats statistics' . "\n";
$vhosts_file.= ' RewriteEngine On' . "\n";
$vhosts_file.= ' RewriteRule ^/awstats(/.*)?$ /awstats/awstats.pl?config=' . $siteDomain . ' [L,PT]' . "\n";
$vhosts_file.= ' RewriteRule ^/awstats.pl(.*)$ /awstats/awstats.pl$1 [QSA,L,PT]' . "\n";
} else {
$vhosts_file = ' <IfModule mod_proxy.c>' . "\n";
$vhosts_file.= ' RewriteEngine On' . "\n";
$vhosts_file.= ' RewriteRule awstats.pl(.*)$ http://' . $settings['system']['hostname'] . '/cgi-bin/awstats.pl$1 [R,P]' . "\n";
$vhosts_file.= ' RewriteRule awstats$ http://' . $settings['system']['hostname'] . '/cgi-bin/awstats.pl?config=' . $siteDomain . ' [R,P]' . "\n";
$vhosts_file.= ' </IfModule>' . "\n";
}
return $vhosts_file;
}

View File

@@ -19,9 +19,8 @@
* Generates a random password
*/
function generatePassword() {
global $settings;
return substr(
base64_encode(sha1(md5(uniqid(microtime(), 1))).md5(uniqid(microtime(), 1)).sha1(md5(uniqid(microtime(), 1)))),
rand(5, 50), ($settings['panel']['password_min_length'] > 0 ? $settings['panel']['password_min_length'] : 10)
rand(5, 50), (Settings::Get('panel.password_min_length') > 0 ? Settings::Get('panel.password_min_length') : 10)
);
}

View File

@@ -15,38 +15,34 @@
*
*/
function getFilesystemQuota()
{
global $settings, $theme;
if ($settings['system']['diskquota_enabled'])
{
# Fetch all quota in the desired partition
exec($settings['system']['diskquota_repquota_path'] . " -np " . escapeshellarg($settings['system']['diskquota_customer_partition']), $repquota);
function getFilesystemQuota() {
if (Settings::Get('system.diskquota_enabled')) {
// Fetch all quota in the desired partition
exec(Settings::Get('system.diskquota_repquota_path') . " -np " . escapeshellarg(Settings::Get('system.diskquota_customer_partition')), $repquota);
$usedquota = array();
foreach ($repquota as $tmpquota)
{
# Let's see if the line matches a quota - line
if (preg_match('/^#([0-9]+)\s*[+-]{2}\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)/i', $tmpquota, $matches))
{
# It matches - put it into an array with userid as key (for easy lookup later)
foreach ($repquota as $tmpquota) {
// Let's see if the line matches a quota - line
if (preg_match('/^#([0-9]+)\s*[+-]{2}\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)/i', $tmpquota, $matches)) {
// It matches - put it into an array with userid as key (for easy lookup later)
$usedquota[$matches[1]] = array(
'block' => array(
'used' => $matches[2],
'soft' => $matches[3],
'hard' => $matches[4],
'grace' => $matches[5]
),
'used' => $matches[2],
'soft' => $matches[3],
'hard' => $matches[4],
'grace' => $matches[5]
),
'file' => array(
'used' => $matches[6],
'soft' => $matches[7],
'hard' => $matches[8],
'grace' => $matches[9]
),
'used' => $matches[6],
'soft' => $matches[7],
'hard' => $matches[8],
'grace' => $matches[9]
),
);
}
}
return $usedquota;
}
return false;

View File

@@ -29,8 +29,6 @@
function inserttask($type, $param1 = '', $param2 = '', $param3 = '', $param4 = '') {
global $settings;
if ($type == '1'
|| $type == '3'
|| $type == '4'
@@ -38,11 +36,11 @@ function inserttask($type, $param1 = '', $param2 = '', $param3 = '', $param4 = '
|| $type == '10'
) {
// 4 = bind -> if bind disabled -> no task
if ($type == '4' && $settings['system']['bind_enable'] == '0') {
if ($type == '4' && Settings::Get('system.bind_enable') == '0') {
return;
}
// 10 = quota -> if quota disabled -> no task
if ($type == '10' && $settings['system']['diskquota_enabled'] == '0') {
if ($type == '10' && Settings::Get('system.diskquota_enabled') == '0') {
return;
}
$del_stmt = Database::prepare("

View File

@@ -28,8 +28,8 @@
*/
function checkLastGuid() {
global $log, $cronlog, $settings;
global $log, $cronlog;
$mylog = null;
if (isset($cronlog) && $cronlog instanceof FroxlorLogger) {
$mylog = $cronlog;
@@ -86,10 +86,9 @@ function checkLastGuid() {
}
// now check if it differs from our settings
if ($update_to_guid != $settings['system']['lastguid']) {
if ($update_to_guid != Settings::Get('system.lastguid')) {
$mylog->logAction(CRON_ACTION, LOG_NOTICE, 'Updating froxlor last guid to '.$update_to_guid);
saveSetting('system', 'lastguid', $update_to_guid);
$settings['system']['lastguid'] = $update_to_guid;
Settings::Set('system.lastguid', $update_to_guid);
}
} else {
$mylog->logAction(CRON_ACTION, LOG_NOTICE, 'File /etc/group not readable; cannot check for latest guid');

View File

@@ -34,9 +34,7 @@
*/
function makeCryptPassword ($password) {
global $settings;
$type = isset($settings['system']['passwordcryptfunc']) ? (int)$settings['system']['passwordcryptfunc'] : 1;
$type = isset(Settings::Get('system.passwordcryptfunc')) ? (int)Settings::Get('system.passwordcryptfunc') : 1;
switch ($type) {
case 0:

View File

@@ -15,27 +15,21 @@
*
*/
function checkFcgidPhpFpm($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
{
global $settings, $theme;
function checkFcgidPhpFpm($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues) {
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_OK);
/*
* check whether fcgid should be enabled but php-fpm is
*/
// check whether fcgid should be enabled but php-fpm is
if($fieldname == 'system_mod_fcgid_enabled'
&& (int)$newfieldvalue == 1
&& (int)$settings['phpfpm']['enabled'] == 1
&& (int)Settings::Get('phpfpm.enabled') == 1
) {
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'phpfpmstillenabled');
}
/*
* check whether php-fpm should be enabled but fcgid is
*/
// check whether php-fpm should be enabled but fcgid is
elseif($fieldname == 'system_phpfpm_enabled'
&& (int)$newfieldvalue == 1
&& (int)$settings['system']['mod_fcgid'] == 1
&& (int)Settings::Get('system.mod_fcgid') == 1
) {
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'fcgidstillenabled');
}

View File

@@ -15,44 +15,30 @@
*
*/
function checkPathConflicts($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
{
global $settings, $theme;
if((int)$settings['system']['mod_fcgid'] == 1)
{
/**
* fcgid-configdir has changed ->
* check against customer-doc-prefix
*/
if($fieldname == "system_mod_fcgid_configdir")
{
function checkPathConflicts($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues) {
if((int)Settings::Get('system.mod_fcgid') == 1) {
// fcgid-configdir has changed -> check against customer-doc-prefix
if ($fieldname == "system_mod_fcgid_configdir") {
$newdir = makeCorrectDir($newfieldvalue);
$cdir = makeCorrectDir($settings['system']['documentroot_prefix']);
$cdir = makeCorrectDir(Settings::Get('system.documentroot_prefix'));
}
/**
* customer-doc-prefix has changed ->
* check against fcgid-configdir
*/
elseif($fieldname == "system_documentroot_prefix")
{
// customer-doc-prefix has changed -> check against fcgid-configdir
elseif ($fieldname == "system_documentroot_prefix") {
$newdir = makeCorrectDir($newfieldvalue);
$cdir = makeCorrectDir($settings['system']['mod_fcgid_configdir']);
$cdir = makeCorrectDir(Settings::Get('system.mod_fcgid_configdir'));
}
// neither dir can be within the other nor can they be equal
if(substr($newdir, 0, strlen($cdir)) == $cdir
|| substr($cdir, 0, strlen($newdir)) == $newdir
|| $newdir == $cdir
if (substr($newdir, 0, strlen($cdir)) == $cdir
|| substr($cdir, 0, strlen($newdir)) == $newdir
|| $newdir == $cdir
) {
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'fcgidpathcannotbeincustomerdoc');
}
else
{
} else {
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_OK);
}
}
else
{
} else {
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_OK);
}

View File

@@ -18,11 +18,9 @@
function checkPhpInterfaceSetting($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues) {
global $settings;
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_OK);
if ((int)$settings['system']['mod_fcgid'] == 1) {
if ((int)Settings::Get('system.mod_fcgid') == 1) {
// now check if we enable a webserver != apache
if (strtolower($newfieldvalue) != 'apache2') {
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'fcgidstillenableddeadlock');

View File

@@ -17,20 +17,20 @@
*
*/
function checkUsername($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
{
global $settings, $theme;
if(!isset($allnewfieldvalues['customer_mysqlprefix']))
{
$allnewfieldvalues['customer_mysqlprefix'] = $settings['customer']['mysqlprefix'];
function checkUsername($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues) {
if (!isset($allnewfieldvalues['customer_mysqlprefix'])) {
$allnewfieldvalues['customer_mysqlprefix'] = Settings::Get('customer.mysqlprefix');
}
$returnvalue = array();
if(validateUsername($newfieldvalue, $settings['panel']['unix_names'], 14 - strlen($allnewfieldvalues['customer_mysqlprefix'])) === true)
{
if (validateUsername(
$newfieldvalue,
Settings::Get('panel.unix_names'),
14 - strlen($allnewfieldvalues['customer_mysqlprefix'])) === true
) {
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_OK);
}
else
{
} else {
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'accountprefixiswrong');
}
return $returnvalue;

View File

@@ -26,24 +26,22 @@
*
* @return string either the password or an errormessage+exit
*/
function validatePassword($password = null)
{
global $settings, $theme;
function validatePassword($password = null) {
if ($settings['panel']['password_min_length'] > 0) {
if (Settings::Get('panel.password_min_length') > 0) {
$password = validate(
$password,
$settings['panel']['password_min_length'], /* replacer needs to be password length, not the fieldname */
'/^.{'.(int)$settings['panel']['password_min_length'].',}$/D',
Settings::Get('panel.password_min_length'),
'/^.{'.(int)Settings::Get('panel.password_min_length').',}$/D',
'notrequiredpasswordlength'
);
}
if ($settings['panel']['password_regex'] != '') {
if (Settings::Get('panel.password_regex') != '') {
$password = validate(
$password,
$settings['panel']['password_regex'],
$settings['panel']['password_regex'],
Settings::Get('panel.password_regex'),
Settings::Get('panel.password_regex'),
'notrequiredpasswordcomplexity'
);
}