本文整理汇总了PHP中Token::sanitizeToken方法的典型用法代码示例。如果您正苦于以下问题:PHP Token::sanitizeToken方法的具体用法?PHP Token::sanitizeToken怎么用?PHP Token::sanitizeToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token::sanitizeToken方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionparticipants
/**
* This function is run when opting out of the participants system. The other function /optout/token
* opts the user out of just a single token/survey invite list
*/
function actionparticipants()
{
$iSurveyID = Yii::app()->request->getQuery('surveyid');
$sLanguageCode = Yii::app()->request->getQuery('langcode');
$sToken = Token::sanitizeToken(Yii::app()->request->getQuery('token'));
Yii::app()->loadHelper('database');
Yii::app()->loadHelper('sanitize');
if (!$iSurveyID) {
$this->redirect(array('/'));
}
$iSurveyID = (int) $iSurveyID;
//Make sure it's an integer (protect from SQL injects)
//Check that there is a SID
// Get passed language from form, so that we dont lose this!
if (!isset($sLanguageCode) || $sLanguageCode == "" || !$sLanguageCode) {
$sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language;
} else {
$sBaseLanguage = sanitize_languagecode($sLanguageCode);
}
Yii::app()->setLanguage($sBaseLanguage);
$aSurveyInfo = getSurveyInfo($iSurveyID, $sBaseLanguage);
if ($aSurveyInfo == false || !tableExists("{{tokens_{$iSurveyID}}}")) {
throw new CHttpException(404, "The survey in which you are trying to participate does not seem to exist. It may have been deleted or the link you were given is outdated or incorrect.");
} else {
LimeExpressionManager::singleton()->loadTokenInformation($iSurveyID, $sToken, false);
$oToken = Token::model($iSurveyID)->findByAttributes(array('token' => $sToken));
if (!isset($oToken)) {
$sMessage = gT('You are not a participant in this survey.');
} else {
if (substr($oToken->emailstatus, 0, strlen('OptOut')) !== 'OptOut') {
$oToken->emailstatus = 'OptOut';
$oToken->save();
$sMessage = gT('You have been successfully removed from this survey.');
} else {
$sMessage = gT('You have been already removed from this survey.');
}
if (!empty($oToken->participant_id)) {
//Participant also exists in central db
$oParticipant = Participant::model()->findByPk($oToken->participant_id);
if ($oParticipant->blacklisted == "Y") {
$sMessage .= "<br />";
$sMessage .= gT("You have already been removed from the central participants list for this site");
} else {
$oParticipant->blacklisted = 'Y';
$oParticipant->save();
$sMessage .= "<br />";
$sMessage .= gT("You have been removed from the central participants list for this site");
}
}
}
}
$this->_renderHtml($sMessage, $aSurveyInfo, $iSurveyID);
}
示例2: actiontokens
function actiontokens($surveyid, $token, $langcode = '')
{
Yii::app()->loadHelper('database');
Yii::app()->loadHelper('sanitize');
$sLanguageCode = $langcode;
$iSurveyID = $surveyid;
$sToken = $token;
$sToken = Token::sanitizeToken($sToken);
if (!$iSurveyID) {
$this->redirect(array('/'));
}
$iSurveyID = (int) $iSurveyID;
//Check that there is a SID
// Get passed language from form, so that we dont loose this!
if (!isset($sLanguageCode) || $sLanguageCode == "" || !$sLanguageCode) {
$sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language;
} else {
$sBaseLanguage = sanitize_languagecode($sLanguageCode);
}
Yii::app()->setLanguage($sBaseLanguage);
$aSurveyInfo = getSurveyInfo($iSurveyID, $sBaseLanguage);
if ($aSurveyInfo == false || !tableExists("{{tokens_{$iSurveyID}}}")) {
throw new CHttpException(404, "This survey does not seem to exist. It may have been deleted or the link you were given is outdated or incorrect.");
} else {
LimeExpressionManager::singleton()->loadTokenInformation($iSurveyID, $token, false);
$oToken = Token::model($iSurveyID)->findByAttributes(array('token' => $token));
if (!isset($oToken)) {
$sMessage = gT('You are not a participant in this survey.');
} else {
if ($oToken->emailstatus == 'OptOut') {
$oToken->emailstatus = 'OK';
$oToken->save();
$sMessage = gT('You have been successfully added back to this survey.');
} elseif ($oToken->emailstatus == 'OK') {
$sMessage = gT('You are already a part of this survey.');
} else {
$sMessage = gT('You have been already removed from this survey.');
}
}
}
$this->_renderHtml($sMessage, $aSurveyInfo, $iSurveyID);
}
示例3: templatereplace
//.........这里部分代码省略.........
} else {
$_saveall = "";
$_savelinks = "";
}
if (isset($thissurvey['allowprev']) && $thissurvey['allowprev'] == "N") {
$_strreview = "";
} else {
$_strreview = 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($surveyid)) {
$restartparam = array();
if ($_token) {
$restartparam['token'] = sanitize_token($_token);
}
// urlencode with needed with sanitize_token
if (Yii::app()->request->getQuery('lang')) {
$restartparam['lang'] = sanitize_languagecode(Yii::app()->request->getQuery('lang'));
} elseif ($s_lang) {
$restartparam['lang'] = $s_lang;
}
$restartparam['newtest'] = "Y";
$restarturl = Yii::app()->getController()->createUrl("survey/index/sid/{$surveyid}", $restartparam);
$_restart = "<a href='{$restarturl}'>" . gT("Restart this Survey") . "</a>";
} else {
$_restart = "";
}
if (isset($thissurvey['anonymized']) && $thissurvey['anonymized'] == 'Y') {
$_savealert = gT("To remain anonymous please use a pseudonym as your username, also an email address is not required.");
} else {
$_savealert = "";
}
if (isset($surveyid)) {
if ($_token) {
$returnlink = Yii::app()->getController()->createUrl("survey/index/sid/{$surveyid}", array('token' => Token::sanitizeToken($_token)));
} else {
$returnlink = Yii::app()->getController()->createUrl("survey/index/sid/{$surveyid}");
}
$_return_to_survey = "<a href='{$returnlink}'>" . gT("Return to survey") . "</a>";
} else {
$_return_to_survey = "";
}
// Save Form
$_saveform = "<table class='save-survey-form'><tr class='save-survey-row save-survey-name'><td class='save-survey-label label-cell' align='right'><label for='savename'>" . gT("Name") . "</label>:</td><td class='save-survey-input input-cell'><input type='text' name='savename' id='savename' value='";
if (isset($_POST['savename'])) {
$_saveform .= HTMLEscape(autoUnescape($_POST['savename']));
}
$_saveform .= "' /></td></tr>\n" . "<tr class='save-survey-row save-survey-password-1'><td class='save-survey-label label-cell' align='right'><label for='savepass'>" . gT("Password") . "</label>:</td><td class='save-survey-input input-cell'><input type='password' id='savepass' name='savepass' value='";
if (isset($_POST['savepass'])) {
$_saveform .= HTMLEscape(autoUnescape($_POST['savepass']));
}
$_saveform .= "' /></td></tr>\n" . "<tr class='save-survey-row save-survey-password-2'><td class='save-survey-label label-cell' align='right'><label for='savepass2'>" . gT("Repeat password") . "</label>:</td><td class='save-survey-input input-cell'><input type='password' id='savepass2' name='savepass2' value='";
if (isset($_POST['savepass2'])) {
$_saveform .= HTMLEscape(autoUnescape($_POST['savepass2']));
}
$_saveform .= "' /></td></tr>\n" . "<tr class='save-survey-row save-survey-email'><td class='save-survey-label label-cell' align='right'><label for='saveemail'>" . gT("Your email address") . "</label>:</td><td class='save-survey-input input-cell'><input type='text' id='saveemail' name='saveemail' value='";
if (isset($_POST['saveemail'])) {
$_saveform .= HTMLEscape(autoUnescape($_POST['saveemail']));
}
$_saveform .= "' /></td></tr>\n";
if (isset($thissurvey['usecaptcha']) && function_exists("ImageCreate") && isCaptchaEnabled('saveandloadscreen', $thissurvey['usecaptcha'])) {
$_saveform .= "<tr class='save-survey-row save-survey-captcha'><td class='save-survey-label label-cell' align='right'><label for='loadsecurity'>" . gT("Security question") . "</label>:</td><td class='save-survey-input input-cell'><table class='captcha-table'><tr><td class='captcha-image' valign='middle'><img alt='' src='" . Yii::app()->getController()->createUrl('/verification/image/sid/' . (isset($surveyid) ? $surveyid : '')) . "' /></td><td class='captcha-input' valign='middle' style='text-align:left'><input type='text' size='5' maxlength='3' id='loadsecurity' name='loadsecurity' value='' /></td></tr></table></td></tr>\n";
}
$_saveform .= "<tr><td align='right'></td><td></td></tr>\n" . "<tr class='save-survey-row save-survey-submit'><td class='save-survey-label label-cell'><label class='hide jshide' for='savebutton'>" . gT("Save Now") . "</label></td><td class='save-survey-input input-cell'><input type='submit' id='savebutton' name='savesubmit' class='button' value='" . gT("Save Now") . "' /></td></tr>\n" . "</table>";
// Load Form
$_loadform = "<table class='load-survey-form'><tr class='load-survey-row load-survey-name'><td class='load-survey-label label-cell' align='right'><label for='loadname'>" . gT("Saved name") . "</label>:</td><td class='load-survey-input input-cell'><input type='text' id='loadname' name='loadname' value='";
if (isset($loadname)) {
示例4: sanitize_token
/**
* @deprecated use Token::sanitizeToken($codetosanitize);
*/
function sanitize_token($codetosanitize)
{
return Token::sanitizeToken($codetosanitize);
}