public function getDatabaseVersions() { $dbs = array('GEOIP_COUNTRY_EDITION' => GEOIP_COUNTRY_EDITION, 'GEOIP_REGION_EDITION_REV0' => GEOIP_REGION_EDITION_REV0, 'GEOIP_CITY_EDITION_REV0' => GEOIP_CITY_EDITION_REV0, 'GEOIP_ORG_EDITION' => GEOIP_ORG_EDITION, 'GEOIP_ISP_EDITION' => GEOIP_ISP_EDITION, 'GEOIP_CITY_EDITION_REV1' => GEOIP_CITY_EDITION_REV1, 'GEOIP_REGION_EDITION_REV1' => GEOIP_REGION_EDITION_REV1, 'GEOIP_PROXY_EDITION' => GEOIP_PROXY_EDITION, 'GEOIP_ASNUM_EDITION' => GEOIP_ASNUM_EDITION, 'GEOIP_NETSPEED_EDITION' => GEOIP_NETSPEED_EDITION, 'GEOIP_DOMAIN_EDITION' => GEOIP_DOMAIN_EDITION); $res = array(); foreach ($dbs as $name => $id) { if (!\geoip_db_avail($id)) { continue; } $info = \geoip_database_info($id); $x = explode(' ', $info); $res[] = array('name' => $name, 'file' => \geoip_db_filename($id), 'date' => $x[1], 'version' => $x[0]); } return $res; }
/** * Get GeoIp Version release * Return an array with keys "country" & "city" * @access public * @return array */ public function getGeoIpVersion() { $return = array('country' => '-', 'city' => '-', 'local' => '-'); // let's see the version of local .dat file $geoipPath = $this->config->resources->geoip->path; $geoipVersion = explode(" ", Dot_Geoip_Country::geoipDatabaseInfo($geoipPath)); $return['local'] = $geoipVersion[0] . ' ' . Dot_Kernel::TimeFormat($geoipVersion[1]); // do we have geoIP server-wide ? if (function_exists('geoip_database_info')) { if (geoip_db_avail(GEOIP_COUNTRY_EDITION)) { $info = explode(" ", geoip_database_info(GEOIP_COUNTRY_EDITION)); $return['country'] = $info[0] . ' ' . Dot_Kernel::TimeFormat($info[1]); } } return $return; }
function UpdateGeoip() { $database = "/usr/share/GeoIP/GeoIP.dat"; if (!is_file($database)) { RTMevents("Unable to stat /usr/share/GeoIP/GeoIP.dat"); installgeoip(); return null; } if (!is_file("/usr/local/share/GeoIP/GeoIPCity.dat")) { if (is_file("/usr/local/share/GeoIP/GeoLiteCity.dat")) { RTMevents("Linking /usr/local/share/GeoIP/GeoLiteCity.dat"); system('/bin/ln -s /usr/local/share/GeoIP/GeoLiteCity.dat /usr/local/share/GeoIP/GeoIPCity.dat >/dev/null 2>&1'); } } if (!is_file("/usr/share/GeoIP/GeoIPCity.dat")) { if (is_file("/usr/share/GeoIP/GeoLiteCity.dat")) { RTMevents("Linking /usr/share/GeoIP/GeoLiteCity.dat"); system('/bin/ln -s /usr/share/GeoIP/GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat >/dev/null 2>&1'); } } if (!function_exists("geoip_record_by_name")) { RTMevents("Unable to sat geoip_record_by_name() function"); installgeoip(); return null; } $db_info = geoip_database_info(GEOIP_COUNTRY_EDITION); RTMevents("Using {$db_info}"); $q = new mysql(); $sql = "SELECT smtp_sender FROM `smtp_logs` WHERE LENGTH(smtp_sender)>0 AND smtp_sender!='127.0.0.1' AND (Country IS NULL or Country='undefined')"; $results = $q->QUERY_SQL($sql, "artica_events"); if (!$q->ok) { RTMevents("Wrong sql query {$q->mysql_error}"); return null; } while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $smtp_sender = $ligne["smtp_sender"]; if ($_GET["smtp_cache"][$smtp_sender]) { continue; } $record = geoip_record_by_name($smtp_sender); if (!$record) { RTMevents("unable to locate this IP {$smtp_sender}"); $_GET["smtp_cache"][$smtp_sender] = true; continue; } $Country = $record["country_name"]; $_GET["smtp_cache"][$smtp_sender] = true; RTMevents("{$smtp_sender} = {$Country}"); updategeo($smtp_sender, $Country); } }
/** * Return verion of data file * * @return string Version of datafile */ function getVersion() { if ($this->gi == 'NOGI') { return geoip_database_info(); } return 'Not available (not using PHP internal geo functions)'; }
/** * Return verion of data file * * @return string Version of datafile */ function getVersion() { if ($this->gi == 'NOGI') { return geoip_database_info(); } return ''; }