Skip to content
This repository has been archived by the owner on Apr 5, 2018. It is now read-only.

Commit

Permalink
Add GEOIP_REGION_NAME for City and Region databases ( Boris Zentner )
Browse files Browse the repository at this point in the history
  • Loading branch information
borisz committed Aug 6, 2008
1 parent 6022e91 commit e9e9c9e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,3 +1,4 @@
- Add GEOIP_REGION_NAME for City and Region databases ( Boris Zentner )
1.2.4 Jun 10th 2008
! mod_geoip2 has sets GEOIP_COUNTRY_CODE to -- for unknown countries when used with the country database. But for any other database ( City for example ) GEOIP_COUNTRY_CODE is unset for unknown countries. This is fixed now. Same for GEOIP_CONTINENT_CODE and GEOIP_COUNTRY_NAME. ( Boris Zentner )
- Add GEOIP_ADDR. That's the address used to compute the geoip information. Exported as env, notes or both as usual ( Jason Caldwell )
Expand Down
20 changes: 20 additions & 0 deletions mod_geoip.c
Expand Up @@ -302,6 +302,7 @@ geoip_header_parser(request_rec * r)
const char *continent_code;
const char *country_code;
const char *country_name;
const char *region_name;

geoip_server_config_rec *cfg;

Expand Down Expand Up @@ -462,13 +463,23 @@ geoip_header_parser(request_rec * r)
case GEOIP_REGION_EDITION_REV1:
giregion = GeoIP_region_by_name(cfg->gips[i], ipaddr);
if (giregion != NULL) {
if ( giregion->country_code != NULL ) {
region_name = GeoIP_region_name_by_code(giregion->country_code, giregion->region);
}
if (cfg->GeoIPOutput & GEOIP_NOTES) {
apr_table_set(r->notes, "GEOIP_COUNTRY_CODE", giregion->country_code);
apr_table_set(r->notes, "GEOIP_REGION", giregion->region);

if ( region_name != NULL ){
apr_table_set(r->notes, "GEOIP_REGION_NAME", region_name);
}
}
if (cfg->GeoIPOutput & GEOIP_ENV) {
apr_table_set(r->subprocess_env, "GEOIP_COUNTRY_CODE", giregion->country_code);
apr_table_set(r->subprocess_env, "GEOIP_REGION", giregion->region);
if ( region_name != NULL ){
apr_table_set(r->subprocess_env, "GEOIP_REGION_NAME", region_name);
}
}
GeoIPRegion_delete(giregion);
}
Expand All @@ -477,6 +488,9 @@ geoip_header_parser(request_rec * r)
case GEOIP_CITY_EDITION_REV1:
gir = GeoIP_record_by_addr(cfg->gips[i], ipaddr);
if (gir != NULL) {
if ( gir->country_code != NULL ) {
region_name = GeoIP_region_name_by_code(gir->country_code, gir->region);
}
sprintf(dmacodestr, "%d", gir->dma_code);
sprintf(areacodestr, "%d", gir->area_code);
if (cfg->GeoIPOutput & GEOIP_NOTES) {
Expand All @@ -485,6 +499,9 @@ geoip_header_parser(request_rec * r)
apr_table_setn(r->notes, "GEOIP_COUNTRY_NAME", gir->country_name);
if (gir->region != NULL) {
apr_table_set(r->notes, "GEOIP_REGION", gir->region);
if ( region_name != NULL ){
apr_table_set(r->notes, "GEOIP_REGION_NAME", region_name);
}
}
if (gir->city != NULL) {
apr_table_set(r->notes, "GEOIP_CITY", gir->city);
Expand All @@ -498,6 +515,9 @@ geoip_header_parser(request_rec * r)
apr_table_setn(r->subprocess_env, "GEOIP_COUNTRY_NAME", gir->country_name);
if (gir->region != NULL) {
apr_table_set(r->subprocess_env, "GEOIP_REGION", gir->region);
if ( region_name != NULL ){
apr_table_set(r->subprocess_env, "GEOIP_REGION_NAME", region_name);
}
}
if (gir->city != NULL) {
apr_table_set(r->subprocess_env, "GEOIP_CITY", gir->city);
Expand Down

0 comments on commit e9e9c9e

Please sign in to comment.