Skip to content

Commit

Permalink
display time left unban
Browse files Browse the repository at this point in the history
  • Loading branch information
judemont committed May 19, 2024
1 parent 4d8b874 commit 8b92861
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
8 changes: 5 additions & 3 deletions api/isBanned.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
$bannRecords = $db->select("SELECT * FROM cescoleaks_bann WHERE IP = '$hashedIp'");

if (count($bannRecords) >= 1) {
if ($bannRecords[0]["end_date"] <= time()) {
$db->query("DELETE FROM cescoleaks_bann WHERE IP = '$hashedIp'");
// echo time();
// echo $bannRecords[0]["end_time"];
if ($bannRecords[0]["end_time"] <= time()) {
// $db->query("DELETE FROM cescoleaks_bann WHERE IP = '$hashedIp'");
echo json_encode(array(
"banned" => false,
"ip" => $hashedIp,
Expand All @@ -25,7 +27,7 @@
}
echo json_encode(array(
"banned" => true,
"end_date" => (int)$bannRecords[0]["end_date"],
"end_date" => (int)$bannRecords[0]["end_time"],
"ip" => $bannRecords[0]["IP"],
));
} else {
Expand Down
19 changes: 14 additions & 5 deletions scripts/bannedPage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
getBann().then((result) => {
console.log(result);
let unbannTime = (result.end_date - Math.floor(Date.now() / 1000)) * 1;
document.getElementById(
"bannedTime"
).innerText = `Vous allez être réintégré dans ${unbannTime / 3600} heurs`;
setInterval(() => {
let unbannTime = (result.end_date - Math.floor(Date.now() / 1000)) * 1;
let hours = unbannTime / 3600;
let minutes = (hours - Math.floor(hours)) * 60;
let seconds = (minutes - Math.floor(minutes)) * 60;

document.getElementById(
"bannedTime"
).innerText = `Vous allez être réintégré dans ${Math.floor(
hours
)} heurs, ${Math.floor(minutes)} minutes et ${Math.floor(
seconds
)} secondes`;
}, 500);
});

0 comments on commit 8b92861

Please sign in to comment.