Repository navigation
Expand file tree
/
Copy pathmap.php
More file actions
115 lines (101 loc) · 3.66 KB
/
Copy pathmap.php
File metadata and controls
115 lines (101 loc) · 3.66 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
<!DOCTYPE html>
<html>
<?php
require("incl/database.php")
?>
<head>
<title>Adammantium Multiplayer Server Map</title>
<link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon/favicon-16x16.png">
<link rel="manifest" href="/favicon/site.webmanifest">
<link rel="stylesheet" type="text/css" href="/css/style.css?version=5">
<!-- Leaflet CSS -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
crossorigin=""/>
<meta name="description" content="World map of Adammantium Multiplayer servers.">
</head>
<body>
<div class="title-bar">
<p class="title">Adammantium Multiplayer</p>
<nav class="title-nav" aria-label="Main">
<a href="index.php" class="title-link">Serverlist</a>
<a href="mod_compat.php" class="title-link">Mod Compatibility</a>
<a href="map.php" class="title-link active">Server Map</a>
</nav>
</div>
<div id="map" style="width: 100%; height: calc(100vh - 60px);"></div>
<!-- Leaflet JS -->
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
crossorigin=""></script>
<script src="/js/jquery-3.7.1.min.js"></script>
<script>
$(document).ready(function() {
// Initialize map
var map = L.map('map').setView([51.1657, 10.4515], 3); // Center on Germany
// Add tile layer
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
// Get server data
<?php
// For demonstration, add some sample servers with locations
$sampleServers = [
[
'servername' => '[US] Sample Server',
'latitude' => 37.0902,
'longitude' => -95.7129,
'current_lobbies' => 5,
'max_lobbies' => 10,
'last_update' => date('Y-m-d H:i:s', strtotime('-1 minute'))
],
[
'servername' => '[Canada] Sample Server',
'latitude' => 56.1304,
'longitude' => -106.3468,
'current_lobbies' => 3,
'max_lobbies' => 8,
'last_update' => date('Y-m-d H:i:s', strtotime('-10 minutes'))
],
[
'servername' => '[Germany] Sample Server',
'latitude' => 51.1657,
'longitude' => 10.4515,
'current_lobbies' => 7,
'max_lobbies' => 12,
'last_update' => date('Y-m-d H:i:s', strtotime('-2 minutes'))
]
];
// Get real servers from database
$result = executeQuery("select name, latitude, longitude, current_lobbies, max_lobbies from hostservers where enabled = 1 AND latitude IS NOT NULL AND longitude IS NOT NULL");
$allServers = $result; #array_merge($sampleServers, $result);
?>
var servers = <?php echo json_encode($allServers); ?>;
// Add markers
servers.forEach(function(server) {
var lat = parseFloat(server.latitude);
var lng = parseFloat(server.longitude);
var name = server.name;
var players = server.current_lobbies + '/' + server.max_lobbies;
var isOnline = server.max_lobbies > 0;
var color = isOnline ? 'green' : 'red';
var marker = L.circleMarker([lat, lng], {
color: color,
fillColor: color,
fillOpacity: 0.8,
radius: 8
}).addTo(map);
// Show player count on hover
marker.bindTooltip(name + '<br>Players: ' + players, {
permanent: false,
direction: 'top'
});
// Show server name and details on click
marker.bindPopup('<b>' + name + '</b><br>Players: ' + players);
});
});
</script>
</body>
</html>