Import source
This commit is contained in:
parent
b397f4ab19
commit
cbccd71059
2 changed files with 28 additions and 0 deletions
8
.htaccess
Normal file
8
.htaccess
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
<IfModule mod_rewrite.c>
|
||||||
|
RewriteEngine On
|
||||||
|
RewriteBase /
|
||||||
|
RewriteRule ^$ echoip.php [L]
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteRule (.*) echoip.php?cmd=$1 [L]
|
||||||
|
</IfModule>
|
||||||
20
echoip.php
Normal file
20
echoip.php
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
ini_set('default_charset', 'iso-8859-1');
|
||||||
|
header('Content-Type: text/plain');
|
||||||
|
$ip = $_SERVER['REMOTE_ADDR'];
|
||||||
|
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
||||||
|
$cmd = isset($_GET['cmd']) ? $_GET['cmd'] : '';
|
||||||
|
if ($cmd === 'long') {
|
||||||
|
printf('%u', ip2long($ip));
|
||||||
|
}
|
||||||
|
elseif ($cmd === 'hostname') {
|
||||||
|
echo gethostbyaddr($ip);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo $ip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo $ip;
|
||||||
|
}
|
||||||
|
?>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue