From 2b24f3ef0e800f878177973eefcb28380a292503 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 17 Nov 2014 20:10:50 +0100 Subject: ifconfig stable --- ifconfig/ifconfig.php | 7 +++- ifconfig/index.php | 31 +++++++++++---- ifconfig/template.php | 105 +++++++++++++++++++++++++++++++++++++++++++++++++- tools/footer.php | 2 +- tools/navbar.php | 2 +- tools/style.css | 6 +++ 6 files changed, 139 insertions(+), 14 deletions(-) diff --git a/ifconfig/ifconfig.php b/ifconfig/ifconfig.php index 215f0df..cf1dc8f 100644 --- a/ifconfig/ifconfig.php +++ b/ifconfig/ifconfig.php @@ -19,10 +19,13 @@ class Ifconfig { } public function getAllGeoipRecords(){ - return geoip_record_by_name( $this->ip ); + $tmp = geoip_record_by_name( $this->ip ); + unset($tmp['dma_code']); + unset($tmp['area_code']); + return $tmp; } - public function encodeInJson($value){ + public function encodeJson($value){ if( empty($value) || is_null($value) || $value == "" ) return json_encode($output = array( "status" => "failure" )); diff --git a/ifconfig/index.php b/ifconfig/index.php index ff30813..b87d316 100644 --- a/ifconfig/index.php +++ b/ifconfig/index.php @@ -1,20 +1,29 @@ $ip, "hostname" => $if->getReverseDNS()); if( isset($_GET["geoip"]) && $_GET["geoip"] != 0){ - $result = array_merge($result, $if->getAllGeoipRecords()); + $geoip = $result = array_merge($result, $if->getAllGeoipRecords()); } if( isset($_GET["header"]) && $_GET["header"] != 0){ - $result = array_merge($result, $if->getHeader()); + $header = $if->getHeader(); + $result = array_merge($result, $header); } if( ! isset($_GET["output"]) || $_GET["output"] == "" ){ @@ -37,11 +47,16 @@ if( ! isset($_GET["output"]) || $_GET["output"] == "" ){ switch($_GET["output"]){ case("json"): - echo $if->encodeJSON($result); + 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; diff --git a/ifconfig/template.php b/ifconfig/template.php index 2271887..50e9b74 100644 --- a/ifconfig/template.php +++ b/ifconfig/template.php @@ -17,13 +17,114 @@
+

Ifconfig

+

Basic IP API/Look up.

+
+ + +

IP API

+
+ $value){ + echo "
".str_replace('_', ' ', ucfirst($key))."
".$value."
"; + } + ?> +
+ +

HTTP Header

$value){ - echo "
".$key."
".$value."
"; + foreach($header as $key => $value){ + echo "
".$key."
".$value."
"; } ?>
+ + +
+
+ + + + + +
+ +
+ + +
+
+ + +
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+ + +
+ + + +Choose output format. +
+
+
+ + +
+ +
+ +
+
+ + + +
+
+
+ +

Command Line Interface:

+ + Get IP: $ curl http://tools.iamfabulous.de/ifconfig/ =>
+ JSON: $ curl http://tools.iamfabulous.de/ifconfig/?output=json
+ Get everything: $ curl http://tools.iamfabulous.de/ifconfig/?geoip=1&header=1&output=json + +
diff --git a/tools/footer.php b/tools/footer.php index fedea9f..ce072aa 100644 --- a/tools/footer.php +++ b/tools/footer.php @@ -23,5 +23,5 @@ return n; } - addClass("", "active"); + addClass("", "actives"); diff --git a/tools/navbar.php b/tools/navbar.php index d63bcb4..5546fc3 100644 --- a/tools/navbar.php +++ b/tools/navbar.php @@ -16,7 +16,7 @@ Header
  • - ifconfig + ifconfig
  • diff --git a/tools/style.css b/tools/style.css index 02249d3..b5aa321 100644 --- a/tools/style.css +++ b/tools/style.css @@ -60,3 +60,9 @@ a { .underline { text-decoration: underline; } + +.actives { + color: white !important; + text-decoration: underline; + font-weight: bold; +} -- cgit v1.2.3