-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathCloseGame.php
51 lines (41 loc) · 1.03 KB
/
CloseGame.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
<?php
include "./Libraries/HTTPLibraries.php";
include_once './includes/functions.inc.php';
include_once "./includes/dbh.inc.php";
include "Libraries/SHMOPLibraries.php";
session_start();
if (!isset($_SESSION["useruid"])) {
echo ("Please login to view this page.");
exit;
}
$useruid = $_SESSION["useruid"];
if ($useruid != "OotTheMonk" && $useruid != "love" && $useruid != "ninin" && $useruid != "Brubraz") {
echo ("You must log in to use this page.");
exit;
}
$gameToken = TryGET("gameToClose", "");
$folder = "./Games/" . $gameToken;
deleteDirectory($folder);
DeleteCache($gameToken);
header("Location: ./zzModPage.php");
function deleteDirectory($dir)
{
if (!file_exists($dir)) {
return true;
}
if (!is_dir($dir)) {
$handler = fopen($dir, "w");
fwrite($handler, "");
fclose($handler);
return unlink($dir);
}
foreach (scandir($dir) as $item) {
if ($item == '.' || $item == '..') {
continue;
}
if (!deleteDirectory($dir . "/" . $item)) {
return false;
}
}
return rmdir($dir);
}