echo "(This doesn't seem to be the case.)"; ?> <?php } ?> </em> </span> </p> <p> External IP of this server: <input type="text" name="options[external_ip]" value="<?php echo esc_attr($wp_options['external_ip']); ?> " placeholder="auto" /> <span class="detail-box"> Current value: <?php echo geoip_detect2_get_external_ip_adress(); ?> <br /> If empty: Try to use an ip service to detect it (Internet connection is necessary). If this is not possible, 0.0.0.0 will be returned.<br /> (This external adress will be used when the request IP adress is not a public IP, e.g. 127.0.0.1) </span> </p> <p> <input type="submit" class="button button-primary" value="<?php _e('Save', 'geoip-detect'); ?> " />
/** * Sometimes we can only see an local IP adress (local development environment.) * In this case we need to ask an internet server which IP adress our internet connection has. * * @deprecated since v2.0 * @return string The detected IP Adress. If none is found, '0.0.0.0' is returned instead. */ function geoip_detect_get_external_ip_adress() { return geoip_detect2_get_external_ip_adress(); }
function _geoip_detect2_get_record_from_reader($reader, $ip, &$error) { $record = null; $ip = trim($ip); if ($reader) { // When plugin installed on development boxes: // If the client IP is not a public IP, use the public IP of the server instead. // Of course this only works if the internet can be accessed. if ($ip == 'me' || geoip_detect_is_ip($ip) && !geoip_detect_is_public_ip($ip)) { $ip = geoip_detect2_get_external_ip_adress(); } try { try { $record = $reader->city($ip); } catch (\BadMethodCallException $e) { $record = $reader->country($ip); } } catch (\Exception $e) { $error = 'Lookup Error: ' . $e->getMessage(); } $reader->close(); } else { $error = 'No reader was found. Check if the configuration is complete and correct.'; } return $record; }
function geoip_detect2_shortcode_get_external_ip_adress($attr) { $external_ip = geoip_detect2_get_external_ip_adress(); return $external_ip; }