-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
247 lines (239 loc) · 10.6 KB
/
index.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<?php
include 'config.php';
$browscap = get_browser(null, true);
$browscap_translation = [
'device_type' => [
'Console' => 'Konsole',
'TV Device' => 'TV Gerät',
'Tablet' => 'Tablet',
'Mobile Phone' => 'Smartphone',
'Mobile Device' => 'Mobiles Gerät',
'Desktop' => 'Desktop',
'Ebook Reader' => 'E-Book Reader',
'Car Entertainment System' => 'Autoradio',
'Digital Camera' => 'Digitalkamera'
]
];
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
if($lang != 'de'){
$lang = 'en';
}
if($lang == substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2)){
$language_string = locale_get_display_language(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2), substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2));
}
else{
$language_string = locale_get_display_language(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2), substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2))." (".locale_get_display_language(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2), $lang).")";
}
if(strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'curl')!==false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'httpie')!==false){
print("ip: ".$_SERVER['REMOTE_ADDR']."\n");
if($_SERVER['REMOTE_ADDR'] != gethostbyaddr($_SERVER['REMOTE_ADDR'])){
print("hostname: ".gethostbyaddr($_SERVER['REMOTE_ADDR'])."\n");
}
print('network: '.(String)getenv('MM_ASN_DB_NETWORK')."\n");
if((String)getenv('MM_ASN') != ''){
print('asn: '.(String)getenv('MM_ASN')."\n");
}
$a = shell_exec('/var/www/p0f/p0f-client /var/run/p0f.sock '.$_SERVER['REMOTE_ADDR']);
$b = explode("\n", trim($a));
$data = Array();
foreach($b as $current){
$current_array = explode('=', $current);
$data[trim($current_array[0])] = trim($current_array[1]);
}
$isp = '';
if((String)getenv('MM_AS_ORG') != ''){
$isp = $isp.(String)getenv('MM_AS_ORG');
}
if((String)getenv('MM_CITY_NAME') != ''){
if($isp != ''){
$isp = $isp.', ';
}
$isp = $isp.(String)getenv('MM_CITY_NAME');
}
if((String)getenv('MM_COUNTRY_CODE_CITY_DB') != ''){
if($isp != ''){
$isp = $isp.', ';
}
$isp = $isp.locale_get_display_region('-'.(String)getenv('MM_COUNTRY_CODE_CITY_DB'), $lang);
}
if($isp != ''){
print('isp: '.$isp."\n");
}
if($data['MTU'] != ''){
print('mtu: '.$data['MTU']."\n");
}
if($data['MTU'] != ''){
print('hop-distance: '.$data['Distance']."\n");
}
}
else {
?>
<!doctype html>
<html lang="<?php print($lang); ?>">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="style.css">
<script src="jquery/jquery-3.5.0.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="script.js"></script>
<title>IP Test</title>
</head>
<body>
<div class="container mb-4">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12">
<div class="card mt-4">
<div class="card-header text-center">
<h4 class="my-0"><?php print($_SERVER['HTTP_HOST']); ?></h4>
</div>
<div class="card-body">
<table class="table table-striped">
<tbody>
<tr>
<th scope="row"><?php print(($lang == 'de')?('Verbindung über'):('Connection via')); ?>:</th>
<td id="content-ip-version"><?php if(strpos($_SERVER['REMOTE_ADDR'], ":")){print('IPv6');} else{print('IPv4');} ?></td>
</tr>
<tr>
<th scope="row">DNS-Server:</th>
<td id="content-dns"><img src="loader.gif" width="16" height="16" id="loader-dns"></td>
</tr>
<tr>
<th scope="row">EDNS-Subnetz:</th>
<td id="content-edns"><img src="loader.gif" width="16" height="16" id="loader-dns"></td>
</tr>
<tr>
<th scope="row">User-Agent:</th>
<td id="content-user-agent"><small><?php print($_SERVER['HTTP_USER_AGENT']); ?></small></td>
</tr>
<tr>
<th scope="row"><?php print(($lang == 'de')?('Geräte-Typ'):('Device type')); ?>:</th>
<td id="content-device-type"><?php print(($lang == 'de')?($browscap_translation['device_type'][$browscap['device_type']]):($browscap['device_type'])); ?></td>
</tr>
<tr>
<th scope="row"><?php print(($lang == 'de')?('Betriebssystem'):('Operating system')); ?>:</th>
<td id="content-os"><?php print($browscap['platform']); ?></td>
</tr>
<tr>
<th scope="row">Browser:</th>
<td id="content-browser"><?php print($browscap['browser']); ?></td>
</tr>
<tr>
<th scope="row"><?php print(($lang == 'de')?('Sprache'):('Language')); ?>:</th>
<td id="content-language"><?php print($language_string); ?></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="card mt-4">
<div class="card-header">
<h4 class="my-0">IPv4</h4>
</div>
<div class="card-body">
<table class="table table-striped">
<tbody>
<tr>
<th scope="row">IP:</th>
<td id="content-ipv4-ip"><img src="loader.gif" width="16" height="16" id="loader-ipv4-ip"></td>
</tr>
<tr>
<th scope="row">Hostname:</th>
<td id="content-ipv4-hostname"><img src="loader.gif" width="16" height="16" id="loader-ipv4-hostname"></td>
</tr>
<tr>
<th scope="row">MTU:</th>
<td id="content-ipv4-mtu"><img src="loader.gif" width="16" height="16" id="loader-ipv4-mtu"></td>
</tr>
<tr>
<th scope="row"><?php print(($lang == 'de')?('Anschluss-Typ'):('Connection type')); ?>:</th>
<td id="content-ipv4-link-type"><img src="loader.gif" width="16" height="16" id="loader-ipv4-link-type"></td>
</tr>
<tr>
<th scope="row"><?php print(($lang == 'de')?('Hop-Distanz'):('Hop distance')); ?>:</th>
<td id="content-ipv4-distance"><img src="loader.gif" width="16" height="16" id="loader-ipv4-distance"></td>
</tr>
<tr>
<th scope="row"><?php print(($lang == 'de')?('IP-Netz'):('IP network')); ?>:</th>
<td id="content-ipv4-ip-network"><img src="loader.gif" width="16" height="16" id="loader-ipv4-ip-network"></td>
</tr>
<tr>
<th scope="row">ISP:</th>
<td id="content-ipv4-isp"><img src="loader.gif" width="16" height="16" id="loader-ipv4-isp"></td>
</tr>
<tr>
<th scope="row">AS:</th>
<td id="content-ipv4-as"><img src="loader.gif" width="16" height="16" id="loader-ipv4-as"></td>
</tr>
</tbody>
</table>
<div id="map-ipv4">
</div>
</div>
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="card mt-4">
<div class="card-header">
<h4 class="my-0">IPv6</h4>
</div>
<div class="card-body">
<table class="table table-striped">
<tbody>
<tr>
<th scope="row">IP:</th>
<td id="content-ipv6-ip"><img src="loader.gif" width="16" height="16" id="loader-ipv6-ip"></td>
</tr>
<tr>
<th scope="row">Hostname:</th>
<td id="content-ipv6-hostname"><img src="loader.gif" width="16" height="16" id="loader-ipv6-hostname"></td>
</tr>
<tr>
<th scope="row">MTU:</th>
<td id="content-ipv6-mtu"><img src="loader.gif" width="16" height="16" id="loader-ipv6-mtu"></td>
</tr>
<tr>
<th scope="row"><?php print(($lang == 'de')?('Anschluss-Typ'):('Connection type')); ?>:</th>
<td id="content-ipv6-link-type"><img src="loader.gif" width="16" height="16" id="loader-ipv6-link-type"></td>
</tr>
<tr>
<th scope="row"><?php print(($lang == 'de')?('Hop-Distanz'):('Hop distance')); ?>:</th>
<td id="content-ipv6-distance"><img src="loader.gif" width="16" height="16" id="loader-ipv6-distance"></td>
</tr>
<tr>
<th scope="row"><?php print(($lang == 'de')?('IP-Netz'):('IP network')); ?>:</th>
<td id="content-ipv6-ip-network"><img src="loader.gif" width="16" height="16" id="loader-ipv6-ip-network"></td>
</tr>
<tr>
<th scope="row">ISP:</th>
<td id="content-ipv6-isp"><img src="loader.gif" width="16" height="16" id="loader-ipv6-isp"></td>
</tr>
<tr>
<th scope="row">AS:</th>
<td id="content-ipv6-as"><img src="loader.gif" width="16" height="16" id="loader-ipv6-as"></td>
</tr>
</tbody>
</table>
<div id="map-ipv6">
</div>
</div>
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-12">
<div class="card mt-4">
<div class="card-header card-header-no-border text-center">
© Sebastian Hegge · <a href="https://heg.ge/impressum" target="_blank"><?php print(($lang == 'de')?('Impressum & Datenschutz'):('Imprint & Privacy policy')); ?></a> · <a href="https://github.com/sebastianhegge/iptest" target="_blank"><?php print(($lang == 'de')?('Quellcode auf GitHub'):('Source on GitHub')); ?></a> · v3.1
</div>
</div>
</div>
</div>
</div>
<script src="https://maps.googleapis.com/maps/api/js?key=<?php print(GOOGLE_MAPS_API_KEY); ?>"></script>
</body>
</html>
<?php
}
?>