diff --git a/scripts/jobs/cron_mailboxsize.php b/scripts/jobs/cron_mailboxsize.php index 201dfa9f..abd9156b 100644 --- a/scripts/jobs/cron_mailboxsize.php +++ b/scripts/jobs/cron_mailboxsize.php @@ -18,7 +18,7 @@ * */ -fwrite($debugHandler, "calculating mailspace usage\n"); +$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'calculating mailspace usage'); $maildirs_stmt = Database::query(" 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); Database::pexecute($upd_stmt, array('size' => $emailusage, 'id' => $maildir['id'])); } else { - fwrite($debugHandler, 'maildir ' . $_maildir . ' does not exist' . "\n"); + $cronlog->logAction(CRON_ACTION, LOG_WARNING, 'maildir ' . $_maildir . ' does not exist'); } } diff --git a/scripts/jobs/cron_tasks.inc.dns.10.bind.php b/scripts/jobs/cron_tasks.inc.dns.10.bind.php index f97e567b..a3ee6139 100644 --- a/scripts/jobs/cron_tasks.inc.dns.10.bind.php +++ b/scripts/jobs/cron_tasks.inc.dns.10.bind.php @@ -67,7 +67,6 @@ class bind { 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'); if (!file_exists(makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/'))) { @@ -130,22 +129,20 @@ class bind { } } - fwrite($this->debugHandler, + $this->logger->logAction(CRON_ACTION, LOG_DEBUG, str_pad('domId', 9, ' ') . str_pad('domain', 40, ' ') . 'ismainbutsubto ' . str_pad('parent domain', 40, ' ') . - "list of child domain ids\n"); + "list of child domain ids"); foreach ($domains as $domain) { - fwrite($this->debugHandler, + $logLine = str_pad($domain['id'], 9, ' ') . str_pad($domain['domain'], 40, ' ') . str_pad($domain['ismainbutsubto'], 15, ' ') . str_pad(((isset($domains[ $domain['ismainbutsubto'] ])) ? $domains[ $domain['ismainbutsubto'] ]['domain'] : - '-'), 40, ' ')); - foreach ($domain['children'] as $child) { - fwrite($this->debugHandler, '$child, '); - } - fwrite($this->debugHandler, "\n"); + '-'), 40, ' ') . + join(', ', $domain['children']); + $this->logger->logAction(CRON_ACTION, LOG_DEBUG, $logLine); } foreach ($domains as $domain) { @@ -159,10 +156,8 @@ class bind { $bindconf_file_handler = fopen(makeCorrectFile(Settings::Get('system.bindconf_directory') . '/froxlor_bind.conf'), 'w'); fwrite($bindconf_file_handler, $this->_bindconf_file); 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'); 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'); $domains_dir = makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/'); @@ -178,12 +173,12 @@ class bind { && !in_array($domain_filename, $this->_known_filenames) && is_file($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); unlink(makeCorrectFile($domains_dir . '/' . $domain_filename)); } } } + $this->logger->logAction(CRON_ACTION, LOG_INFO, 'Task4 finished'); } private function walkDomainList($domain, $domains) { @@ -202,7 +197,7 @@ class bind { $zonefile_handler = fopen($zonefile_name, 'w'); fwrite($zonefile_handler, $zonefile.$subzones); 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 { return $this->generateZone($domain); } @@ -600,7 +595,6 @@ class bind { fclose($dkimkeys_file_handler); 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'); } } diff --git a/scripts/jobs/cron_tasks.inc.http.10.apache.php b/scripts/jobs/cron_tasks.inc.http.10.apache.php index 6dce1c8e..0fb41d3b 100644 --- a/scripts/jobs/cron_tasks.inc.http.10.apache.php +++ b/scripts/jobs/cron_tasks.inc.http.10.apache.php @@ -49,12 +49,10 @@ class apache extends HttpConfigBase { public function reload() { if ((int)Settings::Get('phpfpm.enabled') == 1) { - fwrite($this->debugHandler, ' apache::reload: reloading php-fpm' . "\n"); - $this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading php-fpm'); + $this->logger->logAction(CRON_ACTION, LOG_INFO, 'apache::reload: reloading php-fpm'); safe_exec(escapeshellcmd(Settings::Get('phpfpm.reload'))); } - fwrite($this->debugHandler, ' apache::reload: reloading apache' . "\n"); - $this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading apache'); + $this->logger->logAction(CRON_ACTION, LOG_INFO, 'apache::reload: reloading apache'); safe_exec(escapeshellcmd(Settings::Get('system.apachereload_command'))); } @@ -76,8 +74,7 @@ class apache extends HttpConfigBase { ) { // if we use fcgid or php-fpm we don't need this file if (file_exists($vhosts_filename)) { - fwrite($this->debugHandler, ' apache::_createStandardDirectoryEntry: unlinking ' . basename($vhosts_filename) . "\n"); - $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'unlinking ' . basename($vhosts_filename)); + $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'apache::_createStandardDirectoryEntry: unlinking ' . basename($vhosts_filename)); unlink(makeCorrectFile($vhosts_filename)); } } else { @@ -147,8 +144,7 @@ class apache extends HttpConfigBase { $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, 'creating ip/port settings for ' . $ipport); + $this->logger->logAction(CRON_ACTION, LOG_INFO, 'apache::createIpPort: 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'); if (!isset($this->virtualhosts_data[$vhosts_filename])) { @@ -895,8 +891,7 @@ class apache extends HttpConfigBase { $domains = WebserverBase::getVhostsToCreate(); 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, 'creating vhost container for domain ' . $domain['id'] . ', customer ' . $domain['loginname']); + $this->logger->logAction(CRON_ACTION, LOG_INFO, 'apache::createVirtualHosts: creating vhost container for domain ' . $domain['id'] . ', customer ' . $domain['loginname']); $vhosts_filename = $this->getVhostFilename($domain); // Apply header @@ -995,7 +990,7 @@ class apache extends HttpConfigBase { } else { $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']) @@ -1012,7 +1007,7 @@ class apache extends HttpConfigBase { } else { $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'); @@ -1048,7 +1043,7 @@ class apache extends HttpConfigBase { $this->diroptions_data[$diroptions_filename] .= ' Order allow,deny' . "\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 if ((int)Settings::Get('perl.suexecworkaround') == 1) { @@ -1116,8 +1111,7 @@ class apache extends HttpConfigBase { */ public function writeConfigs() { // Write diroptions - fwrite($this->debugHandler, ' apache::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_diroptions') . "\n"); - $this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_diroptions')); + $this->logger->logAction(CRON_ACTION, LOG_INFO, "apache::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_diroptions')); if (count($this->diroptions_data) > 0) { $optsDir = new frxDirectory(Settings::Get('system.apacheconf_diroptions')); @@ -1138,8 +1132,7 @@ class apache extends HttpConfigBase { fclose($diroptions_file_handler); } else { 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, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_diroptions')))); + $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'apache::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_diroptions')))); safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_diroptions')))); } @@ -1157,8 +1150,7 @@ class apache extends HttpConfigBase { } // Write htpasswds - fwrite($this->debugHandler, ' apache::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_htpasswddir') . "\n"); - $this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_htpasswddir')); + $this->logger->logAction(CRON_ACTION, LOG_INFO, "apache::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_htpasswddir')); if (count($this->htpasswds_data) > 0) { if (!file_exists(Settings::Get('system.apacheconf_htpasswddir'))) { @@ -1177,15 +1169,12 @@ class apache extends HttpConfigBase { fclose($htpasswd_file_handler); } } 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!!!'); } } // Write virtualhosts - fwrite($this->debugHandler, ' apache::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_vhost') . "\n"); - $this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_vhost')); + $this->logger->logAction(CRON_ACTION, LOG_INFO, "apache::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_vhost')); if (count($this->virtualhosts_data) > 0) { $vhostDir = new frxDirectory(Settings::Get('system.apacheconf_vhost')); @@ -1218,8 +1207,7 @@ class apache extends HttpConfigBase { fclose($vhosts_file_handler); } else { 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, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost')))); + $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'apache::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost')))); safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost')))); } diff --git a/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php b/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php index 9d76b428..6606f841 100644 --- a/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php +++ b/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php @@ -49,12 +49,10 @@ class lighttpd extends HttpConfigBase { public function reload() { if ((int)Settings::Get('phpfpm.enabled') == 1) { - fwrite($this->debugHandler, ' lighttpd::reload: reloading php-fpm' . "\n"); - $this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading php-fpm'); + $this->logger->logAction(CRON_ACTION, LOG_INFO, 'lighttpd::reload: reloading php-fpm'); safe_exec(escapeshellcmd(Settings::Get('phpfpm.reload'))); } - fwrite($this->debugHandler, ' lighttpd::reload: reloading lighttpd' . "\n"); - $this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading lighttpd'); + $this->logger->logAction(CRON_ACTION, LOG_INFO, 'lighttpd::reload: reloading lighttpd'); safe_exec(escapeshellcmd(Settings::Get('system.apachereload_command'))); } @@ -73,8 +71,7 @@ class lighttpd extends HttpConfigBase { $ipv6 = ''; } - fwrite($this->debugHandler, ' lighttpd::createIpPort: creating ip/port settings for ' . $ip . ":" . $port . "\n"); - $this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating ip/port settings for ' . $ip . ":" . $port); + $this->logger->logAction(CRON_ACTION, LOG_INFO, 'lighttpd::createIpPort: 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'); if (!isset($this->lighttpd_data[$vhost_filename])) { @@ -861,8 +858,7 @@ class lighttpd extends HttpConfigBase { public function writeConfigs() { - fwrite($this->debugHandler, ' lighttpd::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_vhost') . "\n"); - $this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_vhost')); + $this->logger->logAction(CRON_ACTION, LOG_INFO, "lighttpd::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_vhost')); $vhostDir = new frxDirectory(Settings::Get('system.apacheconf_vhost')); if (!$vhostDir->isConfigDir()) { @@ -889,8 +885,7 @@ class lighttpd extends HttpConfigBase { fclose($vhosts_file_handler); } else { 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, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost')))); + $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'lighttpd::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost')))); safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost')))); } diff --git a/scripts/jobs/cron_tasks.inc.http.30.nginx.php b/scripts/jobs/cron_tasks.inc.http.30.nginx.php index 4f3cf4d1..ae962835 100644 --- a/scripts/jobs/cron_tasks.inc.http.30.nginx.php +++ b/scripts/jobs/cron_tasks.inc.http.30.nginx.php @@ -49,8 +49,7 @@ class nginx extends HttpConfigBase { public function reload() { - fwrite($this->debugHandler, ' nginx::reload: reloading nginx' . "\n"); - $this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading nginx'); + $this->logger->logAction(CRON_ACTION, LOG_INFO, 'nginx::reload: reloading nginx'); safe_exec(Settings::Get('system.apachereload_command')); /** @@ -59,12 +58,10 @@ class nginx extends HttpConfigBase { if (Settings::Get('system.phpreload_command') != '' && (int)Settings::Get('phpfpm.enabled') == 0 ) { - fwrite($this->debugHandler, ' nginx::reload: restarting php processes' . "\n"); - $this->logger->logAction(CRON_ACTION, LOG_INFO, 'restarting php processes'); + $this->logger->logAction(CRON_ACTION, LOG_INFO, 'nginx::reload: restarting php processes'); safe_exec(Settings::Get('system.phpreload_command')); } elseif ((int)Settings::Get('phpfpm.enabled') == 1) { - fwrite($this->debugHandler, ' nginx::reload: reloading php-fpm' . "\n"); - $this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading php-fpm'); + $this->logger->logAction(CRON_ACTION, LOG_INFO, 'nginx::reload: reloading php-fpm'); safe_exec(escapeshellcmd(Settings::Get('phpfpm.reload'))); } } @@ -128,8 +125,7 @@ class nginx extends HttpConfigBase { } $port = $row_ipsandports['port']; - fwrite($this->debugHandler, ' nginx::createIpPort: creating ip/port settings for ' . $ip . ":" . $port . "\n"); - $this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating ip/port settings for ' . $ip . ":" . $port); + $this->logger->logAction(CRON_ACTION, LOG_INFO, 'nginx::createIpPort: 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'); if (!isset($this->nginx_data[$vhost_filename])) { @@ -1002,8 +998,7 @@ class nginx extends HttpConfigBase { public function writeConfigs() { - fwrite($this->debugHandler, ' nginx::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_vhost') . "\n"); - $this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_vhost')); + $this->logger->logAction(CRON_ACTION, LOG_INFO, "nginx::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_vhost')); $vhostDir = new frxDirectory(Settings::Get('system.apacheconf_vhost')); if (!$vhostDir->isConfigDir()) { @@ -1029,8 +1024,7 @@ class nginx extends HttpConfigBase { fclose($vhosts_file_handler); } else { 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, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost')))); + $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'nginx::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost')))); safe_exec('mkdir -p ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost')))); } @@ -1058,8 +1052,6 @@ class nginx extends HttpConfigBase { mkdir(Settings::Get('system.apacheconf_htpasswddir'), 0751); umask($umask); } 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!!!'); } diff --git a/scripts/jobs/cron_tasks.php b/scripts/jobs/cron_tasks.php index 8d5abaf7..ba7a7876 100644 --- a/scripts/jobs/cron_tasks.php +++ b/scripts/jobs/cron_tasks.php @@ -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 */ -fwrite($debugHandler, ' cron_tasks: Searching for tasks to do' . "\n"); -$cronlog->logAction(CRON_ACTION, LOG_INFO, "Searching for tasks to do"); +$cronlog->logAction(CRON_ACTION, LOG_INFO, "cron_tasks: Searching for tasks to do"); $result_tasks_stmt = Database::query(" SELECT `id`, `type`, `data` FROM `" . TABLE_PANEL_TASKS . "` WHERE `type` <> '99' ORDER BY `id` ASC "); @@ -112,8 +111,7 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) { * TYPE=2 MEANS TO CREATE A NEW HOME AND CHOWN */ elseif ($row['type'] == '2') { - fwrite($debugHandler, ' cron_tasks: Task2 started - create new home' . "\n"); - $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task2 started - create new home'); + $cronlog->logAction(CRON_ACTION, LOG_INFO, 'cron_tasks: Task2 started - create new home'); if (is_array($row['data'])) { // define paths @@ -201,8 +199,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 */ elseif ($row['type'] == '6') { - fwrite($debugHandler, ' cron_tasks: Task6 started - deleting customer data' . "\n"); - $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task6 started - deleting customer data'); + $cronlog->logAction(CRON_ACTION, LOG_INFO, 'cron_tasks: Task6 started - deleting customer data'); if (is_array($row['data'])) { if (isset($row['data']['loginname'])) { @@ -268,8 +265,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 */ elseif ($row['type'] == '7') { - fwrite($debugHandler, ' cron_tasks: Task7 started - deleting customer e-mail data' . "\n"); - $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task7 started - deleting customer e-mail data'); + $cronlog->logAction(CRON_ACTION, LOG_INFO, 'cron_tasks: Task7 started - deleting customer e-mail data'); if (is_array($row['data'])) { @@ -334,8 +330,7 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) { * refs #293 */ elseif ($row['type'] == '8') { - fwrite($debugHandler, ' cron_tasks: Task8 started - deleting customer ftp homedir' . "\n"); - $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task8 started - deleting customer ftp homedir'); + $cronlog->logAction(CRON_ACTION, LOG_INFO, 'cron_tasks: Task8 started - deleting customer ftp homedir'); if (is_array($row['data'])) { @@ -363,8 +358,7 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) { */ 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, 'Task10 started - setting filesystem quota'); + $cronlog->logAction(CRON_ACTION, LOG_INFO, 'cron_tasks: Task10 started - setting filesystem quota'); $usedquota = getFilesystemQuota(); diff --git a/scripts/jobs/cron_ticketarchive.php b/scripts/jobs/cron_ticketarchive.php index d7ab7d42..8febe3ad 100644 --- a/scripts/jobs/cron_ticketarchive.php +++ b/scripts/jobs/cron_ticketarchive.php @@ -20,7 +20,7 @@ /** * 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(" SELECT `id`, `lastchange`, `subject` FROM `" . TABLE_PANEL_TICKETS . "` 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')) { - 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->Set('lastchange', $now, 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(" UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = UNIX_TIMESTAMP() WHERE `settinggroup` = 'system' AND `varname` = 'last_archive_run'" diff --git a/scripts/jobs/cron_traffic.php b/scripts/jobs/cron_traffic.php index 5d141ebc..4477fab9 100644 --- a/scripts/jobs/cron_traffic.php +++ b/scripts/jobs/cron_traffic.php @@ -30,7 +30,7 @@ if (function_exists('pcntl_fork')) { $TrafficPidStatus = $TrafficPidStatus ? false : true; } if ($TrafficPidStatus) { - fwrite($debugHandler,"Traffic Run already in progress\n"); + $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Traffic Run already in progress'); return 1; } } @@ -49,7 +49,6 @@ if (function_exists('pcntl_fork')) { elseif ($TrafficPid == 0) { posix_setsid(); fclose($debugHandler); - $debugHandler = fopen("/tmp/froxlor_traffic.log", "w"); // re-create db Database::needRoot(false); } @@ -64,7 +63,7 @@ if (function_exists('pcntl_fork')) { } else { $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'); @@ -72,7 +71,7 @@ require_once makeCorrectFile(dirname(__FILE__) . '/cron_traffic.inc.functions.ph /** * TRAFFIC AND DISKUSAGE MESSURE */ -fwrite($debugHandler, 'Traffic run started...' . "\n"); +$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Traffic run started...'); $admin_traffic = array(); $domainlist = array(); $speciallogfile_domainlist = array(); @@ -164,7 +163,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { /** * 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; if (isset($domainlist[$row['customerid']]) @@ -225,7 +224,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { /** * 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(" SELECT SUM(`up_bytes`) AS `up_bytes_sum`, SUM(`down_bytes`) AS `down_bytes_sum` FROM `" . TABLE_FTP_USERS . "` WHERE `customerid` = :customerid @@ -249,7 +248,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { */ $mailtraffic = 0; 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"); @@ -294,7 +293,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { /** * 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['http'] = floatval($httptraffic); $current_traffic['ftp_up'] = floatval(($ftptraffic['up_bytes_sum'] / 1024)); @@ -355,7 +354,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { /** * 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; // 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); } else { - fwrite($debugHandler, 'documentroot ' . $row['documentroot'] . ' does not exist' . "\n"); + $cronlog->logAction(CRON_ACTION, LOG_WARNING, 'documentroot ' . $row['documentroot'] . ' does not exist'); } } /** * 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; $maildir = makeCorrectDir(Settings::Get('system.vmail_homedir') . $row['loginname']); @@ -402,13 +401,13 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { unset($back); } else { - fwrite($debugHandler, 'maildir ' . $maildir . ' does not exist' . "\n"); + $cronlog->logAction(CRON_ACTION, LOG_WARNING, 'maildir ' . $maildir . ' does not exist'); } /** * 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; if (isset($mysqlusage_all[$row['customerid']])) { diff --git a/scripts/jobs/cron_usage_report.php b/scripts/jobs/cron_usage_report.php index e6cb3c8b..60d9cc21 100644 --- a/scripts/jobs/cron_usage_report.php +++ b/scripts/jobs/cron_usage_report.php @@ -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); /** diff --git a/scripts/jobs/cron_used_tickets_reset.php b/scripts/jobs/cron_used_tickets_reset.php index 83e28278..9809effa 100644 --- a/scripts/jobs/cron_used_tickets_reset.php +++ b/scripts/jobs/cron_used_tickets_reset.php @@ -20,6 +20,5 @@ /** * RESET USED TICKETS COUNTER */ -fwrite($debugHandler, 'Resetting customers used ticket counter' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, "Resetting customers used ticket counter"); Database::query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `tickets_used` = '0'");