MDL-19874 updated geoip to 1.80 and fixed iplookup regressions
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script serves draft files of current user
|
||||
*
|
||||
* @package moodlecore
|
||||
* @subpackage iplookup
|
||||
* @copyright 2008 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
function iplookup_load(latitude, longitude) {
|
||||
if (GBrowserIsCompatible()) {
|
||||
var map = new GMap2(document.getElementById("map"));
|
||||
map.addControl(new GSmallMapControl());
|
||||
map.addControl(new GMapTypeControl());
|
||||
var point = new GLatLng(latitude, longitude);
|
||||
map.setCenter(point, 4);
|
||||
map.addOverlay(new GMarker(point));
|
||||
map.setMapType(G_HYBRID_MAP);
|
||||
}
|
||||
}
|
||||
|
||||
function iplookup_unload() {
|
||||
if (GBrowserIsCompatible()) {
|
||||
GUnload();
|
||||
}
|
||||
}
|
||||
+37
-47
@@ -1,26 +1,28 @@
|
||||
<?php // $Id$
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 2008 onwards Petr Skoda (skodak) //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Displays IP address on map
|
||||
*
|
||||
* @package moodlecore
|
||||
* @subpackage iplookup
|
||||
* @copyright 2008 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require('../config.php');
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
@@ -36,6 +38,9 @@ if (isset($CFG->iplookup)) {
|
||||
set_config('iplookup', NULL);
|
||||
}
|
||||
|
||||
$PAGE->set_url('iplookup/index.php', array('id'=>$ip, 'user'=>$user));
|
||||
$PAGE->set_generaltype('popup');
|
||||
|
||||
$info = array($ip);
|
||||
$note = array();
|
||||
|
||||
@@ -145,33 +150,18 @@ if (empty($CFG->googlemapkey)) {
|
||||
$info = implode(' - ', $info);
|
||||
$note = implode('<br />', $note);
|
||||
|
||||
$meta = '
|
||||
<script src="http://maps.google.com/maps?file=api&v=2&key='.$CFG->googlemapkey.'" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
$PAGE->requires->js("http://maps.google.com/maps?file=api&v=2&key=$CFG->googlemapkey", true)->in_head();
|
||||
$PAGE->requires->js('/iplookup/functions.js')->in_head();
|
||||
|
||||
//<![CDATA[
|
||||
|
||||
function load() {
|
||||
if (GBrowserIsCompatible()) {
|
||||
var map = new GMap2(document.getElementById("map"));
|
||||
map.addControl(new GSmallMapControl());
|
||||
map.addControl(new GMapTypeControl());
|
||||
var point = new GLatLng('.$latitude.', '.$longitude.');
|
||||
map.setCenter(point, 4);
|
||||
map.addOverlay(new GMarker(point));
|
||||
map.setMapType(G_HYBRID_MAP);
|
||||
}
|
||||
}
|
||||
|
||||
//]]>
|
||||
</script>
|
||||
';
|
||||
|
||||
print_header(get_string('iplookup', 'admin').': '.$info, $info, '', '', $meta, false, ' ', '', false, 'onload="load()" onunload="GUnload()"');
|
||||
print_header(get_string('iplookup', 'admin').': '.$info, $info);
|
||||
|
||||
echo '<div id="map" style="width: 650px; height: 360px"></div>';
|
||||
echo '<div id="note">'.$note.'</div>';
|
||||
print_footer('empty');
|
||||
|
||||
$PAGE->requires->js_function_call('iplookup_load', array($latitude, $longitude));
|
||||
|
||||
//TODO: MDL-19875 - call uplookup_unload() js function when page unloads, previously in meta parameter
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
+47
-30
@@ -1,44 +1,61 @@
|
||||
* Fix bug where PHP API didn't work with new edition of GeoIP ISP
|
||||
1.8 2009-04-02
|
||||
* Update FIPS codes 20090401 ( Boris Zentner )
|
||||
* Fixed spelling of Kazakhstan, was Kazakstan
|
||||
* Fix TN FIPS codes and add two new TH79 and TH80 ( Boris Zentner )
|
||||
* Fix geoip_country_code_by_addr when used with a city database for unknown or private records ( cpw )
|
||||
* Update timezone.php
|
||||
* Sync geoipregionvars.php with fips codes from Jan, 14th 2009 ( Boris Zentner )
|
||||
* use metro_code in sample_city.php ( Boris Zentner )
|
||||
* replace the depreciated dma_code field with metro_code ( Boris Zentner )
|
||||
* remove wrong but unreferenced Singapur SG fips regions codes ( Boris Zentner )
|
||||
* update regions ( geoipregionvars.php ) ( Boris Zentner )
|
||||
* Die when the database file is not found or readable ( Boris Zentner )
|
||||
|
||||
1.6 2007-1-10
|
||||
* Added AX/Aland Islands, GG/Guernsey, IM/Isle of Man, JE/Jersey (ISO-3166-1 changes)
|
||||
* Replaced CS/Serbia and Montenegro with RS/Serbia, removed ZR/Zaire, added ME/Montenegro
|
||||
* geoip_country_(code|name)_by_addr now work against Geo(IP|Lite) City (Frank Mather)
|
||||
* Added code to lookup zoneinfo timezone given country and region (Frank Mather)
|
||||
* TP/East Timor changed to TL/Timor-Leste, reflecting changes in ISO-3166
|
||||
1.7 2008-1-8
|
||||
* Added BL/Saint Barthelemy, MF/Saint Martin (ISO-3166-1 additions)
|
||||
* fixed bug with newlines in Country Name
|
||||
* replaced $s_array[size] with $s_array['size'] (Daniel Horchner)
|
||||
* Fix bug where PHP API didn't work with new edition of GeoIP ISP
|
||||
|
||||
1.5 2005-11-1
|
||||
* Added Shared Memory support for GeoIP City (Frank Mather)
|
||||
* Replaced Yugoslavia with Serbia and Montenegro
|
||||
* Removed global declaration for $GEOIP_COUNTRY_CODE_TO_NUMBER, $GEOIP_COUNTRY_CODES,
|
||||
and $GEOIP_COUNTRY_CODES3
|
||||
1.6 2007-1-10
|
||||
* Added AX/Aland Islands, GG/Guernsey, IM/Isle of Man, JE/Jersey (ISO-3166-1 changes)
|
||||
* Replaced CS/Serbia and Montenegro with RS/Serbia, removed ZR/Zaire, added ME/Montenegro
|
||||
* geoip_country_(code|name)_by_addr now work against Geo(IP|Lite) City (Frank Mather)
|
||||
* Added code to lookup zoneinfo timezone given country and region (Frank Mather)
|
||||
* TP/East Timor changed to TL/Timor-Leste, reflecting changes in ISO-3166
|
||||
|
||||
1.4 2005-01-13 Andrew Hill, Awarez Ltd. (http://www.awarez.net)
|
||||
1.5 2005-11-1
|
||||
* Added Shared Memory support for GeoIP City (Frank Mather)
|
||||
* Replaced Yugoslavia with Serbia and Montenegro
|
||||
* Removed global declaration for $GEOIP_COUNTRY_CODE_TO_NUMBER, $GEOIP_COUNTRY_CODES,
|
||||
and $GEOIP_COUNTRY_CODES3
|
||||
|
||||
1.4 2005-01-13 Andrew Hill, Awarez Ltd. (http://www.awarez.net)
|
||||
* Formatted file according to PEAR library standards.
|
||||
* Moved $GEOIP_COUNTRY_CODE_TO_NUMBER, $GEOIP_COUNTRY_CODES,
|
||||
* $GEOIP_COUNTRY_CODES3 and $GEOIP_COUNTRY_NAMES into the
|
||||
* GeoIP class, so that library will still work even when
|
||||
* not included in the $GLOBAL context.
|
||||
|
||||
* Updated geoip_country_code_by_addr to work with PHP5 (Eric of Host Ultra)
|
||||
* Replaced bit operators (| and &) with logical operators (|| and &&)
|
||||
* Defined GEOIP_ISP_EDITION
|
||||
* Updated geoip_country_code_by_addr to work with PHP5 (Eric of Host Ultra)
|
||||
* Replaced bit operators (| and &) with logical operators (|| and &&)
|
||||
* Defined GEOIP_ISP_EDITION
|
||||
|
||||
1.3 2004-8-4
|
||||
* Changed license from GPL to LGPL so code can be included in PEAR
|
||||
* added global definitions to prevent undefined variables error when including from function (Cédric Dufour)
|
||||
* Updated country names
|
||||
* Added support for GeoIP City, version 1 with DMA and Area codes
|
||||
1.3 2004-8-4
|
||||
* Changed license from GPL to LGPL so code can be included in PEAR
|
||||
* added global definitions to prevent undefined variables error when including from function (Cédric Dufour)
|
||||
* Updated country names
|
||||
* Added support for GeoIP City, version 1 with DMA and Area codes
|
||||
|
||||
1.2 2003-10-28
|
||||
* Added support for Shared Memory (Jason Priebe)
|
||||
* Added support for Distributed queries
|
||||
* Added support for GeoIP Region, version 1
|
||||
* Added Anonymous Proxy and Satellite Provider code/labels
|
||||
* Changed Taiwan, Province of China to Taiwan
|
||||
1.2 2003-10-28
|
||||
* Added support for Shared Memory (Jason Priebe)
|
||||
* Added support for Distributed queries
|
||||
* Added support for GeoIP Region, version 1
|
||||
* Added Anonymous Proxy and Satellite Provider code/labels
|
||||
* Changed Taiwan, Province of China to Taiwan
|
||||
|
||||
1.1 2003-01-15
|
||||
* Added support for GeoIP Region and GeoIP City
|
||||
1.1 2003-01-15
|
||||
* Added support for GeoIP Region and GeoIP City
|
||||
|
||||
1.0 2002-11-21
|
||||
1.0 2002-11-21
|
||||
* Initial checkin to CVS
|
||||
|
||||
+40
-37
@@ -103,7 +103,8 @@ class GeoIP {
|
||||
"VA" => 228, "VC" => 229, "VE" => 230, "VG" => 231, "VI" => 232, "VN" => 233,
|
||||
"VU" => 234, "WF" => 235, "WS" => 236, "YE" => 237, "YT" => 238, "RS" => 239,
|
||||
"ZA" => 240, "ZM" => 241, "ME" => 242, "ZW" => 243, "A1" => 244, "A2" => 245,
|
||||
"O1" => 246, "AX" => 247, "GG" => 248, "IM" => 249, "JE" => 250
|
||||
"O1" => 246, "AX" => 247, "GG" => 248, "IM" => 249, "JE" => 250, "BL" => 251,
|
||||
"MF" => 252
|
||||
);
|
||||
var $GEOIP_COUNTRY_CODES = array(
|
||||
"", "AP", "EU", "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN", "AO", "AQ",
|
||||
@@ -125,7 +126,7 @@ class GeoIP {
|
||||
"TF", "TG", "TH", "TJ", "TK", "TM", "TN", "TO", "TL", "TR", "TT", "TV", "TW",
|
||||
"TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN",
|
||||
"VU", "WF", "WS", "YE", "YT", "RS", "ZA", "ZM", "ME", "ZW", "A1", "A2", "O1",
|
||||
"AX", "GG", "IM", "JE"
|
||||
"AX", "GG", "IM", "JE", "BL", "MF"
|
||||
);
|
||||
var $GEOIP_COUNTRY_CODES3 = array(
|
||||
"","AP","EU","AND","ARE","AFG","ATG","AIA","ALB","ARM","ANT","AGO","AQ","ARG",
|
||||
@@ -147,7 +148,7 @@ class GeoIP {
|
||||
"TGO","THA","TJK","TKL","TLS","TKM","TUN","TON","TUR","TTO","TUV","TWN","TZA",
|
||||
"UKR","UGA","UM","USA","URY","UZB","VAT","VCT","VEN","VGB","VIR","VNM","VUT",
|
||||
"WLF","WSM","YEM","YT","SRB","ZAF","ZMB","MNE","ZWE","A1","A2","O1",
|
||||
"ALA","GGY","IMN","JEY"
|
||||
"ALA","GGY","IMN","JEY","BLM","MAF"
|
||||
);
|
||||
var $GEOIP_COUNTRY_NAMES = array(
|
||||
"", "Asia/Pacific Region", "Europe", "Andorra", "United Arab Emirates",
|
||||
@@ -158,49 +159,49 @@ class GeoIP {
|
||||
"Burundi", "Benin", "Bermuda", "Brunei Darussalam", "Bolivia", "Brazil",
|
||||
"Bahamas", "Bhutan", "Bouvet Island", "Botswana", "Belarus", "Belize",
|
||||
"Canada", "Cocos (Keeling) Islands", "Congo, The Democratic Republic of the",
|
||||
"Central African Republic", "Congo", "Switzerland", "Cote D'Ivoire", "Cook
|
||||
Islands", "Chile", "Cameroon", "China", "Colombia", "Costa Rica", "Cuba", "Cape
|
||||
Verde", "Christmas Island", "Cyprus", "Czech Republic", "Germany", "Djibouti",
|
||||
"Central African Republic", "Congo", "Switzerland", "Cote D'Ivoire", "Cook Islands",
|
||||
"Chile", "Cameroon", "China", "Colombia", "Costa Rica", "Cuba", "Cape Verde",
|
||||
"Christmas Island", "Cyprus", "Czech Republic", "Germany", "Djibouti",
|
||||
"Denmark", "Dominica", "Dominican Republic", "Algeria", "Ecuador", "Estonia",
|
||||
"Egypt", "Western Sahara", "Eritrea", "Spain", "Ethiopia", "Finland", "Fiji",
|
||||
"Falkland Islands (Malvinas)", "Micronesia, Federated States of", "Faroe
|
||||
Islands", "France", "France, Metropolitan", "Gabon", "United Kingdom",
|
||||
"Falkland Islands (Malvinas)", "Micronesia, Federated States of", "Faroe Islands",
|
||||
"France", "France, Metropolitan", "Gabon", "United Kingdom",
|
||||
"Grenada", "Georgia", "French Guiana", "Ghana", "Gibraltar", "Greenland",
|
||||
"Gambia", "Guinea", "Guadeloupe", "Equatorial Guinea", "Greece", "South Georgia
|
||||
and the South Sandwich Islands", "Guatemala", "Guam", "Guinea-Bissau",
|
||||
"Gambia", "Guinea", "Guadeloupe", "Equatorial Guinea", "Greece", "South Georgia and the South Sandwich Islands",
|
||||
"Guatemala", "Guam", "Guinea-Bissau",
|
||||
"Guyana", "Hong Kong", "Heard Island and McDonald Islands", "Honduras",
|
||||
"Croatia", "Haiti", "Hungary", "Indonesia", "Ireland", "Israel", "India",
|
||||
"British Indian Ocean Territory", "Iraq", "Iran, Islamic Republic of",
|
||||
"Iceland", "Italy", "Jamaica", "Jordan", "Japan", "Kenya", "Kyrgyzstan",
|
||||
"Cambodia", "Kiribati", "Comoros", "Saint Kitts and Nevis", "Korea, Democratic
|
||||
People's Republic of", "Korea, Republic of", "Kuwait", "Cayman Islands",
|
||||
"Kazakstan", "Lao People's Democratic Republic", "Lebanon", "Saint Lucia",
|
||||
"Cambodia", "Kiribati", "Comoros", "Saint Kitts and Nevis", "Korea, Democratic People's Republic of",
|
||||
"Korea, Republic of", "Kuwait", "Cayman Islands",
|
||||
"Kazakhstan", "Lao People's Democratic Republic", "Lebanon", "Saint Lucia",
|
||||
"Liechtenstein", "Sri Lanka", "Liberia", "Lesotho", "Lithuania", "Luxembourg",
|
||||
"Latvia", "Libyan Arab Jamahiriya", "Morocco", "Monaco", "Moldova, Republic
|
||||
of", "Madagascar", "Marshall Islands", "Macedonia",
|
||||
"Latvia", "Libyan Arab Jamahiriya", "Morocco", "Monaco", "Moldova, Republic of",
|
||||
"Madagascar", "Marshall Islands", "Macedonia",
|
||||
"Mali", "Myanmar", "Mongolia", "Macau", "Northern Mariana Islands",
|
||||
"Martinique", "Mauritania", "Montserrat", "Malta", "Mauritius", "Maldives",
|
||||
"Malawi", "Mexico", "Malaysia", "Mozambique", "Namibia", "New Caledonia",
|
||||
"Niger", "Norfolk Island", "Nigeria", "Nicaragua", "Netherlands", "Norway",
|
||||
"Nepal", "Nauru", "Niue", "New Zealand", "Oman", "Panama", "Peru", "French
|
||||
Polynesia", "Papua New Guinea", "Philippines", "Pakistan", "Poland", "Saint
|
||||
Pierre and Miquelon", "Pitcairn Islands", "Puerto Rico", "Palestinian Territory",
|
||||
"Nepal", "Nauru", "Niue", "New Zealand", "Oman", "Panama", "Peru", "French Polynesia",
|
||||
"Papua New Guinea", "Philippines", "Pakistan", "Poland", "Saint Pierre and Miquelon",
|
||||
"Pitcairn Islands", "Puerto Rico", "Palestinian Territory",
|
||||
"Portugal", "Palau", "Paraguay", "Qatar", "Reunion", "Romania",
|
||||
"Russian Federation", "Rwanda", "Saudi Arabia", "Solomon Islands",
|
||||
"Seychelles", "Sudan", "Sweden", "Singapore", "Saint Helena", "Slovenia",
|
||||
"Svalbard and Jan Mayen", "Slovakia", "Sierra Leone", "San Marino", "Senegal",
|
||||
"Somalia", "Suriname", "Sao Tome and Principe", "El Salvador", "Syrian Arab
|
||||
Republic", "Swaziland", "Turks and Caicos Islands", "Chad", "French Southern
|
||||
Territories", "Togo", "Thailand", "Tajikistan", "Tokelau", "Turkmenistan",
|
||||
"Somalia", "Suriname", "Sao Tome and Principe", "El Salvador", "Syrian Arab Republic",
|
||||
"Swaziland", "Turks and Caicos Islands", "Chad", "French Southern Territories",
|
||||
"Togo", "Thailand", "Tajikistan", "Tokelau", "Turkmenistan",
|
||||
"Tunisia", "Tonga", "Timor-Leste", "Turkey", "Trinidad and Tobago", "Tuvalu",
|
||||
"Taiwan", "Tanzania, United Republic of", "Ukraine",
|
||||
"Uganda", "United States Minor Outlying Islands", "United States", "Uruguay",
|
||||
"Uzbekistan", "Holy See (Vatican City State)", "Saint Vincent and the
|
||||
Grenadines", "Venezuela", "Virgin Islands, British", "Virgin Islands, U.S.",
|
||||
"Uzbekistan", "Holy See (Vatican City State)", "Saint Vincent and the Grenadines",
|
||||
"Venezuela", "Virgin Islands, British", "Virgin Islands, U.S.",
|
||||
"Vietnam", "Vanuatu", "Wallis and Futuna", "Samoa", "Yemen", "Mayotte",
|
||||
"Serbia", "South Africa", "Zambia", "Montenegro", "Zimbabwe",
|
||||
"Anonymous Proxy","Satellite Provider","Other",
|
||||
"Aland Islands","Guernsey","Isle of Man","Jersey"
|
||||
"Aland Islands","Guernsey","Isle of Man","Jersey","Saint Barthelemy","Saint Martin"
|
||||
);
|
||||
}
|
||||
function geoip_load_shared_mem ($file) {
|
||||
@@ -237,19 +238,19 @@ function _setup_segments($gi){
|
||||
$gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
|
||||
} else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
|
||||
$gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
|
||||
} else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)||
|
||||
} else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)||
|
||||
($gi->databaseType == GEOIP_CITY_EDITION_REV1)
|
||||
|| ($gi->databaseType == GEOIP_ORG_EDITION)
|
||||
|| ($gi->databaseType == GEOIP_ISP_EDITION)
|
||||
|| ($gi->databaseType == GEOIP_ASNUM_EDITION)){
|
||||
|| ($gi->databaseType == GEOIP_ISP_EDITION)
|
||||
|| ($gi->databaseType == GEOIP_ASNUM_EDITION)){
|
||||
$gi->databaseSegments = 0;
|
||||
$buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH);
|
||||
for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
|
||||
$gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
|
||||
}
|
||||
if (($gi->databaseType == GEOIP_ORG_EDITION)||
|
||||
($gi->databaseType == GEOIP_ISP_EDITION)) {
|
||||
$gi->record_length = ORG_RECORD_LENGTH;
|
||||
if (($gi->databaseType == GEOIP_ORG_EDITION)||
|
||||
($gi->databaseType == GEOIP_ISP_EDITION)) {
|
||||
$gi->record_length = ORG_RECORD_LENGTH;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -273,20 +274,20 @@ function _setup_segments($gi){
|
||||
$gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
|
||||
}
|
||||
else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
|
||||
$gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
|
||||
$gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
|
||||
} else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) ||
|
||||
($gi->databaseType == GEOIP_CITY_EDITION_REV1) ||
|
||||
($gi->databaseType == GEOIP_ORG_EDITION) ||
|
||||
($gi->databaseType == GEOIP_ISP_EDITION) ||
|
||||
($gi->databaseType == GEOIP_ISP_EDITION) ||
|
||||
($gi->databaseType == GEOIP_ASNUM_EDITION)){
|
||||
$gi->databaseSegments = 0;
|
||||
$buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH);
|
||||
for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
|
||||
$gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
|
||||
}
|
||||
if ($gi->databaseType == GEOIP_ORG_EDITION ||
|
||||
$gi->databaseType == GEOIP_ISP_EDITION) {
|
||||
$gi->record_length = ORG_RECORD_LENGTH;
|
||||
if ($gi->databaseType == GEOIP_ORG_EDITION ||
|
||||
$gi->databaseType == GEOIP_ISP_EDITION) {
|
||||
$gi->record_length = ORG_RECORD_LENGTH;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -310,7 +311,7 @@ function geoip_open($filename, $flags) {
|
||||
if ($gi->flags & GEOIP_SHARED_MEMORY) {
|
||||
$gi->shmid = @shmop_open (GEOIP_SHM_KEY, "a", 0, 0);
|
||||
} else {
|
||||
$gi->filehandle = fopen($filename,"rb");
|
||||
$gi->filehandle = fopen($filename,"rb") or die( "Can not open $filename\n" );
|
||||
if ($gi->flags & GEOIP_MEMORY_CACHE) {
|
||||
$s_array = fstat($gi->filehandle);
|
||||
$gi->memory_buffer = fread($gi->filehandle, $s_array['size']);
|
||||
@@ -361,7 +362,9 @@ function geoip_country_id_by_addr($gi, $addr) {
|
||||
function geoip_country_code_by_addr($gi, $addr) {
|
||||
if ($gi->databaseType == GEOIP_CITY_EDITION_REV1) {
|
||||
$record = geoip_record_by_addr($gi,$addr);
|
||||
return $record->country_code;
|
||||
if ( $record !== false ) {
|
||||
return $record->country_code;
|
||||
}
|
||||
} else {
|
||||
$country_id = geoip_country_id_by_addr($gi,$addr);
|
||||
if ($country_id !== false) {
|
||||
|
||||
+10
-7
@@ -43,7 +43,8 @@ class geoiprecord {
|
||||
var $latitude;
|
||||
var $longitude;
|
||||
var $area_code;
|
||||
var $dma_code;
|
||||
var $dma_code; # metro and dma code are the same. use metro_code
|
||||
var $metro_code;
|
||||
}
|
||||
|
||||
class geoipdnsrecord {
|
||||
@@ -60,6 +61,7 @@ class geoipdnsrecord {
|
||||
var $dmacode;
|
||||
var $isp;
|
||||
var $org;
|
||||
var $metrocode;
|
||||
}
|
||||
|
||||
function getrecordwithdnsservice($str){
|
||||
@@ -79,8 +81,9 @@ function getrecordwithdnsservice($str){
|
||||
if ($key == "ac"){
|
||||
$record->areacode = $value;
|
||||
}
|
||||
if ($key == "dm"){
|
||||
$record->dmacode = $value;
|
||||
if ($key == "dm" || $key == "me" ){
|
||||
$record->dmacode = $value;
|
||||
$record->metrocode = $value;
|
||||
}
|
||||
if ($key == "is"){
|
||||
$record->isp = $value;
|
||||
@@ -181,14 +184,14 @@ function _get_record($gi,$ipnum){
|
||||
}
|
||||
$record->longitude = ($longitude/10000) - 180;
|
||||
if (GEOIP_CITY_EDITION_REV1 == $gi->databaseType){
|
||||
$dmaarea_combo = 0;
|
||||
$metroarea_combo = 0;
|
||||
if ($record->country_code == "US"){
|
||||
for ($j = 0;$j < 3;++$j){
|
||||
$char = ord(substr($record_buf,$record_buf_pos++,1));
|
||||
$dmaarea_combo += ($char << ($j * 8));
|
||||
$metroarea_combo += ($char << ($j * 8));
|
||||
}
|
||||
$record->dma_code = floor($dmaarea_combo/1000);
|
||||
$record->area_code = $dmaarea_combo%1000;
|
||||
$record->metro_code = $record->dma_code = floor($metroarea_combo/1000);
|
||||
$record->area_code = $metroarea_combo%1000;
|
||||
}
|
||||
}
|
||||
return $record;
|
||||
|
||||
+4255
-3930
File diff suppressed because it is too large
Load Diff
@@ -60,7 +60,7 @@
|
||||
<location>geoip</location>
|
||||
<name>GeoIP</name>
|
||||
<license>LGPL</license>
|
||||
<version>1.6</version>
|
||||
<version>1.8</version>
|
||||
<licenseversion>2.1+</licenseversion>
|
||||
</library>
|
||||
<library>
|
||||
|
||||
Reference in New Issue
Block a user