@@ -2,56 +2,56 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | function imapFolder($cf, $username) { |
| 4 | 4 | $return = array(); |
| 5 | - $open='{'.$cf['mailhost'].':143/imap/novalidate-cert/authuser='.$cf['authuser'].'}'; |
|
| 5 | + $open = '{'.$cf['mailhost'].':143/imap/novalidate-cert/authuser='.$cf['authuser'].'}'; |
|
| 6 | 6 | $m_mail = imap_open($open, $username, $cf['authpassword'], OP_READONLY) |
| 7 | - or syslog (LOG_EMERG, $cf['user'].': Error in IMAP connection to <'.$cf['mailhost'].'>: ' . imap_last_error()); |
|
| 8 | - if ( !$m_mail ) exit(254); |
|
| 7 | + or syslog(LOG_EMERG, $cf['user'].': Error in IMAP connection to <'.$cf['mailhost'].'>: '.imap_last_error()); |
|
| 8 | + if (!$m_mail) exit(254); |
|
| 9 | 9 | |
| 10 | 10 | |
| 11 | - syslog (LOG_INFO,$cf['user'].': Successfully connected to <'.$cf['mailhost'].'>; Listing folders of account <'.$username.'>...'); |
|
| 11 | + syslog(LOG_INFO, $cf['user'].': Successfully connected to <'.$cf['mailhost'].'>; Listing folders of account <'.$username.'>...'); |
|
| 12 | 12 | //get all folder |
| 13 | 13 | $list = imap_list($m_mail, $open, "*"); |
| 14 | 14 | imap_close($m_mail); |
| 15 | 15 | if (is_array($list)) |
| 16 | 16 | foreach ($list as $mbox) |
| 17 | - $return[] = explode($open,$mbox,2)[1]; |
|
| 17 | + $return[] = explode($open, $mbox, 2)[1]; |
|
| 18 | 18 | else |
| 19 | - syslog (LOG_INFO,$cf['user'] . ': imap_list failed: ' . imap_last_error() ); |
|
| 19 | + syslog(LOG_INFO, $cf['user'].': imap_list failed: '.imap_last_error()); |
|
| 20 | 20 | return $return; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | -function imapFind ($cf, $username, $folder) { |
|
| 24 | - $head=array(); |
|
| 25 | - $m_mail = imap_open('{'.$cf['mailhost'].':143/imap/novalidate-cert/authuser='.$cf['authuser'].'}'.$folder, $username,$cf['authpassword'], OP_READONLY) |
|
| 26 | - or syslog (LOG_EMERG, $cf['user'].': Error in IMAP connection to <'.$cf['mailhost'].'>: ' . imap_last_error()); |
|
| 27 | - if ( !$m_mail ) exit(254); |
|
| 23 | +function imapFind($cf, $username, $folder) { |
|
| 24 | + $head = array(); |
|
| 25 | + $m_mail = imap_open('{'.$cf['mailhost'].':143/imap/novalidate-cert/authuser='.$cf['authuser'].'}'.$folder, $username, $cf['authpassword'], OP_READONLY) |
|
| 26 | + or syslog(LOG_EMERG, $cf['user'].': Error in IMAP connection to <'.$cf['mailhost'].'>: '.imap_last_error()); |
|
| 27 | + if (!$m_mail) exit(254); |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | - syslog (LOG_INFO,$cf['user'].': Successfully connected to <'.$cf['mailhost'].">; Reading <$folder> messages of last ".$cf['oldestday'].' days on account <'.$username.'>...'); |
|
| 30 | + syslog(LOG_INFO, $cf['user'].': Successfully connected to <'.$cf['mailhost'].">; Reading <$folder> messages of last ".$cf['oldestday'].' days on account <'.$username.'>...'); |
|
| 31 | 31 | //get all messages |
| 32 | - $dateTh = date ( "d-M-Y", strToTime ( '-'.$cf['oldestday'].' days' ) ); |
|
| 33 | - $m_search=imap_search ($m_mail, "SINCE \"$dateTh\" TEXT \"Authentication-Results: \"" ); |
|
| 32 | + $dateTh = date("d-M-Y", strToTime('-'.$cf['oldestday'].' days')); |
|
| 33 | + $m_search = imap_search($m_mail, "SINCE \"$dateTh\" TEXT \"Authentication-Results: \""); |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | // Order results starting from newest message |
| 37 | - if ( empty($m_search) ) { |
|
| 38 | - syslog (LOG_INFO,$cf['user'].": No suitable mail found in <$folder> folder."); |
|
| 39 | - if ( $ierr = imap_errors() ) |
|
| 40 | - foreach ( $ierr as $thiserr ) |
|
| 41 | - syslog (LOG_ERR, $cf['user'].": IMAP Error: $thiserr"); |
|
| 42 | - if ( $ierr = imap_alerts() ) |
|
| 43 | - foreach ( $ierr as $thiserr ) |
|
| 44 | - syslog (LOG_ALERT, $cf['user'].": IMAP Alert: $thiserr"); |
|
| 45 | - imap_close( $m_mail ); |
|
| 37 | + if (empty($m_search)) { |
|
| 38 | + syslog(LOG_INFO, $cf['user'].": No suitable mail found in <$folder> folder."); |
|
| 39 | + if ($ierr = imap_errors()) |
|
| 40 | + foreach ($ierr as $thiserr) |
|
| 41 | + syslog(LOG_ERR, $cf['user'].": IMAP Error: $thiserr"); |
|
| 42 | + if ($ierr = imap_alerts()) |
|
| 43 | + foreach ($ierr as $thiserr) |
|
| 44 | + syslog(LOG_ALERT, $cf['user'].": IMAP Alert: $thiserr"); |
|
| 45 | + imap_close($m_mail); |
|
| 46 | 46 | return FALSE; |
| 47 | 47 | } |
| 48 | - $nmes = count ($m_search); |
|
| 49 | - syslog (LOG_INFO,$cf['user'].": Found $nmes mail in <$folder> folder."); |
|
| 48 | + $nmes = count($m_search); |
|
| 49 | + syslog(LOG_INFO, $cf['user'].": Found $nmes mail in <$folder> folder."); |
|
| 50 | 50 | if ($nmes>0) rsort($m_search); |
| 51 | 51 | |
| 52 | 52 | // loop for each message |
| 53 | 53 | foreach ($m_search as $onem) |
| 54 | - $head[] = imap_fetchheader($m_mail, $onem ); |
|
| 54 | + $head[] = imap_fetchheader($m_mail, $onem); |
|
| 55 | 55 | imap_close($m_mail); |
| 56 | 56 | return $head; |
| 57 | 57 | } |
@@ -59,11 +59,11 @@ discard block |
||
| 59 | 59 | function dspamLevel($prob, $conf) { |
| 60 | 60 | /* Calculate DSPAM Level as the Spamassassin Plugin */ |
| 61 | 61 | if (is_null($prob) or is_null($conf)) return '-'; |
| 62 | - $t_prob = abs((($prob - 0.5) * 2) * 100); |
|
| 63 | - return round(($t_prob + ($conf*100)) / 2); |
|
| 62 | + $t_prob = abs((($prob-0.5) * 2) * 100); |
|
| 63 | + return round(($t_prob+($conf * 100)) / 2); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | -function imapInfo($user,$header,$ARhosts,$dpl=false, $learn=false) { |
|
| 66 | +function imapInfo($user, $header, $ARhosts, $dpl = false, $learn = false) { |
|
| 67 | 67 | /* Get relevant Info from header's mail */ |
| 68 | 68 | /* Each line must end with /r/n */ |
| 69 | 69 | |
@@ -97,118 +97,118 @@ discard block |
||
| 97 | 97 | ); |
| 98 | 98 | |
| 99 | 99 | |
| 100 | - if ( preg_match_all ('/^Authentication\-Results:\s+(?<host>[\w\.]+);(?:\s+|\r\n\s+)dmarc=(?<dmarc>\w+)\s+\(p=\w+\s+dis=\w+\)\s+header\.from=(?<DMARCfrom>[\w\.]+)/m',$header,$received) ) { |
|
| 101 | - $k=0; |
|
| 102 | - for ($i = count($received[0])-1;$i>=0;$i--) { |
|
| 100 | + if (preg_match_all('/^Authentication\-Results:\s+(?<host>[\w\.]+);(?:\s+|\r\n\s+)dmarc=(?<dmarc>\w+)\s+\(p=\w+\s+dis=\w+\)\s+header\.from=(?<DMARCfrom>[\w\.]+)/m', $header, $received)) { |
|
| 101 | + $k = 0; |
|
| 102 | + for ($i = count($received[0])-1; $i>=0; $i--) { |
|
| 103 | 103 | foreach ($ARhosts as $mx) { |
| 104 | 104 | if ($mx == $received['host'][$i]) { |
| 105 | 105 | /* This is a trusted AR result */ |
| 106 | - $result['dmarc']['result']=$received['dmarc'][$i]; |
|
| 106 | + $result['dmarc']['result'] = $received['dmarc'][$i]; |
|
| 107 | 107 | $result['dmarc']['dom'] = $received['DMARCfrom'][$i]; |
| 108 | 108 | $k++; |
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | - $received=NULL; |
|
| 113 | + $received = NULL; |
|
| 114 | 114 | if ($k>1) $result['warn'][] = 'The trusted DMARC AR Headers are present more than once. Something wrong.'; |
| 115 | 115 | |
| 116 | - if ( preg_match_all('/^Authentication\-Results:\s+(?<host>[\w\.]+);(?:\s+|\r\n\s+)spf=(?<spf>\w+)\s+smtp\.(?:mailfrom|helo)=(?<SPFfrom>[\w\.]+)/m',$header,$received) ) { |
|
| 117 | - $k=0; |
|
| 118 | - for ($i = count($received[0])-1;$i>=0;$i--) { |
|
| 116 | + if (preg_match_all('/^Authentication\-Results:\s+(?<host>[\w\.]+);(?:\s+|\r\n\s+)spf=(?<spf>\w+)\s+smtp\.(?:mailfrom|helo)=(?<SPFfrom>[\w\.]+)/m', $header, $received)) { |
|
| 117 | + $k = 0; |
|
| 118 | + for ($i = count($received[0])-1; $i>=0; $i--) { |
|
| 119 | 119 | foreach ($ARhosts as $mx) { |
| 120 | 120 | if ($mx == $received['host'][$i]) { |
| 121 | 121 | /* This is a trusted AR result */ |
| 122 | - $result['spf']['result']=$received['spf'][$i]; |
|
| 122 | + $result['spf']['result'] = $received['spf'][$i]; |
|
| 123 | 123 | $result['spf']['dom'] = $received['SPFfrom'][$i]; |
| 124 | 124 | $k++; |
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | - $received=NULL; |
|
| 129 | + $received = NULL; |
|
| 130 | 130 | if ($k>1) $result['warn'][] = 'The trusted SPF AR Headers are present more than once. Something wrong.'; |
| 131 | 131 | |
| 132 | - $k=0; |
|
| 133 | - if ( preg_match_all('/^Authentication\-Results:\s+(?<host>[\w\.]+);(?:\s+|\r\n\s+)dkim=(?<dkim>\w+)\s+[\w\s\(\)\-]+header\.d=(?<DKIMdom>[\w\.]+)/m',$header,$received) ) { |
|
| 134 | - for ($i = count($received[0])-1;$i>=0;$i--) { |
|
| 132 | + $k = 0; |
|
| 133 | + if (preg_match_all('/^Authentication\-Results:\s+(?<host>[\w\.]+);(?:\s+|\r\n\s+)dkim=(?<dkim>\w+)\s+[\w\s\(\)\-]+header\.d=(?<DKIMdom>[\w\.]+)/m', $header, $received)) { |
|
| 134 | + for ($i = count($received[0])-1; $i>=0; $i--) { |
|
| 135 | 135 | foreach ($ARhosts as $mx) { |
| 136 | 136 | if ($mx == $received['host'][$i]) { |
| 137 | 137 | /* This is a trusted AR result */ |
| 138 | - $result['dkim']['result']=$received['dkim'][$i]; |
|
| 138 | + $result['dkim']['result'] = $received['dkim'][$i]; |
|
| 139 | 139 | $result['dkim']['dom'] = $received['DKIMdom'][$i]; |
| 140 | 140 | $k++; |
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | } |
| 145 | - $received=NULL; |
|
| 145 | + $received = NULL; |
|
| 146 | 146 | if ($k>1) $result['warn'][] = 'The trusted DKIM AR Headers are present more than once. Something wrong.'; |
| 147 | 147 | |
| 148 | 148 | if ($dpl) { /* Use Spamassassin Plugin */ |
| 149 | - if ( preg_match_all('/^X\-Spam\-Status:\s(?P<spamstatus>\w+)\,(?:\s+|\r\n\s+)score=(?P<score>[\-\.\d]+)(?:\s+|\r\n\s+)tagged_above=\-{0,1}\d+(?:\s+|\r\n\s+)required=(?P<th>[\-\.\d]+)(?:\s+|\r\n\s+)tests=\[(?:.|\r\n\s+)*DSPAM_(?P<dtype>SPAM|HAM)_(?P<dlevel>\d\d)(?:.|\r\n\s+)*\]/m',$header,$received) ) { |
|
| 150 | - $result['spam']['status']=$received['spamstatus'][0]; |
|
| 149 | + if (preg_match_all('/^X\-Spam\-Status:\s(?P<spamstatus>\w+)\,(?:\s+|\r\n\s+)score=(?P<score>[\-\.\d]+)(?:\s+|\r\n\s+)tagged_above=\-{0,1}\d+(?:\s+|\r\n\s+)required=(?P<th>[\-\.\d]+)(?:\s+|\r\n\s+)tests=\[(?:.|\r\n\s+)*DSPAM_(?P<dtype>SPAM|HAM)_(?P<dlevel>\d\d)(?:.|\r\n\s+)*\]/m', $header, $received)) { |
|
| 150 | + $result['spam']['status'] = $received['spamstatus'][0]; |
|
| 151 | 151 | $result['spam']['score'] = $received['score'][0]; |
| 152 | 152 | $result['spam']['th'] = $received['th'][0]; |
| 153 | 153 | $result['dspam']['type'] = $received['dtype'][0]; |
| 154 | - $result['dspam']['level'] =$received['dlevel'][0]; |
|
| 154 | + $result['dspam']['level'] = $received['dlevel'][0]; |
|
| 155 | 155 | } |
| 156 | 156 | if (count($received[0])>1) $result['warn'][] = 'The Spamassassin Headers are present more than once. I consider only the last one.'; |
| 157 | 157 | } |
| 158 | 158 | else { /* Parse apart all DSPAM Header and calculate a level */ |
| 159 | - if ( preg_match_all('/^X\-Spam\-Status:\s(?P<spamstatus>\w+)\,(?:\s+|\r\n\s+)score=(?P<score>[\-\.\d]+)(?:\s+|\r\n\s+)tagged_above=\-{0,1}\d+(?:\s+|\r\n\s+)required=(?P<th>[\-\.\d]+)(?:\s+|\r\n\s+)tests=\[(?:.|\r\n\s+)*\]/m',$header,$received) ) { |
|
| 160 | - $result['spam']['status']=$received['spamstatus'][0]; |
|
| 159 | + if (preg_match_all('/^X\-Spam\-Status:\s(?P<spamstatus>\w+)\,(?:\s+|\r\n\s+)score=(?P<score>[\-\.\d]+)(?:\s+|\r\n\s+)tagged_above=\-{0,1}\d+(?:\s+|\r\n\s+)required=(?P<th>[\-\.\d]+)(?:\s+|\r\n\s+)tests=\[(?:.|\r\n\s+)*\]/m', $header, $received)) { |
|
| 160 | + $result['spam']['status'] = $received['spamstatus'][0]; |
|
| 161 | 161 | $result['spam']['score'] = $received['score'][0]; |
| 162 | 162 | $result['spam']['th'] = $received['th'][0]; |
| 163 | 163 | if (count($received[0])>1) |
| 164 | - $result['warn'][]= 'The Spamassassin Headers are present more than once. I consider only the last one.'; |
|
| 164 | + $result['warn'][] = 'The Spamassassin Headers are present more than once. I consider only the last one.'; |
|
| 165 | 165 | } |
| 166 | - if ( preg_match ('/\r\nX\-DSPAM\-Result:\s(?P<result>.*)\r\n/',$header,$received) != 1) |
|
| 166 | + if (preg_match('/\r\nX\-DSPAM\-Result:\s(?P<result>.*)\r\n/', $header, $received) != 1) |
|
| 167 | 167 | $result['warn'] = 'DSPAM Result invalid, not present or present more than once.'; |
| 168 | 168 | else |
| 169 | - $result['dspam']['type']=$received['result']; |
|
| 169 | + $result['dspam']['type'] = $received['result']; |
|
| 170 | 170 | $prob = NULL; |
| 171 | 171 | $conf = NULL; |
| 172 | - if ( preg_match ('/\r\nX\-DSPAM\-Probability:\s(?P<prob>.*)\r\n/',$header,$received) != 1) |
|
| 172 | + if (preg_match('/\r\nX\-DSPAM\-Probability:\s(?P<prob>.*)\r\n/', $header, $received) != 1) |
|
| 173 | 173 | $result['warn'][] = 'DSPAM Probability invalid, not present or present more than once.'; |
| 174 | 174 | else |
| 175 | 175 | $prob = $received['prob']; |
| 176 | - if ( preg_match ('/\r\nX\-DSPAM\-Confidence:\s(?P<conf>.*)\r\n/',$header,$received) != 1) |
|
| 176 | + if (preg_match('/\r\nX\-DSPAM\-Confidence:\s(?P<conf>.*)\r\n/', $header, $received) != 1) |
|
| 177 | 177 | $result['warn'][] = 'DSPAM Confidence invalid, not present or present more than once.'; |
| 178 | 178 | else |
| 179 | 179 | $conf = $received['conf']; |
| 180 | - $result['dspam']['level'] = dspamLevel($prob,$conf); |
|
| 180 | + $result['dspam']['level'] = dspamLevel($prob, $conf); |
|
| 181 | 181 | } |
| 182 | - $received=NULL; |
|
| 183 | - if ( preg_match ('/\r\nFrom:\s(?P<from>.*)\r\n/',$header,$received) != 1) |
|
| 182 | + $received = NULL; |
|
| 183 | + if (preg_match('/\r\nFrom:\s(?P<from>.*)\r\n/', $header, $received) != 1) |
|
| 184 | 184 | $result['warn'][] = 'From header invalid or not present'; |
| 185 | 185 | else |
| 186 | 186 | $result['from'] = $received['from']; |
| 187 | 187 | |
| 188 | - if ( preg_match ('/\r\nDate:\s(?P<date>.*)\r\n/',$header,$received) != 1) |
|
| 188 | + if (preg_match('/\r\nDate:\s(?P<date>.*)\r\n/', $header, $received) != 1) |
|
| 189 | 189 | $result['warn'][] = 'Date header invalid or not present'; |
| 190 | 190 | else |
| 191 | 191 | $result['date'] = $received['date']; |
| 192 | 192 | |
| 193 | - $received=NULL; |
|
| 194 | - if ( preg_match ('/\r\nMessage\-I(?:D|d):\s(?P<mid>.*)\r\n/',$header,$received) != 1) |
|
| 193 | + $received = NULL; |
|
| 194 | + if (preg_match('/\r\nMessage\-I(?:D|d):\s(?P<mid>.*)\r\n/', $header, $received) != 1) |
|
| 195 | 195 | $result['warn'][] = 'Message-ID invalid, not present or present more than once.'; |
| 196 | 196 | else |
| 197 | - $result['messageid']=$received['mid']; |
|
| 197 | + $result['messageid'] = $received['mid']; |
|
| 198 | 198 | |
| 199 | - $received=NULL; |
|
| 199 | + $received = NULL; |
|
| 200 | 200 | |
| 201 | 201 | switch ($learn) { |
| 202 | 202 | case 'dspamc': |
| 203 | - if ( preg_match ('/\r\nX\-DSPAM\-Signature:\s(?P<sig>.*)\r\n/',$header,$received) != 1) |
|
| 203 | + if (preg_match('/\r\nX\-DSPAM\-Signature:\s(?P<sig>.*)\r\n/', $header, $received) != 1) |
|
| 204 | 204 | $result['warn'] = 'DSPAM Signature invalid, not present or present more than once.'; |
| 205 | 205 | else |
| 206 | - $result['dspam']['learn']=$received['sig']; |
|
| 206 | + $result['dspam']['learn'] = $received['sig']; |
|
| 207 | 207 | break; |
| 208 | 208 | case false: |
| 209 | 209 | break; |
| 210 | 210 | default: |
| 211 | - syslog (LOG_INFO,$user.': Error in "learn" imap configuration value. Please, set "dspamc" or "false".'); |
|
| 211 | + syslog(LOG_INFO, $user.': Error in "learn" imap configuration value. Please, set "dspamc" or "false".'); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | return $result; |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | |
| 218 | 218 | |
| 219 | 219 | |
| 220 | -function printTableHeader($title,$content,$footer=FALSE,$fcontent) { |
|
| 220 | +function printTableHeader($title, $content, $footer = FALSE, $fcontent) { |
|
| 221 | 221 | print <<<END |
| 222 | 222 | <caption>$title</caption> |
| 223 | 223 | <thead> |
@@ -225,21 +225,19 @@ discard block |
||
| 225 | 225 | END; |
| 226 | 226 | $kcontent = array_keys($content); |
| 227 | 227 | $cols = count($kcontent); |
| 228 | - for ($i=0; $i<$cols; $i++) { |
|
| 228 | + for ($i = 0; $i<$cols; $i++) { |
|
| 229 | 229 | $key = $kcontent[$i]; |
| 230 | - printf ('<th colspan="%d" rowspan="%d">%s</th>', |
|
| 231 | - !is_array($content[$key]) ?: |
|
| 232 | - count(array_keys($content[$key])) ?: '1', |
|
| 233 | - !is_array($content[$key]) ?: |
|
| 234 | - empty(array_keys($content[$key])) ? '2' : '1', |
|
| 230 | + printf('<th colspan="%d" rowspan="%d">%s</th>', |
|
| 231 | + !is_array($content[$key]) ?: count(array_keys($content[$key])) ?: '1', |
|
| 232 | + !is_array($content[$key]) ?: empty(array_keys($content[$key])) ? '2' : '1', |
|
| 235 | 233 | $kcontent[$i]); |
| 236 | 234 | } |
| 237 | 235 | print '</tr><tr>'; |
| 238 | - for ($i=0; $i<$cols; $i++) { |
|
| 236 | + for ($i = 0; $i<$cols; $i++) { |
|
| 239 | 237 | $key = $kcontent[$i]; |
| 240 | - if (is_array($content[$key])&&($hs = array_keys($content[$key]))) { |
|
| 238 | + if (is_array($content[$key]) && ($hs = array_keys($content[$key]))) { |
|
| 241 | 239 | foreach ($hs as $h) |
| 242 | - printf('<th>%s</th>',$h); |
|
| 240 | + printf('<th>%s</th>', $h); |
|
| 243 | 241 | } |
| 244 | 242 | } |
| 245 | 243 | |
@@ -255,7 +253,7 @@ discard block |
||
| 255 | 253 | |
| 256 | 254 | function formatVal($val, $learn) { |
| 257 | 255 | foreach (array_keys($val) as $key) { |
| 258 | - if (is_array($val["$key"]) and ($key!='warn')) |
|
| 256 | + if (is_array($val["$key"]) and ($key != 'warn')) |
|
| 259 | 257 | $val["$key"] = formatVal($val["$key"], $learn); |
| 260 | 258 | else { |
| 261 | 259 | switch ($key) { |
@@ -263,7 +261,7 @@ discard block |
||
| 263 | 261 | if (empty($val["$key"])) |
| 264 | 262 | $val["$key"] = '-'; |
| 265 | 263 | else |
| 266 | - $val["$key"] = sprintf('<div title="%s">Y</div>',implode($val["$key"],"\n")); |
|
| 264 | + $val["$key"] = sprintf('<div title="%s">Y</div>', implode($val["$key"], "\n")); |
|
| 267 | 265 | break; |
| 268 | 266 | case 'learn': |
| 269 | 267 | $val["$key"] = formLearn($learn, $val); |
@@ -285,26 +283,26 @@ discard block |
||
| 285 | 283 | $par['class'] = $class; |
| 286 | 284 | $val["$class"] = sprintf('dspamc --user dspam --deliver=summary --class=%s --source=error --signature=%s', |
| 287 | 285 | strtolower($class), $par['learn']); |
| 288 | - if (($class != $par['type'])||($par['level']<99)) |
|
| 286 | + if (($class != $par['type']) || ($par['level']<99)) |
|
| 289 | 287 | $return .= sprintf(file_get_contents('formLearnDSPAM.htm'), |
| 290 | - $class,$class,$val["$class"],base64_encode(json_encode($par)),$class); |
|
| 288 | + $class, $class, $val["$class"], base64_encode(json_encode($par)), $class); |
|
| 291 | 289 | } |
| 292 | 290 | default: |
| 293 | 291 | return $return; |
| 294 | 292 | } |
| 295 | 293 | } |
| 296 | 294 | |
| 297 | -function printTableRow($row, $learn, $init=true) { |
|
| 295 | +function printTableRow($row, $learn, $init = true) { |
|
| 298 | 296 | $color = 'inherit'; |
| 299 | 297 | if ($init) |
| 300 | - $row=formatVal($row,$learn); |
|
| 301 | - foreach( $row as $key => $val) { |
|
| 298 | + $row = formatVal($row, $learn); |
|
| 299 | + foreach ($row as $key => $val) { |
|
| 302 | 300 | if (is_array($val)) |
| 303 | 301 | printTableRow($val, $learn, false); |
| 304 | 302 | else { |
| 305 | 303 | /* DSPAM format */ |
| 306 | 304 | if (isset($row['type'])) |
| 307 | - switch($row['type']) { |
|
| 305 | + switch ($row['type']) { |
|
| 308 | 306 | case 'Innocent': |
| 309 | 307 | case 'HAM': |
| 310 | 308 | $color = 'rgba(0,255,0, %.1f)'; |
@@ -315,7 +313,7 @@ discard block |
||
| 315 | 313 | } |
| 316 | 314 | /* DMARC, DKIM, SPF format */ |
| 317 | 315 | if (isset($row['result'])) |
| 318 | - switch($row['result']) { |
|
| 316 | + switch ($row['result']) { |
|
| 319 | 317 | case 'pass': |
| 320 | 318 | $color = 'rgba(0,255,0, %.1f)'; |
| 321 | 319 | break; |
@@ -324,7 +322,7 @@ discard block |
||
| 324 | 322 | } |
| 325 | 323 | /* Spamassassin format */ |
| 326 | 324 | if (isset($row['status'])) |
| 327 | - switch($row['status']) { |
|
| 325 | + switch ($row['status']) { |
|
| 328 | 326 | case 'No': |
| 329 | 327 | $color = 'rgba(0,255,0, %.1f)'; |
| 330 | 328 | break; |
@@ -332,9 +330,9 @@ discard block |
||
| 332 | 330 | $color = 'rgba(255,0,0,%.1f)'; |
| 333 | 331 | } |
| 334 | 332 | |
| 335 | - $alpha = (is_numeric($val)AND($key=='type')) ? round($val/100,1) : 1.0; |
|
| 333 | + $alpha = (is_numeric($val) AND ($key == 'type')) ? round($val / 100, 1) : 1.0; |
|
| 336 | 334 | $bg = sprintf(" style=\"background-color: $color\"", $alpha); |
| 337 | - printf ('<td%s>%s</td>',$bg, $val); |
|
| 335 | + printf('<td%s>%s</td>', $bg, $val); |
|
| 338 | 336 | } |
| 339 | 337 | } |
| 340 | 338 | } |
@@ -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>'; |