summaryrefslogtreecommitdiff
path: root/ifconfig/ifconfig.php
diff options
context:
space:
mode:
Diffstat (limited to 'ifconfig/ifconfig.php')
-rw-r--r--ifconfig/ifconfig.php51
1 files changed, 51 insertions, 0 deletions
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 @@
+<?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(){
+ 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;
+ }
+}