-
Notifications
You must be signed in to change notification settings - Fork 988
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/trunk/unstable@2 b72ed6b6-b9f8-46b5-92b4-906544132732
- Loading branch information
John Richards
committed
Mar 7, 2003
0 parents
commit 85deb6a
Showing
18 changed files
with
4,658 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
<?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. # | ||
############################################################# | ||
*/ | ||
|
||
if (!$ok) | ||
{ | ||
echo "<TABLE WIDTH='350' ALIGN='CENTER'><TR><TD ALIGN='CENTER' BGCOLOR='PINK'><FONT COLOR='RED'>$setfont<B>"; | ||
echo ":WARNING:<BR>READ THIS CAREFULLY BEFORE PROCEEDING</TD></TR>\n"; | ||
echo "<TR><TD>$setfont"; | ||
echo "You should only activate a survey when you are absolutely certain that your survey "; | ||
echo "setup is finished and will not need changing.<P>"; | ||
echo "Once a survey is activated you can no longer:"; | ||
echo "<UL><LI>Add or delete groups</LI>"; | ||
echo "<LI>Add or remove answers to Multiple Answer questions</LI>"; | ||
echo "<LI>Add or delete questions</LI></UL>"; | ||
echo "However you can still:"; | ||
echo "<UL><LI>Edit (change) your questions code, text or type</LI>"; | ||
echo "<LI>Edit (change) your group names</LI>"; | ||
echo "<LI>Add, Remove or Edit pre-defined question answers <I>(except for Multi-answer questions)</I></LI>"; | ||
echo "<LI>Change survey name or description</LI></UL>"; | ||
echo "Once data has been entered into this survey, if you want to add or remove groups "; | ||
echo "or questions, you will need to de-activate this survey, which will move all data "; | ||
echo "that has already been entered into a seperate archived table.<P>"; | ||
echo "The point of all this being that you should not proceed to the next step unless "; | ||
echo "you are ABSOLUTELY SURE!"; | ||
echo "</TD></TR>"; | ||
echo "<TR><TD ALIGN='CENTER'>"; | ||
echo "<INPUT TYPE='SUBMIT' $btstyle VALUE='I`m Unsure' onclick=\"window.open('$scriptname?sid=$sid', '_top')\"><BR>\n"; | ||
echo "<INPUT TYPE='SUBMIT' $btstyle VALUE='Activate' onClick=\"window.open('$scriptname?action=activate&ok=Y&sid=$sid', '_top')\">"; | ||
echo "</TD></TR></TABLE>\n"; | ||
|
||
} | ||
else | ||
{ | ||
$createsurvey = "CREATE TABLE survey_$sid (\n"; | ||
$createsurvey .= " id INT(11) NOT NULL auto_increment,\n"; | ||
$aquery = "SELECT * FROM questions, groups WHERE questions.gid=groups.gid AND questions.sid=$sid ORDER BY group_name, title"; | ||
$aresult = mysql_query($aquery); | ||
//echo "<BR><BR>$aquery<BR><BR>\n"; | ||
while ($arow=mysql_fetch_row($aresult)) | ||
{ | ||
if ($arow[3] != "M" && $arow[3] != "A" && $arow[3] != "B" && $arow[3] !="C" &&$arow[3] !="P") | ||
{ | ||
$createsurvey .= " $arow[1]"."X"."$arow[2]"."X"."$arow[0]"; | ||
switch($arow[3]) | ||
{ | ||
case "S": //SHORT TEXT | ||
$createsurvey .= " VARCHAR(200)"; | ||
break; | ||
case "L": //DROPDOWN LIST | ||
$createsurvey .= " VARCHAR(5)"; | ||
break; | ||
case "O": //DROPDOWN LIST WITH COMMENT | ||
$createsurvey .= " VARCHAR(5),\n $arow[1]"."X"."$arow[2]"."X"."$arow[0]"."comment TEXT"; | ||
break; | ||
case "T": //LONG TEXT | ||
$createsurvey .= " TEXT"; | ||
break; | ||
case "D": //DATE | ||
$createsurvey .= " DATE"; | ||
break; | ||
case "5": //5 Point Choice | ||
$createsurvey .= " VARCHAR(1)"; | ||
break; | ||
case "G": //Gender | ||
$createsurvey .= " VARCHAR(1)"; | ||
break; | ||
case "Y": //YesNo | ||
$createsurvey .= " VARCHAR(1)"; | ||
break; | ||
} | ||
} | ||
elseif ($arow[3] == "M" || $arow[3] == "A" || $arow[3] == "B" || $arow[3] == "C" || $arow[3] == "P") | ||
{ | ||
//MULTI ENTRY | ||
$abquery = "SELECT answers.*, questions.other FROM answers, questions WHERE answers.qid=questions.qid AND sid=$sid AND questions.qid=$arow[0] ORDER BY code"; | ||
$abresult=mysql_query($abquery); | ||
while ($abrow=mysql_fetch_row($abresult)) | ||
{ | ||
$createsurvey .= " $arow[1]"."X"."$arow[2]"."X"."$arow[0]"."$abrow[1] VARCHAR(5),\n"; | ||
if ($abrow[4]=="Y") {$alsoother="Y";} | ||
if ($arow[3] == "P") {$createsurvey .= " $arow[1]"."X"."$arow[2]"."X"."$arow[0]"."$abrow[1]comment VARCHAR(100),\n";} | ||
} | ||
if ($alsoother=="Y" && $arow[3]=="M") {$createsurvey .= " $arow[1]"."X"."$arow[2]"."X"."$arow[0]"."other VARCHAR(100),\n";} | ||
|
||
} | ||
|
||
|
||
if ( substr($createsurvey, strlen($createsurvey)-2, 2) != ",\n") {$createsurvey .= ",\n";} | ||
} | ||
//$createsurvey = substr($createsurvey, 0, strlen($createsurvey)-2); | ||
$createsurvey .= " INDEX(id)"; | ||
$createsurvey .= ") TYPE=MyISAM;"; | ||
$prettycreate=str_replace("\n", "<BR>", $createsurvey); | ||
echo "<BR>$prettycreate"; | ||
|
||
$createtable=mysql_query($createsurvey) or die ("Could not activate this survey. <BR>".mysql_error() . "<BR><BR><a href='$scriptname?sid=$sid'>Back to Admin</A>"); | ||
|
||
echo "<FONT COLOR='GREEN'>Results Table has been created!<BR><BR>"; | ||
|
||
$acquery = "UPDATE surveys SET active='Y' WHERE sid=$sid"; | ||
$acresult = mysql_query($acquery); | ||
|
||
echo "Survey is now active and data entry can proceed!<BR><BR>"; | ||
echo "<a href='$scriptname?sid=$sid'>Return to administration</a>\n"; | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<?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. # | ||
############################################################# | ||
*/ | ||
|
||
|
||
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 | ||
//Send ("Expires: " & Format$(Date - 30, "ddd, d mmm yyyy") & " " & Format$(Time, "hh:mm:ss") & " GMT ") | ||
|
||
include("config.php"); | ||
echo $htmlheader; | ||
|
||
// CHECK IF FIRST USE! | ||
if (!mysql_selectdb ($databasename, $connect)) | ||
{ | ||
echo "<CENTER><B><FONT COLOR='RED'>ERROR: Surveyor database does not exist</FONT></B><BR><BR>"; | ||
echo "It appears that your surveyor script has not yet been set up properly.<BR>"; | ||
echo "The first step is to create a MYSQL database name with your chosen default name of $databasename<BR>"; | ||
echo "<BR><INPUT TYPE='SUBMIT' VALUE='Create $databasename' onClick='location.href=\"createdb.php?dbname=$databasename\"'>"; | ||
exit; | ||
} | ||
else | ||
{ | ||
//OPEN DATABASE CONNECTION | ||
$db = mysql_selectdb($databasename, $connect); | ||
//DB EXISTS, CHECK FOR APPROPRIATE TABLES | ||
checkfortables(); | ||
} | ||
|
||
|
||
if ($action == "activate") | ||
{ | ||
echo "<CENTER><B>Activating survey ID $sid</B><BR><BR>"; | ||
include("activate.php"); | ||
exit; | ||
} | ||
if ($action == "deactivate") | ||
{ | ||
echo "<CENTER><B>De-activating survey ID $sid</B><BR><BR>"; | ||
include("deactivate.php"); | ||
exit; | ||
} | ||
|
||
if ($action == "importsurvey") | ||
{ | ||
echo "<CENTER><B>Importing Survey</B><BR><BR>\n"; | ||
include("importsurvey.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=="delquestion" || $action == "delanswer" || $action == "insertnewsurvey" || $action == "copynewquestion" || $action == "insertnewgroup" || $action == "insertnewquestion" || $action == "insertnewanswer" || $action == "updatesurvey" || $action=="updategroup" || $action=="updatequestion" || $action == "updateanswer") | ||
{ | ||
include("database.php"); | ||
} | ||
|
||
|
||
// WE DRAW THE PRETTY SCREEN HERE | ||
|
||
include("html.php"); | ||
|
||
$cellstyle="STYLE='border-color: #000080; border-width: 1; border-style: solid'"; | ||
echo "<TABLE WIDTH='100%' BORDER='0' CELLPADDING='0' CELLSPACING='0' STYLE='border-color: #000080; border-width: 5; border-style: solid'>\n"; | ||
echo "<TR><TD WIDTH='25%' VALIGN='TOP' ALIGN='CENTER' BGCOLOR='SILVER' $cellstyle>"; | ||
echo "<FONT SIZE='2'>$adminmenu</TD>\n"; | ||
|
||
echo "<TD WIDTH='75%' VALIGN='TOP' $cellstyle>"; | ||
if ($action == "newsurvey") | ||
{ | ||
echo "$newsurvey</TD></TR>\n"; | ||
echo $htmlfooter; | ||
exit; | ||
} | ||
|
||
echo "$surveysummary"; | ||
if ($usersummary) {echo $usersummary;} | ||
if ($addsummary) {echo $addsummary;} | ||
if ($editsurvey) {echo "$editsurvey";} | ||
if ($newgroup) {echo "$newgroup";} | ||
if ($groupsummary) {echo "$groupsummary";} | ||
if ($editgroup) {echo "$editgroup";} | ||
if ($newquestion) {echo "$newquestion";} | ||
if ($questionsummary) {echo "$questionsummary";} | ||
if ($editquestion) {echo "$editquestion";} | ||
if ($newanswer) {echo "$newanswer";} | ||
if ($answersummary) {echo "$answersummary";} | ||
if ($editanswer) {echo "$editanswer";} | ||
echo "</TD></TR>\n"; | ||
|
||
echo $htmlfooter; | ||
?> |
Oops, something went wrong.