-
Notifications
You must be signed in to change notification settings - Fork 1
/
deletecalendar.php
199 lines (177 loc) · 4.87 KB
/
deletecalendar.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?php
require_once('application.inc.php');
if (!authorized()) { exit; }
if (!$_SESSION['AUTH_ISMAINADMIN'] ) { exit; } // additional security
if (!isset($_POST['cancel']) || !setVar($cancel, $_POST['cancel'], 'cancel')) { unset($cancel); }
if (!isset($_POST['save']) || !setVar($save, $_POST['save'], 'save')) { unset($save); }
if (isset($_POST['cal']) || isset($_GET['cal'])) {
if (!isset($_POST['cal']['id']) || !setVar($cal['id'], $_POST['cal']['id'], 'calendarid')) {
if (!isset($_GET['cal']['id']) || !setVar($cal['id'], $_GET['cal']['id'], 'calendarid')) {
unset($cal['id']);
}
}
}
else { unset($cal); }
if (isset($cancel)) {
redirect2URL('managecalendars.php');
exit;
}
// make sure the calendar exists
$result =& DBQuery("
SELECT
*
FROM
" . SCHEMANAME . "vtcal_calendar
WHERE
id='" . sqlescape($cal['id']) . "'
");
if (is_string($result)) {
DBErrorBox('Error determining if calendar exists: ' . $result);
exit;
}
if ( $result->numRows() != 1 ) {
redirect2URL('managecalendars.php');
exit;
}
else {
$c = $result->fetchRow(DB_FETCHMODE_ASSOC, 0);
}
if (isset($save) ) {
$result =& DBQuery("
DELETE FROM
" . SCHEMANAME . "vtcal_event
WHERE
calendarid='" . sqlescape($cal['id']) . "'
");
if (is_string($result)) {
DBErrorBox('Error deleting events from ' . SCHEMANAME . 'vtcal_event: ' . $result);
exit;
}
$result =& DBQuery("
DELETE FROM
" . SCHEMANAME . "vtcal_event_repeat
WHERE
calendarid='" . sqlescape($cal['id']) . "'
");
if (is_string($result)) {
DBErrorBox('Error deleting repeating events from ' . SCHEMANAME . 'vtcal_event_repeat: ' . $result);
exit;
}
$result =& DBQuery("
DELETE FROM
" . SCHEMANAME . "vtcal_event_public
WHERE
calendarid='" . sqlescape($cal['id']) . "'
");
if (is_string($result)) {
DBErrorBox('Error deleting public events from ' . SCHEMANAME . 'vtcal_event_public: ' . $result);
exit;
}
$result =& DBQuery("
DELETE FROM
" . SCHEMANAME . "vtcal_calendarviewauth
WHERE
calendarid='" . sqlescape($cal['id']) . "'
");
if (is_string($result)) {
DBErrorBox('Error deleting view auth from ' . SCHEMANAME . 'vtcal_calendarviewauth: ' . $result);
exit;
}
$result =& DBQuery("
DELETE FROM
" . SCHEMANAME . "vtcal_auth
WHERE
calendarid='" . sqlescape($cal['id']) . "'
");
if (is_string($result)) {
DBErrorBox('Error deleting auth from ' . SCHEMANAME . 'vtcal_auth: ' . $result);
exit;
}
$result =& DBQuery("
DELETE FROM
" . SCHEMANAME . "vtcal_searchlog
WHERE
calendarid='" . sqlescape($cal['id']) . "'
");
if (is_string($result)) {
DBErrorBox('Error deleting log entries from ' . SCHEMANAME . 'vtcal_searchlog: ' . $result);
exit;
}
$result =& DBQuery("
DELETE FROM
" . SCHEMANAME . "vtcal_searchkeyword
WHERE
calendarid='" . sqlescape($cal['id']) . "'
");
if (is_string($result)) {
DBErrorBox('Error deleting keywords from ' . SCHEMANAME . 'vtcal_searchkeyword: ' . $result);
exit;
}
$result =& DBQuery("
DELETE FROM
" . SCHEMANAME . "vtcal_searchfeatured
WHERE
calendarid='" . sqlescape($cal['id']) . "'
");
if (is_string($result)) {
DBErrorBox('Error deleting featured keywords from ' . SCHEMANAME . 'vtcal_searchfeatured: ' . $result);
exit;
}
$result =& DBQuery("
DELETE FROM
" . SCHEMANAME . "vtcal_category
WHERE
calendarid='" . sqlescape($cal['id']) . "'
");
if (is_string($result)) {
DBErrorBox('Error categories from ' . SCHEMANAME . 'vtcal_category: ' . $result);
exit;
}
$result =& DBQuery("
DELETE FROM
" . SCHEMANAME . "vtcal_template
WHERE
calendarid='" . sqlescape($cal['id']) . "'
");
if (is_string($result)) {
DBErrorBox('Error templates from ' . SCHEMANAME . 'vtcal_template: ' . $result);
exit;
}
$result =& DBQuery("
DELETE FROM
" . SCHEMANAME . "vtcal_sponsor
WHERE
calendarid='" . sqlescape($cal['id']) . "'
");
if (is_string($result)) {
DBErrorBox('Error sponsors from ' . SCHEMANAME . 'vtcal_sponsor: ' . $result);
exit;
}
$result =& DBQuery("
DELETE FROM
" . SCHEMANAME . "vtcal_calendar
WHERE
id='" . sqlescape($cal['id']) . "'
");
if (is_string($result)) {
DBErrorBox('Error the calendar from ' . SCHEMANAME . 'vtcal_calendar: ' . $result);
exit;
}
redirect2URL('managecalendars.php');
exit;
}
pageheader(lang('delete_calendar', false), 'Update');
contentsection_begin(lang('delete_calendar'));
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<?php if (isset($cal['id'])) { echo '<input type="hidden" name="cal[id]" value="' . htmlspecialchars($cal['id'], ENT_COMPAT, 'UTF-8') . '" />' . "\n"; } ?>
<p><strong class="txtWarn"><?php echo lang('warning_calendar_delete'); ?> "<?php echo $c['name']; ?>"</strong></p>
<p><input type="submit" name="save" value="<?php echo htmlspecialchars(lang('ok_button_text', false), ENT_COMPAT, 'UTF-8'); ?>" />
<input type="submit" name="cancel" value="<?php echo htmlspecialchars(lang('cancel_button_text', false), ENT_COMPAT, 'UTF-8'); ?>" /></p>
</form>
<?php
contentsection_end();
pagefooter();
DBclose();
?>