-
Notifications
You must be signed in to change notification settings - Fork 8
/
events.php
134 lines (133 loc) · 3.4 KB
/
events.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
declare(strict_types=1);
/**
* MCCodes v2 by Dabomstew & ColdBlooded
*
* Repository: https://github.com/davemacaulay/mccodesv2
* License: MIT License
*/
global $db, $ir, $userid, $h;
require_once('globals.php');
if (!isset($_GET['delete']))
{
$_GET['delete'] = 0;
}
$_GET['delete'] = abs((int) $_GET['delete']);
if ($_GET['delete'] > 0)
{
$d_c =
$db->query(
"SELECT COUNT(`evUSER`)
FROM `events`
WHERE `evID` = {$_GET['delete']}
AND `evUSER` = {$userid}");
if ($db->fetch_single($d_c) == 0)
{
echo '<span style="font-weight:bold;">Event doesn\'t exist</span><br />';
}
else
{
$db->query(
"DELETE FROM `events`
WHERE `evID` = {$_GET['delete']}
AND `evUSER` = {$userid}");
echo '<span style="font-weight:bold;">Event Deleted</span><br />';
}
$db->free_result($d_c);
}
if (isset($_GET['delall']) && $_GET['delall'])
{
$delall_verf = request_csrf_code('events_delall');
echo "
This will delete all your events.<br />
There is <b>NO</b> undo, so be sure.<br />
> <a href='events.php?delall2=1&verf={$delall_verf}'>Yes,
delete all my events</a><br />
> <a href='events.php'>No, go back</a><br />
";
$h->endpage();
exit;
}
if (isset($_GET['delall2']) && $_GET['delall2'])
{
if (!isset($_GET['verf'])
|| !verify_csrf_code('events_delall', stripslashes($_GET['verf'])))
{
echo '<h3>Error</h3><hr />
This action has been blocked for your security.<br />
You should submit this action fast,
to ensure that it is really you doing it.<br />
> <a href="events.php?delall=1">Try Again</a>';
$h->endpage();
exit;
}
$am =
$db->fetch_single(
$db->query(
"SELECT COUNT(`evID`)
FROM `events`
WHERE `evUSER` = $userid"));
if ($am == 0)
{
echo 'You have no events to delete.<br />
> <a href="events.php">Go Back</a>';
$h->endpage();
exit;
}
$db->query("DELETE FROM `events`
WHERE `evUSER` = $userid");
echo "
All <b>{$am}</b> events you had were deleted.<br />
<br />> <a href='events.php'>Go Back</a>
";
$h->endpage();
exit;
}
echo "
<b>Latest 10 events</b>
<hr />
> <a href='events.php?delall=1'>Delete All Events</a>
<hr />
";
$q =
$db->query(
"SELECT `evTIME`, `evREAD`, `evTEXT`, `evID`
FROM `events`
WHERE `evUSER` = $userid
ORDER BY `evTIME` DESC
LIMIT 10");
echo "
<table width=75% cellspacing=1 class='table'>
<tr style='background:gray;'>
<th>Time</th>
<th>Event</th>
<th>Links</th>
</tr>
";
while ($r = $db->fetch_row($q))
{
echo '<tr>
<td>' . date('F j Y, g:i:s a', (int)$r['evTIME']);
if (!$r['evREAD'])
{
echo '<br /><b>New!</b>';
}
echo " </td>
<td>{$r['evTEXT']}</td>
<td><a href='events.php?delete={$r['evID']}'>Delete</a></td>
</tr>";
}
echo '</table>';
$db->free_result($q);
if ($ir['new_events'] > 0)
{
$db->query(
"UPDATE `events`
SET `evREAD` = 1
WHERE `evUSER` = $userid");
$db->query(
"UPDATE `users`
SET `new_events` = 0
WHERE `userid` = $userid");
}
$h->endpage();