@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | <?php |
3 | 3 | |
4 | 4 | if (PHP_SAPI != "cli") |
5 | - exit; |
|
5 | + exit; |
|
6 | 6 | |
7 | 7 | $home = '/var/www/html/RBL'; |
8 | 8 | require_once($home.'/config.php'); |
@@ -20,30 +20,30 @@ discard block |
||
20 | 20 | |
21 | 21 | $opts = getopt('f:t:'); |
22 | 22 | if ( isset($opts['f']) ) { |
23 | - $filetemplate = $opts['f']; |
|
23 | + $filetemplate = $opts['f']; |
|
24 | 24 | } else { |
25 | 25 | print "\nNo option for '-f' given.\n"; |
26 | - exit ( usage() ); |
|
26 | + exit ( usage() ); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | if ( isset($opts['t']) ) { |
30 | - $tablename = $opts['t']; |
|
30 | + $tablename = $opts['t']; |
|
31 | 31 | } else { |
32 | 32 | print "\nNo option for '-t' given.\n"; |
33 | - exit ( usage() ); |
|
33 | + exit ( usage() ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | if ( ($typedescN = array_search( $tablename, array_column($tables, 'name'))) === FALSE ) { |
37 | - print "\nDB <$tablename> doesn't exist!\n"; |
|
38 | - syslog (LOG_EMERG, "$user: DB <$tablename> doesn't exist!"); |
|
39 | - exit ( usage() ); |
|
37 | + print "\nDB <$tablename> doesn't exist!\n"; |
|
38 | + syslog (LOG_EMERG, "$user: DB <$tablename> doesn't exist!"); |
|
39 | + exit ( usage() ); |
|
40 | 40 | } |
41 | 41 | $typedesc = array_keys($tables)[$typedescN]; |
42 | 42 | |
43 | 43 | if (! file_exists($filetemplate) ) { |
44 | - print "\nFile <$filetemplate> doesn't exists!\n"; |
|
44 | + print "\nFile <$filetemplate> doesn't exists!\n"; |
|
45 | 45 | syslog (LOG_EMERG, "$user: File <$filetemplate> doesn't exist!"); |
46 | - exit ( usage() ); |
|
46 | + exit ( usage() ); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | if (! in_array( $typedesc, array_keys($tables) ) ) { |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | if (! $tables["$typedesc"]['active'] ) { |
55 | 55 | print "\nList <$typedesc> is not active. Please provide an active list name.\n"; |
56 | - exit ( usage() ); |
|
56 | + exit ( usage() ); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | |
74 | 74 | $mysqli = new mysqli($dbhost, $userdb, $pwd, $db, $dbport); |
75 | 75 | if ($mysqli->connect_error) { |
76 | - syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
77 | - . $mysqli->connect_error); |
|
78 | - exit ($user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
79 | - . $mysqli->connect_error); |
|
76 | + syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
77 | + . $mysqli->connect_error); |
|
78 | + exit ($user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
79 | + . $mysqli->connect_error); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | syslog(LOG_INFO, $user.': Successfully mysql connected to ' . $mysqli->host_info) ; |
@@ -87,14 +87,14 @@ discard block |
||
87 | 87 | while ($riga = $result->fetch_array(MYSQLI_ASSOC)) { |
88 | 88 | if (isListed($riga)) { |
89 | 89 | switch ( $tables["$typedesc"]['field'] ) { |
90 | - case 'ip': |
|
91 | - $element[] = long2ip($riga['ip']); |
|
92 | - break; |
|
93 | - case 'network': |
|
94 | - $element[] = long2ip($riga['network']).'/'.long2ip($riga['netmask']); |
|
95 | - break; |
|
96 | - default: |
|
97 | - $element[] = $riga["$type"]; |
|
90 | + case 'ip': |
|
91 | + $element[] = long2ip($riga['ip']); |
|
92 | + break; |
|
93 | + case 'network': |
|
94 | + $element[] = long2ip($riga['network']).'/'.long2ip($riga['netmask']); |
|
95 | + break; |
|
96 | + default: |
|
97 | + $element[] = $riga["$type"]; |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | } |
@@ -7,7 +7,7 @@ |
||
7 | 7 | print '<p>List of available Reports for '.date('l, d M Y', strtotime($theDate)).'</p><ul>'; |
8 | 8 | foreach($dir as $file) |
9 | 9 | { |
10 | - if ( basename($file) != basename(__FILE__) ) { |
|
10 | + if ( basename($file) != basename(__FILE__) ) { |
|
11 | 11 | $modalDiv = 'openModal'.basename($file); |
12 | 12 | echo '<li><a href="#'.$modalDiv.'">'.str_replace("-$theDate.html",'',basename($file)).'</a></li>'; |
13 | 13 | # echo '<li><pre><a href="'.basename($file).'" title="'.str_replace("-$theDate.html",'',basename($file))." of $theDate".'" onClick="Modalbox.show(this.href, {title: this.title, height: 600}); return false;">'.str_replace("-$theDate.html",'',basename($file)).'</a></pre></li>'; |
@@ -21,7 +21,7 @@ |
||
21 | 21 | <?php |
22 | 22 | $reports = array(); |
23 | 23 | foreach (glob("*.{htm,html}", GLOB_BRACE) as $filename) { |
24 | - $reports[$filename] = filemtime($filename); |
|
24 | + $reports[$filename] = filemtime($filename); |
|
25 | 25 | } |
26 | 26 | arsort($reports); |
27 | 27 | $newest = array_shift($reports); |
@@ -117,17 +117,17 @@ |
||
117 | 117 | |
118 | 118 | //check for leapyear |
119 | 119 | function is_leapyear($year){ |
120 | - return ($year % 4 == 0) ? |
|
121 | - !($year % 100 == 0 && $year % 400 <> 0) : false; |
|
122 | - } |
|
120 | + return ($year % 4 == 0) ? |
|
121 | + !($year % 100 == 0 && $year % 400 <> 0) : false; |
|
122 | + } |
|
123 | 123 | |
124 | 124 | //get the total day of each month in year |
125 | - function total_days($month,$year){ |
|
126 | - $days = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
125 | + function total_days($month,$year){ |
|
126 | + $days = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
127 | 127 | if($month > 0 && $year > 0){ |
128 | - return ($month == 2 && $this->is_leapYear($year)) ? 29 : $days[$month-1]; |
|
128 | + return ($month == 2 && $this->is_leapYear($year)) ? 29 : $days[$month-1]; |
|
129 | 129 | }else return 31; |
130 | - } |
|
130 | + } |
|
131 | 131 | |
132 | 132 | //Deprecate since v1.6 |
133 | 133 | function getDayNum($day){ |
@@ -5,10 +5,10 @@ discard block |
||
5 | 5 | include_once($path.'config.php'); |
6 | 6 | require_once($path.'function.php'); |
7 | 7 | if ( !isset($version) ) { |
8 | - openlog('myRBLemergency', LOG_PID, LOG_LOCAL0); |
|
9 | - syslog (LOG_EMERG, 'unknown: I can\'t read the config files. Do you have configured the $path in getip.php?'); |
|
10 | - closelog(); |
|
11 | - exit(255); |
|
8 | + openlog('myRBLemergency', LOG_PID, LOG_LOCAL0); |
|
9 | + syslog (LOG_EMERG, 'unknown: I can\'t read the config files. Do you have configured the $path in getip.php?'); |
|
10 | + closelog(); |
|
11 | + exit(255); |
|
12 | 12 | } |
13 | 13 | include_once(dirname(__FILE__) . '/function.php'); |
14 | 14 | $conf = parse_ini_file($confImap_file); |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | |
36 | 36 | /* check you select a right list */ |
37 | 37 | if ( !$tables[$conf['list']['spam']]['bl'] ) { |
38 | - syslog(LOG_EMERG, $conf['user'].': <'.$conf['list']['spam'].'> is not a blocklist. Are you stupid? Do you want to whitelist a spammer? I refuse to continue.'); |
|
39 | - exit (254); |
|
38 | + syslog(LOG_EMERG, $conf['user'].': <'.$conf['list']['spam'].'> is not a blocklist. Are you stupid? Do you want to whitelist a spammer? I refuse to continue.'); |
|
39 | + exit (254); |
|
40 | 40 | } |
41 | 41 | if ( $tables[$conf['list']['ham']]['bl'] ) { |
42 | - syslog(LOG_EMERG, $conf['user'].': <'.$conf['list']['ham'].'> is a blocklist. Are you stupid? Do you want to block a legitimate sender? I refuse to continue.'); |
|
43 | - exit (254); |
|
42 | + syslog(LOG_EMERG, $conf['user'].': <'.$conf['list']['ham'].'> is a blocklist. Are you stupid? Do you want to block a legitimate sender? I refuse to continue.'); |
|
43 | + exit (254); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /* Make MYSQL connection Array */ |
@@ -15,10 +15,10 @@ |
||
15 | 15 | openlog($tag, LOG_PID, $fac); |
16 | 16 | $mysqli = new mysqli($dbhost, $userdb, $pwd, $db, $dbport); |
17 | 17 | if ($mysqli->connect_error) { |
18 | - syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
19 | - . $mysqli->connect_error); |
|
20 | - die($user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
21 | - . $mysqli->connect_error); |
|
18 | + syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
19 | + . $mysqli->connect_error); |
|
20 | + die($user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
21 | + . $mysqli->connect_error); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | syslog (LOG_INFO, $user.': Successfully connected to ' . $mysqli->host_info ); |
@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | # print "Examine ".$received[0][$i]."\n"; |
13 | 13 | if ( preg_match($msa,$received['host'][$i]) ) |
14 | 14 | $dateR = $received['date'][$i]; |
15 | - foreach ($mxserver as $mx) { |
|
16 | - if (!$ip) |
|
15 | + foreach ($mxserver as $mx) { |
|
16 | + if (!$ip) |
|
17 | 17 | if ($mx == $received['host'][$i]) { |
18 | 18 | $host = $received['host'][$i]; |
19 | 19 | $ip = $received['ip'][$i]; |
20 | - } |
|
21 | - } |
|
22 | - } |
|
20 | + } |
|
21 | + } |
|
22 | + } |
|
23 | 23 | } |
24 | 24 | if ( preg_match ('/\r\nDate:\s(?P<date>.*)\r\n/',$header,$dateC) != 1) |
25 | 25 | $dateC['date'] = 'Not found'; |
@@ -39,15 +39,15 @@ discard block |
||
39 | 39 | |
40 | 40 | |
41 | 41 | function summaryBadReport ($uidvet) { |
42 | - $nuid = $uidvet['count']; |
|
43 | - if ( empty($uidvet) ) return NULL; |
|
44 | - $return = '<hr><h3>Statistics by UID</h3><table><tr><th>UID</th><th>Learned times</th></tr>'."\n"; |
|
42 | + $nuid = $uidvet['count']; |
|
43 | + if ( empty($uidvet) ) return NULL; |
|
44 | + $return = '<hr><h3>Statistics by UID</h3><table><tr><th>UID</th><th>Learned times</th></tr>'."\n"; |
|
45 | 45 | |
46 | - /* Remove count index */ |
|
47 | - $uids = array_keys($uidvet['uid']); |
|
46 | + /* Remove count index */ |
|
47 | + $uids = array_keys($uidvet['uid']); |
|
48 | 48 | $totlearn = 0; |
49 | 49 | |
50 | - foreach ( $uids as $uid ) { |
|
50 | + foreach ( $uids as $uid ) { |
|
51 | 51 | $totlearn += $uidvet['uid']["$uid"]['count'];; |
52 | 52 | $return .= sprintf ('<tr><td>%s</td><td>%u</td></tr>',$uid,$uidvet['uid']["$uid"]['count']); |
53 | 53 | } |
@@ -60,26 +60,26 @@ discard block |
||
60 | 60 | |
61 | 61 | function array_msort($array, $cols) |
62 | 62 | { |
63 | - $colarr = array(); |
|
64 | - foreach ($cols as $col => $order) { |
|
65 | - $colarr[$col] = array(); |
|
66 | - foreach ($array as $k => $row) { $colarr[$col]['_'.$k] = strtolower($row[$col]); } |
|
67 | - } |
|
68 | - $eval = 'array_multisort('; |
|
69 | - foreach ($cols as $col => $order) { |
|
70 | - $eval .= '$colarr[\''.$col.'\'],'.$order.','; |
|
71 | - } |
|
72 | - $eval = substr($eval,0,-1).');'; |
|
73 | - eval($eval); |
|
74 | - $ret = array(); |
|
75 | - foreach ($colarr as $col => $arr) { |
|
76 | - foreach ($arr as $k => $v) { |
|
77 | - $k = substr($k,1); |
|
78 | - if (!isset($ret[$k])) $ret[$k] = $array[$k]; |
|
79 | - if (isset ($array[$k][$col])) $ret[$k][$col] = $array[$k][$col]; |
|
80 | - } |
|
81 | - } |
|
82 | - return $ret; |
|
63 | + $colarr = array(); |
|
64 | + foreach ($cols as $col => $order) { |
|
65 | + $colarr[$col] = array(); |
|
66 | + foreach ($array as $k => $row) { $colarr[$col]['_'.$k] = strtolower($row[$col]); } |
|
67 | + } |
|
68 | + $eval = 'array_multisort('; |
|
69 | + foreach ($cols as $col => $order) { |
|
70 | + $eval .= '$colarr[\''.$col.'\'],'.$order.','; |
|
71 | + } |
|
72 | + $eval = substr($eval,0,-1).');'; |
|
73 | + eval($eval); |
|
74 | + $ret = array(); |
|
75 | + foreach ($colarr as $col => $arr) { |
|
76 | + foreach ($arr as $k => $v) { |
|
77 | + $k = substr($k,1); |
|
78 | + if (!isset($ret[$k])) $ret[$k] = $array[$k]; |
|
79 | + if (isset ($array[$k][$col])) $ret[$k][$col] = $array[$k][$col]; |
|
80 | + } |
|
81 | + } |
|
82 | + return $ret; |
|
83 | 83 | |
84 | 84 | } |
85 | 85 | |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | |
95 | 95 | foreach ( $ips as $ip ) { |
96 | 96 | if ( $ip == 'count' ) continue; |
97 | - $nlearn = $ipvet['ip']["$ip"]['count']; |
|
98 | - unset($ipvet['ip']["$ip"]['count']); |
|
97 | + $nlearn = $ipvet['ip']["$ip"]['count']; |
|
98 | + unset($ipvet['ip']["$ip"]['count']); |
|
99 | 99 | $quantity = $cf['quantity']["$category"]; /* In searchAndList this value is passed by reference and modified */ |
100 | 100 | $nuid = count($ipvet['ip']["$ip"]); |
101 | 101 | if ( !$cf['onlyReport'] ) { |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | $return .='<tr><td rowspan="'.$nuid.'">'.$ip.'</td>'; |
124 | 124 | $return .= sprintf ('<td>%s</td><td rowspan="'.$nuid.'">%u</td><td rowspan="'.$nuid.'" '.$nowlist["$listed"]['style'].'>%s</td></tr>',$ipvet['ip']["$ip"][0],$nlearn,$nowlist["$listed"]['name']); |
125 | 125 | $rowuid=NULL; |
126 | - for ($j=1;$j<$nuid;$j++) $rowuid .= '<tr><td>%s</td></tr>'; |
|
126 | + for ($j=1;$j<$nuid;$j++) $rowuid .= '<tr><td>%s</td></tr>'; |
|
127 | 127 | array_shift($ipvet['ip']["$ip"]); |
128 | - $return .= vsprintf ($rowuid,$ipvet['ip']["$ip"]); |
|
128 | + $return .= vsprintf ($rowuid,$ipvet['ip']["$ip"]); |
|
129 | 129 | |
130 | 130 | } |
131 | 131 | $return .= sprintf ('<tr><th title="unique ips">%u</th><th title="unique uids">%u</th><th>%u</th></table>',$ipvet['ip']['count'],$ipvet['uid']['count'],$nips); |
@@ -135,20 +135,20 @@ discard block |
||
135 | 135 | /* Not used for listing purpose, but useful to you! */ |
136 | 136 | $return .= '<h3>Statistics by UID</h3><table><tr><th>UID</th><th>IP learned</th><th>Learned times</th></tr>'."\n"; |
137 | 137 | $uids = array_keys($ipvet['uid']); |
138 | - foreach ( $uids as $uid ) { |
|
138 | + foreach ( $uids as $uid ) { |
|
139 | 139 | if ( $uid == 'count' ) continue; |
140 | - $nlearn = $ipvet['uid']["$uid"]['count']; |
|
141 | - unset ( $ipvet['uid']["$uid"]['count'] ); |
|
140 | + $nlearn = $ipvet['uid']["$uid"]['count']; |
|
141 | + unset ( $ipvet['uid']["$uid"]['count'] ); |
|
142 | 142 | $nip = count($ipvet['uid']["$uid"]); |
143 | 143 | $return .='<tr><td rowspan="'.$nip.'">'.$uid.'</td>'; |
144 | 144 | $return .= sprintf ('<td>%s</td><td rowspan="'.$nip.'">%u</td></tr>',$ipvet['uid']["$uid"][0],$nlearn); |
145 | - $rowuid=NULL; |
|
146 | - for ($j=1;$j<$nip;$j++) $rowuid .= '<tr><td>%s</td></tr>'; |
|
147 | - array_shift($ipvet['uid']["$uid"]); |
|
148 | - $return .= vsprintf ($rowuid,$ipvet['uid']["$uid"]); |
|
145 | + $rowuid=NULL; |
|
146 | + for ($j=1;$j<$nip;$j++) $rowuid .= '<tr><td>%s</td></tr>'; |
|
147 | + array_shift($ipvet['uid']["$uid"]); |
|
148 | + $return .= vsprintf ($rowuid,$ipvet['uid']["$uid"]); |
|
149 | 149 | |
150 | - } |
|
151 | - $return .= sprintf ('<tr><th title="unique uids">%u</th><th title="unique ips">%u</th><th>%u</th></table>',$ipvet['uid']['count'],$ipvet['ip']['count'],$nips); |
|
150 | + } |
|
151 | + $return .= sprintf ('<tr><th title="unique uids">%u</th><th title="unique ips">%u</th><th>%u</th></table>',$ipvet['uid']['count'],$ipvet['ip']['count'],$nips); |
|
152 | 152 | |
153 | 153 | |
154 | 154 | return $return; |
@@ -176,50 +176,50 @@ discard block |
||
176 | 176 | */ |
177 | 177 | |
178 | 178 | // A one shot search |
179 | - $searchParams = array( |
|
180 | - 'earliest_time' => date("c",strtotime ($date)-120), |
|
181 | - 'latest_time' => date("c",strtotime ($date)+60) |
|
182 | - ); |
|
179 | + $searchParams = array( |
|
180 | + 'earliest_time' => date("c",strtotime ($date)-120), |
|
181 | + 'latest_time' => date("c",strtotime ($date)+60) |
|
182 | + ); |
|
183 | 183 | |
184 | - // Run a oneshot search that returns the job's results |
|
185 | - $resultsStream = $service->oneshotSearch($searchQueryBlocking, $searchParams); |
|
186 | - $resultSearch = new Splunk_ResultsReader($resultsStream); |
|
184 | + // Run a oneshot search that returns the job's results |
|
185 | + $resultsStream = $service->oneshotSearch($searchQueryBlocking, $searchParams); |
|
186 | + $resultSearch = new Splunk_ResultsReader($resultsStream); |
|
187 | 187 | |
188 | 188 | // Use the built-in XML parser to display the job results |
189 | 189 | foreach ($resultSearch as $result) |
190 | 190 | { |
191 | - if ($result instanceof Splunk_ResultsFieldOrder) |
|
192 | - { |
|
193 | - // More than one field attribute returned by search |
|
194 | - // You must redefine the search |
|
195 | - if ( count($result->getFieldNames()) > 1 ) return FALSE; |
|
196 | - } |
|
197 | - else if ($result instanceof Splunk_ResultsMessage) |
|
198 | - { |
|
199 | - // I don't want messages in my search |
|
200 | - return FALSE; |
|
201 | - } |
|
202 | - else if (is_array($result)) |
|
203 | - { |
|
204 | - // Process a row |
|
205 | - foreach ($result as $key => $valueOrValues) |
|
206 | - { |
|
207 | - if (is_array($valueOrValues)) |
|
208 | - { |
|
209 | - return FALSE; |
|
210 | - } |
|
211 | - else |
|
212 | - { |
|
213 | - return $valueOrValues; |
|
214 | - #print " {$key} => {$value}\r\n"; |
|
215 | - } |
|
216 | - } |
|
217 | - } |
|
218 | - else |
|
219 | - { |
|
220 | - #print "Unknow result type"; |
|
221 | - return FALSE; |
|
222 | - } |
|
191 | + if ($result instanceof Splunk_ResultsFieldOrder) |
|
192 | + { |
|
193 | + // More than one field attribute returned by search |
|
194 | + // You must redefine the search |
|
195 | + if ( count($result->getFieldNames()) > 1 ) return FALSE; |
|
196 | + } |
|
197 | + else if ($result instanceof Splunk_ResultsMessage) |
|
198 | + { |
|
199 | + // I don't want messages in my search |
|
200 | + return FALSE; |
|
201 | + } |
|
202 | + else if (is_array($result)) |
|
203 | + { |
|
204 | + // Process a row |
|
205 | + foreach ($result as $key => $valueOrValues) |
|
206 | + { |
|
207 | + if (is_array($valueOrValues)) |
|
208 | + { |
|
209 | + return FALSE; |
|
210 | + } |
|
211 | + else |
|
212 | + { |
|
213 | + return $valueOrValues; |
|
214 | + #print " {$key} => {$value}\r\n"; |
|
215 | + } |
|
216 | + } |
|
217 | + } |
|
218 | + else |
|
219 | + { |
|
220 | + #print "Unknow result type"; |
|
221 | + return FALSE; |
|
222 | + } |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | |
@@ -228,26 +228,26 @@ discard block |
||
228 | 228 | $file = dirname(__FILE__) . '/' . $cf['reportFile']["$type"]; |
229 | 229 | $fileb= dirname(__FILE__) . '/' . $cf['badreportFile']["$type"]; |
230 | 230 | $m_mail = imap_open('{'.$cf['mailhost'].':143/imap/novalidate-cert/authuser='.$cf['authuser'].'}'.$cf['folder']["$type"], $cf['account'],$cf['authpassword'], OP_READONLY) |
231 | - or syslog (LOG_EMERG, $cf['user'].': Error in IMAP connection to <'.$cf['mailhost'].'>: ' . imap_last_error()); |
|
231 | + or syslog (LOG_EMERG, $cf['user'].': Error in IMAP connection to <'.$cf['mailhost'].'>: ' . imap_last_error()); |
|
232 | 232 | if ( !$m_mail ) exit(254); |
233 | 233 | |
234 | 234 | |
235 | 235 | syslog (LOG_INFO,$cf['user'].': Successfully connected to <'.$cf['mailhost'].">; Reading $type messages of last ".$cf['oldestday'].' days...'); |
236 | 236 | //get all messages |
237 | 237 | $dateTh = date ( "d-M-Y", strToTime ( '-'.$cf['oldestday'].' days' ) ); |
238 | - $dateN = date ( "d-M-Y", strToTime ( "now" ) ); |
|
239 | - $m_search=imap_search ($m_mail, "SINCE \"$dateTh\" BEFORE \"$dateN\"" ); |
|
238 | + $dateN = date ( "d-M-Y", strToTime ( "now" ) ); |
|
239 | + $m_search=imap_search ($m_mail, "SINCE \"$dateTh\" BEFORE \"$dateN\"" ); |
|
240 | 240 | |
241 | 241 | |
242 | 242 | // Order results starting from newest message |
243 | 243 | if ( empty($m_search) ) { |
244 | 244 | syslog (LOG_INFO,$cf['user'].": No mail found in $type folder. No reports written for $type."); |
245 | - if ( $ierr = imap_errors() ) |
|
246 | - foreach ( $ierr as $thiserr ) |
|
247 | - syslog (LOG_ERR, $cf['user'].": IMAP Error: $thiserr"); |
|
248 | - if ( $ierr = imap_alerts() ) |
|
249 | - foreach ( $ierr as $thiserr ) |
|
250 | - syslog (LOG_ALERT, $cf['user'].": IMAP Alert: $thiserr"); |
|
245 | + if ( $ierr = imap_errors() ) |
|
246 | + foreach ( $ierr as $thiserr ) |
|
247 | + syslog (LOG_ERR, $cf['user'].": IMAP Error: $thiserr"); |
|
248 | + if ( $ierr = imap_alerts() ) |
|
249 | + foreach ( $ierr as $thiserr ) |
|
250 | + syslog (LOG_ALERT, $cf['user'].": IMAP Alert: $thiserr"); |
|
251 | 251 | imap_close( $m_mail ); |
252 | 252 | if ( file_exists( $file ) ) unlink ($file); |
253 | 253 | if ( file_exists( $fileb ) ) unlink ($fileb); |
@@ -280,16 +280,16 @@ discard block |
||
280 | 280 | $uidbad['count'] = 0; |
281 | 281 | $uidbad['uid'] = array(); |
282 | 282 | |
283 | - // loop for each message |
|
283 | + // loop for each message |
|
284 | 284 | foreach ($m_search as $onem) { |
285 | 285 | |
286 | - //get imap header info for obj thang |
|
287 | - //$headers = imap_headerinfo($m_mail, $onem); |
|
288 | - //$head = imap_fetchheader($m_mail, $headers->Msgno); |
|
286 | + //get imap header info for obj thang |
|
287 | + //$headers = imap_headerinfo($m_mail, $onem); |
|
288 | + //$head = imap_fetchheader($m_mail, $headers->Msgno); |
|
289 | 289 | $head = imap_fetchheader($m_mail, $onem ); |
290 | - //$obj = imap_rfc822_parse_headers( $head); |
|
290 | + //$obj = imap_rfc822_parse_headers( $head); |
|
291 | 291 | |
292 | - list ($ip,$host,$dateReceived,$dateClient,$mid) = getIP( $head,$cf['mx'],$cf['msalearn'] ); |
|
292 | + list ($ip,$host,$dateReceived,$dateClient,$mid) = getIP( $head,$cf['mx'],$cf['msalearn'] ); |
|
293 | 293 | if (empty($mid)) { |
294 | 294 | $uid='NA'; |
295 | 295 | syslog (LOG_ERR, $cf['user'].": Error retrieving data for empty Message-ID."); |
@@ -304,11 +304,11 @@ discard block |
||
304 | 304 | } |
305 | 305 | } |
306 | 306 | |
307 | - /* Update count of each ip */ |
|
308 | - if ($host and ($uid!='NA') and ($uid!='unauthenticated') and ($uid!='unknown')) { /* IP is received by MX servers and learned by valid uid */ |
|
307 | + /* Update count of each ip */ |
|
308 | + if ($host and ($uid!='NA') and ($uid!='unauthenticated') and ($uid!='unknown')) { /* IP is received by MX servers and learned by valid uid */ |
|
309 | 309 | $ipuid['count']++; //number of right messages |
310 | 310 | |
311 | - if (in_array($uid,array_keys($ipuid['uid']))) { |
|
311 | + if (in_array($uid,array_keys($ipuid['uid']))) { |
|
312 | 312 | $ipuid['uid']["$uid"]['count']++; //number of learn by this uid |
313 | 313 | if (!in_array($ip,$ipuid['uid']["$uid"])) |
314 | 314 | $ipuid['uid']["$uid"][]=$ip; //ips learned by this uid |
@@ -319,29 +319,29 @@ discard block |
||
319 | 319 | $ipuid['uid']['count']++; //number of unique uids |
320 | 320 | } |
321 | 321 | |
322 | - if (in_array($ip,array_keys($ipuid['ip']))) { |
|
323 | - $ipuid['ip']["$ip"]['count']++; //number of time this ip appears in different messages |
|
322 | + if (in_array($ip,array_keys($ipuid['ip']))) { |
|
323 | + $ipuid['ip']["$ip"]['count']++; //number of time this ip appears in different messages |
|
324 | 324 | if (!in_array($uid,$ipuid['ip']["$ip"])) |
325 | 325 | $ipuid['ip']["$ip"][]=$uid; //uids that learned this ip |
326 | 326 | } |
327 | - else { |
|
328 | - $ipuid['ip']["$ip"]['count'] = 1; |
|
327 | + else { |
|
328 | + $ipuid['ip']["$ip"]['count'] = 1; |
|
329 | 329 | $ipuid['ip']["$ip"][]=$uid; |
330 | 330 | $ipuid['ip']['count']++; //number of unique ips |
331 | - } |
|
331 | + } |
|
332 | 332 | |
333 | - /* Update HTML report */ |
|
334 | - fwrite($fp,updateReport ( $ip,$uid,$ipuid['ip']["$ip"]['count'],$ipuid['uid']["$uid"]['count'],$host,$dateClient,$mid,$dateReceived) ); |
|
333 | + /* Update HTML report */ |
|
334 | + fwrite($fp,updateReport ( $ip,$uid,$ipuid['ip']["$ip"]['count'],$ipuid['uid']["$uid"]['count'],$host,$dateClient,$mid,$dateReceived) ); |
|
335 | 335 | } |
336 | - else { /* Bad learn */ |
|
336 | + else { /* Bad learn */ |
|
337 | 337 | |
338 | - if (in_array($uid,array_keys($uidbad['uid']))) |
|
339 | - $uidbad['uid']["$uid"]['count']++; //number of bad learn by this uid |
|
340 | - else { |
|
341 | - $uidbad['uid']["$uid"]['count'] = 1; |
|
338 | + if (in_array($uid,array_keys($uidbad['uid']))) |
|
339 | + $uidbad['uid']["$uid"]['count']++; //number of bad learn by this uid |
|
340 | + else { |
|
341 | + $uidbad['uid']["$uid"]['count'] = 1; |
|
342 | 342 | $uidbad['uid']["$uid"][]=$uid; |
343 | - $uidbad['count']++; //numeber of unique bad uids |
|
344 | - } |
|
343 | + $uidbad['count']++; //numeber of unique bad uids |
|
344 | + } |
|
345 | 345 | /* The reason of bad report */ |
346 | 346 | if ($host === FALSE) $reason = 'This mail was not received by recognized MX host'; |
347 | 347 | if ($dateReceived === FALSE) $reason = 'This mail was not submitted to recognized MSA for learn'; |
@@ -363,17 +363,17 @@ discard block |
||
363 | 363 | fwrite($fp, '</table>'); |
364 | 364 | fwrite($fp, '<hr><h2>Summary Report</h2><h5>Listing policy: ip must be learned at least '.$cf['thresholdip']["$type"].' times from at least '.$cf['thresholduid']["$type"].' different valid uids.</h5>' ); |
365 | 365 | |
366 | - /* Make MYSQL connection */ |
|
366 | + /* Make MYSQL connection */ |
|
367 | 367 | if ( $cf['onlyReport'] ) |
368 | 368 | $mysqli = NULL; |
369 | 369 | else { |
370 | - $mysqli = new mysqli($myconnArray['dbhost'], $myconnArray['userdb'], $myconnArray['pwd'], $myconnArray['db'], $myconnArray['dbport']); |
|
371 | - if ($mysqli->connect_error) { |
|
372 | - syslog (LOG_EMERG, $cf['user'].': Connect Error (' . $mysqli->connect_errno . ') ' |
|
373 | - . $mysqli->connect_error); |
|
374 | - exit (254); |
|
375 | - } |
|
376 | - syslog(LOG_INFO, $cf['user'].': Successfully mysql connected to ' . $mysqli->host_info) ; |
|
370 | + $mysqli = new mysqli($myconnArray['dbhost'], $myconnArray['userdb'], $myconnArray['pwd'], $myconnArray['db'], $myconnArray['dbport']); |
|
371 | + if ($mysqli->connect_error) { |
|
372 | + syslog (LOG_EMERG, $cf['user'].': Connect Error (' . $mysqli->connect_errno . ') ' |
|
373 | + . $mysqli->connect_error); |
|
374 | + exit (254); |
|
375 | + } |
|
376 | + syslog(LOG_INFO, $cf['user'].': Successfully mysql connected to ' . $mysqli->host_info) ; |
|
377 | 377 | } |
378 | 378 | /***********************/ |
379 | 379 | |
@@ -393,8 +393,8 @@ discard block |
||
393 | 393 | foreach ( $ierr as $thiserr ) |
394 | 394 | syslog (LOG_ERR, $cf['user'].": IMAP Error: $thiserr"); |
395 | 395 | if ( $ierr = imap_alerts() ) |
396 | - foreach ( $ierr as $thiserr ) |
|
397 | - syslog (LOG_ALERT, $cf['user'].": IMAP Alert: $thiserr"); |
|
396 | + foreach ( $ierr as $thiserr ) |
|
397 | + syslog (LOG_ALERT, $cf['user'].": IMAP Alert: $thiserr"); |
|
398 | 398 | imap_close($m_mail); |
399 | 399 | } |
400 | 400 | ?> |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | } |
45 | 45 | if (! empty($old) ) { |
46 | 46 | foreach ($old as $item) { |
47 | - if (! in_array($item, $new) ) { |
|
48 | - $values["$item"] = 'del'; |
|
47 | + if (! in_array($item, $new) ) { |
|
48 | + $values["$item"] = 'del'; |
|
49 | 49 | $logs[] = "<$item>: ". $values["$item"]; |
50 | 50 | } |
51 | 51 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | /* Store new values */ |
65 | 65 | if ( ($mysqli = myConnect($dbhost, $userdb, $pwd, $db, $dbport, $tables, $typedesc, $user)) === FALSE ) |
66 | - exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error); |
|
66 | + exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error); |
|
67 | 67 | |
68 | 68 | if (changeMilter ($mysqli,$user,$values,$col,$_POST['miltId'])) |
69 | 69 | print 'OK milter setting changed.'; |
@@ -11,11 +11,11 @@ |
||
11 | 11 | openlog($tag, LOG_PID, $fac); |
12 | 12 | if (empty($_POST['reason'])) die ("Specify a reason, please!</td>"); |
13 | 13 | if (preg_match( '/[^\x20-\x7f]/', $_POST['reason'])) |
14 | - exit('ERROR: <'.htmlentities($_POST['reason'],ENT_COMPAT | ENT_HTML401, 'ISO-8859-1').'> contains NON ASCII chars.</td>'); |
|
14 | + exit('ERROR: <'.htmlentities($_POST['reason'],ENT_COMPAT | ENT_HTML401, 'ISO-8859-1').'> contains NON ASCII chars.</td>'); |
|
15 | 15 | $user = username(); |
16 | 16 | |
17 | 17 | if ( ($mysqli = myConnect($dbhost, $userdb, $pwd, $db, $dbport, $tables, $typedesc, $user)) === FALSE ) |
18 | - exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error); |
|
18 | + exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error); |
|
19 | 19 | |
20 | 20 | if (isFull($mysqli,$typedesc,$tables)) die("ERROR in relist: ".htmlspecialchars("$typedesc has reached maximum value of ".$tables["$typedesc"]['limit'].' listed items.') ); |
21 | 21 | if (relist ($mysqli,username(),$_POST['value'],$type,$table,$_POST['unit'],$_POST['quantity'],$_POST['reason'])) |