-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.php
executable file
·168 lines (141 loc) · 5.5 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
<?php
include 'core/init.php';
include 'includes/overall/header.php';
if(servers_count() < 1) {
echo "<br />";
include 'includes/overall/footer.php';
die();
}
?>
<table class="table table-stripped" >
<thead>
<th></th>
<th></th>
<th>Server Informations</th>
<th>Name</th>
<th>Players</th>
<th>Map</th>
<th>Votes</th>
<th>Status</th>
</thead>
<tbody>
<?php
/* Pagination Settings */
$page = 1;
if(isset($_GET['page'])) { $page = $_GET['page']; }
$limitT = (($page * $settings['pagination']) - $settings['pagination']);
$pagination = $settings['pagination'];
/* Query options */
$offline_filter = $game_filter = $country_filter = $map_filter = "";
$order = "`votes` DESC";
if(isset($_GET['sort'])){
switch($_GET['sort']){
case "players" : $order = "`players` DESC"; break;
case "status" : $order = "`status` DESC"; break;
case "votes" : $order = "`votes` DESC"; break;
}
}
if($settings['show_offline_servers'] == '0') $offline_filter = "AND `status` = 1";
if(isset($_GET['country'])) {
$country = sanitize($_GET['country']);
$country_filter = "AND `country` = '{$country}'";
}
if(isset($_GET['map'])) {
$map = sanitize($_GET['map']);
$game_filter = "AND `map` = '{$map}'";
}
if(isset($_GET['game'])) {
$game = sanitize($_GET['game']);
$game_filter = "AND `game` = '{$game}'";
}
/* Ranking settings so it doesnt loses the count on the next page */
$rank = 1;
if($page > 1){
$rank = $page * $pagination - $pagination + 1;
}
/* Setting the maximum live queries to be made on page refresh, preventing long execution time errors and improving performance */
$max_live_queries = 1;
$query_nr = 1;
$result = $database->query("SELECT `id`, `user_id`, `ip`, `game`, `port`, `status`, `country`, `vip`, `name`, `votes`, `map`, `players`, `maxPlayers`, `cache_time` FROM `servers` WHERE `disabled` = '0' {$offline_filter} {$game_filter} {$country_filter} {$map_filter} ORDER BY `vip` DESC, {$order}, `cache_time` ASC LIMIT $limitT, $pagination");
while ($server_data = $result->fetch_array()) {
$server_id = $server_data['id'];
$info = new stdClass();
if($server_data['cache_time'] > time() - $settings['server_cache'] || $query_nr > $max_live_queries || $settings['disable_index_querying'] == 1){
$status = $server_data['status'];
if($status == 1){
$info->Map = $server_data['map'];
$info->PlayerCount = $server_data['players'];
$info->MaxPlayers = $server_data['maxPlayers'];
} elseif ($status == 0) {
$info->Map = "";
$info->PlayerCount = "";
$info->MaxPlayers = "";
}
} else {
try {
$Query = new LiveStats($server_data['ip'], $server_data['port']);
$info = $Query->GetServer();
}catch (LSError $e) {}
if(empty($e)){ $status = 1; } else { $status = 0; }
if($status == 1) {
$database->query("UPDATE `servers` SET `map` = '{$info->Map}', `players` = '{$info->PlayerCount}', `maxPlayers` = '{$info->MaxPlayers}' WHERE `id` = '$server_id'");
}
$database->query("UPDATE `servers` SET `cache_time` = unix_timestamp(), `status` = '$status' WHERE `id` = '$server_id'");
$query_nr++;
}
?>
<tr>
<td>
<?php if($server_data['vip'] == "1"){ ?>
<i class="icon-star"></i>
<?php } else { ?>
<span class="muted">#<?php echo $rank; ?></span>
<?php } ?>
</td>
<td>
<?php if($server_data['game'] !== "samp") echo '<a href="steam://connect/' . $server_data['ip'] . ':' . $server_data['port'] .'"><img src="includes/img/steam.png" alt="Connect" /></a>'; ?>
<?php if(file_exists("includes/game_icons/" . $server_data['game'] . ".gif")) echo "<img src='includes/game_icons/" . $server_data['game'] . ".gif' title='" . $server_data['game'] . "'/>"; ?>
<?php if($server_data['country'] !== 'XX') { ?><img src="includes/locations/<?php echo $server_data['country']; ?>.png" alt="country" title="<?php echo $server_data['country']; ?>"/><?php } ?>
</td>
<td>
<a href="server.php?id=<?php echo $server_data['id']; ?>" >
<?php
echo strtolower($server_data['ip']);
if($server_data['port'] !== "27015") echo ":" . $server_data['port'];
?>
</a>
</td>
</td>
<td><?php echo $server_data['name']; ?></td>
<td><?php if($status == 1){echo $info->PlayerCount . "/" . $info->MaxPlayers; } else { echo "server offline"; } ?></td>
<td><?php if($status == 1){echo $info->Map; } else { echo "server offline"; } ?></td>
<td><?php echo $server_data['votes']; ?></td>
<td>
<?php if($status == 1) echo "<span class='label label-success'>Online</span>"; else echo "<span class='label label-warning'>Offline</span>"; ?>
<?php if(logged_in() && is_admin($session_user_id)) { ?>
<a href="adm_servers_management.php?vip=<?php echo $server_id; ?>" title="VIP">
<span class="label label-info">
<i class="icon-star icon-white"></i>
</span>
</a>
<a href="adm_servers_management.php?status=<?php echo $server_id; ?>" title="Disable">
<span class="label label-important">
<i class="icon-off icon-white"></i>
</span>
</a>
<a href="adm_servers_management.php?delete=<?php echo $server_id; ?>" title="Delete">
<span class="label label-important">
<i class="icon-remove icon-white"></i>
</span>
</a>
<?php } ?>
</td>
</tr>
<?php $rank++;} ?>
</tbody>
</table>
<?php
include "pagination.php";
include 'includes/overall/footer.php';
?>