@@ -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>'; |
@@ -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 ); |
@@ -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'])) |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | $err = NULL; |
| 14 | 14 | |
| 15 | 15 | if ( ($mysqli = myConnect($dbhost, $userdb, $pwd, $db, $dbport, $tables, $typedesc, $user)) === FALSE ) |
| 16 | - exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error); |
|
| 16 | + exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error); |
|
| 17 | 17 | |
| 18 | 18 | if (addtolist ($mysqli,$user,$_POST['value'],$tables["$typedesc"],$_POST['unit'],$_POST['quantity'],$_POST['reason'],$err)) |
| 19 | 19 | print 'OK '.$_POST["type"].' <'.$_POST['value'].'> first time listed for '.$_POST['quantity'].$_POST['unit'].'.'; |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | $user = username(); |
| 11 | 11 | |
| 12 | 12 | if ( ($mysqli = myConnect($dbhost, $userdb, $pwd, $db, $dbport, $tables, $typedesc, $user)) === FALSE ) |
| 13 | - exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error); |
|
| 13 | + exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error); |
|
| 14 | 14 | if (remove ($mysqli,$user,$_POST['value'],$type,$table)) |
| 15 | 15 | print 'OK '.$typedesc.' <'.$_POST['value'].'> permanently REMOVED!'; |
| 16 | 16 | else |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | $user = username(); |
| 13 | 13 | |
| 14 | 14 | if ( ($mysqli = myConnect($dbhost, $userdb, $pwd, $db, $dbport, $tables, $typedesc, $user)) === FALSE ) |
| 15 | - exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error); |
|
| 15 | + exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error); |
|
| 16 | 16 | |
| 17 | 17 | if (changestatus($mysqli,username(),$_POST['value'],'0',$type,$table)) |
| 18 | 18 | print 'OK '.$_POST["type"].' <'.$_POST['value'].'> delisted.'; |
@@ -26,17 +26,17 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | /* Conf */ |
| 28 | 28 | if (!isset($_GET['conf'])) { |
| 29 | - syslog(LOG_ALERT, |
|
| 30 | - sprintf('%s: you must insert the config file name as a GET parameter, such as %s?conf=listEmail.conf', |
|
| 31 | - $user, $_SERVER['SCRIPT_NAME']) ); |
|
| 32 | - exit(254); |
|
| 29 | + syslog(LOG_ALERT, |
|
| 30 | + sprintf('%s: you must insert the config file name as a GET parameter, such as %s?conf=listEmail.conf', |
|
| 31 | + $user, $_SERVER['SCRIPT_NAME']) ); |
|
| 32 | + exit(254); |
|
| 33 | 33 | } |
| 34 | 34 | $fileconf = $_GET['conf']; |
| 35 | 35 | if ( !file_exists(dirname(__FILE__) . '/../' . $fileconf) ) { |
| 36 | - syslog(LOG_ALERT, |
|
| 37 | - sprintf('%s: the configuration file <%s> doesn\'t exist.', |
|
| 38 | - $user, $fileconf )); |
|
| 39 | - exit(254); |
|
| 36 | + syslog(LOG_ALERT, |
|
| 37 | + sprintf('%s: the configuration file <%s> doesn\'t exist.', |
|
| 38 | + $user, $fileconf )); |
|
| 39 | + exit(254); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | closelog(); |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | /* check you select a blocklist */ |
| 66 | 66 | if ( !$tables["$typedesc"]['bl'] ) { |
| 67 | - syslog(LOG_EMERG,"$user: <$typedesc> is not a blocklist. Are you stupid? Do you want to whitelist a spammer? I refuse to continue."); |
|
| 68 | - exit (254); |
|
| 67 | + syslog(LOG_EMERG,"$user: <$typedesc> is not a blocklist. Are you stupid? Do you want to whitelist a spammer? I refuse to continue."); |
|
| 68 | + exit (254); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | |
@@ -95,15 +95,15 @@ discard block |
||
| 95 | 95 | if (preg_match_all('/^https?\:\/\/(?<splunkhost>[\w\.\-]+)\:8000\/app\/(?<splunkapp>[\w\.\-]+)\/\@go\?sid=(?<job>[\w\.\-\d]+)$/', |
| 96 | 96 | $webhook['results_link'], $out, PREG_PATTERN_ORDER) === FALSE) { |
| 97 | 97 | syslog(LOG_ALERT, |
| 98 | - sprintf('%s: unexpected error: can\'t parse the results link returned by webhook (<%s>).', |
|
| 98 | + sprintf('%s: unexpected error: can\'t parse the results link returned by webhook (<%s>).', |
|
| 99 | 99 | $user, $webhook['results_link']) ); |
| 100 | 100 | return 255; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | if ( $webhook['app'] != $out['splunkapp'][0] ) { |
| 104 | 104 | syslog(LOG_ALERT, |
| 105 | - sprintf('%s: unexpected error: the APP returned by webhook (<%s>) doesn\'t match the app (<%s>) in result link.', |
|
| 106 | - $user, $webhook['app'], $out['splunkapp'][0] ) ); |
|
| 105 | + sprintf('%s: unexpected error: the APP returned by webhook (<%s>) doesn\'t match the app (<%s>) in result link.', |
|
| 106 | + $user, $webhook['app'], $out['splunkapp'][0] ) ); |
|
| 107 | 107 | return 255; |
| 108 | 108 | } |
| 109 | 109 | |
@@ -137,14 +137,14 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | $nr = count ($results); |
| 139 | 139 | for ($i=1; $i<$nr; $i++) { /* We skip first header line (i=0) */ |
| 140 | - $data = str_getcsv($results[$i], ','); |
|
| 141 | - $thisVal = $data[1]; |
|
| 142 | - unset($data[1]); |
|
| 143 | - $data = array_values($data); |
|
| 144 | - if ( !in_array($thisVal,array_keys($tolist)) ) |
|
| 145 | - $tolist["$thisVal"] = $data; |
|
| 146 | - else if ($data[3]>$tolist[$thisVal][3]) |
|
| 147 | - $tolist["$thisVal"] = $data; |
|
| 140 | + $data = str_getcsv($results[$i], ','); |
|
| 141 | + $thisVal = $data[1]; |
|
| 142 | + unset($data[1]); |
|
| 143 | + $data = array_values($data); |
|
| 144 | + if ( !in_array($thisVal,array_keys($tolist)) ) |
|
| 145 | + $tolist["$thisVal"] = $data; |
|
| 146 | + else if ($data[3]>$tolist[$thisVal][3]) |
|
| 147 | + $tolist["$thisVal"] = $data; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /* Make MYSQL connection */ |
@@ -154,34 +154,34 @@ discard block |
||
| 154 | 154 | exit (254); |
| 155 | 155 | |
| 156 | 156 | foreach ( array_keys($tolist) as $value) { |
| 157 | - $quantity = $conf['quantity']; |
|
| 158 | - $reason = 'On ['.$tolist["$value"][0]."] <$value> sent ".$tolist["$value"][1].' messages to '.$tolist["$value"][2].' recipients.'; |
|
| 159 | - if ( $tolist["$value"][3] >= $threshold ) { |
|
| 160 | - if ( searchAndList ($mysqli,$user,$tables,$typedesc,$value,$unit,$quantity,$reason) ) { |
|
| 161 | - syslog (LOG_INFO, "$user: ".'Listing reason: '.$reason); |
|
| 162 | - /* Send a email to domain admin if you list an email */ |
|
| 163 | - if ( ( $tables["$typedesc"]['field'] == 'email' ) OR ( $tables["$typedesc"]['field'] == 'username' ) ) { |
|
| 164 | - /* Sometime uid are in the form of <user>@<domain> ... */ |
|
| 165 | - if ( strpos($value, '@') !== FALSE ) { |
|
| 166 | - $domain = substr(strrchr($value, '@'), 1); |
|
| 167 | - if ( strpos($domain, '@') === FALSE ) { |
|
| 168 | - $recip = emailToNotify($domainNotify_file,$domain); |
|
| 169 | - $subject = sprintf('%s <%s> is now blocked because exceedes limits on outgoing emails', |
|
| 170 | - $tables["$typedesc"]['field'], $value); |
|
| 171 | - if (!empty($recip)) |
|
| 172 | - if ( sendEmailWarn($tplfile,'[email protected]',$recip, |
|
| 173 | - $subject,$value,"$quantity $unit",$reason) ) |
|
| 174 | - syslog(LOG_INFO, "$user: \"$recip\" was notified about the \"$value\" abuse."); |
|
| 175 | - } |
|
| 176 | - else syslog(LOG_ERR,"$user: <$domain> contains the '@' char. Notification cannot be sent."); |
|
| 177 | - } |
|
| 178 | - } |
|
| 179 | - } |
|
| 180 | - } |
|
| 181 | - else { |
|
| 182 | - $reason .= " But it has NOT been listed because it doesn't apply to the trigger condition."; |
|
| 183 | - syslog (LOG_INFO, "$user: ".$reason); |
|
| 184 | - } |
|
| 157 | + $quantity = $conf['quantity']; |
|
| 158 | + $reason = 'On ['.$tolist["$value"][0]."] <$value> sent ".$tolist["$value"][1].' messages to '.$tolist["$value"][2].' recipients.'; |
|
| 159 | + if ( $tolist["$value"][3] >= $threshold ) { |
|
| 160 | + if ( searchAndList ($mysqli,$user,$tables,$typedesc,$value,$unit,$quantity,$reason) ) { |
|
| 161 | + syslog (LOG_INFO, "$user: ".'Listing reason: '.$reason); |
|
| 162 | + /* Send a email to domain admin if you list an email */ |
|
| 163 | + if ( ( $tables["$typedesc"]['field'] == 'email' ) OR ( $tables["$typedesc"]['field'] == 'username' ) ) { |
|
| 164 | + /* Sometime uid are in the form of <user>@<domain> ... */ |
|
| 165 | + if ( strpos($value, '@') !== FALSE ) { |
|
| 166 | + $domain = substr(strrchr($value, '@'), 1); |
|
| 167 | + if ( strpos($domain, '@') === FALSE ) { |
|
| 168 | + $recip = emailToNotify($domainNotify_file,$domain); |
|
| 169 | + $subject = sprintf('%s <%s> is now blocked because exceedes limits on outgoing emails', |
|
| 170 | + $tables["$typedesc"]['field'], $value); |
|
| 171 | + if (!empty($recip)) |
|
| 172 | + if ( sendEmailWarn($tplfile,'[email protected]',$recip, |
|
| 173 | + $subject,$value,"$quantity $unit",$reason) ) |
|
| 174 | + syslog(LOG_INFO, "$user: \"$recip\" was notified about the \"$value\" abuse."); |
|
| 175 | + } |
|
| 176 | + else syslog(LOG_ERR,"$user: <$domain> contains the '@' char. Notification cannot be sent."); |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | + } |
|
| 180 | + } |
|
| 181 | + else { |
|
| 182 | + $reason .= " But it has NOT been listed because it doesn't apply to the trigger condition."; |
|
| 183 | + syslog (LOG_INFO, "$user: ".$reason); |
|
| 184 | + } |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /* Close connection */ |
@@ -27,32 +27,32 @@ |
||
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | $data = array( |
| 30 | - 'date' => NULL, |
|
| 31 | - 'from' => NULL, |
|
| 32 | - 'messageid' => NULL, |
|
| 33 | - 'dmarc' => array( |
|
| 34 | - 'result' => NULL, |
|
| 35 | - 'dom' => NULL |
|
| 36 | - ), |
|
| 37 | - 'spf' => array( |
|
| 38 | - 'result' => NULL, |
|
| 39 | - 'dom' => NULL |
|
| 40 | - ), |
|
| 41 | - 'dkim' => array( |
|
| 42 | - 'result' => NULL, |
|
| 43 | - 'dom' => NULL |
|
| 44 | - ), |
|
| 45 | - 'spam' => array( |
|
| 46 | - 'status' => NULL, |
|
| 47 | - 'score' => NULL, |
|
| 48 | - 'th' => NULL, |
|
| 49 | - ), |
|
| 50 | - 'dspam' => array( |
|
| 51 | - 'type' => NULL, |
|
| 52 | - 'level' => NULL, |
|
| 53 | - 'learn' => NULL |
|
| 54 | - ), |
|
| 55 | - 'warn' => NULL |
|
| 30 | + 'date' => NULL, |
|
| 31 | + 'from' => NULL, |
|
| 32 | + 'messageid' => NULL, |
|
| 33 | + 'dmarc' => array( |
|
| 34 | + 'result' => NULL, |
|
| 35 | + 'dom' => NULL |
|
| 36 | + ), |
|
| 37 | + 'spf' => array( |
|
| 38 | + 'result' => NULL, |
|
| 39 | + 'dom' => NULL |
|
| 40 | + ), |
|
| 41 | + 'dkim' => array( |
|
| 42 | + 'result' => NULL, |
|
| 43 | + 'dom' => NULL |
|
| 44 | + ), |
|
| 45 | + 'spam' => array( |
|
| 46 | + 'status' => NULL, |
|
| 47 | + 'score' => NULL, |
|
| 48 | + 'th' => NULL, |
|
| 49 | + ), |
|
| 50 | + 'dspam' => array( |
|
| 51 | + 'type' => NULL, |
|
| 52 | + 'level' => NULL, |
|
| 53 | + 'learn' => NULL |
|
| 54 | + ), |
|
| 55 | + 'warn' => NULL |
|
| 56 | 56 | ); |
| 57 | 57 | |
| 58 | 58 | if (empty($folder)) exit ('<p>No folder found.</p>'); /* This should not occur */ |