public static function SmartIpAdminSettingsForm::manualLookup in Smart IP 8.2
Same name and namespace in other branches
- 8.4 src/Form/SmartIpAdminSettingsForm.php \Drupal\smart_ip\Form\SmartIpAdminSettingsForm::manualLookup()
- 8.3 src/Form/SmartIpAdminSettingsForm.php \Drupal\smart_ip\Form\SmartIpAdminSettingsForm::manualLookup()
Submit handler to lookup an IP address in the database.
Parameters
array $form:
\Drupal\Core\Form\FormStateInterface $form_state:
See also
\Drupal\smart_ip\Form\SmartIpAdminSettingsForm::manualLookupAjax
File
- src/
Form/ SmartIpAdminSettingsForm.php, line 236 - Contains \Drupal\smart_ip\Form\SmartIpAdminSettingsForm.
Class
- SmartIpAdminSettingsForm
- Smart IP main admin settings page.
Namespace
Drupal\smart_ip\FormCode
public static function manualLookup(array $form, FormStateInterface $form_state) {
$ip = $form_state
->getValue('smart_ip_lookup');
$location = SmartIp::query($ip);
if (isset($location['latitude']) && isset($location['longitude'])) {
$message = '<p>' . t('IP Address @ip is assigned to the following location details:', array(
'@ip' => $ip,
)) . '</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['countryCode'],
)) . '</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['timeZone'],
)) . '</dd>' . '</dl>';
}
else {
$message = t('IP Address @ip is not assigned to any location.', array(
'@ip' => $ip,
));
}
$storage['smart_ip_message'] = $message;
$form_state
->setStorage($storage);
$form_state
->setRebuild();
}