當前位置: 首頁>>代碼示例>>PHP>>正文


PHP zmf::getCookie方法代碼示例

本文整理匯總了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;
     }
 }
開發者ID:ph7pal,項目名稱:mei,代碼行數:30,代碼來源:Q.php

示例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;
 }
開發者ID:ph7pal,項目名稱:momo,代碼行數:27,代碼來源:Comments.php

示例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'));
         }
     }
 }
開發者ID:ph7pal,項目名稱:momo,代碼行數:29,代碼來源:Admin.php

示例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'));
     }
 }
開發者ID:ph7pal,項目名稱:mei,代碼行數:7,代碼來源:SiteController.php

示例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;
 }
開發者ID:ph7pal,項目名稱:mei,代碼行數:9,代碼來源:LoginForm.php

示例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));
     }
 }
開發者ID:ph7pal,項目名稱:wedding,代碼行數:24,代碼來源:AreaLikes.php

示例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);
 }
開發者ID:ph7pal,項目名稱:momo,代碼行數:40,代碼來源:SiteController.php

示例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));
?>
開發者ID:ph7pal,項目名稱:momo,代碼行數:31,代碼來源:_addComment.php

示例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;
     }
 }
開發者ID:ph7pal,項目名稱:mei,代碼行數:15,代碼來源:zmf.php

示例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')));
開發者ID:ph7pal,項目名稱:mei,代碼行數:31,代碼來源:login.php

示例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) {
//.........這裏部分代碼省略.........
開發者ID:ph7pal,項目名稱:wedding,代碼行數:101,代碼來源:SiteController.php

示例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, '寫入數據時錯誤,請重試');
             }
         }
     }
 }
開發者ID:ph7pal,項目名稱:wedding,代碼行數:87,代碼來源:WeiboController.php

示例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;
     }
 }
開發者ID:ph7pal,項目名稱:wedding,代碼行數:45,代碼來源:AjaxController.php


注:本文中的zmf::getCookie方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。