blob: 33ec5baba7a605f5b8c6b78083c8adfe4147a1af (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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;
}
}
|