-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete.php
69 lines (65 loc) · 1.98 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
<?php
require("header.php");
if (!$_COOKIE['bm-id']) {
header("Location: " . $config_basedir);
}
if ($_POST['submit']) {
if ($_POST['really'] == "really") {
if ($_POST['type'] == "account") {
if ($_POST['id'] == $_COOKIE['bm-id']) {
$sql = "DELETE FROM users WHERE id = " . $_COOKIE['bm-id'] . " LIMIT 1";
mysql_query($sql) or die(mysql_error());
setcookie("bm-id", $row['id'], time()-60);
echo "<p class='alert'>Bye. (Back to the <a href='index.php'>index</a>?</p>";
}
else {
echo "<p class='alert'>Nice try, but you can't delete an account that's not yours.</p>";
}
}
if ($_POST['type'] == "bookmark") {
$check_sql = "SELECT user_id FROM bookmarks WHERE id = " . $_POST['id'];
$check_res = mysql_query($check_sql) or die(mysql_error());
$check_row = mysql_fetch_assoc($check_res);
if ($check_row['user_id'] == $_COOKIE['bm-id']) {
$sql = "DELETE FROM bookmarks WHERE id = " . $_POST['id'] . " LIMIT 1";
mysql_query($sql) or die(mysql_error());
header("Location: " . $config_basedir . "bookmarks.php");
}
else {
echo "<p class='alert'>Nice try, but you can't delete a bookmark that's not yours.</p>";
}
}
}
else {
echo "<p class='alert'>You didn't check the 'really' box...</p>";
}
}
else {
?>
<h1>exmeamente.ws/bm/delete</h1>
<p>Anything you do can't be undone, so be careful.</p>
<p><form action="delete.php" method="post">
<table>
<tr>
<td>Type</td>
<td>
<select name="type">
<option value="bookmark">Bookmark</option>
<option value="account">Account</option>
</select>
</td>
</tr>
<tr>
<td>ID</td>
<td><input type="text" name="id" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Delete" name="submit" /> Really<input type="checkbox" value="really" name="really" /></td>
</tr>
</table>
</form></p>
<?php
}
require("footer.php");
?>