more implementing of new Settings class, refs #1325

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2013-12-15 12:40:24 +01:00
parent eb33493c79
commit 558108008a
20 changed files with 245 additions and 312 deletions

View File

@@ -179,8 +179,7 @@ if ($page == 'tickets'
if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
// FIXME ticket -> settings
$newticket = ticket::getInstanceOf($userinfo, $settings, -1);
$newticket = ticket::getInstanceOf($userinfo, -1);
$newticket->Set('subject', validate($_POST['subject'], 'subject'), true, false);
$newticket->Set('priority', validate($_POST['priority'], 'priority'), true, false);
$newticket->Set('category', validate($_POST['category'], 'category'), true, false);
@@ -271,8 +270,7 @@ if ($page == 'tickets'
if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
// FIXME ticket -> settings
$replyticket = ticket::getInstanceOf($userinfo, $settings, -1);
$replyticket = ticket::getInstanceOf($userinfo, -1);
$replyticket->Set('subject', validate($_POST['subject'], 'subject'), true, false);
$replyticket->Set('priority', validate($_POST['priority'], 'priority'), true, false);
$replyticket->Set('message', validate(htmlentities(str_replace("\r\n", "\n", $_POST['message'])), 'message', '/^[^\0]*$/'), true, false);
@@ -281,8 +279,7 @@ if ($page == 'tickets'
standard_error(array('stringisempty', 'mymessage'));
} else {
$now = time();
// FIXME ticket -> settings
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, (int)$id);
$replyticket->Set('customer', $mainticket->Get('customer'), true, true);
$replyticket->Set('lastchange', $now, true, true);
$replyticket->Set('ip', $_SERVER['REMOTE_ADDR'], true, true);
@@ -308,8 +305,7 @@ if ($page == 'tickets'
} else {
$ticket_replies = '';
// FIXME ticket -> settings
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, (int)$id);
$dt = date("d.m.Y H:i\h", $mainticket->Get('dt'));
$status = ticket::getStatusText($lng, $mainticket->Get('status'));
@@ -352,8 +348,7 @@ if ($page == 'tickets'
$numrows_andere = Database::num_rows();
while ($row2 = $andere_stmt->fetch(PDO::FETCH_ASSOC)) {
// FIXME ticket -> settings
$subticket = ticket::getInstanceOf($userinfo, $settings, (int)$row2['id']);
$subticket = ticket::getInstanceOf($userinfo, (int)$row2['id']);
$lastchange = date("d.m.Y H:i\h", $subticket->Get('lastchange'));
if ($subticket->Get('by') == '1') {
@@ -400,8 +395,7 @@ if ($page == 'tickets'
&& $_POST['send'] == 'send'
) {
$now = time();
// FIXME ticket -> settings
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, (int)$id);
$mainticket->Set('lastchange', $now, true, true);
$mainticket->Set('lastreplier', '1', true, true);
$mainticket->Set('status', '3', true, true);
@@ -409,8 +403,7 @@ if ($page == 'tickets'
$log->logAction(ADM_ACTION, LOG_NOTICE, "closed ticket '" . $mainticket->Get('subject') . "'");
redirectTo($filename, array('page' => $page, 's' => $s));
} else {
// FIXME ticket -> settings
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, (int)$id);
ask_yesno('ticket_reallyclose', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $mainticket->Get('subject'));
}
@@ -418,8 +411,7 @@ if ($page == 'tickets'
&& $id != 0
) {
$now = time();
// FIXME ticket -> settings
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, (int)$id);
$mainticket->Set('lastchange', $now, true, true);
$mainticket->Set('lastreplier', '1', true, true);
$mainticket->Set('status', '0', true, true);
@@ -434,8 +426,7 @@ if ($page == 'tickets'
&& $_POST['send'] == 'send'
) {
$now = time();
// FIXME ticket -> settings
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, (int)$id);
$mainticket->Set('lastchange', $now, true, true);
$mainticket->Set('lastreplier', '1', true, true);
$mainticket->Set('status', '3', true, true);
@@ -444,8 +435,7 @@ if ($page == 'tickets'
$log->logAction(ADM_ACTION, LOG_NOTICE, "archived ticket '" . $mainticket->Get('subject') . "'");
redirectTo($filename, array('page' => $page, 's' => $s));
} else {
// FIXME ticket -> settings
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, (int)$id);
ask_yesno('ticket_reallyarchive', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $mainticket->Get('subject'));
}
@@ -455,14 +445,12 @@ if ($page == 'tickets'
if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
// FIXME ticket -> settings
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, (int)$id);
$log->logAction(ADM_ACTION, LOG_INFO, "deleted ticket '" . $mainticket->Get('subject') . "'");
$mainticket->Delete();
redirectTo($filename, array('page' => $page, 's' => $s));
} else {
// FIXME ticket -> settings
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, (int)$id);
ask_yesno('ticket_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $mainticket->Get('subject'));
}
}
@@ -804,8 +792,7 @@ if ($page == 'tickets'
) {
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed archived-ticket #" . $id);
$ticket_replies = '';
// FIXME ticket -> settings
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, (int)$id);
$lastchange = date("d.m.Y H:i\h", $mainticket->Get('lastchange'));
$dt = date("d.m.Y H:i\h", $mainticket->Get('dt'));
$status = ticket::getStatusText($lng, $mainticket->Get('status'));
@@ -855,8 +842,7 @@ if ($page == 'tickets'
$numrows_andere = Database::num_rows();
while ($row2 = $andere_stmt->fetch(PDO::FETCH_ASSOC)) {
// FIXME ticket -> settings
$subticket = ticket::getInstanceOf($userinfo, $settings, (int)$row2['id']);
$subticket = ticket::getInstanceOf($userinfo, (int)$row2['id']);
$lastchange = date("d.m.Y H:i\h", $subticket->Get('lastchange'));
if ($subticket->Get('by') == '1') {
@@ -907,14 +893,12 @@ if ($page == 'tickets'
if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
// FIXME ticket -> settings
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, (int)$id);
$log->logAction(ADM_ACTION, LOG_INFO, "deleted archived ticket '" . $mainticket->Get('subject') . "'");
$mainticket->Delete();
redirectTo($filename, array('page' => $page, 's' => $s));
} else {
// FIXME ticket -> settings
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, (int)$id);
ask_yesno('ticket_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $mainticket->Get('subject'));
}
}

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

@@ -20,65 +20,61 @@
* 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

@@ -20,20 +20,14 @@
* 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

@@ -20,57 +20,54 @@
* 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 {

View File

@@ -219,7 +219,7 @@ class apache
'loginname' => 'froxlor.panel',
'documentroot' => $mypath
);
$php = new phpinterface($this->settings, $domain);
$php = new phpinterface($domain);
$phpconfig = $php->getPhpConfig($this->settings['system']['mod_fcgid_defaultini_ownvhost']);
$starter_filename = makeCorrectFile($configdir . '/php-fcgi-starter');
@@ -258,7 +258,7 @@ class apache
'documentroot' => $mypath,
);
$php = new phpinterface($this->settings, $domain);
$php = new phpinterface($domain);
$phpconfig = $php->getPhpConfig($this->settings['phpfpm']['vhost_defaultini']);
$srvName = substr(md5($ipport),0,4).'.fpm.external';
if ($row_ipsandports['ssl']) {
@@ -642,7 +642,7 @@ class apache
$domain['ssl_cert_chainfile'] = $ipandport['ssl_cert_chainfile'];
// SSL STUFF
$dssl = new DomainSSL($this->settings);
$dssl = new DomainSSL();
// this sets the ssl-related array-indices in the $domain array
// if the domain has customer-defined ssl-certificates
$dssl->setDomainSSLFilesArray($domain);

View File

@@ -25,7 +25,7 @@ class apache_fcgid extends apache
if($domain['phpenabled'] == '1')
{
$php = new phpinterface($this->settings, $domain);
$php = new phpinterface($domain);
$phpconfig = $php->getPhpConfig((int)$domain['phpsettingid']);
if((int)$this->settings['phpfpm']['enabled'] == 1)
@@ -141,7 +141,7 @@ class apache_fcgid extends apache
safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath));
// get php.ini for our own vhost
$php = new phpinterface($this->settings, $domain);
$php = new phpinterface($domain);
// get php-config
if ($this->settings['phpfpm']['enabled'] == '1') {

View File

@@ -135,7 +135,7 @@ class lighttpd
'documentroot' => $mypath
);
$php = new phpinterface($this->settings, $domain);
$php = new phpinterface($domain);
$this->lighttpd_data[$vhost_filename].= ' fastcgi.server = ( '."\n";
$this->lighttpd_data[$vhost_filename].= "\t".'".php" => ('."\n";
@@ -434,7 +434,7 @@ class lighttpd
$domain['ssl_cert_chainfile'] = $ipandport['ssl_cert_chainfile'];
// SSL STUFF
$dssl = new DomainSSL($this->settings);
$dssl = new DomainSSL();
// this sets the ssl-related array-indices in the $domain array
// if the domain has customer-defined ssl-certificates
$dssl->setDomainSSLFilesArray($domain);

View File

@@ -23,7 +23,7 @@ class lighttpd_fcgid extends lighttpd
if($domain['phpenabled'] == '1')
{
$php = new phpinterface($this->settings, $domain);
$php = new phpinterface($domain);
$phpconfig = $php->getPhpConfig((int)$domain['phpsettingid']);
// vhost data for php-fpm
@@ -134,7 +134,7 @@ class lighttpd_fcgid extends lighttpd
safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath));
// get php.ini for our own vhost
$php = new phpinterface($this->settings, $domain);
$php = new phpinterface($domain);
// get php-config
if ($this->settings['phpfpm']['enabled'] == '1') {

View File

@@ -228,7 +228,7 @@ class nginx
'documentroot' => $mypath,
);
$php = new phpinterface($this->settings, $domain);
$php = new phpinterface($domain);
$this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_pass unix:' . $php->getInterface()->getSocketFile() . ';' . "\n";
} else {
$this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_pass ' . $this->settings['system']['nginx_php_backend'] . ';' . "\n";
@@ -351,7 +351,7 @@ class nginx
$domain['ssl_cert_chainfile'] = $ipandport['ssl_cert_chainfile'];
// SSL STUFF
$dssl = new DomainSSL($this->settings);
$dssl = new DomainSSL();
// this sets the ssl-related array-indices in the $domain array
// if the domain has customer-defined ssl-certificates
$dssl->setDomainSSLFilesArray($domain);

View File

@@ -23,7 +23,7 @@ class nginx_phpfpm extends nginx
if($domain['phpenabled'] == '1')
{
$php = new phpinterface($this->settings, $domain);
$php = new phpinterface($domain);
$phpconfig = $php->getPhpConfig((int)$domain['phpsettingid']);
$php_options_text = "\t".'location ~ \.php$ {'."\n";
@@ -81,7 +81,7 @@ class nginx_phpfpm extends nginx
safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath));
// get php.ini for our own vhost
$php = new phpinterface($this->settings, $domain);
$php = new phpinterface($domain);
// get php-config
if ($this->settings['phpfpm']['enabled'] == '1') {

View File

@@ -51,7 +51,7 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
if ($row['type'] == '1') {
// get configuration-I/O object
$configio = new ConfigIO($settings);
$configio = new ConfigIO();
// clean up old configs
$configio->cleanUp();