aboutsummaryrefslogtreecommitdiffstats
path: root/config/postfix
diff options
context:
space:
mode:
Diffstat (limited to 'config/postfix')
-rw-r--r--config/postfix/postfix.inc6
-rw-r--r--config/postfix/postfix.php1469
-rw-r--r--config/postfix/postfix_antispam.xml16
-rwxr-xr-xconfig/postfix/postfix_queue.php12
-rwxr-xr-xconfig/postfix/postfix_search.php1
5 files changed, 775 insertions, 729 deletions
diff --git a/config/postfix/postfix.inc b/config/postfix/postfix.inc
index d009e72a..5a802054 100644
--- a/config/postfix/postfix.inc
+++ b/config/postfix/postfix.inc
@@ -391,8 +391,10 @@ EOF;
if($antispam['antispam_enabled']){
switch ($antispam['antispam_software']){
case "mailscanner":
- $header_check .= (!preg_match('@/ HOLD@',$header_check)?"\n/^Received:/ HOLD\n":"\n");
- $postfix_main_antispam = "#Saving all mail after header/body/rbl/spf checks to mailscanner\n\n";
+ if ($antispam['hold_mode']=='auto'){
+ $header_check .= "\n/^Received:/ HOLD\n";
+ $postfix_main_antispam = "#Saving all mail after header/body/rbl/spf checks to mailscanner\n\n";
+ }
break;
case "policyd2":
if ($antispam['antispam_location']){
diff --git a/config/postfix/postfix.php b/config/postfix/postfix.php
index 842d5658..9f15973c 100644
--- a/config/postfix/postfix.php
+++ b/config/postfix/postfix.php
@@ -1,727 +1,744 @@
-<?php
-/*
- postfix.php
- part of pfSense (http://www.pfsense.com/)
- Copyright (C) 2011 Marcello Coutinho <marcellocoutinho@gmail.com>
- based on varnish_view_config.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-require_once("/etc/inc/util.inc");
-require_once("/etc/inc/functions.inc");
-require_once("/etc/inc/pkg-utils.inc");
-require_once("/etc/inc/globals.inc");
-require_once("/usr/local/pkg/postfix.inc");
-
-function get_remote_log(){
- global $config,$g,$postfix_dir;
- $curr_time = time();
- $log_time=date('YmdHis',$curr_time);
- #get protocol
- if($config['system']['webgui']['protocol'] != "")
- $synchronizetoip = $config['system']['webgui']['protocol']. "://";
- #get port
- $port = $config['system']['webgui']['port'];
- #if port is empty lets rely on the protocol selection
- if($port == "")
- $port =($config['system']['webgui']['protocol'] == "http"?"80":"443");
- $synchronizetoip .= $sync_to_ip;
- if (is_array($config['installedpackages']['postfixsync']))
- foreach($config['installedpackages']['postfixsync']['config'][0]['row'] as $sh){
- $sync_to_ip = $sh['ipaddress'];
- $sync_type = $sh['sync_type'];
- $password = $sh['password'];
- $file= '/var/db/postfix/'.$server.'.sql';
- #get remote data
- if ($sync_type=='fetch'){
- $url= $synchronizetoip . $sync_to_ip;
- print "$sync_to_ip $url, $port\n";
- $method = 'pfsense.exec_php';
- $execcmd = "require_once('/usr/local/www/postfix.php');\n";
- $execcmd .= '$toreturn=get_sql('.$log_time.');';
- /* assemble xmlrpc payload */
- $params = array(XML_RPC_encode($password),
- XML_RPC_encode($execcmd));
- log_error("postfix get sql data from {$sync_to_ip}.");
- $msg = new XML_RPC_Message($method, $params);
- $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
- $cli->setCredentials('admin', $password);
- #$cli->setDebug(1);
- $resp = $cli->send($msg, "250");
- $a=$resp->value();
- $errors=0;
- #var_dump($sql);
- foreach($a as $b)
- foreach ($b as $c)
- foreach ($c as $d)
- foreach ($d as $e){
- $update=unserialize($e['string']);
- print $update['day']."\n";
- if ($update['day'] != ""){
- create_db($update['day'].".db");
- if ($debug=true)
- print $update['day'] ." writing from remote system to db...";
- $dbhandle = sqlite_open($postfix_dir.'/'.$update['day'].".db", 0666, $error);
- #file_put_contents("/tmp/".$key.'-'.$update['day'].".sql",gzuncompress(base64_decode($update['sql'])), LOCK_EX);
- $ok = sqlite_exec($dbhandle, gzuncompress(base64_decode($update['sql'])), $error);
- if (!$ok){
- $errors++;
- die ("Cannot execute query. $error\n".$update['sql']."\n");
- }
- else{
- if ($debug=true)
- print "ok\n";
- }
- sqlite_close($dbhandle);
- }
- }
- if ($errors ==0){
- $method = 'pfsense.exec_php';
- $execcmd = "require_once('/usr/local/www/postfix.php');\n";
- $execcmd .= 'flush_sql('.$log_time.');';
- /* assemble xmlrpc payload */
- $params = array(XML_RPC_encode($password),
- XML_RPC_encode($execcmd));
- log_error("postfix flush sql buffer file from {$sync_to_ip}.");
- $msg = new XML_RPC_Message($method, $params);
- $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
- $cli->setCredentials('admin', $password);
- #$cli->setDebug(1);
- $resp = $cli->send($msg, "250");
- }
- }
- }
-}
-function get_sql($log_time){
- global $config,$xmlrpc_g;
- $server=$_SERVER['REMOTE_ADDR'];
-
- if (is_array($config['installedpackages']['postfixsync']))
- foreach($config['installedpackages']['postfixsync']['config'][0]['row'] as $sh){
- $sync_to_ip = $sh['ipaddress'];
- $sync_type = $sh['sync_type'];
- $password = $sh['password'];
- $file= '/var/db/postfix/'.$server.'.sql';
- if ($sync_to_ip==$server && $sync_type=='share' && file_exists($file)){
- rename($file,$file.".$log_time");
- return (file($file.".$log_time"));
- }
- }
- return "";
-}
-
-function flush_sql($log_time){
- if (preg_match("/\d+\.\d+\.\d+\.\d+/",$_SERVER['REMOTE_ADDR']))
- unlink_if_exists('/var/db/postfix/'.$_SERVER['REMOTE_ADDR'].".sql.$log_time");
-}
-
-function grep_log(){
- global $postfix_dir,$postfix_arg,$config,$g;
-
- $total_lines=0;
- $days=array();
- $grep="postfix.\(cleanup\|smtp\|error\|qmgr\)";
- $curr_time = time();
- $log_time=strtotime($postfix_arg['time'],$curr_time);
- $m=date('M',strtotime($postfix_arg['time'],$curr_time));
- $j=substr(" ".date('j',strtotime($postfix_arg['time'],$curr_time)),-3);
- # file grep loop
- foreach ($postfix_arg['grep'] as $hour){
- print "/usr/bin/grep '^".$m.$j." ".$hour.".*".$grep."' /var/log/maillog\n";
- $lists=array();
- exec("/usr/bin/grep " . escapeshellarg('^'.$m.$j." ".$hour.".*".$grep)." /var/log/maillog", $lists);
- foreach ($lists as $line){
- #check where is first mail record
- if (preg_match("/ delay=(\d+)/",$line,$delay)){
- $day=date("Y-m-d",strtotime("-".$delay[1]." second",$log_time));
- if (! in_array($day,$days)){
- $days[]=$day;
- create_db($day.".db");
- print "Found logs to $day.db\n";
- $stm_queue[$day]="BEGIN;\n";
- $stm_noqueue[$day]="BEGIN;\n";
- }
- }
- else{
- $day=date("Y-m-d",strtotime($postfix_arg['time'],$curr_time));
- if (! in_array($day,$days)){
- $days[]=$day;
- create_db($day.".db");
- print "Found logs to $day.db\n";
- $stm_queue[$day]="BEGIN;\n";
- $stm_noqueue[$day]="BEGIN;\n";
- }
- }
- $status=array();
- $total_lines++;
- #Nov 8 09:31:50 srvch011 postfix/smtpd[43585]: 19C281F59C8: client=pm03-974.auinmem.br[177.70.0.3]
- if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.smtpd\W\d+\W+(\w+): client=(.*)/",$line,$email)){
- $values="'".$email[3]."','".$email[1]."','".$email[2]."','".$email[4]."'";
- if(${$email[3]}!=$email[3])
- $stm_queue[$day].='insert or ignore into mail_from(sid,date,server,client) values ('.$values.');'."\n";
- ${$email[3]}=$email[3];
- }
- #Nov 14 09:29:32 srvch011 postfix/error[58443]: 2B8EB1F5A5A: to=<hildae.sva@pi.email.com>, relay=none, delay=0.66, delays=0.63/0/0/0.02, dsn=4.4.3, status=deferred (delivery temporarily suspended: Host or domain name not found. Name service error for name=mail.pi.trf1.gov.br type=A: Host not found, try again)
- #Nov 3 21:45:32 srvch011 postfix/smtp[18041]: 4CE321F4887: to=<viinil@vitive.com.br>, relay=smtpe1.eom[81.00.20.9]:25, delay=1.9, delays=0.06/0.01/0.68/1.2, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 2C33E2382C8)
- #Nov 16 00:00:14 srvch011 postfix/smtp[7363]: 7AEB91F797D: to=<alessandra.bueno@mg.trf1.gov.br>, relay=mail.mg.trf1.gov.br[172.25.3.5]:25, delay=39, delays=35/1.1/0.04/2.7, dsn=5.7.1, status=bounced (host mail.mg.trf1.gov.br[172.25.3.5] said: 550 5.7.1 Unable to relay for alessandra.bueno@mg.trf1.gov.br (in reply to RCPT TO command))
- else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.\w+\W\d+\W+(\w+): to=\<(.*)\>, relay=(.*), delay=([0-9,.]+), .* dsn=([0-9,.]+), status=(\w+) (.*)/",$line,$email)){
- $stm_queue[$day].= "insert or ignore into mail_status (info) values ('".$email[8]."');\n";
- $stm_queue[$day].= "insert or ignore into mail_to (from_id,too,status,status_info,relay,delay,dsn) values ((select id from mail_from where sid='".$email[3]."' and server='".$email[2]."'),'".strtolower($email[4])."',(select id from mail_status where info='".$email[8]."'),'".preg_replace("/(\<|\>|\s+|\'|\")/"," ",$email[9])."','".$email[5]."','".$email[6]."','".$email[7]."');\n";
- $stm_queue[$day].= "update or ignore mail_to set status=(select id from mail_status where info='".$email[8]."'), status_info='".preg_replace("/(\<|\>|\s+|\'|\")/"," ",$email[9])."', dsn='".$email[7]."', delay='".$email[6]."', relay='".$email[5]."', too='".strtolower($email[4])."' where from_id in (select id from mail_from where sid='".$email[3]."' and server='".$email[2]."');\n";
- }
- #Nov 13 01:48:44 srvch011 postfix/cleanup[16914]: D995B1F570B: message-id=<61.40.11745.10E3FBE4@ofertas6>
- else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.cleanup\W\d+\W+(\w+): message-id=\<(.*)\>/",$line,$email)){
- $stm_queue[$day].="update mail_from set msgid='".$email[4]."' where sid='".$email[3]."';\n";
- }
- #Nov 14 02:40:05 srvch011 postfix/qmgr[46834]: BC5931F4F13: from=<ceag@mx.crmcom.br>, size=32727, nrcpt=1 (queue active)
- else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.qmgr\W\d+\W+(\w+): from=\<(.*)\>\W+size=(\d+)/",$line,$email)){
- $stm_queue[$day].= "update mail_from set fromm='".strtolower($email[4])."', size='".$email[5]."' where sid='".$email[3]."';\n";
- }
- #Nov 13 00:09:07 srvch011 postfix/bounce[56376]: 9145C1F67F7: sender non-delivery notification: D5BD31F6865
- #else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.bounce\W\d+\W+(\w+): sender non-delivery notification: (\w+)/",$line,$email)){
- # $stm_queue[$day].= "update mail_queue set bounce='".$email[4]."' where sid='".$email[3]."';\n";
- #}
- #Nov 14 01:41:44 srvch011 postfix/smtpd[15259]: warning: 1EF3F1F573A: queue file size limit exceeded
- else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.smtpd\W\d+\W+warning: (\w+): queue file size limit exceeded/",$line,$email)){
- $stm_queue[$day].= "insert or ignore into mail_status (info) values ('".$email[8]."');\n";
- $stm_queue[$day].= "update mail_to set status=(select id from mail_status where info='reject'), status_info='queue file size limit exceeded' where from_id in (select id from mail_from where sid='".$email[3]."' and server='".$email[2]."');\n";
- }
-
- #Nov 9 02:14:57 srvch011 postfix/cleanup[6856]: 617A51F5AC5: warning: header Subject: Mapeamento de Processos from lxalpha.12b.com.br[66.109.29.225]; from=<apache@lxalpha.12b.com.br> to=<ritiele.faria@mail.test.com> proto=ESMTP helo=<lxalpha.12b.com.br>
- #Nov 8 09:31:50 srvch011 postfix/cleanup[11471]: 19C281F59C8: reject: header From: "Giuliana Flores - Parceiro do Grupo Virtual" <publicidade@parceiro-grupovirtual.com.br> from pm03-974.auinmeio.com.br[177.70.232.225]; from=<publicidade@parceiro-grupovirtual.com.br> to=<jorge.lustosa@mail.test.com> proto=ESMTP helo=<pm03-974.auinmeio.com.br>: 5.7.1 [SN007]
- #Nov 13 00:03:24 srvch011 postfix/cleanup[4192]: 8A5B31F52D2: reject: body http://platform.roastcrack.info/mj0ie6p-48qtiyq from move2.igloojack.info[173.239.63.16]; from=<ljmd6u8lrxke4@move2.igloojack.info> to=<edileva@aasdf..br> proto=SMTP helo=<move2.igloojack.info>: 5.7.1 [BD040]
- #Nov 14 01:41:35 srvch011 postfix/cleanup[58446]: 1EF3F1F573A: warning: header Subject: =?windows-1252?Q?IMOVEL_Voc=EA_=E9_um_Cliente_especial_da_=93CENTURY21=22?=??=?windows-1252?Q?Veja_o_que_tenho_para_voc=EA?= from mail-yw0-f51.google.com[209.85.213.51]; from=<sergioalexandre6308@gmail.com> to=<sinza@tr.br> proto=ESMTP helo=<mail-yw0-f51.google.com>
- else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.cleanup\W\d+\W+(\w+): (\w+): (.*) from ([a-z,A-Z,0-9,.,-]+)\W([0-9,.]+)\W+from=\<(.*)\> to=\<(.*)\>.*helo=\W([a-z,A-Z,0-9,.,-]+)(.*)/",$line,$email)){
- $status['date']=$email[1];
- $status['server']=$email[2];
- $status['sid']=$email[3];
- $status['remote_hostname']=$email[6];
- $status['remote_ip']=$email[7];
- $status['from']=$email[8];
- $status['to']=$email[9];
- $status['helo']=$email[10];
- $status['status']=$email[4];
- $stm_queue[$day].= "insert or ignore into mail_status (info) values ('".$email[4]."');\n";
- if ($email[4] =="warning"){
- $stm_queue[$day].= "insert or ignore into mail_status (info) values ('incoming');\n";
- #print "$line\n";
- $status['status_info']=preg_replace("/(\<|\>|\s+|\'|\")/"," ",$email[11]);
- $status['subject']=preg_replace("/header Subject: /","",$email[5]);
- $status['subject']=preg_replace("/(\<|\>|\s+|\'|\")/"," ",$status['subject']);
- $stm_queue[$day].="update mail_from set subject='".$status['subject']."', fromm='".strtolower($status['from'])."',helo='".$status['helo']."' where sid='".$status['sid']."';\n";
- $stm_queue[$day].="insert or ignore into mail_to (from_id,too,status,status_info) VALUES ((select id from mail_from where sid='".$email[3]."' and server='".$email[2]."'),'".strtolower($status['to'])."',(select id from mail_status where info='incoming'),'".$status['status_info']."');\n";
- $stm_queue[$day].="update or ignore mail_to set status=(select id from mail_status where info='incoming'), status_info='".$status['status_info']."', too='".strtolower($status['to'])."' where from_id in (select id from mail_from where sid='".$status['sid']."' and server='".$email[2]."');\n";
- }
- else{
- $stm_queue[$day].="update mail_from set fromm='".strtolower($status['from'])."',helo='".$status['helo']."' where sid='".$status['sid']."';\n";
- $status['status_info']=preg_replace("/(\<|\>|\s+|\'|\")/"," ",$email[5].$email[11]);
- $stm_queue[$day].="insert or ignore into mail_to (from_id,too,status,status_info) VALUES ((select id from mail_from where sid='".$email[3]."' and server='".$email[2]."'),'".strtolower($status['to'])."',(select id from mail_status where info='".$email[4]."'),'".$status['status_info']."');\n";
- $stm_queue[$day].="update or ignore mail_to set status=(select id from mail_status where info='".$email[4]."'), status_info='".$status['status_info']."', too='".strtolower($status['to'])."' where from_id in (select id from mail_from where sid='".$status['sid']."' and server='".$email[2]."');\n";
- }
- }
- #Nov 9 02:14:34 srvch011 postfix/smtpd[38129]: NOQUEUE: reject: RCPT from unknown[201.36.0.7]: 450 4.7.1 Client host rejected: cannot find your hostname, [201.36.98.7]; from=<maladireta@esadcos.com.br> to=<sexec.09vara@go.domain.test.com> proto=ESMTP helo=<capri0.wb.com.br>
- else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.smtpd\W\d+\W+NOQUEUE:\s+(\w+): (.*); from=\<(.*)\> to=\<(.*)\>.*helo=\<(.*)\>/",$line,$email)){
- $status['date']=$email[1];
- $status['server']=$email[2];
- $status['status']=$email[3];
- $status['status_info']=$email[4];
- $status['from']=$email[5];
- $status['to']=$email[6];
- $status['helo']=$email[7];
- $values="'".$status['date']."','".$status['status']."','".$status['status_info']."','".strtolower($status['from'])."','".strtolower($status['to'])."','".$status['helo']."','".$status['server']."'";
- $stm_noqueue[$day].='insert or ignore into mail_noqueue(date,status,status_info,fromm,too,helo,server) values ('.$values.');'."\n";
- }
- if ($total_lines%1500 == 0){
- #save log in database
- write_db($stm_noqueue,"noqueue",$days);
- write_db($stm_queue,"from",$days);
- foreach ($days as $d){
- $stm_noqueue[$d]="BEGIN;\n";
- $stm_queue[$d]="BEGIN;\n";
- }
- }
- if ($total_lines%1500 == 0)
- print "$line\n";
- }
- #save log in database
- write_db($stm_noqueue,"noqueue",$days);
- write_db($stm_queue,"from",$days);
- foreach ($days as $d){
- $stm_noqueue[$d]="BEGIN;\n";
- $stm_queue[$d]="BEGIN;\n";
- }
- }
-
- $config=parse_xml_config("{$g['conf_path']}/config.xml", $g['xml_rootobj']);
- print count($config['installedpackages']);
- #start db replication if configured
- if ($config['installedpackages']['postfixsync']['config'][0]['rsync'])
- foreach ($config['installedpackages']['postfixsync']['config'] as $rs )
- foreach($rs['row'] as $sh){
- $sync_to_ip = $sh['ipaddress'];
- $sync_type = $sh['sync_type'];
- $password = $sh['password'];
- print "checking replication to $sync_to_ip...";
- if ($password && $sync_to_ip && preg_match("/(both|database)/",$sync_type))
- postfix_do_xmlrpc_sync($sync_to_ip, $password,$sync_type);
- print "ok\n";
- }
-
-}
-
-function write_db($stm,$table,$days){
- global $postfix_dir,$config,$g;
- conf_mount_rw();
- $do_sync=array();
- print "writing to database...";
- foreach ($days as $day)
- if (strlen($stm[$day]) > 10){
- if ($config['installedpackages']['postfixsync']['config'][0])
- foreach ($config['installedpackages']['postfixsync']['config'] as $rs )
- foreach($rs['row'] as $sh){
- $sync_to_ip = $sh['ipaddress'];
- $sync_type = $sh['sync_type'];
- $password = $sh['password'];
- $sql_file='/var/db/postfix/'.$sync_to_ip.'.sql';
- ${$sync_to_ip}="";
- if (file_exists($sql_file))
- ${$sync_to_ip}=file_get_contents($sql_file);
- if ($sync_to_ip && $sync_type=="share"){
- ${$sync_to_ip}.=serialize(array('day'=> $day,'sql'=> base64_encode(gzcompress($stm[$day]."COMMIT;",9))))."\n";
- if (! in_array($sync_to_ip,$do_sync))
- $do_sync[]=$sync_to_ip;
- }
- }
- #write local db file
- create_db($day.".db");
- if ($debug=true)
- print " writing to local db $day...";
- $dbhandle = sqlite_open($postfix_dir.$day.".db", 0666, $error);
- if (!$dbhandle) die ($error);
- #file_put_contents("/tmp/".$key.'-'.$update['day'].".sql",gzuncompress(base64_decode($update['sql'])), LOCK_EX);
- $ok = sqlite_exec($dbhandle, $stm[$day]."COMMIT;", $error);
- if (!$ok){
- if ($debug=true)
- print ("Cannot execute query. $error\n".$stm[$day]."COMMIT;\n");
- }
- else{
- if ($debug=true)
- print "ok\n";
- }
- sqlite_close($dbhandle);
- }
- #write update sql files
- if (count ($do_sync) > 0 ){
-
- foreach($do_sync as $ip)
- file_put_contents('/var/db/postfix/'.$ip.'.sql',${$ip},LOCK_EX);
- conf_mount_ro();
- }
- #write local file
-
-}
-
-function create_db($postfix_db){
- global $postfix_dir,$postfix_arg;
- if (! is_dir($postfix_dir))
- mkdir($postfix_dir,0775);
- $new_db=(file_exists($postfix_dir.$postfix_db)?1:0);
-$stm = <<<EOF
- CREATE TABLE "mail_from"(
- "id" INTEGER PRIMARY KEY,
- "sid" VARCHAR(11) NOT NULL,
- "client" TEXT NOT NULL,
- "msgid" TEXT,
- "fromm" TEXT,
- "size" INTEGER,
- "subject" TEXT,
- "date" TEXT NOT NULL,
- "server" TEXT,
- "helo" TEXT
-);
- CREATE TABLE "mail_to"(
- "id" INTEGER PRIMARY KEY,
- "from_id" INTEGER NOT NULL,
- "too" TEXT,
- "status" INTEGER,
- "status_info" TEXT,
- "smtp" TEXT,
- "delay" TEXT,
- "relay" TEXT,
- "dsn" TEXT,
- "server" TEXT,
- "bounce" TEXT,
- FOREIGN KEY (status) REFERENCES mail_status(id),
- FOREIGN KEY (from_id) REFERENCES mail_from(id)
-);
-
-
-CREATE TABLE "mail_status"(
- "id" INTEGER PRIMARY KEY,
- "info" varchar(35) NOT NULL
-);
-
-CREATE TABLE "mail_noqueue"(
- "id" INTEGER PRIMARY KEY,
- "date" TEXT NOT NULL,
- "server" TEXT NOT NULL,
- "status" TEXT NOT NULL,
- "status_info" INTEGER NOT NULL,
- "fromm" TEXT NOT NULL,
- "too" TEXT NOT NULL,
- "helo" TEXT NOT NULL
-);
-
-CREATE TABLE "db_version"(
- "value" varchar(10),
- "info" TEXT
-);
-
-insert or ignore into db_version ('value') VALUES ('2.3.1');
-
-CREATE INDEX "noqueue_unique" on mail_noqueue (date ASC, fromm ASC, too ASC);
-CREATE INDEX "noqueue_helo" on mail_noqueue (helo ASC);
-CREATE INDEX "noqueue_too" on mail_noqueue (too ASC);
-CREATE INDEX "noqueue_fromm" on mail_noqueue (fromm ASC);
-CREATE INDEX "noqueue_info" on mail_noqueue (status_info ASC);
-CREATE INDEX "noqueue_status" on mail_noqueue (status ASC);
-CREATE INDEX "noqueue_server" on mail_noqueue (server ASC);
-CREATE INDEX "noqueue_date" on mail_noqueue (date ASC);
-
-CREATE UNIQUE INDEX "status_info" on mail_status (info ASC);
-
-CREATE UNIQUE INDEX "from_sid_server" on mail_from (sid ASC,server ASC);
-CREATE INDEX "from_client" on mail_from (client ASC);
-CREATE INDEX "from_helo" on mail_from (helo ASC);
-CREATE INDEX "from_server" on mail_from (server ASC);
-CREATE INDEX "from_subject" on mail_from (subject ASC);
-CREATE INDEX "from_msgid" on mail_from (msgid ASC);
-CREATE INDEX "from_fromm" on mail_from (fromm ASC);
-CREATE INDEX "from_date" on mail_from (date ASC);
-
-CREATE UNIQUE INDEX "mail_to_unique" on mail_to (from_id ASC, too ASC);
-CREATE INDEX "to_bounce" on mail_to (bounce ASC);
-CREATE INDEX "to_relay" on mail_to (relay ASC);
-CREATE INDEX "to_smtp" on mail_to (smtp ASC);
-CREATE INDEX "to_info" on mail_to (status_info ASC);
-CREATE INDEX "to_status" on mail_to (status ASC);
-CREATE INDEX "to_too" on mail_to (too ASC);
-
-EOF;
-#test file version
-print "checking". $postfix_dir.$postfix_db."\n";
-$dbhandle = sqlite_open($postfix_dir.$postfix_db, 0666, $error);
-if (!$dbhandle) die ($error);
-$ok = sqlite_exec($dbhandle,"select value from db_version", $error);
-sqlite_close($dbhandle);
-if (!$ok){
- print "delete previous table version\n";
- if (file_exists($postfix_dir.$postfix_db))
- unlink($postfix_dir.$postfix_db);
- $new_db=0;
-}
-if ($new_db==0){
- $dbhandle = sqlite_open($postfix_dir.$postfix_db, 0666, $error);
- $ok = sqlite_exec($dbhandle, $stm, $error);
- if (!$ok)
- print ("Cannot execute query. $error\n");
- $ok = sqlite_exec($dbhandle, $stm2, $error);
- if (!$ok)
- print ("Cannot execute query. $error\n");
- sqlite_close($dbhandle);
- }
-}
-
-$postfix_dir="/var/db/postfix/";
-$curr_time = time();
-#console script call
-if ($argv[1]!=""){
-switch ($argv[1]){
- case "01min":
- $postfix_arg=array( 'grep' => array(date("H:i",strtotime('-1 min',$curr_time))),
- 'time' => '-1 min');
- break;
- case "10min":
- $postfix_arg=array( 'grep' => array(substr(date("H:i",strtotime('-10 min',$curr_time)),0,-1)),
- 'time' => '-10 min');
- break;
- case "01hour":
- $postfix_arg=array( 'grep' => array(date("H:",strtotime('-01 hour',$curr_time))),
- 'time' => '-01 hour');
- break;
- case "04hour":
- $postfix_arg=array( 'grep' => array(date("H:",strtotime('-04 hour',$curr_time)),date("H:",strtotime('-03 hour',$curr_time)),
- date("H:",strtotime('-02 hour',$curr_time)),date("H:",strtotime('-01 hour',$curr_time))),
- 'time' => '-04 hour');
- break;
- case "24hours":
- $postfix_arg=array( 'grep' => array('00:','01:','02:','03:','04:','05:','06:','07:','08:','09:','10:','11:',
- '12:','13:','14:','15:','16:','17:','18:','19:','20:','21:','22:','23:'),
- 'time' => '-01 day');
- break;
- case "02days":
- $postfix_arg=array( 'grep' => array('00:','01:','02:','03:','04:','05:','06:','07:','08:','09:','10:','11:',
- '12:','13:','14:','15:','16:','17:','18:','19:','20:','21:','22:','23:'),
- 'time' => '-02 day');
- break;
- case "03days":
- $postfix_arg=array( 'grep' => array('00:','01:','02:','03:','04:','05:','06:','07:','08:','09:','10:','11:',
- '12:','13:','14:','15:','16:','17:','18:','19:','20:','21:','22:','23:'),
- 'time' => '-03 day');
- break;
-
- default:
- die ("invalid parameters\n");
-}
-# get remote log from remote server
-get_remote_log();
-# get local log from logfile
-grep_log();
-}
-
-#http client call
-if ($_REQUEST['files']!= ""){
- #do search
- if($_REQUEST['queue']=="QUEUE"){
- $stm="select * from mail_from, mail_to ,mail_status where mail_from.id=mail_to.from_id and mail_to.status=mail_status.id ";
- $last_next=" and ";
- }
- else{
- $stm="select * from mail_noqueue";
- $last_next=" where ";
- }
- $limit_prefix=(preg_match("/\d+/",$_REQUEST['limit'])?"limit ":"");
- $limit=(preg_match("/\d+/",$_REQUEST['limit'])?$_REQUEST['limit']:"");
- $files= explode(",", $_REQUEST['files']);
- $stm_fetch=array();
- $total_result=0;
- foreach ($files as $postfix_db)
- if (file_exists($postfix_dir.'/'.$postfix_db)){
- $dbhandle = sqlite_open($postfix_dir.'/'.$postfix_db, 0666, $error);
- if ($_REQUEST['from']!= ""){
- $next=($last_next==" and "?" and ":" where ");
- $last_next=" and ";
- if (preg_match('/\*/',$_REQUEST['from']))
- $stm .=$next."fromm like '".preg_replace('/\*/','%',$_REQUEST['from'])."'";
- else
- $stm .=$next."fromm in('".$_REQUEST['from']."')";
- }
- if ($_REQUEST['to']!= ""){
- $next=($last_next==" and "?" and ":" where ");
- $last_next=" and ";
- if (preg_match('/\*/',$_REQUEST['to']))
- $stm .=$next."too like '".preg_replace('/\*/','%',$_REQUEST['to'])."'";
- else
- $stm .=$next."too in('".$_REQUEST['to']."')";
- }
- if ($_REQUEST['sid']!= "" && $_REQUEST['queue']=="QUEUE"){
- $next=($last_next==" and "?" and ":" where ");
- $last_next=" and ";
- $stm .=$next."sid in('".$_REQUEST['sid']."')";
- }
- if ($_REQUEST['relay']!= "" && $_REQUEST['queue']=="QUEUE"){
- $next=($last_next==" and "?" and ":" where ");
- $last_next=" and ";
- if (preg_match('/\*/',$_REQUEST['subject']))
- $stm .=$next."relay like '".preg_replace('/\*/','%',$_REQUEST['relay'])."'";
- else
- $stm .=$next."relay = '".$_REQUEST['relay']."'";
- }
- if ($_REQUEST['subject']!= "" && $_REQUEST['queue']=="QUEUE"){
- $next=($last_next==" and "?" and ":" where ");
- $last_next=" and ";
- if (preg_match('/\*/',$_REQUEST['subject']))
- $stm .=$next."subject like '".preg_replace('/\*/','%',$_REQUEST['subject'])."'";
- else
- $stm .=$next."subject = '".$_REQUEST['subject']."'";
- }
- if ($_REQUEST['msgid']!= "" && $_REQUEST['queue']=="QUEUE"){
- $next=($last_next==" and "?" and ":" where ");
- $last_next=" and ";
- if (preg_match('/\*/',$_REQUEST['msgid']))
- $stm .=$next."msgid like '".preg_replace('/\*/','%',$_REQUEST['msgid'])."'";
- else
- $stm .=$next."msgid = '".$_REQUEST['msgid']."'";
- }
- if ($_REQUEST['server']!= "" ){
- $next=($last_next==" and "?" and ":" where ");
- $last_next=" and ";
- if( $_REQUEST['queue']=="QUEUE")
- $stm .=$next."mail_from.server = '".$_REQUEST['server']."'";
- else
- $stm .=$next."server = '".$_REQUEST['server']."'";
- }
-
- if ($_REQUEST['status']!= ""){
- $next=($last_next==" and "?" and ":" where ");
- $last_next=" and ";
- $stm .=$next."mail_status.info = '".$_REQUEST['status']."'";
- }
- #print "<pre>".$stm;
- #$stm = "select * from mail_to,mail_status where mail_to.status=mail_status.id";
- $result = sqlite_query($dbhandle, $stm." order by date desc $limit_prefix $limit ");
- #$result = sqlite_query($dbhandle, $stm." $limit_prefix $limit ");
- if (preg_match("/\d+/",$_REQUEST['limit'])){
- for ($i = 1; $i <= $limit; $i++) {
- $row = sqlite_fetch_array($result, SQLITE_ASSOC);
- if (is_array($row))
- $stm_fetch[]=$row;
- }
- }
- else{
- $stm_fetch = sqlite_fetch_all($result, SQLITE_ASSOC);
- }
- sqlite_close($dbhandle);
- }
- $fields= explode(",", $_REQUEST['fields']);
- if ($_REQUEST['sbutton']=='export'){
- print '<table class="tabcont" width="100%" border="0" cellpadding="8" cellspacing="0">';
- print '<tr><td colspan="'.count($fields).'" valign="top" class="listtopic">'.gettext("Search Results").'</td></tr>';
- print '<tr>';
- $header="";
- foreach ($stm_fetch as $mail){
- foreach ($mail as $key => $data){
- if (!preg_match("/$key/",$header))
- $header .= $key.",";
- $export.=preg_replace('/,/',"",$mail[$key]).",";
- }
- $export.= "\n";
- }
- print '<td class="tabcont"><textarea id="varnishlogs" rows="50" cols="100%">';
- print "This export is in csv format, paste it without this line on any software that handles csv files.\n\n".$header."\n".$export;
- print "</textarea></td></tr></table>";
- }
- else{
- if ($_REQUEST['queue']=="NOQUEUE"){
- print '<table class="tabcont" width="100%" border="0" cellpadding="8" cellspacing="0">';
- print '<tr><td colspan="'.count($fields).'" valign="top" class="listtopic">'.gettext("Search Results").'</td></tr>';
- print '<tr>';
- if(in_array("date",$fields))
- print '<td class="listlr"><strong>date</strong></td>';
- if(in_array("server",$fields))
- print '<td class="listlr"><strong>server</strong></td>';
- if(in_array("from",$fields))
- print '<td class="listlr"><strong>From</strong></td>';
- if(in_array("to",$fields))
- print '<td class="listlr"><strong>to</strong></td>';
- if(in_array("helo",$fields))
- print '<td class="listlr"><strong>Helo</strong></td>';
- if(in_array("status",$fields))
- print '<td class="listlr"><strong>Status</strong></td>';
- if(in_array("status_info",$fields))
- print '<td class="listlr"><strong>Status Info</strong></td>';
- print '</tr>';
- foreach ($stm_fetch as $mail){
- print '<tr>';
- if(in_array("date",$fields))
- print '<td class="listlr">'.$mail['date'].'</td>';
- if(in_array("server",$fields))
- print '<td class="listlr">'.$mail['server'].'</td>';
- if(in_array("from",$fields))
- print '<td class="listlr">'.$mail['fromm'].'</td>';
- if(in_array("to",$fields))
- print '<td class="listlr">'.$mail['too'].'</td>';
- if(in_array("helo",$fields))
- print '<td class="listlr">'.$mail['helo'].'</td>';
- if(in_array("status",$fields))
- print '<td class="listlr">'.$mail['status'].'</td>';
- if(in_array("status_info",$fields))
- print '<td class="listlr">'.$mail['status_info'].'</td>';
- print '</tr>';
- $total_result++;
- }
- }
- else{
- print '<table class="tabcont" width="100%" border="0" cellpadding="8" cellspacing="0">';
- print '<tr><td colspan="'.count($fields).'" valign="top" class="listtopic">'.gettext("Search Results").'</td></tr>';
- print '<tr>';
- if(in_array("date",$fields))
- print '<td class="listlr" ><strong>Date</strong></td>';
- if(in_array("server",$fields))
- print '<td class="listlr" ><strong>Server</strong></td>';
- if(in_array("from",$fields))
- print '<td class="listlr" ><strong>From</strong></td>';
- if(in_array("to",$fields))
- print '<td class="listlr" ><strong>to</strong></td>';
- if(in_array("subject",$fields))
- print '<td class="listlr" ><strong>Subject</strong></td>';
- if(in_array("delay",$fields))
- print '<td class="listlr" ><strong>Delay</strong></td>';
- if(in_array("status",$fields))
- print '<td class="listlr" ><strong>Status</strong></td>';
- if(in_array("status_info",$fields))
- print '<td class="listlr" ><strong>Status Info</strong></td>';
- if(in_array("size",$fields))
- print '<td class="listlr" ><strong>Size</strong></td>';
- if(in_array("helo",$fields))
- print '<td class="listlr" ><strong>Helo</strong></td>';
- if(in_array("sid",$fields))
- print '<td class="listlr" ><strong>SID</strong></td>';
- if(in_array("msgid",$fields))
- print '<td class="listlr" ><strong>MSGID</strong></td>';
- if(in_array("bounce",$fields))
- print '<td class="listlr" ><strong>Bounce</strong></td>';
- if(in_array("relay",$fields))
- print '<td class="listlr" ><strong>Relay</strong></td>';
- print '</tr>';
- foreach ($stm_fetch as $mail){
- if(in_array("date",$fields))
- print '<td class="listlr">'.$mail['mail_from.date'].'</td>';
- if(in_array("server",$fields))
- print '<td class="listlr">'.$mail['mail_from.server'].'</td>';
- if(in_array("from",$fields))
- print '<td class="listlr">'.$mail['mail_from.fromm'].'</td>';
- if(in_array("to",$fields))
- print '<td class="listlr">'.$mail['mail_to.too'].'</td>';
- if(in_array("subject",$fields))
- print '<td class="listlr">'.$mail['mail_from.subject'].'</td>';
- if(in_array("delay",$fields))
- print '<td class="listlr">'.$mail['mail_to.delay'].'</td>';
- if(in_array("status",$fields))
- print '<td class="listlr">'.$mail['mail_status.info'].'</td>';
- if(in_array("status_info",$fields))
- print '<td class="listlr">'.$mail['mail_to.status_info'].'</td>';
- if(in_array("size",$fields))
- print '<td class="listlr">'.$mail['mail_from.size'].'</td>';
- if(in_array("helo",$fields))
- print '<td class="listlr">'.$mail['mail_from.helo'].'</td>';
- if(in_array("sid",$fields))
- print '<td class="listlr">'.$mail['mail_from.sid'].'</td>';
- if(in_array("msgid",$fields))
- print '<td class="listlr">'.$mail['mail_from.msgid'].'</td>';
- if(in_array("bounce",$fields))
- print '<td class="listlr">'.$mail['mail_to.bounce'].'</td>';
- if(in_array("relay",$fields))
- print '<td class="listlr">'.$mail['mail_to.relay'].'</td>';
- print '</tr>';
- $total_result++;
- }
- }
- print '<tr>';
- print '<td ><strong>Total:</strong></td>';
- print '<td ><strong>'.$total_result.'</strong></td>';
- print '</tr>';
- print '</table>';
- }
-}
+<?php
+/*
+ postfix.php
+ part of pfSense (http://www.pfsense.com/)
+ Copyright (C) 2011 Marcello Coutinho <marcellocoutinho@gmail.com>
+ based on varnish_view_config.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+require_once("/etc/inc/util.inc");
+require_once("/etc/inc/functions.inc");
+require_once("/etc/inc/pkg-utils.inc");
+require_once("/etc/inc/globals.inc");
+require_once("/usr/local/pkg/postfix.inc");
+
+function get_remote_log(){
+ global $config,$g,$postfix_dir;
+ $curr_time = time();
+ $log_time=date('YmdHis',$curr_time);
+ #get protocol
+ if($config['system']['webgui']['protocol'] != "")
+ $synchronizetoip = $config['system']['webgui']['protocol']. "://";
+ #get port
+ $port = $config['system']['webgui']['port'];
+ #if port is empty lets rely on the protocol selection
+ if($port == "")
+ $port =($config['system']['webgui']['protocol'] == "http"?"80":"443");
+ $synchronizetoip .= $sync_to_ip;
+ if (is_array($config['installedpackages']['postfixsync']))
+ foreach($config['installedpackages']['postfixsync']['config'][0]['row'] as $sh){
+ $sync_to_ip = $sh['ipaddress'];
+ $sync_type = $sh['sync_type'];
+ $password = $sh['password'];
+ $file= '/var/db/postfix/'.$server.'.sql';
+ #get remote data
+ if ($sync_type=='fetch'){
+ $url= $synchronizetoip . $sync_to_ip;
+ print "$sync_to_ip $url, $port\n";
+ $method = 'pfsense.exec_php';
+ $execcmd = "require_once('/usr/local/www/postfix.php');\n";
+ $execcmd .= '$toreturn=get_sql('.$log_time.');';
+ /* assemble xmlrpc payload */
+ $params = array(XML_RPC_encode($password),
+ XML_RPC_encode($execcmd));
+ log_error("postfix get sql data from {$sync_to_ip}.");
+ $msg = new XML_RPC_Message($method, $params);
+ $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
+ $cli->setCredentials('admin', $password);
+ #$cli->setDebug(1);
+ $resp = $cli->send($msg, "250");
+ $a=$resp->value();
+ $errors=0;
+ #var_dump($sql);
+ foreach($a as $b)
+ foreach ($b as $c)
+ foreach ($c as $d)
+ foreach ($d as $e){
+ $update=unserialize($e['string']);
+ print $update['day']."\n";
+ if ($update['day'] != ""){
+ create_db($update['day'].".db");
+ if ($debug=true)
+ print $update['day'] ." writing from remote system to db...";
+ $dbhandle = sqlite_open($postfix_dir.'/'.$update['day'].".db", 0666, $error);
+ #file_put_contents("/tmp/".$key.'-'.$update['day'].".sql",gzuncompress(base64_decode($update['sql'])), LOCK_EX);
+ $ok = sqlite_exec($dbhandle, gzuncompress(base64_decode($update['sql'])), $error);
+ if (!$ok){
+ $errors++;
+ die ("Cannot execute query. $error\n".$update['sql']."\n");
+ }
+ else{
+ if ($debug=true)
+ print "ok\n";
+ }
+ sqlite_close($dbhandle);
+ }
+ }
+ if ($errors ==0){
+ $method = 'pfsense.exec_php';
+ $execcmd = "require_once('/usr/local/www/postfix.php');\n";
+ $execcmd .= 'flush_sql('.$log_time.');';
+ /* assemble xmlrpc payload */
+ $params = array(XML_RPC_encode($password),
+ XML_RPC_encode($execcmd));
+ log_error("postfix flush sql buffer file from {$sync_to_ip}.");
+ $msg = new XML_RPC_Message($method, $params);
+ $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
+ $cli->setCredentials('admin', $password);
+ #$cli->setDebug(1);
+ $resp = $cli->send($msg, "250");
+ }
+ }
+ }
+}
+function get_sql($log_time){
+ global $config,$xmlrpc_g;
+ $server=$_SERVER['REMOTE_ADDR'];
+
+ if (is_array($config['installedpackages']['postfixsync']))
+ foreach($config['installedpackages']['postfixsync']['config'][0]['row'] as $sh){
+ $sync_to_ip = $sh['ipaddress'];
+ $sync_type = $sh['sync_type'];
+ $password = $sh['password'];
+ $file= '/var/db/postfix/'.$server.'.sql';
+ if ($sync_to_ip==$server && $sync_type=='share' && file_exists($file)){
+ rename($file,$file.".$log_time");
+ return (file($file.".$log_time"));
+ }
+ }
+ return "";
+}
+
+function flush_sql($log_time){
+ if (preg_match("/\d+\.\d+\.\d+\.\d+/",$_SERVER['REMOTE_ADDR']))
+ unlink_if_exists('/var/db/postfix/'.$_SERVER['REMOTE_ADDR'].".sql.$log_time");
+}
+
+function grep_log(){
+ global $postfix_dir,$postfix_arg,$config,$g;
+
+ $total_lines=0;
+ $days=array();
+ $grep="\(MailScanner\|postfix.cleanup\|postfix.smtp\|postfix.error\|postfix.qmgr\)";
+ $curr_time = time();
+ $log_time=strtotime($postfix_arg['time'],$curr_time);
+ $m=date('M',strtotime($postfix_arg['time'],$curr_time));
+ $j=substr(" ".date('j',strtotime($postfix_arg['time'],$curr_time)),-3);
+ # file grep loop
+ foreach ($postfix_arg['grep'] as $hour){
+ print "/usr/bin/grep '^".$m.$j." ".$hour.".*".$grep."' /var/log/maillog\n";
+ $lists=array();
+ exec("/usr/bin/grep " . escapeshellarg('^'.$m.$j." ".$hour.".*".$grep)." /var/log/maillog", $lists);
+ foreach ($lists as $line){
+ #check where is first mail record
+ if (preg_match("/ delay=(\d+)/",$line,$delay)){
+ $day=date("Y-m-d",strtotime("-".$delay[1]." second",$log_time));
+ if (! in_array($day,$days)){
+ $days[]=$day;
+ create_db($day.".db");
+ print "Found logs to $day.db\n";
+ $stm_queue[$day]="BEGIN;\n";
+ $stm_noqueue[$day]="BEGIN;\n";
+ }
+ }
+ else{
+ $day=date("Y-m-d",strtotime($postfix_arg['time'],$curr_time));
+ if (! in_array($day,$days)){
+ $days[]=$day;
+ create_db($day.".db");
+ print "Found logs to $day.db\n";
+ $stm_queue[$day]="BEGIN;\n";
+ $stm_noqueue[$day]="BEGIN;\n";
+ }
+ }
+ $status=array();
+ $total_lines++;
+ #Nov 8 09:31:50 srvch011 postfix/smtpd[43585]: 19C281F59C8: client=pm03-974.auinmem.br[177.70.0.3]
+ if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.smtpd\W\d+\W+(\w+): client=(.*)/",$line,$email)){
+ $values="'".$email[3]."','".$email[1]."','".$email[2]."','".$email[4]."'";
+ if(${$email[3]}!=$email[3])
+ $stm_queue[$day].='insert or ignore into mail_from(sid,date,server,client) values ('.$values.');'."\n";
+ ${$email[3]}=$email[3];
+ }
+ #Dec 2 22:21:18 pfsense MailScanner[60670]: Requeue: 8DC3BBDEAF.A29D3 to 5AD9ABDEB5
+ else if (preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) MailScanner.*Requeue: (\w+)\W\w+ to (\w+)/",$line,$email)){
+ $stm_queue[$day].= "update or ignore mail_from set sid='".$email[4]."' where sid='".$email[3]."';\n";
+ }
+ #Dec 5 14:06:10 srvchunk01 MailScanner[19589]: Message 775201F44B1.AED2C from 209.185.111.50 (marcellocoutinho@mailtest.com) to sede.mail.test.com is spam, SpamAssassin (not cached, escore=99.202, requerido 6, autolearn=spam, DKIM_SIGNED 0.10, DKIM_VALID -0.10, DKIM_VALID_AU -0.10, FREEMAIL_FROM 0.00, HTML_MESSAGE 0.00, RCVD_IN_DNSWL_LOW -0.70, WORM_TEST2 100.00)
+ else if (preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) MailScanner\W\d+\W+\w+\s+(\w+).* is spam, (.*)/",$line,$email)){
+ $stm_queue[$day].= "insert or ignore into mail_status (info) values ('spam');\n";
+ print "\n#######################################\nSPAM:".$email[4].$email[3].$email[2]."\n#######################################\n";
+ $stm_queue[$day].= "update or ignore mail_to set status=(select id from mail_status where info='spam'), status_info='".preg_replace("/(\<|\>|\s+|\'|\")/"," ",$email[4])."' where from_id in (select id from mail_from where sid='".$email[3]."' and server='".$email[2]."');\n";
+ }
+ #Nov 14 09:29:32 srvch011 postfix/error[58443]: 2B8EB1F5A5A: to=<hildae.sva@pi.email.com>, relay=none, delay=0.66, delays=0.63/0/0/0.02, dsn=4.4.3, status=deferred (delivery temporarily suspended: Host or domain name not found. Name service error for name=mail.pi.test.com type=A: Host not found, try again)
+ #Nov 3 21:45:32 srvch011 postfix/smtp[18041]: 4CE321F4887: to=<viinil@vitive.com.br>, relay=smtpe1.eom[81.00.20.9]:25, delay=1.9, delays=0.06/0.01/0.68/1.2, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 2C33E2382C8)
+ #Nov 16 00:00:14 srvch011 postfix/smtp[7363]: 7AEB91F797D: to=<alessandra.bueno@mg.test.com>, relay=mail.mg.test.com[172.25.3.5]:25, delay=39, delays=35/1.1/0.04/2.7, dsn=5.7.1, status=bounced (host mail.mg.test.com[172.25.3.5] said: 550 5.7.1 Unable to relay for alessandra.bueno@mg.test.com (in reply to RCPT TO command))
+ else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.\w+\W\d+\W+(\w+): to=\<(.*)\>, relay=(.*), delay=([0-9,.]+), .* dsn=([0-9,.]+), status=(\w+) (.*)/",$line,$email)){
+ $stm_queue[$day].= "insert or ignore into mail_status (info) values ('".$email[8]."');\n";
+ $stm_queue[$day].= "insert or ignore into mail_to (from_id,too,status,status_info,relay,delay,dsn) values ((select id from mail_from where sid='".$email[3]."' and server='".$email[2]."'),'".strtolower($email[4])."',(select id from mail_status where info='".$email[8]."'),'".preg_replace("/(\<|\>|\s+|\'|\")/"," ",$email[9])."','".$email[5]."','".$email[6]."','".$email[7]."');\n";
+ $stm_queue[$day].= "update or ignore mail_to set status=(select id from mail_status where info='".$email[8]."'), status_info='".preg_replace("/(\<|\>|\s+|\'|\")/"," ",$email[9])."', dsn='".$email[7]."', delay='".$email[6]."', relay='".$email[5]."', too='".strtolower($email[4])."' where from_id in (select id from mail_from where sid='".$email[3]."' and server='".$email[2]."');\n";
+ }
+ #Nov 13 01:48:44 srvch011 postfix/cleanup[16914]: D995B1F570B: message-id=<61.40.11745.10E3FBE4@ofertas6>
+ else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.cleanup\W\d+\W+(\w+): message-id=\<(.*)\>/",$line,$email)){
+ $stm_queue[$day].="update mail_from set msgid='".$email[4]."' where sid='".$email[3]."';\n";
+ }
+ #Nov 14 02:40:05 srvch011 postfix/qmgr[46834]: BC5931F4F13: from=<ceag@mx.crmcom.br>, size=32727, nrcpt=1 (queue active)
+ else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.qmgr\W\d+\W+(\w+): from=\<(.*)\>\W+size=(\d+)/",$line,$email)){
+ $stm_queue[$day].= "update mail_from set fromm='".strtolower($email[4])."', size='".$email[5]."' where sid='".$email[3]."';\n";
+ }
+ #Nov 13 00:09:07 srvch011 postfix/bounce[56376]: 9145C1F67F7: sender non-delivery notification: D5BD31F6865
+ #else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.bounce\W\d+\W+(\w+): sender non-delivery notification: (\w+)/",$line,$email)){
+ # $stm_queue[$day].= "update mail_queue set bounce='".$email[4]."' where sid='".$email[3]."';\n";
+ #}
+ #Nov 14 01:41:44 srvch011 postfix/smtpd[15259]: warning: 1EF3F1F573A: queue file size limit exceeded
+ else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.smtpd\W\d+\W+warning: (\w+): queue file size limit exceeded/",$line,$email)){
+ $stm_queue[$day].= "insert or ignore into mail_status (info) values ('".$email[8]."');\n";
+ $stm_queue[$day].= "update mail_to set status=(select id from mail_status where info='reject'), status_info='queue file size limit exceeded' where from_id in (select id from mail_from where sid='".$email[3]."' and server='".$email[2]."');\n";
+ }
+
+ #Nov 9 02:14:57 srvch011 postfix/cleanup[6856]: 617A51F5AC5: warning: header Subject: Mapeamento de Processos from lxalpha.12b.com.br[66.109.29.225]; from=<apache@lxalpha.12b.com.br> to=<ritiele.faria@mail.test.com> proto=ESMTP helo=<lxalpha.12b.com.br>
+ #Nov 8 09:31:50 srvch011 postfix/cleanup[11471]: 19C281F59C8: reject: header From: "Giuliana Flores - Parceiro do Grupo Virtual" <publicidade@parceiro-grupovirtual.com.br> from pm03-974.auinmeio.com.br[177.70.232.225]; from=<publicidade@parceiro-grupovirtual.com.br> to=<jorge.lustosa@mail.test.com> proto=ESMTP helo=<pm03-974.auinmeio.com.br>: 5.7.1 [SN007]
+ #Nov 13 00:03:24 srvch011 postfix/cleanup[4192]: 8A5B31F52D2: reject: body http://platform.roastcrack.info/mj0ie6p-48qtiyq from move2.igloojack.info[173.239.63.16]; from=<ljmd6u8lrxke4@move2.igloojack.info> to=<edileva@aasdf..br> proto=SMTP helo=<move2.igloojack.info>: 5.7.1 [BD040]
+ #Nov 14 01:41:35 srvch011 postfix/cleanup[58446]: 1EF3F1F573A: warning: header Subject: =?windows-1252?Q?IMOVEL_Voc=EA_=E9_um_Cliente_especial_da_=93CENTURY21=22?=??=?windows-1252?Q?Veja_o_que_tenho_para_voc=EA?= from mail-yw0-f51.google.com[209.85.213.51]; from=<sergioalexandre6308@gmail.com> to=<sinza@tr.br> proto=ESMTP helo=<mail-yw0-f51.google.com>
+ else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.cleanup\W\d+\W+(\w+): (\w+): (.*) from ([a-z,A-Z,0-9,.,-]+)\W([0-9,.]+)\W+from=\<(.*)\> to=\<(.*)\>.*helo=\W([a-z,A-Z,0-9,.,-]+)(.*)/",$line,$email)){
+ $status['date']=$email[1];
+ $status['server']=$email[2];
+ $status['sid']=$email[3];
+ $status['remote_hostname']=$email[6];
+ $status['remote_ip']=$email[7];
+ $status['from']=$email[8];
+ $status['to']=$email[9];
+ $status['helo']=$email[10];
+ $status['status']=$email[4];
+ $stm_queue[$day].= "insert or ignore into mail_status (info) values ('".$email[4]."');\n";
+ if ($email[4] =="warning"){
+ if (${$status['sid']}=='hold'){
+ $status['status']='hold';
+ }
+ else{
+ $status['status']='incoming';
+ $stm_queue[$day].= "insert or ignore into mail_status (info) values ('".$status['status']."');\n";
+ }
+ #print "$line\n";
+ $status['status_info']=preg_replace("/(\<|\>|\s+|\'|\")/"," ",$email[11]);
+ $status['subject']=preg_replace("/header Subject: /","",$email[5]);
+ $status['subject']=preg_replace("/(\<|\>|\s+|\'|\")/"," ",$status['subject']);
+ $stm_queue[$day].="update mail_from set subject='".$status['subject']."', fromm='".strtolower($status['from'])."',helo='".$status['helo']."' where sid='".$status['sid']."';\n";
+ $stm_queue[$day].="insert or ignore into mail_to (from_id,too,status,status_info) VALUES ((select id from mail_from where sid='".$email[3]."' and server='".$email[2]."'),'".strtolower($status['to'])."',(select id from mail_status where info='".$status['status']."'),'".$status['status_info']."');\n";
+ $stm_queue[$day].="update or ignore mail_to set status=(select id from mail_status where info='".$status['status']."'), status_info='".$status['status_info']."', too='".strtolower($status['to'])."' where from_id in (select id from mail_from where sid='".$status['sid']."' and server='".$email[2]."');\n";
+ }
+ else{
+ ${$status['sid']}=$status['status'];
+ $stm_queue[$day].="update mail_from set fromm='".strtolower($status['from'])."',helo='".$status['helo']."' where sid='".$status['sid']."';\n";
+ $status['status_info']=preg_replace("/(\<|\>|\s+|\'|\")/"," ",$email[5].$email[11]);
+ $stm_queue[$day].="insert or ignore into mail_to (from_id,too,status,status_info) VALUES ((select id from mail_from where sid='".$email[3]."' and server='".$email[2]."'),'".strtolower($status['to'])."',(select id from mail_status where info='".$email[4]."'),'".$status['status_info']."');\n";
+ $stm_queue[$day].="update or ignore mail_to set status=(select id from mail_status where info='".$email[4]."'), status_info='".$status['status_info']."', too='".strtolower($status['to'])."' where from_id in (select id from mail_from where sid='".$status['sid']."' and server='".$email[2]."');\n";
+ }
+ }
+ #Nov 9 02:14:34 srvch011 postfix/smtpd[38129]: NOQUEUE: reject: RCPT from unknown[201.36.0.7]: 450 4.7.1 Client host rejected: cannot find your hostname, [201.36.98.7]; from=<maladireta@esadcos.com.br> to=<sexec.09vara@go.domain.test.com> proto=ESMTP helo=<capri0.wb.com.br>
+ else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.smtpd\W\d+\W+NOQUEUE:\s+(\w+): (.*); from=\<(.*)\> to=\<(.*)\>.*helo=\<(.*)\>/",$line,$email)){
+ $status['date']=$email[1];
+ $status['server']=$email[2];
+ $status['status']=$email[3];
+ $status['status_info']=$email[4];
+ $status['from']=$email[5];
+ $status['to']=$email[6];
+ $status['helo']=$email[7];
+ $values="'".$status['date']."','".$status['status']."','".$status['status_info']."','".strtolower($status['from'])."','".strtolower($status['to'])."','".$status['helo']."','".$status['server']."'";
+ $stm_noqueue[$day].='insert or ignore into mail_noqueue(date,status,status_info,fromm,too,helo,server) values ('.$values.');'."\n";
+ }
+ if ($total_lines%1500 == 0){
+ #save log in database
+ write_db($stm_noqueue,"noqueue",$days);
+ write_db($stm_queue,"from",$days);
+ foreach ($days as $d){
+ $stm_noqueue[$d]="BEGIN;\n";
+ $stm_queue[$d]="BEGIN;\n";
+ }
+ }
+ if ($total_lines%1500 == 0)
+ print "$line\n";
+ }
+ #save log in database
+ write_db($stm_noqueue,"noqueue",$days);
+ write_db($stm_queue,"from",$days);
+ foreach ($days as $d){
+ $stm_noqueue[$d]="BEGIN;\n";
+ $stm_queue[$d]="BEGIN;\n";
+ }
+ }
+
+ $config=parse_xml_config("{$g['conf_path']}/config.xml", $g['xml_rootobj']);
+ print count($config['installedpackages']);
+ #start db replication if configured
+ if ($config['installedpackages']['postfixsync']['config'][0]['rsync'])
+ foreach ($config['installedpackages']['postfixsync']['config'] as $rs )
+ foreach($rs['row'] as $sh){
+ $sync_to_ip = $sh['ipaddress'];
+ $sync_type = $sh['sync_type'];
+ $password = $sh['password'];
+ print "checking replication to $sync_to_ip...";
+ if ($password && $sync_to_ip && preg_match("/(both|database)/",$sync_type))
+ postfix_do_xmlrpc_sync($sync_to_ip, $password,$sync_type);
+ print "ok\n";
+ }
+
+}
+
+function write_db($stm,$table,$days){
+ global $postfix_dir,$config,$g;
+ conf_mount_rw();
+ $do_sync=array();
+ print "writing to database...";
+ foreach ($days as $day)
+ if (strlen($stm[$day]) > 10){
+ if ($config['installedpackages']['postfixsync']['config'][0])
+ foreach ($config['installedpackages']['postfixsync']['config'] as $rs )
+ foreach($rs['row'] as $sh){
+ $sync_to_ip = $sh['ipaddress'];
+ $sync_type = $sh['sync_type'];
+ $password = $sh['password'];
+ $sql_file='/var/db/postfix/'.$sync_to_ip.'.sql';
+ ${$sync_to_ip}="";
+ if (file_exists($sql_file))
+ ${$sync_to_ip}=file_get_contents($sql_file);
+ if ($sync_to_ip && $sync_type=="share"){
+ ${$sync_to_ip}.=serialize(array('day'=> $day,'sql'=> base64_encode(gzcompress($stm[$day]."COMMIT;",9))))."\n";
+ if (! in_array($sync_to_ip,$do_sync))
+ $do_sync[]=$sync_to_ip;
+ }
+ }
+ #write local db file
+ create_db($day.".db");
+ if ($debug=true)
+ print " writing to local db $day...";
+ $dbhandle = sqlite_open($postfix_dir.$day.".db", 0666, $error);
+ if (!$dbhandle) die ($error);
+ #file_put_contents("/tmp/".$key.'-'.$update['day'].".sql",gzuncompress(base64_decode($update['sql'])), LOCK_EX);
+ $ok = sqlite_exec($dbhandle, $stm[$day]."COMMIT;", $error);
+ if (!$ok){
+ if ($debug=true)
+ print ("Cannot execute query. $error\n".$stm[$day]."COMMIT;\n");
+ }
+ else{
+ if ($debug=true)
+ print "ok\n";
+ }
+ sqlite_close($dbhandle);
+ }
+ #write update sql files
+ if (count ($do_sync) > 0 ){
+
+ foreach($do_sync as $ip)
+ file_put_contents('/var/db/postfix/'.$ip.'.sql',${$ip},LOCK_EX);
+ conf_mount_ro();
+ }
+ #write local file
+
+}
+
+function create_db($postfix_db){
+ global $postfix_dir,$postfix_arg;
+ if (! is_dir($postfix_dir))
+ mkdir($postfix_dir,0775);
+ $new_db=(file_exists($postfix_dir.$postfix_db)?1:0);
+$stm = <<<EOF
+ CREATE TABLE "mail_from"(
+ "id" INTEGER PRIMARY KEY,
+ "sid" VARCHAR(11) NOT NULL,
+ "client" TEXT NOT NULL,
+ "msgid" TEXT,
+ "fromm" TEXT,
+ "size" INTEGER,
+ "subject" TEXT,
+ "date" TEXT NOT NULL,
+ "server" TEXT,
+ "helo" TEXT
+);
+ CREATE TABLE "mail_to"(
+ "id" INTEGER PRIMARY KEY,
+ "from_id" INTEGER NOT NULL,
+ "too" TEXT,
+ "status" INTEGER,
+ "status_info" TEXT,
+ "smtp" TEXT,
+ "delay" TEXT,
+ "relay" TEXT,
+ "dsn" TEXT,
+ "server" TEXT,
+ "bounce" TEXT,
+ FOREIGN KEY (status) REFERENCES mail_status(id),
+ FOREIGN KEY (from_id) REFERENCES mail_from(id)
+);
+
+
+CREATE TABLE "mail_status"(
+ "id" INTEGER PRIMARY KEY,
+ "info" varchar(35) NOT NULL
+);
+
+CREATE TABLE "mail_noqueue"(
+ "id" INTEGER PRIMARY KEY,
+ "date" TEXT NOT NULL,
+ "server" TEXT NOT NULL,
+ "status" TEXT NOT NULL,
+ "status_info" INTEGER NOT NULL,
+ "fromm" TEXT NOT NULL,
+ "too" TEXT NOT NULL,
+ "helo" TEXT NOT NULL
+);
+
+CREATE TABLE "db_version"(
+ "value" varchar(10),
+ "info" TEXT
+);
+
+insert or ignore into db_version ('value') VALUES ('2.3.1');
+
+CREATE INDEX "noqueue_unique" on mail_noqueue (date ASC, fromm ASC, too ASC);
+CREATE INDEX "noqueue_helo" on mail_noqueue (helo ASC);
+CREATE INDEX "noqueue_too" on mail_noqueue (too ASC);
+CREATE INDEX "noqueue_fromm" on mail_noqueue (fromm ASC);
+CREATE INDEX "noqueue_info" on mail_noqueue (status_info ASC);
+CREATE INDEX "noqueue_status" on mail_noqueue (status ASC);
+CREATE INDEX "noqueue_server" on mail_noqueue (server ASC);
+CREATE INDEX "noqueue_date" on mail_noqueue (date ASC);
+
+CREATE UNIQUE INDEX "status_info" on mail_status (info ASC);
+
+CREATE UNIQUE INDEX "from_sid_server" on mail_from (sid ASC,server ASC);
+CREATE INDEX "from_client" on mail_from (client ASC);
+CREATE INDEX "from_helo" on mail_from (helo ASC);
+CREATE INDEX "from_server" on mail_from (server ASC);
+CREATE INDEX "from_subject" on mail_from (subject ASC);
+CREATE INDEX "from_msgid" on mail_from (msgid ASC);
+CREATE INDEX "from_fromm" on mail_from (fromm ASC);
+CREATE INDEX "from_date" on mail_from (date ASC);
+
+CREATE UNIQUE INDEX "mail_to_unique" on mail_to (from_id ASC, too ASC);
+CREATE INDEX "to_bounce" on mail_to (bounce ASC);
+CREATE INDEX "to_relay" on mail_to (relay ASC);
+CREATE INDEX "to_smtp" on mail_to (smtp ASC);
+CREATE INDEX "to_info" on mail_to (status_info ASC);
+CREATE INDEX "to_status" on mail_to (status ASC);
+CREATE INDEX "to_too" on mail_to (too ASC);
+
+EOF;
+#test file version
+print "checking". $postfix_dir.$postfix_db."\n";
+$dbhandle = sqlite_open($postfix_dir.$postfix_db, 0666, $error);
+if (!$dbhandle) die ($error);
+$ok = sqlite_exec($dbhandle,"select value from db_version", $error);
+sqlite_close($dbhandle);
+if (!$ok){
+ print "delete previous table version\n";
+ if (file_exists($postfix_dir.$postfix_db))
+ unlink($postfix_dir.$postfix_db);
+ $new_db=0;
+}
+if ($new_db==0){
+ $dbhandle = sqlite_open($postfix_dir.$postfix_db, 0666, $error);
+ $ok = sqlite_exec($dbhandle, $stm, $error);
+ if (!$ok)
+ print ("Cannot execute query. $error\n");
+ $ok = sqlite_exec($dbhandle, $stm2, $error);
+ if (!$ok)
+ print ("Cannot execute query. $error\n");
+ sqlite_close($dbhandle);
+ }
+}
+
+$postfix_dir="/var/db/postfix/";
+$curr_time = time();
+#console script call
+if ($argv[1]!=""){
+switch ($argv[1]){
+ case "01min":
+ $postfix_arg=array( 'grep' => array(date("H:i",strtotime('-1 min',$curr_time))),
+ 'time' => '-1 min');
+ break;
+ case "10min":
+ $postfix_arg=array( 'grep' => array(substr(date("H:i",strtotime('-10 min',$curr_time)),0,-1)),
+ 'time' => '-10 min');
+ break;
+ case "01hour":
+ $postfix_arg=array( 'grep' => array(date("H:",strtotime('-01 hour',$curr_time))),
+ 'time' => '-01 hour');
+ break;
+ case "04hour":
+ $postfix_arg=array( 'grep' => array(date("H:",strtotime('-04 hour',$curr_time)),date("H:",strtotime('-03 hour',$curr_time)),
+ date("H:",strtotime('-02 hour',$curr_time)),date("H:",strtotime('-01 hour',$curr_time))),
+ 'time' => '-04 hour');
+ break;
+ case "24hours":
+ $postfix_arg=array( 'grep' => array('00:','01:','02:','03:','04:','05:','06:','07:','08:','09:','10:','11:',
+ '12:','13:','14:','15:','16:','17:','18:','19:','20:','21:','22:','23:'),
+ 'time' => '-01 day');
+ break;
+ case "02days":
+ $postfix_arg=array( 'grep' => array('00:','01:','02:','03:','04:','05:','06:','07:','08:','09:','10:','11:',
+ '12:','13:','14:','15:','16:','17:','18:','19:','20:','21:','22:','23:'),
+ 'time' => '-02 day');
+ break;
+ case "03days":
+ $postfix_arg=array( 'grep' => array('00:','01:','02:','03:','04:','05:','06:','07:','08:','09:','10:','11:',
+ '12:','13:','14:','15:','16:','17:','18:','19:','20:','21:','22:','23:'),
+ 'time' => '-03 day');
+ break;
+
+ default:
+ die ("invalid parameters\n");
+}
+# get remote log from remote server
+get_remote_log();
+# get local log from logfile
+grep_log();
+}
+
+#http client call
+if ($_REQUEST['files']!= ""){
+ #do search
+ if($_REQUEST['queue']=="QUEUE"){
+ $stm="select * from mail_from, mail_to ,mail_status where mail_from.id=mail_to.from_id and mail_to.status=mail_status.id ";
+ $last_next=" and ";
+ }
+ else{
+ $stm="select * from mail_noqueue";
+ $last_next=" where ";
+ }
+ $limit_prefix=(preg_match("/\d+/",$_REQUEST['limit'])?"limit ":"");
+ $limit=(preg_match("/\d+/",$_REQUEST['limit'])?$_REQUEST['limit']:"");
+ $files= explode(",", $_REQUEST['files']);
+ $stm_fetch=array();
+ $total_result=0;
+ foreach ($files as $postfix_db)
+ if (file_exists($postfix_dir.'/'.$postfix_db)){
+ $dbhandle = sqlite_open($postfix_dir.'/'.$postfix_db, 0666, $error);
+ if ($_REQUEST['from']!= ""){
+ $next=($last_next==" and "?" and ":" where ");
+ $last_next=" and ";
+ if (preg_match('/\*/',$_REQUEST['from']))
+ $stm .=$next."fromm like '".preg_replace('/\*/','%',$_REQUEST['from'])."'";
+ else
+ $stm .=$next."fromm in('".$_REQUEST['from']."')";
+ }
+ if ($_REQUEST['to']!= ""){
+ $next=($last_next==" and "?" and ":" where ");
+ $last_next=" and ";
+ if (preg_match('/\*/',$_REQUEST['to']))
+ $stm .=$next."too like '".preg_replace('/\*/','%',$_REQUEST['to'])."'";
+ else
+ $stm .=$next."too in('".$_REQUEST['to']."')";
+ }
+ if ($_REQUEST['sid']!= "" && $_REQUEST['queue']=="QUEUE"){
+ $next=($last_next==" and "?" and ":" where ");
+ $last_next=" and ";
+ $stm .=$next."sid in('".$_REQUEST['sid']."')";
+ }
+ if ($_REQUEST['relay']!= "" && $_REQUEST['queue']=="QUEUE"){
+ $next=($last_next==" and "?" and ":" where ");
+ $last_next=" and ";
+ if (preg_match('/\*/',$_REQUEST['subject']))
+ $stm .=$next."relay like '".preg_replace('/\*/','%',$_REQUEST['relay'])."'";
+ else
+ $stm .=$next."relay = '".$_REQUEST['relay']."'";
+ }
+ if ($_REQUEST['subject']!= "" && $_REQUEST['queue']=="QUEUE"){
+ $next=($last_next==" and "?" and ":" where ");
+ $last_next=" and ";
+ if (preg_match('/\*/',$_REQUEST['subject']))
+ $stm .=$next."subject like '".preg_replace('/\*/','%',$_REQUEST['subject'])."'";
+ else
+ $stm .=$next."subject = '".$_REQUEST['subject']."'";
+ }
+ if ($_REQUEST['msgid']!= "" && $_REQUEST['queue']=="QUEUE"){
+ $next=($last_next==" and "?" and ":" where ");
+ $last_next=" and ";
+ if (preg_match('/\*/',$_REQUEST['msgid']))
+ $stm .=$next."msgid like '".preg_replace('/\*/','%',$_REQUEST['msgid'])."'";
+ else
+ $stm .=$next."msgid = '".$_REQUEST['msgid']."'";
+ }
+ if ($_REQUEST['server']!= "" ){
+ $next=($last_next==" and "?" and ":" where ");
+ $last_next=" and ";
+ if( $_REQUEST['queue']=="QUEUE")
+ $stm .=$next."mail_from.server = '".$_REQUEST['server']."'";
+ else
+ $stm .=$next."server = '".$_REQUEST['server']."'";
+ }
+
+ if ($_REQUEST['status']!= ""){
+ $next=($last_next==" and "?" and ":" where ");
+ $last_next=" and ";
+ $stm .=$next."mail_status.info = '".$_REQUEST['status']."'";
+ }
+ #print "<pre>".$stm;
+ #$stm = "select * from mail_to,mail_status where mail_to.status=mail_status.id";
+ $result = sqlite_query($dbhandle, $stm." order by date desc $limit_prefix $limit ");
+ #$result = sqlite_query($dbhandle, $stm." $limit_prefix $limit ");
+ if (preg_match("/\d+/",$_REQUEST['limit'])){
+ for ($i = 1; $i <= $limit; $i++) {
+ $row = sqlite_fetch_array($result, SQLITE_ASSOC);
+ if (is_array($row))
+ $stm_fetch[]=$row;
+ }
+ }
+ else{
+ $stm_fetch = sqlite_fetch_all($result, SQLITE_ASSOC);
+ }
+ sqlite_close($dbhandle);
+ }
+ $fields= explode(",", $_REQUEST['fields']);
+ if ($_REQUEST['sbutton']=='export'){
+ print '<table class="tabcont" width="100%" border="0" cellpadding="8" cellspacing="0">';
+ print '<tr><td colspan="'.count($fields).'" valign="top" class="listtopic">'.gettext("Search Results").'</td></tr>';
+ print '<tr>';
+ $header="";
+ foreach ($stm_fetch as $mail){
+ foreach ($mail as $key => $data){
+ if (!preg_match("/$key/",$header))
+ $header .= $key.",";
+ $export.=preg_replace('/,/',"",$mail[$key]).",";
+ }
+ $export.= "\n";
+ }
+ print '<td class="tabcont"><textarea id="varnishlogs" rows="50" cols="100%">';
+ print "This export is in csv format, paste it without this line on any software that handles csv files.\n\n".$header."\n".$export;
+ print "</textarea></td></tr></table>";
+ }
+ else{
+ if ($_REQUEST['queue']=="NOQUEUE"){
+ print '<table class="tabcont" width="100%" border="0" cellpadding="8" cellspacing="0">';
+ print '<tr><td colspan="'.count($fields).'" valign="top" class="listtopic">'.gettext("Search Results").'</td></tr>';
+ print '<tr>';
+ if(in_array("date",$fields))
+ print '<td class="listlr"><strong>date</strong></td>';
+ if(in_array("server",$fields))
+ print '<td class="listlr"><strong>server</strong></td>';
+ if(in_array("from",$fields))
+ print '<td class="listlr"><strong>From</strong></td>';
+ if(in_array("to",$fields))
+ print '<td class="listlr"><strong>to</strong></td>';
+ if(in_array("helo",$fields))
+ print '<td class="listlr"><strong>Helo</strong></td>';
+ if(in_array("status",$fields))
+ print '<td class="listlr"><strong>Status</strong></td>';
+ if(in_array("status_info",$fields))
+ print '<td class="listlr"><strong>Status Info</strong></td>';
+ print '</tr>';
+ foreach ($stm_fetch as $mail){
+ print '<tr>';
+ if(in_array("date",$fields))
+ print '<td class="listlr">'.$mail['date'].'</td>';
+ if(in_array("server",$fields))
+ print '<td class="listlr">'.$mail['server'].'</td>';
+ if(in_array("from",$fields))
+ print '<td class="listlr">'.$mail['fromm'].'</td>';
+ if(in_array("to",$fields))
+ print '<td class="listlr">'.$mail['too'].'</td>';
+ if(in_array("helo",$fields))
+ print '<td class="listlr">'.$mail['helo'].'</td>';
+ if(in_array("status",$fields))
+ print '<td class="listlr">'.$mail['status'].'</td>';
+ if(in_array("status_info",$fields))
+ print '<td class="listlr">'.$mail['status_info'].'</td>';
+ print '</tr>';
+ $total_result++;
+ }
+ }
+ else{
+ print '<table class="tabcont" width="100%" border="0" cellpadding="8" cellspacing="0">';
+ print '<tr><td colspan="'.count($fields).'" valign="top" class="listtopic">'.gettext("Search Results").'</td></tr>';
+ print '<tr>';
+ if(in_array("date",$fields))
+ print '<td class="listlr" ><strong>Date</strong></td>';
+ if(in_array("server",$fields))
+ print '<td class="listlr" ><strong>Server</strong></td>';
+ if(in_array("from",$fields))
+ print '<td class="listlr" ><strong>From</strong></td>';
+ if(in_array("to",$fields))
+ print '<td class="listlr" ><strong>to</strong></td>';
+ if(in_array("subject",$fields))
+ print '<td class="listlr" ><strong>Subject</strong></td>';
+ if(in_array("delay",$fields))
+ print '<td class="listlr" ><strong>Delay</strong></td>';
+ if(in_array("status",$fields))
+ print '<td class="listlr" ><strong>Status</strong></td>';
+ if(in_array("status_info",$fields))
+ print '<td class="listlr" ><strong>Status Info</strong></td>';
+ if(in_array("size",$fields))
+ print '<td class="listlr" ><strong>Size</strong></td>';
+ if(in_array("helo",$fields))
+ print '<td class="listlr" ><strong>Helo</strong></td>';
+ if(in_array("sid",$fields))
+ print '<td class="listlr" ><strong>SID</strong></td>';
+ if(in_array("msgid",$fields))
+ print '<td class="listlr" ><strong>MSGID</strong></td>';
+ if(in_array("bounce",$fields))
+ print '<td class="listlr" ><strong>Bounce</strong></td>';
+ if(in_array("relay",$fields))
+ print '<td class="listlr" ><strong>Relay</strong></td>';
+ print '</tr>';
+ foreach ($stm_fetch as $mail){
+ if(in_array("date",$fields))
+ print '<td class="listlr">'.$mail['mail_from.date'].'</td>';
+ if(in_array("server",$fields))
+ print '<td class="listlr">'.$mail['mail_from.server'].'</td>';
+ if(in_array("from",$fields))
+ print '<td class="listlr">'.$mail['mail_from.fromm'].'</td>';
+ if(in_array("to",$fields))
+ print '<td class="listlr">'.$mail['mail_to.too'].'</td>';
+ if(in_array("subject",$fields))
+ print '<td class="listlr">'.$mail['mail_from.subject'].'</td>';
+ if(in_array("delay",$fields))
+ print '<td class="listlr">'.$mail['mail_to.delay'].'</td>';
+ if(in_array("status",$fields))
+ print '<td class="listlr">'.$mail['mail_status.info'].'</td>';
+ if(in_array("status_info",$fields))
+ print '<td class="listlr">'.$mail['mail_to.status_info'].'</td>';
+ if(in_array("size",$fields))
+ print '<td class="listlr">'.$mail['mail_from.size'].'</td>';
+ if(in_array("helo",$fields))
+ print '<td class="listlr">'.$mail['mail_from.helo'].'</td>';
+ if(in_array("sid",$fields))
+ print '<td class="listlr">'.$mail['mail_from.sid'].'</td>';
+ if(in_array("msgid",$fields))
+ print '<td class="listlr">'.$mail['mail_from.msgid'].'</td>';
+ if(in_array("bounce",$fields))
+ print '<td class="listlr">'.$mail['mail_to.bounce'].'</td>';
+ if(in_array("relay",$fields))
+ print '<td class="listlr">'.$mail['mail_to.relay'].'</td>';
+ print '</tr>';
+ $total_result++;
+ }
+ }
+ print '<tr>';
+ print '<td ><strong>Total:</strong></td>';
+ print '<td ><strong>'.$total_result.'</strong></td>';
+ print '</tr>';
+ print '</table>';
+ }
+}
?> \ No newline at end of file
diff --git a/config/postfix/postfix_antispam.xml b/config/postfix/postfix_antispam.xml
index c4772085..94f52f35 100644
--- a/config/postfix/postfix_antispam.xml
+++ b/config/postfix/postfix_antispam.xml
@@ -239,6 +239,22 @@
<description></description>
</field>
<field>
+ <fielddescr>Message Hold mode</fielddescr>
+ <fieldname>hold_mode</fieldname>
+ <description><![CDATA[Select how postfix will hold messages to mailscanner.<br>
+ When using auto mode, postfix will hold all messages.<br>
+ When using manual mode, include options like this in acl headers:<br>
+ /^to:.*admin@mydomain.com/ OK<br>
+ /^from:.*user@extdomain.com/ OK<br>
+ /^from:/ HOLD<br>
+ /^to:.*@mydomain.com/ HOLD]]></description>
+ <type>select</type>
+ <options>
+ <option><name>Auto mode</name><value>auto</value></option>
+ <option><name>Manual mode using ACLs</name><value>manual</value></option>
+ </options>
+ </field>
+ <field>
<fielddescr>Software</fielddescr>
<fieldname>antispam_software</fieldname>
<description>Select Third part solution to use. See postfix forwarder package info page for instaling instructions</description>
diff --git a/config/postfix/postfix_queue.php b/config/postfix/postfix_queue.php
index eaf6b7f5..ce4d6cc6 100755
--- a/config/postfix/postfix_queue.php
+++ b/config/postfix/postfix_queue.php
@@ -62,7 +62,7 @@ function get_cmd(){
}
if ($_REQUEST['cmd'] =='qshape'){
if ($_REQUEST['qshape']!="")
- exec("/usr/local/bin/qshape ". preg_replace("/\W/"," ",$_REQUEST['qshape']), $qshape);
+ exec("/usr/local/bin/qshape -".preg_replace("/\W/","",$_REQUEST['type'])." ". preg_replace("/\W/","",$_REQUEST['qshape']), $qshape);
else
exec("/usr/local/bin/qshape", $qshape);
print '<table class="tabcont" width="100%" border="0" cellpadding="8" cellspacing="0">';
@@ -167,6 +167,15 @@ else{
<option value="maildrop">maildrop</option>
</select><br><?=gettext("Select how often queue will be queried.");?></td>
</tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("qshape Report type: ");?></td>
+ <td width="78%" class="vtable">
+ <select name="drop3" id="qtype">
+ <option value="s" selected>sender domain</option>
+ <option value="p">parent domain</option>
+ </select><br><?=gettext("Select between sender or parent domains to order by.");?></td>
+ </tr>
+
<tr>
<td width="22%" valign="top"></td>
<td width="78%"><input name="Submit" type="button" class="formbtn" id="run" value="<?=gettext("show queue");?>" onclick="get_queue('mailq')"><div id="search_help"></div></td>
@@ -212,6 +221,7 @@ else{
var q_args=loopSelected('qshape');
var pars = 'cmd='+$('cmd').options[$('cmd').selectedIndex].value;
var pars = pars + '&qshape='+q_args;
+ var pars = pars + '&type='+$('qtype').options[$('qtype').selectedIndex].value;
var url = "/postfix_queue.php";
var myAjax = new Ajax.Request(
url,
diff --git a/config/postfix/postfix_search.php b/config/postfix/postfix_search.php
index b76f0554..c2da3f7e 100755
--- a/config/postfix/postfix_search.php
+++ b/config/postfix/postfix_search.php
@@ -119,6 +119,7 @@ include("head.inc");
<option value="sent">sent</option>
<option value="bounced">bounced</option>
<option value="reject">reject</option>
+ <option value="spam">spam</option>
<option value="incoming">incoming</option>
</select><br><?=gettext("Max log messages to fetch per Sqlite file.");?></td>
</tr>
id='n3234' href='#n3234'>3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918