Skip to content

Instantly share code, notes, and snippets.

@centminmod

centminmod/geoinc.patch Secret

Last active Sep 1, 2016
Embed
What would you like to do?
sendy.co includes/helpers/geo/geoip.inc patch fix for nginx / php-fpm when php geoip extension is loaded - fixes broken sendy.co t.php tracking images which give 500 internal server errors
--- geoip.inc 2016-02-15 18:11:41.880114058 +0000
+++ geoip.inc-fixed 2016-02-15 18:12:12.875832234 +0000
@@ -28,16 +28,18 @@
define("GEOIP_SHARED_MEMORY", 2);
define("STRUCTURE_INFO_MAX_SIZE", 20);
define("DATABASE_INFO_MAX_SIZE", 100);
-define("GEOIP_COUNTRY_EDITION", 106);
-define("GEOIP_PROXY_EDITION", 8);
-define("GEOIP_ASNUM_EDITION", 9);
-define("GEOIP_NETSPEED_EDITION", 10);
-define("GEOIP_REGION_EDITION_REV0", 112);
-define("GEOIP_REGION_EDITION_REV1", 3);
-define("GEOIP_CITY_EDITION_REV0", 111);
-define("GEOIP_CITY_EDITION_REV1", 2);
-define("GEOIP_ORG_EDITION", 110);
-define("GEOIP_ISP_EDITION", 4);
+if(!extension_loaded('geoip')) {
+ define("GEOIP_COUNTRY_EDITION", 106);
+ define("GEOIP_PROXY_EDITION", 8);
+ define("GEOIP_ASNUM_EDITION", 9);
+ define("GEOIP_NETSPEED_EDITION", 10);
+ define("GEOIP_REGION_EDITION_REV0", 112);
+ define("GEOIP_REGION_EDITION_REV1", 3);
+ define("GEOIP_CITY_EDITION_REV0", 111);
+ define("GEOIP_CITY_EDITION_REV1", 2);
+ define("GEOIP_ORG_EDITION", 110);
+ define("GEOIP_ISP_EDITION", 4);
+}
define("SEGMENT_RECORD_LENGTH", 3);
define("STANDARD_RECORD_LENGTH", 3);
define("ORG_RECORD_LENGTH", 4);
@@ -48,18 +50,22 @@
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);
+if(!extension_loaded('geoip')) {
+ 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);
+if(!extension_loaded('geoip')) {
+ define("GEOIP_NETSPEED_EDITION_REV1",32);
+}
define("GEOIP_NETSPEED_EDITION_REV1_V6",33);
define("GEOIP_USERTYPE_EDITION",28);
define("GEOIP_USERTYPE_EDITION_V6",29);
@@ -421,12 +427,14 @@
return geoip_country_id_by_addr($gi, $addr);
}
-function geoip_country_code_by_name_v6($gi, $name) {
- $country_id = geoip_country_id_by_name_v6($gi,$name);
- if ($country_id !== false) {
- return $gi->GEOIP_COUNTRY_CODES[$country_id];
+if (!function_exists('geoip_country_code_by_name_v6')) {
+ function geoip_country_code_by_name_v6($gi, $name) {
+ $country_id = geoip_country_id_by_name_v6($gi,$name);
+ if ($country_id !== false) {
+ return $gi->GEOIP_COUNTRY_CODES[$country_id];
+ }
+ return false;
}
- return false;
}
if(!function_exists('geoip_country_code_by_name')) {
@@ -439,12 +447,14 @@
}
}
-function geoip_country_name_by_name_v6($gi, $name) {
- $country_id = geoip_country_id_by_name_v6($gi,$name);
- if ($country_id !== false) {
- return $gi->GEOIP_COUNTRY_NAMES[$country_id];
+if(!function_exists('geoip_country_name_by_name_v6')) {
+ function geoip_country_name_by_name_v6($gi, $name) {
+ $country_id = geoip_country_id_by_name_v6($gi,$name);
+ if ($country_id !== false) {
+ return $gi->GEOIP_COUNTRY_NAMES[$country_id];
+ }
+ return false;
}
- return false;
}
if(! function_exists('geoip_country_name_by_name')) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.