diff options
| author | root | 2015-04-01 23:53:58 +0200 |
|---|---|---|
| committer | root | 2015-04-01 23:53:58 +0200 |
| commit | a31396fb8c67f27a0055e4c4a6fa95e3cde24d1a (patch) | |
| tree | 8e5f72013ffe1fda6ab64514a79943f83d841e51 /ip/ifconfig.php | |
| parent | 6ec371bff3d3eda0c535fe773c292f66bd746a7a (diff) | |
| download | tools.iamfabulous.de-a31396fb8c67f27a0055e4c4a6fa95e3cde24d1a.tar.gz | |
Small improvements.
Diffstat (limited to 'ip/ifconfig.php')
| -rw-r--r-- | ip/ifconfig.php | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/ip/ifconfig.php b/ip/ifconfig.php new file mode 100644 index 0000000..33ec5ba --- /dev/null +++ b/ip/ifconfig.php @@ -0,0 +1,60 @@ +<?php + +class Ifconfig { + + public $ip; + + public function __construct($ip){ + $this->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(){ + + $tmp = geoip_record_by_name( $this->ip ); + if( $tmp ){ + unset($tmp['dma_code']); + unset($tmp['area_code']); + } else { + $tmp = array ( "status" => "Data not available"); + } + + return $tmp; + } + + public function encodeJson($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; + } +} |
