diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql index 1934cd8957448053990a71608cd24440bba69ba6..f2f497ae10ff4acda8670daa61d788263d7ff4e0 100644 --- a/install/sql/ispconfig3.sql +++ b/install/sql/ispconfig3.sql @@ -1986,6 +1986,7 @@ CREATE TABLE `web_domain` ( `http_port` int(11) unsigned NOT NULL DEFAULT '80', `https_port` int(11) unsigned NOT NULL DEFAULT '443', `folder_directive_snippets` text, + `log_retention` int(11) NOT NULL DEFAULT '30', PRIMARY KEY (`domain_id`), UNIQUE KEY `serverdomain` ( `server_id` , `ip_address`, `domain` ) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; diff --git a/interface/web/sites/form/web_vhost_domain.tform.php b/interface/web/sites/form/web_vhost_domain.tform.php index 923e73b2b041d44c22b62a1c190196a6703a7823..10f08f643dbd8c4b53a0b890e3dc5a99b8a544ee 100644 --- a/interface/web/sites/form/web_vhost_domain.tform.php +++ b/interface/web/sites/form/web_vhost_domain.tform.php @@ -917,7 +917,19 @@ if($_SESSION["s"]["user"]["typ"] == 'admin' 'value' => '', 'width' => '3', 'maxlength' => '6' - ) + ), + 'log_retention' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^([0-9]{1,5})$/', + 'errmsg'=> 'log_retention_error_regex'), + ), + 'default' => '30', + 'value' => '', + 'width' => '4', + 'maxlength' => '6' + ) //################################# // ENDE Datatable fields //################################# diff --git a/interface/web/sites/lib/lang/de_web_domain.lng b/interface/web/sites/lib/lang/de_web_domain.lng index 75a4f146695d49aa69b729de85343c6aa0b346c5..c2d8ff9020757aea56280b3628a0bd984a0b9d30 100644 --- a/interface/web/sites/lib/lang/de_web_domain.lng +++ b/interface/web/sites/lib/lang/de_web_domain.lng @@ -133,4 +133,6 @@ $wb['http_port_txt'] = 'HTTP Port'; $wb['https_port_txt'] = 'HTTPS Port'; $wb['http_port_error_regex'] = 'HTTP Port invalid.'; $wb['https_port_error_regex'] = 'HTTPS Port invalid.'; +$wb['log_retention_txt'] = 'Log-Datei Aufbewahrungszeit'; +$wb['log_retention_error_regex'] = 'Nur Nummern von 0-9999 zulässig.' ?> diff --git a/interface/web/sites/lib/lang/de_web_vhost_domain.lng b/interface/web/sites/lib/lang/de_web_vhost_domain.lng index 5a732471891043a43cef47650b8947ca9eb4c1d9..f7b006342569b860dba212b6381a7f786e8e97b5 100644 --- a/interface/web/sites/lib/lang/de_web_vhost_domain.lng +++ b/interface/web/sites/lib/lang/de_web_vhost_domain.lng @@ -148,4 +148,6 @@ $wb['https_port_txt'] = 'HTTPS Port'; $wb['http_port_error_regex'] = 'HTTP Port invalid.'; $wb['https_port_error_regex'] = 'HTTPS Port invalid.'; $wb['enable_pagespeed_txt'] = 'Enable PageSpeed'; +$wb['log_retention_txt'] = 'Log-Datei Aufbewahrungszeit'; +$wb['log_retention_error_regex'] = 'Nur Nummern von 0-9999 zulässig.' ?> diff --git a/interface/web/sites/templates/web_vhost_domain_advanced.htm b/interface/web/sites/templates/web_vhost_domain_advanced.htm index 2ef8c7daf47d95db61f38b1e6771cdd2cb572b98..7ca4710f404328e6e0b857f87ad7d766120efab1 100644 --- a/interface/web/sites/templates/web_vhost_domain_advanced.htm +++ b/interface/web/sites/templates/web_vhost_domain_advanced.htm @@ -35,6 +35,10 @@ +
+ +
+
diff --git a/server/lib/classes/cron.d/200-logfiles.inc.php b/server/lib/classes/cron.d/200-logfiles.inc.php index 98dd662f696f636e6e33a217e39ba19894284fc2..035a084e37990bb03b17e7dff993133028c98ba8 100644 --- a/server/lib/classes/cron.d/200-logfiles.inc.php +++ b/server/lib/classes/cron.d/200-logfiles.inc.php @@ -60,7 +60,7 @@ class cronjob_logfiles extends cronjob { // Manage and compress web logfiles and create traffic statistics //###################################################################################################### - $sql = "SELECT domain_id, domain, type, document_root, web_folder, parent_domain_id FROM web_domain WHERE (type = 'vhost' or type = 'vhostsubdomain' or type = 'vhostalias') AND server_id = ?"; + $sql = "SELECT domain_id, domain, type, document_root, web_folder, parent_domain_id, log_retention FROM web_domain WHERE (type = 'vhost' or type = 'vhostsubdomain' or type = 'vhostalias') AND server_id = ?"; $records = $app->db->queryAllRecords($sql, $conf['server_id']); foreach($records as $rec) { @@ -76,6 +76,8 @@ class cronjob_logfiles extends cronjob { unset($tmp); } + $log_retention = $rec['log_retention']; + $logfile = $rec['document_root'].'/' . $log_folder . '/'.$yesterday.'-access.log'; $total_bytes = 0; @@ -142,21 +144,25 @@ class cronjob_logfiles extends cronjob { exec("cat /dev/null > $logfile"); } - // delete logfiles after 30 days - $month_ago = date('Ymd', time() - 86400 * 30); + // delete logfiles after x days (default 30) + if($log_retention > 0) { + $month_ago = date('Ymd', time() - 86400 * $log_retention); $logfile = escapeshellcmd($rec['document_root'].'/' . $log_folder . '/'.$month_ago.'-access.log.gz'); if(@is_file($logfile)) { unlink($logfile); } + } //* Delete older Log files, in case that we missed them before due to serverdowntimes. - $datepart = date('Ym', time() - 86400 * 31 * 2); + if($log_retention > 0) { + $datepart = date('Ym', time() - 86400 * $log_retention+1 * 2); $logfile = escapeshellcmd($rec['document_root']).'/' . $log_folder . '/'.$datepart.'*-access.log.gz'; exec('rm -f '.$logfile); $logfile = escapeshellcmd($rec['document_root']).'/' . $log_folder . '/'.$datepart.'*-access.log'; exec('rm -f '.$logfile); + } } //* Delete old logfiles in /var/log/ispconfig/httpd/ that were created by vlogger for the hostname of the server