本文整理汇总了PHP中zmf::getCookie方法的典型用法代码示例。如果您正苦于以下问题:PHP zmf::getCookie方法的具体用法?PHP zmf::getCookie怎么用?PHP zmf::getCookie使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zmf
的用法示例。
在下文中一共展示了zmf::getCookie方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _referer
function _referer()
{
$currentUrl = Yii::app()->request->url;
$arr = array('/site/', '/error/', '/attachments/');
$set = true;
if (Common::checkImg($currentUrl)) {
$set = false;
}
if ($set) {
foreach ($arr as $val) {
if (!$set) {
break;
}
if (strpos($currentUrl, $val) !== false) {
$set = false;
break;
}
}
}
if ($set && Yii::app()->request->isAjaxRequest) {
$set = false;
}
$referer = zmf::getCookie('refererUrl');
if ($set) {
zmf::setCookie('refererUrl', $currentUrl, 86400);
}
if ($referer != '') {
$this->referer = $referer;
}
}
示例2: beforeSave
public function beforeSave()
{
$ip = Yii::app()->request->userHostAddress;
$key = 'ipInfo-' . $ip;
$ipData = zmf::getCookie($key);
if (!$ipData) {
$url = 'http://apis.baidu.com/apistore/iplookupservice/iplookup?ip=' . $ip;
// 执行HTTP请求
$header = array('apikey:e5882e7ac4b03c5d6f332b6de4469e81');
$ch = curl_init();
// 添加apikey到header
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$res = curl_exec($ch);
$res = CJSON::decode($res, true);
$retData = array();
if ($res['errNum'] == 0) {
$retData = $res['retData'];
}
$ipData = json_encode($retData);
zmf::setCookie($key, $ipData, 2592000);
}
$this->ip = ip2long($ip);
$this->ipInfo = $ipData;
return true;
}
示例3: init
public function init()
{
parent::init();
$passwdErrorTimes = zmf::getCookie('checkWithCaptcha');
$time = zmf::config('adminErrorTimes');
if ($time > 0) {
if ($passwdErrorTimes >= $time) {
header('Content-Type: text/html; charset=utf-8');
echo '您暂时已被禁止访问';
Yii::app()->end();
}
}
$uid = zmf::uid();
if ($uid) {
// $randKey_cookie = zmf::getCookie('adminRandKey' . $uid);
// $randKey_cache = zmf::getFCache('adminRandKey' . $uid);
// if (!$randKey_cookie || ($randKey_cache != $randKey_cookie)) {
// Yii::app()->user->logout();
// $this->message(0, '登录已过期,请重新登录', Yii::app()->createUrl('admin/site/login'));
// }
$this->userInfo = Users::getOne($uid);
$this->uid = $uid;
} else {
$currentUrl = Yii::app()->request->url;
if (strpos($currentUrl, '/site/') === false) {
$this->message(0, '请先登录', Yii::app()->createUrl('/site/login'));
}
}
}
示例4: actions
public function actions()
{
$cookieInfo = zmf::getCookie('checkWithCaptcha');
if ($cookieInfo == '1') {
return array('captcha' => array('class' => 'CCaptchaAction', 'backColor' => 0xffffff, 'minLength' => '2', 'maxLength' => '3', 'height' => '30', 'width' => '60'), 'page' => array('class' => 'CViewAction'));
}
}
示例5: rules
public function rules()
{
$rules = array(array('email, password', 'required'), array('rememberMe', 'boolean'), array('password', 'authenticate'));
$cookieInfo = zmf::getCookie('checkWithCaptcha');
if ($cookieInfo == '1') {
$rules[] = array('verifyCode', 'captcha', 'allowEmpty' => !CCaptcha::checkRequirements());
}
return $rules;
}
示例6: getLikes
/**
* 返回用户关注的地址
* @param type $userInfo 用户信息
* @param type $return 返回方式 a:数组;s:字符串
* @return type
*/
public static function getLikes($userInfo, $return = 'a')
{
$cache = zmf::getCookie('myLikeAreas');
if (!$userInfo && !$cache) {
return array();
}
if ($userInfo) {
$extra = CJSON::decode($userInfo['extra'], true);
$likes = $extra['likeAreas'];
} else {
$likes = $cache;
}
if ($return == 'a') {
return explode(',', $likes);
} else {
return join(',', explode(',', $likes));
}
}
示例7: actionLogin
function actionLogin()
{
$this->layout = 'common';
if (!Yii::app()->user->isGuest) {
$this->message(0, '您已登录,请勿重复操作', Yii::app()->createUrl('admin/index/index'));
}
$model = new LoginForm();
if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
echo CActiveForm::validate($model);
Yii::app()->end();
}
if (isset($_POST['LoginForm'])) {
$model->attributes = $_POST['LoginForm'];
if ($model->validate() && $model->login()) {
$arr = array('latestLoginTime' => zmf::now());
$uid = Yii::app()->user->id;
if (!$this->checkPower('user', $uid, true)) {
Yii::app()->user->logout();
$model->addError('username', '您不是管理员');
} else {
//User::model()->updateByPk($uid, $arr);
zmf::delCookie('checkWithCaptcha');
//只允许单点登录
$randKey = zmf::randMykeys(8);
zmf::setCookie('adminRandKey' . $uid, $randKey, 86400);
zmf::setFCache('adminRandKey' . $uid, $randKey, 86400);
//记录操作
//UserLog::add($uid, '登录后台'.Yii::app()->request->userHostAddress);
$uuid = zmf::uuid();
zmf::setCookie('userCheckedLogin' . $uid, $uuid, 86400);
$this->redirect(array('index/index'));
}
} else {
$times = zmf::getCookie('checkWithCaptcha');
zmf::setCookie('checkWithCaptcha', intval($times) + 1, 86400);
}
}
$data = array('model' => $model);
$this->render('login', $data);
}
示例8: array
?>
" value="<?php
echo zmf::getCookie('noLoginUsername');
?>
">
</div>
<p class="help-block">将显示为由谁评论</p>
</div>
<div class="col-xs-6 col-sm-6">
<div class="input-group">
<span class="input-group-addon">邮箱</span>
<input type="text" class="form-control" placeholder="Email地址(选填)" id="<?php
echo 'email-' . $type . '-' . $keyid;
?>
" value="<?php
echo zmf::getCookie('noLoginEmail');
?>
">
</div>
<p class="help-block">Email不会被公布,仅用于接收评论的回复</p>
</div>
</div>
</div>
<?php
}
?>
<div class="form-group toggle-area">
<p>
<?php
echo CHtml::link('评论', 'javascript:;', array('class' => 'btn btn-success pull-right', 'action' => 'add-comment', 'action-data' => $keyid, 'action-type' => $type));
?>
示例9: actionLimit
/**
* 限制用户对某一操作的频率,如点赞,收藏,关注
* 默认4次
*/
public static function actionLimit($type, $keyid, $num = 4)
{
$cacheKey = 'actionLimit-' . $type . '-' . $keyid;
$info = (int) zmf::getCookie($cacheKey);
if ($info >= $num) {
return true;
} else {
zmf::setCookie($cacheKey, $info + 1, 60);
return false;
}
}
示例10: array
echo $form->error($model, 'email');
?>
</div>
<div class="form-group">
<?php
echo $form->labelEx($model, 'password');
?>
<?php
echo $form->passwordField($model, 'password', array('class' => 'form-control', 'placeholder' => '请输入密码'));
?>
<?php
echo $form->error($model, 'password');
?>
</div>
<?php
$cookieInfo = zmf::getCookie('checkWithCaptcha');
if ($cookieInfo == '1') {
?>
<div class="form-group">
<label class="required"><?php
echo zmf::t('verifyCode');
?>
<span class="required">*</span></label>
<?php
echo $form->textField($model, 'verifyCode', array('class' => 'form-control verify-code'));
?>
<?php
echo $form->error($model, 'verifyCode');
?>
<?php
$this->widget('CCaptcha', array('showRefreshButton' => true, 'clickableImage' => true, 'buttonType' => 'link', 'buttonLabel' => zmf::t('change_verify'), 'imageOptions' => array('alt' => zmf::t('change_verify'), 'align' => 'absmiddle')));
示例11: actionLogin
public function actionLogin($from = '')
{
if (!Yii::app()->user->isGuest) {
$this->message(0, '您已登录,请勿重复操作');
}
if (!$from) {
$from = 'login';
}
$bind = tools::val('bind', 't');
$model = new LoginForm();
//登录
$modelUser = new Users();
//注册
if ($bind == 'weibo') {
$strdata = zmf::getCookie('userWeiboData');
//取出cookie中用户的微博信息
if ($strdata) {
$data = unserialize($strdata);
$modelUser->truename = $data['screen_name'];
}
} elseif ($bind == 'qq') {
$strdata = zmf::getCookie('userQQData');
//取出cookie中用户的微博信息
if ($strdata) {
$data = unserialize($strdata);
$modelUser->truename = $data['nickname'];
}
} elseif ($bind == 'weixin') {
$strdata = zmf::getCookie('userWeixinData');
//取出cookie中用户的微博信息
if ($strdata) {
$data = unserialize($strdata);
$modelUser->truename = $data['nickname'];
}
}
if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
echo CActiveForm::validate($model);
Yii::app()->end();
}
if (isset($_POST['ajax']) && $_POST['ajax'] === 'users-addUser-form') {
echo CActiveForm::validate($modelUser);
Yii::app()->end();
}
//登录
if (isset($_POST['LoginForm'])) {
$from = 'login';
$model->attributes = $_POST['LoginForm'];
if ($model->validate()) {
$hasBind = false;
//判断是否绑定过微博
if ($bind == 'weibo') {
$strdata = zmf::getCookie('userWeiboData');
//取出cookie中用户的微博信息
if (!$strdata) {
$model->addError('email', '未能获取微博绑定信息,请重试');
} else {
$binddata = unserialize($strdata);
}
//根据当前用户名获取他是否已经绑定过
$email = $_POST['LoginForm']['email'];
$validator = new CEmailValidator();
if ($validator->validateValue($email)) {
$user = Users::model()->find('email=:email', array(':email' => $email));
} else {
$user = Users::model()->find('truename=:truename', array(':truename' => $email));
}
if ($user) {
$bindInfo = UserSina::model()->findByPk($user['id']);
if ($bindInfo) {
$hasBind = true;
}
$binddata['uid'] = $user['id'];
}
} elseif ($bind == 'qq') {
$strdata = zmf::getCookie('userQQData');
//取出cookie中用户的微博信息
if (!$strdata) {
$model->addError('email', '未能获取微博绑定信息,请重试');
} else {
$binddata = unserialize($strdata);
}
//根据当前用户名获取他是否已经绑定过
$email = $_POST['LoginForm']['email'];
$validator = new CEmailValidator();
if ($validator->validateValue($email)) {
$user = Users::model()->find('email=:email', array(':email' => $email));
} else {
$user = Users::model()->find('truename=:truename', array(':truename' => $email));
}
if ($user) {
$bindInfo = UserQq::model()->findByPk($user['id']);
if ($bindInfo) {
$hasBind = true;
}
$binddata['uid'] = $user['id'];
}
} elseif ($bind == 'weixin') {
$strdata = zmf::getCookie('userWeixinData');
//取出cookie中用户的微博信息
if (!$strdata) {
//.........这里部分代码省略.........
示例12: actionCallback
public function actionCallback()
{
$cacheToken = zmf::getCookie('weibojs_' . $this->weiboService->client_id);
//将token存入cookie,方便下次调用
if (isset($_REQUEST['code']) && !$cacheToken) {
$keys = array();
$keys['code'] = $_REQUEST['code'];
$keys['redirect_uri'] = $this->WB_CALLBACK_URL;
try {
$token = $this->weiboService->getAccessToken('code', $keys);
zmf::setCookie('weibojs_' . $this->weiboService->client_id, serialize($token), $this->cookieTime);
} catch (OAuthException $e) {
$this->message(0, '获取授权信息出错,请重试');
}
} elseif ($cacheToken) {
$token = unserialize($cacheToken);
}
if (!$token || !$token['access_token']) {
$this->message(0, '获取授权信息出错,请重试');
}
//根据ID获取用户等基本信息
$c = new SaeTClientV2($this->WB_AKEY, $this->WB_SKEY, $token['access_token']);
$uid_get = $c->get_uid();
$sinauid = $uid_get['uid'];
//新浪的用户ID
$user_message = $c->show_user_by_id($sinauid);
if (!$user_message) {
$this->message(0, '获取用户信息出错,请重试');
}
//将用户数据存入cookie
$data['access_token'] = $token['access_token'];
$data['expires_in'] = zmf::now() + intval($token['expires_in']);
$data['sinauid'] = $sinauid;
$data['screen_name'] = $user_message['screen_name'];
$data['name'] = $user_message['name'];
$data['profile_url'] = 'http://weibo.com/' . $user_message['profile_url'];
$data['avatarurl'] = $user_message['avatar_hd'];
$infoArr = array('screen_name' => $user_message['screen_name'], 'avatarurl' => $user_message['avatarurl'], 'profile_url' => 'http://weibo.com/' . $user_message['profile_url']);
$data['data'] = serialize($infoArr);
$strdata = serialize($data);
zmf::setCookie('userWeiboData', $strdata, $this->cookieTime);
//获取用户之前的意图,是注册、登录还是绑定
$action = zmf::getCookie('lastWeiboAction');
if (!in_array($action, array('login', 'reg', 'bind'))) {
throw new CHttpException(403, '缺少参数');
}
if (in_array($action, array('login', 'reg')) && zmf::uid()) {
$this->message(0, '您已登录,请勿该操作', $this->referer);
} elseif ($action == 'bind' && !zmf::uid()) {
$this->redirect(array('site/login'));
}
$bindInfo = UserSina::model()->find('openid=:sinauid', array(':sinauid' => $data['sinauid']));
if ($action == 'login') {
//确实绑定过微博,则直接登录
if ($bindInfo) {
$this->loginWithWeibo($bindInfo, $data);
} else {
//没有绑定过就跳转到注册页面
$this->redirect(array('site/reg', 'bind' => 'weibo'));
}
} elseif ($action == 'reg') {
//绑定过微博就直接登录
if ($bindInfo) {
$this->loginWithWeibo($bindInfo, $data);
} else {
//没有绑定过就跳转到注册页面
$this->redirect(array('site/reg', 'bind' => 'weibo'));
}
} elseif ($action == 'bind') {
$uid = zmf::uid();
if ($bindInfo) {
throw new CHttpException(403, '该微博已经绑定其他账户');
} else {
$otherBind = UserSina::model()->findByPk($uid);
if ($otherBind) {
throw new CHttpException(403, '您已经绑定过其他账户');
}
$data['uid'] = $uid;
if (UserSina::addCookie($data)) {
//返回设置页面
$this->redirect(array('users/config'));
} else {
throw new CHttpException(403, '写入数据时错误,请重试');
}
}
}
}
示例13: actionMergecookie
/**
* 合并用户关注的地区
*/
public function actionMergecookie()
{
$type = tools::val('type', 't', 1);
if (!in_array($type, array('add', 'del'))) {
$this->jsonOutPut(0, '不允许的类型');
}
$uid = zmf::uid();
switch ($type) {
case 'add':
$this->checkLogin();
$cache = zmf::getCookie('myLikeAreas');
if ($cache) {
//取出只存在于cookie的地区id
$items = AreaLikes::model()->findAll(array('select' => 'logid', 'condition' => "uid={$uid} AND logid NOT IN({$cache})"));
$ids = array_keys(CHtml::listData($items, 'logid', ''));
if (!empty($ids)) {
$extraInfo = Users::getExtra($this->userInfo);
if ($extraInfo['likeAreas']) {
$arr = explode(',', $extraInfo['likeAreas']);
}
foreach ($ids as $id) {
$attr = array('uid' => $uid, 'logid' => $id);
$model = new AreaLikes();
$model->attributes = $attr;
if ($model->save()) {
$arr[] = $id;
}
}
$arr = array_unique(array_filter($arr));
$extraInfo['likeAreas'] = join(',', $arr);
Users::updateExtra($uid, $extraInfo);
}
}
zmf::delCookie('myLikeAreas');
$this->jsonOutPut(1, '合并成功');
break;
case 'del':
zmf::delCookie('myLikeAreas');
$this->jsonOutPut(1, '删除成功');
break;
}
}