@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | exit ('<pre><'.$_POST['Value'].'> is NOT a valid email address.</pre>'); |
| 11 | 11 | |
| 12 | 12 | if ( ($tables["$_"]['field']=='domain') AND ($_POST['Value']!='ALL') ) |
| 13 | - if (!(filter_var(gethostbyname($_POST['Value']), FILTER_VALIDATE_IP))) |
|
| 13 | + if (!(filter_var(gethostbyname($_POST['Value']), FILTER_VALIDATE_IP))) |
|
| 14 | 14 | exit ('<pre><'.$_POST['Value'].'> is NOT a valid domain.</pre>'); |
| 15 | 15 | |
| 16 | 16 | if ( ($tables["$_"]['field']=='ip') AND ($_POST['Value']!='ALL') ) |
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | if ( ($tables["$_"]['field']=='username') AND ($_POST['Value']!='ALL') ) { |
| 29 | - if ( preg_match( '/[^\x20-\x7f]/', $_POST['Value']) ) |
|
| 30 | - exit('<pre><'.$_POST['Value'].'> contains NON ASCII chars.</pre>'); |
|
| 29 | + if ( preg_match( '/[^\x20-\x7f]/', $_POST['Value']) ) |
|
| 30 | + exit('<pre><'.$_POST['Value'].'> contains NON ASCII chars.</pre>'); |
|
| 31 | 31 | if ( preg_match( '/[$~=#*+%,{}()\/\\<>;:\"`\[\]&?\s]/', $_POST['Value']) ) |
| 32 | 32 | exit('<pre><'.$_POST['Value'].'> contains invalid ASCII chars.</pre>'); |
| 33 | 33 | switch ( $_POST['Value'] ) { |
@@ -49,10 +49,10 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | $mysqli = new mysqli($dbhost, $userdb, $pwd, $db, $dbport); |
| 51 | 51 | if ($mysqli->connect_error) { |
| 52 | - syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
| 53 | - . $mysqli->connect_error); |
|
| 54 | - exit ($user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
| 55 | - . $mysqli->connect_error); |
|
| 52 | + syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
| 53 | + . $mysqli->connect_error); |
|
| 54 | + exit ($user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
| 55 | + . $mysqli->connect_error); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | syslog(LOG_INFO, $user.': Successfully mysql connected to ' . $mysqli->host_info) ; |
@@ -5,31 +5,38 @@ discard block |
||
| 5 | 5 | $net = new \dautkom\ipv4\IPv4(); |
| 6 | 6 | |
| 7 | 7 | $_ = $_POST['genere']; |
| 8 | -if ( ($tables["$_"]['field']=='email') AND ($_POST['Value']!='ALL') ) |
|
| 8 | +if ( ($tables["$_"]['field']=='email') AND ($_POST['Value']!='ALL') ) { |
|
| 9 | 9 | if (!(filter_var($_POST['Value'], FILTER_VALIDATE_EMAIL))) |
| 10 | 10 | exit ('<pre><'.$_POST['Value'].'> is NOT a valid email address.</pre>'); |
| 11 | +} |
|
| 11 | 12 | |
| 12 | -if ( ($tables["$_"]['field']=='domain') AND ($_POST['Value']!='ALL') ) |
|
| 13 | +if ( ($tables["$_"]['field']=='domain') AND ($_POST['Value']!='ALL') ) { |
|
| 13 | 14 | if (!(filter_var(gethostbyname($_POST['Value']), FILTER_VALIDATE_IP))) |
| 14 | 15 | exit ('<pre><'.$_POST['Value'].'> is NOT a valid domain.</pre>'); |
| 16 | +} |
|
| 15 | 17 | |
| 16 | -if ( ($tables["$_"]['field']=='ip') AND ($_POST['Value']!='ALL') ) |
|
| 18 | +if ( ($tables["$_"]['field']=='ip') AND ($_POST['Value']!='ALL') ) { |
|
| 17 | 19 | if (!(filter_var($_POST['Value'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4))) |
| 18 | 20 | exit ('<pre><'.$_POST['Value'].'> is NOT a valid IP address.</pre>'); |
| 21 | +} |
|
| 19 | 22 | |
| 20 | 23 | if ( ($tables["$_"]['field']=='network') AND ($_POST['Value']!='ALL') ) { |
| 21 | 24 | $value = explode('/',$_POST['Value']); |
| 22 | - if (count($value) != 2) |
|
| 23 | - exit ('<pre><'.$_POST['Value'].'> is NOT a valid Network/Netmask pair.</pre>'); |
|
| 24 | - if (!$net->address($value[0])->mask($value[1])->isValid(1)) |
|
| 25 | - exit ('<pre><'.$_POST['Value'].'> is NOT a valid Network/Netmask.</pre>'); |
|
| 26 | -} |
|
| 25 | + if (count($value) != 2) { |
|
| 26 | + exit ('<pre><'.$_POST['Value'].'> is NOT a valid Network/Netmask pair.</pre>'); |
|
| 27 | + } |
|
| 28 | + if (!$net->address($value[0])->mask($value[1])->isValid(1)) { |
|
| 29 | + exit ('<pre><'.$_POST['Value'].'> is NOT a valid Network/Netmask.</pre>'); |
|
| 30 | + } |
|
| 31 | + } |
|
| 27 | 32 | |
| 28 | 33 | if ( ($tables["$_"]['field']=='username') AND ($_POST['Value']!='ALL') ) { |
| 29 | - if ( preg_match( '/[^\x20-\x7f]/', $_POST['Value']) ) |
|
| 30 | - exit('<pre><'.$_POST['Value'].'> contains NON ASCII chars.</pre>'); |
|
| 31 | - if ( preg_match( '/[$~=#*+%,{}()\/\\<>;:\"`\[\]&?\s]/', $_POST['Value']) ) |
|
| 32 | - exit('<pre><'.$_POST['Value'].'> contains invalid ASCII chars.</pre>'); |
|
| 34 | + if ( preg_match( '/[^\x20-\x7f]/', $_POST['Value']) ) { |
|
| 35 | + exit('<pre><'.$_POST['Value'].'> contains NON ASCII chars.</pre>'); |
|
| 36 | + } |
|
| 37 | + if ( preg_match( '/[$~=#*+%,{}()\/\\<>;:\"`\[\]&?\s]/', $_POST['Value']) ) { |
|
| 38 | + exit('<pre><'.$_POST['Value'].'> contains invalid ASCII chars.</pre>'); |
|
| 39 | + } |
|
| 33 | 40 | switch ( $_POST['Value'] ) { |
| 34 | 41 | case 'anonymous': |
| 35 | 42 | case 'anybody': |
@@ -40,9 +47,12 @@ discard block |
||
| 40 | 47 | } |
| 41 | 48 | |
| 42 | 49 | if (empty($_GET)) { |
| 43 | - if ($tables["$_"]['bl']) print "<p><i>$_</i> is a blocklist of ".$tables["$_"]['field'].'.</p>'; |
|
| 44 | - else print "<p><i>$_</i> is a whitelist of ".$tables["$_"]['field'].'.</p>'; |
|
| 45 | -} |
|
| 50 | + if ($tables["$_"]['bl']) { |
|
| 51 | + print "<p><i>$_</i> is a blocklist of ".$tables["$_"]['field'].'.</p>'; |
|
| 52 | + } else { |
|
| 53 | + print "<p><i>$_</i> is a whitelist of ".$tables["$_"]['field'].'.</p>'; |
|
| 54 | + } |
|
| 55 | + } |
|
| 46 | 56 | |
| 47 | 57 | openlog($tag, LOG_PID, $fac); |
| 48 | 58 | $user = username(); |
@@ -14,11 +14,14 @@ |
||
| 14 | 14 | require_once('function.php'); |
| 15 | 15 | |
| 16 | 16 | |
| 17 | -if ( $require_auth ) if ( username() == 'unknown' ) exit ("<p>You MUST configure your server to use authentication.</p>"); |
|
| 17 | +if ( $require_auth ) { |
|
| 18 | + if ( username() == 'unknown' ) exit ("<p>You MUST configure your server to use authentication.</p>"); |
|
| 19 | +} |
|
| 18 | 20 | |
| 19 | 21 | |
| 20 | -if ( $imapListActive ) |
|
| 22 | +if ( $imapListActive ) { |
|
| 21 | 23 | print ' <p style="text-align: right"><a href="/spamreport" target="_new">SPAM Learn Observer</a></p>'; |
| 24 | +} |
|
| 22 | 25 | |
| 23 | 26 | print <<<END |
| 24 | 27 | <form name="check" action="result.php" onSubmit="xmlhttpPost('result.php', 'check', 'Risultato', '<img src=\'/include/pleasewait.gif\'>'); return false;" enctype="text/plain" method="post" target="_self"> |
@@ -10,9 +10,9 @@ |
||
| 10 | 10 | $mysqli = new mysqli($dbhost, $userdb, $pwd, $db, $dbport); |
| 11 | 11 | if ($mysqli->connect_error) { |
| 12 | 12 | syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') ' |
| 13 | - . $mysqli->connect_error); |
|
| 14 | - die($user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
| 15 | - . $mysqli->connect_error); |
|
| 13 | + . $mysqli->connect_error); |
|
| 14 | + die($user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
| 15 | + . $mysqli->connect_error); |
|
| 16 | 16 | } |
| 17 | 17 | syslog (LOG_INFO, $user.': Successfully connected to ' . $mysqli->host_info ); |
| 18 | 18 | |
@@ -16,10 +16,11 @@ |
||
| 16 | 16 | } |
| 17 | 17 | syslog (LOG_INFO, $user.': Successfully connected to ' . $mysqli->host_info ); |
| 18 | 18 | |
| 19 | -if (remove ($mysqli,$user,$_POST['value'],$type,$table)) |
|
| 19 | +if (remove ($mysqli,$user,$_POST['value'],$type,$table)) { |
|
| 20 | 20 | print 'OK '.$typedesc.' <'.$_POST['value'].'> permanently REMOVED!'; |
| 21 | -else |
|
| 21 | +} else { |
|
| 22 | 22 | print 'Delete operation ERROR on '.$typedesc.' <'.$_POST['value'].'>; check log.'; |
| 23 | +} |
|
| 23 | 24 | $mysqli->close(); |
| 24 | 25 | closelog(); |
| 25 | 26 | ?> |
@@ -12,12 +12,12 @@ |
||
| 12 | 12 | $user = username(); |
| 13 | 13 | |
| 14 | 14 | $mysqli = new mysqli($dbhost, $userdb, $pwd, $db, $dbport); |
| 15 | - if ($mysqli->connect_error) { |
|
| 16 | - syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
| 17 | - . $mysqli->connect_error); |
|
| 18 | - die($user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
| 19 | - . $mysqli->connect_error); |
|
| 20 | - } |
|
| 15 | + if ($mysqli->connect_error) { |
|
| 16 | + syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
| 17 | + . $mysqli->connect_error); |
|
| 18 | + die($user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
| 19 | + . $mysqli->connect_error); |
|
| 20 | + } |
|
| 21 | 21 | syslog (LOG_INFO, $user.': Successfully connected to ' . $mysqli->host_info ); |
| 22 | 22 | |
| 23 | 23 | if (addtolist ($mysqli,username(),$_POST['value'],$type,$table,$_POST['unit'],$_POST['quantity'],$_POST['reason'])) |
@@ -6,9 +6,12 @@ discard block |
||
| 6 | 6 | $table = $tables["$typedesc"]['name']; |
| 7 | 7 | |
| 8 | 8 | openlog($tag, LOG_PID, $fac); |
| 9 | -if (empty($_POST['reason'])) die ("<p>Please, specify a reason!</p>"); |
|
| 10 | -if (preg_match( '/[^\x20-\x7f]/', $_POST['reason'])) |
|
| 9 | +if (empty($_POST['reason'])) { |
|
| 10 | + die ("<p>Please, specify a reason!</p>"); |
|
| 11 | +} |
|
| 12 | +if (preg_match( '/[^\x20-\x7f]/', $_POST['reason'])) { |
|
| 11 | 13 | exit('<p>ERROR: <'.htmlentities($_POST['reason'],ENT_COMPAT | ENT_HTML401, 'ISO-8859-1').'> contains NON ASCII chars.</p>'); |
| 14 | +} |
|
| 12 | 15 | $user = username(); |
| 13 | 16 | |
| 14 | 17 | $mysqli = new mysqli($dbhost, $userdb, $pwd, $db, $dbport); |
@@ -20,10 +23,11 @@ discard block |
||
| 20 | 23 | } |
| 21 | 24 | syslog (LOG_INFO, $user.': Successfully connected to ' . $mysqli->host_info ); |
| 22 | 25 | |
| 23 | -if (addtolist ($mysqli,username(),$_POST['value'],$type,$table,$_POST['unit'],$_POST['quantity'],$_POST['reason'])) |
|
| 26 | +if (addtolist ($mysqli,username(),$_POST['value'],$type,$table,$_POST['unit'],$_POST['quantity'],$_POST['reason'])) { |
|
| 24 | 27 | print 'OK '.$_POST["type"].' <'.$_POST['value'].'> first time listed for '.$_POST['quantity'].$_POST['unit'].'.'; |
| 25 | -else |
|
| 28 | +} else { |
|
| 26 | 29 | print 'List operation ERROR; check log.'; |
| 30 | +} |
|
| 27 | 31 | $mysqli->close(); |
| 28 | 32 | closelog(); |
| 29 | 33 | ?> |
@@ -2,23 +2,23 @@ |
||
| 2 | 2 | require_once('config.php'); |
| 3 | 3 | require_once('function.php'); |
| 4 | 4 | $typedesc=$_POST['type']; |
| 5 | - $type = $tables["$typedesc"]['field']; |
|
| 6 | - $table = $tables["$typedesc"]['name']; |
|
| 5 | + $type = $tables["$typedesc"]['field']; |
|
| 6 | + $table = $tables["$typedesc"]['name']; |
|
| 7 | 7 | ?> |
| 8 | 8 | <td colspan="9" style="text-align: center"> |
| 9 | 9 | <?php |
| 10 | 10 | openlog($tag, LOG_PID, $fac); |
| 11 | 11 | if (empty($_POST['reason'])) die ("Specify a reason, please!</td>"); |
| 12 | 12 | if (preg_match( '/[^\x20-\x7f]/', $_POST['reason'])) |
| 13 | - exit('ERROR: <'.htmlentities($_POST['reason'],ENT_COMPAT | ENT_HTML401, 'ISO-8859-1').'> contains NON ASCII chars.</td>'); |
|
| 13 | + exit('ERROR: <'.htmlentities($_POST['reason'],ENT_COMPAT | ENT_HTML401, 'ISO-8859-1').'> contains NON ASCII chars.</td>'); |
|
| 14 | 14 | $user = username(); |
| 15 | 15 | |
| 16 | 16 | $mysqli = new mysqli($dbhost, $userdb, $pwd, $db, $dbport); |
| 17 | 17 | if ($mysqli->connect_error) { |
| 18 | 18 | syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') ' |
| 19 | - . $mysqli->connect_error); |
|
| 20 | - exit ($user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
| 21 | - . $mysqli->connect_error); |
|
| 19 | + . $mysqli->connect_error); |
|
| 20 | + exit ($user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
| 21 | + . $mysqli->connect_error); |
|
| 22 | 22 | } |
| 23 | 23 | syslog(LOG_INFO, $user.': Successfully connected to ' . $mysqli->host_info) ; |
| 24 | 24 | |
@@ -8,9 +8,12 @@ discard block |
||
| 8 | 8 | <td colspan="9" style="text-align: center"> |
| 9 | 9 | <?php |
| 10 | 10 | openlog($tag, LOG_PID, $fac); |
| 11 | -if (empty($_POST['reason'])) die ("Specify a reason, please!</td>"); |
|
| 12 | -if (preg_match( '/[^\x20-\x7f]/', $_POST['reason'])) |
|
| 11 | +if (empty($_POST['reason'])) { |
|
| 12 | + die ("Specify a reason, please!</td>"); |
|
| 13 | +} |
|
| 14 | +if (preg_match( '/[^\x20-\x7f]/', $_POST['reason'])) { |
|
| 13 | 15 | exit('ERROR: <'.htmlentities($_POST['reason'],ENT_COMPAT | ENT_HTML401, 'ISO-8859-1').'> contains NON ASCII chars.</td>'); |
| 16 | +} |
|
| 14 | 17 | $user = username(); |
| 15 | 18 | |
| 16 | 19 | $mysqli = new mysqli($dbhost, $userdb, $pwd, $db, $dbport); |
@@ -22,11 +25,14 @@ discard block |
||
| 22 | 25 | } |
| 23 | 26 | syslog(LOG_INFO, $user.': Successfully connected to ' . $mysqli->host_info) ; |
| 24 | 27 | |
| 25 | -if (isFull($mysqli,$typedesc,$tables)) die("ERROR in relist: ".htmlspecialchars("$typedesc has reached maximum value of ".$tables["$typedesc"]['limit'].' listed items.') ); |
|
| 26 | -if (relist ($mysqli,username(),$_POST['value'],$type,$table,$_POST['unit'],$_POST['quantity'],$_POST['reason'])) |
|
| 28 | +if (isFull($mysqli,$typedesc,$tables)) { |
|
| 29 | + die("ERROR in relist: ".htmlspecialchars("$typedesc has reached maximum value of ".$tables["$typedesc"]['limit'].' listed items.') ); |
|
| 30 | +} |
|
| 31 | +if (relist ($mysqli,username(),$_POST['value'],$type,$table,$_POST['unit'],$_POST['quantity'],$_POST['reason'])) { |
|
| 27 | 32 | print 'OK '.$_POST["type"].' <'.$_POST['value'].'> relisted for '.$_POST['quantity'].$_POST['unit']; |
| 28 | -else |
|
| 33 | +} else { |
|
| 29 | 34 | print 'ERROR in relist; check log'; |
| 35 | +} |
|
| 30 | 36 | $mysqli->close(); |
| 31 | 37 | closelog(); |
| 32 | 38 | print '</td>'; |
@@ -1,6 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | -if (in_array($user,array_keys(array_filter($adm)))) $extopt = '<option value="MONTH">MONTHS</option><option value="YEAR">YEARS</option>'; |
|
| 3 | -else $extopt = NULL; |
|
| 2 | +if (in_array($user,array_keys(array_filter($adm)))) { |
|
| 3 | + $extopt = '<option value="MONTH">MONTHS</option><option value="YEAR">YEARS</option>'; |
|
| 4 | +} else { |
|
| 5 | + $extopt = NULL; |
|
| 6 | +} |
|
| 4 | 7 | ?> |
| 5 | 8 | <form style="margin:0; text-align: left;" name='ListButton<?php echo $type ?>' enctype="text/plain" method="post" target="_self" action="list.php" onSubmit="xmlhttpPost('list.php', 'ListButton<?php echo $type ?>', 'Risultato', '<img src=\'/include/pleasewait.gif\'>'); return false;" /> |
| 6 | 9 | |
@@ -12,8 +12,12 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | $shortopts = "c:"; // Required value |
| 14 | 14 | $options = getopt($shortopts); |
| 15 | -if ( !isset($options['c']) ) exit ("\n\nUSAGE: ${_SERVER['SCRIPT_NAME']} -c <file.conf>\n\n"); |
|
| 16 | -if ( !file_exists(dirname(__FILE__) . '/' . $options['c']) ) exit ("\n\nThe file <".$options['c']."> doesn't exists.\nExiting...\n\n"); |
|
| 15 | +if ( !isset($options['c']) ) { |
|
| 16 | + exit ("\n\nUSAGE: ${_SERVER['SCRIPT_NAME']} -c <file.conf>\n\n"); |
|
| 17 | +} |
|
| 18 | +if ( !file_exists(dirname(__FILE__) . '/' . $options['c']) ) { |
|
| 19 | + exit ("\n\nThe file <".$options['c']."> doesn't exists.\nExiting...\n\n"); |
|
| 20 | +} |
|
| 17 | 21 | |
| 18 | 22 | /************** Start of conf ************************/ |
| 19 | 23 | require_once('config.php'); |
@@ -77,14 +81,18 @@ discard block |
||
| 77 | 81 | $row = -1; |
| 78 | 82 | while (($data = fgetcsv($handle, 500, ',')) !== FALSE) { |
| 79 | 83 | $row++; |
| 80 | - if ($row == 0) continue; /* Skip heading line */ |
|
| 84 | + if ($row == 0) { |
|
| 85 | + continue; |
|
| 86 | + } |
|
| 87 | + /* Skip heading line */ |
|
| 81 | 88 | $thisVal = $data[1]; |
| 82 | 89 | unset($data[1]); |
| 83 | 90 | $data = array_values($data); |
| 84 | - if ( !in_array($thisVal,array_keys($tolist)) ) |
|
| 85 | - $tolist["$thisVal"] = $data; |
|
| 86 | - else if ($data[3]>$tolist[$thisVal][3]) |
|
| 87 | - $tolist["$thisVal"] = $data; |
|
| 91 | + if ( !in_array($thisVal,array_keys($tolist)) ) { |
|
| 92 | + $tolist["$thisVal"] = $data; |
|
| 93 | + } else if ($data[3]>$tolist[$thisVal][3]) { |
|
| 94 | + $tolist["$thisVal"] = $data; |
|
| 95 | + } |
|
| 88 | 96 | } |
| 89 | 97 | fclose($handle); |
| 90 | 98 | } |
@@ -115,17 +123,18 @@ discard block |
||
| 115 | 123 | $recip = emailToNotify($domainNotify_file,$domain); |
| 116 | 124 | $subject = sprintf('%s <%s> is now blocked because exceedes limits on outgoing emails', |
| 117 | 125 | $tables["$typedesc"]['field'], $value); |
| 118 | - if (!empty($recip)) |
|
| 119 | - if ( sendEmailWarn($tplfile,'[email protected]',$recip, |
|
| 126 | + if (!empty($recip)) { |
|
| 127 | + if ( sendEmailWarn($tplfile,'[email protected]',$recip, |
|
| 120 | 128 | $subject,$value,"$quantity $unit",$reason) ) |
| 121 | 129 | syslog(LOG_INFO, "$user: \"$recip\" was notified about the \"$value\" abuse."); |
| 130 | + } |
|
| 131 | + } else { |
|
| 132 | + syslog(LOG_ERR,"$user: <$domain> contains the '@' char. Notification cannot be sent."); |
|
| 122 | 133 | } |
| 123 | - else syslog(LOG_ERR,"$user: <$domain> contains the '@' char. Notification cannot be sent."); |
|
| 124 | 134 | } |
| 125 | 135 | } |
| 126 | 136 | } |
| 127 | - } |
|
| 128 | - else { |
|
| 137 | + } else { |
|
| 129 | 138 | $reason .= " But it has NOT been listed because it doesn't apply to the trigger condition."; |
| 130 | 139 | syslog (LOG_INFO, "$user: ".$reason); |
| 131 | 140 | } |
@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | /* check you select a blocklist */ |
| 49 | 49 | if ( !$tables["$typedesc"]['bl'] ) { |
| 50 | - syslog(LOG_EMERG,"$user: <$typedesc> is not a blocklist. Are you stupid? Do you want to whitelist a spammer? I refuse to continue."); |
|
| 51 | - exit (254); |
|
| 50 | + syslog(LOG_EMERG,"$user: <$typedesc> is not a blocklist. Are you stupid? Do you want to whitelist a spammer? I refuse to continue."); |
|
| 51 | + exit (254); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | |
@@ -68,33 +68,33 @@ discard block |
||
| 68 | 68 | $tolist = array(); |
| 69 | 69 | |
| 70 | 70 | if ( !file_exists($splfile) ) { |
| 71 | - syslog(LOG_ERR,"$user: File <$splfile> not found! Exit."); |
|
| 72 | - exit (254); |
|
| 71 | + syslog(LOG_ERR,"$user: File <$splfile> not found! Exit."); |
|
| 72 | + exit (254); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | if (($handle = gzopen($splfile, 'r')) !== FALSE) { |
| 76 | - $row = -1; |
|
| 77 | - while (($data = fgetcsv($handle, 500, ',')) !== FALSE) { |
|
| 78 | - $row++; |
|
| 79 | - if ($row == 0) continue; /* Skip heading line */ |
|
| 80 | - $thisVal = $data[1]; |
|
| 81 | - unset($data[1]); |
|
| 82 | - $data = array_values($data); |
|
| 83 | - if ( !in_array($thisVal,array_keys($tolist)) ) |
|
| 84 | - $tolist["$thisVal"] = $data; |
|
| 85 | - else if ($data[3]>$tolist[$thisVal][3]) |
|
| 86 | - $tolist["$thisVal"] = $data; |
|
| 87 | - } |
|
| 88 | - fclose($handle); |
|
| 76 | + $row = -1; |
|
| 77 | + while (($data = fgetcsv($handle, 500, ',')) !== FALSE) { |
|
| 78 | + $row++; |
|
| 79 | + if ($row == 0) continue; /* Skip heading line */ |
|
| 80 | + $thisVal = $data[1]; |
|
| 81 | + unset($data[1]); |
|
| 82 | + $data = array_values($data); |
|
| 83 | + if ( !in_array($thisVal,array_keys($tolist)) ) |
|
| 84 | + $tolist["$thisVal"] = $data; |
|
| 85 | + else if ($data[3]>$tolist[$thisVal][3]) |
|
| 86 | + $tolist["$thisVal"] = $data; |
|
| 87 | + } |
|
| 88 | + fclose($handle); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /* Make MYSQL connection */ |
| 92 | 92 | |
| 93 | 93 | $mysqli = new mysqli($dbhost, $userdb, $pwd, $db, $dbport); |
| 94 | 94 | if ($mysqli->connect_error) { |
| 95 | - syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
| 96 | - . $mysqli->connect_error); |
|
| 97 | - exit (254); |
|
| 95 | + syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
| 96 | + . $mysqli->connect_error); |
|
| 97 | + exit (254); |
|
| 98 | 98 | |
| 99 | 99 | } |
| 100 | 100 | |
@@ -103,28 +103,28 @@ discard block |
||
| 103 | 103 | foreach ( array_keys($tolist) as $value) { |
| 104 | 104 | $quantity = $conf['quantity']; |
| 105 | 105 | $reason = 'On ['.$tolist["$value"][0]."] <$value> sent ".$tolist["$value"][1].' messages to '.$tolist["$value"][2].' recipients.'; |
| 106 | - if ( $tolist["$value"][3] >= $threshold ) { |
|
| 107 | - if ( searchAndList ($mysqli,$user,$tables,$typedesc,$value,$unit,$quantity,$reason) ) { |
|
| 108 | - syslog (LOG_INFO, "$user: ".'Listing reason: '.$reason); |
|
| 109 | - /* Send a email to domain admin if you list an email */ |
|
| 110 | - if ( ( $tables["$typedesc"]['field'] == 'email' ) OR ( $tables["$typedesc"]['field'] == 'username' ) ) { |
|
| 106 | + if ( $tolist["$value"][3] >= $threshold ) { |
|
| 107 | + if ( searchAndList ($mysqli,$user,$tables,$typedesc,$value,$unit,$quantity,$reason) ) { |
|
| 108 | + syslog (LOG_INFO, "$user: ".'Listing reason: '.$reason); |
|
| 109 | + /* Send a email to domain admin if you list an email */ |
|
| 110 | + if ( ( $tables["$typedesc"]['field'] == 'email' ) OR ( $tables["$typedesc"]['field'] == 'username' ) ) { |
|
| 111 | 111 | /* Sometime uid are in the form of <user>@<domain> ... */ |
| 112 | 112 | if ( strpos($value, '@') !== FALSE ) { |
| 113 | - $domain = array_pop(explode('@',$value,2)); |
|
| 113 | + $domain = array_pop(explode('@',$value,2)); |
|
| 114 | 114 | if ( strpos($domain, '@') === FALSE ) { |
| 115 | - $recip = emailToNotify($domainNotify_file,$domain); |
|
| 116 | - $subject = sprintf('%s <%s> is now blocked because exceedes limits on outgoing emails', |
|
| 115 | + $recip = emailToNotify($domainNotify_file,$domain); |
|
| 116 | + $subject = sprintf('%s <%s> is now blocked because exceedes limits on outgoing emails', |
|
| 117 | 117 | $tables["$typedesc"]['field'], $value); |
| 118 | - if (!empty($recip)) |
|
| 119 | - if ( sendEmailWarn($tplfile,'[email protected]',$recip, |
|
| 118 | + if (!empty($recip)) |
|
| 119 | + if ( sendEmailWarn($tplfile,'[email protected]',$recip, |
|
| 120 | 120 | $subject,$value,"$quantity $unit",$reason) ) |
| 121 | - syslog(LOG_INFO, "$user: \"$recip\" was notified about the \"$value\" abuse."); |
|
| 121 | + syslog(LOG_INFO, "$user: \"$recip\" was notified about the \"$value\" abuse."); |
|
| 122 | 122 | } |
| 123 | 123 | else syslog(LOG_ERR,"$user: <$domain> contains the '@' char. Notification cannot be sent."); |
| 124 | 124 | } |
| 125 | - } |
|
| 126 | - } |
|
| 127 | - } |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | 128 | else { |
| 129 | 129 | $reason .= " But it has NOT been listed because it doesn't apply to the trigger condition."; |
| 130 | 130 | syslog (LOG_INFO, "$user: ".$reason); |
@@ -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 | } |
@@ -1,8 +1,9 @@ |
||
| 1 | 1 | #!/usr/bin/php |
| 2 | 2 | <?php |
| 3 | 3 | |
| 4 | -if (PHP_SAPI != "cli") |
|
| 4 | +if (PHP_SAPI != "cli") { |
|
| 5 | 5 | exit; |
| 6 | +} |
|
| 6 | 7 | |
| 7 | 8 | $home = '/var/www/html/RBL'; |
| 8 | 9 | require_once($home.'/config.php'); |
@@ -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>'; |