本文整理汇总了PHP中Typecho_Cookie::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Typecho_Cookie::get方法的具体用法?PHP Typecho_Cookie::get怎么用?PHP Typecho_Cookie::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Typecho_Cookie
的用法示例。
在下文中一共展示了Typecho_Cookie::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action
public function action()
{
$this->db = Typecho_Db::get();
$this->prefix = $this->db->getPrefix();
$this->options = Typecho_Widget::widget('Widget_Options');
$cid = $this->request->cid;
if (!$cid) {
$this->response->throwJson(array('status' => 0, 'msg' => '请选择喜欢的文章!'));
}
$likes = Typecho_Cookie::get('__post_likes');
if (empty($likes)) {
$likes = array();
} else {
$likes = explode(',', $likes);
}
if (!in_array($cid, $likes)) {
$row = $this->db->fetchRow($this->db->select('likesNum')->from('table.contents')->where('cid = ?', $cid)->limit(1));
$this->db->query($this->db->update('table.contents')->rows(array('likesNum' => (int) $row['likesNum'] + 1))->where('cid = ?', $cid));
array_push($likes, $cid);
$likes = implode(',', $likes);
Typecho_Cookie::set('__post_likes', $likes);
//记录查看cookie
$this->response->throwJson(array('status' => 1, 'msg' => '成功点赞!'));
}
$this->response->throwJson(array('status' => 0, 'msg' => '你已经点赞过了!'));
}
示例2: setTheme
/**
* 插件实现方法
*
* @access public
* @return void
*/
public static function setTheme($widget)
{
$cookie = array('name' => '__typecho_theme', 'expire' => 86400);
$options = Typecho_Widget::widget('Widget_Options');
if (isset($widget->request->theme) && $widget->request->isGet()) {
if ($widget->request->theme) {
$theme = $widget->request->theme;
if (static::check($theme)) {
Typecho_Cookie::set($cookie['name'], $widget->request->theme, $options->gmtTime + $cookie['expire'], $options->siteUrl);
} else {
$widget->response->redirect(Typecho_Common::url($widget->request->getPathInfo(), $options->siteUrl));
}
} else {
Typecho_Cookie::delete($cookie['name']);
//直接提交?theme将删除cookie,恢复默认主题
return;
}
} else {
$theme = Typecho_Cookie::get($cookie['name']);
if (!$theme) {
return;
}
if (!static::check($theme)) {
Typecho_Cookie::delete($cookie['name']);
return;
}
}
/** 删除旧主题的相关设置 */
$themeRow = 'theme:' . $options->theme;
if (isset($options->{$themeRow})) {
$config = unserialize($options->{$themeRow});
$options->{$themeRow} = '';
foreach ($config as $row => $value) {
$options->{$row} = '';
}
}
/** 载入新主题的相关设置 参考var/Widget/Themes/Edit.php */
$themeDir = __TYPECHO_ROOT_DIR__ . __TYPECHO_THEME_DIR__ . DIRECTORY_SEPARATOR . $theme . DIRECTORY_SEPARATOR;
$configFile = $themeDir . 'functions.php';
if (file_exists($configFile)) {
require_once $configFile;
if (function_exists('themeConfig')) {
$form = new Typecho_Widget_Helper_Form();
themeConfig($form);
$config = $form->getValues();
if ($config) {
$options->{'theme:' . $theme} = serialize($config);
foreach ($config as $row => $value) {
$options->{$row} = $value;
}
}
}
}
/** 修改$this->options->theme */
$options->theme = $theme;
/** 修改$this->_themeDir */
$widget->setThemeDir($themeDir);
}
示例3: callback
/**
* 授权回调地址
*/
public function callback()
{
if (empty($_GET['code'])) {
throw new Typecho_Exception(_t('无效请求!'));
}
//跳转
if (!class_exists('SaeTOAuthV2')) {
require_once './saetv2.ex.class.php';
}
$saeto_client = new SaeTOAuthV2($this->config->client_id, $this->config->client_secret);
//取access_token
$access_token = $saeto_client->getAccessToken('code', array('code' => trim($_GET['code']), 'redirect_uri' => $this->config->callback_url));
if (empty($access_token) || !is_array($access_token) || empty($access_token['uid'])) {
throw new Typecho_Exception(_t('获取access_token失败,请返回重新授权!'));
}
$table = $this->db->getPrefix() . self::$tableName;
$query = $this->db->query("SELECT * FROM {$table} WHERE openid='{$access_token['uid']}' AND plateform='sina'");
$users_oauth = $this->db->fetchRow($query);
if (!empty($users_oauth['uid'])) {
//该新浪帐号已经绑定了用户
if (Typecho_Widget::widget('Widget_User')->hasLogin()) {
/** 直接返回 */
$this->response->redirect(Typecho_Widget::widget('Widget_Options')->index);
} else {
//让其直接登陆
$this->setUserLogin($users_oauth['uid']);
if (!Typecho_Widget::widget('Widget_User')->pass('contributor', true)) {
/** 不允许普通用户直接跳转后台 */
$this->response->redirect(Typecho_Widget::widget('Widget_Options')->profileUrl);
} else {
$this->response->redirect(Typecho_Widget::widget('Widget_Options')->adminUrl);
}
}
exit;
}
//该新浪帐号未绑定过
/** 如果已经登录 */
if (Typecho_Widget::widget('Widget_User')->hasLogin()) {
/** 直接绑定 */
$cookieUid = Typecho_Cookie::get('__typecho_uid');
$this->bindOauthUser($cookieUid, $access_token['uid'], 'sina', $access_token['expires_in']);
$this->response->redirect(Typecho_Widget::widget('Widget_Options')->index);
} else {
//取用户信息
$saetc_client = new SaeTClientV2($this->config->client_id, $this->config->client_secret, $access_token['access_token']);
$weibo_user = $saetc_client->show_user_by_id($access_token['uid']);
//创建用户
$uid = $this->registerFromWeiboUser($weibo_user);
if (!$uid) {
throw new Typecho_Exception(_t('创建帐号失败,请联系管理员!'));
}
$this->setUserLogin($uid);
$this->bindOauthUser($uid, $access_token['uid'], 'sina', $access_token['expires_in']);
$this->response->redirect(Typecho_Widget::widget('Widget_Options')->profileUrl);
}
//构造用户帐号
exit;
}
示例4: getReadMode
function getReadMode($icon = false)
{
$class = Typecho_Cookie::get('read-mode', 'day');
if ($icon) {
$class = $class == 'day' ? 'fa fa-sun-o' : 'fa fa-moon-o';
} else {
$class = 'day' == $class ? '' : 'night-mode';
}
echo $class;
}
示例5: execute
/**
* 执行函数
*
* @access public
* @return void
*/
public function execute()
{
if (NULL !== Typecho_Cookie::get('__typecho_notice')) {
$this->noticeType = Typecho_Cookie::get('__typecho_notice_type');
$this->push(Typecho_Cookie::get('__typecho_notice'));
Typecho_Cookie::delete('__typecho_notice', $this->widget('Widget_Options')->siteUrl);
Typecho_Cookie::delete('__typecho_notice_type', $this->widget('Widget_Options')->siteUrl);
}
if (NULL !== Typecho_Cookie::get('__typecho_notice_highlight')) {
$this->highlight = Typecho_Cookie::get('__typecho_notice_highlight');
Typecho_Cookie::delete('__typecho_notice_highlight', $this->widget('Widget_Options')->siteUrl);
}
}
示例6: getNotice
/**
* 获取提示消息
*/
function getNotice()
{
$notice = Typecho_Cookie::get('__typecho_notice');
if (empty($notice)) {
echo "''";
return;
}
$notice = json_decode($notice, true);
$rs = array('msg' => $notice[0], 'type' => Typecho_Cookie::get('__typecho_notice_type'));
Typecho_Cookie::delete('__typecho_notice');
Typecho_Cookie::delete('__typecho_notice_type');
echo json_encode($rs);
}
示例7: hasLogin
public static function hasLogin()
{
$cookieUid = Typecho_Cookie::get('__typecho_uid');
if (null !== $cookieUid) {
$db = Typecho_Db::get();
$user = $db->fetchRow($db->select()->from('table.users')->where('uid = ?', intval($cookieUid))->limit(1));
$cookieAuthCode = Typecho_Cookie::get('__typecho_authCode');
if ($user && Typecho_Common::hashValidate($user['authCode'], $cookieAuthCode)) {
return true;
}
Typecho_Cookie::delete('__typecho_uid');
Typecho_Cookie::delete('__typecho_authCode');
}
return false;
}
示例8: like
protected function like()
{
$cid = $this->request->cid;
if (!$cid) {
$this->response->throwJson(array('status' => 0, 'msg' => '请选择喜欢的文章!'));
}
$likes = Typecho_Cookie::get('__sis_pls');
if (empty($likes)) {
$likes = array();
} else {
$likes = explode(',', $likes);
}
if (!in_array($cid, $likes)) {
$db = Typecho_Db::get();
$row = $db->fetchRow($db->select('likesNum')->from('table.contents')->where('cid = ?', $cid)->limit(1));
$db->query($db->update('table.contents')->rows(array('likesNum' => (int) $row['likesNum'] + 1))->where('cid = ?', $cid));
array_push($likes, $cid);
$likes = implode(',', $likes);
Typecho_Cookie::set('__sis_pls', $likes);
//记录查看cookie
$this->response->throwJson(array('status' => 1, 'msg' => '成功点赞!'));
}
$this->response->throwJson(array('status' => 0, 'msg' => '你已经点赞过了!'));
}
示例9: _e
<?php
}
?>
<?php
}
?>
<!--<li><a href="<?php
$options->adminUrl('profile.php');
?>
"><?php
_e('更新我的资料');
?>
</a></li>-->
</ul>
<?php
$version = Typecho_Cookie::get('__typecho_check_version');
?>
<?php
if ($version && $version['available']) {
?>
<div class="update-check">
<p class="message notice">
<?php
_e('您当前使用的版本是');
?>
<?php
echo $version['current'];
?>
→
<strong><a href="<?php
echo $version['link'];
示例10: execute
/**
* 执行函数
*
* @access public
* @return void
*/
public function execute()
{
$select = $this->select();
$this->parameter->setDefault('pageSize=20');
$this->_currentPage = $this->request->get('page', 1);
/** 过滤标题 */
if (NULL != ($keywords = $this->request->filter('search')->keywords)) {
$select->where('table.comments.text LIKE ?', '%' . $keywords . '%');
}
/** 如果具有贡献者以上权限,可以查看所有评论,反之只能查看自己的评论 */
if (!$this->user->pass('editor', true)) {
$select->where('table.comments.ownerId = ?', $this->user->uid);
} else {
if (!isset($this->request->cid)) {
if ('on' == $this->request->__some_all_comments) {
Typecho_Cookie::set('__some_all_comments', 'on');
} else {
if ('off' == $this->request->__some_all_comments) {
Typecho_Cookie::set('__some_all_comments', 'off');
}
if ('on' != Typecho_Cookie::get('__some_all_comments')) {
$select->where('table.comments.ownerId = ?', $this->user->uid);
}
}
}
}
if (in_array($this->request->status, array('approved', 'waiting', 'spam'))) {
$select->where('table.comments.status = ?', $this->request->status);
} else {
if ('hold' == $this->request->status) {
$select->where('table.comments.status <> ?', 'approved');
} else {
$select->where('table.comments.status = ?', 'approved');
}
}
//增加按文章归档功能
if (isset($this->request->cid)) {
$select->where('table.comments.cid = ?', $this->request->filter('int')->cid);
}
$this->_countSql = clone $select;
$select->order('table.comments.coid', Typecho_Db::SORT_DESC)->page($this->_currentPage, $this->parameter->pageSize);
$this->db->fetchAll($select, array($this, 'push'));
}
示例11: execute
/**
* 执行函数
*
* @access public
* @return void
*/
public function execute()
{
if (!$this->parameter->parentId) {
return;
}
$commentsAuthor = Typecho_Cookie::get('__typecho_remember_author');
$commentsMail = Typecho_Cookie::get('__typecho_remember_mail');
$select = $this->select()->where('table.comments.cid = ?', $this->parameter->parentId)->where('table.comments.status = ? OR (table.comments.author = ? AND table.comments.mail = ? AND table.comments.status = ?)', 'approved', $commentsAuthor, $commentsMail, 'waiting');
$threadedSelect = NULL;
if ($this->options->commentsShowCommentOnly) {
$select->where('table.comments.type = ?', 'comment');
}
$select->order('table.comments.coid', 'ASC');
$this->db->fetchAll($select, array($this, 'push'));
/** 需要输出的评论列表 */
$outputComments = array();
/** 如果开启评论回复 */
if ($this->options->commentsThreaded) {
foreach ($this->stack as $coid => &$comment) {
/** 取出父节点 */
$parent = $comment['parent'];
/** 如果存在父节点 */
if (0 != $parent && isset($this->stack[$parent])) {
/** 如果当前节点深度大于最大深度, 则将其挂接在父节点上 */
if ($comment['levels'] >= $this->options->commentsMaxNestingLevels) {
$comment['levels'] = $this->stack[$parent]['levels'];
$parent = $this->stack[$parent]['parent'];
// 上上层节点
$comment['parent'] = $parent;
}
/** 计算子节点顺序 */
$comment['order'] = isset($this->_threadedComments[$parent]) ? count($this->_threadedComments[$parent]) + 1 : 1;
/** 如果是子节点 */
$this->_threadedComments[$parent][$coid] = $comment;
} else {
$outputComments[$coid] = $comment;
}
}
$this->stack = $outputComments;
}
/** 评论排序 */
if ('DESC' == $this->options->commentsOrder) {
$this->stack = array_reverse($this->stack, true);
$this->_threadedComments = array_map('array_reverse', $this->_threadedComments);
}
/** 评论总数 */
$this->_total = count($this->stack);
/** 对评论进行分页 */
if ($this->options->commentsPageBreak) {
if ('last' == $this->options->commentsPageDisplay && !$this->parameter->commentPage) {
$this->_currentPage = ceil($this->_total / $this->options->commentsPageSize);
} else {
$this->_currentPage = $this->parameter->commentPage ? $this->parameter->commentPage : 1;
}
/** 截取评论 */
$this->stack = array_slice($this->stack, ($this->_currentPage - 1) * $this->options->commentsPageSize, $this->options->commentsPageSize);
/** 评论置位 */
$this->row = current($this->stack);
$this->length = count($this->stack);
}
reset($this->stack);
}
示例12:
<?php
include 'common.php';
include 'header.php';
$rememberName = Typecho_Cookie::get('__typecho_remember_name');
Typecho_Cookie::delete('__typecho_remember_name');
?>
<div class="body body-950">
<div class="container">
<div class="column-07 start-09 typecho-login">
<h2 class="logo-dark">typecho</h2>
<form action="<?php
$options->loginAction();
?>
" method="post" name="login">
<fieldset>
<?php
if (!$user->hasLogin()) {
?>
<?php
if ($notice->have() && in_array($notice->noticeType, array('success', 'notice', 'error'))) {
?>
<div class="message <?php
$notice->noticeType();
?>
typecho-radius-topleft typecho-radius-topright typecho-radius-bottomleft typecho-radius-bottomright">
<ul>
<?php
$notice->lists();
?>
</ul>
示例13: action
public function action()
{
// protect
$this->security->protect();
/** 如果已经登录 */
if ($this->user->hasLogin()) {
/** 直接返回 */
$this->response->redirect($this->options->index);
}
/** 如果未开启注册 */
if (!$this->options->allowRegister) {
/** 直接返回 */
$this->widget('Widget_Notice')->set('未开启注册!', 'error');
$this->response->redirect($this->options->index);
}
/** 初始化验证类 */
$validator = new Typecho_Validate();
$validator->addRule('captcha', 'required', _t('必须填写验证码'));
$validator->addRule('captcha', array($this, 'checkCaptcha'), _t('验证码错误'));
$validator->addRule('name', 'required', _t('必须填写用户名称'));
$validator->addRule('name', 'minLength', _t('用户名至少包含2个字符'), 2);
$validator->addRule('name', 'maxLength', _t('用户名最多包含32个字符'), 32);
$validator->addRule('name', 'xssCheck', _t('请不要在用户名中使用特殊字符'));
$validator->addRule('name', array($this, 'nameExists'), _t('用户名已经存在'));
$validator->addRule('mail', 'required', _t('必须填写电子邮箱'));
$validator->addRule('mail', array($this, 'mailExists'), _t('电子邮箱地址已经存在'));
$validator->addRule('mail', 'email', _t('电子邮箱格式错误'));
$validator->addRule('mail', 'maxLength', _t('电子邮箱最多包含200个字符'), 200);
/** 如果请求中有password */
$validator->addRule('password', 'required', _t('必须填写密码'));
$validator->addRule('password', 'minLength', _t('为了保证账户安全, 请输入至少六位的密码'), 6);
$validator->addRule('password', 'maxLength', _t('为了便于记忆, 密码长度请不要超过十八位'), 18);
$validator->addRule('confirm', 'confirm', _t('两次输入的密码不一致'), 'password');
/** 截获验证异常 */
if ($error = $validator->run($this->request->from('captcha', 'name', 'password', 'mail', 'confirm'))) {
Typecho_Cookie::set('__typecho_remember_name', $this->request->name);
Typecho_Cookie::set('__typecho_remember_mail', $this->request->mail);
/** 设置提示信息 */
$this->widget('Widget_Notice')->set($error, 'error');
$this->response->goBack();
}
$hasher = new PasswordHash(8, true);
//$generatedPassword = Typecho_Common::randString(7);
$extend = array();
$inviter = Typecho_Cookie::get('__typecho_inviter');
if (!empty($inviter)) {
$inviter = $this->widget('Widget_Users_Query@name_' . $inviter, 'name=' . $inviter);
if ($inviter->have()) {
$extend['inviter'] = $inviter->name;
}
Typecho_Cookie::delete('__typecho_inviter');
}
$dataStruct = array('name' => $this->request->name, 'mail' => $this->request->mail, 'screenName' => $this->request->name, 'password' => $hasher->HashPassword($this->request->password), 'created' => $this->options->gmtTime, 'group' => 'subscriber', 'extend' => empty($extend) ? '' : serialize($extend));
$insertId = $this->insert($dataStruct);
$this->db->fetchRow($this->select()->where('uid = ?', $insertId)->limit(1), array($this, 'push'));
$this->user->login($this->request->name, $this->request->password);
$params = array('uid' => $this->user->uid, 'confirm' => $this->user->mail, 'name' => $this->user->screenName, 'type' => 'register');
//发送验证信息
Widget_Common::sendVerify($params);
//注册积分
Widget_Common::credits('register');
$this->widget('Widget_Notice')->set(_t('用户 <strong>%s</strong> 已经成功注册,请及时验证邮件', $this->screenName), 'success');
$this->response->redirect($this->options->index);
}
示例14: filter
/**
* 通用过滤器
*
* @access public
* @param array $value 需要过滤的行数据
* @return array
* @throws Typecho_Widget_Exception
*/
public function filter(array $value)
{
/** 取出所有分类 */
$value['categories'] = $this->db->fetchAll($this->db->select()->from('table.metas')->join('table.relationships', 'table.relationships.mid = table.metas.mid')->where('table.relationships.cid = ?', $value['cid'])->where('table.metas.type = ?', 'category')->order('table.metas.order', Typecho_Db::SORT_ASC), array($this->widget('Widget_Metas_Category_List'), 'filter'));
$value['category'] = NULL;
$value['directory'] = array();
/** 取出第一个分类作为slug条件 */
if (!empty($value['categories'])) {
$value['category'] = $value['categories'][0]['slug'];
$value['directory'] = $this->widget('Widget_Metas_Category_List')->getAllParents($value['categories'][0]['mid']);
$value['directory'][] = $value['category'];
}
$value['date'] = new Typecho_Date($value['created']);
/** 生成日期 */
$value['year'] = $value['date']->year;
$value['month'] = $value['date']->month;
$value['day'] = $value['date']->day;
/** 生成访问权限 */
$value['hidden'] = false;
/** 获取路由类型并判断此类型在路由表中是否存在 */
$type = $value['type'];
$routeExists = NULL != Typecho_Router::get($type);
$tmpSlug = $value['slug'];
$tmpCategory = $value['category'];
$tmpDirectory = $value['directory'];
$value['slug'] = urlencode($value['slug']);
$value['category'] = urlencode($value['category']);
$value['directory'] = implode('/', array_map('urlencode', $value['directory']));
/** 生成静态路径 */
$value['pathinfo'] = $routeExists ? Typecho_Router::url($type, $value) : '#';
/** 生成静态链接 */
$value['permalink'] = Typecho_Common::url($value['pathinfo'], $this->options->index);
/** 处理附件 */
if ('attachment' == $type) {
$content = @unserialize($value['text']);
//增加数据信息
$value['attachment'] = new Typecho_Config($content);
$value['attachment']->isImage = in_array($content['type'], array('jpg', 'jpeg', 'gif', 'png', 'tiff', 'bmp'));
$value['attachment']->url = Widget_Upload::attachmentHandle($value);
if ($value['attachment']->isImage) {
$value['text'] = '<img src="' . $value['attachment']->url . '" alt="' . $value['title'] . '" />';
} else {
$value['text'] = '<a href="' . $value['attachment']->url . '" title="' . $value['title'] . '">' . $value['title'] . '</a>';
}
}
/** 处理Markdown **/
$value['isMarkdown'] = 0 === strpos($value['text'], '<!--markdown-->');
if ($value['isMarkdown']) {
$value['text'] = substr($value['text'], 15);
}
/** 生成聚合链接 */
/** RSS 2.0 */
$value['feedUrl'] = $routeExists ? Typecho_Router::url($type, $value, $this->options->feedUrl) : '#';
/** RSS 1.0 */
$value['feedRssUrl'] = $routeExists ? Typecho_Router::url($type, $value, $this->options->feedRssUrl) : '#';
/** ATOM 1.0 */
$value['feedAtomUrl'] = $routeExists ? Typecho_Router::url($type, $value, $this->options->feedAtomUrl) : '#';
$value['slug'] = $tmpSlug;
$value['category'] = $tmpCategory;
$value['directory'] = $tmpDirectory;
/** 处理密码保护流程 */
if (!empty($value['password']) && $value['password'] !== Typecho_Cookie::get('protectPassword') && $value['authorId'] != $this->user->uid && !$this->user->pass('editor', true)) {
$value['hidden'] = true;
/** 抛出错误 */
if ($this->request->isPost() && isset($this->request->protectPassword)) {
throw new Typecho_Widget_Exception(_t('对不起,您输入的密码错误'), 403);
}
}
$value = $this->pluginHandle(__CLASS__)->filter($value, $this);
/** 如果访问权限被禁止 */
if ($value['hidden']) {
$value['text'] = '<form class="protected" action="' . $this->security->getTokenUrl($value['permalink']) . '" method="post">' . '<p class="word">' . _t('请输入密码访问') . '</p>' . '<p><input type="password" class="text" name="protectPassword" />
<input type="submit" class="submit" value="' . _t('提交') . '" /></p>' . '</form>';
$value['title'] = _t('此内容被密码保护');
$value['tags'] = array();
$value['commentsNum'] = 0;
}
return $value;
}
示例15: htmlspecialchars
<?php
if (!defined('__TYPECHO_ROOT_DIR__')) {
exit;
}
$this->need('header.php');
?>
<style>.user-page .page-title,.user-page footer{display:none;}</style>
<?php
$rememberName = htmlspecialchars(Typecho_Cookie::get('__typecho_remember_name'));
$rememberMail = htmlspecialchars(Typecho_Cookie::get('__typecho_remember_mail'));
$notice = Typecho_Cookie::get('__typecho_notice');
if (!empty($notice)) {
$notice = json_decode($notice, true);
}
Typecho_Cookie::delete('__typecho_remember_name');
Typecho_Cookie::delete('__typecho_remember_mail');
?>
<div id="sidebar">
<?php
$this->need('user/widget_login.php');
?>
</div>
<div class="box" id="main">
<div class="head">
<div class="location">
<a href="<?php
$this->options->siteUrl();
?>
"><?php
$this->options->title();