Skip to content

Commit 9b078d1

Browse files
committed
Bug Fix: Admin couldn't add server to admin account if somebody added the server before
1 parent 4a343ab commit 9b078d1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

users/control/server.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,15 @@ function deleteserver($id, $arrayresult) {
246246
if (mysqli_num_rows($result) > 0) {
247247
while ($row = mysqli_fetch_assoc($result)) {
248248
$addid = $row['ID'];
249+
$alreadyindb = TRUE;
249250
}
250251
} else {
251252
$sql = "SELECT ID FROM serverconfig ORDER BY ID DESC LIMIT 1";
252253
$result = mysqli_query($conn, $sql);
253254
if (mysqli_num_rows($result) > 0) {
254255
while ($row = mysqli_fetch_assoc($result)) {
255256
$addid = $row["ID"] + 1;
257+
$alreadyindb = False;
256258
}
257259
}
258260
}
@@ -280,11 +282,13 @@ function deleteserver($id, $arrayresult) {
280282
echo "Error updating record: " . mysqli_error($conn);
281283
}
282284
}
283-
$sql = "INSERT INTO serverconfig (ID, IP, type, QueryPort, GamePort, RconPort, Name, controlserver) VALUES ('$addid', '$addip', '$addtype', '$addqport', '$addgport', '$addrport', '0', '[\"admin\"]')";// Add server data to serverconfig table
284-
if (mysqli_query($conn, $sql)) {
285-
echo "<script>console.log('Record updated successfully')</script>";
286-
} else {
287-
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
285+
if (!$alreadyindb) {
286+
$sql = "INSERT INTO serverconfig (ID, IP, type, QueryPort, GamePort, RconPort, Name, controlserver) VALUES ('$addid', '$addip', '$addtype', '$addqport', '$addgport', '$addrport', '0', '[\"admin\"]')";// Add server data to serverconfig table
287+
if (mysqli_query($conn, $sql)) {
288+
echo "<script>console.log('Record updated successfully')</script>";
289+
} else {
290+
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
291+
}
288292
}
289293
$conn->close();
290294
}

0 commit comments

Comments
 (0)