From c5da911b67f8c41a9a0b9bf0fb419e41c63e86af Mon Sep 17 00:00:00 2001
From: benchea dan <30780133+bnchdan@users.noreply.github.com>
Date: Mon, 7 Mar 2022 15:10:47 +0200
Subject: [PATCH 01/37] Create cron
---
cron | 1 +
1 file changed, 1 insertion(+)
create mode 100644 cron
diff --git a/cron b/cron
new file mode 100644
index 00000000..8b137891
--- /dev/null
+++ b/cron
@@ -0,0 +1 @@
+
From aeb1dc61f666bea6f8fcceee2f284e4c3edb627c Mon Sep 17 00:00:00 2001
From: benchea dan <30780133+bnchdan@users.noreply.github.com>
Date: Mon, 7 Mar 2022 15:13:30 +0200
Subject: [PATCH 02/37] Delete cron
---
cron | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 cron
diff --git a/cron b/cron
deleted file mode 100644
index 8b137891..00000000
--- a/cron
+++ /dev/null
@@ -1 +0,0 @@
-
From cbc1c78d58b034aa6c1109c99d8523bb90373e25 Mon Sep 17 00:00:00 2001
From: benchea dan <30780133+bnchdan@users.noreply.github.com>
Date: Mon, 7 Mar 2022 15:13:57 +0200
Subject: [PATCH 03/37] Create postfix_logs.sh
---
cron/postfix_logs.sh | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
create mode 100644 cron/postfix_logs.sh
diff --git a/cron/postfix_logs.sh b/cron/postfix_logs.sh
new file mode 100644
index 00000000..acba89b6
--- /dev/null
+++ b/cron/postfix_logs.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+#check if maillog directory exists
+if [ ! -d ../maillog ]
+then
+ #create direcotry
+ mkdir ../maillog
+fi
+
+
+data=`date --date='1 day ago' +%F`
+
+mysql -u root --skip-column-names --execute="USE postfix; SELECT username,domain FROM domain_admins WHERE active=1 AND domain <> 'ALL';" | while read username domain
+ do
+
+ #check if folder for domain doesn t exists
+ if [ ! -d ../maillog/$domain ]
+ then
+ echo "Directory does not exists for "$domain
+ #create direcotry
+ mkdir ../maillog/$domain
+ fi
+
+ grep @$domain /var/log/mail.log.1 | grep -v "postfix-policyd" | grep -v postgrey > ../maillog/$domain/$data-bulk.log
+ pflogsumm -i --problems_first --detail 5 ../maillog/$domain/$data-bulk.log > ../maillog/$domain/$data-pflogsum.log
+ grep @$domain /var/log/mail.log.1 | grep "Password mismatch" > ../maillog/$domain/$data-failed-auth.log
+
+ gzip ../maillog/$domain/$data-bulk.log
+ gzip ../maillog/$domain/$data-pflogsum.log
+ gzip ../maillog/$domain/$data-failed-auth.log
+ echo $domain
+
+# rm ../maillog/$domain/$data-bulk.log
+# rm ../maillog/$domain/$data-pflogsum.log
+# rm ../maillog/$domain/$data-failed-auth.log
+ done
From 774051fb7e607e5b4fc2c07542d655de3cd4b366 Mon Sep 17 00:00:00 2001
From: benchea dan <30780133+bnchdan@users.noreply.github.com>
Date: Mon, 7 Mar 2022 15:14:48 +0200
Subject: [PATCH 04/37] Create domain_example
---
maillog/domain_example | 1 +
1 file changed, 1 insertion(+)
create mode 100644 maillog/domain_example
diff --git a/maillog/domain_example b/maillog/domain_example
new file mode 100644
index 00000000..8b137891
--- /dev/null
+++ b/maillog/domain_example
@@ -0,0 +1 @@
+
From adb7329c979a0e23ae2e53bb5c62bfec26075591 Mon Sep 17 00:00:00 2001
From: benchea dan <30780133+bnchdan@users.noreply.github.com>
Date: Mon, 7 Mar 2022 15:16:56 +0200
Subject: [PATCH 05/37] Create 2022-03-06-bulk.log.gz
---
maillog/domain/2022-03-06-bulk.log.gz | 1 +
1 file changed, 1 insertion(+)
create mode 100644 maillog/domain/2022-03-06-bulk.log.gz
diff --git a/maillog/domain/2022-03-06-bulk.log.gz b/maillog/domain/2022-03-06-bulk.log.gz
new file mode 100644
index 00000000..33a9488b
--- /dev/null
+++ b/maillog/domain/2022-03-06-bulk.log.gz
@@ -0,0 +1 @@
+example
From 008b4a4ee1084ec181d8dbc3bc8b395ef012ecec Mon Sep 17 00:00:00 2001
From: benchea dan <30780133+bnchdan@users.noreply.github.com>
Date: Mon, 7 Mar 2022 15:17:24 +0200
Subject: [PATCH 06/37] Create 2022-03-06-failed-auth.log.gz
---
maillog/domain/2022-03-06-failed-auth.log.gz | 1 +
1 file changed, 1 insertion(+)
create mode 100644 maillog/domain/2022-03-06-failed-auth.log.gz
diff --git a/maillog/domain/2022-03-06-failed-auth.log.gz b/maillog/domain/2022-03-06-failed-auth.log.gz
new file mode 100644
index 00000000..33a9488b
--- /dev/null
+++ b/maillog/domain/2022-03-06-failed-auth.log.gz
@@ -0,0 +1 @@
+example
From 9a35b0ff14fe23406513d7129a967a15fe3eed26 Mon Sep 17 00:00:00 2001
From: benchea dan <30780133+bnchdan@users.noreply.github.com>
Date: Mon, 7 Mar 2022 15:17:47 +0200
Subject: [PATCH 07/37] Create 2022-03-06-pflogsum.log.gz
---
maillog/domain/2022-03-06-pflogsum.log.gz | 1 +
1 file changed, 1 insertion(+)
create mode 100644 maillog/domain/2022-03-06-pflogsum.log.gz
diff --git a/maillog/domain/2022-03-06-pflogsum.log.gz b/maillog/domain/2022-03-06-pflogsum.log.gz
new file mode 100644
index 00000000..33a9488b
--- /dev/null
+++ b/maillog/domain/2022-03-06-pflogsum.log.gz
@@ -0,0 +1 @@
+example
From 5ccfdc9e904b7dbcec0c5196d4e304bb89361f0c Mon Sep 17 00:00:00 2001
From: benchea dan <30780133+bnchdan@users.noreply.github.com>
Date: Mon, 7 Mar 2022 15:17:55 +0200
Subject: [PATCH 08/37] Delete domain_example
---
maillog/domain_example | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 maillog/domain_example
diff --git a/maillog/domain_example b/maillog/domain_example
deleted file mode 100644
index 8b137891..00000000
--- a/maillog/domain_example
+++ /dev/null
@@ -1 +0,0 @@
-
From 2464e1890b557b32932e549580484776984c8538 Mon Sep 17 00:00:00 2001
From: benchea dan <30780133+bnchdan@users.noreply.github.com>
Date: Mon, 7 Mar 2022 15:19:13 +0200
Subject: [PATCH 09/37] Create mailog.php
---
public/mailog.php | 149 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 149 insertions(+)
create mode 100644 public/mailog.php
diff --git a/public/mailog.php b/public/mailog.php
new file mode 100644
index 00000000..360483e7
--- /dev/null
+++ b/public/mailog.php
@@ -0,0 +1,149 @@
+getAll();
+$smarty = PFASmarty::getInstance();
+
+$PALANG = $CONF['__LANG'];
+
+$SESSID_USERNAME = authentication_get_username();
+if (authentication_has_role('global-admin')) {
+ $list_domains = list_domains();
+} else {
+ $list_domains = list_domains_for_admin($SESSID_USERNAME);
+}
+
+
+/*
+foreach ($list_domains as $domain){
+ echo $domain. ' ';
+}
+*/
+
+$fDomain=$list_domains[0];
+
+if ($_SERVER['REQUEST_METHOD'] == "GET") {
+ if (isset($_GET['fDomain'])) {
+ $fDomain_aux = escape_string($_GET['fDomain']);
+ $flag_fDomain = 0;
+ //check if domain exists
+ if ((is_array($list_domains) and sizeof($list_domains) > 0)) {
+ foreach ($list_domains as $domain) {
+ if ($domain == $fDomain_aux) {
+ $fDomain=$domain;
+ $flag_fDomain=1;
+ break;
+ }
+ }
+ }
+
+ if ($flag_fDomain == 0 ) {
+ die('Unknown domain');
+ }
+
+ if (strpos($fDomain, '/') !== false) {
+ die("Unknown path");
+ }
+
+ //check if file exists
+
+ if (isset($_GET['get_log'])){
+ // remove path from filename
+ if (strpos($_GET['get_log'], '/') !== false) {
+ die("Unknown file");
+ }
+
+
+ $file = '../maillog/'.$fDomain.'/'.$_GET['get_log'];
+
+ if (file_exists($file)) {
+ header('Content-Description: File Transfer');
+ header('Content-Type: application/octet-stream');
+ header('Content-Disposition: attachment; filename='.basename($file));
+ header('Content-Transfer-Encoding: binary');
+ header('Expires: 0');
+ header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
+ header('Pragma: public');
+ header('Content-Length: ' . filesize($file));
+ ob_clean();
+ flush();
+ readfile($file);
+ exit;
+ }else{
+ die("The file does not exists");
+ }
+
+
+ }
+
+ }
+} elseif ($_SERVER['REQUEST_METHOD'] == "POST") {
+ if (isset($_POST['fDomain'])) {
+ $fDomain_aux = escape_string($_POST['fDomain']);
+ $flag_fDomain = 0;
+ if ((is_array($list_domains) and sizeof($list_domains) > 0)) {
+ foreach ($list_domains as $domain) {
+ if ($domain == $fDomain_aux) {
+ $fDomain=$domain;
+ $flag_fDomain=1;
+ break;
+ }
+ }
+ }
+
+ if ($flag_fDomain == 0 ) {
+ die('Unknown domain');
+ }
+
+ if (strpos($fDomain, '/') !== false) {
+ die("Unknown domain");
+ }
+
+
+ }
+} else {
+ die('Unknown request method');
+}
+
+
+$path = '../maillog/'.$fDomain;
+
+//check if folder exists
+$log_list='';
+$log_size_list=array();
+if (file_exists($path)){
+ //read logs from path
+ $logs=scandir($path);
+ //remove . and .. from result
+ $log_list = array_diff( $logs,array('.', '..') );
+
+ $i=0;
+ foreach ($log_list as $log){
+ $log_size_list[$i++] = round ( filesize($path.'/'.$log)/ 1024, 3);
+ }
+}
+
+
+
+$smarty->assign("domain_list", $list_domains);
+$smarty->assign('domain_selected', $fDomain);
+
+$smarty->assign('log_list', $log_list);
+$smarty->assign('log_size_list', $log_size_list);
+
+
+$smarty->assign('smarty_template', 'maillog');
+$smarty->display('index.tpl');
+
+
+
+
+?>
From 3d95ba776b8bb08c4049933d12d9ac44ffa5c21d Mon Sep 17 00:00:00 2001
From: benchea dan <30780133+bnchdan@users.noreply.github.com>
Date: Mon, 7 Mar 2022 15:20:23 +0200
Subject: [PATCH 10/37] Create maillog.tpl
---
templates/maillog.tpl | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
create mode 100644 templates/maillog.tpl
diff --git a/templates/maillog.tpl b/templates/maillog.tpl
new file mode 100644
index 00000000..f6452e49
--- /dev/null
+++ b/templates/maillog.tpl
@@ -0,0 +1,43 @@
+
+
+
+
+
+ {if !$log_list}
+ No logs found for {$domain_selected}!
+ {else}
+
+ {assign var=i value=0}
+ {assign var=logNumber value=1}
+ {foreach from=$log_list item=log}
+
+
+ {$logNumber}
+
+
+
+ {$log}
+
+
+ {$log_size_list[$i]}
+
+
+
+ Download
+
+ {assign var=logNumber value=$logNumber+1}
+ {assign var=i value=$i+1}
+
+ {/foreach}
+ {/if}
+
+
+
From a72a7be5701e0bc9e342287591dce82ced262692 Mon Sep 17 00:00:00 2001
From: benchea dan <30780133+bnchdan@users.noreply.github.com>
Date: Mon, 7 Mar 2022 15:20:51 +0200
Subject: [PATCH 11/37] Rename mailog.php to maillog.php
---
public/{mailog.php => maillog.php} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename public/{mailog.php => maillog.php} (100%)
diff --git a/public/mailog.php b/public/maillog.php
similarity index 100%
rename from public/mailog.php
rename to public/maillog.php
From bb8a1bc6a089903548f6a6e9bfd0fa6b7357a0a6 Mon Sep 17 00:00:00 2001
From: benchea dan <30780133+bnchdan@users.noreply.github.com>
Date: Mon, 7 Mar 2022 15:22:01 +0200
Subject: [PATCH 12/37] Update menu.tpl
---
templates/menu.tpl | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/templates/menu.tpl b/templates/menu.tpl
index 6e8d8bd3..56761af9 100644
--- a/templates/menu.tpl
+++ b/templates/menu.tpl
@@ -114,6 +114,12 @@
{$PALANG.pAdminMenu_backup}
{/if}
+ {* maillog *}
+ {* to do - add to palang *}
+ {if $CONF.maillogging==='YES'}
+ Mail Log
+ {/if}
{* viewlog *}
{if $CONF.logging==='YES'}
Date: Mon, 7 Mar 2022 15:23:28 +0200
Subject: [PATCH 13/37] Update config.inc.php
---
config.inc.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/config.inc.php b/config.inc.php
index e4c63286..ab7e2137 100644
--- a/config.inc.php
+++ b/config.inc.php
@@ -479,6 +479,10 @@ $CONF['sendmail'] = 'YES';
// send mails to their users
$CONF['sendmail_all_admins'] = 'NO';
+// Mail Logging
+// If you don't want mail logging set this to 'NO';
+$CONF['maillogging'] = 'YES';
+
// Logging
// If you don't want logging set this to 'NO';
$CONF['logging'] = 'YES';
From 866090899a0338d7d3ea61b4707cd3f6c1ac5fda Mon Sep 17 00:00:00 2001
From: benchea dan <30780133+bnchdan@users.noreply.github.com>
Date: Mon, 7 Mar 2022 15:24:37 +0200
Subject: [PATCH 14/37] Update menu.conf
---
configs/menu.conf | 2 ++
1 file changed, 2 insertions(+)
diff --git a/configs/menu.conf b/configs/menu.conf
index 55ae6b91..6d279292 100644
--- a/configs/menu.conf
+++ b/configs/menu.conf
@@ -21,6 +21,8 @@ url_broadcast_message = broadcast-message.php
url_password = edit.php?table=adminpassword
# backup
url_backup = backup.php
+# maillog
+url_maillog = maillog.php
# viewlog
url_viewlog = viewlog.php
# logout
From 23b7e1bbed6e197f38c36c2cef4bc65669813ce0 Mon Sep 17 00:00:00 2001
From: benchea dan <30780133+bnchdan@users.noreply.github.com>
Date: Tue, 8 Mar 2022 06:37:14 +0200
Subject: [PATCH 15/37] Update postfix_logs.sh
---
cron/postfix_logs.sh | 3 +++
1 file changed, 3 insertions(+)
diff --git a/cron/postfix_logs.sh b/cron/postfix_logs.sh
index acba89b6..07b38fe2 100644
--- a/cron/postfix_logs.sh
+++ b/cron/postfix_logs.sh
@@ -1,5 +1,8 @@
#!/bin/bash
+#TO DO
+# - Delete old logs
+
#check if maillog directory exists
if [ ! -d ../maillog ]
then
From dffbced072eadc2f43dee9aa8017aa37c60668df Mon Sep 17 00:00:00 2001
From: benchea dan <30780133+bnchdan@users.noreply.github.com>
Date: Tue, 8 Mar 2022 08:40:17 +0200
Subject: [PATCH 16/37] Update menu.tpl
---
templates/menu.tpl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/templates/menu.tpl b/templates/menu.tpl
index 56761af9..70df682b 100644
--- a/templates/menu.tpl
+++ b/templates/menu.tpl
@@ -118,7 +118,7 @@
{* to do - add to palang *}
{if $CONF.maillogging==='YES'}
Mail Log
+ href="{#url_maillog#}">Mail Log
{/if}
{* viewlog *}
{if $CONF.logging==='YES'}
From c90b45c7f8b349b1bbd2a74187f63ffbfad221b1 Mon Sep 17 00:00:00 2001
From: benchea dan <30780133+bnchdan@users.noreply.github.com>
Date: Fri, 11 Mar 2022 08:28:29 +0200
Subject: [PATCH 17/37] add cd $(dirname $0)
---
cron/postfix_logs.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/cron/postfix_logs.sh b/cron/postfix_logs.sh
index 07b38fe2..45ee5bb6 100644
--- a/cron/postfix_logs.sh
+++ b/cron/postfix_logs.sh
@@ -1,8 +1,9 @@
#!/bin/bash
-
#TO DO
# - Delete old logs
+cd $(dirname $0)
+
#check if maillog directory exists
if [ ! -d ../maillog ]
then
From 43643f0a4504bafe92a8c1dc9a325b63cb65dda4 Mon Sep 17 00:00:00 2001
From: benchea dan <30780133+bnchdan@users.noreply.github.com>
Date: Fri, 11 Mar 2022 08:30:37 +0200
Subject: [PATCH 18/37] add if (!file_exists($file)) { die(.....) ; }
---
public/maillog.php | 33 ++++++++++++++++-----------------
1 file changed, 16 insertions(+), 17 deletions(-)
diff --git a/public/maillog.php b/public/maillog.php
index 360483e7..fcca652b 100644
--- a/public/maillog.php
+++ b/public/maillog.php
@@ -63,23 +63,22 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
$file = '../maillog/'.$fDomain.'/'.$_GET['get_log'];
-
- if (file_exists($file)) {
- header('Content-Description: File Transfer');
- header('Content-Type: application/octet-stream');
- header('Content-Disposition: attachment; filename='.basename($file));
- header('Content-Transfer-Encoding: binary');
- header('Expires: 0');
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header('Pragma: public');
- header('Content-Length: ' . filesize($file));
- ob_clean();
- flush();
- readfile($file);
- exit;
- }else{
- die("The file does not exists");
- }
+
+ if (!file_exists($file)) { die("The file does not exists") ; }
+
+
+ header('Content-Description: File Transfer');
+ header('Content-Type: application/octet-stream');
+ header('Content-Disposition: attachment; filename='.basename($file));
+ header('Content-Transfer-Encoding: binary');
+ header('Expires: 0');
+ header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
+ header('Pragma: public');
+ header('Content-Length: ' . filesize($file));
+ ob_clean();
+ flush();
+ readfile($file);
+
}
From f9be3371646f6649f41f896e3d8717640ce6db61 Mon Sep 17 00:00:00 2001
From: benchea dan <30780133+bnchdan@users.noreply.github.com>
Date: Fri, 11 Mar 2022 08:47:00 +0200
Subject: [PATCH 19/37] Update maillog.php
---
public/maillog.php | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/public/maillog.php b/public/maillog.php
index fcca652b..5e800319 100644
--- a/public/maillog.php
+++ b/public/maillog.php
@@ -66,18 +66,17 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
if (!file_exists($file)) { die("The file does not exists") ; }
-
- header('Content-Description: File Transfer');
- header('Content-Type: application/octet-stream');
- header('Content-Disposition: attachment; filename='.basename($file));
- header('Content-Transfer-Encoding: binary');
- header('Expires: 0');
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header('Pragma: public');
- header('Content-Length: ' . filesize($file));
- ob_clean();
- flush();
- readfile($file);
+ header('Content-Description: File Transfer');
+ header('Content-Type: application/octet-stream');
+ header('Content-Disposition: attachment; filename='.basename($file));
+ header('Content-Transfer-Encoding: binary');
+ header('Expires: 0');
+ header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
+ header('Pragma: public');
+ header('Content-Length: ' . filesize($file));
+ ob_clean();
+ flush();
+ readfile($file);
From 01308c413ad4bacebb830ee9ef6ade90469d220f Mon Sep 17 00:00:00 2001
From: benchea dan
Date: Fri, 11 Mar 2022 10:41:40 +0200
Subject: [PATCH 20/37] Update main.tpl
---
templates/main.tpl | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/templates/main.tpl b/templates/main.tpl
index c1a681a0..314710ff 100644
--- a/templates/main.tpl
+++ b/templates/main.tpl
@@ -3,33 +3,33 @@
From bb8014e2cbdd9915d0e07e3ecf3e5b72a168ad6c Mon Sep 17 00:00:00 2001
From: benchea dan
Date: Fri, 11 Mar 2022 11:00:59 +0200
Subject: [PATCH 21/37] disable viewlog from main.tp
---
templates/main.tpl | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/templates/main.tpl b/templates/main.tpl
index 314710ff..a50f5ef4 100644
--- a/templates/main.tpl
+++ b/templates/main.tpl
@@ -24,10 +24,14 @@
{$PALANG.pMenu_password}
{$PALANG.pMain_password}
-
- {$PALANG.pMenu_viewlog}
- {$PALANG.pMain_viewlog}
-
+ {* viewlog *}
+ {if $CONF.logging==='YES'}
+
+ {$PALANG.pMenu_viewlog}
+ {$PALANG.pMain_viewlog}
+
+ {/if}
+
{$PALANG.pMenu_logout}
{$PALANG.pMain_logout}
From af9c3197b90cb51723fa80dc5a8d330834cbbcfa Mon Sep 17 00:00:00 2001
From: benchea dan
Date: Fri, 11 Mar 2022 12:30:42 +0200
Subject: [PATCH 22/37] set default $CONF['maillogging'] = 'NO';
---
config.inc.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/config.inc.php b/config.inc.php
index ab7e2137..84a79d34 100644
--- a/config.inc.php
+++ b/config.inc.php
@@ -480,8 +480,8 @@ $CONF['sendmail'] = 'YES';
$CONF['sendmail_all_admins'] = 'NO';
// Mail Logging
-// If you don't want mail logging set this to 'NO';
-$CONF['maillogging'] = 'YES';
+// If you want mail logging set this to 'YES';
+$CONF['maillogging'] = 'NO';
// Logging
// If you don't want logging set this to 'NO';
From cbd1a0387fcd6680a51cc09bf93af5b5b2e1eb61 Mon Sep 17 00:00:00 2001
From: benchea dan
Date: Fri, 11 Mar 2022 12:51:50 +0200
Subject: [PATCH 23/37] Update config.inc.php
---
config.inc.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/config.inc.php b/config.inc.php
index 84a79d34..3bdbd064 100644
--- a/config.inc.php
+++ b/config.inc.php
@@ -481,6 +481,8 @@ $CONF['sendmail_all_admins'] = 'NO';
// Mail Logging
// If you want mail logging set this to 'YES';
+// The logs are in the mailog/ direcory.
+// You need to execute (add in the crontab) postfix_logs.sh script
$CONF['maillogging'] = 'NO';
// Logging
From e7650304358f416e2d1bbf7df01f79c0d7c9f871 Mon Sep 17 00:00:00 2001
From: benchea dan
Date: Fri, 11 Mar 2022 12:54:36 +0200
Subject: [PATCH 24/37] Update postfix_logs.sh
---
cron/postfix_logs.sh | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/cron/postfix_logs.sh b/cron/postfix_logs.sh
index 45ee5bb6..69a502ef 100644
--- a/cron/postfix_logs.sh
+++ b/cron/postfix_logs.sh
@@ -1,4 +1,11 @@
#!/bin/bash
+
+#
+# The logs are in the mailog/ direcory.
+# You need to execute (add in the crontab) this script and set the $CONF['maillogging'] to 'YES' in the config.inc.php
+#
+
+
#TO DO
# - Delete old logs
From 9b969d973827f72396e6b822aef406dfc17b46d2 Mon Sep 17 00:00:00 2001
From: benchea dan
Date: Fri, 11 Mar 2022 13:45:20 +0200
Subject: [PATCH 25/37] Update config.inc.php
---
config.inc.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config.inc.php b/config.inc.php
index 3bdbd064..5f6eaeae 100644
--- a/config.inc.php
+++ b/config.inc.php
@@ -482,7 +482,7 @@ $CONF['sendmail_all_admins'] = 'NO';
// Mail Logging
// If you want mail logging set this to 'YES';
// The logs are in the mailog/ direcory.
-// You need to execute (add in the crontab) postfix_logs.sh script
+// You need to execute (add in the crontab) postfix_logs.sh script from cron/ directory
$CONF['maillogging'] = 'NO';
// Logging
From d999074466dcd6ba76aee05f0e8f59be0c96ebd6 Mon Sep 17 00:00:00 2001
From: benchea dan
Date: Tue, 15 Mar 2022 09:51:15 +0200
Subject: [PATCH 26/37] order by date, first 50 files
---
public/maillog.php | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/public/maillog.php b/public/maillog.php
index 5e800319..0529aa9b 100644
--- a/public/maillog.php
+++ b/public/maillog.php
@@ -119,10 +119,13 @@ $log_list='';
$log_size_list=array();
if (file_exists($path)){
//read logs from path
- $logs=scandir($path);
+ $logs=scandir($path, 1);
//remove . and .. from result
$log_list = array_diff( $logs,array('.', '..') );
+ //first 50 files
+ $log_list=array_slice($log_list, 0, 50);
+
$i=0;
foreach ($log_list as $log){
$log_size_list[$i++] = round ( filesize($path.'/'.$log)/ 1024, 3);
From 39c4d5b13fd5ebae010c2a2bc8fa2a83d55079d9 Mon Sep 17 00:00:00 2001
From: benchea dan
Date: Tue, 15 Mar 2022 11:48:24 +0200
Subject: [PATCH 27/37] glyphicon icons
---
templates/menu.tpl | 85 +++++++++++++++++++++++++---------------------
1 file changed, 46 insertions(+), 39 deletions(-)
diff --git a/templates/menu.tpl b/templates/menu.tpl
index 70df682b..bcac4830 100644
--- a/templates/menu.tpl
+++ b/templates/menu.tpl
@@ -8,8 +8,10 @@
{/strip}
{strip}
-
-
+
+
+
+
From ed001c97846f2704e6a17f8ba38044698d286535 Mon Sep 17 00:00:00 2001
From: benchea dan
Date: Tue, 15 Mar 2022 11:50:07 +0200
Subject: [PATCH 28/37] glyphicon icons
---
templates/main.tpl | 44 +++++++++++++++++++++++++-------------------
1 file changed, 25 insertions(+), 19 deletions(-)
diff --git a/templates/main.tpl b/templates/main.tpl
index a50f5ef4..71241b2b 100644
--- a/templates/main.tpl
+++ b/templates/main.tpl
@@ -3,38 +3,44 @@
From dad563fe753d89748b61ca7db18b175b4b8acc42 Mon Sep 17 00:00:00 2001
From: benchea dan
Date: Wed, 16 Mar 2022 21:39:25 +0200
Subject: [PATCH 29/37] Update postfix_logs.sh
---
cron/postfix_logs.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/cron/postfix_logs.sh b/cron/postfix_logs.sh
index 69a502ef..d6229d71 100644
--- a/cron/postfix_logs.sh
+++ b/cron/postfix_logs.sh
@@ -9,6 +9,7 @@
#TO DO
# - Delete old logs
+
cd $(dirname $0)
#check if maillog directory exists
From 3e6ff06095df6f8342ddb95fd4e67888319007a8 Mon Sep 17 00:00:00 2001
From: benchea dan
Date: Wed, 16 Mar 2022 21:40:52 +0200
Subject: [PATCH 30/37] Delete cron directory
---
cron/postfix_logs.sh | 48 --------------------------------------------
1 file changed, 48 deletions(-)
delete mode 100644 cron/postfix_logs.sh
diff --git a/cron/postfix_logs.sh b/cron/postfix_logs.sh
deleted file mode 100644
index d6229d71..00000000
--- a/cron/postfix_logs.sh
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/bash
-
-#
-# The logs are in the mailog/ direcory.
-# You need to execute (add in the crontab) this script and set the $CONF['maillogging'] to 'YES' in the config.inc.php
-#
-
-
-#TO DO
-# - Delete old logs
-
-
-cd $(dirname $0)
-
-#check if maillog directory exists
-if [ ! -d ../maillog ]
-then
- #create direcotry
- mkdir ../maillog
-fi
-
-
-data=`date --date='1 day ago' +%F`
-
-mysql -u root --skip-column-names --execute="USE postfix; SELECT username,domain FROM domain_admins WHERE active=1 AND domain <> 'ALL';" | while read username domain
- do
-
- #check if folder for domain doesn t exists
- if [ ! -d ../maillog/$domain ]
- then
- echo "Directory does not exists for "$domain
- #create direcotry
- mkdir ../maillog/$domain
- fi
-
- grep @$domain /var/log/mail.log.1 | grep -v "postfix-policyd" | grep -v postgrey > ../maillog/$domain/$data-bulk.log
- pflogsumm -i --problems_first --detail 5 ../maillog/$domain/$data-bulk.log > ../maillog/$domain/$data-pflogsum.log
- grep @$domain /var/log/mail.log.1 | grep "Password mismatch" > ../maillog/$domain/$data-failed-auth.log
-
- gzip ../maillog/$domain/$data-bulk.log
- gzip ../maillog/$domain/$data-pflogsum.log
- gzip ../maillog/$domain/$data-failed-auth.log
- echo $domain
-
-# rm ../maillog/$domain/$data-bulk.log
-# rm ../maillog/$domain/$data-pflogsum.log
-# rm ../maillog/$domain/$data-failed-auth.log
- done
From 9dede248864678e3a34dabd42edbda35f35caf61 Mon Sep 17 00:00:00 2001
From: benchea dan
Date: Wed, 16 Mar 2022 21:43:25 +0200
Subject: [PATCH 31/37] Delete maillog/domain directory
---
maillog/domain/2022-03-06-bulk.log.gz | 1 -
maillog/domain/2022-03-06-failed-auth.log.gz | 1 -
maillog/domain/2022-03-06-pflogsum.log.gz | 1 -
3 files changed, 3 deletions(-)
delete mode 100644 maillog/domain/2022-03-06-bulk.log.gz
delete mode 100644 maillog/domain/2022-03-06-failed-auth.log.gz
delete mode 100644 maillog/domain/2022-03-06-pflogsum.log.gz
diff --git a/maillog/domain/2022-03-06-bulk.log.gz b/maillog/domain/2022-03-06-bulk.log.gz
deleted file mode 100644
index 33a9488b..00000000
--- a/maillog/domain/2022-03-06-bulk.log.gz
+++ /dev/null
@@ -1 +0,0 @@
-example
diff --git a/maillog/domain/2022-03-06-failed-auth.log.gz b/maillog/domain/2022-03-06-failed-auth.log.gz
deleted file mode 100644
index 33a9488b..00000000
--- a/maillog/domain/2022-03-06-failed-auth.log.gz
+++ /dev/null
@@ -1 +0,0 @@
-example
diff --git a/maillog/domain/2022-03-06-pflogsum.log.gz b/maillog/domain/2022-03-06-pflogsum.log.gz
deleted file mode 100644
index 33a9488b..00000000
--- a/maillog/domain/2022-03-06-pflogsum.log.gz
+++ /dev/null
@@ -1 +0,0 @@
-example
From 1a17804b7368aae98c9c2129b8589571c7c8cb84 Mon Sep 17 00:00:00 2001
From: benchea dan
Date: Wed, 16 Mar 2022 21:43:41 +0200
Subject: [PATCH 32/37] Delete maillog.tpl
---
templates/maillog.tpl | 43 -------------------------------------------
1 file changed, 43 deletions(-)
delete mode 100644 templates/maillog.tpl
diff --git a/templates/maillog.tpl b/templates/maillog.tpl
deleted file mode 100644
index f6452e49..00000000
--- a/templates/maillog.tpl
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
- {if !$log_list}
- No logs found for {$domain_selected}!
- {else}
-
- {assign var=i value=0}
- {assign var=logNumber value=1}
- {foreach from=$log_list item=log}
-
-
- {$logNumber}
-
-
-
- {$log}
-
-
- {$log_size_list[$i]}
-
-
-
- Download
-
- {assign var=logNumber value=$logNumber+1}
- {assign var=i value=$i+1}
-
- {/foreach}
- {/if}
-
-
-
From e819bc49b371c004db7cac1a0267a5980e936f21 Mon Sep 17 00:00:00 2001
From: benchea dan
Date: Wed, 16 Mar 2022 21:44:13 +0200
Subject: [PATCH 33/37] Delete maillog.php
---
public/maillog.php | 150 ---------------------------------------------
1 file changed, 150 deletions(-)
delete mode 100644 public/maillog.php
diff --git a/public/maillog.php b/public/maillog.php
deleted file mode 100644
index 0529aa9b..00000000
--- a/public/maillog.php
+++ /dev/null
@@ -1,150 +0,0 @@
-getAll();
-$smarty = PFASmarty::getInstance();
-
-$PALANG = $CONF['__LANG'];
-
-$SESSID_USERNAME = authentication_get_username();
-if (authentication_has_role('global-admin')) {
- $list_domains = list_domains();
-} else {
- $list_domains = list_domains_for_admin($SESSID_USERNAME);
-}
-
-
-/*
-foreach ($list_domains as $domain){
- echo $domain. ' ';
-}
-*/
-
-$fDomain=$list_domains[0];
-
-if ($_SERVER['REQUEST_METHOD'] == "GET") {
- if (isset($_GET['fDomain'])) {
- $fDomain_aux = escape_string($_GET['fDomain']);
- $flag_fDomain = 0;
- //check if domain exists
- if ((is_array($list_domains) and sizeof($list_domains) > 0)) {
- foreach ($list_domains as $domain) {
- if ($domain == $fDomain_aux) {
- $fDomain=$domain;
- $flag_fDomain=1;
- break;
- }
- }
- }
-
- if ($flag_fDomain == 0 ) {
- die('Unknown domain');
- }
-
- if (strpos($fDomain, '/') !== false) {
- die("Unknown path");
- }
-
- //check if file exists
-
- if (isset($_GET['get_log'])){
- // remove path from filename
- if (strpos($_GET['get_log'], '/') !== false) {
- die("Unknown file");
- }
-
-
- $file = '../maillog/'.$fDomain.'/'.$_GET['get_log'];
-
- if (!file_exists($file)) { die("The file does not exists") ; }
-
- header('Content-Description: File Transfer');
- header('Content-Type: application/octet-stream');
- header('Content-Disposition: attachment; filename='.basename($file));
- header('Content-Transfer-Encoding: binary');
- header('Expires: 0');
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header('Pragma: public');
- header('Content-Length: ' . filesize($file));
- ob_clean();
- flush();
- readfile($file);
-
-
-
- }
-
- }
-} elseif ($_SERVER['REQUEST_METHOD'] == "POST") {
- if (isset($_POST['fDomain'])) {
- $fDomain_aux = escape_string($_POST['fDomain']);
- $flag_fDomain = 0;
- if ((is_array($list_domains) and sizeof($list_domains) > 0)) {
- foreach ($list_domains as $domain) {
- if ($domain == $fDomain_aux) {
- $fDomain=$domain;
- $flag_fDomain=1;
- break;
- }
- }
- }
-
- if ($flag_fDomain == 0 ) {
- die('Unknown domain');
- }
-
- if (strpos($fDomain, '/') !== false) {
- die("Unknown domain");
- }
-
-
- }
-} else {
- die('Unknown request method');
-}
-
-
-$path = '../maillog/'.$fDomain;
-
-//check if folder exists
-$log_list='';
-$log_size_list=array();
-if (file_exists($path)){
- //read logs from path
- $logs=scandir($path, 1);
- //remove . and .. from result
- $log_list = array_diff( $logs,array('.', '..') );
-
- //first 50 files
- $log_list=array_slice($log_list, 0, 50);
-
- $i=0;
- foreach ($log_list as $log){
- $log_size_list[$i++] = round ( filesize($path.'/'.$log)/ 1024, 3);
- }
-}
-
-
-
-$smarty->assign("domain_list", $list_domains);
-$smarty->assign('domain_selected', $fDomain);
-
-$smarty->assign('log_list', $log_list);
-$smarty->assign('log_size_list', $log_size_list);
-
-
-$smarty->assign('smarty_template', 'maillog');
-$smarty->display('index.tpl');
-
-
-
-
-?>
From d8be2df654936268dd4eb47b2d5af392dca2e1ff Mon Sep 17 00:00:00 2001
From: benchea dan
Date: Wed, 16 Mar 2022 21:46:07 +0200
Subject: [PATCH 34/37] Update config.inc.php
---
config.inc.php | 5 -----
1 file changed, 5 deletions(-)
diff --git a/config.inc.php b/config.inc.php
index 5f6eaeae..60c0cd56 100644
--- a/config.inc.php
+++ b/config.inc.php
@@ -479,11 +479,6 @@ $CONF['sendmail'] = 'YES';
// send mails to their users
$CONF['sendmail_all_admins'] = 'NO';
-// Mail Logging
-// If you want mail logging set this to 'YES';
-// The logs are in the mailog/ direcory.
-// You need to execute (add in the crontab) postfix_logs.sh script from cron/ directory
-$CONF['maillogging'] = 'NO';
// Logging
// If you don't want logging set this to 'NO';
From fe01fa9a3f79a8ecce5d811a35b556bc776cfb97 Mon Sep 17 00:00:00 2001
From: benchea dan
Date: Wed, 16 Mar 2022 21:48:37 +0200
Subject: [PATCH 35/37] Update config.inc.php
---
config.inc.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/config.inc.php b/config.inc.php
index 60c0cd56..e4c63286 100644
--- a/config.inc.php
+++ b/config.inc.php
@@ -479,7 +479,6 @@ $CONF['sendmail'] = 'YES';
// send mails to their users
$CONF['sendmail_all_admins'] = 'NO';
-
// Logging
// If you don't want logging set this to 'NO';
$CONF['logging'] = 'YES';
From b99724311034f4574fe62766ff7ab823ecd4baef Mon Sep 17 00:00:00 2001
From: benchea dan
Date: Wed, 16 Mar 2022 21:49:01 +0200
Subject: [PATCH 36/37] Update menu.conf
---
configs/menu.conf | 2 --
1 file changed, 2 deletions(-)
diff --git a/configs/menu.conf b/configs/menu.conf
index 6d279292..55ae6b91 100644
--- a/configs/menu.conf
+++ b/configs/menu.conf
@@ -21,8 +21,6 @@ url_broadcast_message = broadcast-message.php
url_password = edit.php?table=adminpassword
# backup
url_backup = backup.php
-# maillog
-url_maillog = maillog.php
# viewlog
url_viewlog = viewlog.php
# logout
From 537926793acc9eb883cd778242dacf7fca32aeaf Mon Sep 17 00:00:00 2001
From: benchea dan
Date: Wed, 16 Mar 2022 21:50:59 +0200
Subject: [PATCH 37/37] Update menu.tpl
---
templates/menu.tpl | 8 --------
1 file changed, 8 deletions(-)
diff --git a/templates/menu.tpl b/templates/menu.tpl
index bcac4830..17287ae1 100644
--- a/templates/menu.tpl
+++ b/templates/menu.tpl
@@ -120,14 +120,6 @@
{$PALANG.pAdminMenu_backup}
{/if}
- {* maillog *}
- {* to do - add to palang *}
- {if $CONF.maillogging==='YES'}
-
-
- Mail Log
- {/if}
{* viewlog *}
{if $CONF.logging==='YES'}