'assessment.pstpl'); $files[]=array('name'=>'clearall.pstpl'); $files[]=array('name'=>'completed.pstpl'); $files[]=array('name'=>'endgroup.pstpl'); $files[]=array('name'=>'endpage.pstpl'); $files[]=array('name'=>'groupdescription.pstpl'); $files[]=array('name'=>'load.pstpl'); $files[]=array('name'=>'navigator.pstpl'); $files[]=array('name'=>'printanswers.pstpl'); $files[]=array('name'=>'privacy.pstpl'); $files[]=array('name'=>'question.pstpl'); $files[]=array('name'=>'register.pstpl'); $files[]=array('name'=>'save.pstpl'); $files[]=array('name'=>'surveylist.pstpl'); $files[]=array('name'=>'startgroup.pstpl'); $files[]=array('name'=>'startpage.pstpl'); $files[]=array('name'=>'survey.pstpl'); $files[]=array('name'=>'welcome.pstpl'); $files[]=array('name'=>'print_survey.pstpl'); $files[]=array('name'=>'print_group.pstpl'); $files[]=array('name'=>'print_question.pstpl'); //Standard CSS Files //These files may be edited or saved $cssfiles[]=array('name'=>'template.css'); $cssfiles[]=array('name'=>'template-rtl.css'); $cssfiles[]=array('name'=>'ie_fix_6.css'); $cssfiles[]=array('name'=>'ie_fix_7.css'); $cssfiles[]=array('name'=>'ie_fix_8.css'); $cssfiles[]=array('name'=>'print_template.css'); $cssfiles[]=array('name'=>'template.js'); //Standard Support Files //These files may be edited or saved $supportfiles[]=array('name'=>'print_img_radio.png'); $supportfiles[]=array('name'=>'print_img_checkbox.png'); //Standard screens //Only these may be viewed $screens[]=array('name'=>$clang->gT('Survey List Page'),'id'=>'surveylist'); $screens[]=array('name'=>$clang->gT('Welcome Page'),'id'=>'welcome'); $screens[]=array('name'=>$clang->gT('Question Page'),'id'=>'question'); $screens[]=array('name'=>$clang->gT('Completed Page'),'id'=>'completed'); $screens[]=array('name'=>$clang->gT('Clear All Page'),'id'=>'clearall'); $screens[]=array('name'=>$clang->gT('Register Page'),'id'=>'register'); $screens[]=array('name'=>$clang->gT('Load Page'),'id'=>'load'); $screens[]=array('name'=>$clang->gT('Save Page'),'id'=>'save'); $screens[]=array('name'=>$clang->gT('Print answers page'),'id'=>'printanswers'); $screens[]=array('name'=>$clang->gT('Printable survey page'),'id'=>'printablesurvey'); //Page display blocks $SurveyList=array('startpage.pstpl', 'surveylist.pstpl', 'endpage.pstpl' ); $Welcome=array('startpage.pstpl', 'welcome.pstpl', 'privacy.pstpl', 'navigator.pstpl', 'endpage.pstpl' ); $Question=array('startpage.pstpl', 'survey.pstpl', 'startgroup.pstpl', 'groupdescription.pstpl', 'question.pstpl', 'endgroup.pstpl', 'navigator.pstpl', 'endpage.pstpl' ); $CompletedTemplate=array( 'startpage.pstpl', 'assessment.pstpl', 'completed.pstpl', 'endpage.pstpl' ); $Clearall=array('startpage.pstpl', 'clearall.pstpl', 'endpage.pstpl' ); $Register=array('startpage.pstpl', 'survey.pstpl', 'register.pstpl', 'endpage.pstpl' ); $Save=array('startpage.pstpl', 'save.pstpl', 'endpage.pstpl' ); $Load=array('startpage.pstpl', 'load.pstpl', 'endpage.pstpl' ); $printtemplate=array('startpage.pstpl', 'printanswers.pstpl', 'endpage.pstpl' ); $printablesurveytemplate=array('print_survey.pstpl', 'print_group.pstpl', 'print_question.pstpl' ); // Set this so common.php doesn't throw notices about undefined variables $thissurvey['active']='N'; $file_version="LimeSurvey template editor ".$versionnumber; $_SESSION['s_lang']=$_SESSION['adminlang']; if (!isset($templatename)) {$templatename = sanitize_paranoid_string(returnglobal('templatename'));} if (!isset($templatedir)) {$templatedir = sanitize_paranoid_string(returnglobal('templatedir'));} if (!isset($editfile)) {$editfile = sanitize_filename(returnglobal('editfile'));} if (!isset($screenname)) {$screenname=auto_unescape(returnglobal('screenname'));} // Checks if screen name is in the list of allowed screen names if ( isset($screenname) && (multiarray_search($screens,'id',$screenname)===false)) {die('Invalid screen name');} // Die you sneaky bastard! if (!isset($action)) {$action=sanitize_paranoid_string(returnglobal('action'));} if (!isset($subaction)) {$subaction=sanitize_paranoid_string(returnglobal('subaction'));} if (!isset($otherfile)) {$otherfile = sanitize_filename(returnglobal('otherfile'));} if (!isset($newname)) {$newname = sanitize_paranoid_string(returnglobal('newname'));} if (!isset($copydir)) {$copydir = sanitize_paranoid_string(returnglobal('copydir'));} if(is_file($usertemplaterootdir.'/'.$templatename.'/question_start.pstpl')) { $files[]=array('name'=>'question_start.pstpl'); $Question[]='question_start.pstpl'; } $js_admin_includes[]= $homeurl."/scripts/edit_area/edit_area_loader.js"; $js_admin_includes[]= $homeurl."/scripts/templates.js"; // find out language for code editor $availableeditorlanguages=array('bg','cs','de','dk','en','eo','es','fi','fr','hr','it','ja','mk','nl','pl','pt','ru','sk','zh'); $extension = substr(strrchr($editfile, "."), 1); if ($extension=='css' || $extension=='js') {$highlighter=$extension;} else {$highlighter='html';}; if(in_array($_SESSION['adminlang'],$availableeditorlanguages)) {$codelanguage=$_SESSION['adminlang'];} else {$codelanguage='en';} if (isset ($_POST['changes'])) { $changedtext=$_POST['changes']; $changedtext=str_replace ('Execute($templatequery) or safe_die ("Couldn't update surveys with default template!
\n$utquery
\n".$connect->ErrorMsg()); //Checked $templatequery = "UPDATE {$dbprefix}surveys set template='$defaulttemplate' where template='$templatename'\n"; $connect->Execute($templatequery) or safe_die ("Couldn't update surveys with default template!
\n$utquery
\n".$connect->ErrorMsg()); //Checked $templatequery = "delete from {$dbprefix}templates_rights where folder='$templatename'\n"; $connect->Execute($templatequery) or safe_die ("Couldn't update template_rights
\n$utquery
\n".$connect->ErrorMsg()); //Checked $templatequery = "delete from {$dbprefix}templates where folder='$templatename'\n"; $connect->Execute($templatequery) or safe_die ("Couldn't update templates
\n$utquery
\n".$connect->ErrorMsg()); //Checked $flashmessage=sprintf($clang->gT("Template '%s' was successfully deleted."),$templatename); unset($templates[$templatename]); $templatename = $defaulttemplate; } else { $flashmessage=sprintf($clang->gT("There was a problem deleting the template '%s'. Please check your directory/file permissions."),$templatename); } } if ($action == "templateupload") { include("import_resources_zip.php"); } //Save Changes if necessary if ($action=="templatesavechanges" && $changedtext) { $changedtext=str_replace("\r\n", "\n", $changedtext); if ($editfile) { // Check if someone tries to submit a file other than one of the allowed filenames if (multiarray_search($files,'name',$editfile)===false && multiarray_search($cssfiles,'name',$editfile)===false) {die('Invalid template filename');} // Die you sneaky bastard! $savefilename=$usertemplaterootdir."/".$templatename."/".$editfile; if (is_writable($savefilename)) { if (!$handle = fopen($savefilename, 'w')) { echo "Could not open file ($savefilename)"; exit; } if (!fwrite($handle, $changedtext)) { echo "Cannot write to file ($savefilename)"; exit; } fclose($handle); } else { echo "The file $savefilename is not writable"; } } } if ($action == "templatecopy" && isset($newname) && isset($copydir)) { //Copies all the files from one template directory to a new one //This is a security issue because it is allowing copying from get variables... $newdirname=$usertemplaterootdir."/".$newname; $copydirname=sGetTemplatePath($copydir); $mkdirresult=mkdir_p($newdirname); if ($mkdirresult == 1) { $copyfiles=getListOfFiles($copydirname); foreach ($copyfiles as $file) { $copyfile=$copydirname."/".$file; $newfile=$newdirname."/".$file; if (!copy($copyfile, $newfile)) { echo ""; } } $templates[$newname]=$newdirname; $templatename=$newname; } elseif($mkdirresult == 2) { echo ""; } else { echo ""; } } if ($action == "templaterename" && isset($newname) && isset($copydir)) { $newdirname=$usertemplaterootdir."/".$newname; $olddirname=$usertemplaterootdir."/".$copydir; if(isStandardTemplate($newname)) { echo ""; } elseif (rename($olddirname, $newdirname)==false) { echo ""; } else { $templates[$newname]=$newdirname; $templatename=$newname; } } if ($action == "templateuploadfile") { if ($demoModeOnly == true) { $action = ''; } else { $the_full_file_path = $usertemplaterootdir."/".$templatename . "/" . sanitize_filename($_FILES['the_file']['name']); if ($extfile = strrchr($_FILES['the_file']['name'], '.')) { if (!(stripos(','.$allowedtemplateuploads.',',','. substr($extfile,1).',') === false)) { //Uploads the file into the appropriate directory if (!@move_uploaded_file($_FILES['the_file']['tmp_name'], $the_full_file_path)) { echo "".$clang->gT("Error")."
\n"; echo sprintf ($clang->gT("An error occurred uploading your file. This may be caused by incorrect permissions in your %s folder."),$tempdir)."

\n"; echo "\n"; echo "\n"; echo "\n\n"; exit; } } else { // if we came here is because the file extention is not allowed @unlink($_FILES['the_file']['tmp_name']); echo "".$clang->gT("Error")."
\n"; echo $clang->gT("This file type is not allowed to be uploaded.")."

\n"; echo "\n"; echo "\n"; echo "\n\n"; exit; } } else { // if we came here is because the file extention is not allowed @unlink($_FILES['the_file']['tmp_name']); echo "".$clang->gT("Error")."
\n"; echo $clang->gT("This file type is not allowed to be uploaded.")."

\n"; echo "\n"; echo "\n"; echo "\n\n"; exit; } } } if ($action == "templatefiledelete") { $the_full_file_path = $usertemplaterootdir."/".$templatename."/".$otherfile; //This is where the temp file is unlink($the_full_file_path); } if ($action == "templatezip") { require("classes/phpzip/phpzip.inc.php"); $z = new PHPZip(); $templatedir=sGetTemplatePath($templatename).DIRECTORY_SEPARATOR; $zipfile="$tempdir/$templatename.zip"; $z -> Zip($templatedir, $zipfile); if (is_file($zipfile)) { //Send the file for download! header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header( "Content-Disposition: attachment; filename=$templatename.zip" ); header( "Content-Description: File Transfer"); @readfile($zipfile); //Delete the temporary file unlink($zipfile); } } $normalfiles=array("DUMMYENTRY", ".", "..", "preview.png"); foreach ($files as $fl) { $normalfiles[]=$fl["name"]; } foreach ($cssfiles as $fl) { $normalfiles[]=$fl["name"]; } //CHECK ALL FILES EXIST, AND IF NOT - COPY IT FROM DEFAULT DIRECTORY foreach ($files as $file) { $thisfile=sGetTemplatePath($templatename)."/".$file['name']; if (!is_file($thisfile)) { $copyfile="$standardtemplaterootdir/default/".$file['name']; $newfile=$thisfile; if (!@copy($copyfile, $newfile)) { echo ""; } } } //CHECK if ALL CSS & JS FILES EXIST, AND IF NOT - COPY IT FROM DEFAULT DIRECTORY foreach ($cssfiles as $file) { $thisfile=sGetTemplatePath($templatename)."/".$file['name']; if (!is_file($thisfile)) { $copyfile="$standardtemplaterootdir/default/".$file['name']; $newfile=$thisfile; if (!@copy($copyfile, $newfile)) { echo ""; } } } //CHECK IF REQUIRED SUPPORT FILE EXIST, AND IF NOT - COPY IT FROM DEFAULT DIRECTORY foreach($supportfiles as $file) { $thisfile=sGetTemplatePath($templatename)."/".$file['name']; if (!is_file($thisfile)) { $copyfile="$standardtemplaterootdir/default/".$file['name']; $newfile=$thisfile; if (!@copy($copyfile, $newfile)) { echo ""; } } } if (!$screenname) {$screenname='welcome';} if ($screenname != 'welcome') {$_SESSION['step']=1;} else {unset($_SESSION['step']);} //This helps handle the load/save buttons // =========================== FAKE DATA FOR TEMPLATES $thissurvey['name']=$clang->gT("Template Sample"); $thissurvey['description']=$clang->gT('This is a sample survey description. It could be quite long.').'

'.$clang->gT("But this one isn't."); $thissurvey['welcome']=$clang->gT('Welcome to this sample survey').'
'.$clang->gT('You should have a great time doing this').'
'; $thissurvey['allowsave']="Y"; $thissurvey['active']="Y"; $thissurvey['tokenanswerspersistence']="Y"; $thissurvey['templatedir']=$templatename; $thissurvey['format']="G"; $thissurvey['surveyls_url']="http://www.limesurvey.org/"; $thissurvey['surveyls_urldescription']=$clang->gT("Some URL description"); $thissurvey['usecaptcha']="A"; $percentcomplete=makegraph(6, 10); $groupname=$clang->gT("Group 1: The first lot of questions"); $groupdescription=$clang->gT("This group description is fairly vacuous, but quite important."); $navigator="gT('Next').">>\" name=\"move\" />\n"; if ($screenname != 'welcome') {$navigator = "gT('Previous')."\" name=\"move\" />\n".$navigator;} $help=$clang->gT("This is some help text."); $totalquestions="10"; $surveyformat="Format"; $completed = "
".$clang->gT("Thank you!")."

" .$clang->gT("Your survey responses have been recorded.")."

\n"; $notanswered="5"; $privacy=""; $surveyid="1295"; $token=1234567; $assessments="
".$clang->gT("Assessment heading")."
".$clang->gT("Assessment details")."
".$clang->gT("Note that this assessment section will only show if assessment rules have been set and assessment mode is activated.")."
"; $printoutput="".$clang->gT("Survey name (ID)")." Test survey (46962)
".$clang->gT("Question")."".$clang->gT("Your answer")."
id 12
Date Submitted 1980-01-01 00:00:00
This is a sample question text. The user was asked to enter a date. 2007-11-06
This is another sample question text - asking for number. 666
This is one last sample question text - asking for some free text. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
"; $addbr=false; $templatedir=sGetTemplatePath($templatename); $templateurl=sGetTemplateURL($templatename); switch($screenname) { case 'surveylist': unset($files); $list[]="
  • Survey Number 1
  • \n"; $list[]="
  • Survey Number 2
  • \n"; $surveylist=array( "nosid"=>$clang->gT("You have not provided a survey identification number"), "contact"=>sprintf($clang->gT("Please contact %s ( %s ) for further assistance."),$siteadminname,$siteadminemail), "listheading"=>$clang->gT("The following surveys are available:"), "list"=>implode("\n",$list), ); $myoutput[]=""; foreach ($SurveyList as $qs) { $files[]=array("name"=>$qs); $myoutput = array_merge($myoutput, doreplacement(sGetTemplatePath($templatename)."/$qs")); } break; case 'question': unset($files); foreach ($Question as $qs) { $files[]=array("name"=>$qs); } $myoutput[]="\n"; $myoutput[]="\n"; $myoutput[]="\n"; $myoutput[]="\n"; $myoutput[]="\n"; $myoutput = array_merge($myoutput, doreplacement(sGetTemplatePath($templatename)."/startpage.pstpl")); $myoutput = array_merge($myoutput, doreplacement(sGetTemplatePath($templatename)."/survey.pstpl")); $myoutput = array_merge($myoutput, doreplacement(sGetTemplatePath($templatename)."/startgroup.pstpl")); $myoutput = array_merge($myoutput, doreplacement(sGetTemplatePath($templatename)."/groupdescription.pstpl")); $question = array( 'all' => 'How many roads must a man walk down?' ,'text' => 'How many roads must a man walk down?' ,'code' => '1a' ,'help' => 'helpful text' ,'mandatory' => '' ,'man_message' => '' ,'valid_message' => '' ,'file_valid_message' => '' ,'essentials' => 'id="question1"' ,'class' => 'list-radio' ,'man_class' => '' ,'input_error_class' => '' ,'number' => '1' ); $answer="\n"; $myoutput = array_merge($myoutput, doreplacement(sGetTemplatePath($templatename)."/question.pstpl")); // $question='*'.$clang->gT("Please explain something in detail:"); $answer=""; $question = array( 'all' => '*'.$clang->gT("Please explain something in detail:") ,'text' => $clang->gT('Please explain something in detail:') ,'code' => '2a' ,'help' => '' ,'mandatory' => $clang->gT('*') ,'man_message' => '' ,'valid_message' => '' ,'file_valid_message' => '' ,'essentials' => 'id="question2"' ,'class' => 'text-long' ,'man_class' => ' mandatory' ,'input_error_class' => '' ,'number' => '2' ); $myoutput = array_merge($myoutput, doreplacement(sGetTemplatePath($templatename)."/question.pstpl")); $myoutput = array_merge($myoutput, doreplacement(sGetTemplatePath($templatename)."/endgroup.pstpl")); $myoutput = array_merge($myoutput, doreplacement(sGetTemplatePath($templatename)."/navigator.pstpl")); $myoutput = array_merge($myoutput, doreplacement(sGetTemplatePath($templatename)."/endpage.pstpl")); break; case 'welcome': unset($files); $myoutput[]=""; foreach ($Welcome as $qs) { $files[]=array("name"=>$qs); $myoutput = array_merge($myoutput, doreplacement(sGetTemplatePath($templatename)."/$qs")); } break; case 'register': unset($files); foreach($Register as $qs) { $files[]=array("name"=>$qs); } foreach(file("$templatedir/startpage.pstpl") as $op) { $myoutput[]=templatereplace($op); } foreach(file("$templatedir/survey.pstpl") as $op) { $myoutput[]=templatereplace($op); } foreach(file("$templatedir/register.pstpl") as $op) { $myoutput[]=templatereplace($op); } foreach(file("$templatedir/endpage.pstpl") as $op) { $myoutput[]=templatereplace($op); } $myoutput[]= "\n"; break; case 'save': unset($files); foreach($Save as $qs) { $files[]=array("name"=>$qs); } foreach(file("$templatedir/startpage.pstpl") as $op) { $myoutput[]=templatereplace($op); } foreach(file("$templatedir/save.pstpl") as $op) { $myoutput[]=templatereplace($op); } foreach(file("$templatedir/endpage.pstpl") as $op) { $myoutput[]=templatereplace($op); } $myoutput[]= "\n"; break; case 'load': unset($files); foreach($Load as $qs) { $files[]=array("name"=>$qs); } foreach(file("$templatedir/startpage.pstpl") as $op) { $myoutput[]=templatereplace($op); } foreach(file("$templatedir/load.pstpl") as $op) { $myoutput[]=templatereplace($op); } foreach(file("$templatedir/endpage.pstpl") as $op) { $myoutput[]=templatereplace($op); } $myoutput[]= "\n"; break; case 'clearall': unset($files); foreach ($Clearall as $qs) { $files[]=array("name"=>$qs); } foreach(file("$templatedir/startpage.pstpl") as $op) { $myoutput[]=templatereplace($op); } foreach(file("$templatedir/clearall.pstpl") as $op) { $myoutput[]=templatereplace($op); } foreach(file("$templatedir/endpage.pstpl") as $op) { $myoutput[]=templatereplace($op); } $myoutput[]= "\n"; break; case 'completed': unset($files); $myoutput[]=""; foreach ($CompletedTemplate as $qs) { $files[]=array("name"=>$qs); $myoutput = array_merge($myoutput, doreplacement(sGetTemplatePath($templatename)."/$qs")); } break; case 'printablesurvey': unset($files); foreach ($printablesurveytemplate as $qs) { $files[]=array("name"=>$qs); } $questionoutput=array(); foreach(file("$templatedir/print_question.pstpl") as $op) { // echo '
    line '.__LINE__.'$op = '.htmlspecialchars(print_r($op)).'
    '; $questionoutput[]=templatereplace($op, array( 'QUESTION_NUMBER'=>'1', 'QUESTION_CODE'=>'Q1', 'QUESTION_MANDATORY' => $clang->gT('*'), 'QUESTION_SCENARIO' => 'Only answer this if certain conditions are met.', // if there are conditions on a question, list the conditions. 'QUESTION_CLASS' => ' mandatory list-radio', 'QUESTION_TYPE_HELP' => $clang->gT('Please choose *only one* of the following:'), 'QUESTION_MAN_MESSAGE' => '', // (not sure if this is used) mandatory error 'QUESTION_VALID_MESSAGE' => '', // (not sure if this is used) validation error 'QUESTION_FILE_VALID_MESSAGE' => '', // (not sure if this is used) file validation error 'QUESTION_TEXT'=>'This is a sample question text. The user was asked to pick an entry.', 'QUESTIONHELP'=>'This is some help text for this question.', 'ANSWER'=>'' )); } $groupoutput=array(); foreach(file("$templatedir/print_group.pstpl") as $op) { $groupoutput[]=templatereplace($op, array('QUESTIONS'=>implode(' ',$questionoutput))); } foreach(file("$templatedir/print_survey.pstpl") as $op) { $myoutput[]=templatereplace($op, array('GROUPS'=>implode(' ',$groupoutput), 'FAX_TO' => $clang->gT("Please fax your completed survey to:")." 000-000-000", 'SUBMIT_TEXT'=> $clang->gT("Submit your survey."), 'HEADELEMENTS'=>getPrintableHeader(), 'SUBMIT_BY' => sprintf($clang->gT("Please submit by %s"), date('d.m.y')), 'THANKS'=>$clang->gT('Thank you for completing this survey.'), 'END'=>$clang->gT('This is the survey end message.') )); } break; case 'printanswers': unset($files); foreach ($printtemplate as $qs) { $files[]=array("name"=>$qs); } foreach(file("$templatedir/startpage.pstpl") as $op) { $myoutput[]=templatereplace($op); } foreach(file("$templatedir/printanswers.pstpl") as $op) { $myoutput[]=templatereplace($op,array('ANSWERTABLE'=>$printoutput)); } foreach(file("$templatedir/endpage.pstpl") as $op) { $myoutput[]=templatereplace($op); } $myoutput[]= "\n"; break; } $myoutput[]=""; if (is_array($files)) { $match=0; foreach ($files as $f) { if ($editfile == $f["name"]) { $match=1; } } foreach ($cssfiles as $f) { if ($editfile == $f["name"]) { $match=1; } } if ($match == 0) { if (count($files) > 0) { $editfile=$files[0]["name"]; } else { $editfile=""; } } } //Get list of 'otherfiles' $otherfiles=array(); if ($handle = opendir($templatedir)) { while(false !== ($file = readdir($handle))) { if (!array_search($file, $normalfiles)) { if (!is_dir($templatedir.DIRECTORY_SEPARATOR.$file)) { $otherfiles[]=array("name"=>$file); } } } // while closedir($handle); } //**************************************************************** //** OUTPUT STARTS HERE //**************************************************************** $templatesoutput = "\n"; $templatesoutput.= "\n"; $templatesoutput.= "\n" ."  "; //CSS Firefox 2 transition fix //TEMPLATE DETAILS $templatesoutput.= "\t\n" ."

     

    "; //CSS Firefox 2 transition fix if ($subaction=='templateupload') { $ZIPimportAction = " onclick='if (validatefilename(this.form,\"".$clang->gT('Please select a file to import!','js')."\")) {this.form.submit();}'"; if (!function_exists("zip_open")) { $ZIPimportAction = " onclick='alert(\"".$clang->gT("zip library not supported by PHP, Import ZIP Disabled","js")."\");'"; } $templatesoutput.= "
    ".$clang->gT("Uploaded template file") ."
    \n"; $templatesoutput.= "\t
    \n" . "\t\n" . "\t\n" . "\t
    \n"; } elseif (isset($importtemplateoutput)) { $templatesoutput.=$importtemplateoutput; } else { //FILE CONTROL DETAILS if (is_template_editable($templatename)==true) { $templatesoutput.= "\t\n" ."\t\n" ."\n" ."\t\n" ."\t" .""; $templatesoutput.= "\n"; $templatesoutput.="\n" ."\n" ."\n" ."" ."\n" ."\t\n" //."
    \n" ."\t".sprintf($clang->gT("Editing template '%s' - File '%s'"),$templatename,$editfile)."\n" ."
    " .$clang->gT("Standard Files:")."\n" ."
    \n" ."\t\n" ."\t\n" ."\t\n" ."\t\n" ."
    \n"; if (is_writable($templates[$templatename])) { $templatesoutput.= "gT("Changes cannot be saved to a standard template.")."'"; } $templatesoutput.= " />"; } else { $templatesoutput.=''.$clang->gT("You can't save changes because the template directory is not writable.").''; } $templatesoutput.= "
    \n" ."
    ".$clang->gT("Other Files:")."


    \n" .$clang->gT("CSS & Javascript files:") ."
    \n" ."
    " ."\n" . "" ."
    " ."
    " ."gT("Are you sure you want to delete this file?","js")."')\""; if (!is_template_editable($templatename)) { $templatesoutput.= " style='color: #BBBBBB;' disabled='disabled' alt='".$clang->gT("Files in a standard template cannot be deleted.")."'"; } $templatesoutput.= " />\n" ."\n" ."\n" ."\n" . "
    " ."
    \n" ."
    \n" .$clang->gT("Upload a file:")."

    " ."\n" ."\n" ."\n" ."\n" ."
    \n" ."
    \n" //."\t\n" //."\t" .""; } //SAMPLE ROW $templatesoutput.= "\t
    \n" . "\t".$clang->gT("Preview:")."\n" . "\t\n" . "\t\n" . "\t\n" . "\t\n" . "\t\n" . "
    \n" ."
    \n"; // The following lines are forcing the browser to refresh the templates on each save $time=date("ymdHis"); @$fnew=fopen("$tempdir/template_temp_$time.html", "w+"); if(!$fnew) { $templatesoutput.= "

    \n"."".sprintf($clang->gT("Please change the directory permissions of the folder %s in order to preview templates."), $tempdir)."" ."

    \n"; } else { @fwrite ($fnew, getHeader()); foreach ($cssfiles as $cssfile) { $myoutput=str_replace($cssfile['name'],$cssfile['name']."?t=$time",$myoutput); } foreach($myoutput as $line) { @fwrite($fnew, $line); } @fclose($fnew); $langdir_template="$publicurl/locale/".$_SESSION['adminlang']."/help"; $templatesoutput.= "

    \n"."\n" ."\n"; } } function doreplacement($file) { //Produce sample page from template file $output=array(); foreach(file($file) as $op) { $output[]=templatereplace($op); } return $output; } function getListOfFiles($wh){ //Returns an array containing all files in a directory if ($handle = opendir($wh)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && !is_dir($file)) { if(!isset($files) || !$files) $files="$file"; else $files="$file\n$files"; } } closedir($handle); } $arr=explode("\n",$files); sort($arr); return $arr; } function textarea_encode($html_code) { $from = array('<', '>'); $to = array('<', '>'); $html_code = str_replace($from, $to, $html_code); return $html_code; } //Load this editfile function filetext($templatename,$templatefile) { global $templates; $sFileName=$templates[$templatename].'/'.$templatefile; if (file_exists($sFileName)) { return file_get_contents($sFileName); } else { return ''; } } function makegraph($currentstep, $total) { global $thissurvey; global $publicurl, $clang; $size = intval(($currentstep-1)/$total*100); $graph = '

    '.sprintf($clang->gT('You have completed %s%% of this survey'),$size).'
    '; if (getLanguageRTL($clang->langcode)) { $graph.='100%'; } else { $graph.='0%'; } $graph.='
    '; if (getLanguageRTL($clang->langcode)) { $graph.='0%'; } else { $graph.='100%'; } $graph.='
    '; if ($size == 0) // Progress bar looks dumb if 0 { $graph.=' '; } return $graph; } function mkdir_p($target){ //creates a new directory //Returns 1 for success // 2 for "directory/file by that name exists // 0 for other errors if(file_exists($target) || is_dir($target)) return 2; if(mkdir($target,0777)){ return 1; } if(mkdir_p(substr($target, 0, (strrpos($target, '/')))) == 1){ if(mkdir_p($target) == 1) return 1; else return 0; } else { return 0; } } function makeoptions($array, $value, $text, $selectedvalue) { $return=''; foreach ($array as $ar) { $return .= "