-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.php
More file actions
116 lines (108 loc) · 4.88 KB
/
index.php
File metadata and controls
116 lines (108 loc) · 4.88 KB
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
<?php
// Set the below variables:
$lg_location = "🇺🇸 Liberty Lake, WA"; // Where is this looking glass install located?
$lg_ipv4 = "23.184.48.25"; // IPv4 address of your looking glass server
$lg_ipv6 = "2602:fc24:18:a5d8::1"; // IPv6 address of your looking glass server
$logo = "logo.svg"; // Logo or image to display above your other locations
$description = ""; // Add a description for the meta tags (Ex: Kansas City, Missouri Network Speed test and Looking Glass)
// Get the IP / hostname of the website visitor
function getUserInfo() {
$ipAddress = $_SERVER['REMOTE_ADDR'];
$hostName = gethostbyaddr($ipAddress);
return [
'ip' => $ipAddress,
'hostname' => $hostName
];
}
$userInfo = getUserInfo();
// Probably a better way of doing an ISP check but it works. Will refine it later.
function getISP($ip) {
$result = shell_exec("whois {$ip}");
preg_match('/^OrgName: +(.+)$/m', $result, $matches);
return $matches[1] ?? 'Unknown ISP';
}
// Get the connecting user's IP address
$userIP = $_SERVER['REMOTE_ADDR'];
$isp = getISP($userIP);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="<?php echo ("$description");?>">
<meta name="author" content="IncogNET">
<meta name="robots" content="index, follow">
<link rel="preload" as="style" href="style.css">
<link rel="stylesheet" href="style.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<title><?php echo($lg_location)?> - Looking Glass</title>
<body>
<nav id="mainNav">
<h1>Network Looking Glass</h1>
</nav>
<div class="forms-container">
<div class="left-form">
<form id="lookupForm">
<div id="userInfo">
<b>Looking Glass Location:</b> <span><?php echo($lg_location)?></span><br>
<b>Looking Glass IPv4:</b> <span><?php echo($lg_ipv4)?></span><br>
<b>Looking Glass IPv6:</b> <span><?php echo($lg_ipv6)?></span><br>
<hr>
<b>Your IP Address:</b> <span><?= $userInfo['ip'] ?></span><br>
<b>Your Hostname:</b> <span><?= $userInfo['hostname'] ?></span><br>
<b>Your ISP:</b> <span><?php echo($isp)?></span>
<hr>
</div>
IPv4 / IPv6 Address or Hostname: <input type="text" name="ip" required>
Run Command:
<select name="command">
<option value="ping">Ping</option>
<option value="ping6">Ping6</option>
<option value="traceroute">Traceroute</option>
<option value="traceroute6">Traceroute6</option>
<option value="mtr">MTR</option>
<option value="mtr6">MTR6</option>
</select>
<input type="submit" value="Proceed">
</form>
</div>
<div class="center-results">
<div id="loadingMessage" style="display: none;"><h2>Running test, please wait...<br>(This may take a moment)</h2></div>
<div id="results"></div>
</div>
<div class="right-form">
<form id="lookupForm">
<div id="userInfo">
<center>
<img src="<?php echo($logo)?>" width="313" height="63"><br>
<h4>Want to test from one of our other locations?</h4>
<hr>
<span>🇺🇸 Liberty Lake, WA</span> | <span>🇺🇸 Kansas City, MO</span><br>
<span>🇺🇸 Allentown, PA</span> | <span>🇺🇸 Miami, FL</span><br>
<span>🇺🇸 Las Vegas, NV</span> | <span>🇺🇸 New York, NY</span><br>
<span>🇳🇱 Naaldwijk, NL</span> | <span>🇱🇺 Roost, Bissen, LU</span>
<hr>
<small>The above links are for demonstration purposes only.<br><br>© <?php echo date("Y"); ?> <a href="https://incognet.io" target="_blank">IncogNET LLC</a> | <a href="https://github.com/Incognify/php-lg/" target="_blank">GitHub</a> | <a href="https://twitter.com/IncogNETLLC" target="_blank">Twitter</a> | <a href="https://bgp.tools/as/210630" target="_blank">BGP.TOOLS</a> | v1.3</small></center>
</div>
</form>
</div>
</div>
<script>
$('#lookupForm').submit(function(e) {
e.preventDefault();
// Show the loading message
$('#loadingMessage').show();
$.post('result.php', $(this).serialize(), function(data) {
$('#results').html(data);
// Hide the loading message
$('#loadingMessage').hide();
}).fail(function() {
$('#results').html('<pre><code>Error fetching the results. Please try again later.</code></pre>');
// Hide the loading message
$('#loadingMessage').hide();
});
});
</script>
</body>
</html>