-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.php
144 lines (143 loc) · 5.7 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
<?php
require_once 'html/config.php';
if (file_exists("query/cron/cache/minecraft.php")) {
include 'query/cron/cache/minecraft.php';
}
require "html/tailcustom.php";
require "functions.php";
if (!isset($install)) {
header("Location: html/install.php");
}
session_start();
session_write_close();
$username = $_SESSION['username'] ?? "public";
$conn = mysqli_connect($DB_SERVER, $DB_USERNAME, $DB_PASSWORD, $DB_NAME);
$sql = "SELECT server, sprite, seed FROM users WHERE username='$username'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$serverjson = $row['server'];
$sprite = $row['sprite'];
$seed = $row['seed'];
}
}
if ($username == "admin") {
$seed = "d";
$sprite = "bottts";
}
?>
<!doctype html>
<html lang="<?php
echo $lang ?>">
<?php
include('html/head.php') ?>
<body onload="callLoadData()">
<?php
include('html/nav.php'); ?>
<div id="login-popup">
<div id="lpopb" onclick="exitpopuplogin()" style="z-index:5"></div>
<div class="centerdiv">
<div class="padding15">
<form method="post" action="users/login.php" style="margin:0">
<label for="username">Username:</label><input id="username" class="input" name="username" type="text" minlength="4" maxlength="15" placeholder="xxxxx" autocomplete="off" required="required">
<label for="password">Password:</label><input id="password" class="input" name="password" type="password" minlength="8" placeholder="xxxxxxxxxxxx" autocomplete="off" required="required">
<div style="display:flex;justify-content: flex-end;-webkit-align-items: center;align-items: center;">
<?php
session_start();
if (!empty($_SESSION['error'])) {
$error = $_SESSION['error'];
}
if (isset($_GET['login'])) {
echo "<style>#login-popup{display:flex};</style>";
}
if (isset($error['specialuser'])){echo $error['specialuser'];}elseif (isset($error['nomatch'])){echo $error['nomatch'];}else {echo "<a class='button white-hover' href='users/register.php'>Register</a>";}
unset($_SESSION['error']);
?>
<input class="button" type="submit" name="login" value="Submit">
</div>
</form>
</div>
</div>
</div>
<div class="container">
<table class="server_list_table">
<tbody>
<tr class="server_list_table_top">
<th class="status_cell">
<?php echo $language[$lang][6] ?>
</th>
<th class="connectlink_cell">
<?php echo $language[$lang][7] ?>
</th>
<th class="servername_cell">
<?php echo $language[$lang][8] ?>
</th>
<th class="players_cell">
<?php echo $language[$lang][4] ?>
</th>
<th class="img-cell">
<div></div>
</th>
</tr>
</tbody>
</table>
<?php
$sql = "SELECT server FROM users WHERE username='$username'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$serverjson = json_decode($row["server"]);
}
} else {
echo "Query failed! Talk to your server administrator.";
}
$idimp = implode(',', $serverjson);
// Get server information from database
$sql = "SELECT ID, type FROM serverconfig WHERE ID IN ({$idimp})";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
$ID = $row['ID'];
$typearr[$ID] = $row['type'];
}
}
if (isset($serverjson)) {
foreach ($serverjson as $ServerID) {
if (!$ServerID) {
continue;
}
$type = $typearr[$ServerID];
$sidscript[] = $ServerID;
require 'server.php';
}
$conn->close();
}
if ($username == "public") {
echo "<div class='white-inftext'>" . $language[$lang][9] . "</div>";
}
?>
<p class="countdown"><?php echo $language[$lang][13]?> <span id="countdown"></span>s.</p>
<div style="padding-bottom: 15px;"><button class="countdownbtn" type="button" onclick="callLoadData()">Refresh Servers</button></div>
<script>
function callLoadData() {
if (typeof downloadTimer !== 'undefined') {
clearInterval(downloadTimer);
}
countdown(30);
let serverid = JSON.parse('<?php echo json_encode($sidscript);?>');
for (const value in serverid) {
let modlink = `${serverid[value]}`;
LoadData(modlink);
}
}
function popuplogin() {
document.getElementById("login-popup").style.display = "flex";
}
function exitpopuplogin() {
document.getElementById("login-popup").style.display = "none";
}
</script>
<script src="html/reload.js"></script>
</div>
</body>
</html>