Remove Geoipv1 library. We use now v2

This commit is contained in:
Laurent Destailleur 2020-04-02 12:37:21 +02:00
parent b8eaf8dd03
commit 9f55918cb8
13 changed files with 7 additions and 9140 deletions

View File

@ -16,7 +16,7 @@ AdoDb-Date 0.36 Modified BSD License Yes
CKEditor 4.12.1 LGPL-2.1+ Yes Editor WYSIWYG
EvalMath 1.0 BSD Yes Safe math expressions evaluation
Escpos-php 2.2 MIT License Yes Thermal receipt printer library, for use with ESC/POS compatible printers
GeoIP 1.4 LGPL-2.1+ Yes Sample code to make geoip convert (not into deb package)
GeoIP2 0.2.0 LGPL-2.1+ Yes Lib to make geoip convert
Mobiledetect 2.8.34 MIT License Yes Detect mobile devices browsers
NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package)
PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency

View File

@ -45,7 +45,7 @@ class DolGeoIP
{
global $conf;
$geoipversion = '2'; // 'php', '1' or '2'
$geoipversion = '2'; // 'php', or '2'
if (! empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION;
if ($type == 'country')
@ -53,9 +53,7 @@ class DolGeoIP
// geoip may have been already included with PEAR
if ($geoipversion == '2' || ($geoipversion != 'php' && ! function_exists('geoip_country_code_by_name')))
{
if ($geoipversion == '1') $res=include_once GEOIP_PATH.'geoip.inc';
//else $res=include_once DOL_DOCUMENT_ROOT.'/includes/geoip2/vendor/autoload.php';
else require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar';
require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar';
}
}
elseif ($type == 'city')
@ -63,9 +61,7 @@ class DolGeoIP
// geoip may have been already included with PEAR
if ($geoipversion == '2' || ($geoipversion != 'php' && ! function_exists('geoip_country_code_by_name')))
{
if ($geoipversion == '1') $res=include_once GEOIP_PATH.'geoipcity.inc';
//else $res=include_once DOL_DOCUMENT_ROOT.'/includes/geoip2/vendor/autoload.php';
else require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar';
require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar';
}
}
else { print 'ErrorBadParameterInConstructor'; return 0; }
@ -119,7 +115,7 @@ class DolGeoIP
{
global $conf;
$geoipversion = '2'; // 'php', '1' or '2'
$geoipversion = '2'; // 'php', or '2'
if (! empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION;
if (empty($this->gi))
@ -184,7 +180,7 @@ class DolGeoIP
{
global $conf;
$geoipversion = '2'; // 'php', '1' or '2'
$geoipversion = '2'; // 'php', or '2'
if (! empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION;
if (empty($this->gi))
@ -218,7 +214,7 @@ class DolGeoIP
{
global $conf;
$geoipversion = '2'; // 'php', '1' or '2'
$geoipversion = '2'; // 'php', or '2'
if (! empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION;
if ($geoipversion == 'php')

View File

@ -1,43 +0,0 @@
Requirements
None (only the 'GeoIP.dat' file is needed). To download a free GeoIP Standard Country
database, go to
http://maxmind.com/download/geoip/database/
Install
Just place the 'geoip.inc' file somewhere according to the 'include_path' directive of
your 'php.ini' file, or just place it in the same directory as your PHP scripts.
Usage
Gets country name by hostname :
include("geoip.inc");
$gi = geoip_open("/usr/local/share/GeoIP/GeoIP.dat",GEOIP_STANDARD);
echo geoip_country_code_by_addr($gi, "24.24.24.24") . "\t" .
geoip_country_name_by_addr($gi, "24.24.24.24") . "\n";
echo geoip_country_code_by_addr($gi, "80.24.24.24") . "\t" .
geoip_country_name_by_addr($gi, "80.24.24.24") . "\n";
geoip_close($gi);
Memory Caching:
To enable memory caching, pass GEOIP_SHARED_MEMORY or
GEOIP_MEMORY_CACHE to the second argument of geoip_open
For GEOIP_SHARED_MEMORY, requires php >= 4.0.4,
and --enable-shmop passed at configure time, see
http://us2.php.net/manual/en/ref.shmop.php
In addition, you should call geoip_load_shared_mem
before calling geoip_open. See sample_city.php for an
example of shared memory caching.
Working with PHP5.
geoip_country_code_by_addr should work
with PHP. For help with the other
routines, please contact support@maxmind.com
Thanks to Jim Winstead.

File diff suppressed because it is too large Load Diff

View File

@ -1,171 +0,0 @@
<?php
/* geoipcity.inc
*
* Copyright (C) 2013 MaxMind, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
define("FULL_RECORD_LENGTH", 50);
require_once 'geoip.inc';
require_once 'geoipregionvars.php';
class geoiprecord
{
public $country_code;
public $country_code3;
public $country_name;
public $region;
public $city;
public $postal_code;
public $latitude;
public $longitude;
public $area_code;
public $dma_code; # metro and dma code are the same. use metro_code
public $metro_code;
public $continent_code;
}
function _get_record_v6($gi, $ipnum)
{
$seek_country = _geoip_seek_country_v6($gi, $ipnum);
if ($seek_country == $gi->databaseSegments) {
return null;
}
return _common_get_record($gi, $seek_country);
}
function _common_get_record($gi, $seek_country)
{
// workaround php's broken substr, strpos, etc handling with
// mbstring.func_overload and mbstring.internal_encoding
$mbExists = extension_loaded('mbstring');
if ($mbExists) {
$enc = mb_internal_encoding();
mb_internal_encoding('ISO-8859-1');
}
$record_pointer = $seek_country + (2 * $gi->record_length - 1) * $gi->databaseSegments;
if ($gi->flags & GEOIP_MEMORY_CACHE) {
$record_buf = substr($gi->memory_buffer, $record_pointer, FULL_RECORD_LENGTH);
} elseif ($gi->flags & GEOIP_SHARED_MEMORY) {
$record_buf = _sharedMemRead($gi, $record_pointer, FULL_RECORD_LENGTH);
} else {
fseek($gi->filehandle, $record_pointer, SEEK_SET);
$record_buf = fread($gi->filehandle, FULL_RECORD_LENGTH);
}
$record = new geoiprecord;
$record_buf_pos = 0;
$char = ord(substr($record_buf, $record_buf_pos, 1));
$record->country_code = $gi->GEOIP_COUNTRY_CODES[$char];
$record->country_code3 = $gi->GEOIP_COUNTRY_CODES3[$char];
$record->country_name = $gi->GEOIP_COUNTRY_NAMES[$char];
$record->continent_code = $gi->GEOIP_CONTINENT_CODES[$char];
$record_buf_pos++;
$str_length = 0;
// Get region
$char = ord(substr($record_buf, $record_buf_pos + $str_length, 1));
while ($char != 0) {
$str_length++;
$char = ord(substr($record_buf, $record_buf_pos + $str_length, 1));
}
if ($str_length > 0) {
$record->region = substr($record_buf, $record_buf_pos, $str_length);
}
$record_buf_pos += $str_length + 1;
$str_length = 0;
// Get city
$char = ord(substr($record_buf, $record_buf_pos + $str_length, 1));
while ($char != 0) {
$str_length++;
$char = ord(substr($record_buf, $record_buf_pos + $str_length, 1));
}
if ($str_length > 0) {
$record->city = substr($record_buf, $record_buf_pos, $str_length);
}
$record_buf_pos += $str_length + 1;
$str_length = 0;
// Get postal code
$char = ord(substr($record_buf, $record_buf_pos + $str_length, 1));
while ($char != 0) {
$str_length++;
$char = ord(substr($record_buf, $record_buf_pos + $str_length, 1));
}
if ($str_length > 0) {
$record->postal_code = substr($record_buf, $record_buf_pos, $str_length);
}
$record_buf_pos += $str_length + 1;
// Get latitude and longitude
$latitude = 0;
$longitude = 0;
for ($j = 0; $j < 3; ++$j) {
$char = ord(substr($record_buf, $record_buf_pos++, 1));
$latitude += ($char << ($j * 8));
}
$record->latitude = ($latitude / 10000) - 180;
for ($j = 0; $j < 3; ++$j) {
$char = ord(substr($record_buf, $record_buf_pos++, 1));
$longitude += ($char << ($j * 8));
}
$record->longitude = ($longitude / 10000) - 180;
if (GEOIP_CITY_EDITION_REV1 == $gi->databaseType) {
$metroarea_combo = 0;
if ($record->country_code == "US") {
for ($j = 0; $j < 3; ++$j) {
$char = ord(substr($record_buf, $record_buf_pos++, 1));
$metroarea_combo += ($char << ($j * 8));
}
$record->metro_code = $record->dma_code = floor($metroarea_combo / 1000);
$record->area_code = $metroarea_combo % 1000;
}
}
if ($mbExists) {
mb_internal_encoding($enc);
}
return $record;
}
function GeoIP_record_by_addr_v6($gi, $addr)
{
if ($addr == null) {
return 0;
}
$ipnum = inet_pton($addr);
return _get_record_v6($gi, $ipnum);
}
function _get_record($gi, $ipnum)
{
$seek_country = _geoip_seek_country($gi, $ipnum);
if ($seek_country == $gi->databaseSegments) {
return null;
}
return _common_get_record($gi, $seek_country);
}
function GeoIP_record_by_addr($gi, $addr)
{
if ($addr == null) {
return 0;
}
$ipnum = ip2long($addr);
return _get_record($gi, $ipnum);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +0,0 @@
#!/usr/bin/php -q
<?php
// This code demonstrates how to lookup the country by IP Address
include("geoip.inc");
// Uncomment if querying against GeoIP/Lite City.
// include("geoipcity.inc");
$gi = geoip_open("/usr/local/share/GeoIP/GeoIP.dat",GEOIP_STANDARD);
echo geoip_country_code_by_addr($gi, "24.24.24.24") . "\t" .
geoip_country_name_by_addr($gi, "24.24.24.24") . "\n";
echo geoip_country_code_by_addr($gi, "80.24.24.24") . "\t" .
geoip_country_name_by_addr($gi, "80.24.24.24") . "\n";
geoip_close($gi);
?>

View File

@ -1,32 +0,0 @@
#!/usr/bin/php -q
<?php
// This code demonstrates how to lookup the country, region, city,
// postal code, latitude, and longitude by IP Address.
// It is designed to work with GeoIP/GeoLite City
// Note that you must download the New Format of GeoIP City (GEO-133).
// The old format (GEO-132) will not work.
include("geoipcity.inc");
include("geoipregionvars.php");
// uncomment for Shared Memory support
// geoip_load_shared_mem("/usr/local/share/GeoIP/GeoIPCity.dat");
// $gi = geoip_open("/usr/local/share/GeoIP/GeoIPCity.dat",GEOIP_SHARED_MEMORY);
$gi = geoip_open("/usr/local/share/GeoIP/GeoIPCity.dat",GEOIP_STANDARD);
$record = geoip_record_by_addr($gi,"24.24.24.24");
print $record->country_code . " " . $record->country_code3 . " " . $record->country_name . "\n";
print $record->region . " " . $GEOIP_REGION_NAME[$record->country_code][$record->region] . "\n";
print $record->city . "\n";
print $record->postal_code . "\n";
print $record->latitude . "\n";
print $record->longitude . "\n";
print $record->metro_code . "\n";
print $record->area_code . "\n";
geoip_close($gi);
?>

View File

@ -1,31 +0,0 @@
#!/usr/bin/php -q
<?php
include("geoipcity.inc");
include("Net/DNS.php");
# replace LICENSE_KEY_HERE with your license key
$l = "LICENSE_KEY_HERE";
$ip = "24.24.24.24";
if ($l == "LICENSE_KEY_HERE") {
print "Error, must edit sample_distributed.php to replace LICENSE_KEY_HERE\n";
exit;
}
$str = getdnsattributes($l,$ip);
$r = getrecordwithdnsservice($str);
print "country code: " . $r->country_code . "\n";
print "country code3: " . $r->country_code3 . "\n";
print "country name: " . $r->country_name . "\n";
print "city: " . $r->city . "\n";
print "region: " . $r->region . "\n";
print "region name: " . $r->regionname . "\n";
print "postal_code: " . $r->postal_code . "\n";
print "latitude: " . $r->latitude . "\n";
print "longitude: " . $r->longitude . "\n";
print "area code: " . $r->areacode . "\n";
print "dma code: " . $r->dmacode . "\n";
print "isp: " . $r->isp . "\n";
print "org: " . $r->org . "\n";
?>

View File

@ -1,23 +0,0 @@
#!/usr/bin/php -q
<?php
include("geoip.inc");
$gi = geoip_open("/usr/local/share/GeoIP/GeoIPNetSpeed.dat",GEOIP_STANDARD);
$netspeed = geoip_country_id_by_addr($gi,"24.24.24.24");
//print $n . "\n";
if ($netspeed == GEOIP_UNKNOWN_SPEED){
print "Unknown\n";
}else if ($netspeed == GEOIP_DIALUP_SPEED){
print "Dailup\n";
}else if ($netspeed == GEOIP_CABLEDSL_SPEED){
print "Cable/DSL\n";
}else if ($netspeed == GEOIP_CORPORATE_SPEED){
print "Corporate\n";
}
geoip_close($gi);
?>

View File

@ -1,23 +0,0 @@
#!/usr/bin/php -q
<?php
// This code demonstrates how to lookup the country and region by IP Address
// It is designed to work with GeoIP Organization or GeoIP ISP available from MaxMind
include("geoip.inc");
$giorg = geoip_open("/usr/local/share/GeoIP/GeoIPOrg.dat",GEOIP_STANDARD);
$org = geoip_org_by_addr($giorg,"80.24.24.24");
print "80.24.24.24 belongs to " . $org . "\n";
$giisp = geoip_open("/usr/local/share/GeoIP/GeoIPISP.dat",GEOIP_STANDARD);
$isp = geoip_org_by_addr($giisp,"80.24.24.24");
print "80.24.24.24 has isp " . $isp . "\n";
geoip_close($giorg);
geoip_close($giisp);
?>

View File

@ -1,20 +0,0 @@
#!/usr/bin/php -q
<?php
// This code demonstrates how to lookup the country and region by IP Address
// It is designed to work with GeoIP Region available from MaxMind
include("geoip.inc");
include("geoipregionvars.php");
$gi = geoip_open("/usr/local/share/GeoIP/GeoIPRegion.dat",GEOIP_STANDARD);
list ($countrycode,$region) = geoip_region_by_addr($gi,"24.24.24.24");
print $countrycode . " " . $region . " " . $GEOIP_REGION_NAME[$countrycode][$region] . "\n";
list ($countrycode,$region) = geoip_region_by_addr($gi,"80.24.24.24");
print $countrycode . " " . $region . " " . $GEOIP_REGION_NAME[$countrycode][$region] . "\n";
list ($countrycode,$region) = geoip_region_by_addr($gi,"199.243.137.184");
print $countrycode . " " . $region . " " . $GEOIP_REGION_NAME[$countrycode][$region] . "\n";
geoip_close($gi);
?>

File diff suppressed because it is too large Load Diff