- if (ereg("^\\* [0-9]+ FETCH.*\\{([0-9]+)\\}", $read, $regs)) {
- $size = $regs[1];
- if ($imap_general_debug) {
- echo "<small><tt><font color=\"#CC0000\">Size is $size</font></tt></small><br>\n";
+ // Look through all of the Received headers for IP addresses
+ // Stop when I get ")" on a line
+ // Stop if I get "*" on a line (don't advance)
+ // and above all, stop if $i is bigger than the total # of lines
+ while (($i < count($read)) &&
+ ($read[$i][0] != ')' && $read[$i][0] != '*' &&
+ $read[$i][0] != "\n")) {
+ // Check to see if this line is the right "Received from" line
+ // to check
+ if (is_int(strpos($read[$i], $SpamFilters_YourHop))) {
+ $read[$i] = ereg_replace('[^0-9\.]', ' ', $read[$i]);
+ $elements = explode(' ', $read[$i]);
+ foreach ($elements as $value) {
+ if ($value != '' &&
+ ereg('[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}',
+ $value, $regs)) {
+ $Chunks = explode('.', $value);
+ $IP = $Chunks[3] . '.' . $Chunks[2] . '.' .
+ $Chunks[1] . '.' . $Chunks[0];
+ foreach ($filters as $key => $value) {
+ if ($filters[$key]['enabled'] &&
+ $filters[$key]['dns']) {
+ if (strlen($SpamFilters_DNScache[$IP.'.'.$filters[$key]['dns']]) == 0) {
+ $IPs[$IP] = true;
+ break;
+ }
+ }
+ }
+ // If we've checked one IP and YourHop is
+ // just a space
+ if ($SpamFilters_YourHop == ' ') {
+ break; // don't check any more
+ }
+ }
+ }