Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions geoip.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ zend_function_entry geoip_functions[] = {
PHP_FE(geoip_org_by_name, NULL)
PHP_FE(geoip_record_by_name, NULL)
PHP_FE(geoip_id_by_name, NULL)
PHP_FE(geoip_name_by_addr, NULL)
PHP_FE(geoip_region_by_name, NULL)
PHP_FE(geoip_isp_by_name, NULL)
PHP_FE(geoip_db_avail, NULL)
Expand Down Expand Up @@ -526,6 +527,36 @@ PHP_FUNCTION(geoip_id_by_name)
}
/* }}} */

/* {{{ proto string geoip_name_by_addr( string hostname )
Returns the Net Speed found in the GeoIP Database */
PHP_FUNCTION(geoip_name_by_addr)
{
GeoIP * gi;
char * hostname = NULL;
int arglen;
char * netspeed;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) {
return;
}

if (GeoIP_db_avail(GEOIP_NETSPEED_EDITION)) {
gi = GeoIP_open_type(GEOIP_NETSPEED_EDITION, GEOIP_STANDARD);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_NETSPEED_EDITION]);
return;
}

netspeed = GeoIP_name_by_addr(gi, hostname);
GeoIP_delete(gi);

if(netspeed == NULL) {
RETURN_FALSE;
}
RETURN_STRING((char*)netspeed, 1);
}
/* }}} */

/* {{{ proto array geoip_region_by_name( string hostname )
Returns the Country Code and region found in the GeoIP Database */
PHP_FUNCTION(geoip_region_by_name)
Expand Down
1 change: 1 addition & 0 deletions php_geoip.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ PHP_FUNCTION(geoip_continent_code_by_name);
PHP_FUNCTION(geoip_org_by_name);
PHP_FUNCTION(geoip_record_by_name);
PHP_FUNCTION(geoip_id_by_name);
PHP_FUNCTION(geoip_name_by_addr);
PHP_FUNCTION(geoip_region_by_name);
PHP_FUNCTION(geoip_isp_by_name);
PHP_FUNCTION(geoip_db_avail);
Expand Down