-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset.php
76 lines (76 loc) · 2.38 KB
/
reset.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Blog | Reset</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
</head>
<body class="bg-dark">
<div class="container-fluid row align-items-center sticky-top bg-dark">
<div class="col-6 text-left text-primary">
<h1>Blog</h1>
</div>
<div class="col-6 text-right text-primary">
<h2>Reset Page</h2>
</div>
</div>
<?php
include 'php/connect.php';
try
{
$sql = "DROP DATABASE $db";
if ($conn->query($sql) === TRUE)
{
echo "<div class='alert alert-success alert-dismissible fade show text-center'>Database has been deleted successfully.<button type='button' class='close' data-dismiss='alert'>×</button></div>";
}
}
catch (mysqli_sql_exception $e)
{
echo "<div class='alert alert-info alert-dismissible fade show text-center'>Database does not exist.<button type='button' class='close' data-dismiss='alert'>×</button></div>";
}
$conn->close();
$file = 'misc/counter.txt';
if (file_exists($file))
{
if (unlink($file))
{
echo "<div class='alert alert-success alert-dismissible fade show text-center'>Associated file has been deleted successfully.<button type='button' class='close' data-dismiss='alert'>×</button></div>";
}
else
{
echo "Error deleting file.";
}
}
else
{
echo "<div class='alert alert-info alert-dismissible fade show text-center'>Associated file does not exist.<button type='button' class='close' data-dismiss='alert'>×</button></div>";
}
function deleteFolder($folderPath)
{
if (is_dir($folderPath))
{
$files = array_diff(scandir($folderPath), array('.', '..'));
foreach ($files as $file) {
$filePath = $folderPath . DIRECTORY_SEPARATOR . $file;
if (is_file($filePath))
{
unlink($filePath);
}
}
rmdir($folderPath);
echo "<div class='alert alert-success alert-dismissible fade show text-center'>Associated folder has been deleted successfully.<button type='button' class='close' data-dismiss='alert'>×</button></div>";
}
else
{
echo "<div class='alert alert-info alert-dismissible fade show text-center'>Associated folder does not exist.<button type='button' class='close' data-dismiss='alert'>×</button></div>";
}
}
$folderPath = 'uploads';
deleteFolder($folderPath);
?>
<script src="js/jquery.slim.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>