/
deletesurvey.php
109 lines (101 loc) · 4.17 KB
/
deletesurvey.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
<?php
/*
#############################################################
# >>> PHP Surveyor #
#############################################################
# > Author: Jason Cleeland #
# > E-mail: jason@cleeland.org #
# > Mail: Box 99, Trades Hall, 54 Victoria St, #
# > CARLTON SOUTH 3053, AUSTRALIA
# > Date: 20 February 2003 #
# #
# This set of scripts allows you to develop, publish and #
# perform data-entry on surveys. #
#############################################################
# #
# Copyright (C) 2003 Jason Cleeland #
# #
# This program is free software; you can redistribute #
# it and/or modify it under the terms of the GNU General #
# Public License as published by the Free Software #
# Foundation; either version 2 of the License, or (at your #
# option) any later version. #
# #
# This program is distributed in the hope that it will be #
# useful, but WITHOUT ANY WARRANTY; without even the #
# implied warranty of MERCHANTABILITY or FITNESS FOR A #
# PARTICULAR PURPOSE. See the GNU General Public License #
# for more details. #
# #
# You should have received a copy of the GNU General #
# Public License along with this program; if not, write to #
# the Free Software Foundation, Inc., 59 Temple Place - #
# Suite 330, Boston, MA 02111-1307, USA. #
#############################################################
*/
include("config.php");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
echo $htmlheader;
if (!$sid)
{
echo "<center><br />ERROR: You have not chosen a survey to delete!</center>\n";
echo "</body>\n</html>";
exit;
}
if (!$ok)
{
echo "<table width='100%' align='center'>\n";
echo "\t<tr>\n";
echo "\t\t<td align='center'>$setfont<br />\n";
echo "\t\t\t<font color='red'><b>--:WARNING:--</b></font><br />\n";
echo "\t\t\t<b>You are about to delete survey $sid</b><br />\n";
echo "\t\t\tIf you select \"OK\" below to delete this survey<br />\n";
echo "\t\t\tyou will lose all your work on this survey. You'd want<br />\n";
echo "\t\t\tto be pretty sure about that!<br /><br />\n";
echo "\t\t\tYou could consider 'exporting' the survey before deleting<br />\n";
echo "\t\t\tit, and then if you change your mind later you could<br />\n";
echo "\t\t\tre-install it. If you want to do this, click on 'cancel'<br />\n";
echo "\t\t\tand then choose \"export\" from the survey summary on the<br />\n";
echo "\t\t\tmain administration screen.\n";
echo "\t\t</td>\n";
echo "\t</tr>\n";
echo "\t<tr>\n";
echo "\t\t<td align='center'><br />\n";
echo "\t\t\t<input type='submit' $btstyle style='width:100' value='Delete It' onClick=\"window.open('$PHP_SELF?sid=$sid&ok=Y','_top')\" /><br /><br />\n";
echo "\t\t\t<input type='submit' $btstyle style='width:100' value='Cancel' onClick=\"window.open('admin.php?sid=$sid', '_top')\" />\n";
echo "\t\t</td>\n";
echo "\t</tr>\n";
echo "</table>\n";
echo "</body>\n</html>";
}
else
{
$dsquery = "SELECT qid FROM questions WHERE sid=$sid";
$dsresult = mysql_query($dsquery);
while ($dsrow = mysql_fetch_array($dsresult))
{
$asdel = "DELETE FROM answers WHERE qid=$dsrow['qid']";
$asres = mysql_query($asdel);
}
$qdel = "DELETE FROM questions WHERE sid=$sid";
$qres = mysql_query($qdel);
$gdel = "DELETE FROM groups WHERE sid=$sid";
$gres = mysql_query($gdel);
$sdel = "DELETE FROM surveys WHERE sid=$sid";
$sres = mysql_query($sdel);
echo "<table width='100%' align='center'>\n";
echo "\t<tr>\n";
echo "\t\t<td align='center'>$setfont<br />\n";
echo "\t\t\t<b>All bits of survey $sid have been deleted.<br /><br />\n";
echo "\t\t\t<a href='admin.php'>Return to Admin Page</a>\n";
echo "\t\t</td>\n";
echo "\t</tr>\n";
echo "</table>\n";
echo "</body>\n</html>";
}
?>