本文整理汇总了PHP中common_session_token函数的典型用法代码示例。如果您正苦于以下问题:PHP common_session_token函数的具体用法?PHP common_session_token怎么用?PHP common_session_token使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了common_session_token函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onEndAvatarFormData
function onEndAvatarFormData($action)
{
$user = common_current_user();
$hasGravatar = $this->hasGravatar($user->id);
if (!empty($user->email) && !$hasGravatar) {
//and not gravatar already set
$action->elementStart('form', array('method' => 'post', 'id' => 'form_settings_gravatar_add', 'class' => 'form_settings', 'action' => common_local_url('avatarsettings')));
$action->elementStart('fieldset', array('id' => 'settings_gravatar_add'));
$action->element('legend', null, _m('Set Gravatar'));
$action->hidden('token', common_session_token());
$action->element('p', 'form_guide', _m('If you want to use your Gravatar image, click "Add".'));
$action->element('input', array('type' => 'submit', 'id' => 'settings_gravatar_add_action-submit', 'name' => 'add', 'class' => 'submit', 'value' => _m('Add')));
$action->elementEnd('fieldset');
$action->elementEnd('form');
} elseif ($hasGravatar) {
$action->elementStart('form', array('method' => 'post', 'id' => 'form_settings_gravatar_remove', 'class' => 'form_settings', 'action' => common_local_url('avatarsettings')));
$action->elementStart('fieldset', array('id' => 'settings_gravatar_remove'));
$action->element('legend', null, _m('Remove Gravatar'));
$action->hidden('token', common_session_token());
$action->element('p', 'form_guide', _m('If you want to remove your Gravatar image, click "Remove".'));
$action->element('input', array('type' => 'submit', 'id' => 'settings_gravatar_remove_action-submit', 'name' => 'remove', 'class' => 'submit', 'value' => _m('Remove')));
$action->elementEnd('fieldset');
$action->elementEnd('form');
} else {
$action->element('p', 'form_guide', _m('To use a Gravatar first enter in an email address.'));
}
}
示例2: prepare
function prepare($args)
{
parent::prepare($args);
$this->user = common_current_user();
if (empty($this->user)) {
// TRANS: Client error displayed when trying to repeat a notice while not logged in.
$this->clientError(_('Only logged-in users can repeat notices.'));
return false;
}
$id = $this->trimmed('notice');
if (empty($id)) {
// TRANS: Client error displayed when trying to repeat a notice while not providing a notice ID.
$this->clientError(_('No notice specified.'));
return false;
}
$this->notice = Notice::staticGet('id', $id);
if (empty($this->notice)) {
// TRANS: Client error displayed when trying to repeat a non-existing notice.
$this->clientError(_('No notice specified.'));
return false;
}
$token = $this->trimmed('token-' . $id);
if (empty($token) || $token != common_session_token()) {
// TRANS: Client error displayed when the session token does not match or is not given.
$this->clientError(_('There was a problem with your session token. Try again, please.'));
return false;
}
return true;
}
示例3: prepare
/**
* Check pre-requisites and instantiate attributes
*
* @param Array $args array of arguments (URL, GET, POST)
*
* @return boolean success flag
*/
function prepare($args)
{
parent::prepare($args);
// @fixme these are pretty common, should a parent class factor these out?
// Only allow POST requests
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
// TRANS: Client error displayed when trying to use another method than POST.
// TRANS: Do not translate POST.
$this->clientError(_('This action only accepts POST requests.'));
}
// CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
// TRANS: Client error displayed when the session token does not match or is not given.
$this->clientError(_('There was a problem with your session token.' . ' Try again, please.'));
}
// Only for logged-in users
$this->user = common_current_user();
if (empty($this->user)) {
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
$this->clientError(_('Not logged in.'));
}
if (!AdminPanelAction::canAdmin('plugins')) {
// TRANS: Client error displayed when trying to enable or disable a plugin without access rights.
$this->clientError(_('You cannot administer plugins.'));
}
$this->plugin = $this->arg('plugin');
$defaultPlugins = common_config('plugins', 'default');
if (!array_key_exists($this->plugin, $defaultPlugins)) {
// TRANS: Client error displayed when trying to enable or disable a non-existing plugin.
$this->clientError(_('No such plugin.'));
}
return true;
}
示例4: prepare
/**
* Check pre-requisites and instantiate attributes
*
* @param Array $args array of arguments (URL, GET, POST)
*
* @return boolean success flag
*/
function prepare($args)
{
parent::prepare($args);
// Only for logged-in users
$this->user = common_current_user();
if (empty($this->user)) {
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
$this->clientError(_('Not logged in.'));
}
// CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
// TRANS: Client error displayed when the session token does not match or is not given.
$this->clientError(_('There was a problem with your session token.' . ' Try again, please.'));
}
$profile = $this->user->getProfile();
$tags = $profile->getLists($this->scoped);
$this->tags = array();
while ($tags->fetch()) {
if (empty($this->last_mod)) {
$this->last_mod = $tags->modified;
}
$arr = array();
$arr['tag'] = $tags->tag;
$arr['mode'] = $tags->private ? 'private' : 'public';
// $arr['url'] = $tags->homeUrl();
$arr['freq'] = $tags->taggedCount();
$this->tags[] = $arr;
}
$tags = NULL;
return true;
}
示例5: prepare
/**
* Check pre-requisites and instantiate attributes
*
* @param Array $args array of arguments (URL, GET, POST)
*
* @return boolean success flag
*/
function prepare($args)
{
parent::prepare($args);
// Only allow POST requests
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
// TRANS: Client error displayed trying to perform any request method other than POST.
// TRANS: Do not translate POST.
$this->clientError(_('This action only accepts POST requests.'));
return false;
}
// CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
// TRANS: Client error displayed when the session token is not okay.
$this->clientError(_('There was a problem with your session token.' . ' Try again, please.'));
return false;
}
// Only for logged-in users
$this->user = common_current_user();
if (empty($this->user)) {
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
$this->clientError(_('Not logged in.'));
return false;
}
// Profile to subscribe to
$other_id = $this->arg('subscribeto');
$this->other = Profile::staticGet('id', $other_id);
if (empty($this->other)) {
// TRANS: Client error displayed trying to subscribe to a non-existing profile.
$this->clientError(_('No such profile.'));
return false;
}
return true;
}
示例6: prepare
function prepare($args)
{
parent::prepare($args);
if (!common_logged_in()) {
$this->clientError(_('Not logged in.'));
return false;
}
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$this->clientError(_('网页错误,请返回重试
'));
return false;
}
$id = $this->trimmed('profile');
if (!$id) {
$this->clientError(_('No profile specified.'));
return false;
}
$this->profile = Profile::staticGet('id', $id);
if (!$this->profile) {
$this->clientError(_('No profile with that ID.'));
return false;
}
return true;
}
示例7: handle
/**
* Class handler.
*
* @param array $args query arguments
*
* @return void
*/
function handle($args)
{
parent::handle($args);
if (!common_logged_in()) {
$this->clientError(_('Not logged in.'));
return;
}
$user = common_current_user();
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
common_redirect(common_local_url('all', array('nickname' => $user->nickname)));
return;
}
$idGroup = $this->trimmed('idGroup');
$token = $this->trimmed('token-' . $idGroup);
if (!$token || $token != common_session_token()) {
$this->clientError(_('There was a problem with your session token. Try again, please.'));
return;
}
if ($this->trimmed('submit-auto') != null) {
$groupids = NotesPDF::getNoticeIDsInAGroupModeAuto($idGroup);
$notices = Notice::multiGet('id', $groupids)->fetchAll();
GenerarPDF::content($idGroup, $notices, 'Automáticos');
} else {
if ($this->trimmed('submit-custom') != null) {
$tag = $this->trimmed('combo-tag') == 'Todos' ? '%' : $this->trimmed('combo-tag');
$nick = $this->trimmed('combo-user') == 'Todos' ? '%' : $this->trimmed('combo-user');
$grade = $this->trimmed('combo-grade') == 'Todos' ? '%' : $this->trimmed('combo-grade');
$noticeIds = NotesPDF::getNoticesInModeCustom(array('idGroup' => $idGroup, 'tag' => $tag, 'nick' => $nick, 'grade' => $grade));
$notices = Notice::multiGet('id', $noticeIds)->fetchAll();
GenerarPDF::content($idGroup, $notices, 'Personalizados');
} else {
$this->showForm('Error al generar los apuntes. Inténtelo de nuevo en unos minutos.');
}
}
}
示例8: handle
function handle($args)
{
// Trigger short error responses; not a human-readable web page.
StatusNet::setApi(true);
// We're not a general oEmbed proxy service; limit to valid sessions.
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
// TRANS: Client error displayed when the session token does not match or is not given.
$this->clientError(_m('There was a problem with your session token. ' . 'Try again, please.'));
}
$format = $this->arg('format');
if ($format && $format != 'json') {
// TRANS: Client exception thrown when requesting a different format than JSON.
throw new ClientException(_m('Invalid format; only JSON supported.'));
}
$url = $this->arg('url');
if (!common_valid_http_url($url)) {
// TRANS: Client exception thrown when not providing a valid URL.
throw new ClientException(_m('Invalid URL.'));
}
$params = array();
if ($this->arg('maxwidth')) {
$params['maxwidth'] = $this->arg('maxwidth');
}
if ($this->arg('maxheight')) {
$params['maxheight'] = $this->arg('maxheight');
}
$data = oEmbedHelper::getObject($url, $params);
$this->init_document('json');
print json_encode($data);
}
示例9: prepare
/**
* Prepare to run
*/
function prepare($args)
{
parent::prepare($args);
if (!common_logged_in()) {
// TRANS: Client error displayed when trying to perform an action while not logged in.
$this->clientError(_('You must be logged in to unsubscribe from a list.'));
}
// Only allow POST requests
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
// TRANS: Client error displayed when trying to use another method than POST.
$this->clientError(_('This action only accepts POST requests.'));
}
// CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
// TRANS: Client error displayed when the session token does not match or is not given.
$this->clientError(_('There was a problem with your session token.' . ' Try again, please.'));
}
$tagger_arg = $this->trimmed('tagger');
$tag_arg = $this->trimmed('tag');
$id = intval($this->arg('id'));
if ($id) {
$this->peopletag = Profile_list::getKV('id', $id);
} else {
// TRANS: Client error displayed when trying to perform an action without providing an ID.
$this->clientError(_('No ID given.'), 404);
}
if (!$this->peopletag || $this->peopletag->private) {
// TRANS: Client error displayed trying to reference a non-existing list.
$this->clientError(_('No such list.'), 404);
}
$this->tagger = Profile::getKV('id', $this->peopletag->tagger);
return true;
}
示例10: showContent
function showContent()
{
if (!empty($this->message_text)) {
$this->element('p', null, $this->message);
return;
}
$this->elementStart('form', array('method' => 'post', 'id' => 'account_connect', 'action' => common_local_url('finishopenidlogin')));
$this->hidden('token', common_session_token());
$this->element('h2', null, _('Create new account'));
$this->element('p', null, _('Create a new user with this nickname.'));
$this->input('newname', _('New nickname'), $this->username ? $this->username : '', _('1-64 lowercase letters or numbers, no punctuation or spaces'));
$this->elementStart('p');
$this->element('input', array('type' => 'checkbox', 'id' => 'license', 'name' => 'license', 'value' => 'true'));
$this->text(_('My text and files are available under '));
$this->element('a', array('href' => common_config('license', 'url')), common_config('license', 'title'));
$this->text(_(' except this private data: password, email address, IM address, phone number.'));
$this->elementEnd('p');
$this->submit('create', _('Create'));
$this->element('h2', null, _('Connect existing account'));
$this->element('p', null, _('If you already have an account, login with your username and password to connect it to your OpenID.'));
$this->input('nickname', _('Existing nickname'));
$this->password('password', _('Password'));
$this->submit('connect', _('Connect'));
$this->elementEnd('form');
}
示例11: prepare
/**
* Check pre-requisites and instantiate attributes
*
* @param Array $args array of arguments (URL, GET, POST)
*
* @return boolean success flag
*/
function prepare($args)
{
parent::prepare($args);
// CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
// TRANS: Client error displayed when the session token does not match or is not given.
$this->clientError(_('There was a problem with your session token.' . ' Try again, please.'));
return false;
}
// Only for logged-in users
$this->user = common_current_user();
if (empty($this->user)) {
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
$this->clientError(_('Not logged in.'));
return false;
}
$id = $this->arg('peopletag_id');
$this->peopletag = Profile_list::staticGet('id', $id);
if (empty($this->peopletag)) {
// TRANS: Client error displayed trying to reference a non-existing list.
$this->clientError(_('No such list.'));
return false;
}
$field = $this->arg('field');
if (!in_array($field, array('fulltext', 'nickname', 'fullname', 'description', 'location', 'uri'))) {
// TRANS: Client error displayed when trying to add an unindentified field to profile.
// TRANS: %s is a field name.
$this->clientError(sprintf(_('Unidentified field %s.'), htmlspecialchars($field)), 404);
return false;
}
$this->field = $field;
return true;
}
示例12: prepare
function prepare($args)
{
parent::prepare($args);
if (!common_logged_in()) {
// TRANS: Client error displayed trying a change a subscription while not logged in.
$this->clientError(_('Not logged in.'));
return false;
}
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$this->clientError(_('There was a problem with your session token. ' . 'Try again, please.'));
return false;
}
$id = $this->trimmed('profile');
if (!$id) {
// TRANS: Client error displayed trying a change a subscription without providing a profile.
$this->clientError(_('No profile specified.'));
return false;
}
$this->profile = Profile::staticGet('id', $id);
if (!$this->profile) {
// TRANS: Client error displayed trying a change a subscription for a non-existant profile ID.
$this->clientError(_('No profile with that ID.'));
return false;
}
return true;
}
示例13: prepare
function prepare($args)
{
parent::prepare($args);
$this->user = common_current_user();
if (empty($this->user)) {
$this->clientError(_('Only logged-in users can repeat notices.'));
return false;
}
$id = $this->trimmed('notice');
if (empty($id)) {
$this->clientError(_('No notice specified.'));
return false;
}
$this->notice = Notice::staticGet('id', $id);
if (empty($this->notice)) {
$this->clientError(_('No notice specified.'));
return false;
}
if ($this->user->id == $this->notice->profile_id) {
$this->clientError(_("You can't repeat your own notice."));
return false;
}
$token = $this->trimmed('token-' . $id);
if (empty($token) || $token != common_session_token()) {
$this->clientError(_('There was a problem with your session token. Try again, please.'));
return false;
}
$profile = $this->user->getProfile();
if ($profile->hasRepeated($id)) {
$this->clientError(_('You already repeated that notice.'));
return false;
}
return true;
}
示例14: prepare
/**
* Check pre-requisites and instantiate attributes
*
* @param Array $args array of arguments (URL, GET, POST)
*
* @return boolean success flag
*/
function prepare($args)
{
parent::prepare($args);
// CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
// TRANS: Client error displayed when the session token does not match or is not given.
$this->clientError(_('There was a problem with your session token.' . ' Try again, please.'));
}
// Only for logged-in users
$this->user = common_current_user();
if (empty($this->user)) {
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
$this->clientError(_('Not logged in.'));
}
// Profile to subscribe to
$tagged_id = $this->arg('tagged');
$this->tagged = Profile::getKV('id', $tagged_id);
if (empty($this->tagged)) {
// TRANS: Client error displayed trying to perform an action related to a non-existing profile.
$this->clientError(_('No such profile.'));
}
$id = $this->arg('peopletag_id');
$this->peopletag = Profile_list::getKV('id', $id);
if (empty($this->peopletag)) {
// TRANS: Client error displayed trying to reference a non-existing list.
$this->clientError(_('No such list.'));
}
return true;
}
示例15: showContent
function showContent()
{
$this->elementStart('form', array('method' => 'POST', 'id' => 'form_password', 'class' => 'form_settings', 'action' => common_local_url('passwordsettings')));
$this->elementStart('fieldset');
// TRANS: Fieldset legend on page where to change password.
$this->element('legend', null, _('Password change'));
$this->hidden('token', common_session_token());
$this->elementStart('ul', 'form_data');
// Users who logged in with OpenID won't have a pwd
if ($this->scoped->hasPassword()) {
$this->elementStart('li');
// TRANS: Field label on page where to change password.
$this->password('oldpassword', _('Old password'));
$this->elementEnd('li');
}
$this->elementStart('li');
// TRANS: Field label on page where to change password.
$this->password('newpassword', _('New password'), _('6 or more characters.'));
$this->elementEnd('li');
$this->elementStart('li');
// TRANS: Field label on page where to change password. In this field the new password should be typed a second time.
$this->password('confirm', _m('LABEL', 'Confirm'), _('Same as password above.'));
$this->elementEnd('li');
$this->elementEnd('ul');
// TRANS: Button text on page where to change password.
$this->submit('changepass', _m('BUTTON', 'Change'));
$this->elementEnd('fieldset');
$this->elementEnd('form');
}