diff options
| author | moehm | 2014-11-17 15:34:04 +0100 |
|---|---|---|
| committer | moehm | 2014-11-17 15:34:04 +0100 |
| commit | aaef9981946924d5da7b244ee2c5bcd7167f6820 (patch) | |
| tree | 9c991e7bd077c6eaffc0ac04da6b578c456b04cd /ifconfig/index.php | |
| parent | f7755964e8703d66cee123a18519a07d49df0ae0 (diff) | |
| download | tools.iamfabulous.de-aaef9981946924d5da7b244ee2c5bcd7167f6820.tar.gz | |
tool: ifconfig
Diffstat (limited to 'ifconfig/index.php')
| -rw-r--r-- | ifconfig/index.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/ifconfig/index.php b/ifconfig/index.php new file mode 100644 index 0000000..ff30813 --- /dev/null +++ b/ifconfig/index.php @@ -0,0 +1,48 @@ +<?php + +if ( strpos($_SERVER['HTTP_USER_AGENT'], 'libcurl') === true ){ + echo $_SERVER["REMOTE_ADDR"]; + exit; +} + +if ( empty($_GET) ){ + header($_SERVER["SERVER_PROTOCOL"] . " 302 Moved"); + header("Location: http://".$_SERVER["HTTP_HOST"].$_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 { + $ip = $_GET["ip"]; +} + +require 'ifconfig.php'; + +$if = new Ifconfig($ip); + +$result = array("ip" => $ip, "hostname" => $if->getReverseDNS()); + +if( isset($_GET["geoip"]) && $_GET["geoip"] != 0){ + $result = array_merge($result, $if->getAllGeoipRecords()); +} + +if( isset($_GET["header"]) && $_GET["header"] != 0){ + $result = array_merge($result, $if->getHeader()); +} + +if( ! isset($_GET["output"]) || $_GET["output"] == "" ){ + $_GET["output"] = "html"; +} + +switch($_GET["output"]){ + case("json"): + echo $if->encodeJSON($result); + break; + case("html"): + require 'template.php'; + break; + default: + require 'template.php'; + break; +} |
