@@ -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,18 +87,18 @@ 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']); |
|
| 90 | + case 'ip': |
|
| 91 | + $element[] = long2ip($riga['ip']); |
|
| 92 | + break; |
|
| 93 | + case 'network': |
|
| 94 | + $element[] = long2ip($riga['network']).'/'.long2ip($riga['netmask']); |
|
| 95 | 95 | break; |
| 96 | 96 | case 'text': |
| 97 | 97 | $element[] = sha1($riga['text']); |
| 98 | 98 | break; |
| 99 | - default: |
|
| 99 | + default: |
|
| 100 | 100 | $type = $tables["$typedesc"]['field']; |
| 101 | - $element[] = $riga["$type"]; |
|
| 101 | + $element[] = $riga["$type"]; |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -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 | ?> |
@@ -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;" accept-charset="utf-8" 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.' <'.htmlentities($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> |
|
@@ -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(); |
@@ -1,7 +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>'; |
|
| 4 | -else $extopt = NULL; |
|
| 3 | +if (in_array($_POST["user"],array_keys(array_filter($adm)))) { |
|
| 4 | + $extopt = '<option value="MONTH">MONTHS</option><option value="YEAR">YEARS</option>'; |
|
| 5 | +} else { |
|
| 6 | + $extopt = NULL; |
|
| 7 | +} |
|
| 5 | 8 | |
| 6 | 9 | require_once('config.php'); |
| 7 | 10 | $typedesc=$_POST['type']; |
@@ -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 | $value = iconv(mb_detect_encoding($_POST['value'], mb_detect_order('ISO-8859-1, ISO-8859-15')), "UTF-8", $_POST['value']); |
| 9 | 9 | $cl = ($tables["$typedesc"]['milter']) ? 10 : 9; |
| 10 | 10 | ?> |
@@ -14,11 +14,11 @@ discard block |
||
| 14 | 14 | require_once('function.php'); |
| 15 | 15 | |
| 16 | 16 | checkSSL(); |
| 17 | -if ( $require_auth ) |
|
| 18 | - 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 | 19 | |
| 20 | 20 | |
| 21 | -if ( $imapListActive ) |
|
| 21 | +if ($imapListActive) |
|
| 22 | 22 | print ' <p style="text-align: right"><a href="/spamreport" target="_new">SPAM Learn Observer</a></p>'; |
| 23 | 23 | |
| 24 | 24 | print <<<END |
@@ -27,10 +27,10 @@ discard block |
||
| 27 | 27 | END; |
| 28 | 28 | |
| 29 | 29 | |
| 30 | -$option=NULL; |
|
| 30 | +$option = NULL; |
|
| 31 | 31 | $desc = array_keys($tables); |
| 32 | 32 | foreach ($desc as $description) { |
| 33 | - $disabled = $tables["$description"]['active']==TRUE ? '' : ' disabled'; |
|
| 33 | + $disabled = $tables["$description"]['active'] == TRUE ? '' : ' disabled'; |
|
| 34 | 34 | $option .= '<option value="'.$description."\"$disabled>$description</option>"; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -15,12 +15,14 @@ |
||
| 15 | 15 | require_once('function.php'); |
| 16 | 16 | |
| 17 | 17 | checkSSL(); |
| 18 | -if ( $require_auth ) |
|
| 18 | +if ( $require_auth ) { |
|
| 19 | 19 | if ( username() == 'unknown' ) exit ("<p>You MUST configure your server to use authentication.</p>"); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | |
| 22 | -if ( $imapListActive ) |
|
| 23 | +if ( $imapListActive ) { |
|
| 23 | 24 | print ' <p style="text-align: right"><a href="/spamreport" target="_new">SPAM Learn Observer</a></p>'; |
| 25 | +} |
|
| 24 | 26 | |
| 25 | 27 | print <<<END |
| 26 | 28 | <form name="check" action="result.php" accept-charset="utf-8" onSubmit="xmlhttpPost('result.php', 'check', 'Risultato', '<img src=\'/include/pleasewait.gif\'>'); return false;" enctype="text/plain" method="post" target="_self"> |
@@ -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 */ |
@@ -55,10 +55,15 @@ |
||
| 55 | 55 | 'warn' => NULL |
| 56 | 56 | ); |
| 57 | 57 | |
| 58 | -if (empty($folder)) exit ('<p>No folder found.</p>'); /* This should not occur */ |
|
| 58 | +if (empty($folder)) { |
|
| 59 | + exit ('<p>No folder found.</p>'); |
|
| 60 | +} |
|
| 61 | +/* This should not occur */ |
|
| 59 | 62 | $confimap['user'] = $username; |
| 60 | 63 | $headers = imapFind($confimap, $account, $folder); |
| 61 | -if (empty($headers)) exit (sprintf('<p>No suitable mail found in <b>%s</b> folder.</p>', htmlentities("<$folder>"))); |
|
| 64 | +if (empty($headers)) { |
|
| 65 | + exit (sprintf('<p>No suitable mail found in <b>%s</b> folder.</p>', htmlentities("<$folder>"))); |
|
| 66 | +} |
|
| 62 | 67 | print '<table>'; |
| 63 | 68 | printTableHeader($folder,$data,TRUE,sprintf('Found %d suitable mails.',count($headers))); |
| 64 | 69 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -$path='/var/www/html/RBL/'; |
|
| 2 | +$path = '/var/www/html/RBL/'; |
|
| 3 | 3 | include_once($path.'config.php'); |
| 4 | 4 | require_once($path.'function.php'); |
| 5 | 5 | |
@@ -14,14 +14,14 @@ discard block |
||
| 14 | 14 | $tag .= $conf['syslog']['tag']; |
| 15 | 15 | openlog($tag, LOG_PID, $fac); |
| 16 | 16 | |
| 17 | -if ( $confimap['learn']=='dspamc' ) { |
|
| 17 | +if ($confimap['learn'] == 'dspamc') { |
|
| 18 | 18 | $cmd = escapeshellcmd('which dspamc'); |
| 19 | 19 | $cmd = escapeshellcmd('which ls'); |
| 20 | - exec ( $cmd, $out, $ret ); |
|
| 20 | + exec($cmd, $out, $ret); |
|
| 21 | 21 | if ($ret != 0) { |
| 22 | 22 | $err = 'No DSPAM Client found on your system. Please, force your sysadmin to install "dspamc".'; |
| 23 | 23 | syslog(LOG_ERR, $username.': Error: '.$err); |
| 24 | - exit (sprintf('<p>%s</p>',htmlentities($err))); |
|
| 24 | + exit (sprintf('<p>%s</p>', htmlentities($err))); |
|
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | $headers = imapFind($confimap, $account, $folder); |
| 61 | 61 | if (empty($headers)) exit (sprintf('<p>No suitable mail found in <b>%s</b> folder.</p>', htmlentities("<$folder>"))); |
| 62 | 62 | print '<table>'; |
| 63 | -printTableHeader($folder,$data,TRUE,sprintf('Found %d suitable mails.',count($headers))); |
|
| 63 | +printTableHeader($folder, $data, TRUE, sprintf('Found %d suitable mails.', count($headers))); |
|
| 64 | 64 | |
| 65 | -foreach ( $headers AS $header ) { |
|
| 66 | - $values = imapInfo($username, $header,$conf['host']['ar'],$confimap['dspamtospamass'],$confimap['learn']); |
|
| 65 | +foreach ($headers AS $header) { |
|
| 66 | + $values = imapInfo($username, $header, $conf['host']['ar'], $confimap['dspamtospamass'], $confimap['learn']); |
|
| 67 | 67 | print '<tr>'; |
| 68 | 68 | printTableRow($values, $confimap['learn']); |
| 69 | 69 | print '</tr>'; |