@@ -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 | ?> |
@@ -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'); |
@@ -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,15 +87,15 @@ 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: |
|
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 | 97 | $type = $tables["$typedesc"]['field']; |
98 | - $element[] = $riga["$type"]; |
|
98 | + $element[] = $riga["$type"]; |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
@@ -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>'; |
@@ -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,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 ); |
@@ -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 | ?> |
@@ -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.'; |
@@ -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.'; |
@@ -4,8 +4,9 @@ discard block |
||
4 | 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 | 11 | <td colspan="10" style="text-align: center"> |
11 | 12 | |
@@ -14,31 +15,35 @@ discard block |
||
14 | 15 | $user = $_POST['user']; |
15 | 16 | |
16 | 17 | /* Compare old values with new ones */ |
17 | -if (isset($_POST['newvalues'])) |
|
18 | +if (isset($_POST['newvalues'])) { |
|
18 | 19 | $new = $_POST['newvalues']; |
19 | -else |
|
20 | +} else { |
|
20 | 21 | $new = array(); |
21 | -if (! empty($_POST['oldvalues'])) |
|
22 | +} |
|
23 | +if (! empty($_POST['oldvalues'])) { |
|
22 | 24 | $old = explode(',', $_POST['oldvalues']); |
23 | -else |
|
25 | +} else { |
|
24 | 26 | $old=array(); |
27 | +} |
|
25 | 28 | $values=array(); |
26 | 29 | $logs=array(); |
27 | 30 | |
28 | 31 | print '<pre>'; |
29 | 32 | /* Check need to disable all milters, removing unnecessary setting */ |
30 | -if ( in_array('DISABLE ALL', $new) ) |
|
33 | +if ( in_array('DISABLE ALL', $new) ) { |
|
31 | 34 | $new = array('DISABLE ALL'); |
35 | +} |
|
32 | 36 | |
33 | 37 | /* Compare the values determining what to do */ |
34 | 38 | if (count(array_diff(array_merge($new, $old), array_intersect($new, $old))) !== 0) { |
35 | 39 | /* New and old are different (we assume we don't have duplicate values) */ |
36 | 40 | if (! empty($new) ) { |
37 | 41 | foreach ($new as $item) { |
38 | - if ( in_array($item, $old) ) |
|
39 | - $values["$item"] = 'keep'; |
|
40 | - else |
|
41 | - $values["$item"] = 'add'; |
|
42 | + if ( in_array($item, $old) ) { |
|
43 | + $values["$item"] = 'keep'; |
|
44 | + } else { |
|
45 | + $values["$item"] = 'add'; |
|
46 | + } |
|
42 | 47 | $logs[] = "<$item>: ". $values["$item"]; |
43 | 48 | } |
44 | 49 | } |
@@ -53,22 +58,25 @@ discard block |
||
53 | 58 | } |
54 | 59 | |
55 | 60 | /* Logging */ |
56 | -if ( empty($values) ) |
|
61 | +if ( empty($values) ) { |
|
57 | 62 | print 'No values to change.'; |
58 | -else { |
|
63 | +} else { |
|
59 | 64 | $msg = sprintf('%s: Changing Milter setting on list <%s> for %s <%s>.',$user,$typedesc,$type, $_POST['object']); |
60 | 65 | syslog(LOG_INFO, $msg); |
61 | - foreach ($logs as $log) |
|
62 | - syslog(LOG_INFO, "$user: milter $log"); |
|
66 | + foreach ($logs as $log) { |
|
67 | + syslog(LOG_INFO, "$user: milter $log"); |
|
68 | + } |
|
63 | 69 | |
64 | 70 | /* 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); |
|
71 | + if ( ($mysqli = myConnect($dbhost, $userdb, $pwd, $db, $dbport, $tables, $typedesc, $user)) === FALSE ) { |
|
72 | + exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error); |
|
73 | + } |
|
67 | 74 | |
68 | - if (changeMilter ($mysqli,$user,$values,$col,$_POST['miltId'])) |
|
69 | - print 'OK milter setting changed.'; |
|
70 | - else |
|
71 | - print 'ERROR updating milter setting; check your syslog. No changes made.'; |
|
75 | + if (changeMilter ($mysqli,$user,$values,$col,$_POST['miltId'])) { |
|
76 | + print 'OK milter setting changed.'; |
|
77 | + } else { |
|
78 | + print 'ERROR updating milter setting; check your syslog. No changes made.'; |
|
79 | + } |
|
72 | 80 | |
73 | 81 | $mysqli->close(); |
74 | 82 | } |
@@ -1,11 +1,14 @@ |
||
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 | if ( $tables["$typedesc"]['milter'] ) { |
6 | - if ( checkMilterConf($tables["$typedesc"]) ) |
|
7 | - print '<p>This is a milter table. Please, first add your item as usual. Then you will be able to customize the milter settings.</p>'; |
|
8 | - else { |
|
9 | + if ( checkMilterConf($tables["$typedesc"]) ) { |
|
10 | + print '<p>This is a milter table. Please, first add your item as usual. Then you will be able to customize the milter settings.</p>'; |
|
11 | + } else { |
|
9 | 12 | $err = "Error in config about <$typedesc>. Check at your config.php."; |
10 | 13 | syslog (LOG_EMERG, $err); |
11 | 14 | printf ('<p>%s</p>', htmlspecialchars($err) ); |
@@ -1,14 +1,14 @@ discard block |
||
1 | 1 | <?php |
2 | -if (in_array($user,array_keys(array_filter($adm)))) $extopt = '<option value="MONTH">MONTHS</option><option value="YEAR">YEARS</option>'; |
|
2 | +if (in_array($user, array_keys(array_filter($adm)))) $extopt = '<option value="MONTH">MONTHS</option><option value="YEAR">YEARS</option>'; |
|
3 | 3 | else $extopt = NULL; |
4 | 4 | |
5 | -if ( $tables["$typedesc"]['milter'] ) { |
|
6 | - if ( checkMilterConf($tables["$typedesc"]) ) |
|
5 | +if ($tables["$typedesc"]['milter']) { |
|
6 | + if (checkMilterConf($tables["$typedesc"])) |
|
7 | 7 | print '<p>This is a milter table. Please, first add your item as usual. Then you will be able to customize the milter settings.</p>'; |
8 | 8 | else { |
9 | 9 | $err = "Error in config about <$typedesc>. Check at your config.php."; |
10 | - syslog (LOG_EMERG, $err); |
|
11 | - printf ('<p>%s</p>', htmlspecialchars($err) ); |
|
10 | + syslog(LOG_EMERG, $err); |
|
11 | + printf('<p>%s</p>', htmlspecialchars($err)); |
|
12 | 12 | } |
13 | 13 | } |
14 | 14 | |
@@ -16,4 +16,4 @@ discard block |
||
16 | 16 | <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;" /> |
17 | 17 | |
18 | 18 | List <?php echo $typedesc.' <'.$value.'>'; ?> for <input name="type" type="hidden" value="<?php echo $typedesc; ?>" /><input name="value" type="hidden" class="input_text" value="<?php echo $value; ?>" /> |
19 | - <select name="quantity" class="input_text" size="1"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="20">20</option></select><select class="input_text" name="unit" size="1"><option value="DAY">DAYS</option><option value="WEEK">WEEKS</option><?php echo $extopt;?></select> Reason:<input maxlength="128" name="reason" size="30" type="text" class="input_text" /><input name="List" class="button" id="bwarn" type="submit" value="List"/></form> |
|
19 | + <select name="quantity" class="input_text" size="1"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="20">20</option></select><select class="input_text" name="unit" size="1"><option value="DAY">DAYS</option><option value="WEEK">WEEKS</option><?php echo $extopt; ?></select> Reason:<input maxlength="128" name="reason" size="30" type="text" class="input_text" /><input name="List" class="button" id="bwarn" type="submit" value="List"/></form> |
@@ -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'])) |
@@ -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'; |
@@ -9,19 +9,26 @@ |
||
9 | 9 | <td colspan="<?php echo $cl; ?>" style="text-align: center"> |
10 | 10 | <?php |
11 | 11 | openlog($tag, LOG_PID, $fac); |
12 | -if (empty($_POST['reason'])) die ("Specify a reason, please!</td>"); |
|
13 | -if (preg_match( '/[^\x20-\x7f]/', $_POST['reason'])) |
|
12 | +if (empty($_POST['reason'])) { |
|
13 | + die ("Specify a reason, please!</td>"); |
|
14 | +} |
|
15 | +if (preg_match( '/[^\x20-\x7f]/', $_POST['reason'])) { |
|
14 | 16 | exit('ERROR: <'.htmlentities($_POST['reason'],ENT_COMPAT | ENT_HTML401, 'ISO-8859-1').'> contains NON ASCII chars.</td>'); |
17 | +} |
|
15 | 18 | $user = username(); |
16 | 19 | |
17 | -if ( ($mysqli = myConnect($dbhost, $userdb, $pwd, $db, $dbport, $tables, $typedesc, $user)) === FALSE ) |
|
20 | +if ( ($mysqli = myConnect($dbhost, $userdb, $pwd, $db, $dbport, $tables, $typedesc, $user)) === FALSE ) { |
|
18 | 21 | exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error); |
22 | +} |
|
19 | 23 | |
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'])) |
|
24 | +if (isFull($mysqli,$typedesc,$tables)) { |
|
25 | + die("ERROR in relist: ".htmlspecialchars("$typedesc has reached maximum value of ".$tables["$typedesc"]['limit'].' listed items.') ); |
|
26 | +} |
|
27 | +if (relist ($mysqli,username(),$_POST['value'],$type,$table,$_POST['unit'],$_POST['quantity'],$_POST['reason'])) { |
|
22 | 28 | print 'OK '.$_POST["type"].' <'.$_POST['value'].'> relisted for '.$_POST['quantity'].$_POST['unit']; |
23 | -else |
|
29 | +} else { |
|
24 | 30 | print 'ERROR in relist; check log'; |
31 | +} |
|
25 | 32 | $mysqli->close(); |
26 | 33 | closelog(); |
27 | 34 | print '</td>'; |
@@ -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'].'.'; |
@@ -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 | ?> |
@@ -6,20 +6,27 @@ |
||
6 | 6 | $table = ($tables["$typedesc"]['milter']) ? milterTable($type) : $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 | $err = NULL; |
14 | 17 | |
15 | -if ( ($mysqli = myConnect($dbhost, $userdb, $pwd, $db, $dbport, $tables, $typedesc, $user)) === FALSE ) |
|
18 | +if ( ($mysqli = myConnect($dbhost, $userdb, $pwd, $db, $dbport, $tables, $typedesc, $user)) === FALSE ) { |
|
16 | 19 | exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error); |
20 | +} |
|
17 | 21 | |
18 | -if (addtolist ($mysqli,$user,$_POST['value'],$tables["$typedesc"],$_POST['unit'],$_POST['quantity'],$_POST['reason'],$err)) |
|
22 | +if (addtolist ($mysqli,$user,$_POST['value'],$tables["$typedesc"],$_POST['unit'],$_POST['quantity'],$_POST['reason'],$err)) { |
|
19 | 23 | print 'OK '.$_POST["type"].' <'.$_POST['value'].'> first time listed for '.$_POST['quantity'].$_POST['unit'].'.'; |
20 | -else |
|
24 | +} else { |
|
21 | 25 | print 'List operation ERROR; check log.'; |
22 | -if (!is_null($err) ) print htmlentities(' Error: ' . $err); |
|
26 | +} |
|
27 | +if (!is_null($err) ) { |
|
28 | + print htmlentities(' Error: ' . $err); |
|
29 | +} |
|
23 | 30 | $mysqli->close(); |
24 | 31 | closelog(); |
25 | 32 | ?> |
@@ -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 |
@@ -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.'; |
@@ -9,12 +9,14 @@ |
||
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 ) |
|
12 | +if ( ($mysqli = myConnect($dbhost, $userdb, $pwd, $db, $dbport, $tables, $typedesc, $user)) === FALSE ) { |
|
13 | 13 | exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error); |
14 | -if (remove ($mysqli,$user,$_POST['value'],$type,$table)) |
|
14 | +} |
|
15 | +if (remove ($mysqli,$user,$_POST['value'],$type,$table)) { |
|
15 | 16 | print 'OK '.$typedesc.' <'.$_POST['value'].'> permanently REMOVED!'; |
16 | -else |
|
17 | +} else { |
|
17 | 18 | print 'Delete operation ERROR on '.$typedesc.' <'.$_POST['value'].'>; check log.'; |
19 | +} |
|
18 | 20 | print '</td>'; |
19 | 21 | $mysqli->close(); |
20 | 22 | closelog(); |