You are here

function _smart_ip_lookup_submit in Smart IP 7.2

Same name and namespace in other branches
  1. 6.2 includes/smart_ip.admin.inc \_smart_ip_lookup_submit()
  2. 6 includes/smart_ip.admin.inc \_smart_ip_lookup_submit()
  3. 7 includes/smart_ip.admin.inc \_smart_ip_lookup_submit()

Submit handler to lookup an IP address in the database.

See also

_smart_ip_lookup_js()

1 string reference to '_smart_ip_lookup_submit'
smart_ip_admin_settings in includes/smart_ip.admin.inc
Smart IP administration settings.

File

includes/smart_ip.admin.inc, line 730
Admin interface callbacks/handlers to configure Smart IP.

Code

function _smart_ip_lookup_submit($form, &$form_state) {
  $lookup = $form_state['values']['smart_ip_lookup'];

  // Return results of manual lookup
  $location = smart_ip_get_location($lookup);
  if (isset($location['country_code'])) {
    $is_eu_country = $location['is_eu_country'] ? t('Yes') : t('No');
    $is_gdpr_country = $location['is_gdpr_country'] ? t('Yes') : t('No');
    $message = '<p>' . t('IP Address @ip is assigned to the following location details:', array(
      '@ip' => $lookup,
    )) . '</p><dl>' . '<dt>' . t('Country:') . '</dt>' . '<dd>' . t('%country', array(
      '%country' => $location['country'],
    )) . '</dd>' . '<dt>' . t('Country code:') . '</dt>' . '<dd>' . t('%country_code', array(
      '%country_code' => $location['country_code'],
    )) . '</dd>' . '<dt>' . t('Region:') . '</dt>' . '<dd>' . t('%region', array(
      '%region' => $location['region'],
    )) . '</dd>' . '<dt>' . t('City:') . '</dt>' . '<dd>' . t('%city', array(
      '%city' => $location['city'],
    )) . '</dd>' . '<dt>' . t('Postal code:') . '</dt>' . '<dd>' . t('%zip', array(
      '%zip' => $location['zip'],
    )) . '</dd>' . '<dt>' . t('Latitude:') . '</dt>' . '<dd>' . t('%latitude', array(
      '%latitude' => $location['latitude'],
    )) . '</dd>' . '<dt>' . t('Longitude:') . '</dt>' . '<dd>' . t('%longitude', array(
      '%longitude' => $location['longitude'],
    )) . '</dd>' . '<dt>' . t('Is EU member country:') . '</dt>' . '<dd>' . $is_eu_country . '</dd>' . '<dt>' . t('Is GDPR country:') . '</dt>' . '<dd>' . $is_gdpr_country . '</dd>' . '<dt>' . t('Time zone:') . '</dt>' . '<dd>' . t('%time_zone', array(
      '%time_zone' => $location['time_zone'],
    )) . '</dd>' . '</dl>';
  }
  else {
    $message = t('IP Address @ip is not assigned to any location.', array(
      '@ip' => $lookup,
    ));
  }
  $form_state['storage']['smart_ip_message'] = $message;
  $form_state['rebuild'] = TRUE;
}