blob: 83e03ed2bb328620832a6bc935e1c9cc23748515 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
<?php
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'libcurl') ){
if ( empty($_GET) ){
echo $_SERVER["REMOTE_ADDR"];
exit;
} else {
// avoid redirect
$_GET["curl"] = true;
}
}
if ( empty($_GET) ){
header($_SERVER["SERVER_PROTOCOL"] . " 302 Moved");
header("Location: http://".$_SERVER["HTTP_HOST"].str_replace("/index.php", "", $_SERVER["PHP_SELF"] )."/?ip=".$_SERVER["REMOTE_ADDR"]."&geoip=1&header=1&output=html");
exit;
}
if ( ! isset($_GET["ip"]) || $_GET["ip"] == "" ){
$ip = $_SERVER["REMOTE_ADDR"];
} else {
if( preg_match("/([0-9]+\.){3}[0-9]+/", $_GET["ip"]) ){
$ip = $_GET["ip"];
} else {
$ip = gethostbyname($_GET["ip"]);
}
}
require 'ifconfig.php';
$if = new Ifconfig($ip);
$result = array("ip" => $ip, "hostname" => $if->getReverseDNS());
if( isset($_GET["geoip"]) && $_GET["geoip"] != 0){
$geoip = $result = array_merge($result, $if->getAllGeoipRecords());
}
if( isset($_GET["header"]) && $_GET["header"] != 0){
$header = $if->getHeader();
$result = array_merge($result, $header);
}
if( ! isset($_GET["output"]) || $_GET["output"] == "" ){
$_GET["output"] = "html";
}
switch($_GET["output"]){
case("json"):
header("Content-Type: application/json");
echo $if->encodeJson($result);
break;
case("html"):
require 'template.php';
break;
case("php"):
header("Content-Type: text/plain");
echo serialize($result);
break;
default:
require 'template.php';
break;
}
|