📄 survey.php
字号:
<?
################################################################################
# phpQuestionnaire Version 2.2 #
# Copyright 2003-2005 chumpsoft, inc. March 28, 2005 #
################################################################################
# SCRiPTMAFiA 2005 - THE DiRTY HANDS ON YOUR SCRiPTS #
################################################################################
$GLOBALS["inAdmin"] = 1;
#-->> Including Files
require("../inc/init.php");
require("../inc/mysql.php");
require("../inc/functions.php");
require("../inc/pfunctions.php");
require("../inc/ifunctions.php");
#-->> Setting Variables
$varnames = array("surveyname", "description", "adminnotes", "surveywidth",
"questionstyle", "answerinputstyle", "answerstyle", "answertextstyle",
"errorstyle", "template", "oncomplete", "redirecturl", "completed",
"verifyemail", "emailfrom", "emailsubject", "localadvance", "advance",
"questionnumb", "surveyusersip", "surveyusersck", "surveyusersem",
"surveyresults", "sdmonth", "sdday", "sdyear", "sdhr", "sdmt", "sdsc",
"edmonth", "edday", "edyear", "edhr", "edmt", "edsc", "cs", "action",
"modifyid", "activate", "activateid", "deleteid", "indent",
"submitimagesrc", "submitimagewidth", "submitimageheight", "submitimagealt",
"resultimagesrc", "resultimagewidth", "resultimageheight", "resultimagealt",
"nextimagesrc", "nextimagewidth", "nextimageheight", "nextimagealt",
"resultswidth", "resultsborder", "resultsanswer", "resultsstats",
"resultsgraph", "responseemail", "responsenotice", "message", "language");
SetVars($varnames);
#-->> Logging In
IsAdmin(1);
SetLanguage('', 'ADMIN');
$languages = GetLanguages();
$imgurl = $GLOBALS["phpQImageDir"];
if (!$advance) {
$advance = ($phpQAdmin["AdvanceInterface"] == "y") ? true : false;
}
#-->> Setting Interface
if ($cs) {
$mqadvance = mysql_query("select AdvanceInterface from phpQSurvey where SID = \"".ProtectMySQL($cs)."\"");
if ($maadvance = mysql_fetch_array($mqadvance)) {
$advance = ($maadvance["AdvanceInterface"]) ? (($maadvance["AdvanceInterface"]=="y") ? true : false) : $advance;
}
}
switch ($localadvance) {
case "y": $advance = true; break;
case "n": $advance = false; break;
default: break;
}
#-->> Option Arrays
$qnumb = array(array($phpQlang['Yes'], "y"), array($phpQlang['No'], "n"));
$advancearray = array(array($phpQlang['Basic'], "n"), array($phpQlang['Advanced'], "y"));
$startyear = 2000;
$endyear = $startyear + 50;
$resultswidth = is_numeric($resultswidth) ? $resultswidth : 500;
if ($action == 'add' || $action == 'modify') {
$surveyresults = is_numeric($surveyresults) ? $surveyresults : 0;
$oncomplete = $oncomplete ? $oncomplete : 0;
if (!$surveyresults && $oncomplete == 1) {
$oncomplete = 0;
$message = $phpQlang['RedirectPrivateError'];
}
}
#-->> Add, Modify or Delete Surveys
switch ($action) {
case "add":
if ($surveyname) {
$surveyname = ProtectMySQL($surveyname);
$description = ProtectMySQL($description);
$adminnotes = ProtectMySQL($adminnotes);
$surveywidth = ProtectMySQL($surveywidth);
$questionstyle = ProtectMySQL(preg_replace("/STYLE=\"(.*)\"/i", "\\1", $questionstyle));
$answerinputstyle = ProtectMySQL(preg_replace("/STYLE=\"(.*)\"/i", "\\1", $answerinputstyle));
$answerstyle = ProtectMySQL(preg_replace("/STYLE=\"(.*)\"/i", "\\1", $answerstyle));
$answertextstyle = ProtectMySQL(preg_replace("/STYLE=\"(.*)\"/i", "\\1", $answertextstyle));
$errorstyle = ProtectMySQL(preg_replace("/STYLE=\"(.*)\"/i", "\\1", $errorstyle));
$template = ProtectMySQL($template);
if (!isset($languages[$language])) {
if (isset($languages['english'])) { $language = 'english'; }
else { foreach ($languages as $key => $value) { $language = $key; break; } }
}
$language = ProtectMySQL($language);
$oncomplete = ProtectMySQL($oncomplete);
$redirecturl = ProtectMySQL($redirecturl);
$responsenotice = ProtectMySQL($responsenotice);
$responseemail = ProtectMySQL($responseemail);
$completed = ProtectMySQL($completed);
$emailfrom = ProtectMySQL($emailfrom);
$emailsubject = ProtectMySQL($emailsubject);
$verifyemail = ProtectMySQL($verifyemail);
$resultswidth = ProtectMySQL($resultswidth);
$resultsborder = ProtectMySQL(preg_replace("/STYLE=\"(.*)\"/i", "\\1", $resultsborder));
$resultsanswer = ProtectMySQL(preg_replace("/STYLE=\"(.*)\"/i", "\\1", $resultsanswer));
$resultsstats = ProtectMySQL(preg_replace("/STYLE=\"(.*)\"/i", "\\1", $resultsstats));
$resultsgraph = ProtectMySQL(preg_replace("/STYLE=\"(.*)\"/i", "\\1", $resultsgraph));
$localadvance = ($localadvance=="y" || $localadvance=="n") ? $localadvance : $advance;
$questionnumb = ($questionnumb == "y" || $questionnumb == "n") ? $questionnumb : "y";
$surveyusers = ProcessSurveyUsers($surveyusersip, $surveyusersck, $surveyusersem);
$surveyresults = ProtectMySQL($surveyresults);
if ($advance) {
if ($sdmonth || $sdday || $sdyear || $sdhr || $sdmt || $sdsc) {
if (CheckDateTime($sdmonth,$sdday,$sdyear,$sdhr,$sdmt,$sdsc)) {
$startdate = "$sdyear-$sdmonth-$sdday $sdhr:$sdmt:$sdsc";
}
else {
$message = sprintf($phpQlang['InvalidDateError'], $phpQlang['StartingDate']);
}
}
if ($edmonth || $edday || $edyear || $edhr || $edmt || $edsc) {
if (CheckDateTime($edmonth,$edday,$edyear,$edhr,$edmt,$edsc)) {
$enddate = "$edyear-$edmonth-$edday $edhr:$edmt:$edsc";
}
elseif ($edyear || $edmonth || $edday) {
$message = sprintf($phpQlang['InvalidDateError'], $phpQlang['EndingDate']);
}
}
if ($startdate && $enddate &&
mktime($sdhr,$sdmt,$sdsc,$sdmonth,$sdday,$sdyear) > mktime($edhr,$edmt,$edsc,$edmonth,$edday,$edyear)) {
$startdate = "";
$enddate = "";
$message = sprintf($phpQlang['DateOrderError'], $phpQlang['StartingDate'], $phpQlang['EndingDate']);
}
}
else {
# These are the default values for basic interface...
$resultswidth = '500';
$resultsborder = 'background-color: #333366; color: #FFFFFF; text-decoration: none;';
$resultsanswer = 'background-color: #FFFFFF; color: #333366;';
$resultsstats = 'background-color: #DDEEFF; color: #333366;';
$resultsgraph = 'background-color: #333366; height: 8px;';
$submitimagealt = $phpQlang['Submit'];
$resultimagealt = $phpQlang['ShowResults'];
$nextimagealt = $phpQlang['Next'];
}
$submitimagesrc = ProtectMySQL($submitimagesrc);
$submitimagealt = $submitimagealt ? ProtectMySQL($submitimagealt) : '';
$submitimagewidth = $submitimagewidth > 0 ? ProtectMySQL($submitimagewidth) : 0;
$submitimageheight = $submitimageheight > 0 ? ProtectMySQL($submitimageheight) : 0;
$resultimagesrc = ProtectMySQL($resultimagesrc);
$resultimagealt = $resultimagealt ? ProtectMySQL($resultimagealt) : '';
$resultimagewidth = $resultimagewidth > 0 ? ProtectMySQL($resultimagewidth) : 0;
$resultimageheight = $resultimageheight > 0 ? ProtectMySQL($resultimageheight) : 0;
$nextimagesrc = ProtectMySQL($nextimagesrc);
$nextimagealt = $nextimagealt ? ProtectMySQL($nextimagealt) : '';
$nextimagewidth = $nextimagewidth > 0 ? ProtectMySQL($nextimagewidth) : 0;
$nextimageheight = $nextimageheight > 0 ? ProtectMySQL($nextimageheight) : 0;
$insertquery = "insert into phpQSurvey (";
$insertquery .= "SID, Name, Description, AdminNotes, Width, Indent, ";
$insertquery .= "QuestionStyle, AnswerInputStyle, AnswerTextStyle, AnswerStyle, ";
$insertquery .= "Template, Language, AddDate, ErrorStyle, SurveyUsers, SurveyResults, ";
$insertquery .= "OnComplete, RedirectURL, Completed, QuestionNumb, ";
$insertquery .= "VerifyEmail, EmailFrom, EmailSubject, ";
$insertquery .= "AdvanceInterface, ResultsWidth, ResultsBorder, ";
$insertquery .= "ResultsAnswer, ResultsStats, ResultsGraph, ";
$insertquery .= "SubmitImageSrc, SubmitImageWidth, SubmitImageHeight, SubmitImageText, ";
$insertquery .= "ResultImageSrc, ResultImageWidth, ResultImageHeight, ResultImageText, ";
$insertquery .= "NextImageSrc, NextImageWidth, NextImageHeight, NextImageText ";
$insertquery .= ($startdate) ? ", StartDate" : "";
$insertquery .= ($enddate) ? ", EndDate" : "";
$insertquery .= ", ResponseNotice, ResponseEmail) values (";
$insertquery .= "NULL, \"$surveyname\", \"$description\", \"$adminnotes\", \"$surveywidth\", ";
$insertquery .= "\"$indent\", \"$questionstyle\", \"$answerinputstyle\", \"$answertextstyle\", \"$answerstyle\", ";
$insertquery .= "\"$template\", \"$language\", now(), \"$errorstyle\", ";
$insertquery .= "\"$surveyusers\", \"$surveyresults\", \"$oncomplete\", \"$redirecturl\", ";
$insertquery .= "\"$completed\", \"$questionnumb\", \"$verifyemail\", \"$emailfrom\", \"$emailsubject\", ";
$insertquery .= "\"$localadvance\", \"$resultswidth\", \"$resultsborder\", ";
$insertquery .= "\"$resultsanswer\", \"$resultsstats\", \"$resultsgraph\", ";
$insertquery .= "\"$submitimagesrc\", \"$submitimagewidth\", \"$submitimageheight\", \"$submitimagealt\", ";
$insertquery .= "\"$resultimagesrc\", \"$resultimagewidth\", \"$resultimageheight\", \"$resultimagealt\", ";
$insertquery .= "\"$nextimagesrc\", \"$nextimagewidth\", \"$nextimageheight\", \"$nextimagealt\" ";
$insertquery .= ($startdate) ? ", \"$startdate\"" : '';
$insertquery .= ($enddate) ? ", \"$enddate\"" : '';
$insertquery .= ", \"$responsenotice\", \"$responseemail\")";
$success = mysql_query($insertquery);
if ($success) { $cs = mysql_insert_id(); }
if (!$success) { $message = $phpQlang['AddSurveyError']; }
elseif (!$message) { $phpQlang['AddSurveySuccess']; }
}
break;
case "activate":
if ($activateid && $activate) {
$success = mysql_query("update phpQSurvey set Active = \"$activate\" where SID = \"".ProtectMySQL($activateid)."\"");
if (!$success) { $message = $phpQlang['ActivateSurveyError']; }
}
break;
case "delete":
if ($deleteid) {
$success = mysql_query("delete from phpQSurvey where SID = \"".ProtectMySQL($deleteid)."\"");
$success = (mysql_query("delete from phpQQuestion where SID = \"".ProtectMySQL($deleteid)."\"")) ? $success : false;
$success = (mysql_query("delete from phpQUser where SID = \"".ProtectMySQL($deleteid)."\"")) ? $success : false;
$success = (mysql_query("delete from phpQAnswer where SID = \"".ProtectMySQL($deleteid)."\"")) ? $success : false;
$message = ($success) ? $phpQlang['DeleteSurveySuccess'] : $phpQlang['DeleteSurveyError'];
}
break;
case "modify":
if ($surveyname && $modifyid) {
$surveyname = ProtectMySQL($surveyname);
$description = ProtectMySQL($description);
$adminnotes = ProtectMySQL($adminnotes);
$surveywidth = ProtectMySQL($surveywidth);
$questionstyle = ProtectMySQL(preg_replace("/STYLE=\"(.*)\"/i", "\\1", $questionstyle));
$answerstyle = ProtectMySQL(preg_replace("/STYLE=\"(.*)\"/i", "\\1", $answerstyle));
$answertextstyle = ProtectMySQL(preg_replace("/STYLE=\"(.*)\"/i", "\\1", $answertextstyle));
$errorstyle = ProtectMySQL(preg_replace("/STYLE=\"(.*)\"/i", "\\1", $errorstyle));
$template = ProtectMySQL($template);
if (!isset($languages[$language])) {
if (isset($languages['english'])) { $language = 'english'; }
else { foreach ($languages as $key => $value) { $language = $key; break; } }
}
$language = ProtectMySQL($language);
$oncomplete = ProtectMySQL($oncomplete);
$redirecturl = ProtectMySQL($redirecturl);
$responsenotice = ProtectMySQL($responsenotice);
$responseemail = ProtectMySQL($responseemail);
$completed = ProtectMySQL($completed);
$emailfrom = ProtectMySQL($emailfrom);
$emailsubject = ProtectMySQL($emailsubject);
$verifyemail = ProtectMySQL($verifyemail);
$resultswidth = ProtectMySQL($resultswidth);
$resultsborder = ProtectMySQL(preg_replace("/STYLE=\"(.*)\"/i", "\\1", $resultsborder));
$resultsanswer = ProtectMySQL(preg_replace("/STYLE=\"(.*)\"/i", "\\1", $resultsanswer));
$resultsstats = ProtectMySQL(preg_replace("/STYLE=\"(.*)\"/i", "\\1", $resultsstats));
$resultsgraph = ProtectMySQL(preg_replace("/STYLE=\"(.*)\"/i", "\\1", $resultsgraph));
$localadvance = ($localadvance=="y" || $localadvance=="n") ? $localadvance : $advance;
$questionnumb = ($questionnumb == "y" || $questionnumb == "n") ? $questionnumb : "y";
$surveyusers = ProcessSurveyUsers($surveyusersip, $surveyusersck, $surveyusersem);
$surveyresults = ProtectMySQL($surveyresults);
if ($advance) {
if ($sdmonth || $sdday || $sdyear || $sdhr || $sdmt || $sdsc) {
if (CheckDateTime($sdmonth,$sdday,$sdyear,$sdhr,$sdmt,$sdsc)) {
$startdate = "$sdyear-$sdmonth-$sdday $sdhr:$sdmt:$sdsc";
}
else {
$message = sprintf($phpQlang['InvalidDateError'], $phpQlang['StartingDate']);
}
}
if ($edmonth || $edday || $edyear || $edhr || $edmt || $edsc) {
if (CheckDateTime($edmonth,$edday,$edyear,$edhr,$edmt,$edsc)) {
$enddate = "$edyear-$edmonth-$edday $edhr:$edmt:$edsc";
}
elseif ($edyear || $edmonth || $edday) {
$message = sprintf($phpQlang['InvalidDateError'], $phpQlang['EndingDate']);
}
}
if ($startdate && $enddate && mktime($sdhr,$sdmt,$sdsc,$sdmonth,$sdday,$sdyear) > mktime($edhr,$edmt,$edsc,$edmonth,$edday,$edyear)) {
$startdate = '';
$enddate = '';
$message = sprintf($phpQlang['DateOrderError'], $phpQlang['StartingDate'], $phpQlang['EndingDate']);
}
$submitimagesrc = ProtectMySQL($submitimagesrc);
$submitimagealt = $submitimagealt ? ProtectMySQL($submitimagealt) : '';
$submitimagewidth = $submitimagewidth > 0 ? ProtectMySQL($submitimagewidth) : 0;
$submitimageheight = $submitimageheight > 0 ? ProtectMySQL($submitimageheight) : 0;
$resultimagesrc = ProtectMySQL($resultimagesrc);
$resultimagealt = $resultimagealt ? ProtectMySQL($resultimagealt) : '';
$resultimagewidth = $resultimagewidth > 0 ? ProtectMySQL($resultimagewidth) : 0;
$resultimageheight = $resultimageheight > 0 ? ProtectMySQL($resultimageheight) : 0;
$nextimagesrc = ProtectMySQL($nextimagesrc);
$nextimagealt = $nextimagealt ? ProtectMySQL($nextimagealt) : '';
$nextimagewidth = $nextimagewidth > 0 ? ProtectMySQL($nextimagewidth) : 0;
$nextimageheight = $nextimageheight > 0 ? ProtectMySQL($nextimageheight) : 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -