Maxmind provides geolocation Web services (non-free).
I wrote a small patch which permits the use of thoses web services.
Only available for Country for now since I don't have information on other services.
Probably need to refactor the UI admin to integrate this in a more ergonomic way.
Attached is a patch against 7-x.1.5.

CommentFileSizeAuthor
smart_ip_maxmindgeoip.patch6.99 KBetiennechataignier

Comments

etiennechataignier’s picture

Issue summary: View changes

Add UI info

arpeggio’s picture

Status: Needs review » Fixed

Hi echataig, I have implemented the patch you have submitted (I have done few improvements). Already pushed, please use dev version. Thank you for sharing the patch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

duntuk’s picture

Version: 7.x-1.5 » 7.x-1.x-dev

Here's the updated code for maxmind IP web service "GeoIP City/ISP/Organization Web Service" (they only offer 3 packages: "Country", "GeoIP City/ISP/Organization Web Service" , and "omni":

under smart_ip.module around line 389. Which includes additional: longtitude, latitude, and region

Prior to this, smart_ip only displayed maxmind's City and Country.

Before:

Los Angeles, US

AFTER

Los Angeles, CA, US longtitude, latitude

As you can tell, having the 'region' is pretty crucial, since there are identical city names throughout the United States.

  if ($smart_ip_source == 'maxmindgeoip_service') {
    // Use Maxmind GeoIP service if needed
    include_once DRUPAL_ROOT . '/includes/locale.inc';
    $countries = country_get_list();
    $request = drupal_http_request(smart_ip_get_maxmindgeoip_url($ip_address));
    if (!empty($request)) {
      switch (variable_get('smart_ip_maxmind_service', 'country')) {
        case 'country':
          // For Maxmind GeoIp Country
          // In case of errors the country code "(null),IP_NOT_FOUND" is returned,
          // so we need to check if the code is in our countries list.
          $result['country_code'] = isset($request->data) && isset($countries[$request->data]) ? $request->data : '';
          $result['country']      = empty($result['country_code']) ? '' : $countries[$request->data];
          $result['region']       = '';
          $result['region_code']  = '';
          $result['city']         = '';
          $result['zip']          = '';
          $result['latitude']     = '';
          $result['longitude']    = '';
          break;
        case 'city':
          // For Maxmind GeoIp City
          // In case of errors the country code "(null),IP_NOT_FOUND" is returned,
          // so we need to check if the code is in our countries list.
          $response = str_getcsv($request->data);
          $result['country_code'] = isset($request->data) && isset($countries[$response[0]]) ? $response[0] : '';
          $result['country']      = empty($result['country_code']) ? '' : $countries[$response[0]];
          $result['region']       = $response[1];
          $result['region_code']  = $response[1];
          $result['city']         = $response[2];
          $result['zip']          = '';
          $result['latitude']     = $response[3];
          $result['longitude']    = $response[4];
          break;
      }
    }
  }  
arpeggio’s picture

@duntuk I have already updated the code for GeoIP City/ISP/Organization Web Service. Thank you for sharing this info.

arpeggio’s picture

Issue summary: View changes

english trial