You are here

function _smart_ip_lookup_submit in Smart IP 6

Same name and namespace in other branches
  1. 6.2 includes/smart_ip.admin.inc \_smart_ip_lookup_submit()
  2. 7.2 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.

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 240
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 ($location) {
    $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('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('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;
}