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


PHP Forum::initUser方法代碼示例

本文整理匯總了PHP中Forum::initUser方法的典型用法代碼示例。如果您正苦於以下問題:PHP Forum::initUser方法的具體用法?PHP Forum::initUser怎麽用?PHP Forum::initUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Forum的用法示例。


在下文中一共展示了Forum::initUser方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: initLogin

 public function initLogin()
 {
     App::import('vendor', array('db', 'api.basic_auth'));
     $id = BasicAuth::getCurrentUser();
     if (false === $id) {
         $this->controller->error(ECode::$LOGIN_ERROR);
     }
     $this->isLogin = $id !== 'guest';
     if ('guest' !== $id) {
         $ret = Forum::checkBanIP($id, $this->from);
         switch ($ret) {
             case 1:
                 $this->controller->error(ECode::$LOGIN_IPBAN);
                 break;
             case 2:
                 $this->controller->error(ECode::$LOGIN_EPOS);
                 break;
             case 3:
                 $this->controller->error(ECode::$LOGIN_ERROR);
                 break;
         }
     }
     $db = DB::getInstance();
     if ($u = $db->one('select id, utmpnum, utmpkey from pl_api_session where id=?', array($id))) {
         if (Forum::initUser($u['id'], intval($u['utmpnum']), intval($u['utmpkey']))) {
             $val = array('expire' => time() + $this->_expire);
             $db->update('pl_api_session', $val, 'where id=?', array($u['id']));
             return;
         }
     }
     $ret = Forum::setUser(true);
     switch ($ret) {
         case -1:
             $this->controller->error(ECode::$LOGIN_MULLOGIN);
         case 1:
             $this->controller->error(ECode::$LOGIN_MAX);
         case 3:
             $this->controller->error(ECode::$LOGIN_IDBAN);
         case 4:
             $this->controller->error(ECode::$LOGIN_IPBAN);
         case 5:
             $this->controller->error(ECode::$LOGIN_FREQUENT);
         case 7:
             $this->controller->error(ECode::$LOGIN_NOPOS);
     }
     User::update();
     $user = User::getInstance();
     if ($u) {
         $val = array('utmpnum' => $user->index, 'utmpkey' => $user->utmpkey, 'expire' => time() + $this->_expire);
         $db->update('pl_api_session', $val, 'where id=?', array($user->userid));
     } else {
         $val = array('k' => array('id', 'utmpnum', 'utmpkey', 'expire'), 'v' => array(array($user->userid, $user->index, $user->utmpkey, time() + $this->_expire)));
         $db->insert('pl_api_session', $val);
     }
 }
開發者ID:tilitala,項目名稱:nForum,代碼行數:55,代碼來源:api_session.php

示例2: setCookie

 public function setCookie()
 {
     if ($this->_isSetOnline) {
         return;
     }
     $u = User::getInstance();
     $arr = array();
     Forum::initUser($this->userId, $u->index, $u->utmpkey);
     $utmpkey = $u->utmpkey;
     if (Configure::read("cookie.encryption")) {
         $utmpkey = $this->encrypt($u->utmpkey);
     }
     if ($this->_updateID) {
         $this->Cookie->write("UTMPUSERID", $u->userid, false);
     }
     $this->Cookie->write("UTMPKEY", $utmpkey, false);
     $this->Cookie->write("UTMPNUM", $u->index, false);
 }
開發者ID:tilitala,項目名稱:nForum,代碼行數:18,代碼來源:byr_session.php


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