-
Notifications
You must be signed in to change notification settings - Fork 3
/
ip.php
157 lines (142 loc) · 5.54 KB
/
ip.php
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
error_reporting(E_ERROR | E_PARSE);
function get_client_ip()
{
$ipaddress = '';
if (isset($_SERVER['HTTP_CLIENT_IP'])) {
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
} else if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else if (isset($_SERVER['HTTP_X_FORWARDED'])) {
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
} else if (isset($_SERVER['HTTP_FORWARDED_FOR'])) {
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
} else if (isset($_SERVER['HTTP_FORWARDED'])) {
$ipaddress = $_SERVER['HTTP_FORWARDED'];
} else if (isset($_SERVER['REMOTE_ADDR'])) {
$ipaddress = $_SERVER['REMOTE_ADDR'];
} else {
$ipaddress = 'UNKNOWN';
}
return $ipaddress;
}
$user_agent = $_SERVER['HTTP_USER_AGENT'];
function getOS() {
global $user_agent;
$os_platform = "OS desconocido";
$os_array = array(
'/windows nt 10/i' => 'Windows 10',
'/windows nt 6.3/i' => 'Windows 8.1',
'/windows nt 6.2/i' => 'Windows 8',
'/windows nt 6.1/i' => 'Windows 7',
'/windows nt 6.0/i' => 'Windows Vista',
'/windows nt 5.2/i' => 'Windows Server 2003/XP x64',
'/windows nt 5.1/i' => 'Windows XP',
'/windows xp/i' => 'Windows XP',
'/windows nt 5.0/i' => 'Windows 2000',
'/windows me/i' => 'Windows ME',
'/win98/i' => 'Windows 98',
'/win95/i' => 'Windows 95',
'/win16/i' => 'Windows 3.11',
'/macintosh|mac os x/i' => 'Mac OS X',
'/mac_powerpc/i' => 'Mac OS 9',
'/linux/i' => 'Linux',
'/ubuntu/i' => 'Ubuntu',
'/iphone/i' => 'iPhone',
'/ipod/i' => 'iPod',
'/ipad/i' => 'iPad',
'/android/i' => 'Android',
'/blackberry/i' => 'BlackBerry',
'/webos/i' => 'Mobile'
);
foreach ($os_array as $regex => $value)
if (preg_match($regex, $user_agent))
$os_platform = $value;
return $os_platform;
}
function getBrowser() {
global $user_agent;
$browser = "Navegador desconocido";
$browser_array = array(
'/msie/i' => 'Internet Explorer',
'/firefox/i' => 'Firefox',
'/safari/i' => 'Safari',
'/chrome/i' => 'Chrome',
'/edge/i' => 'Edge',
'/opera/i' => 'Opera',
'/netscape/i' => 'Netscape',
'/maxthon/i' => 'Maxthon',
'/konqueror/i' => 'Konqueror',
'/mobile/i' => 'Handheld Browser'
);
foreach ($browser_array as $regex => $value)
if (preg_match($regex, $user_agent))
$browser = $value;
return $browser;
}
$user_os = getOS();
$user_browser = getBrowser();
$PublicIP = get_client_ip();
$localHost = "127.0.0.1";
if (strpos($PublicIP, ',') !== false) {
$PublicIP = explode(",", $PublicIP)[0];
}
$file = 'ip.txt';
$ip = "IP : ".$PublicIP;
$uaget = "User Agent : ".$user_agent;
$bsr = "Navegador : ".$user_browser;
$uos = "OS : ".$user_os;
$ust= explode(" ", $user_agent);
$vr= $ust[3];
$ver=str_replace(")", "", $vr);
$version = "Version : ".$ver;
if (strpos($PublicIP, $localHost) !== false) {
$details = '{
"success": false
}';
}
else {
$details = file_get_contents("http://ipwhois.app/json/$PublicIP");
}
$details = json_decode($details, true);
$success = $details['success'];
$fp = fopen($file, 'a');
if ($success==false) {
fwrite($fp, $ip."\n");
fwrite($fp, $uos."\n");
fwrite($fp, $version."\n");
fwrite($fp, $bsr."\n");
fclose($fp);
} else if ($success==true) {
$country = $details['country'];
$city = $details['city'];
$continent= $details['continent'];
$tp = $details['type'];
$cn = $details['country_phone'];
$is = $details['isp'];
$latitude = $details['latitude'];
$longitude= $details['longitude'];
$crn = $details['currency'];
$type = "Tipo de IP : ".$tp;
$comma = ", ";
$location = "Ubicacion : ".$city.$comma.$country.$comma.$continent;
$geolocation= "Geoubicacion(lat, lon): ".$latitude.$comma.$longitude;
$isp = "ISP : ".$is;
$currency = "Moneda : ".$crn;
fwrite($fp, $ip."\n");
fwrite($fp, $type."\n");
fwrite($fp, $uos."\n");
fwrite($fp, $uaget."\n");
fwrite($fp, $version."\n");
fwrite($fp, $bsr."\n");
fwrite($fp, $location."\n");
fwrite($fp, $geolocation."\n");
fwrite($fp, $currency."\n");
fclose($fp);
} else {
$status = "Status : ".$success;
fwrite($fp, $status."\n");
fwrite($fp, $uaget."\n");
fclose($fp);
}
?>