php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #68277
Patch patch-geoip-open-type revision 2014-10-23 15:22 UTC by phpbugs at joern dot heissler dot de
Patch geoip-1.1.0-city.patch revision 2014-10-23 13:08 UTC by slim at inbox dot lv
Patch patch-geoip_record_by_name revision 2014-10-23 02:47 UTC by phpbugs at joern dot heissler dot de

Patch geoip-1.1.0-city.patch for geoip Bug #68277

Patch version 2014-10-23 13:08 UTC

Return to Bug #68277 | Download this patch
Patch Revisions:

Developer: slim@inbox.lv

--- geoip.c.orig        2014-05-01 20:44:31.000000000 +0300
+++ geoip.c     2014-10-22 20:54:31.000000000 +0300
@@ -548,15 +548,18 @@
        }
 
        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);
-               } else {
-                       gi = GeoIP_open_type(GEOIP_CITY_EDITION_REV0, GEOIP_STANDARD);
+               gi = GeoIP_open_type(GEOIP_CITY_EDITION_REV0, GEOIP_STANDARD);
+               if (NULL == gi) { gi = GeoIP_open_type(GEOIP_CITY_EDITION_REV1, GEOIP_STANDARD); }
+               if (NULL == gi) { 
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't open database file");
+                       return;
                }
-       }   else {
+       } 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);
 
        GeoIP_delete(gi);
@@ -628,11 +631,12 @@
        }
 
        if (GeoIP_db_avail(GEOIP_REGION_EDITION_REV0) || GeoIP_db_avail(GEOIP_REGION_EDITION_REV1)) {
-               if (GeoIP_db_avail(GEOIP_REGION_EDITION_REV1)) {
-                       gi = GeoIP_open_type(GEOIP_REGION_EDITION_REV1, GEOIP_STANDARD);
-               } else {
-                       gi = GeoIP_open_type(GEOIP_REGION_EDITION_REV0, GEOIP_STANDARD);
-               }
+               gi = GeoIP_open_type(GEOIP_REGION_EDITION_REV0, GEOIP_STANDARD);
+               if (NULL == gi) { gi = GeoIP_open_type(GEOIP_REGION_EDITION_REV1, GEOIP_STANDARD); }
+               if (NULL == gi) { 
+                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't open database file");
+                        return;
+               }
        }   else {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_REGION_EDITION_REV0]);
                return;
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Aug 13 00:05:43 2022 UTC