-
Notifications
You must be signed in to change notification settings - Fork 2
/
delete.php
75 lines (55 loc) · 1.89 KB
/
delete.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hanover High School - Delete Page</title>
<!-- Everything in the <head> except for <title> : Also contains the navbar-->
<?php
require_once("opendb.php");
$response = strtolower($connection->escape_string($_POST["response"]));
$status = loginStatus();
$refer = strToLower($connection->escape_string(basename($_SERVER["HTTP_REFERER"])));
$page = $_POST["name"];
if (!($status & $LoginStatusCanEdit)) {
header("Location: nope.php");
die();
}
require("head.php");
?>
<!-- Start main container -->
<div id="container" class="container">
<!-- Main hero unit -->
<div class="hero-unit" id="hero-unit">
<?php
if ($page != "") {
$page = basename($page, ".php");
$query = "SELECT * FROM `special_pages` WHERE `name` = '$page'";
$result = $connection->query($query);
$page = "$page.php";
if ($result->num_rows) die("Cannot delete reserved page \"$page\"");
if (file_exists($page)) {
unlink($page);
echo "Deleted <b>".$page."</b><br><br>";
} else {
echo "File <b>".$page."</b> does not exist.<br><br>";
}
$page = basename($page, ".php");
$query = "DROP TABLE `$page-index`;";
$connection->query($query) or die("The table <b>".$page."-index</b> does not exist");
echo "Deleted table <b>".$page."-index</b>";
} else {
if ($refer == "dev.hanoverhs.org") {
} elseif ($refer == "") {
echo "Enter the page you wish to delete below<br><br>";
} elseif ($refer != "") {
echo "To delete the page you were just viewing, enter <b>".$refer."</b> below.<br><br>";
}
echo "<form method=\"POST\" action=\"delete.php\">";
echo "<label for=\"name\">File Name:</label><input type=\"text\" name=\"name\" maxlength=\"1024\"><br>";
echo "<input type=\"submit\" value=\"Delete Page\">";
echo "</form>";
}
?>
</div>
<div class="row">
</div>
<?php require("foot.php"); ?>