(.*?)<\/id>/si",$loaded_polldata,$poll_id); $loadedpoll['id'] = trim($poll_id[1][0]); preg_match_all("/(.*?)<\/title>/si",$loaded_polldata,$poll_title); $loadedpoll['title'] = stripslashes(trim($poll_title[1][0])); preg_match_all("/<creator>(.*?)<\/creator>/si",$loaded_polldata,$poll_creator); $loadedpoll['creator'] = trim($poll_creator[1][0]); preg_match_all("/<template>(.*?)<\/template>/si",$loaded_polldata,$poll_template); $loadedpoll['template'] = trim($poll_template[1][0]); // backwards-compatibility hack for versions prior to 1.3: if (strlen($loadedpoll['template'])<1) { // no <template> tags found $loadedpoll['template'] = "Default"; } preg_match_all("/<date>(.*?)<\/date>/si",$loaded_polldata,$poll_date); $loadedpoll['date'] = trim($poll_date[1][0]); preg_match_all("/<introduction>(.*?)<\/introduction>/si",$loaded_polldata,$poll_intro); $loadedpoll['introduction'] = stripslashes(trim($poll_intro[1][0])); preg_match_all("/<question>(.*?)<\/question>/si",$loaded_polldata,$poll_question); for ($a=0;$a<count($poll_question[1]);$a++) { // iterate through answers preg_match_all("/<questionid>(.*?)<\/questionid>/si",$poll_question[1][$a],$poll_questionid); $loadedpoll[$a]['questionid'] = trim($poll_questionid[1][0]); preg_match_all("/<type>(.*?)<\/type>/si",$poll_question[1][$a],$poll_questiontype); $loadedpoll[$a]['type'] = trim($poll_questiontype[1][0]); preg_match_all("/<validation>(.*?)<\/validation>/si",$poll_question[1][$a],$poll_questionvalidation); $loadedpoll[$a]['validation'] = trim($poll_questionvalidation[1][0]); preg_match_all("/<questiontext>(.*?)<\/questiontext>/si",$poll_question[1][$a],$poll_questiontext); $loadedpoll[$a]['questiontext'] = stripslashes(trim($poll_questiontext[1][0])); preg_match_all("/<options>(.*?)<\/options>/si",$poll_question[1][$a],$poll_questionoptions); $loadedpoll[$a]['options'] = explode("|", stripslashes(trim($poll_questionoptions[1][0]))); } } else { die ("Unable to load questionnaire file"); } return ($loadedpoll); } function exportQuestToText($id,$boxes="on") { $pollfilename = "surveys/quest_" . $id . ".xml"; if ($boxes == "on") { $boxesarray = array("box" => "[ ] ","line" => "------------------------------------------------------------------------","dotted" => "....................................................................................................\n","shortdotted" => " ...................."); } $loaded = loadquest($pollfilename); /* echo ("<pre>"); print_r($loaded); echo ("</pre>"); */ if (strlen($loaded[title])>0) { $output .= $loaded[title] . "\n\n"; } if (strlen($loaded[introduction])>0) { $output .= $loaded[introduction] . "\n\n"; } $typearray = array("single","multi","smallbox","bigbox"); $newtypearray = array("Please tick one option","Please tick all that apply","Please write your answer in the space below","Please write your answer in the space below"); for ($a=0;$a<count($loaded);$a++) { if (strlen($loaded[$a])>0) { $output .= $loaded[$a][questionid] . ". " . $loaded[$a][questiontext] . "\n\n"; $output .= str_replace($typearray,$newtypearray,$loaded[$a][type]) . "\n\n"; if ($loaded[$a][type] == "multi" || $loaded[$a][type] == "single") { foreach($loaded[$a][options] as $v) { if ($v == "other_specify") { $output .= "Other (please specify)" . $boxesarray[shortdotted] ."\n"; } else { $output .= $boxesarray[box] . $v . "\n"; } } } else { $testoptions = implode("\n",$loaded[$a][options]); if (strlen($testoptions)>0) { $output .= "(" . $testoptions . ")\n"; } $output .= $boxesarray[dotted]; } $output .= "\n\n"; } } return(array($output,$loaded[title])); } function savePoll($id,$pollarray) { // save a poll datafile and confirm // two 'templates' used to define the datafile structure: $polldatatemplate = " <questionnaire> <id>%id%</id> <title>%title% %creator% %introduction% %questions% %date% "; $pollanswertemplate = " %q_id% %q_type% %q_validation% %q_text% %q_options% "; for ($a=0;$a0) { $answertemp = $pollanswertemplate; $answertemp = str_replace("%q_id%",$pollarray[$a][questionid],$answertemp); $answertemp = str_replace("%q_type%",$pollarray[$a][type],$answertemp); $answertemp = str_replace("%q_validation%",$pollarray[$a][validation],$answertemp); $answertemp = str_replace("%q_text%",$pollarray[$a][questiontext],$answertemp); $answertemp = str_replace("%q_options%",$pollarray[$a][options],$answertemp); $outputchunk .= $answertemp; } } $outputfile = $polldatatemplate; $outputfile = str_replace("%id%",$pollarray[id],$outputfile); $outputfile = str_replace("%title%",$pollarray[title],$outputfile); $outputfile = str_replace("%date%",$pollarray[date],$outputfile); $outputfile = str_replace("%creator%",$pollarray[creator],$outputfile); $outputfile = str_replace("%template%",$pollarray[template],$outputfile); $outputfile = str_replace("%introduction%",$pollarray[introduction],$outputfile); $outputfile = str_replace("%questions%",$outputchunk,$outputfile); // save file to disk $filename = "surveys/quest_" . $id . ".xml"; $open = fopen ($filename, "w+"); if ($open) { fwrite ($open, $outputfile); fclose ($open); return (true); } else { die("

Unable to save changes to questionnaire data file.

"); } } function saveResponse($surveyid,$responsearray) { $output = date("d-M-Y H:i" . "\t"); $dodgy = array("\r","\t","\n"); foreach ($responsearray as $k => $v) { if (is_array($v)) { $tempresponse = implode(",",$v); } else { $tempresponse = str_replace($dodgy," ",$v); } $output .= $tempresponse . "\t"; } $output = substr($output,0,-1) . "\n"; // save file to disk $filename = "surveys/data_" . $surveyid . ".dat"; $open = fopen ($filename, "a+"); if ($open) { fwrite ($open, $output); fclose ($open); return (true); } else { die("

Unable to save response data to file.

"); } } function makeQuestionnaireMenu($dir="surveys/") { if ($handle = opendir($dir)) { // specify questionnaire directory //$excludedfiles = array('functions.inc','.','..','upload.php','fileupload.class'); while (false !== ($file = readdir($handle))) { //if (!in_array($file,$excludedfiles)) { if (substr($file,-3) == "xml") { // only find XML files in the directory $file_id_key = substr($file,6,-4); $filemenuarray[$file_id_key] = 'surveys/' . $file; } } closedir($handle); } krsort($filemenuarray); if (strlen($filemenuarray)>0) { foreach($filemenuarray as $k => $v) { if (file_exists($v)) { $polldata = implode("",file($v)); preg_match_all("/(.*?)<\/title>/si",$polldata,$poll_title); $filemenuarray[$k] = trim($poll_title[1][0]); } } } $filemenu = "<select name=\"surveyid\">"; if (strlen($filemenuarray)>0) { foreach($filemenuarray as $k => $v) { if (strlen($v)>0) { $filemenu .= "<option value=\"$k\">$v</option>\n"; } } } $filemenu .= "</select>"; return($filemenu); } function makeTemplateMenu($dir="templates/",$selected="Default",$menuname="templatename") { if (strlen(trim($selected))<1) { // quick hack to ensure Default is selected if blank $selected = "Default"; } if ($handle = opendir($dir)) { // specify template directory //$excludedfiles = array('functions.inc','.','..','upload.php','fileupload.class'); while (false !== ($file = readdir($handle))) { //if (!in_array($file,$excludedfiles)) { if (substr($file,-3) == "php") { // only find PHP files in the directory $filemenuarray[] = str_replace(".php","",$file); } } closedir($handle); } sort($filemenuarray); $filemenu = "<select name=\"{$menuname}\">"; if (strlen($filemenuarray)>0) { foreach($filemenuarray as $v) { if (strlen($v)>0) { if ($v == $selected) { $filemenu .= "<option value=\"$v\" selected=\"selected\">$v</option>\n"; } else { $filemenu .= "<option value=\"$v\">$v</option>\n"; } } } } $filemenu .= "</select>"; return($filemenu); } function getNextId($dir="surveys/") { if ($handle = opendir($dir)) { // specify questionnaire directory //$excludedfiles = array('functions.inc','.','..','upload.php','fileupload.class'); while (false !== ($file = readdir($handle))) { //if (!in_array($file,$excludedfiles)) { if (substr($file,-3) == "xml") { // only find XML files in the directory $file_id_key = substr($file,6,-4); $filemenuarray[$file_id_key] = 'surveys/' . $file; } } closedir($handle); } ksort($filemenuarray); end($filemenuarray); $lastid = key($filemenuarray); return($lastid+1); } function loadFile($destination,$charstostrip="") { if (file_exists($destination)) { $open = fopen($destination,"r"); if ($open) { $output = file($destination); if (count($output)>0) { $output = implode("",$output); } $output = str_replace($charstostrip,"",$output); fclose($open); return ($output); } else { die("Unable to load file from \"$destination\""); } } else { die("Unable to load file"); } } function saveFile($destination,$content) { if (ini_get('magic_quotes_gpc')) { $content = stripslashes($content); } $open = fopen($destination, "w+"); if ($open) { fwrite ($open, $content); fclose ($open); } else { die("Unable to save file"); } return (true); } function cleanUpTemp($dir="surveys/temp/",$id) { if ($handle = opendir($dir)) { // specify temp files directory $excludedfiles = array('.','..'); while (false !== ($file = readdir($handle))) { if (!in_array($file,$excludedfiles)) { if (substr($file,-3) == "dat" && substr($file,0,4) == "temp" && substr($file,5,1) == $id) { // only find temp and .dat files for specified project in the directory $deleted_temp[] = $file; $filetodel = $dir . $file; unlink($filetodel); } } } closedir($handle); } return($deleted_temp); } $notesbox = " <div id=\"notes\" class=\"clearbox\"> <h4><img src=\"includes/info.jpg\" width=\"15\" height=\"15\" alt=\"\" /> Notes</h4> <p>To delete a question, leave the question text box blank and save changes.</p> <p>To include 'Other (please specify)' and a text box as a response option in a list, enter <code>other_specify</code> in the list of responses.</p> <p>Explanation of question types:<br /> <strong>Single</strong>: a question with a list of options from which respondents can choose one<br /> <strong>Multi</strong>: a question with a list of options (tick boxes) from which a respondent can choose as many as apply<br /> <strong>Smallbox</strong>: a one-line text box for short written answers<br /> <strong>Bigbox</strong>: a multi-line text box with scroll bar for longer written answers</p> <p>Validation:<br /> To ensure respondents enter a response to a text question (a smallbox or bigbox), you can define a question as 'required'. This will present an on-screen message to respondents alerting them that an answer is required. </p> </div>"; ?><br /> <b>Fatal error</b>: Call to undefined function loadquest() in <b>/home/prestong/public_html/clipboard/survey.php</b> on line <b>320</b><br />