--- 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;