$output = '<table width="100%" class="sa_rules_report">' . "\n"; $output .= ' <tr>' . "\n"; $output .= ' <th>' . __('ipaddress04') . '</th>' . "\n"; $output .= ' <th>Hostname</th>' . "\n"; $output .= ' <th>' . __('country04') . '</th>' . "\n"; $output .= ' <th>RBL</th>' . "\n"; $output .= ' <th>Spam</th>' . "\n"; $output .= ' <th>Virus</th>' . "\n"; $output .= ' <th>' . __('all04') . '</th>' . "\n"; $output .= ' </tr>' . "\n"; if (is_array($relays = get_mail_relays($row[$f]))) { foreach ($relays as $relay) { $output .= ' <tr>' . "\n"; $output .= ' <td>' . $relay . '</td>' . "\n"; // check if ipv4 has a port specified (e.g. 10.0.0.10:1025), strip it if found $relay = stripPortFromIp($relay); // Reverse lookup on address. Possibly need to remove it. if (($host = gethostbyaddr($relay)) != $relay) { $output .= " <td>{$host}</td>\n"; } else { $output .= " <td>(Reverse Lookup Failed)</td>\n"; } // Do GeoIP lookup on address if ($geoip_country = return_geoip_country($relay)) { $output .= ' <td>' . $geoip_country . '</td>' . "\n"; } else { $output .= ' <td>(GeoIP Lookup Failed)</td>' . "\n"; } // Link to RBL Lookup $output .= ' <td align="center">[<a href="http://www.mxtoolbox.com/SuperTool.aspx?action=blacklist:' . $relay . '"> </a>]</td>' . "\n"; // Link to Spam Report for this relay
/** * @param $ip * @return bool */ function return_geoip_country($ip) { require_once __DIR__ . '/lib/geoip.inc'; //check if ipv4 has a port specified (e.g. 10.0.0.10:1025), strip it if found $ip = stripPortFromIp($ip); $countryname = false; if (strpos($ip, ':') === false) { //ipv4 if (file_exists('./temp/GeoIP.dat') && filesize('./temp/GeoIP.dat') > 0) { $gi = geoip_open('./temp/GeoIP.dat', GEOIP_STANDARD); $countryname = geoip_country_name_by_addr($gi, $ip); geoip_close($gi); } } else { //ipv6 if (file_exists('./temp/GeoIPv6.dat') && filesize('./temp/GeoIPv6.dat') > 0) { $gi = geoip_open('./temp/GeoIPv6.dat', GEOIP_STANDARD); $countryname = geoip_country_name_by_addr_v6($gi, $ip); geoip_close($gi); } } return $countryname; }