Example #1
0
    else
    {

        $tokenoutput .= "<div class='messagebox ui-corner-all'>\n"
        . "<div class='header ui-widget-header'>";
        $tokenoutput .= $clang->gT("Sending Reminders")
        ."</div><br />\n";

        $surveylangs = GetAdditionalLanguagesFromSurveyID($surveyid);
        $baselanguage = GetBaseLanguageFromSurveyID($surveyid);
        array_unshift($surveylangs,$baselanguage);

        foreach ($surveylangs as $language)
        {
            $_POST['message_'.$language]=auto_unescape($_POST['message_'.$language]);
            $_POST['subject_'.$language]=auto_unescape($_POST['subject_'.$language]);

        }

        if (isset($starttokenid)) {$tokenoutput .= " (".$clang->gT("From Token ID").":&nbsp;{$starttokenid})";}
        if (isset($tokenid)) {$tokenoutput .= " (".$clang->gT("Sending to Token ID").":&nbsp;{$tokenid})";}
        if (isset($tokenids)) {$tokenoutput .= " (".$clang->gT("Sending to Token IDs").":&nbsp;".implode("|", $tokenids).")";}

        if (isset($_POST['bypassbademails']) && $_POST['bypassbademails'] == 'Y')
        {
            $SQLemailstatuscondition = " AND emailstatus = 'OK'";
        }
        else
        {
            $SQLemailstatuscondition = "";
        }
Example #2
0
}
if (!$column) {
    //NOCOLUMN
    exit;
}
$aColumnNames = $connect->MetaColumnNames("{$dbprefix}survey_{$surveyid}");
if (!isset($aColumnNames[strtoupper($column)])) {
    safe_die('Invalid column name');
}
if ($connect->databaseType == 'odbc_mssql' || $connect->databaseType == 'odbtp' || $connect->databaseType == 'mssql_n' || $connect->databaseType == 'mssqlnative') {
    $query = "SELECT id, " . db_quote_id($column) . " FROM {$dbprefix}survey_{$surveyid} WHERE (" . db_quote_id($column) . " NOT LIKE '')";
} else {
    $query = "SELECT id, " . db_quote_id($column) . " FROM {$dbprefix}survey_{$surveyid} WHERE (" . db_quote_id($column) . " != '')";
}
if ($sql && $sql != "NULL") {
    $query .= " AND " . auto_unescape(urldecode($sql));
}
switch (incompleteAnsFilterstate()) {
    case 'inc':
        //Inclomplete answers only
        $query .= ' AND submitdate is null ';
        break;
    case 'filter':
        //Inclomplete answers only
        $query .= ' AND submitdate is not null ';
        break;
}
if ($order == "alpha") {
    $query .= " ORDER BY " . db_quote_id($column);
} else {
    $query .= " ORDER BY id";
/**
 * This function replaces keywords in a text and is mainly intended for templates
 * If you use this functions put your replacement strings into the $replacements variable
 * instead of using global variables
 * NOTE - Don't do any embedded replacements in this function.  Create the array of replacement values and
 * they will be done in batch at the end
 *
 * @param string $line Text to search in
 * @param array $replacements Array of replacements:  Array( <stringtosearch>=><stringtoreplacewith>, where <stringtosearch> is NOT surrounded with curly braces
 * @param boolean $anonymized Determines if token data is being used or just replaced with blanks
 * @return string  Text with replaced strings
 */
function templatereplace($line, $replacements=array(), $anonymized=false)
{
    global $surveylist, $sitename, $clienttoken, $rooturl;
    global $thissurvey, $imageurl, $defaulttemplate;
    global $percentcomplete, $move;
    global $groupname, $groupdescription;
    global $question;
    global $showXquestions, $showgroupinfo, $showqnumcode;
    global $answer, $navigator;
    global $help, $surveyformat;
    global $completed, $register_errormsg;
    global $privacy, $surveyid;
    global $publicurl, $templatedir, $token;
    global $assessments, $s_lang;
    global $errormsg, $clang;
    global $saved_id;
    global $totalBoilerplatequestions, $relativeurl;
    global $languagechanger;
    global $captchapath, $loadname;

    // lets sanitize the survey template
    if (isset($thissurvey['templatedir']))
    {
        $_templatename = $thissurvey['templatedir'];
    }
    else
    {
        $_templatename = $defaulttemplate;
    }
    $_templatename = validate_templatedir($_templatename);

    // create absolute template URL and template dir vars
    $_templateurl = sGetTemplateURL($_templatename) . '/';
    $templatedir = sgetTemplatePath($_templatename);

    if (stripos($line, "</head>"))
    {
        $line = str_ireplace("</head>",
            "<script type=\"text/javascript\" src=\"$rooturl/scripts/survey_runtime.js\"></script>\n"
                        . use_firebug()
                        . "\t</head>", $line);
    }
    // Get some vars : move elsewhere ?
    // surveyformat
    if (isset($thissurvey['format']))
    {
        $surveyformat = str_replace(array("A", "S", "G"), array("allinone", "questionbyquestion", "groupbygroup"), $thissurvey['format']);
    }
    else
    {
        $surveyformat = "";
    }
    // real survey contact
    if (isset($surveylist['contact']))
    {
        $_surveycontact = $surveylist['contact'];
    }
    elseif (isset($thissurvey['admin']) && $thissurvey['admin'] != "")
    {
        $_surveycontact = sprintf($clang->gT("Please contact %s ( %s ) for further assistance."), $thissurvey['admin'], $thissurvey['adminemail']);
    }
    else
    {
        $_surveycontact = "";
    }

    // If there are non-bracketed replacements to be made do so above this line.
    // Only continue in this routine if there are bracketed items to replace {}
    if (strpos($line, "{") === false)
    {
        return $line;
    }

    if (
        $showgroupinfo == 'both' ||
	    $showgroupinfo == 'name' ||
	    ($showgroupinfo == 'choose' && !isset($thissurvey['showgroupinfo'])) ||
	    ($showgroupinfo == 'choose' && $thissurvey['showgroupinfo'] == 'B') ||
	    ($showgroupinfo == 'choose' && $thissurvey['showgroupinfo'] == 'N')
    )
    {
        $_groupname = $groupname;
    }
    else
    {
        $_groupname = '';
    };
    if (
        $showgroupinfo == 'both' ||
	    $showgroupinfo == 'description' ||
	    ($showgroupinfo == 'choose' && !isset($thissurvey['showgroupinfo'])) ||
	    ($showgroupinfo == 'choose' && $thissurvey['showgroupinfo'] == 'B') ||
	    ($showgroupinfo == 'choose' && $thissurvey['showgroupinfo'] == 'D')
    )
    {
        $_groupdescription = $groupdescription;
    }
    else
    {
        $_groupdescription = '';
    };

    if (is_array($question))
    {
        $_question = $question['all'];
        $_question_text = $question['text'];
        $_question_help = $question['help'];
        $_question_mandatory = $question['mandatory'];
        $_question_man_message = $question['man_message'];
        $_question_valid_message = $question['valid_message'];
        $_question_file_valid_message = $question['file_valid_message'];
        $_question_sgq = (isset($question['sgq']) ? $question['sgq'] : '');
        $_question_essentials = $question['essentials'];
        $_question_class = $question['class'];
        $_question_man_class = $question['man_class'];
        $_question_input_error_class = $question['input_error_class'];
        }
        else
        {
        $_question = $question;
        $_question_text = '';
        $_question_help = '';
        $_question_mandatory = '';
        $_question_man_message = '';
        $_question_valid_message = '';
        $_question_file_valid_message = '';
        $_question_sgq = '';
        $_question_essentials = '';
        $_question_class = '';
        $_question_man_class = '';
        $_question_input_error_class = '';
    };

    if (
        $showqnumcode == 'both' ||
	    $showqnumcode == 'number' ||
	    ($showqnumcode == 'choose' && !isset($thissurvey['showqnumcode'])) ||
	    ($showqnumcode == 'choose' && $thissurvey['showqnumcode'] == 'B') ||
	    ($showqnumcode == 'choose' && $thissurvey['showqnumcode'] == 'N')
    )
    {
        $_question_number = $question['number'];
    }
    else
    {
        $_question_number = '';
    };
    if (
        $showqnumcode == 'both' ||
	    $showqnumcode == 'code' ||
	    ($showqnumcode == 'choose' && !isset($thissurvey['showqnumcode'])) ||
	    ($showqnumcode == 'choose' && $thissurvey['showqnumcode'] == 'B') ||
	    ($showqnumcode == 'choose' && $thissurvey['showqnumcode'] == 'C')
    )
    {
        $_question_code = $question['code'];
    }
    else
    {
        $_question_code = '';
    }

    if (isset($_SESSION['therearexquestions']))
    {
        $_totalquestionsAsked = $_SESSION['therearexquestions'] - $totalBoilerplatequestions;
    }
    else {
        $_totalquestionsAsked = 0;
    }
    if (
      $showXquestions == 'show' ||
      ($showXquestions == 'choose' && !isset($thissurvey['showXquestions'])) ||
      ($showXquestions == 'choose' && $thissurvey['showXquestions'] == 'Y')
    )
    {
        if ($_totalquestionsAsked < 1)
        {
            $_therearexquestions = $clang->gT("There are no questions in this survey"); // Singular
        }
        elseif ($_totalquestionsAsked == 1)
        {
            $_therearexquestions = $clang->gT("There is 1 question in this survey"); //Singular
        }
        else
        {
            $_therearexquestions = $clang->gT("There are {NUMBEROFQUESTIONS} questions in this survey.");    //Note this line MUST be before {NUMBEROFQUESTIONS}
	};
    }
    else
    {
        $_therearexquestions = '';
    };

    if (isset($token))
    {
        $_token = $token;
        }
    elseif (isset($clienttoken))
    {
        $_token = htmlentities($clienttoken, ENT_QUOTES, 'UTF-8');
        }
    else
    {
        $_token = '';
    }

    if (isset($thissurvey['surveyls_dateformat']))
    {
        $dateformatdetails = getDateFormatData($thissurvey['surveyls_dateformat']);
    }
    else {
        $dateformatdetails = getDateFormatData();
    }
    if (isset($thissurvey['expiry']))
    {
        $_datetimeobj = new Date_Time_Converter($thissurvey['expiry'], "Y-m-d");
        $_dateoutput = $_datetimeobj->convert($dateformatdetails['phpdate']);
            }
    else
    {
        $_dateoutput = '-';
            }
    $_submitbutton = "<input class='submit' type='submit' value=' " . $clang->gT("Submit") . " ' name='move2' onclick=\"javascript:document.limesurvey.move.value = 'movesubmit';\" />";
    if (isset($thissurvey['surveyls_url']) and $thissurvey['surveyls_url'] != "")
    {
        if (trim($thissurvey['surveyls_urldescription']) != '')
        {
            $_linkreplace = "<a href='{$thissurvey['surveyls_url']}'>{$thissurvey['surveyls_urldescription']}</a>";
        }
        else
        {
            $_linkreplace = "<a href='{$thissurvey['surveyls_url']}'>{$thissurvey['surveyls_url']}</a>";
    }
    }
    else
    {
        $_linkreplace='';
    }

    if (isset($clienttoken))
    {
        $token = $clienttoken;
    }
    else
    {
        $token = '';
    }

    if (!isset($_SESSION['s_lang']))
    {
        $_s_lang = 'en';
    }
    else
    {
        $_s_lang = $_SESSION['s_lang'];
    }

    $_clearall = "<input type='button' name='clearallbtn' value='" . $clang->gT("Exit and Clear Survey") . "' class='clearall' "
            . "onclick=\"if (confirm('" . $clang->gT("Are you sure you want to clear all your responses?", 'js') . "')) {window.open('{$publicurl}/index.php?sid=$surveyid&amp;move=clearall&amp;lang=" . $_s_lang;
        if (returnglobal('token'))
        {
        $_clearall .= "&amp;token=" . urlencode(trim(sanitize_xss_string(strip_tags(returnglobal('token')))));
        }
        $_clearall .= "', '_self')}\" />";

    if (isset($_SESSION['datestamp']))
    {
        $_datestamp = $_SESSION['datestamp'];
    }
    else
    {
        $_datestamp = '-';
        }
        //Set up save/load feature
    if (isset($thissurvey['allowsave']) and $thissurvey['allowsave'] == "Y")
        {
            // Find out if the user has any saved data

        if ($thissurvey['format'] == 'A')
            {
            if ($thissurvey['tokenanswerspersistence'] != 'Y')
                {
                $_saveall = "\t\t\t<input type='submit' name='loadall' value='" . $clang->gT("Load Unfinished Survey") . "' class='saveall' " . (($thissurvey['active'] != "Y") ? "disabled='disabled'" : "") . "/>"
                        . "\n\t\t\t<input type='button' name='saveallbtn' value='" . $clang->gT("Resume Later") . "' class='saveall' onclick=\"javascript:document.limesurvey.move.value = this.value;addHiddenField(document.getElementById('limesurvey'),'saveall',this.value);document.getElementById('limesurvey').submit();\" " . (($thissurvey['active'] != "Y") ? "disabled='disabled'" : "") . "/>";  // Show Save So Far button
                }
                else
                {
                $_saveall = "\t\t\t<input type='button' name='saveallbtn' value='" . $clang->gT("Resume Later") . "' class='saveall' onclick=\"javascript:document.limesurvey.move.value = this.value;addHiddenField(document.getElementById('limesurvey'),'saveall',this.value);document.getElementById('limesurvey').submit();\" " . (($thissurvey['active'] != "Y") ? "disabled='disabled'" : "") . "/>";  // Show Save So Far button
        	};
            }
        elseif (!isset($_SESSION['step']) || !$_SESSION['step'])
        {  //First page, show LOAD
            if ($thissurvey['tokenanswerspersistence'] != 'Y')
            {
                $_saveall = "\t\t\t<input type='submit' name='loadall' value='" . $clang->gT("Load Unfinished Survey") . "' class='saveall' " . (($thissurvey['active'] != "Y") ? "disabled='disabled'" : "") . "/>";
                }
		else
		{
                    $_saveall = '';
		};
            }
        elseif (isset($_SESSION['scid']) && (isset($move) && $move == "movelast"))
        {  //Already saved and on Submit Page, dont show Save So Far button
            $_saveall = '';
            }
            else
            {
            $_saveall = "<input type='button' name='saveallbtn' value='" . $clang->gT("Resume Later") . "' class='saveall' onclick=\"javascript:document.limesurvey.move.value = this.value;addHiddenField(document.getElementById('limesurvey'),'saveall',this.value);document.getElementById('limesurvey').submit();\" " . (($thissurvey['active'] != "Y") ? "disabled='disabled'" : "") . "/>";  // Show Save So Far button
            }
        }
        else
        {
        $_saveall = "";
        }

    $_templatecss = "<link rel='stylesheet' type='text/css' href='{$_templateurl}template.css' />\n";
        if (getLanguageRTL($clang->langcode))
        {
            $_templatecss.="<link rel='stylesheet' type='text/css' href='{$_templateurl}template-rtl.css' />\n";
        }

    if (FlattenText($help, true) != '')
        {
            If (!isset($helpicon))
            {
            if (file_exists($templatedir . '/help.gif'))
                {

                $helpicon = $_templateurl . 'help.gif';
                }
            elseif (file_exists($templatedir . '/help.png'))
                {

                $helpicon = $_templateurl . 'help.png';
                }
                else
                {
                $helpicon = $imageurl . "/help.gif";
                }
            }
            $_questionhelp =  "<img src='{$helpicon}' alt='Help' align='left' />".$help;
        }
    else
    {
        $_questionhelp = $help;
    }

    if (isset($thissurvey['allowprev']) && $thissurvey['allowprev'] == "N")
    {
            $_strreview = "";
        }
    else
    {
        $_strreview = $clang->gT("If you want to check any of the answers you have made, and/or change them, you can do that now by clicking on the [<< prev] button and browsing through your responses.");
        }

    if (isset($thissurvey['active']) and $thissurvey['active'] == "N")
    {
        $_restart = "<a href='{$publicurl}/index.php?sid=$surveyid&amp;newtest=Y";
        if (isset($s_lang) && $s_lang != '') {
            $_restart.="&amp;lang=" . $s_lang;
        }
        $_restart.="'>" . $clang->gT("Restart this Survey") . "</a>";
    } else
        {
            $restart_extra = "";
            $restart_token = returnglobal('token');
        if (!empty($restart_token))
            $restart_extra .= "&amp;token=" . urlencode($restart_token);
        else
            $restart_extra = "&amp;newtest=Y";
        if (!empty($_GET['lang']))
            $restart_extra .= "&amp;lang=" . returnglobal('lang');
        $_restart = "<a href='{$publicurl}/index.php?sid=$surveyid" . $restart_extra . "'>" . $clang->gT("Restart this Survey") . "</a>";
        }
    if (isset($thissurvey['anonymized']) && $thissurvey['anonymized'] == 'Y')
    {
        $_savealert = $clang->gT("To remain anonymous please use a pseudonym as your username, also an email address is not required.");
        }
        else
        {
        $_savealert = "";
        }

        $_return_to_survey = "<a href='$relativeurl/index.php?sid=$surveyid";
        if (returnglobal('token'))
        {
        $_return_to_survey.= "&amp;token=" . urlencode(trim(sanitize_xss_string(strip_tags(returnglobal('token')))));
        }
    $_return_to_survey .= "'>" . $clang->gT("Return To Survey") . "</a>";

    $_saveform = "<table><tr><td align='right'>" . $clang->gT("Name") . ":</td><td><input type='text' name='savename' value='";
    if (isset($_POST['savename']))
    {
        $_saveform .= html_escape(auto_unescape($_POST['savename']));
    }
        $_saveform .= "' /></td></tr>\n"
            . "<tr><td align='right'>" . $clang->gT("Password") . ":</td><td><input type='password' name='savepass' value='";
    if (isset($_POST['savepass']))
    {
        $_saveform .= html_escape(auto_unescape($_POST['savepass']));
    }
        $_saveform .= "' /></td></tr>\n"
            . "<tr><td align='right'>" . $clang->gT("Repeat Password") . ":</td><td><input type='password' name='savepass2' value='";
    if (isset($_POST['savepass2']))
    {
        $_saveform .= html_escape(auto_unescape($_POST['savepass2']));
    }
        $_saveform .= "' /></td></tr>\n"
            . "<tr><td align='right'>" . $clang->gT("Your Email") . ":</td><td><input type='text' name='saveemail' value='";
    if (isset($_POST['saveemail']))
    {
        $_saveform .= html_escape(auto_unescape($_POST['saveemail']));
    }
        $_saveform .= "' /></td></tr>\n";
    if (isset($thissurvey['usecaptcha']) && function_exists("ImageCreate") && captcha_enabled('saveandloadscreen', $thissurvey['usecaptcha']))
        {
        $_saveform .="<tr><td align='right'>" . $clang->gT("Security Question") . ":</td><td><table><tr><td valign='middle'><img src='{$captchapath}verification.php?sid=$surveyid' alt='' /></td><td valign='middle' style='text-align:left'><input type='text' size='5' maxlength='3' name='loadsecurity' value='' /></td></tr></table></td></tr>\n";
        }
        $_saveform .= "<tr><td align='right'></td><td></td></tr>\n"
            . "<tr><td></td><td><input type='submit'  id='savebutton' name='savesubmit' value='" . $clang->gT("Save Now") . "' /></td></tr>\n"
        . "</table>";

    $_loadform = "<table><tr><td align='right'>" . $clang->gT("Saved name") . ":</td><td><input type='text' name='loadname' value='";
    if ($loadname)
    {
        $_loadform .= html_escape(auto_unescape($loadname));
    }
        $_loadform .= "' /></td></tr>\n"
            . "<tr><td align='right'>" . $clang->gT("Password") . ":</td><td><input type='password' name='loadpass' value='";
    if (isset($loadpass))
    {
        $_loadform .= html_escape(auto_unescape($loadpass));
    }
        $_loadform .= "' /></td></tr>\n";
    if (isset($thissurvey['usecaptcha']) && function_exists("ImageCreate") && captcha_enabled('saveandloadscreen', $thissurvey['usecaptcha']))
        {
        $_loadform .="<tr><td align='right'>" . $clang->gT("Security Question") . ":</td><td><table><tr><td valign='middle'><img src='{$captchapath}verification.php?sid=$surveyid' alt='' /></td><td valign='middle'><input type='text' size='5' maxlength='3' name='loadsecurity' value='' alt=''/></td></tr></table></td></tr>\n";
        }

        $_loadform .="<tr><td align='right'></td><td></td></tr>\n"
            . "<tr><td></td><td><input type='submit' id='loadbutton' value='" . $clang->gT("Load Now") . "' /></td></tr></table>\n";

    $_registerform = "<form method='post' action='{$publicurl}/register.php'>\n";
        if (!isset($_REQUEST['lang']))
        {
            $_reglang = GetBaseLanguageFromSurveyID($surveyid);
        }
        else
        {
            $_reglang = returnglobal('lang');
        }
    $_registerform .= "<input type='hidden' name='lang' value='" . $_reglang . "' />\n";
        $_registerform .= "<input type='hidden' name='sid' value='$surveyid' id='sid' />\n";

        $_registerform.="<table class='register' summary='Registrationform'>\n"
            . "<tr><td align='right'>"
            . $clang->gT("First name") . ":</td>"
            . "<td align='left'><input class='text' type='text' name='register_firstname'";
        if (isset($_POST['register_firstname']))
        {
        $_registerform .= " value='" . htmlentities(returnglobal('register_firstname'), ENT_QUOTES, 'UTF-8') . "'";
        }
        $_registerform .= " /></td></tr>"
            . "<tr><td align='right'>" . $clang->gT("Last name") . ":</td>\n"
            . "<td align='left'><input class='text' type='text' name='register_lastname'";
        if (isset($_POST['register_lastname']))
        {
        $_registerform .= " value='" . htmlentities(returnglobal('register_lastname'), ENT_QUOTES, 'UTF-8') . "'";
        }
        $_registerform .= " /></td></tr>\n"
            . "<tr><td align='right'>" . $clang->gT("Email address") . ":</td>\n"
            . "<td align='left'><input class='text' type='text' name='register_email'";
        if (isset($_POST['register_email']))
        {
        $_registerform .= " value='" . htmlentities(returnglobal('register_email'), ENT_QUOTES, 'UTF-8') . "'";
        }
        $_registerform .= " /></td></tr>\n";


    if (isset($thissurvey['usecaptcha']) && function_exists("ImageCreate") && captcha_enabled('registrationscreen', $thissurvey['usecaptcha']))
        {
        $_registerform .="<tr><td align='right'>" . $clang->gT("Security Question") . ":</td><td><table><tr><td valign='middle'><img src='{$captchapath}verification.php?sid=$surveyid' alt='' /></td><td valign='middle'><input type='text' size='5' maxlength='3' name='loadsecurity' value='' /></td></tr></table></td></tr>\n";
        }


        /*      if(isset($thissurvey['attribute1']) && $thissurvey['attribute1'])
         {
         $_registerform .= "<tr><td align='right'>".$thissurvey['attribute1'].":</td>\n"
         ."<td align='left'><input class='text' type='text' name='register_attribute1'";
         if (isset($_POST['register_attribute1']))
         {
         $_registerform .= " value='".htmlentities(returnglobal('register_attribute1'),ENT_QUOTES,'UTF-8')."'";
         }
         $_registerform .= " /></td></tr>\n";
         }
         if(isset($thissurvey['attribute2']) && $thissurvey['attribute2'])
         {
         $_registerform .= "<tr><td align='right'>".$thissurvey['attribute2'].":</td>\n"
         ."<td align='left'><input class='text' type='text' name='register_attribute2'";
         if (isset($_POST['register_attribute2']))
         {
         $_registerform .= " value='".htmlentities(returnglobal('register_attribute2'),ENT_QUOTES,'UTF-8')."'";
         }
         $_registerform .= " /></td></tr>\n";
      } */
    $_registerform .= "<tr><td></td><td><input id='registercontinue' class='submit' type='submit' value='" . $clang->gT("Continue") . "' />"
            . "</td></tr>\n"
            . "</table>\n"
            . "</form>\n";

    if (!is_null($surveyid) && function_exists('doAssessment'))
    {
        $assessmentdata = doAssessment($surveyid, true);
        $_assessment_current_total = $assessmentdata['total'];
    }
    else
    {
        $_assessment_current_total = '';
    }

    // Set the array of replacement variables here - don't include curly braces
	$corecoreReplacements = array();
	$coreReplacements['ANSWER'] = $answer;  // global
	$coreReplacements['ANSWERSCLEARED'] = $clang->gT("Answers Cleared");
	$coreReplacements['ASSESSMENTS'] = $assessments;    // global
	$coreReplacements['ASSESSMENT_CURRENT_TOTAL'] = $_assessment_current_total;
	$coreReplacements['ASSESSMENT_HEADING'] = $clang->gT("Your Assessment");
	$coreReplacements['CHECKJAVASCRIPT'] = "<noscript><span class='warningjs'>".$clang->gT("Caution: JavaScript execution is disabled in your browser. You may not be able to answer all questions in this survey. Please, verify your browser parameters.")."</span></noscript>";
	$coreReplacements['CLEARALL'] = $_clearall;
	$coreReplacements['CLOSEWINDOW']  =  "<a href='javascript:%20self.close()'>".$clang->gT("Close this window")."</a>";
	$coreReplacements['COMPLETED'] = $completed;    // global
	$coreReplacements['DATESTAMP'] = $_datestamp;
	$coreReplacements['EXPIRY'] = $_dateoutput;
	$coreReplacements['GROUPDESCRIPTION'] = $_groupdescription;
	$coreReplacements['GROUPNAME'] = $_groupname;
	$coreReplacements['LANG'] = $clang->getlangcode();
	$coreReplacements['LANGUAGECHANGER'] = $languagechanger;    // global
	$coreReplacements['LOADERROR'] = $errormsg; // global
	$coreReplacements['LOADFORM'] = $_loadform;
	$coreReplacements['LOADHEADING'] = $clang->gT("Load A Previously Saved Survey");
	$coreReplacements['LOADMESSAGE'] = $clang->gT("You can load a survey that you have previously saved from this screen.")."<br />".$clang->gT("Type in the 'name' you used to save the survey, and the password.")."<br />";
	$coreReplacements['NAVIGATOR'] = $navigator;    // global
	$coreReplacements['NOSURVEYID'] = $surveylist['nosid']; // global
	$coreReplacements['NUMBEROFQUESTIONS'] = $_totalquestionsAsked;
	$coreReplacements['PERCENTCOMPLETE'] = $percentcomplete;    // global
	$coreReplacements['PRIVACY'] = $privacy;    // global
	$coreReplacements['PRIVACYMESSAGE'] = "<span style='font-weight:bold; font-style: italic;'>".$clang->gT("A Note On Privacy")."</span><br />".$clang->gT("This survey is anonymous.")."<br />".$clang->gT("The record kept of your survey responses does not contain any identifying information about you unless a specific question in the survey has asked for this. If you have responded to a survey that used an identifying token to allow you to access the survey, you can rest assured that the identifying token is not kept with your responses. It is managed in a separate database, and will only be updated to indicate that you have (or haven't) completed this survey. There is no way of matching identification tokens with survey responses in this survey.");
	$coreReplacements['QUESTION'] = $_question;
	$coreReplacements['QUESTIONHELP'] = $_questionhelp;
	$coreReplacements['QUESTIONHELPPLAINTEXT'] = strip_tags(addslashes($help)); // global
	$coreReplacements['QUESTION_CLASS'] = $_question_class;
	$coreReplacements['QUESTION_CODE'] = $_question_code;
	$coreReplacements['QUESTION_ESSENTIALS'] = $_question_essentials;
	$coreReplacements['QUESTION_FILE_VALID_MESSAGE'] = $_question_file_valid_message;
	$coreReplacements['QUESTION_HELP'] = $_question_help;
	$coreReplacements['QUESTION_INPUT_ERROR_CLASS'] = $_question_input_error_class;
	$coreReplacements['QUESTION_MANDATORY'] = $_question_mandatory;
	$coreReplacements['QUESTION_MAN_CLASS'] = $_question_man_class;
	$coreReplacements['QUESTION_MAN_MESSAGE'] = $_question_man_message;
	$coreReplacements['QUESTION_NUMBER'] = $_question_number;
	$coreReplacements['QUESTION_TEXT'] = $_question_text;
	$coreReplacements['QUESTION_VALID_MESSAGE'] = $_question_valid_message;
	$coreReplacements['REGISTERERROR'] = $register_errormsg;    // global
	$coreReplacements['REGISTERFORM'] = $_registerform;
	$coreReplacements['REGISTERMESSAGE1'] = $clang->gT("You must be registered to complete this survey");
	$coreReplacements['REGISTERMESSAGE2'] = $clang->gT("You may register for this survey if you wish to take part.")."<br />\n".$clang->gT("Enter your details below, and an email containing the link to participate in this survey will be sent immediately.");
	$coreReplacements['RESTART'] = $_restart;
	$coreReplacements['RETURNTOSURVEY'] = $_return_to_survey;
	$coreReplacements['SAVE'] = $_saveall;
	$coreReplacements['SAVEALERT'] = $_savealert;
	$coreReplacements['SAVEDID'] = $saved_id;   // global
	$coreReplacements['SAVEERROR'] = $errormsg; // global - same as LOADERROR
	$coreReplacements['SAVEFORM'] = $_saveform;
	$coreReplacements['SAVEHEADING'] = $clang->gT("Save Your Unfinished Survey");
	$coreReplacements['SAVEMESSAGE'] = $clang->gT("Enter a name and password for this survey and click save below.")."<br />\n".$clang->gT("Your survey will be saved using that name and password, and can be completed later by logging in with the same name and password.")."<br /><br />\n".$clang->gT("If you give an email address, an email containing the details will be sent to you.")."<br /><br />\n".$clang->gT("After having clicked the save button you can either close this browser window or continue filling out the survey.");
	$coreReplacements['SGQ'] = $_question_sgq;
	$coreReplacements['SID'] = $surveyid;   // global
	$coreReplacements['SITENAME'] = $sitename;  // global
	$coreReplacements['SUBMITBUTTON'] = $_submitbutton;
	$coreReplacements['SUBMITCOMPLETE'] = "<strong>".$clang->gT("Thank you!")."<br /><br />".$clang->gT("You have completed answering the questions in this survey.")."</strong><br /><br />".$clang->gT("Click on 'Submit' now to complete the process and save your answers.");
	$coreReplacements['SUBMITREVIEW'] = $_strreview;
	$coreReplacements['SURVEYCONTACT'] = $_surveycontact;
	$coreReplacements['SURVEYDESCRIPTION'] = (isset($thissurvey['description']) ? $thissurvey['description'] : '');
	$coreReplacements['SURVEYFORMAT'] = $surveyformat;  // global
	$coreReplacements['SURVEYLANGAGE'] = $clang->langcode;
	$coreReplacements['SURVEYLIST'] = $surveylist['list'];  // global
	$coreReplacements['SURVEYLISTHEADING'] =  $surveylist['listheading'];   // global
	$coreReplacements['SURVEYNAME'] = $thissurvey['name'];  // global
	$coreReplacements['TEMPLATECSS'] = $_templatecss;
	$coreReplacements['TEMPLATEURL'] = $_templateurl;
	$coreReplacements['THEREAREXQUESTIONS'] = $_therearexquestions;
	if (!$anonymized) $coreReplacements['TOKEN'] = $_token;
	$coreReplacements['URL'] = $_linkreplace;
	$coreReplacements['WELCOME'] = (isset($thissurvey['welcome']) ? $thissurvey['welcome'] : '');

    $tokenAndAnswerMap = getAnswerAndTokenMappings(false,$anonymized);
    $doTheseReplacements = array_merge($coreReplacements, $tokenAndAnswerMap, $replacements);   // so $replacements overrides core values

    $line = doReplacements($line,$doTheseReplacements);
    // Do replacements twice since some reference others
    $line = doReplacements($line,$doTheseReplacements);

    return $line;
}
Example #4
0
 /**
  *
  * Enter description here...
  * @param $surveyid
  * @param $type
  * @param $maxLsrcEmails
  * @return unknown_type
  */
 function emailSender($surveyid, $type, $maxLsrcEmails = '')
 {
     global $publicurl, $maxemails;
     global $connect, $sitename;
     global $dbprefix;
     $surveyid = sanitize_int($surveyid);
     include "lsrc.config.php";
     // wenn maxmails ber den lsrc gegeben wird das nutzen, ansonsten die default werte aus der config.php
     if ($maxLsrcEmails != '') {
         $maxemails = $maxLsrcEmails;
     }
     switch ($type) {
         case "custom":
             break;
         case "invite":
             $this->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ", START invite ");
             if (isset($surveyid) && getEmailFormat($surveyid) == 'html') {
                 $ishtml = true;
             } else {
                 $ishtml = false;
             }
             //$tokenoutput .= ("Sending Invitations");
             //if (isset($tokenid)) {$tokenoutput .= " (".("Sending to Token ID").":&nbsp;{$tokenid})";}
             //$tokenoutput .= "\n";
             $this->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ", {$surveyid}, {$type}");
             // Texte für Mails aus der Datenbank holen und in die POST Dinger schreiben. Nicht schön aber praktikabel
             $sql = "SELECT surveyls_language, surveyls_email_invite_subj, surveyls_email_invite  " . "FROM {$dbprefix}surveys_languagesettings " . "WHERE surveyls_survey_id = " . $surveyid . " ";
             //GET SURVEY DETAILS
             $thissurvey = getSurveyInfo($surveyid);
             //				$connect->SetFetchMode(ADODB_FETCH_ASSOC);
             //				$sqlResult=$connect->Execute($sql);
             $sqlResult = db_execute_assoc($sql);
             $this->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ", invite ");
             while ($languageRow = $sqlResult->FetchRow()) {
                 $_POST['message_' . $languageRow['surveyls_language']] = $languageRow['surveyls_email_invite'];
                 $_POST['subject_' . $languageRow['surveyls_language']] = $languageRow['surveyls_email_invite_subj'];
             }
             //				if (isset($_POST['bypassbademails']) && $_POST['bypassbademails'] == 'Y')
             //				{
             //					$SQLemailstatuscondition = " AND emailstatus = 'OK'";
             //				}
             //				else
             //				{
             //					$SQLemailstatuscondition = "";
             //				}
             $this->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ", invite ");
             $ctquery = "SELECT * FROM " . db_table_name("tokens_{$surveyid}") . " WHERE ((completed ='N') or (completed='')) AND ((sent ='N') or (sent='')) AND emailstatus = 'OK' ";
             if (isset($tokenid)) {
                 $ctquery .= " AND tid='{$tokenid}'";
             }
             //$tokenoutput .= "<!-- ctquery: $ctquery -->\n";
             $ctresult = $connect->Execute($ctquery);
             $ctcount = $ctresult->RecordCount();
             $ctfieldcount = $ctresult->FieldCount();
             $emquery = "SELECT * ";
             //if ($ctfieldcount > 7) {$emquery .= ", attribute_1, attribute_2";}
             $this->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ", invite ");
             $emquery .= " FROM " . db_table_name("tokens_{$surveyid}") . " WHERE ((completed ='N') or (completed='')) AND ((sent ='N') or (sent=''))  AND emailstatus = 'OK' ";
             if (isset($tokenid)) {
                 $emquery .= " and tid='{$tokenid}'";
             }
             //$tokenoutput .= "\n\n<!-- emquery: $emquery -->\n\n";
             $emresult = db_select_limit_assoc($emquery, $maxemails);
             $emcount = $emresult->RecordCount();
             //$tokenoutput .= "<table width='500px' align='center' >\n"
             ////."\t<tr>\n"
             //."\t\t<td><font size='1'>\n";
             $surveylangs = GetAdditionalLanguagesFromSurveyID($surveyid);
             $baselanguage = GetBaseLanguageFromSurveyID($surveyid);
             array_unshift($surveylangs, $baselanguage);
             $this->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ", invite ");
             foreach ($surveylangs as $language) {
                 $_POST['message_' . $language] = auto_unescape($_POST['message_' . $language]);
                 $_POST['subject_' . $language] = auto_unescape($_POST['subject_' . $language]);
                 if ($ishtml) {
                     $_POST['message_' . $language] = html_entity_decode($_POST['message_' . $language], ENT_QUOTES, $emailcharset);
                 }
             }
             $this->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ", invite ");
             if ($emcount > 0) {
                 $mailsSend = 0;
                 while ($emrow = $emresult->FetchRow()) {
                     $c = 1;
                     unset($fieldsarray);
                     $to = $emrow['email'];
                     $fieldsarray["{EMAIL}"] = $emrow['email'];
                     $fieldsarray["{FIRSTNAME}"] = $emrow['firstname'];
                     $fieldsarray["{LASTNAME}"] = $emrow['lastname'];
                     $fieldsarray["{TOKEN}"] = $emrow['token'];
                     $fieldsarray["{LANGUAGE}"] = $emrow['language'];
                     while (isset($emrow["attribute_{$c}"])) {
                         $fieldsarray["{ATTRIBUTE_{$c}}"] = $emrow["attribute_{$c}"];
                         $fieldsarray["{TOKEN:ATTRIBUTE_{$c}}"] = $emrow["attribute_{$c}"];
                         ++$c;
                     }
                     $fieldsarray["{ADMINNAME}"] = $thissurvey['adminname'];
                     $fieldsarray["{ADMINEMAIL}"] = $thissurvey['adminemail'];
                     $fieldsarray["{SURVEYNAME}"] = $thissurvey['name'];
                     $fieldsarray["{SURVEYDESCRIPTION}"] = $thissurvey['description'];
                     $fieldsarray["{EXPIRY}"] = $thissurvey["expiry"];
                     $emrow['language'] = trim($emrow['language']);
                     if ($emrow['language'] == '') {
                         $emrow['language'] = $baselanguage;
                     }
                     //if language is not give use default
                     $found = array_search($emrow['language'], $surveylangs);
                     if ($found == false) {
                         $emrow['language'] = $baselanguage;
                     }
                     $from = $thissurvey['adminemail'];
                     if ($ishtml === false) {
                         if ($modrewrite) {
                             $fieldsarray["{SURVEYURL}"] = "{$publicurl}/{$surveyid}/lang-" . trim($emrow['language']) . "/tk-{$emrow['token']}";
                         } else {
                             $fieldsarray["{SURVEYURL}"] = "{$publicurl}/index.php?lang=" . trim($emrow['language']) . "&sid={$surveyid}&token={$emrow['token']}";
                         }
                     } else {
                         if ($modrewrite) {
                             $fieldsarray["{SURVEYURL}"] = "<a href='{$publicurl}/{$surveyid}/lang-" . trim($emrow['language']) . "/tk-{$emrow['token']}'>" . htmlspecialchars("{$publicurl}/{$surveyid}/lang-" . trim($emrow['language']) . "/tk-{$emrow['token']}") . "</a>";
                         } else {
                             $fieldsarray["{SURVEYURL}"] = "<a href='{$publicurl}/index.php?lang=" . trim($emrow['language']) . "&sid={$surveyid}&token={$emrow['token']}'>" . htmlspecialchars("{$publicurl}/index.php?lang=" . trim($emrow['language']) . "&sid={$surveyid}&token={$emrow['token']}") . "</a>";
                         }
                     }
                     $this->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ", invite ");
                     $modsubject = Replacefields($_POST['subject_' . $emrow['language']], $fieldsarray);
                     $modmessage = Replacefields($_POST['message_' . $emrow['language']], $fieldsarray);
                     if (SendEmailMessage($modmessage, $modsubject, $to, $from, $sitename, $ishtml, getBounceEmail($surveyid))) {
                         // Put date into sent
                         //$timeadjust = 0;
                         $today = date("Y-m-d H:i");
                         $this->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ", invite Today:" . $today);
                         $udequery = "UPDATE " . db_table_name("tokens_{$surveyid}") . "\n" . "SET sent='{$today}' WHERE tid={$emrow['tid']}";
                         //
                         $uderesult = $connect->Execute($udequery);
                         $mailsSend++;
                         //$tokenoutput .= "[".("Invitation sent to:")."{$emrow['firstname']} {$emrow['lastname']} ($to)]\n";
                     } else {
                         //$tokenoutput .= ReplaceFields(("Email to {FIRSTNAME} {LASTNAME} ({EMAIL}) failed. Error Message:")." ".$maildebug."", $fieldsarray);
                         if ($n == 1) {
                             $failedAddresses .= "," . $to;
                         } else {
                             $failedAddresses = $to;
                             $n = 1;
                         }
                     }
                 }
                 $this->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ", invite ");
                 if ($ctcount > $emcount) {
                     $lefttosend = $ctcount - $maxemails;
                 } else {
                     $lefttosend = 0;
                 }
             } else {
                 return "No Mails to send";
             }
             if ($maxemails > 0 && $maxemails != '') {
                 $returnValue = "" . $mailsSend . " Mails send. " . $lefttosend . " Mails left to send";
                 if (isset($failedAddresses)) {
                     $returnValue .= "\nCould not send to: " . $failedAddresses;
                 }
                 return $returnValue;
             }
             if (isset($mailsSend)) {
                 $returnValue = "" . $mailsSend . " Mails send. ";
                 if (isset($failedAddresses)) {
                     $returnValue .= "\nCould not send to: " . $failedAddresses;
                 }
                 return $returnValue;
             }
             break;
         case "remind":
             // XXX:
             // TODO:
             //				if (!isset($_POST['ok']) || !$_POST['ok'])
             //				{
             /*
              * look if there were reminders send in the past, and if some tokens got lesser reminders than others
              *
              * - if so: send reminders to the unremindet participants until they got the same remindcount than the others
              * - if not: send reminders normally
              */
             $remSQL = "SELECT tid, remindercount " . "FROM " . db_table_name("tokens_{$surveyid}") . " " . "WHERE (completed = 'N' or completed = '') AND sent <> 'N' and sent <>'' AND token <>'' AND EMAIL <>'' " . "ORDER BY remindercount desc LIMIT 1";
             $this->debugLsrc("Executing SQL: " . $remSQL);
             $remResult = db_execute_assoc($remSQL);
             $remRow = $remResult->FetchRow();
             /* Get the reminder count from the row, if we have a row.  If 
              * we don't have a row then we set reminderCount to 0 to prevent
              * queries down below from bombing out. */
             $reminderCount = $remRow['remindercount'];
             if (empty($reminderCount)) {
                 $this->debugLsrc("There are no reminders to send.");
                 $reminderCount = 0;
             }
             $this->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ", remind " . $remRow['tid'] . "; " . $reminderCount . " ");
             $sendOnlySQL = "SELECT tid, remindercount " . "FROM " . db_table_name("tokens_{$surveyid}") . " " . "WHERE (completed = 'N' or completed = '') AND sent <> 'N' and sent <>'' AND token <>'' AND EMAIL <>'' AND remindercount < " . $reminderCount . " " . "ORDER BY tid asc LIMIT 1";
             $this->debugLsrc("Executing SQL: " . $sendOnlySQL);
             if ($sendOnlyResult->RecordCount() > 0) {
                 $sendOnlyRow = $sendOnlyResult->FetchRow();
                 $starttokenid = $sendOnlyRow['tid'];
                 $this->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ", remind " . $sendOnlyRow['tid'] . "; " . $sendOnlyRow['remindercount'] . " ");
             }
             if (isset($surveyid) && getEmailFormat($surveyid) == 'html') {
                 $ishtml = true;
             } else {
                 $ishtml = false;
             }
             //GET SURVEY DETAILS
             $thissurvey = getSurveyInfo($surveyid);
             $this->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ", {$surveyid}, {$type}");
             // Texte für Mails aus der Datenbank holen.
             $sql = "SELECT surveyls_language, surveyls_email_remind_subj, surveyls_email_remind  " . "FROM {$dbprefix}surveys_languagesettings " . "WHERE surveyls_survey_id = " . $surveyid . " ";
             $this->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ", invite ");
             $sqlResult = db_execute_assoc($sql);
             while ($languageRow = $sqlResult->FetchRow()) {
                 $_POST['message_' . $languageRow['surveyls_language']] = $languageRow['surveyls_email_remind'];
                 $_POST['subject_' . $languageRow['surveyls_language']] = $languageRow['surveyls_email_remind_subj'];
             }
             //$tokenoutput .= ("Sending Reminders")."\n";
             $surveylangs = GetAdditionalLanguagesFromSurveyID($surveyid);
             $baselanguage = GetBaseLanguageFromSurveyID($surveyid);
             array_unshift($surveylangs, $baselanguage);
             foreach ($surveylangs as $language) {
                 $_POST['message_' . $language] = auto_unescape($_POST['message_' . $language]);
                 $_POST['subject_' . $language] = auto_unescape($_POST['subject_' . $language]);
             }
             $SQLemailstatuscondition = " AND emailstatus = 'OK'";
             if (isset($_POST['maxremindercount']) && $_POST['maxremindercount'] != '' && intval($_POST['maxremindercount']) != 0) {
                 $SQLremindercountcondition = " AND remindercount < " . intval($_POST['maxremindercount']);
             } else {
                 $SQLremindercountcondition = "";
             }
             if (isset($_POST['minreminderdelay']) && $_POST['minreminderdelay'] != '' && intval($_POST['minreminderdelay']) != 0) {
                 // $_POST['minreminderdelay'] in days (86400 seconds per day)
                 $compareddate = date_shift(date("Y-m-d H:i:s", time() - 86400 * intval($_POST['minreminderdelay'])), "Y-m-d H:i", $timeadjust);
                 $SQLreminderdelaycondition = " AND ( " . " (remindersent = 'N' AND sent < '" . $compareddate . "') " . " OR " . " (remindersent < '" . $compareddate . "'))";
             } else {
                 $SQLreminderdelaycondition = "";
             }
             $ctquery = "SELECT * FROM " . db_table_name("tokens_{$surveyid}") . " WHERE (completed ='N' or completed ='') AND sent<>'' AND sent<>'N' AND token <>'' AND email <> '' {$SQLemailstatuscondition} {$SQLremindercountcondition} {$SQLreminderdelaycondition}";
             if (isset($starttokenid)) {
                 $ctquery .= " AND tid >= '{$starttokenid}'";
             }
             //					if (isset($tokenid) && $tokenid) {$ctquery .= " AND tid = '{$tokenid}'";}
             //					//$tokenoutput .= "<!-- ctquery: $ctquery -->\n";
             $ctresult = $connect->Execute($ctquery) or $this->debugLsrc("Database error!\n" . $connect->ErrorMsg());
             $ctcount = $ctresult->RecordCount();
             $ctfieldcount = $ctresult->FieldCount();
             $emquery = "SELECT * ";
             //if ($ctfieldcount > 7) {$emquery .= ", attribute_1, attribute_2";}
             // TLR change to put date into sent
             $emquery .= " FROM " . db_table_name("tokens_{$surveyid}") . " WHERE (completed = 'N' or completed = '') AND sent <> 'N' and sent <>'' AND token <>'' AND EMAIL <>'' {$SQLemailstatuscondition} {$SQLremindercountcondition} {$SQLreminderdelaycondition}";
             if (isset($starttokenid)) {
                 $emquery .= " AND tid >= '{$starttokenid}'";
             }
             if (isset($tokenid) && $tokenid) {
                 $emquery .= " AND tid = '{$tokenid}'";
             }
             $emquery .= " ORDER BY tid ";
             $emresult = db_select_limit_assoc($emquery, $maxemails);
             //$emresult = db_execute_assoc($emquery);
             $emcount = $emresult->RecordCount();
             if ($emcount > 0) {
                 while ($emrow = $emresult->FetchRow()) {
                     $c = 1;
                     unset($fieldsarray);
                     $to = $emrow['email'];
                     $fieldsarray["{EMAIL}"] = $emrow['email'];
                     $fieldsarray["{FIRSTNAME}"] = $emrow['firstname'];
                     $fieldsarray["{LASTNAME}"] = $emrow['lastname'];
                     $fieldsarray["{TOKEN}"] = $emrow['token'];
                     $fieldsarray["{LANGUAGE}"] = $emrow['language'];
                     while (isset($emrow["attribute_{$c}"])) {
                         $fieldsarray["{ATTRIBUTE_{$c}}"] = $emrow["attribute_{$c}"];
                         $fieldsarray["{TOKEN:ATTRIBUTE_{$c}}"] = $emrow["attribute_{$c}"];
                         ++$c;
                     }
                     $fieldsarray["{ADMINNAME}"] = $thissurvey['adminname'];
                     $fieldsarray["{ADMINEMAIL}"] = $thissurvey['adminemail'];
                     $fieldsarray["{SURVEYNAME}"] = $thissurvey['name'];
                     $fieldsarray["{SURVEYDESCRIPTION}"] = $thissurvey['description'];
                     $fieldsarray["{EXPIRY}"] = $thissurvey["expiry"];
                     $emrow['language'] = trim($emrow['language']);
                     if ($emrow['language'] == '') {
                         $emrow['language'] = $baselanguage;
                     }
                     //if language is not give use default
                     if (!in_array($emrow['language'], $surveylangs)) {
                         $emrow['language'] = $baselanguage;
                     }
                     // if given language is not available use default
                     $found = array_search($emrow['language'], $surveylangs);
                     if ($found == false) {
                         $emrow['language'] = $baselanguage;
                     }
                     $from = $thissurvey['adminemail'];
                     if (getEmailFormat($surveyid) == 'html') {
                         $ishtml = true;
                     } else {
                         $ishtml = false;
                     }
                     if ($ishtml == false) {
                         if ($modrewrite) {
                             $fieldsarray["{SURVEYURL}"] = "{$publicurl}/{$surveyid}/lang-" . trim($emrow['language']) . "/tk-{$emrow['token']}";
                         } else {
                             $fieldsarray["{SURVEYURL}"] = "{$publicurl}/index.php?lang=" . trim($emrow['language']) . "&sid={$surveyid}&token={$emrow['token']}";
                         }
                     } else {
                         if ($modrewrite) {
                             $fieldsarray["{SURVEYURL}"] = "<a href='{$publicurl}/{$surveyid}/lang-" . trim($emrow['language']) . "/tk-{$emrow['token']}'>" . htmlspecialchars("{$publicurl}/{$surveyid}/lang-" . trim($emrow['language']) . "/tk-{$emrow['token']}") . "</a>";
                         } else {
                             $fieldsarray["{SURVEYURL}"] = "<a href='{$publicurl}/index.php?lang=" . trim($emrow['language']) . "&sid={$surveyid}&token={$emrow['token']}'>" . htmlspecialchars("{$publicurl}/index.php?lang=" . trim($emrow['language']) . "&sid={$surveyid}&token={$emrow['token']}") . "</a>";
                             $_POST['message_' . $emrow['language']] = html_entity_decode($_POST['message_' . $emrow['language']], ENT_QUOTES, $emailcharset);
                         }
                     }
                     $msgsubject = Replacefields($_POST['subject_' . $emrow['language']], $fieldsarray);
                     $sendmessage = Replacefields($_POST['message_' . $emrow['language']], $fieldsarray);
                     if (SendEmailMessage($sendmessage, $msgsubject, $to, $from, $sitename, $ishtml, getBounceEmail($surveyid))) {
                         // Put date into remindersent
                         $today = date("Y-m-d H:i");
                         $udequery = "UPDATE " . db_table_name("tokens_{$surveyid}") . "\n" . "SET remindersent='{$today}',remindercount = remindercount+1  WHERE tid={$emrow['tid']}";
                         //
                         $uderesult = $connect->Execute($udequery) or $this->debugLsrc("Could not update tokens{$udequery}" . $connect->ErrorMsg());
                         //orig: $tokenoutput .= "\t\t\t({$emrow['tid']})[".("Reminder sent to:")." {$emrow['firstname']} {$emrow['lastname']}]\n";
                         //$tokenoutput .= "\t\t\t({$emrow['tid']}) [".("Reminder sent to:")." {$emrow['firstname']} {$emrow['lastname']} ($to)]\n";
                         $mailsSend++;
                     } else {
                         //$tokenoutput .= ReplaceFields(("Email to {FIRSTNAME} {LASTNAME} ({EMAIL}) failed. Error Message:")." ".$maildebug."", $fieldsarray);
                         if ($n == 1) {
                             $failedAddresses .= "," . $to;
                         } else {
                             $failedAddresses = $to;
                             $n = 1;
                         }
                     }
                     //$lasttid = $emrow['tid'];
                 }
                 if ($ctcount > $emcount) {
                     $lefttosend = $ctcount - $maxemails;
                 } else {
                     $lefttosend = 0;
                 }
             } else {
                 return "No Reminders to send";
             }
             if ($maxemails > 0) {
                 $returnValue = "" . $mailsSend . " Reminders send. " . $lefttosend . " Reminders left to send";
                 if (isset($failedAddresses)) {
                     $returnValue .= "\nCould not send to: " . $failedAddresses;
                 }
                 return $returnValue;
             }
             if (isset($mailsSend)) {
                 $returnValue = "" . $mailsSend . " Reminders send. ";
                 if (isset($failedAddresses)) {
                     $returnValue .= "\nCould not send to: " . $failedAddresses;
                 }
                 return $returnValue;
             }
             break;
         default:
             break;
     }
 }
Example #5
0
function loadanswers()
{
    global $dbprefix, $surveyid, $errormsg;
    global $thissurvey, $thisstep, $clang;
    global $databasetype, $clienttoken;
    $scid = returnglobal('scid');
    if (isset($_POST['loadall']) && $_POST['loadall'] == "reload") {
        $query = "SELECT * FROM " . db_table_name('saved_control') . " INNER JOIN {$thissurvey['tablename']}\n\t\t\tON " . db_table_name('saved_control') . ".srid = {$thissurvey['tablename']}.id\n\t\t\tWHERE " . db_table_name('saved_control') . ".sid={$surveyid}\n";
        if (isset($scid)) {
            $query .= "AND " . db_table_name('saved_control') . ".scid={$scid}\n";
        }
        $query .= "AND " . db_table_name('saved_control') . ".identifier = '" . auto_escape($_SESSION['holdname']) . "' ";
        if ($databasetype == 'odbc_mssql' || $databasetype == 'odbtp' || $databasetype == 'mssql_n' || $databasetype == 'mssqlnative') {
            $query .= "AND CAST(" . db_table_name('saved_control') . ".access_code as varchar(32))= '" . md5(auto_unescape($_SESSION['holdpass'])) . "'\n";
        } else {
            $query .= "AND " . db_table_name('saved_control') . ".access_code = '" . md5(auto_unescape($_SESSION['holdpass'])) . "'\n";
        }
    } elseif (isset($_SESSION['srid'])) {
        $query = "SELECT * FROM {$thissurvey['tablename']}\n\t\t\tWHERE {$thissurvey['tablename']}.id=" . $_SESSION['srid'] . "\n";
    } else {
        return;
    }
    $result = db_execute_assoc($query) or safe_die("Error loading results<br />{$query}<br />" . $connect->ErrorMsg());
    //Checked
    if ($result->RecordCount() < 1) {
        $errormsg .= $clang->gT("There is no matching saved survey") . "<br />\n";
    } else {
        //A match has been found. Let's load the values!
        //If this is from an email, build surveysession first
        $row = $result->FetchRow();
        foreach ($row as $column => $value) {
            if ($column == "token") {
                $clienttoken = $value;
                $token = $value;
            } elseif ($column == "saved_thisstep") {
                $_SESSION['step'] = $value;
                $thisstep = $value - 1;
            } elseif ($column == 'lastpage' && isset($_GET['token'])) {
                if ($value < 1) {
                    $value = 1;
                }
                $_SESSION['step'] = $value;
                $thisstep = $value - 1;
            } elseif ($column == 'startlanguage') {
                $clang = SetSurveyLanguage($surveyid, $value);
                UpdateSessionGroupList($value);
                // to refresh the language strings in the group list session variable
                UpdateFieldArray();
                // to refresh question titles and question text
            } elseif ($column == "scid") {
                $_SESSION['scid'] = $value;
            } elseif ($column == "srid") {
                $_SESSION['srid'] = $value;
            } elseif ($column == "datestamp") {
                $_SESSION['datestamp'] = $value;
            }
            if ($column == "startdate") {
                $_SESSION['startdate'] = $value;
            } else {
                //Only make session variables for those in insertarray[]
                if (in_array($column, $_SESSION['insertarray'])) {
                    if (($_SESSION['fieldmap'][$column]['type'] == 'N' || $_SESSION['fieldmap'][$column]['type'] == 'K' || $_SESSION['fieldmap'][$column]['type'] == 'D') && $value == null) {
                        // For type N,K,D NULL in DB is to be considered as NoAnswer in any case.
                        // We need to set the _SESSION[field] value to '' in order to evaluate conditions.
                        // This is especially important for the deletenonvalue feature,
                        // otherwise we would erase any answer with condition such as EQUALS-NO-ANSWER on such
                        // question types (NKD)
                        $_SESSION[$column] = '';
                    } else {
                        $_SESSION[$column] = $value;
                    }
                }
                // if (in_array(
            }
            // else
        }
        // foreach
    }
    return true;
}
Example #6
0
/**
 * This function replaces keywords in a text and is mainly intended for templates
 * If you use this functions put your replacement strings into the $replacements variable
 * instead of using global variables
 * NOTE - Don't do any embedded replacements in this function.  Create the array of replacement values and
 * they will be done in batch at the end
 *
 * @param string $line Text to search in
 * @param array $replacements Array of replacements:  Array( <stringtosearch>=><stringtoreplacewith>, where <stringtosearch> is NOT surrounded with curly braces
 * @param boolean $anonymized Determines if token data is being used or just replaced with blanks
 * @return string  Text with replaced strings
 */
function templatereplace($line, $replacements = array(), $anonymized = false, $questionNum = NULL)
{
    global $surveylist, $sitename, $clienttoken, $rooturl;
    global $thissurvey, $imageurl, $defaulttemplate;
    global $percentcomplete, $move;
    global $groupname, $groupdescription;
    global $question;
    global $showxquestions, $showgroupinfo, $showqnumcode;
    global $answer, $navigator;
    global $help, $surveyformat;
    global $completed, $register_errormsg;
    global $privacy, $surveyid;
    global $publicurl, $templatedir, $token;
    global $assessments, $s_lang;
    global $errormsg, $clang;
    global $saved_id;
    global $totalBoilerplatequestions, $relativeurl;
    global $languagechanger;
    global $captchapath, $loadname;
    // lets sanitize the survey template
    if (isset($thissurvey['templatedir'])) {
        $_templatename = $thissurvey['templatedir'];
    } else {
        $_templatename = $defaulttemplate;
    }
    #    $_templatename = validate_templatedir($_templatename); // Not needed: sGetTemplateURL and sgetTemplatePath do validation
    // create absolute template URL and template dir vars
    $_templateurl = sGetTemplateURL($_templatename) . '/';
    $templatedir = sgetTemplatePath($_templatename);
    $interviewer = returnglobal('interviewer');
    if (!empty($interviewer) || isset($_SESSION['interviewer']) && $_SESSION['interviewer'] == true) {
        $interviewer = true;
        $_SESSION['interviewer'] = true;
    } else {
        $interviewer = false;
    }
    if (stripos($line, "</head>")) {
        //queXS Addition
        $textfocus = "";
        if ($interviewer) {
            $textfocus = '<script type="text/javascript">
		$(document).ready(function()
		{
	        	$(".text").focus();
		        $(".textarea").focus();
		});
		</script>';
        }
        $line = str_ireplace("</head>", "<script type=\"text/javascript\" src=\"{$rooturl}/scripts/survey_runtime.js\"></script>\n" . "{$textfocus}\n" . use_firebug() . "\t</head>", $line);
    }
    // Get some vars : move elsewhere ?
    // surveyformat
    if (isset($thissurvey['format'])) {
        $surveyformat = str_replace(array("A", "S", "G"), array("allinone", "questionbyquestion", "groupbygroup"), $thissurvey['format']);
    } else {
        $surveyformat = "";
    }
    /*if (isset($thissurvey['allowjumps']) && $thissurvey['allowjumps']=="Y" && $surveyformat!="allinone" && (isset($_SESSION['step']) && $_SESSION['step']>0)){
          $surveyformat .= " withindex";
      }*/
    if (isset($thissurvey['showprogress']) && $thissurvey['showprogress'] == "Y") {
        $surveyformat .= " showprogress";
    }
    if (isset($thissurvey['showqnumcode'])) {
        $surveyformat .= " showqnumcode-" . $thissurvey['showqnumcode'];
    }
    // real survey contact
    if (isset($surveylist['contact'])) {
        $_surveycontact = $surveylist['contact'];
    } elseif (isset($thissurvey['admin']) && $thissurvey['admin'] != "") {
        $_surveycontact = sprintf($clang->gT("Please contact %s ( %s ) for further assistance."), $thissurvey['admin'], $thissurvey['adminemail']);
    } else {
        $_surveycontact = "";
    }
    // If there are non-bracketed replacements to be made do so above this line.
    // Only continue in this routine if there are bracketed items to replace {}
    if (strpos($line, "{") === false) {
        return LimeExpressionManager::ProcessString($line, $questionNum, NULL, false, 1, 1, true);
    }
    if ($showgroupinfo == 'both' || $showgroupinfo == 'name' || $showgroupinfo == 'choose' && !isset($thissurvey['showgroupinfo']) || $showgroupinfo == 'choose' && $thissurvey['showgroupinfo'] == 'B' || $showgroupinfo == 'choose' && $thissurvey['showgroupinfo'] == 'N') {
        $_groupname = $groupname;
    } else {
        $_groupname = '';
    }
    if ($showgroupinfo == 'both' || $showgroupinfo == 'description' || $showgroupinfo == 'choose' && !isset($thissurvey['showgroupinfo']) || $showgroupinfo == 'choose' && $thissurvey['showgroupinfo'] == 'B' || $showgroupinfo == 'choose' && $thissurvey['showgroupinfo'] == 'D') {
        $_groupdescription = $groupdescription;
    } else {
        $_groupdescription = '';
    }
    if (is_array($question)) {
        $_question = $question['all'];
        $_question_text = $question['text'];
        $_question_help = $question['help'];
        $_question_mandatory = $question['mandatory'];
        $_question_man_message = $question['man_message'];
        $_question_valid_message = $question['valid_message'];
        $_question_file_valid_message = $question['file_valid_message'];
        if (isset($question['sgq'])) {
            $_question_sgq = $question['sgq'];
            $_parts = explode('X', $_question_sgq);
            $_question_gid = $_parts[1];
        } else {
            $_question_sgq = '';
            $_question_gid = '';
        }
        $_question_essentials = $question['essentials'];
        $_question_class = $question['class'];
        $_question_man_class = $question['man_class'];
        $_question_input_error_class = $question['input_error_class'];
        $_aid = isset($question['aid']) ? $question['aid'] : '';
        $_sqid = isset($question['sqid']) ? $question['sqid'] : '';
        $_question_type = isset($question['type']) ? $question['type'] : '';
    } else {
        $_question = $question;
        $_question_text = '';
        $_question_help = '';
        $_question_mandatory = '';
        $_question_man_message = '';
        $_question_valid_message = '';
        $_question_file_valid_message = '';
        $_question_gid = '';
        $_question_sgq = '';
        $_question_essentials = '';
        $_question_class = '';
        $_question_man_class = '';
        $_question_input_error_class = '';
        $_aid = '';
        $_sqid = '';
        $_question_type = '';
    }
    global $answer_id;
    if ($_question_type == '*') {
        $_question_text = '<div class="em_equation">' . $_question_text . '</div>';
    }
    if ($showqnumcode == 'both' || $showqnumcode == 'number' || $showqnumcode == 'choose' && !isset($thissurvey['showqnumcode']) || $showqnumcode == 'choose' && $thissurvey['showqnumcode'] == 'B' || $showqnumcode == 'choose' && $thissurvey['showqnumcode'] == 'N') {
        $_question_number = $question['number'];
    } else {
        $_question_number = '';
    }
    if ($showqnumcode == 'both' || $showqnumcode == 'code' || $showqnumcode == 'choose' && !isset($thissurvey['showqnumcode']) || $showqnumcode == 'choose' && $thissurvey['showqnumcode'] == 'B' || $showqnumcode == 'choose' && $thissurvey['showqnumcode'] == 'C') {
        $_question_code = $question['code'];
    } else {
        $_question_code = '';
    }
    if (isset($_SESSION['therearexquestions'])) {
        $_totalquestionsAsked = $_SESSION['therearexquestions'] - $totalBoilerplatequestions;
    } else {
        $_totalquestionsAsked = 0;
    }
    if ($showxquestions == 'show' || $showxquestions == 'choose' && !isset($thissurvey['showxquestions']) || $showxquestions == 'choose' && $thissurvey['showxquestions'] == 'Y') {
        if ($_totalquestionsAsked < 1) {
            $_therearexquestions = $clang->gT("There are no questions in this survey");
            // Singular
        } elseif ($_totalquestionsAsked == 1) {
            $_therearexquestions = $clang->gT("There is 1 question in this survey");
            //Singular
        } else {
            $_therearexquestions = $clang->gT("There are {NUMBEROFQUESTIONS} questions in this survey.");
            //Note this line MUST be before {NUMBEROFQUESTIONS}
        }
    } else {
        $_therearexquestions = '';
    }
    if (isset($token)) {
        $_token = $token;
    } elseif (isset($clienttoken)) {
        $_token = htmlentities($clienttoken, ENT_QUOTES, 'UTF-8');
    } else {
        $_token = '';
    }
    if (isset($thissurvey['surveyls_dateformat'])) {
        $dateformatdetails = getDateFormatData($thissurvey['surveyls_dateformat']);
    } else {
        $dateformatdetails = getDateFormatData();
    }
    if (isset($thissurvey['expiry'])) {
        $_datetimeobj = new Date_Time_Converter($thissurvey['expiry'], "Y-m-d");
        $_dateoutput = $_datetimeobj->convert($dateformatdetails['phpdate']);
    } else {
        $_dateoutput = '-';
    }
    $_submitbutton = "<input class='submit' type='submit' value=' " . $clang->gT("Submit") . " ' name='move2' onclick=\"javascript:document.limesurvey.move.value = 'movesubmit';\" />";
    if (isset($thissurvey['surveyls_url']) and $thissurvey['surveyls_url'] != "") {
        if (trim($thissurvey['surveyls_urldescription']) != '') {
            $_linkreplace = "<a href='{$thissurvey['surveyls_url']}'>{$thissurvey['surveyls_urldescription']}</a>";
        } else {
            $_linkreplace = "<a href='{$thissurvey['surveyls_url']}'>{$thissurvey['surveyls_url']}</a>";
        }
    } else {
        $_linkreplace = '';
    }
    if (isset($clienttoken)) {
        $token = $clienttoken;
    } else {
        $token = '';
    }
    if (!isset($_SESSION['s_lang'])) {
        $_s_lang = 'en';
    } else {
        $_s_lang = $_SESSION['s_lang'];
    }
    // CLEARALL
    if ($surveyid && !isCompleted($surveyid, $saved_id)) {
        $_clearall = "<input type='button' name='clearallbtn' value='" . $clang->gT("Exit and Clear Survey") . "' class='clearall' " . "onclick=\"if (confirm('" . $clang->gT("Are you sure you want to clear all your responses?", 'js') . "')) {\nwindow.open('{$publicurl}/index.php?sid={$surveyid}&amp;move=clearall&amp;lang=" . $_s_lang;
        if (returnglobal('token')) {
            $_clearall .= "&amp;token={$_token}";
        }
        $_clearall .= "', '_self')}\" />";
    } else {
        $_clearall = "";
        // This survey are already completed or surveyid not set, then don't have access to clearallbtn
    }
    if (isset($_SESSION['datestamp'])) {
        $_datestamp = $_SESSION['datestamp'];
    } else {
        $_datestamp = '-';
    }
    //Set up save/load feature
    if (isset($thissurvey['allowsave']) and $thissurvey['allowsave'] == "Y") {
        // Find out if the user has any saved data
        if ($thissurvey['format'] == 'A') {
            if ($thissurvey['tokenanswerspersistence'] != 'Y' || !tableExists('tokens_' . $surveyid)) {
                $_saveall = "\t\t\t<input type='button' name='loadall' value='" . $clang->gT("Load Unfinished Survey") . "' class='saveall' onclick=\"javascript:addHiddenField(document.getElementById('limesurvey'),'loadall',this.value);document.getElementById('limesurvey').submit();\" " . ($thissurvey['active'] != "Y" ? "disabled='disabled'" : "") . "/>" . "\n\t\t\t<input type='button' name='saveallbtn' value='" . $clang->gT("Resume Later") . "' class='saveall' onclick=\"javascript:document.limesurvey.move.value = this.value;addHiddenField(document.getElementById('limesurvey'),'saveall',this.value);document.getElementById('limesurvey').submit();\" " . ($thissurvey['active'] != "Y" ? "disabled='disabled'" : "") . "/>";
                // Show Save So Far button
            } else {
                $_saveall = "\t\t\t<input type='button' name='saveallbtn' value='" . $clang->gT("Resume Later") . "' class='saveall' onclick=\"javascript:document.limesurvey.move.value = this.value;addHiddenField(document.getElementById('limesurvey'),'saveall',this.value);document.getElementById('limesurvey').submit();\" " . ($thissurvey['active'] != "Y" ? "disabled='disabled'" : "") . "/>";
                // Show Save So Far button
            }
        } elseif (!isset($_SESSION['step']) || !$_SESSION['step']) {
            //First page, show LOAD
            if ($thissurvey['tokenanswerspersistence'] != 'Y' || !tableExists('tokens_' . $surveyid)) {
                $_saveall = "\t\t\t<input type='button' name='loadall' value='" . $clang->gT("Load Unfinished Survey") . "' class='saveall' onclick=\"javascript:addHiddenField(document.getElementById('limesurvey'),'loadall',this.value);document.getElementById('limesurvey').submit();\" " . ($thissurvey['active'] != "Y" ? "disabled='disabled'" : "") . "/>";
            } else {
                $_saveall = '';
            }
        } elseif (isset($_SESSION['scid']) && (isset($move) && $move == "movelast")) {
            //Already saved and on Submit Page, dont show Save So Far button
            $_saveall = '';
        } else {
            $_saveall = "<input type='button' name='saveallbtn' value='" . $clang->gT("Resume Later") . "' class='saveall' onclick=\"javascript:document.limesurvey.move.value = this.value;addHiddenField(document.getElementById('limesurvey'),'saveall',this.value);document.getElementById('limesurvey').submit();\" " . ($thissurvey['active'] != "Y" ? "disabled='disabled'" : "") . "/>";
            // Show Save So Far button
        }
    } else {
        $_saveall = "";
    }
    $_templatecss = "<link rel='stylesheet' type='text/css' href='{$_templateurl}template.css' />\n";
    if (getLanguageRTL($clang->langcode)) {
        $_templatecss .= "<link rel='stylesheet' type='text/css' href='{$_templateurl}template-rtl.css' />\n";
    }
    if (FlattenText($help, true) != '') {
        if (!isset($helpicon)) {
            if (file_exists($templatedir . '/help.gif')) {
                $helpicon = $_templateurl . 'help.gif';
            } elseif (file_exists($templatedir . '/help.png')) {
                $helpicon = $_templateurl . 'help.png';
            } else {
                $helpicon = $imageurl . "/help.gif";
            }
        }
        $_questionhelp = "<img src='{$helpicon}' alt='Help' align='left' />" . $help;
    } else {
        $_questionhelp = $help;
    }
    if (isset($thissurvey['allowprev']) && $thissurvey['allowprev'] == "N") {
        $_strreview = "";
    } else {
        $_strreview = $clang->gT("If you want to check any of the answers you have made, and/or change them, you can do that now by clicking on the [<< prev] button and browsing through your responses.");
    }
    if (isset($thissurvey['active']) and $thissurvey['active'] == "N") {
        $_restart = "<a href='{$publicurl}/index.php?sid={$surveyid}&amp;newtest=Y";
        if (isset($s_lang) && $s_lang != '') {
            $_restart .= "&amp;lang=" . $s_lang;
        }
        $_restart .= "'>" . $clang->gT("Restart this Survey") . "</a>";
    } else {
        $restart_extra = "";
        $restart_token = returnglobal('token');
        if (!empty($restart_token)) {
            $restart_extra .= "&amp;token=" . urlencode($restart_token);
        } else {
            $restart_extra = "&amp;newtest=Y";
        }
        if (!empty($_GET['lang'])) {
            $restart_extra .= "&amp;lang=" . returnglobal('lang');
        }
        $_restart = "<a href='{$publicurl}/index.php?sid={$surveyid}" . $restart_extra . "'>" . $clang->gT("Restart this Survey") . "</a>";
    }
    if (isset($thissurvey['anonymized']) && $thissurvey['anonymized'] == 'Y') {
        $_savealert = $clang->gT("To remain anonymous please use a pseudonym as your username, also an email address is not required.");
    } else {
        $_savealert = "";
    }
    $_return_to_survey = "<a href='{$relativeurl}/index.php?sid={$surveyid}";
    if (returnglobal('token')) {
        $_return_to_survey .= "&amp;token=" . urlencode(trim(sanitize_xss_string(strip_tags(returnglobal('token')))));
    }
    $_return_to_survey .= "'>" . $clang->gT("Return To Survey") . "</a>";
    $_saveform = "<table><tr><td align='right'>" . $clang->gT("Name") . ":</td><td><input type='text' name='savename' value='";
    if (isset($_POST['savename'])) {
        $_saveform .= html_escape(auto_unescape($_POST['savename']));
    }
    $_saveform .= "' /></td></tr>\n" . "<tr><td align='right'>" . $clang->gT("Password") . ":</td><td><input type='password' name='savepass' value='";
    if (isset($_POST['savepass'])) {
        $_saveform .= html_escape(auto_unescape($_POST['savepass']));
    }
    $_saveform .= "' /></td></tr>\n" . "<tr><td align='right'>" . $clang->gT("Repeat Password") . ":</td><td><input type='password' name='savepass2' value='";
    if (isset($_POST['savepass2'])) {
        $_saveform .= html_escape(auto_unescape($_POST['savepass2']));
    }
    $_saveform .= "' /></td></tr>\n" . "<tr><td align='right'>" . $clang->gT("Your Email") . ":</td><td><input type='text' name='saveemail' value='";
    if (isset($_POST['saveemail'])) {
        $_saveform .= html_escape(auto_unescape($_POST['saveemail']));
    }
    $_saveform .= "' /></td></tr>\n";
    if (isset($thissurvey['usecaptcha']) && function_exists("ImageCreate") && captcha_enabled('saveandloadscreen', $thissurvey['usecaptcha'])) {
        $_saveform .= "<tr><td align='right'>" . $clang->gT("Security Question") . ":</td><td><table><tr><td valign='middle'><img src='{$captchapath}verification.php?sid={$surveyid}' alt='' /></td><td valign='middle' style='text-align:left'><input type='text' size='5' maxlength='3' name='loadsecurity' value='' /></td></tr></table></td></tr>\n";
    }
    $_saveform .= "<tr><td align='right'></td><td></td></tr>\n" . "<tr><td></td><td><input type='submit'  id='savebutton' name='savesubmit' value='" . $clang->gT("Save Now") . "' /></td></tr>\n" . "</table>";
    $_loadform = "<table><tr><td align='right'>" . $clang->gT("Saved name") . ":</td><td><input type='text' name='loadname' value='";
    if ($loadname) {
        $_loadform .= html_escape(auto_unescape($loadname));
    }
    $_loadform .= "' /></td></tr>\n" . "<tr><td align='right'>" . $clang->gT("Password") . ":</td><td><input type='password' name='loadpass' value='";
    if (isset($loadpass)) {
        $_loadform .= html_escape(auto_unescape($loadpass));
    }
    $_loadform .= "' /></td></tr>\n";
    if (isset($thissurvey['usecaptcha']) && function_exists("ImageCreate") && captcha_enabled('saveandloadscreen', $thissurvey['usecaptcha'])) {
        $_loadform .= "<tr><td align='right'>" . $clang->gT("Security Question") . ":</td><td><table><tr><td valign='middle'><img src='{$captchapath}verification.php?sid={$surveyid}' alt='' /></td><td valign='middle'><input type='text' size='5' maxlength='3' name='loadsecurity' value='' alt=''/></td></tr></table></td></tr>\n";
    }
    $_loadform .= "<tr><td align='right'></td><td></td></tr>\n" . "<tr><td></td><td><input type='submit' id='loadbutton' value='" . $clang->gT("Load Now") . "' /></td></tr></table>\n";
    $_registerform = "<form method='post' action='{$publicurl}/register.php'>\n";
    if (!isset($_REQUEST['lang'])) {
        $_reglang = GetBaseLanguageFromSurveyID($surveyid);
    } else {
        $_reglang = returnglobal('lang');
    }
    $_registerform .= "<input type='hidden' name='lang' value='" . $_reglang . "' />\n";
    $_registerform .= "<input type='hidden' name='sid' value='{$surveyid}' id='sid' />\n";
    $_registerform .= "<table class='register' summary='Registrationform'>\n" . "<tr><td align='right'>" . $clang->gT("First name") . ":</td>" . "<td align='left'><input class='text' type='text' name='register_firstname'";
    if (isset($_POST['register_firstname'])) {
        $_registerform .= " value='" . htmlentities(returnglobal('register_firstname'), ENT_QUOTES, 'UTF-8') . "'";
    }
    $_registerform .= " /></td></tr>" . "<tr><td align='right'>" . $clang->gT("Last name") . ":</td>\n" . "<td align='left'><input class='text' type='text' name='register_lastname'";
    if (isset($_POST['register_lastname'])) {
        $_registerform .= " value='" . htmlentities(returnglobal('register_lastname'), ENT_QUOTES, 'UTF-8') . "'";
    }
    $_registerform .= " /></td></tr>\n" . "<tr><td align='right'>" . $clang->gT("Email address") . ":</td>\n" . "<td align='left'><input class='text' type='text' name='register_email'";
    if (isset($_POST['register_email'])) {
        $_registerform .= " value='" . htmlentities(returnglobal('register_email'), ENT_QUOTES, 'UTF-8') . "'";
    }
    $_registerform .= " /></td></tr>\n";
    if (isset($thissurvey['usecaptcha']) && function_exists("ImageCreate") && captcha_enabled('registrationscreen', $thissurvey['usecaptcha'])) {
        $_registerform .= "<tr><td align='right'>" . $clang->gT("Security Question") . ":</td><td><table><tr><td valign='middle'><img src='{$captchapath}verification.php?sid={$surveyid}' alt='' /></td><td valign='middle'><input type='text' size='5' maxlength='3' name='loadsecurity' value='' /></td></tr></table></td></tr>\n";
    }
    /*      if(isset($thissurvey['attribute1']) && $thissurvey['attribute1'])
             {
             $_registerform .= "<tr><td align='right'>".$thissurvey['attribute1'].":</td>\n"
             ."<td align='left'><input class='text' type='text' name='register_attribute1'";
             if (isset($_POST['register_attribute1']))
             {
             $_registerform .= " value='".htmlentities(returnglobal('register_attribute1'),ENT_QUOTES,'UTF-8')."'";
             }
             $_registerform .= " /></td></tr>\n";
             }
             if(isset($thissurvey['attribute2']) && $thissurvey['attribute2'])
             {
             $_registerform .= "<tr><td align='right'>".$thissurvey['attribute2'].":</td>\n"
             ."<td align='left'><input class='text' type='text' name='register_attribute2'";
             if (isset($_POST['register_attribute2']))
             {
             $_registerform .= " value='".htmlentities(returnglobal('register_attribute2'),ENT_QUOTES,'UTF-8')."'";
             }
             $_registerform .= " /></td></tr>\n";
          } */
    $_registerform .= "<tr><td></td><td><input id='registercontinue' class='submit' type='submit' value='" . $clang->gT("Continue") . "' />" . "</td></tr>\n" . "</table>\n" . "</form>\n";
    if (!is_null($surveyid) && function_exists('doAssessment')) {
        $assessmentdata = doAssessment($surveyid, true);
        $_assessment_current_total = $assessmentdata['total'];
    } else {
        $_assessment_current_total = '';
    }
    if (isset($thissurvey['googleanalyticsapikey']) && trim($thissurvey['googleanalyticsapikey']) != '') {
        $_googleAnalyticsAPIKey = trim($thissurvey['googleanalyticsapikey']);
    } else {
        $_googleAnalyticsAPIKey = trim(getGlobalSetting('googleanalyticsapikey'));
    }
    $_googleAnalyticsStyle = isset($thissurvey['googleanalyticsstyle']) ? $thissurvey['googleanalyticsstyle'] : '0';
    $_googleAnalyticsJavaScript = '';
    if ($_googleAnalyticsStyle != '' && $_googleAnalyticsStyle != 0 && $_googleAnalyticsAPIKey != '') {
        switch ($_googleAnalyticsStyle) {
            case '1':
                // Default Google Tracking
                $_googleAnalyticsJavaScript = <<<EOD
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', '{$_googleAnalyticsAPIKey}']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>
EOD;
                break;
            case '2':
                // SurveyName-[SID]/[GSEQ]-GroupName - create custom GSEQ based upon page step
                $moveInfo = LimeExpressionManager::GetLastMoveResult();
                if (is_null($moveInfo)) {
                    $gseq = 'welcome';
                } else {
                    if ($moveInfo['finished']) {
                        $gseq = 'finished';
                    } else {
                        if (isset($moveInfo['at_start']) && $moveInfo['at_start']) {
                            $gseq = 'welcome';
                        } else {
                            if (is_null($_groupname)) {
                                $gseq = 'printanswers';
                            } else {
                                $gseq = $moveInfo['gseq'] + 1;
                            }
                        }
                    }
                }
                $_trackURL = htmlentities($thissurvey['name'] . '-[' . $surveyid . ']/[' . $gseq . ']-' . $_groupname, ENT_QUOTES);
                $_googleAnalyticsJavaScript = <<<EOD
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', '{$_googleAnalyticsAPIKey}']);
  _gaq.push(['_trackPageview','{$_trackURL}']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>
EOD;
                break;
        }
    }
    $_endtext = '';
    if (isset($thissurvey['surveyls_endtext']) && trim($thissurvey['surveyls_endtext']) != '') {
        $_endtext = $thissurvey['surveyls_endtext'];
    }
    // Set the array of replacement variables here - don't include curly braces
    // Please put any conditional logic above this section.  Here below should just be an alphabetical list of replacement values with no embedded logic.
    $coreReplacements = array();
    $coreReplacements['ACTIVE'] = isset($thissurvey['active']) && !($thissurvey['active'] != "Y");
    $coreReplacements['AID'] = $_aid;
    // global
    $coreReplacements['ANSWER'] = $answer;
    // global
    $coreReplacements['ANSWERSCLEARED'] = $clang->gT("Answers Cleared");
    $coreReplacements['ASSESSMENTS'] = $assessments;
    // global
    $coreReplacements['ASSESSMENT_CURRENT_TOTAL'] = $_assessment_current_total;
    $coreReplacements['ASSESSMENT_HEADING'] = $clang->gT("Your Assessment");
    $coreReplacements['CHECKJAVASCRIPT'] = "<noscript><span class='warningjs'>" . $clang->gT("Caution: JavaScript execution is disabled in your browser. You may not be able to answer all questions in this survey. Please, verify your browser parameters.") . "</span></noscript>";
    $coreReplacements['CLEARALL'] = $_clearall;
    $coreReplacements['CLOSEWINDOW'] = "<a href='javascript:%20self.close()'>" . $clang->gT("Close this window") . "</a>";
    $coreReplacements['COMPLETED'] = $completed;
    // global
    $coreReplacements['DATESTAMP'] = $_datestamp;
    $coreReplacements['ENDTEXT'] = $_endtext;
    $coreReplacements['EXPIRY'] = $_dateoutput;
    $coreReplacements['GID'] = $_question_gid;
    $coreReplacements['GOOGLE_ANALYTICS_API_KEY'] = $_googleAnalyticsAPIKey;
    $coreReplacements['GOOGLE_ANALYTICS_JAVASCRIPT'] = $_googleAnalyticsJavaScript;
    $coreReplacements['GROUPDESCRIPTION'] = $_groupdescription;
    $coreReplacements['GROUPNAME'] = $_groupname;
    $coreReplacements['LANG'] = $clang->getlangcode();
    $coreReplacements['LANGUAGECHANGER'] = $languagechanger;
    // global
    $coreReplacements['LOADERROR'] = $errormsg;
    // global
    $coreReplacements['LOADFORM'] = $_loadform;
    $coreReplacements['LOADHEADING'] = $clang->gT("Load A Previously Saved Survey");
    $coreReplacements['LOADMESSAGE'] = $clang->gT("You can load a survey that you have previously saved from this screen.") . "<br />" . $clang->gT("Type in the 'name' you used to save the survey, and the password.") . "<br />";
    $coreReplacements['NAVIGATOR'] = $navigator;
    // global
    $coreReplacements['NOSURVEYID'] = $surveylist['nosid'];
    // global
    $coreReplacements['NUMBEROFQUESTIONS'] = $_totalquestionsAsked;
    $coreReplacements['PASSTHRULABEL'] = '';
    $coreReplacements['PASSTHRUVALUE'] = '';
    $coreReplacements['PERCENTCOMPLETE'] = $percentcomplete;
    // global
    $coreReplacements['PRIVACY'] = $privacy;
    // global
    $coreReplacements['PRIVACYMESSAGE'] = "<span style='font-weight:bold; font-style: italic;'>" . $clang->gT("A Note On Privacy") . "</span><br />" . $clang->gT("This survey is anonymous.") . "<br />" . $clang->gT("The record kept of your survey responses does not contain any identifying information about you unless a specific question in the survey has asked for this. If you have responded to a survey that used an identifying token to allow you to access the survey, you can rest assured that the identifying token is not kept with your responses. It is managed in a separate database, and will only be updated to indicate that you have (or haven't) completed this survey. There is no way of matching identification tokens with survey responses in this survey.");
    $coreReplacements['QID'] = isset($questionNum) ? $questionNum : '';
    $coreReplacements['QUESTION'] = $_question;
    $coreReplacements['QUESTIONHELP'] = $_questionhelp;
    $coreReplacements['QUESTIONHELPPLAINTEXT'] = strip_tags(addslashes($help));
    // global
    $coreReplacements['QUESTION_CLASS'] = $_question_class;
    $coreReplacements['QUESTION_CODE'] = $_question_code;
    $coreReplacements['QUESTION_ESSENTIALS'] = $_question_essentials;
    $coreReplacements['QUESTION_FILE_VALID_MESSAGE'] = $_question_file_valid_message;
    $coreReplacements['QUESTION_HELP'] = $_question_help;
    $coreReplacements['QUESTION_INPUT_ERROR_CLASS'] = $_question_input_error_class;
    $coreReplacements['QUESTION_MANDATORY'] = $_question_mandatory;
    $coreReplacements['QUESTION_MAN_CLASS'] = $_question_man_class;
    $coreReplacements['QUESTION_MAN_MESSAGE'] = $_question_man_message;
    $coreReplacements['QUESTION_NUMBER'] = $_question_number;
    $coreReplacements['QUESTION_TEXT'] = $_question_text;
    $coreReplacements['QUESTION_VALID_MESSAGE'] = $_question_valid_message;
    $coreReplacements['REGISTERERROR'] = $register_errormsg;
    // global
    $coreReplacements['REGISTERFORM'] = $_registerform;
    $coreReplacements['REGISTERMESSAGE1'] = $clang->gT("You must be registered to complete this survey");
    $coreReplacements['REGISTERMESSAGE2'] = $clang->gT("You may register for this survey if you wish to take part.") . "<br />\n" . $clang->gT("Enter your details below, and an email containing the link to participate in this survey will be sent immediately.");
    $coreReplacements['RESTART'] = $_restart;
    $coreReplacements['RETURNTOSURVEY'] = $_return_to_survey;
    $coreReplacements['SAVE'] = $_saveall;
    $coreReplacements['SAVEALERT'] = $_savealert;
    $coreReplacements['SAVEDID'] = $saved_id;
    // global
    $coreReplacements['SAVEERROR'] = $errormsg;
    // global - same as LOADERROR
    $coreReplacements['SAVEFORM'] = $_saveform;
    $coreReplacements['SAVEHEADING'] = $clang->gT("Save Your Unfinished Survey");
    $coreReplacements['SAVEMESSAGE'] = $clang->gT("Enter a name and password for this survey and click save below.") . "<br />\n" . $clang->gT("Your survey will be saved using that name and password, and can be completed later by logging in with the same name and password.") . "<br /><br />\n" . $clang->gT("If you give an email address, an email containing the details will be sent to you.") . "<br /><br />\n" . $clang->gT("After having clicked the save button you can either close this browser window or continue filling out the survey.");
    $coreReplacements['SGQ'] = $_question_sgq;
    $coreReplacements['SID'] = $surveyid;
    // global
    $coreReplacements['SITENAME'] = $sitename;
    // global
    $coreReplacements['SQID'] = $_sqid;
    // global
    $coreReplacements['SUBMITBUTTON'] = $_submitbutton;
    $coreReplacements['SUBMITCOMPLETE'] = "<strong>" . $clang->gT("Thank you!") . "<br /><br />" . $clang->gT("You have completed answering the questions in this survey.") . "</strong><br /><br />" . $clang->gT("Click on 'Submit' now to complete the process and save your answers.");
    $coreReplacements['SUBMITREVIEW'] = $_strreview;
    $coreReplacements['SURVEYCONTACT'] = $_surveycontact;
    $coreReplacements['SURVEYDESCRIPTION'] = isset($thissurvey['description']) ? $thissurvey['description'] : '';
    $coreReplacements['SURVEYFORMAT'] = $surveyformat;
    // global
    $coreReplacements['SURVEYLANGAGE'] = $clang->langcode;
    // this misspelling is kept for legacy reasons
    $coreReplacements['SURVEYLANGUAGE'] = $clang->langcode;
    $coreReplacements['SURVEYLIST'] = $surveylist['list'];
    // global
    $coreReplacements['SURVEYLISTHEADING'] = $surveylist['listheading'];
    // global
    $coreReplacements['SURVEYNAME'] = $thissurvey['name'];
    // global
    $coreReplacements['TEMPLATECSS'] = $_templatecss;
    $coreReplacements['TEMPLATEURL'] = $_templateurl;
    $coreReplacements['THEREAREXQUESTIONS'] = $_therearexquestions;
    if (!$anonymized) {
        $coreReplacements['TOKEN'] = $_token;
    }
    $coreReplacements['URL'] = $_linkreplace;
    $coreReplacements['WELCOME'] = isset($thissurvey['welcome']) ? $thissurvey['welcome'] : '';
    //queXS Addition
    include_once "quexs.php";
    $coreReplacements['IS_INTERVIEWER'] = $interviewer;
    $coreReplacements = array_merge($coreReplacements, quexs_core_replace());
    if (!is_null($replacements) && is_array($replacements)) {
        $doTheseReplacements = array_merge($coreReplacements, $replacements);
        // so $replacements overrides core values
    } else {
        $doTheseReplacements = $coreReplacements;
    }
    // Now do all of the replacements - In rare cases, need to do 3 deep recursion, that that is default
    $line = LimeExpressionManager::ProcessString($line, $questionNum, $doTheseReplacements, false, 3, 1);
    return $line;
}
Example #7
0
$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'));
}
function checkIfNewGroup($ia)
{
    foreach ($_SESSION['grouplist'] as $gl) {
        if ($gl[0] == $ia[5]) {
            $gid = $gl[0];
            $groupname = $gl[1];
            $groupdescription = $gl[2];
            if (isset($_POST['lastgroupname']) && auto_unescape($_POST['lastgroupname']) != strip_tags($groupname) && trim($groupdescription) != '') {
                $newgroup = "Y";
            } else {
                $newgroup = "N";
            }
            if (!isset($_POST['lastgroupname']) && isset($move)) {
                $newgroup = "Y";
            }
        }
    }
    return array($newgroup, $gid, $groupname, $groupdescription, $gl);
}
Example #9
0
/**
 * This function replaces keywords in a text and is mainly intended for templates
 * If you use this functions put your replacement strings into the $replacements variable
 * instead of using global variables
 *
 * @param mixed $line Text to search in
 * @param mixed $replacements Array of replacements:  Array( <stringtosearch>=><stringtoreplacewith>
 * @return string  Text with replaced strings
 */
function templatereplace($line, $replacements = array())
{
    global $surveylist, $sitename, $clienttoken, $rooturl;
    global $thissurvey, $imagefiles, $defaulttemplate;
    global $percentcomplete, $move;
    global $groupname, $groupdescription;
    global $question;
    global $answer, $navigator;
    global $help, $totalquestions, $surveyformat;
    global $completed, $register_errormsg;
    global $notanswered, $privacy, $surveyid;
    global $publicurl, $templatedir, $token;
    global $assessments, $s_lang;
    global $errormsg, $clang;
    global $saved_id, $usertemplaterootdir;
    global $totalBoilerplatequestions, $relativeurl;
    global $languagechanger;
    global $printoutput, $captchapath, $loadname;
    // lets sanitize the survey template
    if (isset($thissurvey['templatedir'])) {
        $templatename = $thissurvey['templatedir'];
    } else {
        $templatename = $defaulttemplate;
    }
    $templatename = validate_templatedir($templatename);
    // create absolute template URL and template dir vars
    $templateurl = sGetTemplateURL($templatename) . '/';
    $templatedir = sgetTemplatePath($templatename);
    if (stripos($line, "</head>")) {
        $line = str_ireplace("</head>", "<script type=\"text/javascript\" src=\"{$rooturl}/scripts/survey_runtime.js\"></script>\n" . use_firebug() . "\t</head>", $line);
    }
    // If there are non-bracketed replacements to be made do so above this line.
    // Only continue in this routine if there are bracketed items to replace {}
    if (strpos($line, "{") === false) {
        return $line;
    }
    foreach ($replacements as $replacementkey => $replacementvalue) {
        if (strpos($line, '{' . $replacementkey . '}') !== false) {
            $line = str_replace('{' . $replacementkey . '}', $replacementvalue, $line);
        }
    }
    if (strpos($line, "{SURVEYLISTHEADING}") !== false) {
        $line = str_replace("{SURVEYLISTHEADING}", $surveylist['listheading'], $line);
    }
    if (strpos($line, "{SURVEYLIST}") !== false) {
        $line = str_replace("{SURVEYLIST}", $surveylist['list'], $line);
    }
    if (strpos($line, "{NOSURVEYID}") !== false) {
        $line = str_replace("{NOSURVEYID}", $surveylist['nosid'], $line);
    }
    if (strpos($line, "{SURVEYCONTACT}") !== false) {
        $line = str_replace("{SURVEYCONTACT}", $surveylist['contact'], $line);
    }
    if (strpos($line, "{SITENAME}") !== false) {
        $line = str_replace("{SITENAME}", $sitename, $line);
    }
    if (strpos($line, "{SURVEYLIST}") !== false) {
        $line = str_replace("{SURVEYLIST}", $surveylist, $line);
    }
    if (strpos($line, "{CHECKJAVASCRIPT}") !== false) {
        $line = str_replace("{CHECKJAVASCRIPT}", "<noscript><span class='warningjs'>" . $clang->gT("Caution: JavaScript execution is disabled in your browser. You may not be able to answer all questions in this survey. Please, verify your browser parameters.") . "</span></noscript>", $line);
    }
    if (strpos($line, "{ANSWERTABLE}") !== false) {
        $line = str_replace("{ANSWERTABLE}", $printoutput, $line);
    }
    if (strpos($line, "{SURVEYNAME}") !== false) {
        $line = str_replace("{SURVEYNAME}", $thissurvey['name'], $line);
    }
    if (strpos($line, "{SURVEYDESCRIPTION}") !== false) {
        $line = str_replace("{SURVEYDESCRIPTION}", $thissurvey['description'], $line);
    }
    if (strpos($line, "{WELCOME}") !== false) {
        $line = str_replace("{WELCOME}", $thissurvey['welcome'], $line);
    }
    if (strpos($line, "{LANGUAGECHANGER}") !== false) {
        $line = str_replace("{LANGUAGECHANGER}", $languagechanger, $line);
    }
    if (strpos($line, "{PERCENTCOMPLETE}") !== false) {
        $line = str_replace("{PERCENTCOMPLETE}", $percentcomplete, $line);
    }
    if (strpos($line, "{GROUPNAME}") !== false) {
        $line = str_replace("{GROUPNAME}", $groupname, $line);
    }
    if (strpos($line, "{GROUPDESCRIPTION}") !== false) {
        $line = str_replace("{GROUPDESCRIPTION}", $groupdescription, $line);
    }
    if (is_array($question)) {
        if (strpos($line, "{QUESTION}") !== false) {
            $line = str_replace("{QUESTION}", $question['all'], $line);
        } else {
            if (strpos($line, "{QUESTION_TEXT}") !== false) {
                $line = str_replace("{QUESTION_TEXT}", $question['text'], $line);
            }
            if (strpos($line, "{QUESTION_HELP}") !== false) {
                $line = str_replace("{QUESTION_HELP}", $question['help'], $line);
            }
            if (strpos($line, "{QUESTION_MANDATORY}") !== false) {
                $line = str_replace("{QUESTION_MANDATORY}", $question['mandatory'], $line);
            }
            if (strpos($line, "{QUESTION_MAN_MESSAGE}") !== false) {
                $line = str_replace("{QUESTION_MAN_MESSAGE}", $question['man_message'], $line);
            }
            if (strpos($line, "{QUESTION_VALID_MESSAGE}") !== false) {
                $line = str_replace("{QUESTION_VALID_MESSAGE}", $question['valid_message'], $line);
            }
        }
    } else {
        if (strpos($line, "{QUESTION}") !== false) {
            $line = str_replace("{QUESTION}", $question, $line);
        }
    }
    if (strpos($line, '{QUESTION_ESSENTIALS}') !== false) {
        $line = str_replace('{QUESTION_ESSENTIALS}', $question['essentials'], $line);
    }
    if (strpos($line, '{QUESTION_CLASS}') !== false) {
        $line = str_replace('{QUESTION_CLASS}', $question['class'], $line);
    }
    if (strpos($line, '{QUESTION_MAN_CLASS}') !== false) {
        $line = str_replace('{QUESTION_MAN_CLASS}', $question['man_class'], $line);
    }
    if (strpos($line, "{QUESTION_INPUT_ERROR_CLASS}") !== false) {
        $line = str_replace("{QUESTION_INPUT_ERROR_CLASS}", $question['input_error_class'], $line);
    }
    if (strpos($line, "{QUESTION_CODE}") !== false) {
        $line = str_replace("{QUESTION_CODE}", $question['code'], $line);
    }
    if (strpos($line, "{ANSWER}") !== false) {
        $line = str_replace("{ANSWER}", $answer, $line);
    }
    $totalquestionsAsked = $totalquestions - $totalBoilerplatequestions;
    if ($totalquestionsAsked < 1) {
        if (strpos($line, "{THEREAREXQUESTIONS}") !== false) {
            $line = str_replace("{THEREAREXQUESTIONS}", $clang->gT("There are no questions in this survey"), $line);
        }
        //Singular
    }
    if ($totalquestionsAsked == 1) {
        if (strpos($line, "{THEREAREXQUESTIONS}") !== false) {
            $line = str_replace("{THEREAREXQUESTIONS}", $clang->gT("There is 1 question in this survey"), $line);
        }
        //Singular
    } else {
        if (strpos($line, "{THEREAREXQUESTIONS}") !== false) {
            $line = str_replace("{THEREAREXQUESTIONS}", $clang->gT("There are {NUMBEROFQUESTIONS} questions in this survey."), $line);
        }
        //Note this line MUST be before {NUMBEROFQUESTIONS}
    }
    if (strpos($line, "{NUMBEROFQUESTIONS}") !== false) {
        $line = str_replace("{NUMBEROFQUESTIONS}", $totalquestionsAsked, $line);
    }
    if (strpos($line, "{TOKEN}") !== false) {
        if (isset($token)) {
            $line = str_replace("{TOKEN}", $token, $line);
        } elseif (isset($clienttoken)) {
            $line = str_replace("{TOKEN}", htmlentities($clienttoken, ENT_QUOTES, 'UTF-8'), $line);
        } else {
            $line = str_replace("{TOKEN}", '', $line);
        }
    }
    if (strpos($line, "{SID}") !== false) {
        $line = str_replace("{SID}", $surveyid, $line);
    }
    if (strpos($line, "{EXPIRY}") !== false) {
        $line = str_replace("{EXPIRY}", $thissurvey['expiry'], $line);
    }
    if (strpos($line, "{EXPIRY-DMY}") !== false) {
        $line = str_replace("{EXPIRY-DMY}", date("d-m-Y", strtotime($thissurvey["expiry"])), $line);
    }
    if (strpos($line, "{EXPIRY-MDY}") !== false) {
        $line = str_replace("{EXPIRY-MDY}", date("m-d-Y", strtotime($thissurvey["expiry"])), $line);
    }
    if (strpos($line, "{NAVIGATOR}") !== false) {
        $line = str_replace("{NAVIGATOR}", $navigator, $line);
    }
    if (strpos($line, "{SUBMITBUTTON}") !== false) {
        $submitbutton = "          <input class='submit' type='submit' value=' " . $clang->gT("Submit") . " ' name='move2' onclick=\"javascript:document.limesurvey.move.value = 'movesubmit';\" />";
        $line = str_replace("{SUBMITBUTTON}", $submitbutton, $line);
    }
    if (strpos($line, "{COMPLETED}") !== false) {
        $line = str_replace("{COMPLETED}", $completed, $line);
    }
    if (strpos($line, "{URL}") !== false) {
        if ($thissurvey['surveyls_url'] != "") {
            if (trim($thissurvey['surveyls_urldescription']) != '') {
                $linkreplace = "<a href='{$thissurvey['surveyls_url']}'>{$thissurvey['surveyls_urldescription']}</a>";
            } else {
                $linkreplace = "<a href='{$thissurvey['surveyls_url']}'>{$thissurvey['surveyls_url']}</a>";
            }
        } else {
            $linkreplace = '';
        }
        $line = str_replace("{URL}", $linkreplace, $line);
        $line = str_replace("{SAVEDID}", $saved_id, $line);
        // to activate the SAVEDID in the END URL
        if (isset($clienttoken)) {
            $token = $clienttoken;
        } else {
            $token = '';
        }
        $line = str_replace("{TOKEN}", urlencode($token), $line);
        // to activate the TOKEN in the END URL
        $line = str_replace("{SID}", $surveyid, $line);
        // to activate the SID in the RND URL
    }
    if (strpos($line, "{PRIVACY}") !== false) {
        $line = str_replace("{PRIVACY}", $privacy, $line);
    }
    if (strpos($line, "{PRIVACYMESSAGE}") !== false) {
        $line = str_replace("{PRIVACYMESSAGE}", "<span style='font-weight:bold; font-style: italic;'>" . $clang->gT("A Note On Privacy") . "</span><br />" . $clang->gT("This survey is anonymous.") . "<br />" . $clang->gT("The record kept of your survey responses does not contain any identifying information about you unless a specific question in the survey has asked for this."), $line);
        // If you have responded to a survey that used an identifying token to allow you to access the survey, you can rest assured that the identifying token is not kept with your responses. It is managed in a separate database, and will only be updated to indicate that you have (or haven't) completed this survey. There is no way of matching identification tokens with survey responses in this survey.
    }
    if (strpos($line, "{CLEARALL}") !== false) {
        $clearall = "          <input type='button' name='clearallbtn' value='" . $clang->gT("Exit and Clear Survey") . "' class='clearall' " . "onclick=\"if (confirm('" . $clang->gT("Are you sure you want to clear all your responses?", 'js') . "')) {window.open('{$publicurl}/index.php?sid={$surveyid}&amp;move=clearall&amp;lang=" . $_SESSION['s_lang'];
        if (returnglobal('token')) {
            $clearall .= "&amp;token=" . urlencode(trim(sanitize_xss_string(strip_tags(returnglobal('token')))));
        }
        $clearall .= "', '_top')}\" />";
        $line = str_replace("{CLEARALL}", $clearall, $line);
    }
    // --> START NEW FEATURE - SAVE
    if (strpos($line, "{DATESTAMP}") !== false) {
        if (isset($_SESSION['datestamp'])) {
            $line = str_replace("{DATESTAMP}", $_SESSION['datestamp'], $line);
        } else {
            $line = str_replace("{DATESTAMP}", "-", $line);
        }
    }
    // <-- END NEW FEATURE - SAVE
    if (strpos($line, "{SAVE}") !== false) {
        //Set up save/load feature
        if ($thissurvey['allowsave'] == "Y") {
            // Find out if the user has any saved data
            if ($thissurvey['format'] == 'A') {
                $saveall = "          <input type='submit' name='loadall' value='" . $clang->gT("Load Unfinished Survey") . "' class='saveall' " . ($thissurvey['active'] != "Y" ? "disabled='disabled'" : "") . "/>" . "          <input type='button' name='saveallbtn' value='" . $clang->gT("Resume Later") . "' class='saveall' onclick=\"javascript:document.limesurvey.move.value = this.value;addHiddenField(document.getElementById('limesurvey'),'saveall',this.value);document.getElementById('limesurvey').submit();\" " . ($thissurvey['active'] != "Y" ? "disabled='disabled'" : "") . "/>";
                // Show Save So Far button
            } elseif (!isset($_SESSION['step']) || !$_SESSION['step']) {
                $saveall = "          <input type='submit' name='loadall' value='" . $clang->gT("Load Unfinished Survey") . "' class='saveall' " . ($thissurvey['active'] != "Y" ? "disabled='disabled'" : "") . "/>";
            } elseif (isset($_SESSION['scid']) && (isset($move) && $move == "movelast")) {
                $saveall = "";
            } else {
                $saveall = "          <input type='button' name='saveallbtn' value='" . $clang->gT("Resume Later") . "' class='saveall' onclick=\"javascript:document.limesurvey.move.value = this.value;addHiddenField(document.getElementById('limesurvey'),'saveall',this.value);document.getElementById('limesurvey').submit();\" " . ($thissurvey['active'] != "Y" ? "disabled='disabled'" : "") . "/>";
                // Show Save So Far button
            }
        } else {
            $saveall = "";
        }
        $line = str_replace("{SAVE}", $saveall, $line);
    }
    if (strpos($line, "{TEMPLATEURL}") !== false) {
        $line = str_replace("{TEMPLATEURL}", $templateurl, $line);
    }
    if (strpos($line, "{TEMPLATECSS}") !== false) {
        $templatecss = "<link rel='stylesheet' type='text/css' href='{$templateurl}template.css' />\n";
        if (getLanguageRTL($clang->langcode)) {
            $templatecss .= "<link rel='stylesheet' type='text/css' href='{$templateurl}template-rtl.css' />\n";
        }
        $line = str_replace("{TEMPLATECSS}", $templatecss, $line);
    }
    if (FlattenText($help, true) != '') {
        if (strpos($line, "{QUESTIONHELP}") !== false) {
            if (!isset($helpicon)) {
                if (file_exists($templatedir . '/help.gif')) {
                    $helpicon = $templateurl . 'help.gif';
                } elseif (file_exists($templatedir . '/help.png')) {
                    $helpicon = $templateurl . 'help.png';
                } else {
                    $helpicon = $imagefiles . "/help.gif";
                }
            }
            $line = str_replace("{QUESTIONHELP}", "<img src='{$helpicon}' alt='Help' align='left' />" . $help, $line);
        }
        if (strpos($line, "{QUESTIONHELPPLAINTEXT}") !== false) {
            $line = str_replace("{QUESTIONHELPPLAINTEXT}", strip_tags(addslashes($help)), $line);
        }
    } else {
        if (strpos($line, "{QUESTIONHELP}") !== false) {
            $line = str_replace("{QUESTIONHELP}", $help, $line);
        }
        if (strpos($line, "{QUESTIONHELPPLAINTEXT}") !== false) {
            $line = str_replace("{QUESTIONHELPPLAINTEXT}", strip_tags(addslashes($help)), $line);
        }
    }
    $line = insertansReplace($line);
    if (strpos($line, "{SUBMITCOMPLETE}") !== false) {
        $line = str_replace("{SUBMITCOMPLETE}", "<strong>" . $clang->gT("Thank You!") . "<br /><br />" . $clang->gT("You have completed answering the questions in this survey.") . "</strong><br /><br />" . $clang->gT("Click on 'Submit' now to complete the process and save your answers."), $line);
    }
    if (strpos($line, "{SUBMITREVIEW}") !== false) {
        if (isset($thissurvey['allowprev']) && $thissurvey['allowprev'] == "N") {
            $strreview = "";
        } else {
            $strreview = $clang->gT("If you want to check any of the answers you have made, and/or change them, you can do that now by clicking on the [<< prev] button and browsing through your responses.");
        }
        $line = str_replace("{SUBMITREVIEW}", $strreview, $line);
    }
    $line = tokenReplace($line);
    if (strpos($line, "{ANSWERSCLEARED}") !== false) {
        $line = str_replace("{ANSWERSCLEARED}", $clang->gT("Answers Cleared"), $line);
    }
    if (strpos($line, "{RESTART}") !== false) {
        if ($thissurvey['active'] == "N") {
            $replacetext = "<a href='{$publicurl}/index.php?sid={$surveyid}&amp;newtest=Y";
            if (isset($s_lang) && $s_lang != '') {
                $replacetext .= "&amp;lang=" . $s_lang;
            }
            $replacetext .= "'>" . $clang->gT("Restart this Survey") . "</a>";
            $line = str_replace("{RESTART}", $replacetext, $line);
        } else {
            $restart_extra = "";
            $restart_token = returnglobal('token');
            if (!empty($restart_token)) {
                $restart_extra .= "&amp;token=" . urlencode($restart_token);
            } else {
                $restart_extra = "&amp;newtest=Y";
            }
            if (!empty($_GET['lang'])) {
                $restart_extra .= "&amp;lang=" . returnglobal('lang');
            }
            $line = str_replace("{RESTART}", "<a href='{$publicurl}/index.php?sid={$surveyid}" . $restart_extra . "'>" . $clang->gT("Restart this Survey") . "</a>", $line);
        }
    }
    if (strpos($line, "{CLOSEWINDOW}") !== false) {
        $line = str_replace("{CLOSEWINDOW}", "<a href='javascript:%20self.close()'>" . $clang->gT("Close this Window") . "</a>", $line);
    }
    if (strpos($line, "{SAVEERROR}") !== false) {
        $line = str_replace("{SAVEERROR}", $errormsg, $line);
    }
    if (strpos($line, "{SAVEHEADING}") !== false) {
        $line = str_replace("{SAVEHEADING}", $clang->gT("Save Your Unfinished Survey"), $line);
    }
    if (strpos($line, "{SAVEMESSAGE}") !== false) {
        $line = str_replace("{SAVEMESSAGE}", $clang->gT("Enter a name and password for this survey and click save below.") . "<br />\n" . $clang->gT("Your survey will be saved using that name and password, and can be completed later by logging in with the same name and password.") . "<br /><br />\n" . $clang->gT("If you give an email address, an email containing the details will be sent to you."), $line);
    }
    if (strpos($line, "{RETURNTOSURVEY}") !== false) {
        $savereturn = "<a href='{$relativeurl}/index.php?sid={$surveyid}";
        if (returnglobal('token')) {
            $savereturn .= "&amp;token=" . urlencode(trim(sanitize_xss_string(strip_tags(returnglobal('token')))));
        }
        $savereturn .= "'>" . $clang->gT("Return To Survey") . "</a>";
        $line = str_replace("{RETURNTOSURVEY}", $savereturn, $line);
    }
    if (strpos($line, "{SAVEFORM}") !== false) {
        //SAVE SURVEY DETAILS
        $saveform = "<table><tr><td align='right'>" . $clang->gT("Name") . ":</td><td><input type='text' name='savename' value='";
        if (isset($_POST['savename'])) {
            $saveform .= html_escape(auto_unescape($_POST['savename']));
        }
        $saveform .= "' /></td></tr>\n" . "<tr><td align='right'>" . $clang->gT("Password") . ":</td><td><input type='password' name='savepass' value='";
        if (isset($_POST['savepass'])) {
            $saveform .= html_escape(auto_unescape($_POST['savepass']));
        }
        $saveform .= "' /></td></tr>\n" . "<tr><td align='right'>" . $clang->gT("Repeat Password") . ":</td><td><input type='password' name='savepass2' value='";
        if (isset($_POST['savepass2'])) {
            $saveform .= html_escape(auto_unescape($_POST['savepass2']));
        }
        $saveform .= "' /></td></tr>\n" . "<tr><td align='right'>" . $clang->gT("Your Email") . ":</td><td><input type='text' name='saveemail' value='";
        if (isset($_POST['saveemail'])) {
            $saveform .= html_escape(auto_unescape($_POST['saveemail']));
        }
        $saveform .= "' /></td></tr>\n";
        if (function_exists("ImageCreate") && captcha_enabled('saveandloadscreen', $thissurvey['usecaptcha'])) {
            $saveform .= "<tr><td align='right'>" . $clang->gT("Security Question") . ":</td><td><table><tr><td valign='middle'><img src='{$captchapath}verification.php?sid={$surveyid}' alt='' /></td><td valign='middle' style='text-align:left'><input type='text' size='5' maxlength='3' name='loadsecurity' value='' /></td></tr></table></td></tr>\n";
        }
        $saveform .= "<tr><td align='right'></td><td></td></tr>\n" . "<tr><td></td><td><input type='submit'  id='savebutton' name='savesubmit' value='" . $clang->gT("Save Now") . "' /></td></tr>\n" . "</table>";
        $line = str_replace("{SAVEFORM}", $saveform, $line);
    }
    if (strpos($line, "{LOADERROR}") !== false) {
        $line = str_replace("{LOADERROR}", $errormsg, $line);
    }
    if (strpos($line, "{LOADHEADING}") !== false) {
        $line = str_replace("{LOADHEADING}", $clang->gT("Load A Previously Saved Survey"), $line);
    }
    if (strpos($line, "{LOADMESSAGE}") !== false) {
        $line = str_replace("{LOADMESSAGE}", $clang->gT("You can load a survey that you have previously saved from this screen.") . "<br />" . $clang->gT("Type in the 'name' you used to save the survey, and the password.") . "<br />", $line);
    }
    if (strpos($line, "{LOADFORM}") !== false) {
        //LOAD SURVEY DETAILS
        $loadform = "<table><tr><td align='right'>" . $clang->gT("Saved name") . ":</td><td><input type='text' name='loadname' value='";
        if ($loadname) {
            $loadform .= html_escape(auto_unescape($loadname));
        }
        $loadform .= "' /></td></tr>\n" . "<tr><td align='right'>" . $clang->gT("Password") . ":</td><td><input type='password' name='loadpass' value='";
        if (isset($loadpass)) {
            $loadform .= html_escape(auto_unescape($loadpass));
        }
        $loadform .= "' /></td></tr>\n";
        if (function_exists("ImageCreate") && captcha_enabled('saveandloadscreen', $thissurvey['usecaptcha'])) {
            $loadform .= "<tr><td align='right'>" . $clang->gT("Security Question") . ":</td><td><table><tr><td valign='middle'><img src='{$captchapath}verification.php?sid={$surveyid}' alt='' /></td><td valign='middle'><input type='text' size='5' maxlength='3' name='loadsecurity' value='' alt=''/></td></tr></table></td></tr>\n";
        }
        $loadform .= "<tr><td align='right'></td><td></td></tr>\n" . "<tr><td></td><td><input type='submit' id='loadbutton' value='" . $clang->gT("Load Now") . "' /></td></tr></table>\n";
        $line = str_replace("{LOADFORM}", $loadform, $line);
    }
    //REGISTER SURVEY DETAILS
    if (strpos($line, "{REGISTERERROR}") !== false) {
        $line = str_replace("{REGISTERERROR}", $register_errormsg, $line);
    }
    if (strpos($line, "{REGISTERMESSAGE1}") !== false) {
        $line = str_replace("{REGISTERMESSAGE1}", $clang->gT("You must be registered to complete this survey"), $line);
    }
    if (strpos($line, "{REGISTERMESSAGE2}") !== false) {
        $line = str_replace("{REGISTERMESSAGE2}", $clang->gT("You may register for this survey if you wish to take part.") . "<br />\n" . $clang->gT("Enter your details below, and an email containing the link to participate in this survey will be sent immediately."), $line);
    }
    if (strpos($line, "{REGISTERFORM}") !== false) {
        $registerform = "<form method='post' action='{$publicurl}/register.php'>\n" . "<table class='register' summary='Registrationform'>\n" . "<tr><td align='right'>" . "<input type='hidden' name='sid' value='{$surveyid}' id='sid' />\n" . $clang->gT("First Name") . ":</td>" . "<td align='left'><input class='text' type='text' name='register_firstname'";
        if (isset($_POST['register_firstname'])) {
            $registerform .= " value='" . htmlentities(returnglobal('register_firstname'), ENT_QUOTES, 'UTF-8') . "'";
        }
        $registerform .= " /></td></tr>" . "<tr><td align='right'>" . $clang->gT("Last Name") . ":</td>\n" . "<td align='left'><input class='text' type='text' name='register_lastname'";
        if (isset($_POST['register_lastname'])) {
            $registerform .= " value='" . htmlentities(returnglobal('register_lastname'), ENT_QUOTES, 'UTF-8') . "'";
        }
        $registerform .= " /></td></tr>\n" . "<tr><td align='right'>" . $clang->gT("Email Address") . ":</td>\n" . "<td align='left'><input class='text' type='text' name='register_email'";
        if (isset($_POST['register_email'])) {
            $registerform .= " value='" . htmlentities(returnglobal('register_email'), ENT_QUOTES, 'UTF-8') . "'";
        }
        $registerform .= " /></td></tr>\n";
        if (!isset($_REQUEST['lang'])) {
            $reglang = GetBaseLanguageFromSurveyID($surveyid);
        } else {
            $reglang = returnglobal('lang');
        }
        if (function_exists("ImageCreate") && captcha_enabled('registrationscreen', $thissurvey['usecaptcha'])) {
            $registerform .= "<tr><td align='right'>" . $clang->gT("Security Question") . ":</td><td><table><tr><td valign='middle'><img src='{$captchapath}verification.php?sid={$surveyid}' alt='' /></td><td valign='middle'><input type='text' size='5' maxlength='3' name='loadsecurity' value='' /></td></tr></table></td></tr>\n";
        }
        $registerform .= "<tr><td align='right'><input type='hidden' name='lang' value='" . $reglang . "' /></td><td></td></tr>\n";
        /*      if(isset($thissurvey['attribute1']) && $thissurvey['attribute1'])
                {
                $registerform .= "<tr><td align='right'>".$thissurvey['attribute1'].":</td>\n"
                ."<td align='left'><input class='text' type='text' name='register_attribute1'";
                if (isset($_POST['register_attribute1']))
                {
                $registerform .= " value='".htmlentities(returnglobal('register_attribute1'),ENT_QUOTES,'UTF-8')."'";
                }
                $registerform .= " /></td></tr>\n";
                }
                if(isset($thissurvey['attribute2']) && $thissurvey['attribute2'])
                {
                $registerform .= "<tr><td align='right'>".$thissurvey['attribute2'].":</td>\n"
                ."<td align='left'><input class='text' type='text' name='register_attribute2'";
                if (isset($_POST['register_attribute2']))
                {
                $registerform .= " value='".htmlentities(returnglobal('register_attribute2'),ENT_QUOTES,'UTF-8')."'";
                }
                $registerform .= " /></td></tr>\n";
                }        */
        $registerform .= "<tr><td></td><td><input id='registercontinue' class='submit' type='submit' value='" . $clang->gT("Continue") . "' />" . "</td></tr>\n" . "</table>\n" . "</form>\n";
        $line = str_replace("{REGISTERFORM}", $registerform, $line);
    }
    if (strpos($line, "{ASSESSMENT_CURRENT_TOTAL}") !== false && function_exists('doAssessment')) {
        $assessmentdata = doAssessment($surveyid, true);
        $line = str_replace("{ASSESSMENT_CURRENT_TOTAL}", $assessmentdata['total'], $line);
    }
    if (strpos($line, "{ASSESSMENTS}") !== false) {
        $line = str_replace("{ASSESSMENTS}", $assessments, $line);
    }
    if (strpos($line, "{ASSESSMENT_HEADING}") !== false) {
        $line = str_replace("{ASSESSMENT_HEADING}", $clang->gT("Your Assessment"), $line);
    }
    return $line;
}