From aaef9981946924d5da7b244ee2c5bcd7167f6820 Mon Sep 17 00:00:00 2001 From: moehm Date: Mon, 17 Nov 2014 15:34:04 +0100 Subject: tool: ifconfig --- ifconfig/ifconfig.php | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 ifconfig/ifconfig.php (limited to 'ifconfig/ifconfig.php') diff --git a/ifconfig/ifconfig.php b/ifconfig/ifconfig.php new file mode 100644 index 0000000..215f0df --- /dev/null +++ b/ifconfig/ifconfig.php @@ -0,0 +1,51 @@ +ip=$ip; + } + + public function getHeader(){ + $headers = ''; + foreach ($_SERVER as $name => $value){ + if (substr($name, 0, 5) == 'HTTP_'){ + $headers[str_replace(' ', '-', ucwords( strtolower( str_replace( '_', ' ', substr( $name, 5) ) ) ) )] = $value; + } + } + return $headers; + } + + public function getAllGeoipRecords(){ + return geoip_record_by_name( $this->ip ); + } + + public function encodeInJson($value){ + + if( empty($value) || is_null($value) || $value == "" ) + return json_encode($output = array( "status" => "failure" )); + else + $output = array( "status" => "success" ); + + if ( ! is_array($value) ){ + $output[] = $value; + } else { + $output = array_merge($output, $value); + } + + return json_encode($output); + } + + public function getReverseDNS($ip = NULL){ + if ( is_null($ip) ) + $ip = $this->ip; + + return gethostbyaddr($ip); + } + + public function __destruct(){ + return true; + } +} -- cgit v1.2.3