2011-03-28 14:21:28 +00:00
< ?
2013-05-02 08:00:23 +00:00
if ( isset ( $_SERVER [ 'http_if_modified_since' ])) {
header ( 'Status: 304 Not Modified' );
2011-03-28 14:21:28 +00:00
die ();
}
2013-05-02 08:00:23 +00:00
header ( 'Expires: ' . date ( 'D, d-M-Y H:i:s \U\T\C' , time () + 3600 * 24 * 120 )); //120 days
header ( 'Last-Modified: ' . date ( 'D, d-M-Y H:i:s \U\T\C' , time ()));
2011-03-28 14:21:28 +00:00
2013-05-02 08:00:23 +00:00
if ( ! check_perms ( 'users_view_ips' )) {
die ( 'Access denied.' );
}
2011-03-28 14:21:28 +00:00
2013-05-02 08:00:23 +00:00
$Octets = explode ( '.' , $_GET [ 'ip' ]);
if (
2011-03-28 14:21:28 +00:00
empty ( $_GET [ 'ip' ]) ||
2013-06-11 08:01:24 +00:00
! preg_match ( '/' . IP_REGEX . '/' , $_GET [ 'ip' ]) ||
2011-03-28 14:21:28 +00:00
$Octets [ 0 ] < 0 ||
$Octets [ 0 ] > 255 ||
$Octets [ 1 ] < 0 ||
$Octets [ 1 ] > 255 ||
$Octets [ 2 ] < 0 ||
$Octets [ 2 ] > 255 ||
$Octets [ 3 ] < 0 ||
$Octets [ 3 ] > 255 ||
2013-05-02 08:00:23 +00:00
/*
* Per RFC 1918 , the following CIDR blocks should never be found on the public Internet .
* 10.0 . 0.0 / 8
* 172.16 . 0.0 / 12
* 192.168 . 0.0 / 16
*
* Per RFC 3330 , the block 127.0 . 0.0 / 8 should never appear on any network .
*
*/
2011-03-28 14:21:28 +00:00
$Octets [ 0 ] == 127 ||
2013-05-02 08:00:23 +00:00
$Octets [ 0 ] == 10 ||
( $Octets [ 0 ] == 172 && (( 16 <= $Octets [ 1 ]) && ( $Octets [ 1 ] <= 31 ))) ||
2011-03-28 14:21:28 +00:00
( $Octets [ 0 ] == 192 && $Octets [ 1 ] == 168 )
) {
2013-05-02 08:00:23 +00:00
die ( 'Invalid IPv4 address.' );
2011-03-28 14:21:28 +00:00
}
2012-10-11 08:00:15 +00:00
$Host = Tools :: lookup_ip ( $_GET [ 'ip' ]);
2011-03-28 14:21:28 +00:00
2011-08-09 21:03:28 +00:00
if ( $Host === '' ) {
2013-05-02 08:00:23 +00:00
trigger_error ( 'Tools::get_host_by_ajax() command failed with no output, ensure that the host command exists on your system and accepts the argument -W' );
2011-08-09 21:03:28 +00:00
} elseif ( $Host === false ) {
print 'Could not retrieve host.' ;
2011-03-28 14:21:28 +00:00
} else {
2011-08-09 21:03:28 +00:00
print $Host ;
2011-03-28 14:21:28 +00:00
}