本文整理汇总了PHP中SecurityToken::GetToken方法的典型用法代码示例。如果您正苦于以下问题:PHP SecurityToken::GetToken方法的具体用法?PHP SecurityToken::GetToken怎么用?PHP SecurityToken::GetToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SecurityToken
的用法示例。
在下文中一共展示了SecurityToken::GetToken方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onAuthenticationSuccess
/**
* This is called when an interactive authentication attempt succeeds. This
* is called by authentication listeners inheriting from AbstractAuthenticationListener.
* @param Request $request
* @param TokenInterface $token
* @return Response The response to return
*/
public function onAuthenticationSuccess(Request $request, TokenInterface $token)
{
$user = $token->getUser();
// This should actually be handle by the AuthenticationFailedHandler
if (!$user->isAdmin()) {
// can't go into admin
$request->getSession()->set(SecurityContextInterface::AUTHENTICATION_ERROR, new AuthenticationException('User is not an admin.'));
return $this->httpUtils->createRedirectResponse($request, 'admin_login');
}
\LoginAttempts::DeleteOldLoginAttempts();
\LoginAttempts::ClearLoginAttemptsForIp();
$zendAuth = \Zend_Auth::getInstance();
$this->authAdapter->setUsername($user->getUsername())->setPassword($request->request->get('_password'))->setAdmin(true);
$zendAuth->authenticate($this->authAdapter);
$OAuthtoken = $this->userService->loginUser($user, 'oauth_authorize');
$session = $request->getSession();
$session->set('_security_oauth_authorize', serialize($OAuthtoken));
$frontendToken = $this->userService->loginUser($user, 'frontend_area');
$session = $request->getSession();
$session->set('_security_frontend_area', serialize($frontendToken));
\Article::UnlockByUser($user->getId());
$request->setLocale($request->request->get('login_language'));
$this->setNoCacheCookie($request);
$user->setLastLogin(new \DateTime());
$this->em->flush();
if ($request->get('ajax') === 'true') {
// close popup with login.
return new Response("<script type=\"text/javascript\">window.parent.g_security_token = '" . \SecurityToken::GetToken() . "';window.parent.\$(window.parent.document.body).data('loginDialog').dialog('close');window.parent.setSecurityToken(window.parent.g_security_token);</script>");
}
return parent::onAuthenticationSuccess($request, $token);
}
示例2: getGlobals
public function getGlobals()
{
global $Campsite;
$localeFromCookie = 'en';
if ($this->request) {
$localeFromCookie = $this->request->cookies->has('TOL_Language') == true ? $this->request->cookies->get('TOL_Language') : 'en';
}
try {
$currentUser = $this->container->getService('user')->getCurrentUser();
} catch (AuthenticationException $e) {
$currentUser = null;
}
return array('Newscoop' => $Campsite, 'NewscoopVersion' => new \CampVersion(), 'SecurityToken' => \SecurityToken::GetToken(), 'NewscoopUser' => $currentUser, 'localeFromCookie' => $localeFromCookie);
}
示例3: unset
unset($access);
unset($extension);
unset($extension_start);
unset($question_mark);
unset($no_menu_scripts);
unset($request_uri);
// Restore POST request
$requestId = Input::Get('request', 'string', '', TRUE);
$request = camp_session_get("request_$requestId", '');
if (!empty($request)) {
$request = unserialize($request);
// Update security token.
$token_field = SecurityToken::SECURITY_TOKEN;
$request['post'][$token_field] = SecurityToken::GetToken();
// Set values.
foreach ($request['post'] as $key => $val) {
$_POST[$key] = $_REQUEST[$key] = $val;
}
}
if (file_exists($Campsite['HTML_DIR'] . '/reset_cache')) {
CampCache::singleton()->clear('user');
unlink($GLOBALS['g_campsiteDir'] . '/reset_cache');
}
require_once($Campsite['HTML_DIR'] . "/$ADMIN_DIR/init_content.php");
// Get the main content
ob_start();
示例4:
<!--[if IE 6]>
<style type="text/css">
.fg-menu-ipod .fg-menu li { width: 95%; }
.fg-menu-ipod .ui-widget-content { border:0; }
</style>
<![endif]-->
<script type="text/javascript">
<!--
var g_admin_url = '/<?php
echo $ADMIN;
?>
';
var g_security_token = '<?php
echo SecurityToken::GetToken();
?>
';
<?php
if (strpos($_SERVER['HTTP_REFERER'], 'login.php') !== FALSE) {
?>
if (opener && !opener.closed && opener.setSecurityToken) {
opener.setSecurityToken(g_security_token);
opener.focus();
window.close();
}
<?php
}
?>
var g_admin_img = '<?php
echo $Campsite["ADMIN_IMAGE_BASE_URL"];
示例5: include_once
<link rel="stylesheet" type="text/css" href="<?php echo $Campsite['ADMIN_STYLE_URL']; ?>/admin_stylesheet.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $Campsite['ADMIN_STYLE_URL']; ?>/ColVis.css" />
<style>
body, #tabs { background-color: #f5f5f5; }
#tabs { border: none; }
</style>
<?php include_once($GLOBALS['g_campsiteDir']."/$ADMIN_DIR/javascript_common.php"); ?>
<script src="<?php echo $Campsite['WEBSITE_URL']; ?>/js/jquery/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="<?php echo $Campsite['WEBSITE_URL']; ?>/js/jquery/jquery.dataTables.min.js" type="text/javascript"></script>
<script src="<?php echo $Campsite['WEBSITE_URL']; ?>/js/jquery/ColVis.min.js" type="text/javascript"></script>
<script src="<?php echo $Campsite['WEBSITE_URL']; ?>/js/jquery/jquery-ui-1.8.6.custom.min.js" type="text/javascript"></script>
<script src="<?php echo $Campsite['WEBSITE_URL']; ?>/js/admin.js" type="text/javascript"></script>
<script type="text/javascript">
var g_admin_url = '/<?php echo $ADMIN; ?>';
var g_security_token = '<?php echo SecurityToken::GetToken(); ?>';
var g_admin_img = '<?php echo $Campsite["ADMIN_IMAGE_BASE_URL"]; ?>';
var popupFlash = false;
var localizer = localizer || {};
localizer.processing = '<?php putGS('Processing...'); ?>';
localizer.session_expired = '<?php putGS('Session expired.'); ?>';
localizer.please = '<?php putGS('Please'); ?>';
localizer.login = '<?php putGS('login'); ?>';
$(function() {
$('#tabs').tabs();
});
</script>
</head>
<body>
示例6: setToken
private function setToken()
{
$_REQUEST[SecurityToken::SECURITY_TOKEN] = SecurityToken::GetToken();
}
示例7: getFormMask
private function getFormMask($p_role)
{
$data = $this->m_data;
$mask = array(
array(
'element' => 'action',
'type' => 'hidden',
'constant' => $this->exists() ? 'interviewitem_edit' : 'interviewitem_create'
),
SecurityToken::SECURITY_TOKEN => array(
'element' => SecurityToken::SECURITY_TOKEN,
'type' => 'hidden',
'constant' => SecurityToken::GetToken()
),
array(
'element' => 'f_interview_id',
'type' => 'hidden',
'constant' => $data['fk_interview_id']
),
array(
'element' => 'f_item_id',
'type' => 'hidden',
'constant' => $data['item_id']
),
array(
'element' => 'fk_questioneer_user_id',
'type' => 'hidden',
'constant' => $data['fk_questioneer_user_id']
),
array(
'element' => 'f_question',
'type' => 'textarea',
'label' => getGS('Question'),
'default' => $data['question'],
'required' => $p_role == 'admin' || $p_role == 'moderator' ? true : false,
'attributes'=> $p_role == 'admin' || $p_role == 'moderator' ? false : array('readonly', 'disabled')
),
array(
'element' => 'f_answer',
'type' => 'textarea',
'label' => getGS('Answer'),
'default' => $data['answer'],
'required' => $p_role == 'guest' ? true : false,
'attributes'=> $p_role == 'admin' || $p_role == 'guest' ? false : array('readonly', 'disabled')
),
$p_role == 'admin' || $p_role == 'moderator' ?
array(
'element' => 'f_status',
'type' => 'select',
'label' => getGS('Status'),
'default' => $data['status'],
'options'=> array(
'draft' => getGS('draft'),
'pending' => getGS('pending'),
'published' => getGS('published'),
'rejected' => getGS('rejected')
)
)
: (
$p_role == 'guest' && $data['status'] == 'pending' ?
array(
'element' => 'f_status',
'type' => 'hidden',
'constant' => 'published',
)
:
null
),
array(
'element' => 'f_reset',
'type' => 'reset',
'label' => getGS('Reset'),
'groupit' => true
),
array(
'element' => 'f_submit',
'type' => 'submit',
'label' => getGS('Save'),
'groupit' => true
),
array(
'element' => 'f_cancel',
'type' => 'button',
'label' => getGS('Cancel'),
'attributes' => array('onClick' => 'window.close()'),
'groupit' => true
),
array(
'group' => array('f_reset', 'f_cancel', 'f_submit')
)
);
return $mask;
}
示例8: setcookie
$_POST[SecurityToken::SECURITY_TOKEN] = SecurityToken::GetToken();
}
// fix uri
$_SERVER['REQUEST_URI'] = $this->getRequest()->getRequestUri();
// reset view
$this->view->legacy = NULL;
$this->_helper->layout->enableLayout();
// redirect/forward
if (!empty($_POST['_next']) && $_POST['_next'] == 'post') {
// forward POST request
$this->_forward($this->_getParam('action'), $this->_getParam('controller'), 'admin');
} else {
// redirect GET request
setcookie("TOL_Language", $f_login_language);
if (array_key_exists(SecurityToken::SECURITY_TOKEN, $_GET)) {
$_SERVER['REQUEST_URI'] .= sprintf('&%s=%s', SecurityToken::SECURITY_TOKEN, SecurityToken::GetToken());
}
$this->_redirect($_SERVER['REQUEST_URI'], array('prependBase' => false));
}
return;
}
}
//
// Invalid logins start here.
//
// Record the attempt
LoginAttempts::RecordLoginAttempt();
// CAPTCHA invalid -> captcha login page
if ($validateCaptcha && !PhpCaptcha::Validate($f_captcha_code, true)) {
return 'captcha';
}
示例9: _getFormMask
function _getFormMask($p_admin)
{
global $g_user;
$data = $this->getData();
foreach ($data as $k => $v) {
// clean user input
if (!in_array($k, self::$m_html_allowed_fields)) {
$data[$k] = camp_html_entity_decode_array($v);
}
}
$languageSelectedObj = new Language($data['fk_language_id']);
$editorLanguage = !empty($_COOKIE['TOL_Language']) ? $_COOKIE['TOL_Language'] : $languageSelectedObj->getCode();
$mask = array(
'f_entry_id' => array(
'element' => 'f_entry_id',
'type' => 'hidden',
'constant' => $data['entry_id']
),
SecurityToken::SECURITY_TOKEN => array(
'element' => SecurityToken::SECURITY_TOKEN,
'type' => 'hidden',
'constant' => SecurityToken::GetToken()
),
'f_blog_id' => array(
'element' => 'f_blog_id',
'type' => 'hidden',
'constant' => $data['fk_blog_id']
),
'tiny_mce' => array(
'element' => 'tiny_mce',
'text' => Blog::GetEditor('tiny_mce_box', $g_user, $editorLanguage),
'type' => 'static'
),
'title' => array(
'element' => 'BlogEntry[title]',
'type' => 'text',
'label' => getGS('Title'),
'default' => $data['title'],
'required' => true
),
'content' => array(
'element' => 'BlogEntry[content]',
'type' => 'textarea',
'label' => getGS('Content'),
'default' => $data['content'],
'required' => true,
'attributes'=> array('cols' => 86, 'rows' => 16, 'id' => 'tiny_mce_box', 'class' => 'tinymce')
),
'status' => array(
'element' => 'BlogEntry[status]',
'type' => 'select',
'label' => getGS('Status'),
'default' => $data['status'],
'options' => array(
'online' => 'online',
'offline' => 'offline'
),
'required' => true
),
'admin_status' => array(
'element' => 'BlogEntry[admin_status]',
'type' => 'select',
'label' => getGS('Admin status'),
'default' => $data['admin_status'],
'options' => array(
'online' => 'online',
'offline' => 'offline',
'pending' => 'pending',
),
'required' => true
),
'mood' => array(
'element' => 'BlogEntry[fk_mood_id]',
'type' => 'select',
'label' => getGS('Mood'),
'default' => $data['fk_mood_id'],
'options' => Blog::GetMoodList(!empty($data['fk_laguage_id']) ? $data['fk_laguage_id'] : Blog::GetBlogLanguageId($data['fk_blog_id']))
),
'image' => array(
'element' => 'BlogEntry_Image',
'type' => 'file',
'label' => getGS('Image (.jpg, .png, .gif)'),
),
'image_display' => array(
'element' => 'image_display',
'text' => '<img src="'.$data['images']['100x100'].'">',
'type' => 'static',
'groupit' => true
),
'image_remove' => array(
'element' => 'BlogEntry_Image_remove',
'type' => 'checkbox',
'label' => getGS('Remove this Image'),
'groupit' => true
),
//.........这里部分代码省略.........
示例10: _getFormMask
function _getFormMask($p_admin=false, $p_owner=false)
{
$mask = array(
'f_comment_id' => array(
'element' => 'f_comment_id',
'type' => 'hidden',
'constant' => $this->getProperty('comment_id'),
),
'f_entry_id' => array(
'element' => 'f_entry_id',
'type' => 'hidden',
'constant' => $this->getProperty('fk_entry_id'),
),
SecurityToken::SECURITY_TOKEN => array(
'element' => SecurityToken::SECURITY_TOKEN,
'type' => 'hidden',
'constant' => SecurityToken::GetToken()
),
/*
'tiny_mce' => array(
'element' => 'tiny_mce',
'text' => '<script language="javascript" type="text/javascript" src="/javascript/tinymce/tiny_mce.js"></script>'.
'<script language="javascript" type="text/javascript">'.
' tinyMCE.init({'.
' mode : "exact",'.
' elements : "tiny_mce_box",'.
' theme : "advanced",'.
' plugins : "emotions, paste", '.
' paste_auto_cleanup_on_paste : true, '.
' theme_advanced_buttons1 : "bold, italic, underline, undo, redo, link, emotions", '.
' theme_advanced_buttons2 : "", '.
' theme_advanced_buttons3 : "" '.
' });'.
'</script>',
'type' => 'static'
),
*/
'title' => array(
'element' => 'BlogComment[title]',
'type' => 'text',
'label' => getGS('Title'),
'default' => html_entity_decode($this->getProperty('title'))
),
'user_name' => array(
'element' => 'BlogComment[user_name]',
'type' => 'text',
'label' => getGS('Poster name'),
'default' => html_entity_decode($this->getProperty('user_name'))
),
'user_email' => array(
'element' => 'BlogComment[user_email]',
'type' => 'text',
'label' => getGS('EMail'),
'default' => html_entity_decode($this->getProperty('user_email'))
),
'content' => array(
'element' => 'BlogComment[content]',
'type' => 'textarea',
'label' => getGS('Comment'),
'default' => $this->getProperty('content'),
'required' => true,
'attributes'=> array('cols' => 60, 'rows' => 8, 'id' => 'tiny_mce_box')
),
'mood' => array(
'element' => 'BlogComment[fk_mood_id]',
'type' => 'select',
'label' => getGS('Mood'),
'default' => $this->getProperty('fk_mood_id'),
'options' => Blog::GetMoodList($this->getProperty('fk_language_id') ?
$this->getProperty('fk_language_id') :
BlogEntry::GetEntryLanguageId($this->getProperty('fk_entry_id')))
),
'status' => array(
'element' => 'BlogComment[status]',
'type' => 'select',
'label' => getGS('Status'),
'default' => $this->getProperty('status'),
'options' => array(
'online' => getGS('online'),
'offline' => getGS('offline'),
'pending' => getGS('pending')
),
'required' => true
),
'admin_status' => array(
'element' => 'BlogComment[admin_status]',
'type' => 'select',
'label' => getGS('Admin status'),
'default' => $this->getProperty('admin_status'),
'options' => array(
'pending' => getGS('pending'),
'online' => getGS('online'),
'offline' => getGS('offline'),
),
'required' => true
),
'reset' => array(
'element' => 'reset',
'type' => 'reset',
'label' => getGS('Reset'),
//.........这里部分代码省略.........
示例11: camp_html_display_error
}
if ($isError) {
camp_html_display_error($message, null, true);
exit;
}
camp_html_add_msg($message);
}
if (empty($_POST)) {
setMessage(getGS('The file exceeds the allowed max file size.'), TRUE);
}
if (!SecurityToken::isValid()) {
setMessage(SecurityToken::GetToken(), TRUE);
setMessage(getGS('Invalid security token!'), TRUE);
}
if (!$g_user->hasPermission('AddFile')) {
setMessage(getGS('You do not have the right to add files.'), TRUE);
}
// We set to unlimit the maximum time to execution whether
// safe_mode is disabled. Upload is still under control of
// max upload size.
if (!ini_get('safe_mode')) {
set_time_limit(0);
}
$inArchive = !empty($_REQUEST['archive']);
示例12: getInvitationFormMask
private function getInvitationFormMask($p_preview = false, &$p_userid = null)
{
global $Campsite;
$data = $this->m_data;
if ($p_preview) {
$MetaInterview = new MetaInterview($this->getId());
$MetaUser = new MetaUser($p_userid);
$guest_text = $this->smarty_parse_inviation_template($MetaInterview, $MetaUser, 'guest');
$questioneer_text = $this->smarty_parse_inviation_template($MetaInterview, $MetaUser, 'questioneer');
}
$mask = array(
array(
'element' => 'f_interview_id',
'type' => 'hidden',
'constant' => $data['interview_id']
),
SecurityToken::SECURITY_TOKEN => array(
'element' => SecurityToken::SECURITY_TOKEN,
'type' => 'hidden',
'constant' => SecurityToken::GetToken()
),
isset($p_preview) ?
array(
'element' => 'f_sender',
'type' => 'text',
'label' => getGS('Sender'),
'default' => $data['invitation_sender'],
'attributes'=> array('disabled' => true, 'readonly' => true),
) : null,
isset($p_preview) ?
array(
'element' => 'f_subject',
'type' => 'text',
'label' => getGS('Subject'),
'default' => $data['invitation_subject'],
'attributes'=> array('disabled' => true, 'readonly' => true),
) : null,
isset($p_preview) ?
array(
'element' => 'f_invitation_preview_guest',
'type' => 'static',
'label' => getGS('Guest preview text'),
'default' => $guest_text,
'attributes'=> array('cols' => 70, 'rows' => 12, 'disabled' => true, 'readonly' => true),
) : null,
isset($p_preview) ?
array(
'element' => 'f_invitation_preview_questioneer',
'type' => 'static',
'label' => getGS('Questioneer preview text'),
'default' => $questioneer_text,
'attributes'=> array('cols' => 70, 'rows' => 12, 'disabled' => true, 'readonly' => true),
) : null,
isset($p_preview) ? null :
array(
'element' => 'f_invitation_sender',
'type' => 'text',
'label' => getGS('Sender'),
'default' => $data['invitation_sender'],
'required' => true
),
isset($p_preview) ? null :
array(
'element' => 'f_invitation_subject',
'type' => 'text',
'label' => getGS('Subject'),
'default' => $data['invitation_subject'],
'required' => true
),
isset($p_preview) ? null :
array(
'element' => 'tiny_mce',
'text' => '<script language="javascript" type="text/javascript" src="' . $Campsite['WEBSITE_URL'] . '/javascript/tinymce/tiny_mce.js"></script>'.
'<script language="javascript" type="text/javascript">'.
' tinyMCE.init({'.
' mode : "exact",'.
' elements : "f_invitation_template_guest, f_invitation_template_questioneer",'.
' entity_encoding : "raw",'.
' relative_urls : false,'.
' convert_urls : false,'.
' theme : "advanced",'.
' plugins : "emotions, paste", '.
' paste_auto_cleanup_on_paste : true, '.
' theme_advanced_buttons1 : "bold, italic, underline, undo, redo, link", '.
' theme_advanced_buttons2 : "", '.
' theme_advanced_buttons3 : "" '.
' });'.
'</script>',
'type' => 'static'
),
isset($p_preview) ? null :
array(
'element' => 'f_invitation_template_guest',
'type' => 'textarea',
'label' => getGS('Invitation Template for Guest').'<br><a href="">Help</a>',
'default' => $data['invitation_template_guest'],
//.........这里部分代码省略.........
示例13: getFormMask
private function getFormMask($p_owner=false, $p_admin=false)
{
global $g_user;
$data = $this->getData();
foreach (User::GetUsers() as $User) {
if (1 || $User->hasPermission('PLUGIN_BLOG_USER')) {
$ownerList[$User->getUserId()] = "{$User->getRealName()} ({$User->getUserName()})";
}
}
asort($ownerList);
$languageList = array('' => getGS("---Select language---"));
foreach (Language::GetLanguages() as $Language) {
$languageList[$Language->getLanguageId()] = $Language->getNativeName();
}
asort($languageList);
foreach ($data as $k => $v) {
// clean user input
if (!in_array($k, self::$m_html_allowed_fields)) {
$data[$k] = camp_html_entity_decode_array($v);
}
}
// load possible topic list
foreach ($this->GetTopicTreeFlat() as $topicId => $topicName) {
$topics[$topicId] = $topicName;
}
// get the topics used
foreach ($this->getTopics() as $Topic) {
$active_topics[$Topic->getTopicId()] = $Topic->getName($this->getLanguageId());
}
$languageSelectedObj = new Language($data['fk_language_id']);
$editorLanguage = !empty($_COOKIE['TOL_Language']) ? $_COOKIE['TOL_Language'] : $languageSelectedObj->getCode();
$mask = array(
'f_blog_id' => array(
'element' => 'f_blog_id',
'type' => 'hidden',
'constant' => $data['blog_id']
),
SecurityToken::SECURITY_TOKEN => array(
'element' => SecurityToken::SECURITY_TOKEN,
'type' => 'hidden',
'constant' => SecurityToken::GetToken()
),
'language' => array(
'element' => 'Blog[fk_language_id]',
'type' => 'select',
'label' => getGS('Language'),
'default' => $data['fk_language_id'],
'options' => $languageList,
'required' => true
),
'title' => array(
'element' => 'Blog[title]',
'type' => 'text',
'label' => getGS('Title'),
'default' => $data['title'],
'required' => true
),
'tiny_mce' => array(
'element' => 'tiny_mce',
'text' => self::GetEditor('tiny_mce_box', $g_user, $editorLanguage),
'type' => 'static'
),
'info' => array(
'element' => 'Blog[info]',
'type' => 'textarea',
'label' => getGS('Info'),
'default' => $data['info'],
'required' => true,
'attributes'=> array('cols' => 86, 'rows' => 16, 'id' => 'tiny_mce_box', 'class' => 'tinymce')
),
'feature' => array(
'element' => 'Blog[feature]',
'type' => 'text',
'label' => getGS('Feature'),
'default' => $data['feature'],
),
'status' => array(
'element' => 'Blog[status]',
'type' => 'select',
'label' => getGS('Status'),
'default' => $data['status'],
'required' => true,
'options' => array(
'online' => getGS('online'),
'offline' => getGS('offline'),
'moderated' => getGS('moderated'),
'readonly' => getGS('read only'),
),
),
'admin_status' => array(
'element' => 'Blog[admin_status]',
//.........这里部分代码省略.........