geoip: compatibility fix; this allows to have both versions of geoip loaded

This commit is contained in:
czaks 2014-02-19 00:01:40 +01:00
parent 9dad842c24
commit bcb47a1d33
2 changed files with 53 additions and 51 deletions

View File

@ -20,55 +20,57 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
define("GEOIP_COUNTRY_BEGIN", 16776960);
define("GEOIP_STATE_BEGIN_REV0", 16700000);
define("GEOIP_STATE_BEGIN_REV1", 16000000);
define("GEOIP_STANDARD", 0);
define("GEOIP_MEMORY_CACHE", 1);
define("GEOIP_SHARED_MEMORY", 2);
define("STRUCTURE_INFO_MAX_SIZE", 20);
define("DATABASE_INFO_MAX_SIZE", 100);
define("GEOIP_COUNTRY_EDITION", 1);
define("GEOIP_PROXY_EDITION", 8);
define("GEOIP_ASNUM_EDITION", 9);
define("GEOIP_NETSPEED_EDITION", 10);
define("GEOIP_REGION_EDITION_REV0", 7);
define("GEOIP_REGION_EDITION_REV1", 3);
define("GEOIP_CITY_EDITION_REV0", 6);
define("GEOIP_CITY_EDITION_REV1", 2);
define("GEOIP_ORG_EDITION", 5);
define("GEOIP_ISP_EDITION", 4);
define("SEGMENT_RECORD_LENGTH", 3);
define("STANDARD_RECORD_LENGTH", 3);
define("ORG_RECORD_LENGTH", 4);
define("MAX_RECORD_LENGTH", 4);
define("MAX_ORG_RECORD_LENGTH", 300);
define("GEOIP_SHM_KEY", 0x4f415401);
define("US_OFFSET", 1);
define("CANADA_OFFSET", 677);
define("WORLD_OFFSET", 1353);
define("FIPS_RANGE", 360);
define("GEOIP_UNKNOWN_SPEED", 0);
define("GEOIP_DIALUP_SPEED", 1);
define("GEOIP_CABLEDSL_SPEED", 2);
define("GEOIP_CORPORATE_SPEED", 3);
define("GEOIP_DOMAIN_EDITION", 11);
define("GEOIP_COUNTRY_EDITION_V6", 12);
define("GEOIP_LOCATIONA_EDITION", 13);
define("GEOIP_ACCURACYRADIUS_EDITION", 14);
define("GEOIP_CITYCOMBINED_EDITION", 15);
define("GEOIP_CITY_EDITION_REV1_V6", 30);
define("GEOIP_CITY_EDITION_REV0_V6",31);
define("GEOIP_NETSPEED_EDITION_REV1",32);
define("GEOIP_NETSPEED_EDITION_REV1_V6",33);
define("GEOIP_USERTYPE_EDITION",28);
define("GEOIP_USERTYPE_EDITION_V6",29);
define("GEOIP_ASNUM_EDITION_V6",21);
define("GEOIP_ISP_EDITION_V6",22);
define("GEOIP_ORG_EDITION_V6",23);
define("GEOIP_DOMAIN_EDITION_V6",24);
namespace geoip;
define("CITYCOMBINED_FIXED_RECORD", 7 );
@define("GEOIP_COUNTRY_BEGIN", 16776960);
@define("GEOIP_STATE_BEGIN_REV0", 16700000);
@define("GEOIP_STATE_BEGIN_REV1", 16000000);
@define("GEOIP_STANDARD", 0);
@define("GEOIP_MEMORY_CACHE", 1);
@define("GEOIP_SHARED_MEMORY", 2);
@define("STRUCTURE_INFO_MAX_SIZE", 20);
@define("DATABASE_INFO_MAX_SIZE", 100);
@define("GEOIP_COUNTRY_EDITION", 1);
@define("GEOIP_PROXY_EDITION", 8);
@define("GEOIP_ASNUM_EDITION", 9);
@define("GEOIP_NETSPEED_EDITION", 10);
@define("GEOIP_REGION_EDITION_REV0", 7);
@define("GEOIP_REGION_EDITION_REV1", 3);
@define("GEOIP_CITY_EDITION_REV0", 6);
@define("GEOIP_CITY_EDITION_REV1", 2);
@define("GEOIP_ORG_EDITION", 5);
@define("GEOIP_ISP_EDITION", 4);
@define("SEGMENT_RECORD_LENGTH", 3);
@define("STANDARD_RECORD_LENGTH", 3);
@define("ORG_RECORD_LENGTH", 4);
@define("MAX_RECORD_LENGTH", 4);
@define("MAX_ORG_RECORD_LENGTH", 300);
@define("GEOIP_SHM_KEY", 0x4f415401);
@define("US_OFFSET", 1);
@define("CANADA_OFFSET", 677);
@define("WORLD_OFFSET", 1353);
@define("FIPS_RANGE", 360);
@define("GEOIP_UNKNOWN_SPEED", 0);
@define("GEOIP_DIALUP_SPEED", 1);
@define("GEOIP_CABLEDSL_SPEED", 2);
@define("GEOIP_CORPORATE_SPEED", 3);
@define("GEOIP_DOMAIN_EDITION", 11);
@define("GEOIP_COUNTRY_EDITION_V6", 12);
@define("GEOIP_LOCATIONA_EDITION", 13);
@define("GEOIP_ACCURACYRADIUS_EDITION", 14);
@define("GEOIP_CITYCOMBINED_EDITION", 15);
@define("GEOIP_CITY_EDITION_REV1_V6", 30);
@define("GEOIP_CITY_EDITION_REV0_V6",31);
@define("GEOIP_NETSPEED_EDITION_REV1",32);
@define("GEOIP_NETSPEED_EDITION_REV1_V6",33);
@define("GEOIP_USERTYPE_EDITION",28);
@define("GEOIP_USERTYPE_EDITION_V6",29);
@define("GEOIP_ASNUM_EDITION_V6",21);
@define("GEOIP_ISP_EDITION_V6",22);
@define("GEOIP_ORG_EDITION_V6",23);
@define("GEOIP_DOMAIN_EDITION_V6",24);
@define("CITYCOMBINED_FIXED_RECORD", 7 );
class GeoIP {
var $flags;

View File

@ -448,7 +448,7 @@ if (isset($_POST['delete'])) {
if ($config['country_flags']) {
require 'inc/lib/geoip/geoip.inc';
$gi=geoip_open('inc/lib/geoip/GeoIPv6.dat', GEOIP_STANDARD);
$gi=geoip\geoip_open('inc/lib/geoip/GeoIPv6.dat', GEOIP_STANDARD);
function ipv4to6($ip) {
if (strpos($ip, ':') !== false) {
@ -462,10 +462,10 @@ if (isset($_POST['delete'])) {
return '::ffff:'.$part7.':'.$part8;
}
if ($country_code = geoip_country_code_by_addr_v6($gi, ipv4to6($_SERVER['REMOTE_ADDR']))) {
if ($country_code = geoip\geoip_country_code_by_addr_v6($gi, ipv4to6($_SERVER['REMOTE_ADDR']))) {
if (!in_array(strtolower($country_code), array('eu', 'ap', 'o1', 'a1', 'a2')))
$post['body'] .= "\n<tinyboard flag>".strtolower($country_code)."</tinyboard>".
"\n<tinyboard flag alt>".geoip_country_name_by_addr_v6($gi, ipv4to6($_SERVER['REMOTE_ADDR']))."</tinyboard>";
"\n<tinyboard flag alt>".geoip\geoip_country_name_by_addr_v6($gi, ipv4to6($_SERVER['REMOTE_ADDR']))."</tinyboard>";
}
}