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

@@ -179,8 +179,7 @@ if ($page == 'tickets'
if (isset($_POST['send']) if (isset($_POST['send'])
&& $_POST['send'] == 'send' && $_POST['send'] == 'send'
) { ) {
// FIXME ticket -> settings $newticket = ticket::getInstanceOf($userinfo, -1);
$newticket = ticket::getInstanceOf($userinfo, $settings, -1);
$newticket->Set('subject', validate($_POST['subject'], 'subject'), true, false); $newticket->Set('subject', validate($_POST['subject'], 'subject'), true, false);
$newticket->Set('priority', validate($_POST['priority'], 'priority'), true, false); $newticket->Set('priority', validate($_POST['priority'], 'priority'), true, false);
$newticket->Set('category', validate($_POST['category'], 'category'), true, false); $newticket->Set('category', validate($_POST['category'], 'category'), true, false);
@@ -271,8 +270,7 @@ if ($page == 'tickets'
if (isset($_POST['send']) if (isset($_POST['send'])
&& $_POST['send'] == 'send' && $_POST['send'] == 'send'
) { ) {
// FIXME ticket -> settings $replyticket = ticket::getInstanceOf($userinfo, -1);
$replyticket = ticket::getInstanceOf($userinfo, $settings, -1);
$replyticket->Set('subject', validate($_POST['subject'], 'subject'), true, false); $replyticket->Set('subject', validate($_POST['subject'], 'subject'), true, false);
$replyticket->Set('priority', validate($_POST['priority'], 'priority'), 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); $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')); standard_error(array('stringisempty', 'mymessage'));
} else { } else {
$now = time(); $now = time();
// FIXME ticket -> settings $mainticket = ticket::getInstanceOf($userinfo, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$replyticket->Set('customer', $mainticket->Get('customer'), true, true); $replyticket->Set('customer', $mainticket->Get('customer'), true, true);
$replyticket->Set('lastchange', $now, true, true); $replyticket->Set('lastchange', $now, true, true);
$replyticket->Set('ip', $_SERVER['REMOTE_ADDR'], true, true); $replyticket->Set('ip', $_SERVER['REMOTE_ADDR'], true, true);
@@ -308,8 +305,7 @@ if ($page == 'tickets'
} else { } else {
$ticket_replies = ''; $ticket_replies = '';
// FIXME ticket -> settings $mainticket = ticket::getInstanceOf($userinfo, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$dt = date("d.m.Y H:i\h", $mainticket->Get('dt')); $dt = date("d.m.Y H:i\h", $mainticket->Get('dt'));
$status = ticket::getStatusText($lng, $mainticket->Get('status')); $status = ticket::getStatusText($lng, $mainticket->Get('status'));
@@ -352,8 +348,7 @@ if ($page == 'tickets'
$numrows_andere = Database::num_rows(); $numrows_andere = Database::num_rows();
while ($row2 = $andere_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row2 = $andere_stmt->fetch(PDO::FETCH_ASSOC)) {
// FIXME ticket -> settings $subticket = ticket::getInstanceOf($userinfo, (int)$row2['id']);
$subticket = ticket::getInstanceOf($userinfo, $settings, (int)$row2['id']);
$lastchange = date("d.m.Y H:i\h", $subticket->Get('lastchange')); $lastchange = date("d.m.Y H:i\h", $subticket->Get('lastchange'));
if ($subticket->Get('by') == '1') { if ($subticket->Get('by') == '1') {
@@ -400,8 +395,7 @@ if ($page == 'tickets'
&& $_POST['send'] == 'send' && $_POST['send'] == 'send'
) { ) {
$now = time(); $now = time();
// FIXME ticket -> settings $mainticket = ticket::getInstanceOf($userinfo, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$mainticket->Set('lastchange', $now, true, true); $mainticket->Set('lastchange', $now, true, true);
$mainticket->Set('lastreplier', '1', true, true); $mainticket->Set('lastreplier', '1', true, true);
$mainticket->Set('status', '3', 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') . "'"); $log->logAction(ADM_ACTION, LOG_NOTICE, "closed ticket '" . $mainticket->Get('subject') . "'");
redirectTo($filename, array('page' => $page, 's' => $s)); redirectTo($filename, array('page' => $page, 's' => $s));
} else { } else {
// FIXME ticket -> settings $mainticket = ticket::getInstanceOf($userinfo, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
ask_yesno('ticket_reallyclose', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $mainticket->Get('subject')); ask_yesno('ticket_reallyclose', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $mainticket->Get('subject'));
} }
@@ -418,8 +411,7 @@ if ($page == 'tickets'
&& $id != 0 && $id != 0
) { ) {
$now = time(); $now = time();
// FIXME ticket -> settings $mainticket = ticket::getInstanceOf($userinfo, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$mainticket->Set('lastchange', $now, true, true); $mainticket->Set('lastchange', $now, true, true);
$mainticket->Set('lastreplier', '1', true, true); $mainticket->Set('lastreplier', '1', true, true);
$mainticket->Set('status', '0', true, true); $mainticket->Set('status', '0', true, true);
@@ -434,8 +426,7 @@ if ($page == 'tickets'
&& $_POST['send'] == 'send' && $_POST['send'] == 'send'
) { ) {
$now = time(); $now = time();
// FIXME ticket -> settings $mainticket = ticket::getInstanceOf($userinfo, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$mainticket->Set('lastchange', $now, true, true); $mainticket->Set('lastchange', $now, true, true);
$mainticket->Set('lastreplier', '1', true, true); $mainticket->Set('lastreplier', '1', true, true);
$mainticket->Set('status', '3', 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') . "'"); $log->logAction(ADM_ACTION, LOG_NOTICE, "archived ticket '" . $mainticket->Get('subject') . "'");
redirectTo($filename, array('page' => $page, 's' => $s)); redirectTo($filename, array('page' => $page, 's' => $s));
} else { } else {
// FIXME ticket -> settings $mainticket = ticket::getInstanceOf($userinfo, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
ask_yesno('ticket_reallyarchive', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $mainticket->Get('subject')); 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']) if (isset($_POST['send'])
&& $_POST['send'] == 'send' && $_POST['send'] == 'send'
) { ) {
// FIXME ticket -> settings $mainticket = ticket::getInstanceOf($userinfo, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$log->logAction(ADM_ACTION, LOG_INFO, "deleted ticket '" . $mainticket->Get('subject') . "'"); $log->logAction(ADM_ACTION, LOG_INFO, "deleted ticket '" . $mainticket->Get('subject') . "'");
$mainticket->Delete(); $mainticket->Delete();
redirectTo($filename, array('page' => $page, 's' => $s)); redirectTo($filename, array('page' => $page, 's' => $s));
} else { } else {
// FIXME ticket -> settings $mainticket = ticket::getInstanceOf($userinfo, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
ask_yesno('ticket_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $mainticket->Get('subject')); 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); $log->logAction(ADM_ACTION, LOG_NOTICE, "viewed archived-ticket #" . $id);
$ticket_replies = ''; $ticket_replies = '';
// FIXME ticket -> settings $mainticket = ticket::getInstanceOf($userinfo, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$lastchange = date("d.m.Y H:i\h", $mainticket->Get('lastchange')); $lastchange = date("d.m.Y H:i\h", $mainticket->Get('lastchange'));
$dt = date("d.m.Y H:i\h", $mainticket->Get('dt')); $dt = date("d.m.Y H:i\h", $mainticket->Get('dt'));
$status = ticket::getStatusText($lng, $mainticket->Get('status')); $status = ticket::getStatusText($lng, $mainticket->Get('status'));
@@ -855,8 +842,7 @@ if ($page == 'tickets'
$numrows_andere = Database::num_rows(); $numrows_andere = Database::num_rows();
while ($row2 = $andere_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row2 = $andere_stmt->fetch(PDO::FETCH_ASSOC)) {
// FIXME ticket -> settings $subticket = ticket::getInstanceOf($userinfo, (int)$row2['id']);
$subticket = ticket::getInstanceOf($userinfo, $settings, (int)$row2['id']);
$lastchange = date("d.m.Y H:i\h", $subticket->Get('lastchange')); $lastchange = date("d.m.Y H:i\h", $subticket->Get('lastchange'));
if ($subticket->Get('by') == '1') { if ($subticket->Get('by') == '1') {
@@ -907,14 +893,12 @@ if ($page == 'tickets'
if (isset($_POST['send']) if (isset($_POST['send'])
&& $_POST['send'] == 'send' && $_POST['send'] == 'send'
) { ) {
// FIXME ticket -> settings $mainticket = ticket::getInstanceOf($userinfo, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$log->logAction(ADM_ACTION, LOG_INFO, "deleted archived ticket '" . $mainticket->Get('subject') . "'"); $log->logAction(ADM_ACTION, LOG_INFO, "deleted archived ticket '" . $mainticket->Get('subject') . "'");
$mainticket->Delete(); $mainticket->Delete();
redirectTo($filename, array('page' => $page, 's' => $s)); redirectTo($filename, array('page' => $page, 's' => $s));
} else { } else {
// FIXME ticket -> settings $mainticket = ticket::getInstanceOf($userinfo, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
ask_yesno('ticket_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $mainticket->Get('subject')); 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 * @param bool $showerror if set to false, the error will be logged but we go on
*/ */
private static function _showerror($error, $showerror = true) { 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 * log to a file, so we can actually ask people for the error
@@ -336,8 +336,8 @@ class Database {
$err_report_html = ''; $err_report_html = '';
if (is_array($userinfo) && ( if (is_array($userinfo) && (
($userinfo['adminsession'] == '1' && $settings['system']['allow_error_report_admin'] == '1') ($userinfo['adminsession'] == '1' && Settings::Get('system.allow_error_report_admin') == '1')
|| ($userinfo['adminsession'] == '0' && $settings['system']['allow_error_report_customer'] == '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 = '<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); $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 abstract class AbstractLogger {
{
/**
* Settings array
* @var settings
*/
private $settings = array();
/** /**
* Enable/Disable Logging * Enable/Disable Logging
* @var logenabled * @var logenabled
*/ */
private $logenabled = false; private $logenabled = false;
/** /**
* Enable/Disable Cronjob-Logging * Enable/Disable Cronjob-Logging
* @var logcronjob * @var logcronjob
*/ */
private $logcronjob = false; private $logcronjob = false;
/** /**
* Loggin-Severity * Loggin-Severity
* @var severity * @var severity
*/ */
private $severity = 1; private $severity = 1;
// normal
/** /**
* setup the main logger * setup the main logger
*
* @param array settings
*/ */
protected function setupLogger() {
protected function setupLogger($settings) $this->logenabled = Settings::Get('logger.enabled');
{ $this->logcronjob = Settings::Get('logger.log_cron');
$this->settings = $settings; $this->severity = Settings::Get('logger.severity');
$this->logenabled = $this->settings['logger']['enabled'];
$this->logcronjob = $this->settings['logger']['log_cron'];
$this->severity = $this->settings['logger']['severity'];
} }
protected function isEnabled() /**
{ * return whether this logging is enabled
*
* @return bool
*/
protected function isEnabled() {
return $this->logenabled; return $this->logenabled;
} }
protected function getSeverity() /**
{ * return the log severity
*
* @return int
*/
protected function getSeverity() {
return $this->severity; return $this->severity;
} }
protected function logCron() /**
{ * whether to log cron-runs or not
*
* @return bool
*/
protected function logCron() {
return $this->logcronjob; return $this->logcronjob;
} }
/**
* logs a given text
*/
abstract public function logAction(); abstract public function logAction();
}
?> }

View File

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

View File

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

View File

@@ -38,25 +38,29 @@ class MysqlLogger extends AbstractLogger {
* Class constructor. * Class constructor.
* *
* @param array userinfo * @param array userinfo
* @param array settings
*/ */
protected function __construct($userinfo, $settings) { protected function __construct($userinfo) {
parent::setupLogger($settings); parent::setupLogger();
$this->userinfo = $userinfo; $this->userinfo = $userinfo;
} }
/** /**
* Singleton ftw ;-) * Singleton ftw ;-)
*
*/ */
static public function getInstanceOf($_usernfo, $_settings) { static public function getInstanceOf($_usernfo) {
if (!isset(self::$loggers[$_usernfo['loginname']])) { 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']]; 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) { public function logAction($action = USR_ACTION, $type = LOG_NOTICE, $text = null) {
if (parent::isEnabled()) { if (parent::isEnabled()) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -21,18 +21,9 @@
class DomainSSL { class DomainSSL {
/** /**
* internal settings array * constructor
*
* @var array
*/ */
private $_settings = null; public function __construct() {}
/**
* constructor gets the froxlor settings as array
*/
public function __construct(array $settings = null) {
$this->_settings = $settings;
}
/** /**
* read domain-related (or if empty, parentdomain-related) ssl-certificates from the database * read domain-related (or if empty, parentdomain-related) ssl-certificates from the database
@@ -66,7 +57,7 @@ class DomainSSL {
&& $dom_certs['ssl_cert_file'] != '' && $dom_certs['ssl_cert_file'] != ''
) { ) {
// get destination path // 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 // create path if it does not exist
if (!file_exists($sslcertpath)) { if (!file_exists($sslcertpath)) {
safe_exec('mkdir -p '.escapeshellarg($sslcertpath)); safe_exec('mkdir -p '.escapeshellarg($sslcertpath));
@@ -77,7 +68,7 @@ class DomainSSL {
'ssl_key_file' => makeCorrectFile($sslcertpath.'/'.$domain['domain'].'.key') '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. // 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"; $dom_certs['ssl_cert_file'] = trim($dom_certs['ssl_cert_file'])."\n".trim($dom_certs['ssl_key_file'])."\n";
$ssl_files['ssl_key_file'] = ''; $ssl_files['ssl_key_file'] = '';
@@ -91,7 +82,7 @@ class DomainSSL {
$ssl_files['ssl_ca_file'] = makeCorrectFile($sslcertpath.'/'.$domain['domain'].'_CA.pem'); $ssl_files['ssl_ca_file'] = makeCorrectFile($sslcertpath.'/'.$domain['domain'].'_CA.pem');
} }
if ($dom_certs['ssl_cert_chainfile'] != '') { 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. // 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"; $dom_certs['ssl_cert_file'] = trim($dom_certs['ssl_cert_file'])."\n".trim($dom_certs['ssl_cert_chainfile'])."\n";
} else { } else {
@@ -117,4 +108,4 @@ class DomainSSL {
return; return;
} }
} }

View File

@@ -24,34 +24,30 @@
* *
* @return void * @return void
*/ */
function makeChownWithNewStats($row) function makeChownWithNewStats($row) {
{
global $settings;
// get correct user // 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']; $user = $row['loginname'];
$group = $row['loginname']; $group = $row['loginname'];
} } else {
else
{
$user = $row['guid']; $user = $row['guid'];
$group = $row['guid']; $group = $row['guid'];
} }
// get correct directory // get correct directory
$dir = $row['documentroot']; $dir = $row['documentroot'];
if($settings['system']['awstats_enabled'] == '1') if (Settings::Get('system.awstats_enabled') == '1') {
{
$dir .= '/awstats/'; $dir .= '/awstats/';
} else { } else {
$dir .= '/webalizer/'; $dir .= '/webalizer/';
} }
// only run chown if directory exists // only run chown if directory exists
if (file_exists($dir)) if (file_exists($dir)) {
{
// run chown // run chown
safe_exec('chown -R '.escapeshellarg($user).':'.escapeshellarg($group).' '.escapeshellarg(makeCorrectDir($dir))); 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) { function storeDefaultIndex($loginname = null, $destination = null, $logger = null, $force = false) {
global $settings;
if ($force if ($force
|| (int)$settings['system']['store_index_file_subs'] == 1 || (int)Settings::Get('system.store_index_file_subs') == 1
) { ) {
$result_stmt = Database::prepare(" $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` 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); $template = $result_stmt->fetch(PDO::FETCH_ASSOC);
$replace_arr = array( $replace_arr = array(
'SERVERNAME' => $settings['system']['hostname'], 'SERVERNAME' => Settings::Get('system.hostname'),
'CUSTOMER' => $template['customer_login'], 'CUSTOMER' => $template['customer_login'],
'ADMIN' => $template['admin_login'], 'ADMIN' => $template['admin_login'],
'CUSTOMER_EMAIL' => $template['customer_email'], 'CUSTOMER_EMAIL' => $template['customer_email'],
@@ -54,12 +52,12 @@ function storeDefaultIndex($loginname = null, $destination = null, $logger = nul
); );
$htmlcontent = replace_variables($template['value'], $replace_arr); $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'); $index_html_handler = fopen($indexhtmlpath, 'w');
fwrite($index_html_handler, $htmlcontent); fwrite($index_html_handler, $htmlcontent);
fclose($index_html_handler); fclose($index_html_handler);
if ($logger !== null) { 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 { } else {

View File

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

View File

@@ -28,8 +28,6 @@
*/ */
function createAWStatsConf($logFile, $siteDomain, $hostAliases, $customerDocroot, $awstats_params = array()) { function createAWStatsConf($logFile, $siteDomain, $hostAliases, $customerDocroot, $awstats_params = array()) {
global $settings;
// Generation header // Generation header
$header = "## GENERATED BY FROXLOR\n"; $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"; $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); makeChownWithNewStats($awstats_params);
// weird but could happen... // weird but could happen...
if (!is_dir($settings['system']['awstats_conf'])) { if (!is_dir(Settings::Get('system.awstats_conf'))) {
safe_exec('mkdir -p '.escapeshellarg($settings['system']['awstats_conf'])); safe_exec('mkdir -p '.escapeshellarg(Settings::Get('system.awstats_conf')));
} }
// These are the variables we will replace // These are the variables we will replace
@@ -59,11 +57,11 @@ function createAWStatsConf($logFile, $siteDomain, $hostAliases, $customerDocroot
$siteDomain, $siteDomain,
$hostAliases, $hostAliases,
$awstats_dir, $awstats_dir,
makeCorrectDir($settings['system']['awstats_conf']) makeCorrectDir(Settings::Get('system.awstats_conf'))
); );
// File names // 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 = FROXLOR_INSTALL_DIR.'/templates/misc/awstatsmodel/awstats.froxlor.model.conf';
$model_file = makeCorrectFile($model_file); $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 * Generates a random password
*/ */
function generatePassword() { function generatePassword() {
global $settings;
return substr( return substr(
base64_encode(sha1(md5(uniqid(microtime(), 1))).md5(uniqid(microtime(), 1)).sha1(md5(uniqid(microtime(), 1)))), 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() function getFilesystemQuota() {
{
global $settings, $theme; if (Settings::Get('system.diskquota_enabled')) {
if ($settings['system']['diskquota_enabled'])
{ // Fetch all quota in the desired partition
# Fetch all quota in the desired partition exec(Settings::Get('system.diskquota_repquota_path') . " -np " . escapeshellarg(Settings::Get('system.diskquota_customer_partition')), $repquota);
exec($settings['system']['diskquota_repquota_path'] . " -np " . escapeshellarg($settings['system']['diskquota_customer_partition']), $repquota);
$usedquota = array(); $usedquota = array();
foreach ($repquota as $tmpquota) foreach ($repquota as $tmpquota) {
{ // Let's see if the line matches a quota - line
# 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)) {
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)
{
# It matches - put it into an array with userid as key (for easy lookup later)
$usedquota[$matches[1]] = array( $usedquota[$matches[1]] = array(
'block' => array( 'block' => array(
'used' => $matches[2], 'used' => $matches[2],
'soft' => $matches[3], 'soft' => $matches[3],
'hard' => $matches[4], 'hard' => $matches[4],
'grace' => $matches[5] 'grace' => $matches[5]
), ),
'file' => array( 'file' => array(
'used' => $matches[6], 'used' => $matches[6],
'soft' => $matches[7], 'soft' => $matches[7],
'hard' => $matches[8], 'hard' => $matches[8],
'grace' => $matches[9] 'grace' => $matches[9]
), ),
); );
} }
} }
return $usedquota; return $usedquota;
} }
return false; return false;

View File

@@ -29,8 +29,6 @@
function inserttask($type, $param1 = '', $param2 = '', $param3 = '', $param4 = '') { function inserttask($type, $param1 = '', $param2 = '', $param3 = '', $param4 = '') {
global $settings;
if ($type == '1' if ($type == '1'
|| $type == '3' || $type == '3'
|| $type == '4' || $type == '4'
@@ -38,11 +36,11 @@ function inserttask($type, $param1 = '', $param2 = '', $param3 = '', $param4 = '
|| $type == '10' || $type == '10'
) { ) {
// 4 = bind -> if bind disabled -> no task // 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; return;
} }
// 10 = quota -> if quota disabled -> no task // 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; return;
} }
$del_stmt = Database::prepare(" $del_stmt = Database::prepare("

View File

@@ -28,8 +28,8 @@
*/ */
function checkLastGuid() { function checkLastGuid() {
global $log, $cronlog, $settings; global $log, $cronlog;
$mylog = null; $mylog = null;
if (isset($cronlog) && $cronlog instanceof FroxlorLogger) { if (isset($cronlog) && $cronlog instanceof FroxlorLogger) {
$mylog = $cronlog; $mylog = $cronlog;
@@ -86,10 +86,9 @@ function checkLastGuid() {
} }
// now check if it differs from our settings // 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); $mylog->logAction(CRON_ACTION, LOG_NOTICE, 'Updating froxlor last guid to '.$update_to_guid);
saveSetting('system', 'lastguid', $update_to_guid); Settings::Set('system.lastguid', $update_to_guid);
$settings['system']['lastguid'] = $update_to_guid;
} }
} else { } else {
$mylog->logAction(CRON_ACTION, LOG_NOTICE, 'File /etc/group not readable; cannot check for latest guid'); $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) { function makeCryptPassword ($password) {
global $settings; $type = isset(Settings::Get('system.passwordcryptfunc')) ? (int)Settings::Get('system.passwordcryptfunc') : 1;
$type = isset($settings['system']['passwordcryptfunc']) ? (int)$settings['system']['passwordcryptfunc'] : 1;
switch ($type) { switch ($type) {
case 0: case 0:

View File

@@ -15,27 +15,21 @@
* *
*/ */
function checkFcgidPhpFpm($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues) function checkFcgidPhpFpm($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues) {
{
global $settings, $theme;
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_OK); $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' if($fieldname == 'system_mod_fcgid_enabled'
&& (int)$newfieldvalue == 1 && (int)$newfieldvalue == 1
&& (int)$settings['phpfpm']['enabled'] == 1 && (int)Settings::Get('phpfpm.enabled') == 1
) { ) {
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'phpfpmstillenabled'); $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' elseif($fieldname == 'system_phpfpm_enabled'
&& (int)$newfieldvalue == 1 && (int)$newfieldvalue == 1
&& (int)$settings['system']['mod_fcgid'] == 1 && (int)Settings::Get('system.mod_fcgid') == 1
) { ) {
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'fcgidstillenabled'); $returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'fcgidstillenabled');
} }

View File

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

View File

@@ -18,11 +18,9 @@
function checkPhpInterfaceSetting($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues) { function checkPhpInterfaceSetting($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues) {
global $settings;
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_OK); $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 // now check if we enable a webserver != apache
if (strtolower($newfieldvalue) != 'apache2') { if (strtolower($newfieldvalue) != 'apache2') {
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'fcgidstillenableddeadlock'); $returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'fcgidstillenableddeadlock');

View File

@@ -17,20 +17,20 @@
* *
*/ */
function checkUsername($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues) function checkUsername($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues) {
{
global $settings, $theme; if (!isset($allnewfieldvalues['customer_mysqlprefix'])) {
if(!isset($allnewfieldvalues['customer_mysqlprefix'])) $allnewfieldvalues['customer_mysqlprefix'] = Settings::Get('customer.mysqlprefix');
{
$allnewfieldvalues['customer_mysqlprefix'] = $settings['customer']['mysqlprefix'];
} }
$returnvalue = array(); $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); $returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_OK);
} } else {
else
{
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'accountprefixiswrong'); $returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'accountprefixiswrong');
} }
return $returnvalue; return $returnvalue;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -23,7 +23,7 @@ class nginx_phpfpm extends nginx
if($domain['phpenabled'] == '1') if($domain['phpenabled'] == '1')
{ {
$php = new phpinterface($this->settings, $domain); $php = new phpinterface($domain);
$phpconfig = $php->getPhpConfig((int)$domain['phpsettingid']); $phpconfig = $php->getPhpConfig((int)$domain['phpsettingid']);
$php_options_text = "\t".'location ~ \.php$ {'."\n"; $php_options_text = "\t".'location ~ \.php$ {'."\n";
@@ -81,7 +81,7 @@ class nginx_phpfpm extends nginx
safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath)); safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath));
// get php.ini for our own vhost // get php.ini for our own vhost
$php = new phpinterface($this->settings, $domain); $php = new phpinterface($domain);
// get php-config // get php-config
if ($this->settings['phpfpm']['enabled'] == '1') { 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') { if ($row['type'] == '1') {
// get configuration-I/O object // get configuration-I/O object
$configio = new ConfigIO($settings); $configio = new ConfigIO();
// clean up old configs // clean up old configs
$configio->cleanUp(); $configio->cleanUp();