Search
j0ke.net Open Build Service
>
Projects
>
internetx
:
php5
:
5.3.18
:
extensions
>
php5-geoip
> geoip-1.0.8-ipv6-fix.patch
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File geoip-1.0.8-ipv6-fix.patch of Package php5-geoip
diff -ruN geoip-1.0.8.orig/geoip.c geoip-1.0.8/geoip.c --- geoip-1.0.8.orig/geoip.c 1970-01-01 10:13:08.000000000 +0100 +++ geoip-1.0.8/geoip.c 2012-11-13 11:58:08.000000000 +0100 @@ -42,8 +42,11 @@ PHP_FE(geoip_database_info, NULL) #define GEOIPDEF(php_func, c_func, db_type) \ PHP_FE(php_func, NULL) +#define GEOIPMULTIDEF(php_func, c_func, db_type, c_func_v6, db_type_v6) \ + PHP_FE(php_func, NULL) #include "geoip.def" #undef GEOIPDEF +#undef GEOIPMULTIDEF PHP_FE(geoip_continent_code_by_name, NULL) PHP_FE(geoip_org_by_name, NULL) PHP_FE(geoip_record_by_name, NULL) @@ -119,11 +122,23 @@ /* For database type constants */ REGISTER_LONG_CONSTANT("GEOIP_COUNTRY_EDITION", GEOIP_COUNTRY_EDITION, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("GEOIP_COUNTRY_EDITION_V4", GEOIP_COUNTRY_EDITION, CONST_CS | CONST_PERSISTENT); +#if LIBGEOIP_VERSION >= 1004005 + REGISTER_LONG_CONSTANT("GEOIP_COUNTRY_EDITION_V6", GEOIP_COUNTRY_EDITION_V6, CONST_CS | CONST_PERSISTENT); +#endif REGISTER_LONG_CONSTANT("GEOIP_REGION_EDITION_REV0", GEOIP_REGION_EDITION_REV0, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_CITY_EDITION_REV0", GEOIP_CITY_EDITION_REV0, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("GEOIP_CITY_EDITION_REV0_V4", GEOIP_CITY_EDITION_REV0, CONST_CS | CONST_PERSISTENT); +#if LIBGEOIP_VERSION >= 1004005 + REGISTER_LONG_CONSTANT("GEOIP_CITY_EDITION_REV0_V6", GEOIP_CITY_EDITION_REV0_V6, CONST_CS | CONST_PERSISTENT); +#endif REGISTER_LONG_CONSTANT("GEOIP_ORG_EDITION", GEOIP_ORG_EDITION, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_ISP_EDITION", GEOIP_ISP_EDITION, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_CITY_EDITION_REV1", GEOIP_CITY_EDITION_REV1, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("GEOIP_CITY_EDITION_REV1_V4", GEOIP_CITY_EDITION_REV1, CONST_CS | CONST_PERSISTENT); +#if LIBGEOIP_VERSION >= 1004005 + REGISTER_LONG_CONSTANT("GEOIP_CITY_EDITION_REV1_V6", GEOIP_CITY_EDITION_REV1_V6, CONST_CS | CONST_PERSISTENT); +#endif REGISTER_LONG_CONSTANT("GEOIP_REGION_EDITION_REV1", GEOIP_REGION_EDITION_REV1, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_PROXY_EDITION", GEOIP_PROXY_EDITION, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_ASNUM_EDITION", GEOIP_ASNUM_EDITION, CONST_CS | CONST_PERSISTENT); @@ -313,10 +328,50 @@ RETURN_STRING((char*)return_code, 1); \ \ } + +#define GEOIPMULTIDEF(php_func, c_func, db_type, c_func_v6, db_type_v6) \ + PHP_FUNCTION(php_func) \ + { \ + GeoIP * gi; \ + char * hostname = NULL; \ + const char * return_code; \ + int arglen; \ + \ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { \ + return; \ + } \ + \ + if (GeoIP_db_avail(db_type)) { \ + gi = GeoIP_open_type(db_type, GEOIP_STANDARD); \ + } else { \ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[db_type]); \ + return; \ + } \ + \ + return_code = c_func(gi, hostname); \ + GeoIP_delete(gi); \ + if (return_code != NULL) { \ + RETURN_STRING((char*)return_code, 1); \ + } \ + if (GeoIP_db_avail(db_type_v6)) { \ + gi = GeoIP_open_type(db_type_v6, GEOIP_STANDARD); \ + return_code = c_func_v6(gi, hostname); \ + GeoIP_delete(gi); \ + if (return_code != NULL) { \ + RETURN_STRING((char*)return_code, 1); \ + } \ + } \ + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); \ + RETURN_FALSE; \ + \ + } + #include "geoip.def" #undef GEOIPDEF +#undef GEOIPMULTIDEF /* }}} */ + /* {{{ proto string geoip_continent_code_by_name( string hostname ) Returns the Continent name found in the GeoIP Database */ PHP_FUNCTION(geoip_continent_code_by_name) @@ -339,6 +394,13 @@ id = GeoIP_id_by_name(gi, hostname); GeoIP_delete(gi); +#if LIBGEOIP_VERSION >= 1004005 + if (id == 0 && GeoIP_db_avail(GEOIP_COUNTRY_EDITION_V6)) { + gi = GeoIP_open_type(GEOIP_COUNTRY_EDITION_V6, GEOIP_STANDARD); + id = GeoIP_id_by_name_v6(gi, hostname); + GeoIP_delete(gi); + } +#endif if (id == 0) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); RETURN_FALSE; @@ -385,28 +447,66 @@ GeoIP * gi; char * hostname = NULL; int arglen; - GeoIPRecord * gir; + GeoIPRecord * gir = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { return; } - if (GeoIP_db_avail(GEOIP_CITY_EDITION_REV1) || GeoIP_db_avail(GEOIP_CITY_EDITION_REV0)) { - if (GeoIP_db_avail(GEOIP_CITY_EDITION_REV1)) { - gi = GeoIP_open_type(GEOIP_CITY_EDITION_REV1, GEOIP_STANDARD); + int ipv4_db_available = 1; +#if LIBGEOIP_VERSION >= 1004005 + int ipv6_db_available = 1; +#endif + + if (GeoIP_db_avail(GEOIP_CITY_EDITION_REV1)) { + gi = GeoIP_open_type(GEOIP_CITY_EDITION_REV1, GEOIP_STANDARD); + } else if (GeoIP_db_avail(GEOIP_CITY_EDITION_REV0)) { + gi = GeoIP_open_type(GEOIP_CITY_EDITION_REV0, GEOIP_STANDARD); + } else { + ipv4_db_available = 9; + } + + if (ipv4_db_available) { + gir = GeoIP_record_by_name(gi, hostname); + } + + if (NULL != gi) { + GeoIP_delete(gi); + } + +#if LIBGEOIP_VERSION >= 1004005 + if (NULL == gir) { + if (GeoIP_db_avail(GEOIP_CITY_EDITION_REV1_V6)) { + gi = GeoIP_open_type(GEOIP_CITY_EDITION_REV1_V6, GEOIP_STANDARD); + } else if (GeoIP_db_avail(GEOIP_CITY_EDITION_REV0_V6)) { + gi = GeoIP_open_type(GEOIP_CITY_EDITION_REV0_V6, GEOIP_STANDARD); } else { - gi = GeoIP_open_type(GEOIP_CITY_EDITION_REV0, GEOIP_STANDARD); + ipv6_db_available = 0; + } + + if (ipv6_db_available) { + gir = GeoIP_record_by_name_v6(gi, hostname); + } + + if (NULL != gi) { + GeoIP_delete(gi); } - } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_CITY_EDITION_REV0]); - return; } - gir = GeoIP_record_by_name(gi, hostname); +#endif - GeoIP_delete(gi); - if (NULL == gir) { + if (!ipv4_db_available) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required IPv4 database not available at %s.", GeoIPDBFileName[GEOIP_CITY_EDITION_REV0]); + } + +#if LIBGEOIP_VERSION >= 1004005 + if (!ipv6_db_available) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Required IPv6 database not available at %s.", GeoIPDBFileName[GEOIP_CITY_EDITION_REV0_V6]); + } +#endif + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); + RETURN_FALSE; } diff -ruN geoip-1.0.8.orig/geoip.def geoip-1.0.8/geoip.def --- geoip-1.0.8.orig/geoip.def 1970-01-01 10:13:08.000000000 +0100 +++ geoip-1.0.8/geoip.def 2012-11-13 12:19:51.000000000 +0100 @@ -17,12 +17,20 @@ */ /* GEOIPDEF(php_func, c_func, db_type) */ -GEOIPDEF(geoip_country_code_by_name, GeoIP_country_code_by_name, GEOIP_COUNTRY_EDITION) -GEOIPDEF(geoip_country_code3_by_name, GeoIP_country_code3_by_name, GEOIP_COUNTRY_EDITION) -GEOIPDEF(geoip_country_name_by_name, GeoIP_country_name_by_name, GEOIP_COUNTRY_EDITION) +GEOIPDEF(geoip_country_code_by_name_v4, GeoIP_country_code_by_name, GEOIP_COUNTRY_EDITION) +GEOIPDEF(geoip_country_code3_by_name_v4, GeoIP_country_code3_by_name, GEOIP_COUNTRY_EDITION) +GEOIPDEF(geoip_country_name_by_name_v4, GeoIP_country_name_by_name, GEOIP_COUNTRY_EDITION) -#if LIBGEOIP_VERSION >= 1004005 && FALSE +#if LIBGEOIP_VERSION >= 1004005 GEOIPDEF(geoip_country_code_by_name_v6, GeoIP_country_code_by_name_v6, GEOIP_COUNTRY_EDITION_V6) GEOIPDEF(geoip_country_code3_by_name_v6, GeoIP_country_code3_by_name_v6, GEOIP_COUNTRY_EDITION_V6) GEOIPDEF(geoip_country_name_by_name_v6, GeoIP_country_name_by_name_v6, GEOIP_COUNTRY_EDITION_V6) -#endif \ No newline at end of file + +GEOIPMULTIDEF(geoip_country_code_by_name, GeoIP_country_code_by_name, GEOIP_COUNTRY_EDITION, GeoIP_country_code_by_name_v6, GEOIP_COUNTRY_EDITION_V6) +GEOIPMULTIDEF(geoip_country_code3_by_name, GeoIP_country_code3_by_name, GEOIP_COUNTRY_EDITION, GeoIP_country_code3_by_name_v6, GEOIP_COUNTRY_EDITION_V6) +GEOIPMULTIDEF(geoip_country_name_by_name, GeoIP_country_name_by_name, GEOIP_COUNTRY_EDITION, GeoIP_country_name_by_name_v6, GEOIP_COUNTRY_EDITION_V6) +#else +GEOIPDEF(geoip_country_code_by_name, GeoIP_country_code_by_name, GEOIP_COUNTRY_EDITION) +GEOIPDEF(geoip_country_code3_by_name, GeoIP_country_code3_by_name, GEOIP_COUNTRY_EDITION) +GEOIPDEF(geoip_country_name_by_name, GeoIP_country_name_by_name, GEOIP_COUNTRY_EDITION) +#endif diff -ruN geoip-1.0.8.orig/php_geoip.h geoip-1.0.8/php_geoip.h --- geoip-1.0.8.orig/php_geoip.h 1970-01-01 10:13:08.000000000 +0100 +++ geoip-1.0.8/php_geoip.h 2012-11-13 11:21:40.000000000 +0100 @@ -49,8 +49,11 @@ PHP_FUNCTION(geoip_database_info); #define GEOIPDEF(php_func, c_func, db_type) \ PHP_FUNCTION(php_func); +#define GEOIPMULTIDEF(php_func, c_func, db_type, c_func_v6, db_type_v6) \ +PHP_FUNCTION(php_func); #include "geoip.def" #undef GEOIPDEF +#undef GEOIPMULTIDEF PHP_FUNCTION(geoip_continent_code_by_name); PHP_FUNCTION(geoip_org_by_name); PHP_FUNCTION(geoip_record_by_name);