@@ -19,74 +19,74 @@ discard block |
||
19 | 19 | $user = username(); |
20 | 20 | |
21 | 21 | $opts = getopt('f:t:'); |
22 | -if ( isset($opts['f']) ) { |
|
22 | +if (isset($opts['f'])) { |
|
23 | 23 | $filetemplate = $opts['f']; |
24 | -} else { |
|
24 | +}else { |
|
25 | 25 | print "\nNo option for '-f' given.\n"; |
26 | - exit ( usage() ); |
|
26 | + exit (usage()); |
|
27 | 27 | } |
28 | 28 | |
29 | -if ( isset($opts['t']) ) { |
|
29 | +if (isset($opts['t'])) { |
|
30 | 30 | $tablename = $opts['t']; |
31 | -} else { |
|
31 | +}else { |
|
32 | 32 | print "\nNo option for '-t' given.\n"; |
33 | - exit ( usage() ); |
|
33 | + exit (usage()); |
|
34 | 34 | } |
35 | 35 | |
36 | -if ( ($typedescN = array_search( $tablename, array_column($tables, 'name'))) === FALSE ) { |
|
36 | +if (($typedescN = array_search($tablename, array_column($tables, 'name'))) === FALSE) { |
|
37 | 37 | print "\nDB <$tablename> doesn't exist!\n"; |
38 | - syslog (LOG_EMERG, "$user: DB <$tablename> doesn't exist!"); |
|
39 | - exit ( usage() ); |
|
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 | -if (! file_exists($filetemplate) ) { |
|
43 | +if (!file_exists($filetemplate)) { |
|
44 | 44 | print "\nFile <$filetemplate> doesn't exists!\n"; |
45 | - syslog (LOG_EMERG, "$user: File <$filetemplate> doesn't exist!"); |
|
46 | - exit ( usage() ); |
|
45 | + syslog(LOG_EMERG, "$user: File <$filetemplate> doesn't exist!"); |
|
46 | + exit (usage()); |
|
47 | 47 | } |
48 | 48 | |
49 | -if (! in_array( $typedesc, array_keys($tables) ) ) { |
|
49 | +if (!in_array($typedesc, array_keys($tables))) { |
|
50 | 50 | print "\nUnknown list <$typedesc>. Please provide an existent list name.\n"; |
51 | - exit ( usage() ); |
|
51 | + exit (usage()); |
|
52 | 52 | } |
53 | 53 | |
54 | -if (! $tables["$typedesc"]['active'] ) { |
|
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 | |
60 | 60 | |
61 | -$now=new DateTime('NOW'); |
|
61 | +$now = new DateTime('NOW'); |
|
62 | 62 | $timeunix = $now->format('U'); |
63 | 63 | $dateRFC822 = $now->format('r'); |
64 | 64 | $year = $now->format('Y'); |
65 | -$rbltype= ($tables["$typedesc"]['bl']) ? 'Blocklist' : 'Whitelist'; |
|
65 | +$rbltype = ($tables["$typedesc"]['bl']) ? 'Blocklist' : 'Whitelist'; |
|
66 | 66 | |
67 | 67 | |
68 | 68 | $tmpl = file_get_contents($filetemplate); |
69 | -$arr_tpl_vars = array('{rblname}','{rbltype}','{date822}','{year}','{unixtimestamp}','{rblname64}','{hostname}'); |
|
70 | -$arr_tpl_data = array($typedesc,$rbltype,$dateRFC822,$year,$timeunix,base64_encode($typedesc),gethostname()); |
|
69 | +$arr_tpl_vars = array('{rblname}', '{rbltype}', '{date822}', '{year}', '{unixtimestamp}', '{rblname64}', '{hostname}'); |
|
70 | +$arr_tpl_data = array($typedesc, $rbltype, $dateRFC822, $year, $timeunix, base64_encode($typedesc), gethostname()); |
|
71 | 71 | $headerList = str_replace($arr_tpl_vars, $arr_tpl_data, $tmpl); |
72 | 72 | |
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 . ') ' |
|
76 | + syslog(LOG_EMERG, $user.': Connect Error ('.$mysqli->connect_errno.') ' |
|
77 | 77 | . $mysqli->connect_error); |
78 | - exit ($user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
78 | + exit ($user.': Connect Error ('.$mysqli->connect_errno.') ' |
|
79 | 79 | . $mysqli->connect_error); |
80 | 80 | } |
81 | 81 | |
82 | -syslog(LOG_INFO, $user.': Successfully mysql connected to ' . $mysqli->host_info) ; |
|
82 | +syslog(LOG_INFO, $user.': Successfully mysql connected to '.$mysqli->host_info); |
|
83 | 83 | |
84 | -$result = searchentry ($mysqli,'ALL',$tables["$typedesc"]); |
|
84 | +$result = searchentry($mysqli, 'ALL', $tables["$typedesc"]); |
|
85 | 85 | if ($result->num_rows) { |
86 | 86 | $element = array(); |
87 | 87 | while ($riga = $result->fetch_array(MYSQLI_ASSOC)) { |
88 | 88 | if (isListed($riga)) { |
89 | - switch ( $tables["$typedesc"]['field'] ) { |
|
89 | + switch ($tables["$typedesc"]['field']) { |
|
90 | 90 | case 'ip': |
91 | 91 | $element[] = long2ip($riga['ip']); |
92 | 92 | break; |
@@ -104,6 +104,6 @@ discard block |
||
104 | 104 | $mysqli->close(); |
105 | 105 | |
106 | 106 | /* Print to file */ |
107 | -file_put_contents( $tables["$typedesc"]['name'], $headerList . implode("\n",$element) ); |
|
107 | +file_put_contents($tables["$typedesc"]['name'], $headerList.implode("\n", $element)); |
|
108 | 108 | closelog(); |
109 | 109 | ?> |
@@ -5,11 +5,11 @@ |
||
5 | 5 | |
6 | 6 | |
7 | 7 | print '<p>List of available Reports for '.date('l, d M Y', strtotime($theDate)).'</p><ul>'; |
8 | -foreach($dir as $file) |
|
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 | - echo '<li><a href="#'.$modalDiv.'">'.str_replace("-$theDate.html",'',basename($file)).'</a></li>'; |
|
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>'; |
14 | 14 | print <<<MODAL |
15 | 15 | <div id="$modalDiv" class="overlay"> |
@@ -15,15 +15,15 @@ |
||
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 . ') ' |
|
18 | + syslog(LOG_EMERG, $user.': Connect Error ('.$mysqli->connect_errno.') ' |
|
19 | 19 | . $mysqli->connect_error); |
20 | - die($user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
20 | + die($user.': Connect Error ('.$mysqli->connect_errno.') ' |
|
21 | 21 | . $mysqli->connect_error); |
22 | 22 | } |
23 | 23 | |
24 | -syslog (LOG_INFO, $user.': Successfully connected to ' . $mysqli->host_info ); |
|
24 | +syslog(LOG_INFO, $user.': Successfully connected to '.$mysqli->host_info); |
|
25 | 25 | |
26 | -expire($mysqli,$user,$tables,$expireTime); |
|
26 | +expire($mysqli, $user, $tables, $expireTime); |
|
27 | 27 | $mysqli->close(); |
28 | 28 | closelog(); |
29 | 29 | ?> |
@@ -11,7 +11,7 @@ |
||
11 | 11 | <h1> DNSBL Lookup</h1> |
12 | 12 | <?php |
13 | 13 | |
14 | -$_POST['Value'] = str_replace('_','.',array_keys($_GET)[0]); |
|
14 | +$_POST['Value'] = str_replace('_', '.', array_keys($_GET)[0]); |
|
15 | 15 | $_POST['genere'] = 'Spam IP'; |
16 | 16 | require_once('result.php'); |
17 | 17 | ?> |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | require_once('config.php'); |
3 | 3 | require_once('function.php'); |
4 | -$typedesc=$_POST['type']; |
|
4 | +$typedesc = $_POST['type']; |
|
5 | 5 | $type = $tables["$typedesc"]['field']; |
6 | 6 | $col = milterTable($type); |
7 | -if ( $col === FALSE ) |
|
7 | +if ($col === FALSE) |
|
8 | 8 | exit ("<p>Error in you config at field <b>$type</b>.</p>"); |
9 | 9 | ?> |
10 | 10 | <td colspan="10" style="text-align: center"> |
@@ -18,54 +18,54 @@ discard block |
||
18 | 18 | $new = $_POST['newvalues']; |
19 | 19 | else |
20 | 20 | $new = array(); |
21 | -if (! empty($_POST['oldvalues'])) |
|
21 | +if (!empty($_POST['oldvalues'])) |
|
22 | 22 | $old = explode(',', $_POST['oldvalues']); |
23 | 23 | else |
24 | - $old=array(); |
|
25 | -$values=array(); |
|
26 | -$logs=array(); |
|
24 | + $old = array(); |
|
25 | +$values = array(); |
|
26 | +$logs = array(); |
|
27 | 27 | |
28 | 28 | print '<pre>'; |
29 | 29 | /* Check need to disable all milters, removing unnecessary setting */ |
30 | -if ( in_array('DISABLE ALL', $new) ) |
|
30 | +if (in_array('DISABLE ALL', $new)) |
|
31 | 31 | $new = array('DISABLE ALL'); |
32 | 32 | |
33 | 33 | /* Compare the values determining what to do */ |
34 | 34 | if (count(array_diff(array_merge($new, $old), array_intersect($new, $old))) !== 0) { |
35 | 35 | /* New and old are different (we assume we don't have duplicate values) */ |
36 | - if (! empty($new) ) { |
|
36 | + if (!empty($new)) { |
|
37 | 37 | foreach ($new as $item) { |
38 | - if ( in_array($item, $old) ) |
|
38 | + if (in_array($item, $old)) |
|
39 | 39 | $values["$item"] = 'keep'; |
40 | 40 | else |
41 | 41 | $values["$item"] = 'add'; |
42 | - $logs[] = "<$item>: ". $values["$item"]; |
|
42 | + $logs[] = "<$item>: ".$values["$item"]; |
|
43 | 43 | } |
44 | 44 | } |
45 | - if (! empty($old) ) { |
|
45 | + if (!empty($old)) { |
|
46 | 46 | foreach ($old as $item) { |
47 | - if (! in_array($item, $new) ) { |
|
47 | + if (!in_array($item, $new)) { |
|
48 | 48 | $values["$item"] = 'del'; |
49 | - $logs[] = "<$item>: ". $values["$item"]; |
|
49 | + $logs[] = "<$item>: ".$values["$item"]; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | 55 | /* Logging */ |
56 | -if ( empty($values) ) |
|
56 | +if (empty($values)) |
|
57 | 57 | print 'No values to change.'; |
58 | 58 | else { |
59 | - $msg = sprintf('%s: Changing Milter setting on list <%s> for %s <%s>.',$user,$typedesc,$type, $_POST['object']); |
|
59 | + $msg = sprintf('%s: Changing Milter setting on list <%s> for %s <%s>.', $user, $typedesc, $type, $_POST['object']); |
|
60 | 60 | syslog(LOG_INFO, $msg); |
61 | 61 | foreach ($logs as $log) |
62 | 62 | syslog(LOG_INFO, "$user: milter $log"); |
63 | 63 | |
64 | 64 | /* Store new values */ |
65 | - if ( ($mysqli = myConnect($dbhost, $userdb, $pwd, $db, $dbport, $tables, $typedesc, $user)) === FALSE ) |
|
66 | - exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error); |
|
65 | + if (($mysqli = myConnect($dbhost, $userdb, $pwd, $db, $dbport, $tables, $typedesc, $user)) === FALSE) |
|
66 | + exit ($user.': Connect Error ('.$mysqli->connect_errno.') '.$mysqli->connect_error); |
|
67 | 67 | |
68 | - if (changeMilter ($mysqli,$user,$values,$col,$_POST['miltId'])) |
|
68 | + if (changeMilter($mysqli, $user, $values, $col, $_POST['miltId'])) |
|
69 | 69 | print 'OK milter setting changed.'; |
70 | 70 | else |
71 | 71 | print 'ERROR updating milter setting; check your syslog. No changes made.'; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | require_once('config.php'); |
3 | 3 | require_once('function.php'); |
4 | -$typedesc=$_POST['type']; |
|
4 | +$typedesc = $_POST['type']; |
|
5 | 5 | $type = $tables["$typedesc"]['field']; |
6 | 6 | $table = ($tables["$typedesc"]['milter']) ? milterTable($type) : $tables["$typedesc"]['name']; |
7 | 7 | $cl = ($tables["$typedesc"]['milter']) ? 10 : 9; |
@@ -10,15 +10,15 @@ discard block |
||
10 | 10 | <?php |
11 | 11 | openlog($tag, LOG_PID, $fac); |
12 | 12 | if (empty($_POST['reason'])) die ("Specify a reason, please!</td>"); |
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>'); |
|
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>'); |
|
15 | 15 | $user = username(); |
16 | 16 | |
17 | -if ( ($mysqli = myConnect($dbhost, $userdb, $pwd, $db, $dbport, $tables, $typedesc, $user)) === FALSE ) |
|
18 | - exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error); |
|
17 | +if (($mysqli = myConnect($dbhost, $userdb, $pwd, $db, $dbport, $tables, $typedesc, $user)) === FALSE) |
|
18 | + exit ($user.': Connect Error ('.$mysqli->connect_errno.') '.$mysqli->connect_error); |
|
19 | 19 | |
20 | -if (isFull($mysqli,$typedesc,$tables)) die("ERROR in relist: ".htmlspecialchars("$typedesc has reached maximum value of ".$tables["$typedesc"]['limit'].' listed items.') ); |
|
21 | -if (relist ($mysqli,username(),$_POST['value'],$type,$table,$_POST['unit'],$_POST['quantity'],$_POST['reason'])) |
|
20 | +if (isFull($mysqli, $typedesc, $tables)) die("ERROR in relist: ".htmlspecialchars("$typedesc has reached maximum value of ".$tables["$typedesc"]['limit'].' listed items.')); |
|
21 | +if (relist($mysqli, username(), $_POST['value'], $type, $table, $_POST['unit'], $_POST['quantity'], $_POST['reason'])) |
|
22 | 22 | print 'OK '.$_POST["type"].' <'.$_POST['value'].'> relisted for '.$_POST['quantity'].$_POST['unit']; |
23 | 23 | else |
24 | 24 | print 'ERROR in relist; check log'; |
@@ -1,25 +1,25 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once('config.php'); |
3 | 3 | require_once('function.php'); |
4 | -$typedesc=$_POST['type']; |
|
4 | +$typedesc = $_POST['type']; |
|
5 | 5 | $type = $tables["$typedesc"]['field']; |
6 | 6 | $table = ($tables["$typedesc"]['milter']) ? milterTable($type) : $tables["$typedesc"]['name']; |
7 | 7 | |
8 | 8 | openlog($tag, LOG_PID, $fac); |
9 | 9 | if (empty($_POST['reason'])) die ("<p>Please, specify a reason!</p>"); |
10 | -if (preg_match( '/[^\x20-\x7f]/', $_POST['reason'])) |
|
11 | - exit('<p>ERROR: <'.htmlentities($_POST['reason'],ENT_COMPAT | ENT_HTML401, 'ISO-8859-1').'> contains NON ASCII chars.</p>'); |
|
10 | +if (preg_match('/[^\x20-\x7f]/', $_POST['reason'])) |
|
11 | + exit('<p>ERROR: <'.htmlentities($_POST['reason'], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1').'> contains NON ASCII chars.</p>'); |
|
12 | 12 | $user = username(); |
13 | 13 | $err = NULL; |
14 | 14 | |
15 | -if ( ($mysqli = myConnect($dbhost, $userdb, $pwd, $db, $dbport, $tables, $typedesc, $user)) === FALSE ) |
|
16 | - exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error); |
|
15 | +if (($mysqli = myConnect($dbhost, $userdb, $pwd, $db, $dbport, $tables, $typedesc, $user)) === FALSE) |
|
16 | + exit ($user.': Connect Error ('.$mysqli->connect_errno.') '.$mysqli->connect_error); |
|
17 | 17 | |
18 | -if (addtolist ($mysqli,$user,$_POST['value'],$tables["$typedesc"],$_POST['unit'],$_POST['quantity'],$_POST['reason'],$err)) |
|
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'].'.'; |
20 | 20 | else |
21 | 21 | print 'List operation ERROR; check log.'; |
22 | -if (!is_null($err) ) print htmlentities(' Error: ' . $err); |
|
22 | +if (!is_null($err)) print htmlentities(' Error: '.$err); |
|
23 | 23 | $mysqli->close(); |
24 | 24 | closelog(); |
25 | 25 | ?> |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once('config.php'); |
3 | 3 | require_once('function.php'); |
4 | -$typedesc=$_POST['type']; |
|
5 | -$type = $tables["$typedesc"]['field']; |
|
4 | +$typedesc = $_POST['type']; |
|
5 | +$type = $tables["$typedesc"]['field']; |
|
6 | 6 | $table = ($tables["$typedesc"]['milter']) ? milterTable($type) : $tables["$typedesc"]['name']; |
7 | 7 | $cl = ($tables["$typedesc"]['milter']) ? 10 : 9; |
8 | 8 | printf('<td colspan="%d" style="text-align: center">', $cl); |
9 | 9 | openlog($tag, LOG_PID, $fac); |
10 | 10 | $user = username(); |
11 | 11 | |
12 | -if ( ($mysqli = myConnect($dbhost, $userdb, $pwd, $db, $dbport, $tables, $typedesc, $user)) === FALSE ) |
|
13 | - exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error); |
|
14 | -if (remove ($mysqli,$user,$_POST['value'],$type,$table)) |
|
12 | +if (($mysqli = myConnect($dbhost, $userdb, $pwd, $db, $dbport, $tables, $typedesc, $user)) === FALSE) |
|
13 | + exit ($user.': Connect Error ('.$mysqli->connect_errno.') '.$mysqli->connect_error); |
|
14 | +if (remove($mysqli, $user, $_POST['value'], $type, $table)) |
|
15 | 15 | print 'OK '.$typedesc.' <'.$_POST['value'].'> permanently REMOVED!'; |
16 | 16 | else |
17 | 17 | print 'Delete operation ERROR on '.$typedesc.' <'.$_POST['value'].'>; check log.'; |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | $adm = unserialize($_POST["adm"]); |
3 | -if (in_array($_POST["user"],array_keys(array_filter($adm)))) $extopt = '<option value="MONTH">MONTHS</option><option value="YEAR">YEARS</option>'; |
|
3 | +if (in_array($_POST["user"], array_keys(array_filter($adm)))) $extopt = '<option value="MONTH">MONTHS</option><option value="YEAR">YEARS</option>'; |
|
4 | 4 | else $extopt = NULL; |
5 | 5 | |
6 | 6 | require_once('config.php'); |
7 | -$typedesc=$_POST['type']; |
|
7 | +$typedesc = $_POST['type']; |
|
8 | 8 | $cl = ($tables["$typedesc"]['milter']) ? 10 : 9; |
9 | 9 | ?> |
10 | 10 |