Merge branch 'logging' of https://github.com/nachtgeist/Froxlor into nachtgeist-logging

This commit is contained in:
Michael Kaufmann (d00p)
2016-02-17 08:41:17 +01:00
25 changed files with 153 additions and 187 deletions

View File

@@ -29,14 +29,6 @@ return array(
'default' => '/etc/cron.d/froxlor', 'default' => '/etc/cron.d/froxlor',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
), ),
'system_send_cron_errors' => array(
'label' => $lng['serversettings']['system_send_cron_errors'],
'settinggroup' => 'system',
'varname' => 'send_cron_errors',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField',
),
'system_croncmdline' => array( 'system_croncmdline' => array(
'label' => $lng['serversettings']['system_croncmdline'], 'label' => $lng['serversettings']['system_croncmdline'],
'settinggroup' => 'system', 'settinggroup' => 'system',

View File

@@ -65,8 +65,14 @@ return array(
'label' => $lng['serversettings']['logger']['logcron'], 'label' => $lng['serversettings']['logger']['logcron'],
'settinggroup' => 'logger', 'settinggroup' => 'logger',
'varname' => 'log_cron', 'varname' => 'log_cron',
'type' => 'bool', 'type' => 'option',
'default' => false, 'default' => 0,
'option_mode' => 'one',
'option_options' => array(
0 => $lng['serversettings']['logger']['logcronoption']['never'],
1 => $lng['serversettings']['logger']['logcronoption']['once'],
2 => $lng['serversettings']['logger']['logcronoption']['always']
),
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
), ),
), ),
@@ -74,4 +80,4 @@ return array(
) )
); );
?> ?>

View File

@@ -100,31 +100,7 @@ if ($page == 'log'
} }
$log_count++; $log_count++;
$type = $row['type']; $row['type'] = getLogLevelDesc($row['type']);
$_type = 'unknown';
switch ($type) {
case LOG_INFO:
$_type = 'Information';
break;
case LOG_NOTICE:
$_type = 'Notice';
break;
case LOG_WARNING:
$_type = 'Warning';
break;
case LOG_ERR:
$_type = 'Error';
break;
case LOG_CRIT:
$_type = 'Critical';
break;
default:
$_type = 'Unknown';
break;
}
$row['type'] = $_type;
eval("\$log.=\"" . getTemplate('logger/logger_log') . "\";"); eval("\$log.=\"" . getTemplate('logger/logger_log') . "\";");
$count++; $count++;
$_action = $action; $_action = $action;

View File

@@ -548,7 +548,7 @@ INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES
('panel', 'password_numeric', '0'), ('panel', 'password_numeric', '0'),
('panel', 'password_special_char_required', '0'), ('panel', 'password_special_char_required', '0'),
('panel', 'password_special_char', '!?<>§$%+#=@'), ('panel', 'password_special_char', '!?<>§$%+#=@'),
('panel', 'version', '0.9.35-dev3'); ('panel', 'version', '0.9.35-dev4');
DROP TABLE IF EXISTS `panel_tasks`; DROP TABLE IF EXISTS `panel_tasks`;

View File

@@ -3069,3 +3069,13 @@ if (isFroxlorVersion('0.9.35-dev2')) {
updateToVersion('0.9.35-dev3'); updateToVersion('0.9.35-dev3');
} }
if (isFroxlorVersion('0.9.35-dev3')) {
// remove unused settingjj
showUpdateStep("Removing unused setting &quot;Send cron-errors to froxlor-admin via e-mail&quot;");
Database::query("DELETE FROM `" . TABLE_PANEL_SETTINGS . "` WHERE `settinggroup` = 'system' AND `varname` = 'send_cron_errors';");
lastStepStatus(0);
updateToVersion('0.9.35-dev4');
}

View File

@@ -105,34 +105,12 @@ class FroxlorLogger {
} }
if (self::$crondebug_flag) { if (self::$crondebug_flag) {
switch($type) { echo "[".getLogLevelDesc($type)."] ".$text.PHP_EOL;
case LOG_INFO:
$_type = 'information';
break;
case LOG_NOTICE:
$_type = 'notice';
break;
case LOG_WARNING:
$_type = 'warning';
break;
case LOG_ERR:
$_type = 'error';
break;
case LOG_CRIT:
$_type = 'critical';
break;
case LOG_DEBUG:
$_type = 'debug';
break;
default:
$_type = 'unknown';
break;
}
echo "[".$_type."] ".$text.PHP_EOL;
} }
if (Settings::Get('logger.log_cron') == '0' if (Settings::Get('logger.log_cron') == '0'
&& $action == CRON_ACTION && $action == CRON_ACTION
&& $type > 4 // warnings, errors and critical mesages WILL be logged
) { ) {
return; return;
} }
@@ -191,13 +169,11 @@ class FroxlorLogger {
$_cronlog = (int)$_cronlog; $_cronlog = (int)$_cronlog;
if ($_cronlog != 0 if ($_cronlog < 0 || $_cronlog > 2) {
&& $_cronlog != 1
) {
$_cronlog = 0; $_cronlog = 0;
} }
Settings::Set('logger.log_cron', $_cronlog); Settings::Set('logger.log_cron', $_cronlog);
return true; return $_cronlog;
} }
/** /**

View File

@@ -114,9 +114,9 @@ class SysLogger extends AbstractLogger {
if ($text != null if ($text != null
&& $text != '' && $text != ''
) { ) {
syslog((int)$type, "[" . ucfirst($_action) . " Action " . $name . "] " . $text); syslog((int)$type, "[" . ucfirst($_action) . " Action " . $name . "] [".getLogLevelDesc($type)."] " . $text);
} else { } else {
syslog((int)$type, "[" . ucfirst($_action) . " Action " . $name . "] No text given!!! Check scripts!"); syslog((int)$type, "[" . ucfirst($_action) . " Action " . $name . "] [".getLogLevelDesc($type)."] No text given!!! Check scripts!");
} }
closelog(); closelog();

View File

@@ -0,0 +1,44 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Michael Kaufmann <mkaufmann@nutime.de>
* @author Daniel Reichelt <hacking@nachtgeist.net> (2016-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function getLogLevelDesc($type) {
switch($type) {
case LOG_INFO:
$_type = 'information';
break;
case LOG_NOTICE:
$_type = 'notice';
break;
case LOG_WARNING:
$_type = 'warning';
break;
case LOG_ERR:
$_type = 'error';
break;
case LOG_CRIT:
$_type = 'critical';
break;
case LOG_DEBUG:
$_type = 'debug';
break;
default:
$_type = 'unknown';
break;
}
return $_type;
}

View File

@@ -16,7 +16,7 @@
*/ */
// Main version variable // Main version variable
$version = '0.9.35-dev3'; $version = '0.9.35-dev4';
// Database version (unused, old stuff from SysCP) // Database version (unused, old stuff from SysCP)
$dbversion = '2'; $dbversion = '2';

View File

@@ -689,7 +689,10 @@ $lng['serversettings']['logger']['types']['title'] = 'Log-type(s)';
$lng['serversettings']['logger']['types']['description'] = 'Om meerdere types te selecteren, houd u CTRL ingedrukt terwijl u selecteert.<br />Beschikbare types zijn: syslog, bestand, mysql'; $lng['serversettings']['logger']['types']['description'] = 'Om meerdere types te selecteren, houd u CTRL ingedrukt terwijl u selecteert.<br />Beschikbare types zijn: syslog, bestand, mysql';
$lng['serversettings']['logger']['logfile'] = 'Pad naar logfile, inclusief bestandsnaam'; $lng['serversettings']['logger']['logfile'] = 'Pad naar logfile, inclusief bestandsnaam';
$lng['error']['logerror'] = 'Log-Fout: %s'; $lng['error']['logerror'] = 'Log-Fout: %s';
$lng['serversettings']['logger']['logcron'] = 'Cronjobs loggen (eenmalig)'; $lng['serversettings']['logger']['logcron'] = 'Cronjobs loggen';
$lng['serversettings']['logger']['logcronoption']['never'] = 'Nooit';
$lng['serversettings']['logger']['logcronoption']['once'] = 'Eeenmalig';
$lng['serversettings']['logger']['logcronoption']['always'] = 'Altijd';
$lng['question']['logger_reallytruncate'] = 'Weet u zeker dat u de tabel "%s" wilt legen?'; $lng['question']['logger_reallytruncate'] = 'Weet u zeker dat u de tabel "%s" wilt legen?';
$lng['admin']['loggersystem'] = 'Systeemlog'; $lng['admin']['loggersystem'] = 'Systeemlog';
$lng['menue']['logger']['logger'] = 'Systeemlog'; $lng['menue']['logger']['logger'] = 'Systeemlog';

View File

@@ -738,7 +738,10 @@ $lng['serversettings']['logger']['types']['title'] = 'Log-type(s)';
$lng['serversettings']['logger']['types']['description'] = 'Specify logtypes. To select multiple types, hold down CTRL while selecting.<br />Available logtypes are: syslog, file, mysql'; $lng['serversettings']['logger']['types']['description'] = 'Specify logtypes. To select multiple types, hold down CTRL while selecting.<br />Available logtypes are: syslog, file, mysql';
$lng['serversettings']['logger']['logfile'] = 'Logfile path including filename'; $lng['serversettings']['logger']['logfile'] = 'Logfile path including filename';
$lng['error']['logerror'] = 'Log-Error: %s'; $lng['error']['logerror'] = 'Log-Error: %s';
$lng['serversettings']['logger']['logcron'] = 'Log cronjobs (one run)'; $lng['serversettings']['logger']['logcron'] = 'Log cronjobs';
$lng['serversettings']['logger']['logcronoption']['never'] = 'Never';
$lng['serversettings']['logger']['logcronoption']['once'] = 'Once';
$lng['serversettings']['logger']['logcronoption']['always'] = 'Always';
$lng['question']['logger_reallytruncate'] = 'Do you really want to truncate the table "%s"?'; $lng['question']['logger_reallytruncate'] = 'Do you really want to truncate the table "%s"?';
$lng['admin']['loggersystem'] = 'System-logging'; $lng['admin']['loggersystem'] = 'System-logging';
$lng['menue']['logger']['logger'] = 'System-logging'; $lng['menue']['logger']['logger'] = 'System-logging';
@@ -1833,8 +1836,6 @@ $lng['domains']['import_description'] = 'Detailed information about the structur
$lng['usersettings']['custom_notes']['title'] = 'Custom notes'; $lng['usersettings']['custom_notes']['title'] = 'Custom notes';
$lng['usersettings']['custom_notes']['description'] = 'Feel free to put any notes you want/need in here. They will show up in the admin/customer overview for the corresponding user.'; $lng['usersettings']['custom_notes']['description'] = 'Feel free to put any notes you want/need in here. They will show up in the admin/customer overview for the corresponding user.';
$lng['usersettings']['custom_notes']['show'] = 'Show your notes on the dashboard of the user'; $lng['usersettings']['custom_notes']['show'] = 'Show your notes on the dashboard of the user';
$lng['serversettings']['system_send_cron_errors']['title'] = 'Send cron-errors to froxlor-admin via e-mail';
$lng['serversettings']['system_send_cron_errors']['description'] = 'Choose whether you want to receive an e-mail on cronjob errors. Keep in mind that this can lead to an e-mail being sent every 5 minutes depending on the error and your cronjob settings.';
$lng['error']['fcgidandphpfpmnogoodtogether'] = 'FCGID and PHP-FPM cannot be activated at the same time'; $lng['error']['fcgidandphpfpmnogoodtogether'] = 'FCGID and PHP-FPM cannot be activated at the same time';
// Added in Froxlor 0.9.34 // Added in Froxlor 0.9.34

View File

@@ -728,7 +728,10 @@ $lng['serversettings']['logger']['types']['title'] = 'Type(s) de log';
$lng['serversettings']['logger']['types']['description'] = 'Spécifiez les types de log séparés par des virgules.<br />Les types de log disponible sont : syslog, file, mysql'; $lng['serversettings']['logger']['types']['description'] = 'Spécifiez les types de log séparés par des virgules.<br />Les types de log disponible sont : syslog, file, mysql';
$lng['serversettings']['logger']['logfile'] = 'Nom du fichier de log, dossier + nom du fichier'; $lng['serversettings']['logger']['logfile'] = 'Nom du fichier de log, dossier + nom du fichier';
$lng['error']['logerror'] = 'Erreur log : %s'; $lng['error']['logerror'] = 'Erreur log : %s';
$lng['serversettings']['logger']['logcron'] = 'Loguer les travaux de cron (lancer une fois)'; $lng['serversettings']['logger']['logcron'] = 'Loguer les travaux de cron';
$lng['serversettings']['logger']['logcronoption']['never'] = 'Jamais';
$lng['serversettings']['logger']['logcronoption']['once'] = 'Une fois';
$lng['serversettings']['logger']['logcronoption']['always'] = 'Toujours';
$lng['question']['logger_reallytruncate'] = 'Etes-vous sûr de vouloir vider la table "%s" ?'; $lng['question']['logger_reallytruncate'] = 'Etes-vous sûr de vouloir vider la table "%s" ?';
$lng['admin']['loggersystem'] = 'Log système'; $lng['admin']['loggersystem'] = 'Log système';
$lng['menue']['logger']['logger'] = 'Log système'; $lng['menue']['logger']['logger'] = 'Log système';

View File

@@ -735,7 +735,10 @@ $lng['serversettings']['logger']['types']['title'] = 'Log-Art(en)';
$lng['serversettings']['logger']['types']['description'] = 'Wählen Sie hier die gewünschten Logtypen. Für Mehrfachauswahl, halten Sie während der Auswahl STRG gedrückt<br />Mögliche Logtypen sind: syslog, file, mysql'; $lng['serversettings']['logger']['types']['description'] = 'Wählen Sie hier die gewünschten Logtypen. Für Mehrfachauswahl, halten Sie während der Auswahl STRG gedrückt<br />Mögliche Logtypen sind: syslog, file, mysql';
$lng['serversettings']['logger']['logfile'] = 'Log-Datei Pfad inklusive Dateinamen'; $lng['serversettings']['logger']['logfile'] = 'Log-Datei Pfad inklusive Dateinamen';
$lng['error']['logerror'] = 'Log-Fehler: "%s"'; $lng['error']['logerror'] = 'Log-Fehler: "%s"';
$lng['serversettings']['logger']['logcron'] = 'Logge Cronjobs (einen Durchgang)'; $lng['serversettings']['logger']['logcron'] = 'Logge Cronjobs';
$lng['serversettings']['logger']['logcronoption']['never'] = 'Nie';
$lng['serversettings']['logger']['logcronoption']['once'] = 'Einmalig';
$lng['serversettings']['logger']['logcronoption']['always'] = 'Immer';
$lng['question']['logger_reallytruncate'] = 'Wollen Sie die Tabelle "%s" wirklich leeren?'; $lng['question']['logger_reallytruncate'] = 'Wollen Sie die Tabelle "%s" wirklich leeren?';
$lng['admin']['loggersystem'] = 'System-Logging'; $lng['admin']['loggersystem'] = 'System-Logging';
$lng['menue']['logger']['logger'] = 'System-Logging'; $lng['menue']['logger']['logger'] = 'System-Logging';
@@ -1560,8 +1563,6 @@ $lng['domains']['import_description'] = 'Detaillierte Informationen über den Au
$lng['usersettings']['custom_notes']['title'] = 'Eigene Notizen'; $lng['usersettings']['custom_notes']['title'] = 'Eigene Notizen';
$lng['usersettings']['custom_notes']['description'] = 'Hier können Notizen je nach Lust und Laune eingetragen werden. Diese werden in der Administrator/Kunden-Übersicht bei dem jeweiligen Benutzer angezeigt.'; $lng['usersettings']['custom_notes']['description'] = 'Hier können Notizen je nach Lust und Laune eingetragen werden. Diese werden in der Administrator/Kunden-Übersicht bei dem jeweiligen Benutzer angezeigt.';
$lng['usersettings']['custom_notes']['show'] = 'Zeige die Notizen auf dem Dashboard des Benutzers'; $lng['usersettings']['custom_notes']['show'] = 'Zeige die Notizen auf dem Dashboard des Benutzers';
$lng['serversettings']['system_send_cron_errors']['title'] = 'Sende Cron-Fehler via E-Mail an den Froxlor-Admin';
$lng['serversettings']['system_send_cron_errors']['description'] = 'Gib an, ob bei einem Cron-Fehler eine E-Mail versendet werden soll. Beachte, dass es je nach Fehler und Cronjob-Einstellungen dazu kommen kann, dass diese E-Mail alle 5 Minuten gesendet wird.';
$lng['error']['fcgidandphpfpmnogoodtogether'] = 'FCGID und PHP-FPM können nicht gleichzeitig aktiviert werden.'; $lng['error']['fcgidandphpfpmnogoodtogether'] = 'FCGID und PHP-FPM können nicht gleichzeitig aktiviert werden.';
// Added in Froxlor 0.9.34 // Added in Froxlor 0.9.34

View File

@@ -1802,5 +1802,3 @@ $lng['domains']['import_description'] = 'Per ottenere informazioni dettagliate s
$lng['usersettings']['custom_notes']['title'] = 'Note personali'; $lng['usersettings']['custom_notes']['title'] = 'Note personali';
$lng['usersettings']['custom_notes']['description'] = 'Sentiti libero di inserire qualsi nota vuoi o necessiti qui. Apparirano nel riepilogo dell\'amministratore/cliente perl \'utente corrispondente.'; $lng['usersettings']['custom_notes']['description'] = 'Sentiti libero di inserire qualsi nota vuoi o necessiti qui. Apparirano nel riepilogo dell\'amministratore/cliente perl \'utente corrispondente.';
$lng['usersettings']['custom_notes']['show'] = 'Mostra le tue note nel cruscotto dell\'utente'; $lng['usersettings']['custom_notes']['show'] = 'Mostra le tue note nel cruscotto dell\'utente';
$lng['serversettings']['system_send_cron_errors']['title'] = 'Inviaa gli errori cron all \'amministratore di froxlor via e-mail';
$lng['serversettings']['system_send_cron_errors']['description'] = 'Scegli se ricevere una email sugli errori di cronjob. Ricorda che questo potrebbe causare l\'invio di una mail ogni 5 minuti in dipendenza all \'errore e alle tue impostazioni di cronjob.';

View File

@@ -642,6 +642,9 @@ $lng['serversettings']['logger']['types']['description'] = 'Especificar tipos de
$lng['serversettings']['logger']['logfile'] = 'Caminho do Arquivo de Log incluindo nome de arquivo'; $lng['serversettings']['logger']['logfile'] = 'Caminho do Arquivo de Log incluindo nome de arquivo';
$lng['error']['logerror'] = 'Log-Erro: %s'; $lng['error']['logerror'] = 'Log-Erro: %s';
$lng['serversettings']['logger']['logcron'] = 'Logar tarefas do cron'; $lng['serversettings']['logger']['logcron'] = 'Logar tarefas do cron';
$lng['serversettings']['logger']['logcronoption']['never'] = 'Nunca';
$lng['serversettings']['logger']['logcronoption']['once'] = 'Uma vez';
$lng['serversettings']['logger']['logcronoption']['always'] = 'Sempre';
$lng['question']['logger_reallytruncate'] = 'Você realmente deseja dividir a tabela "%s"?'; $lng['question']['logger_reallytruncate'] = 'Você realmente deseja dividir a tabela "%s"?';
$lng['admin']['loggersystem'] = 'Systema-Logging'; $lng['admin']['loggersystem'] = 'Systema-Logging';
$lng['menue']['logger']['logger'] = 'Systema-Logging'; $lng['menue']['logger']['logger'] = 'Systema-Logging';

View File

@@ -18,7 +18,7 @@
* *
*/ */
fwrite($debugHandler, "calculating mailspace usage\n"); $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'calculating mailspace usage');
$maildirs_stmt = Database::query(" $maildirs_stmt = Database::query("
SELECT `id`, CONCAT(`homedir`, `maildir`) AS `maildirpath` FROM `".TABLE_MAIL_USERS."` ORDER BY `id` SELECT `id`, CONCAT(`homedir`, `maildir`) AS `maildirpath` FROM `".TABLE_MAIL_USERS."` ORDER BY `id`
@@ -50,6 +50,6 @@ while ($maildir = $maildirs_stmt->fetch(PDO::FETCH_ASSOC)) {
unset($back); unset($back);
Database::pexecute($upd_stmt, array('size' => $emailusage, 'id' => $maildir['id'])); Database::pexecute($upd_stmt, array('size' => $emailusage, 'id' => $maildir['id']));
} else { } else {
fwrite($debugHandler, 'maildir ' . $_maildir . ' does not exist' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_WARNING, 'maildir ' . $_maildir . ' does not exist');
} }
} }

View File

@@ -19,7 +19,6 @@
class bind { class bind {
public $logger = false; public $logger = false;
public $debugHandler = false;
public $nameservers = array(); public $nameservers = array();
public $mxservers = array(); public $mxservers = array();
public $axfrservers = array(); public $axfrservers = array();
@@ -27,10 +26,9 @@ class bind {
private $_known_filenames = array(); private $_known_filenames = array();
private $_bindconf_file = ''; private $_bindconf_file = '';
public function __construct($logger, $debugHandler) { public function __construct($logger) {
$this->logger = $logger; $this->logger = $logger;
$this->debugHandler = $debugHandler;
if (Settings::Get('system.nameservers') != '') { if (Settings::Get('system.nameservers') != '') {
$nameservers = explode(',', Settings::Get('system.nameservers')); $nameservers = explode(',', Settings::Get('system.nameservers'));
@@ -67,7 +65,6 @@ class bind {
public function writeConfigs() { public function writeConfigs() {
fwrite($this->debugHandler, ' cron_tasks: Task4 started - Rebuilding froxlor_bind.conf' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'Task4 started - Rebuilding froxlor_bind.conf'); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'Task4 started - Rebuilding froxlor_bind.conf');
if (!file_exists(makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/'))) { if (!file_exists(makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/'))) {
@@ -130,22 +127,20 @@ class bind {
} }
} }
fwrite($this->debugHandler, $this->logger->logAction(CRON_ACTION, LOG_DEBUG,
str_pad('domId', 9, ' ') . str_pad('domain', 40, ' ') . str_pad('domId', 9, ' ') . str_pad('domain', 40, ' ') .
'ismainbutsubto ' . str_pad('parent domain', 40, ' ') . 'ismainbutsubto ' . str_pad('parent domain', 40, ' ') .
"list of child domain ids\n"); "list of child domain ids");
foreach ($domains as $domain) { foreach ($domains as $domain) {
fwrite($this->debugHandler, $logLine =
str_pad($domain['id'], 9, ' ') . str_pad($domain['id'], 9, ' ') .
str_pad($domain['domain'], 40, ' ') . str_pad($domain['domain'], 40, ' ') .
str_pad($domain['ismainbutsubto'], 15, ' ') . str_pad($domain['ismainbutsubto'], 15, ' ') .
str_pad(((isset($domains[ $domain['ismainbutsubto'] ])) ? str_pad(((isset($domains[ $domain['ismainbutsubto'] ])) ?
$domains[ $domain['ismainbutsubto'] ]['domain'] : $domains[ $domain['ismainbutsubto'] ]['domain'] :
'-'), 40, ' ')); '-'), 40, ' ') .
foreach ($domain['children'] as $child) { join(', ', $domain['children']);
fwrite($this->debugHandler, '$child, '); $this->logger->logAction(CRON_ACTION, LOG_DEBUG, $logLine);
}
fwrite($this->debugHandler, "\n");
} }
foreach ($domains as $domain) { foreach ($domains as $domain) {
@@ -159,10 +154,8 @@ class bind {
$bindconf_file_handler = fopen(makeCorrectFile(Settings::Get('system.bindconf_directory') . '/froxlor_bind.conf'), 'w'); $bindconf_file_handler = fopen(makeCorrectFile(Settings::Get('system.bindconf_directory') . '/froxlor_bind.conf'), 'w');
fwrite($bindconf_file_handler, $this->_bindconf_file); fwrite($bindconf_file_handler, $this->_bindconf_file);
fclose($bindconf_file_handler); fclose($bindconf_file_handler);
fwrite($this->debugHandler, ' cron_tasks: Task4 - froxlor_bind.conf written' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'froxlor_bind.conf written'); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'froxlor_bind.conf written');
safe_exec(escapeshellcmd(Settings::Get('system.bindreload_command'))); safe_exec(escapeshellcmd(Settings::Get('system.bindreload_command')));
fwrite($this->debugHandler, ' cron_tasks: Task4 - Bind9 reloaded' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'Bind9 reloaded'); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'Bind9 reloaded');
$domains_dir = makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/'); $domains_dir = makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/');
@@ -178,12 +171,12 @@ class bind {
&& !in_array($domain_filename, $this->_known_filenames) && !in_array($domain_filename, $this->_known_filenames)
&& is_file($full_filename) && is_file($full_filename)
&& file_exists($full_filename)) { && file_exists($full_filename)) {
fwrite($this->debugHandler, ' cron_tasks: Task4 - unlinking ' . $domain_filename . "\n");
$this->logger->logAction(CRON_ACTION, LOG_WARNING, 'Deleting ' . $domain_filename); $this->logger->logAction(CRON_ACTION, LOG_WARNING, 'Deleting ' . $domain_filename);
unlink(makeCorrectFile($domains_dir . '/' . $domain_filename)); unlink(makeCorrectFile($domains_dir . '/' . $domain_filename));
} }
} }
} }
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'Task4 finished');
} }
private function walkDomainList($domain, $domains) { private function walkDomainList($domain, $domains) {
@@ -202,7 +195,7 @@ class bind {
$zonefile_handler = fopen($zonefile_name, 'w'); $zonefile_handler = fopen($zonefile_name, 'w');
fwrite($zonefile_handler, $zonefile.$subzones); fwrite($zonefile_handler, $zonefile.$subzones);
fclose($zonefile_handler); fclose($zonefile_handler);
fwrite($this->debugHandler, ' cron_tasks: Task4 - `' . $zonefile_name . '` zone written' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, '`' . $zonefile_name . '` zone written');
} else { } else {
return $this->generateZone($domain); return $this->generateZone($domain);
} }
@@ -600,7 +593,6 @@ class bind {
fclose($dkimkeys_file_handler); fclose($dkimkeys_file_handler);
safe_exec(escapeshellcmd(Settings::Get('dkim.dkimrestart_command'))); safe_exec(escapeshellcmd(Settings::Get('dkim.dkimrestart_command')));
fwrite($this->debugHandler, ' cron_tasks: Task4 - Dkim-milter reloaded' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'Dkim-milter reloaded'); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'Dkim-milter reloaded');
} }
} }

View File

@@ -21,7 +21,6 @@ require_once(dirname(__FILE__).'/../classes/class.HttpConfigBase.php');
class apache extends HttpConfigBase { class apache extends HttpConfigBase {
private $logger = false; private $logger = false;
private $debugHandler = false;
private $idnaConvert = false; private $idnaConvert = false;
// protected // protected
@@ -40,21 +39,18 @@ class apache extends HttpConfigBase {
*/ */
private $_deactivated = false; private $_deactivated = false;
public function __construct($logger, $debugHandler, $idnaConvert) { public function __construct($logger, $idnaConvert) {
$this->logger = $logger; $this->logger = $logger;
$this->debugHandler = $debugHandler;
$this->idnaConvert = $idnaConvert; $this->idnaConvert = $idnaConvert;
} }
public function reload() { public function reload() {
if ((int)Settings::Get('phpfpm.enabled') == 1) { if ((int)Settings::Get('phpfpm.enabled') == 1) {
fwrite($this->debugHandler, ' apache::reload: reloading php-fpm' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'apache::reload: reloading php-fpm');
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading php-fpm');
safe_exec(escapeshellcmd(Settings::Get('phpfpm.reload'))); safe_exec(escapeshellcmd(Settings::Get('phpfpm.reload')));
} }
fwrite($this->debugHandler, ' apache::reload: reloading apache' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'apache::reload: reloading apache');
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading apache');
safe_exec(escapeshellcmd(Settings::Get('system.apachereload_command'))); safe_exec(escapeshellcmd(Settings::Get('system.apachereload_command')));
} }
@@ -76,8 +72,7 @@ class apache extends HttpConfigBase {
) { ) {
// if we use fcgid or php-fpm we don't need this file // if we use fcgid or php-fpm we don't need this file
if (file_exists($vhosts_filename)) { if (file_exists($vhosts_filename)) {
fwrite($this->debugHandler, ' apache::_createStandardDirectoryEntry: unlinking ' . basename($vhosts_filename) . "\n"); $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'apache::_createStandardDirectoryEntry: unlinking ' . basename($vhosts_filename));
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'unlinking ' . basename($vhosts_filename));
unlink(makeCorrectFile($vhosts_filename)); unlink(makeCorrectFile($vhosts_filename));
} }
} else { } else {
@@ -147,8 +142,7 @@ class apache extends HttpConfigBase {
$ipport = $row_ipsandports['ip'] . ':' . $row_ipsandports['port']; $ipport = $row_ipsandports['ip'] . ':' . $row_ipsandports['port'];
} }
fwrite($this->debugHandler, ' apache::createIpPort: creating ip/port settings for ' . $ipport . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'apache::createIpPort: creating ip/port settings for ' . $ipport);
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating ip/port settings for ' . $ipport);
$vhosts_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf'); $vhosts_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf');
if (!isset($this->virtualhosts_data[$vhosts_filename])) { if (!isset($this->virtualhosts_data[$vhosts_filename])) {
@@ -895,8 +889,7 @@ class apache extends HttpConfigBase {
$domains = WebserverBase::getVhostsToCreate(); $domains = WebserverBase::getVhostsToCreate();
foreach ($domains as $domain) { foreach ($domains as $domain) {
fwrite($this->debugHandler, ' apache::createVirtualHosts: creating vhost container for domain ' . $domain['id'] . ', customer ' . $domain['loginname'] . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'apache::createVirtualHosts: creating vhost container for domain ' . $domain['id'] . ', customer ' . $domain['loginname']);
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating vhost container for domain ' . $domain['id'] . ', customer ' . $domain['loginname']);
$vhosts_filename = $this->getVhostFilename($domain); $vhosts_filename = $this->getVhostFilename($domain);
// Apply header // Apply header
@@ -995,7 +988,7 @@ class apache extends HttpConfigBase {
} else { } else {
$this->diroptions_data[$diroptions_filename] .= "\n"; $this->diroptions_data[$diroptions_filename] .= "\n";
} }
fwrite($this->debugHandler, ' cron_tasks: Task3 - Setting Options +Indexes' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'Setting Options +Indexes');
} }
if (isset($row_diroptions['options_indexes']) if (isset($row_diroptions['options_indexes'])
@@ -1012,7 +1005,7 @@ class apache extends HttpConfigBase {
} else { } else {
$this->diroptions_data[$diroptions_filename] .= "\n"; $this->diroptions_data[$diroptions_filename] .= "\n";
} }
fwrite($this->debugHandler, ' cron_tasks: Task3 - Setting Options -Indexes' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'Setting Options -Indexes');
} }
$statusCodes = array('404', '403', '500'); $statusCodes = array('404', '403', '500');
@@ -1048,7 +1041,7 @@ class apache extends HttpConfigBase {
$this->diroptions_data[$diroptions_filename] .= ' Order allow,deny' . "\n"; $this->diroptions_data[$diroptions_filename] .= ' Order allow,deny' . "\n";
$this->diroptions_data[$diroptions_filename] .= ' Allow from all' . "\n"; $this->diroptions_data[$diroptions_filename] .= ' Allow from all' . "\n";
} }
fwrite($this->debugHandler, ' cron_tasks: Task3 - Enabling perl execution' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'Enabling perl execution');
// check for suexec-workaround, #319 // check for suexec-workaround, #319
if ((int)Settings::Get('perl.suexecworkaround') == 1) { if ((int)Settings::Get('perl.suexecworkaround') == 1) {
@@ -1116,8 +1109,7 @@ class apache extends HttpConfigBase {
*/ */
public function writeConfigs() { public function writeConfigs() {
// Write diroptions // Write diroptions
fwrite($this->debugHandler, ' apache::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_diroptions') . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, "apache::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_diroptions'));
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_diroptions'));
if (count($this->diroptions_data) > 0) { if (count($this->diroptions_data) > 0) {
$optsDir = new frxDirectory(Settings::Get('system.apacheconf_diroptions')); $optsDir = new frxDirectory(Settings::Get('system.apacheconf_diroptions'));
@@ -1138,8 +1130,7 @@ class apache extends HttpConfigBase {
fclose($diroptions_file_handler); fclose($diroptions_file_handler);
} else { } else {
if (!file_exists(Settings::Get('system.apacheconf_diroptions'))) { if (!file_exists(Settings::Get('system.apacheconf_diroptions'))) {
fwrite($this->debugHandler, ' apache::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_diroptions'))) . "\n"); $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'apache::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_diroptions'))));
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_diroptions'))));
safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_diroptions')))); safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_diroptions'))));
} }
@@ -1157,8 +1148,7 @@ class apache extends HttpConfigBase {
} }
// Write htpasswds // Write htpasswds
fwrite($this->debugHandler, ' apache::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_htpasswddir') . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, "apache::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_htpasswddir'));
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_htpasswddir'));
if (count($this->htpasswds_data) > 0) { if (count($this->htpasswds_data) > 0) {
if (!file_exists(Settings::Get('system.apacheconf_htpasswddir'))) { if (!file_exists(Settings::Get('system.apacheconf_htpasswddir'))) {
@@ -1177,15 +1167,12 @@ class apache extends HttpConfigBase {
fclose($htpasswd_file_handler); fclose($htpasswd_file_handler);
} }
} else { } else {
fwrite($this->debugHandler, ' cron_tasks: WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!' . "\n");
echo 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!';
$this->logger->logAction(CRON_ACTION, LOG_WARNING, 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!'); $this->logger->logAction(CRON_ACTION, LOG_WARNING, 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!');
} }
} }
// Write virtualhosts // Write virtualhosts
fwrite($this->debugHandler, ' apache::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_vhost') . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, "apache::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_vhost'));
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_vhost'));
if (count($this->virtualhosts_data) > 0) { if (count($this->virtualhosts_data) > 0) {
$vhostDir = new frxDirectory(Settings::Get('system.apacheconf_vhost')); $vhostDir = new frxDirectory(Settings::Get('system.apacheconf_vhost'));
@@ -1218,8 +1205,7 @@ class apache extends HttpConfigBase {
fclose($vhosts_file_handler); fclose($vhosts_file_handler);
} else { } else {
if (!file_exists(Settings::Get('system.apacheconf_vhost'))) { if (!file_exists(Settings::Get('system.apacheconf_vhost'))) {
fwrite($this->debugHandler, ' apache::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))) . "\n"); $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'apache::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost')))); safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
} }

View File

@@ -22,7 +22,6 @@ require_once(dirname(__FILE__).'/../classes/class.HttpConfigBase.php');
class lighttpd extends HttpConfigBase { class lighttpd extends HttpConfigBase {
private $logger = false; private $logger = false;
private $debugHandler = false;
private $idnaConvert = false; private $idnaConvert = false;
// protected // protected
@@ -40,21 +39,18 @@ class lighttpd extends HttpConfigBase {
*/ */
private $_deactivated = false; private $_deactivated = false;
public function __construct($logger, $debugHandler, $idnaConvert) { public function __construct($logger, $idnaConvert) {
$this->logger = $logger; $this->logger = $logger;
$this->debugHandler = $debugHandler;
$this->idnaConvert = $idnaConvert; $this->idnaConvert = $idnaConvert;
} }
public function reload() { public function reload() {
if ((int)Settings::Get('phpfpm.enabled') == 1) { if ((int)Settings::Get('phpfpm.enabled') == 1) {
fwrite($this->debugHandler, ' lighttpd::reload: reloading php-fpm' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'lighttpd::reload: reloading php-fpm');
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading php-fpm');
safe_exec(escapeshellcmd(Settings::Get('phpfpm.reload'))); safe_exec(escapeshellcmd(Settings::Get('phpfpm.reload')));
} }
fwrite($this->debugHandler, ' lighttpd::reload: reloading lighttpd' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'lighttpd::reload: reloading lighttpd');
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading lighttpd');
safe_exec(escapeshellcmd(Settings::Get('system.apachereload_command'))); safe_exec(escapeshellcmd(Settings::Get('system.apachereload_command')));
} }
@@ -73,8 +69,7 @@ class lighttpd extends HttpConfigBase {
$ipv6 = ''; $ipv6 = '';
} }
fwrite($this->debugHandler, ' lighttpd::createIpPort: creating ip/port settings for ' . $ip . ":" . $port . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'lighttpd::createIpPort: creating ip/port settings for ' . $ip . ":" . $port);
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating ip/port settings for ' . $ip . ":" . $port);
$vhost_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf'); $vhost_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf');
if (!isset($this->lighttpd_data[$vhost_filename])) { if (!isset($this->lighttpd_data[$vhost_filename])) {
@@ -861,8 +856,7 @@ class lighttpd extends HttpConfigBase {
public function writeConfigs() { public function writeConfigs() {
fwrite($this->debugHandler, ' lighttpd::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_vhost') . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, "lighttpd::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_vhost'));
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_vhost'));
$vhostDir = new frxDirectory(Settings::Get('system.apacheconf_vhost')); $vhostDir = new frxDirectory(Settings::Get('system.apacheconf_vhost'));
if (!$vhostDir->isConfigDir()) { if (!$vhostDir->isConfigDir()) {
@@ -889,8 +883,7 @@ class lighttpd extends HttpConfigBase {
fclose($vhosts_file_handler); fclose($vhosts_file_handler);
} else { } else {
if (!file_exists(Settings::Get('system.apacheconf_vhost'))) { if (!file_exists(Settings::Get('system.apacheconf_vhost'))) {
fwrite($this->debugHandler, ' lighttpd::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))) . "\n"); $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'lighttpd::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost')))); safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
} }

View File

@@ -19,7 +19,6 @@ require_once(dirname(__FILE__).'/../classes/class.HttpConfigBase.php');
class nginx extends HttpConfigBase { class nginx extends HttpConfigBase {
private $logger = false; private $logger = false;
private $debugHandler = false;
private $idnaConvert = false; private $idnaConvert = false;
private $nginx_server = array(); private $nginx_server = array();
@@ -40,17 +39,15 @@ class nginx extends HttpConfigBase {
*/ */
private $_deactivated = false; private $_deactivated = false;
public function __construct($logger, $debugHandler, $idnaConvert, $nginx_server=array()) { public function __construct($logger, $idnaConvert, $nginx_server=array()) {
$this->logger = $logger; $this->logger = $logger;
$this->debugHandler = $debugHandler;
$this->idnaConvert = $idnaConvert; $this->idnaConvert = $idnaConvert;
$this->nginx_server = $nginx_server; $this->nginx_server = $nginx_server;
} }
public function reload() { public function reload() {
fwrite($this->debugHandler, ' nginx::reload: reloading nginx' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'nginx::reload: reloading nginx');
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading nginx');
safe_exec(Settings::Get('system.apachereload_command')); safe_exec(Settings::Get('system.apachereload_command'));
/** /**
@@ -59,12 +56,10 @@ class nginx extends HttpConfigBase {
if (Settings::Get('system.phpreload_command') != '' if (Settings::Get('system.phpreload_command') != ''
&& (int)Settings::Get('phpfpm.enabled') == 0 && (int)Settings::Get('phpfpm.enabled') == 0
) { ) {
fwrite($this->debugHandler, ' nginx::reload: restarting php processes' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'nginx::reload: restarting php processes');
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'restarting php processes');
safe_exec(Settings::Get('system.phpreload_command')); safe_exec(Settings::Get('system.phpreload_command'));
} elseif ((int)Settings::Get('phpfpm.enabled') == 1) { } elseif ((int)Settings::Get('phpfpm.enabled') == 1) {
fwrite($this->debugHandler, ' nginx::reload: reloading php-fpm' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'nginx::reload: reloading php-fpm');
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading php-fpm');
safe_exec(escapeshellcmd(Settings::Get('phpfpm.reload'))); safe_exec(escapeshellcmd(Settings::Get('phpfpm.reload')));
} }
} }
@@ -128,8 +123,7 @@ class nginx extends HttpConfigBase {
} }
$port = $row_ipsandports['port']; $port = $row_ipsandports['port'];
fwrite($this->debugHandler, ' nginx::createIpPort: creating ip/port settings for ' . $ip . ":" . $port . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'nginx::createIpPort: creating ip/port settings for ' . $ip . ":" . $port);
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating ip/port settings for ' . $ip . ":" . $port);
$vhost_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf'); $vhost_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf');
if (!isset($this->nginx_data[$vhost_filename])) { if (!isset($this->nginx_data[$vhost_filename])) {
@@ -1002,8 +996,7 @@ class nginx extends HttpConfigBase {
public function writeConfigs() { public function writeConfigs() {
fwrite($this->debugHandler, ' nginx::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_vhost') . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, "nginx::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_vhost'));
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_vhost'));
$vhostDir = new frxDirectory(Settings::Get('system.apacheconf_vhost')); $vhostDir = new frxDirectory(Settings::Get('system.apacheconf_vhost'));
if (!$vhostDir->isConfigDir()) { if (!$vhostDir->isConfigDir()) {
@@ -1029,8 +1022,7 @@ class nginx extends HttpConfigBase {
fclose($vhosts_file_handler); fclose($vhosts_file_handler);
} else { } else {
if (!file_exists(Settings::Get('system.apacheconf_vhost'))) { if (!file_exists(Settings::Get('system.apacheconf_vhost'))) {
fwrite($this->debugHandler, ' nginx::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))) . "\n"); $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'nginx::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
safe_exec('mkdir -p ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost')))); safe_exec('mkdir -p ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
} }
@@ -1058,8 +1050,6 @@ class nginx extends HttpConfigBase {
mkdir(Settings::Get('system.apacheconf_htpasswddir'), 0751); mkdir(Settings::Get('system.apacheconf_htpasswddir'), 0751);
umask($umask); umask($umask);
} elseif (!is_dir(Settings::Get('system.apacheconf_htpasswddir'))) { } elseif (!is_dir(Settings::Get('system.apacheconf_htpasswddir'))) {
fwrite($this->debugHandler, ' cron_tasks: WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!' . "\n");
echo 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!';
$this->logger->logAction(CRON_ACTION, LOG_WARNING, 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!'); $this->logger->logAction(CRON_ACTION, LOG_WARNING, 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!');
} }

View File

@@ -29,8 +29,7 @@ require_once makeCorrectFile(dirname(__FILE__) . '/cron_tasks.inc.http.35.nginx_
/** /**
* LOOK INTO TASKS TABLE TO SEE IF THERE ARE ANY UNDONE JOBS * LOOK INTO TASKS TABLE TO SEE IF THERE ARE ANY UNDONE JOBS
*/ */
fwrite($debugHandler, ' cron_tasks: Searching for tasks to do' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, "cron_tasks: Searching for tasks to do");
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Searching for tasks to do");
$result_tasks_stmt = Database::query(" $result_tasks_stmt = Database::query("
SELECT `id`, `type`, `data` FROM `" . TABLE_PANEL_TASKS . "` WHERE `type` <> '99' ORDER BY `id` ASC SELECT `id`, `type`, `data` FROM `" . TABLE_PANEL_TASKS . "` WHERE `type` <> '99' ORDER BY `id` ASC
"); ");
@@ -73,7 +72,7 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
} }
} }
$webserver = new $websrv($cronlog, $debugHandler, $idna_convert); $webserver = new $websrv($cronlog, $idna_convert);
} }
if (isset($webserver)) { if (isset($webserver)) {
@@ -115,8 +114,7 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
* TYPE=2 MEANS TO CREATE A NEW HOME AND CHOWN * TYPE=2 MEANS TO CREATE A NEW HOME AND CHOWN
*/ */
elseif ($row['type'] == '2') { elseif ($row['type'] == '2') {
fwrite($debugHandler, ' cron_tasks: Task2 started - create new home' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'cron_tasks: Task2 started - create new home');
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task2 started - create new home');
if (is_array($row['data'])) { if (is_array($row['data'])) {
// define paths // define paths
@@ -175,7 +173,7 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
*/ */
elseif ($row['type'] == '4' && (int)Settings::Get('system.bind_enable') != 0) { elseif ($row['type'] == '4' && (int)Settings::Get('system.bind_enable') != 0) {
if (!isset($nameserver)) { if (!isset($nameserver)) {
$nameserver = new bind($cronlog, $debugHandler); $nameserver = new bind($cronlog);
} }
if (Settings::Get('dkim.use_dkim') == '1') { if (Settings::Get('dkim.use_dkim') == '1') {
@@ -204,8 +202,7 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
* TYPE=6 MEANS THAT A CUSTOMER HAS BEEN DELETED AND THAT WE HAVE TO REMOVE ITS FILES * TYPE=6 MEANS THAT A CUSTOMER HAS BEEN DELETED AND THAT WE HAVE TO REMOVE ITS FILES
*/ */
elseif ($row['type'] == '6') { elseif ($row['type'] == '6') {
fwrite($debugHandler, ' cron_tasks: Task6 started - deleting customer data' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'cron_tasks: Task6 started - deleting customer data');
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task6 started - deleting customer data');
if (is_array($row['data'])) { if (is_array($row['data'])) {
if (isset($row['data']['loginname'])) { if (isset($row['data']['loginname'])) {
@@ -271,8 +268,7 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
* TYPE=7 Customer deleted an email account and wants the data to be deleted on the filesystem * TYPE=7 Customer deleted an email account and wants the data to be deleted on the filesystem
*/ */
elseif ($row['type'] == '7') { elseif ($row['type'] == '7') {
fwrite($debugHandler, ' cron_tasks: Task7 started - deleting customer e-mail data' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'cron_tasks: Task7 started - deleting customer e-mail data');
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task7 started - deleting customer e-mail data');
if (is_array($row['data'])) { if (is_array($row['data'])) {
@@ -337,8 +333,7 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
* refs #293 * refs #293
*/ */
elseif ($row['type'] == '8') { elseif ($row['type'] == '8') {
fwrite($debugHandler, ' cron_tasks: Task8 started - deleting customer ftp homedir' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'cron_tasks: Task8 started - deleting customer ftp homedir');
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task8 started - deleting customer ftp homedir');
if (is_array($row['data'])) { if (is_array($row['data'])) {
@@ -366,8 +361,7 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
*/ */
elseif ($row['type'] == '10' && (int)Settings::Get('system.diskquota_enabled') != 0) { elseif ($row['type'] == '10' && (int)Settings::Get('system.diskquota_enabled') != 0) {
fwrite($debugHandler, ' cron_tasks: Task10 started - setting filesystem quota' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'cron_tasks: Task10 started - setting filesystem quota');
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task10 started - setting filesystem quota');
$usedquota = getFilesystemQuota(); $usedquota = getFilesystemQuota();

View File

@@ -20,7 +20,7 @@
/** /**
* ARCHIVING CLOSED TICKETS * ARCHIVING CLOSED TICKETS
*/ */
fwrite($debugHandler, 'Ticket-archiving run started...' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Ticket-archiving run started...');
$result_tickets_stmt = Database::query(" $result_tickets_stmt = Database::query("
SELECT `id`, `lastchange`, `subject` FROM `" . TABLE_PANEL_TICKETS . "` SELECT `id`, `lastchange`, `subject` FROM `" . TABLE_PANEL_TICKETS . "`
WHERE `status` = '3' AND `answerto` = '0';" WHERE `status` = '3' AND `answerto` = '0';"
@@ -35,7 +35,7 @@ while ($row_ticket = $result_tickets_stmt->fetch(PDO::FETCH_ASSOC)) {
if ($days >= Settings::Get('ticket.archiving_days')) { if ($days >= Settings::Get('ticket.archiving_days')) {
fwrite($debugHandler, 'archiving ticket "' . $row_ticket['subject'] . '" (ID #' . $row_ticket['id'] . ')' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'archiving ticket "' . $row_ticket['subject'] . '" (ID #' . $row_ticket['id'] . ')');
$mainticket = ticket::getInstanceOf(null, (int)$row_ticket['id']); $mainticket = ticket::getInstanceOf(null, (int)$row_ticket['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);
@@ -46,7 +46,7 @@ while ($row_ticket = $result_tickets_stmt->fetch(PDO::FETCH_ASSOC)) {
} }
} }
fwrite($debugHandler, 'Archived ' . $archiving_count . ' tickets' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Archived ' . $archiving_count . ' tickets');
Database::query(" Database::query("
UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = UNIX_TIMESTAMP() UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = UNIX_TIMESTAMP()
WHERE `settinggroup` = 'system' AND `varname` = 'last_archive_run'" WHERE `settinggroup` = 'system' AND `varname` = 'last_archive_run'"

View File

@@ -30,7 +30,7 @@ if (function_exists('pcntl_fork')) {
$TrafficPidStatus = $TrafficPidStatus ? false : true; $TrafficPidStatus = $TrafficPidStatus ? false : true;
} }
if ($TrafficPidStatus) { if ($TrafficPidStatus) {
fwrite($debugHandler,"Traffic Run already in progress\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Traffic Run already in progress');
return 1; return 1;
} }
} }
@@ -49,7 +49,6 @@ if (function_exists('pcntl_fork')) {
elseif ($TrafficPid == 0) { elseif ($TrafficPid == 0) {
posix_setsid(); posix_setsid();
fclose($debugHandler); fclose($debugHandler);
$debugHandler = fopen("/tmp/froxlor_traffic.log", "w");
// re-create db // re-create db
Database::needRoot(false); Database::needRoot(false);
} }
@@ -64,7 +63,7 @@ if (function_exists('pcntl_fork')) {
} else { } else {
$msg = "PHP compiled without pcntl."; $msg = "PHP compiled without pcntl.";
} }
fwrite($debugHandler, $msg." Not forking traffic-cron, this may take a long time!"); $cronlog->logAction(CRON_ACTION, LOG_INFO, $msg." Not forking traffic-cron, this may take a long time!");
} }
require_once makeCorrectFile(dirname(__FILE__) . '/cron_traffic.inc.functions.php'); require_once makeCorrectFile(dirname(__FILE__) . '/cron_traffic.inc.functions.php');
@@ -72,7 +71,7 @@ require_once makeCorrectFile(dirname(__FILE__) . '/cron_traffic.inc.functions.ph
/** /**
* TRAFFIC AND DISKUSAGE MESSURE * TRAFFIC AND DISKUSAGE MESSURE
*/ */
fwrite($debugHandler, 'Traffic run started...' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Traffic run started...');
$admin_traffic = array(); $admin_traffic = array();
$domainlist = array(); $domainlist = array();
$speciallogfile_domainlist = array(); $speciallogfile_domainlist = array();
@@ -164,7 +163,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
/** /**
* HTTP-Traffic * HTTP-Traffic
*/ */
fwrite($debugHandler, 'http traffic for ' . $row['loginname'] . ' started...' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'http traffic for ' . $row['loginname'] . ' started...');
$httptraffic = 0; $httptraffic = 0;
if (isset($domainlist[$row['customerid']]) if (isset($domainlist[$row['customerid']])
@@ -225,7 +224,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
/** /**
* FTP-Traffic * FTP-Traffic
*/ */
fwrite($debugHandler, 'ftp traffic for ' . $row['loginname'] . ' started...' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'ftp traffic for ' . $row['loginname'] . ' started...');
$ftptraffic_stmt = Database::prepare(" $ftptraffic_stmt = Database::prepare("
SELECT SUM(`up_bytes`) AS `up_bytes_sum`, SUM(`down_bytes`) AS `down_bytes_sum` SELECT SUM(`up_bytes`) AS `up_bytes_sum`, SUM(`down_bytes`) AS `down_bytes_sum`
FROM `" . TABLE_FTP_USERS . "` WHERE `customerid` = :customerid FROM `" . TABLE_FTP_USERS . "` WHERE `customerid` = :customerid
@@ -249,7 +248,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
*/ */
$mailtraffic = 0; $mailtraffic = 0;
if (Settings::Get("system.mailtraffic_enabled")) { if (Settings::Get("system.mailtraffic_enabled")) {
fwrite($debugHandler, 'mail traffic usage for ' . $row['loginname'] . " started...\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'mail traffic usage for ' . $row['loginname'] . " started...");
$currentDate = date("Y-m-d"); $currentDate = date("Y-m-d");
@@ -294,7 +293,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
/** /**
* Total Traffic * Total Traffic
*/ */
fwrite($debugHandler, 'total traffic for ' . $row['loginname'] . ' started' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'total traffic for ' . $row['loginname'] . ' started');
$current_traffic = array(); $current_traffic = array();
$current_traffic['http'] = floatval($httptraffic); $current_traffic['http'] = floatval($httptraffic);
$current_traffic['ftp_up'] = floatval(($ftptraffic['up_bytes_sum'] / 1024)); $current_traffic['ftp_up'] = floatval(($ftptraffic['up_bytes_sum'] / 1024));
@@ -355,7 +354,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
/** /**
* WebSpace-Usage * WebSpace-Usage
*/ */
fwrite($debugHandler, 'calculating webspace usage for ' . $row['loginname'] . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'calculating webspace usage for ' . $row['loginname']);
$webspaceusage = 0; $webspaceusage = 0;
// Using repquota, it's faster using this tool than using du traversing the complete directory // Using repquota, it's faster using this tool than using du traversing the complete directory
@@ -381,14 +380,14 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
unset($back); unset($back);
} else { } else {
fwrite($debugHandler, 'documentroot ' . $row['documentroot'] . ' does not exist' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_WARNING, 'documentroot ' . $row['documentroot'] . ' does not exist');
} }
} }
/** /**
* MailSpace-Usage * MailSpace-Usage
*/ */
fwrite($debugHandler, 'calculating mailspace usage for ' . $row['loginname'] . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'calculating mailspace usage for ' . $row['loginname']);
$emailusage = 0; $emailusage = 0;
$maildir = makeCorrectDir(Settings::Get('system.vmail_homedir') . $row['loginname']); $maildir = makeCorrectDir(Settings::Get('system.vmail_homedir') . $row['loginname']);
@@ -402,13 +401,13 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
unset($back); unset($back);
} else { } else {
fwrite($debugHandler, 'maildir ' . $maildir . ' does not exist' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_WARNING, 'maildir ' . $maildir . ' does not exist');
} }
/** /**
* MySQLSpace-Usage * MySQLSpace-Usage
*/ */
fwrite($debugHandler, 'calculating mysqlspace usage for ' . $row['loginname'] . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'calculating mysqlspace usage for ' . $row['loginname']);
$mysqlusage = 0; $mysqlusage = 0;
if (isset($mysqlusage_all[$row['customerid']])) { if (isset($mysqlusage_all[$row['customerid']])) {

View File

@@ -17,7 +17,7 @@
* *
*/ */
fwrite($debugHandler, 'Web- and Traffic-usage reporting started...' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Web- and Traffic-usage reporting started...');
$yesterday = time() - (60 * 60 * 24); $yesterday = time() - (60 * 60 * 24);
/** /**

View File

@@ -20,6 +20,5 @@
/** /**
* RESET USED TICKETS COUNTER * RESET USED TICKETS COUNTER
*/ */
fwrite($debugHandler, 'Resetting customers used ticket counter' . "\n");
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Resetting customers used ticket counter"); $cronlog->logAction(CRON_ACTION, LOG_INFO, "Resetting customers used ticket counter");
Database::query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `tickets_used` = '0'"); Database::query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `tickets_used` = '0'");