/
admin.php
250 lines (226 loc) · 8.29 KB
/
admin.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<?php
/*
#############################################################
# >>> PHPSurveyor #
#############################################################
# > 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. #
#############################################################
*/
require_once(dirname(__FILE__).'/../config.php');
if (!isset($surveyid)) {$surveyid=returnglobal('sid');}
if (!isset($gid)) {$gid=returnglobal('gid');}
if (!isset($qid)) {$qid=returnglobal('qid');}
if (!isset($lid)) {$lid=returnglobal('lid');}
if (!isset($code)) {$code=returnglobal('code');}
if (!isset($action)) {$action=returnglobal('action');}
if (!isset($ok)) {$ok=returnglobal('ok');}
if (!isset($user)) {$user=returnglobal('user');}
if (!isset($pass)) {$pass=returnglobal('pass');}
if (!isset($the_file)) {$the_file=returnglobal('the_file');}
if (!isset($svettore)) {$svettore=returnglobal('svettore');}
if (!isset($fp)) {$fp=returnglobal('filev');}
if (!isset($elem)) {$elem=returnglobal('elem');}
sendcacheheaders();
echo $htmlheader;
echo "<script type='text/javascript'>\n"
."<!--\n"
."\tfunction showhelp(action)\n"
."\t\t{\n"
."\t\tvar name='help';\n"
."\t\tif (action == \"hide\")\n"
."\t\t\t{\n"
."\t\t\tdocument.getElementById(name).style.display='none';\n"
."\t\t\t}\n"
."\t\telse if (action == \"show\")\n"
."\t\t\t{\n"
."\t\t\tdocument.getElementById(name).style.display='';\n"
."\t\t\t}\n"
."\t\t}\n"
."-->\n"
."</script>\n";
// CHECK IF FIRST USE!
if (!$database_exists)
{
echo "<br />\n"
."<table width='350' align='center' style='border: 1px solid #555555' cellpadding='1' cellspacing='0'>\n"
."\t<tr bgcolor='#555555'><td colspan='2' height='4'><font size='1' face='verdana' color='white'><strong>"
._("PHPSurveyor Setup")."</strong></td></tr>\n"
."\t<tr bgcolor='#CCCCCC'><td align='center'>$setfont\n"
."<strong><font color='red'>"
._("Error")."<br />\n"
._("The defined surveyor database does not exist")."</font></strong><br /><br />\n"
._("Either your selected database has not yet been created or there is a problem accessing it.")."<br />\n"
._("PHPSurveyor can attempt to create this database for you.")."<br /><br />\n"
._("Your selected database name is:")." $databasename<br />\n"
."<br /><input $btstyle type='submit' value='"
._("Create Database")."' onClick='location.href=\"createdb.php\"' /></center>\n"
."</td></tr></table>\n"
."</body>\n</html>\n";
exit;
}
else
{
//DB EXISTS, CHECK FOR APPROPRIATE TABLES
checkfortables();
}
if ($action == "activate")
{
include("activate.php");
exit;
}
if ($action == "deactivate")
{
include("deactivate.php");
exit;
}
if ($action == "importsurvey")
{
include("importsurvey.php");
exit;
}
if ($action == "importgroup")
{
include("importgroup.php");
exit;
}
if ($action == "importquestion")
{
include("importquestion.php");
exit;
}
//CHECK THAT SURVEYS MARKED AS ACTIVE ACTUALLY HAVE MATCHING TABLES
checkactivations();
//VARIOUS DATABASE OPTIONS/ACTIONS PERFORMED HERE
if ($action == "delsurvey" || $action == "delgroup" || $action == "delgroupall" ||
$action=="delquestion" || $action=="delquestionall" || $action == "insertnewsurvey" ||
$action == "copynewquestion" || $action == "insertnewgroup" || $action=="reordergroups" || $action == "insertCSV" ||
$action == "insertnewquestion" || $action == "updatesurvey" || $action=="updategroup" ||
$action=="reorderquestions" || $action=="updatequestion" || $action == "modanswer" || $action == "renumberquestions" ||
$action == "delattribute" || $action == "addattribute" || $action == "editattribute")
{
include("database.php");
}
// WE DRAW THE PRETTY SCREEN HERE
include("html.php");
//$cellstyle = "style='border: 1px inset #000080'";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"
."\t<tr>\n"
."\t\t<td valign='top' align='center' bgcolor='#BBBBBB'>\n";
//."\t\t\t<font size='2'>\n";
echo showadminmenu();
if ($action == "newsurvey")
{
echo "$newsurvey\n"
."\t\t</td>\n";
helpscreen();
echo "\t</tr>\n"
."</table>\n"
.getAdminFooter("$langdir/instructions.html", "Using PHPSurveyors Admin Script");
exit;
}
if (isset($listsurveys)) {echo $listsurveys; }
if (isset($surveysummary)) {echo $surveysummary;}
if (isset($cssummary)) {echo $cssummary;}
if (isset($usersummary)) {echo $usersummary;}
if (isset($addsummary)) {echo $addsummary;}
if (isset($editsurvey)) {echo $editsurvey;}
if (isset($ordergroups)){echo $ordergroups;}
if (isset($newgroup)) {echo $newgroup;}
if (isset($groupsummary)) {echo $groupsummary;}
if (isset($editgroup)) {echo $editgroup;}
if (isset($newquestion)) {echo $newquestion;}
if (isset($questionsummary)) {echo $questionsummary;}
if (isset($editquestion)) {echo $editquestion;}
if (isset($orderquestions)) {echo $orderquestions;}
if (isset($newanswer)) {echo $newanswer;}
if (isset($answersummary)) {echo $answersummary;}
if (isset($vasummary)) {echo $vasummary;}
if (isset($editanswer)) {echo $editanswer;}
if (isset($editcsv)) {echo $editcsv;}
echo "\t\t</td>\n";
helpscreen();
echo "\t</tr>\n";
echo "</table>\n";
echo getAdminFooter("$langdir/instructions.html", "Using PHPSurveyors Admin Script");
function helpscreen()
{
global $homeurl, $langdir, $setfont, $imagefiles;
global $surveyid, $gid, $qid, $action;
echo "\t\t<td id='help' width='200' valign='top' style='display: none' bgcolor='#CCCCCC'>\n"
."\t\t\t<table width='100%'><tr><td>"
."<table width='100%' align='center' cellspacing='0'>\n"
."\t\t\t\t<tr>\n"
."\t\t\t\t\t<td bgcolor='#555555' height='8'>\n"
."\t\t\t\t\t\t$setfont<font color='white' size='1'><strong>"
._("Help")."</strong>\n"
."\t\t\t\t\t</font></font></td>\n"
."\t\t\t\t</tr>\n"
."\t\t\t\t<tr>\n"
."\t\t\t\t\t<td align='center' bgcolor='#AAAAAA' style='border-style: solid; border-width: 1; border-color: #555555'>\n"
."\t\t\t\t\t\t<img src='$imagefiles/blank.gif' alt='' width='20' hspace='0' border='0' align='left'>\n"
."\t\t\t\t\t\t<input type='image' src='$imagefiles/close.gif' name='CloseHelp' align='right' onClick=\"showhelp('hide')\">\n"
."\t\t\t\t\t</td>\n"
."\t\t\t\t</tr>\n"
."\t\t\t\t<tr>\n"
."\t\t\t\t\t<td bgcolor='silver' height='100%' style='border-style: solid; border-width: 1; border-color: #333333'>\n";
//determine which help document to show
if (!$surveyid && $action != "editusers")
{
$helpdoc = "$langdir/admin.html";
}
elseif (!$surveyid && $action=="editusers")
{
$helpdoc = "$langdir/users.html";
}
elseif ($surveyid && !$gid)
{
$helpdoc = "$langdir/survey.html";
}
elseif ($surveyid && $gid && !$qid)
{
$helpdoc = "$langdir/group.html";
}
//elseif ($surveyid && $gid && $qid && !$_GET['viewanswer'] && !$_POST['viewanswer'])
elseif ($surveyid && $gid && $qid && !returnglobal('viewanswer'))
{
$helpdoc = "$langdir/question.html";
}
elseif ($surveyid && $gid && $qid && (returnglobal('viewanswer')))
{
$helpdoc = "$langdir/answer.html";
}
echo "\t\t\t\t\t\t<iframe width='200' height='400' src='$helpdoc' marginwidth='2' marginheight='2'>\n"
."\t\t\t\t\t\t</iframe>\n"
."\t\t\t\t\t</td>"
."\t\t\t\t</tr>\n"
."\t\t\t</table></td></tr></table>\n"
."\t\t</td>\n";
}
?>