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


PHP Auth::get_user方法代碼示例

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


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

示例1: __construct

 public function __construct()
 {
     parent::__construct();
     $this->template->links = array('Home' => 'home', 'Browse' => 'folders', 'Search' => 'search', 'About' => 'about', 'Contact' => 'contact');
     $this->db = Database::instance();
     // makes database object available to all controllers
     $this->session = Session::instance();
     $authentic = new Auth();
     if ($authentic->logged_in() || $authentic->auto_login()) {
         $this->user = $authentic->get_user();
     } else {
         $this->session->set("requested_url", "/" . url::current());
         // this will redirect from the login page back to this page
         url::redirect('/auth/login');
     }
     // if ($authentic->auto_login()) {
     //     $this->user = $authentic->get_user();
     //     url::redirect('/document/view/1');
     // }
     // if (!$authentic->logged_in()) {
     //
     //     $this->session->set("requested_url","/".url::current()); // this will redirect from the login page back to this page
     //     url::redirect('/auth/login');
     // } else {
     //     $this->user = $authentic->get_user(); //now you have access to user information stored in the database
     // }
 }
開發者ID:jokke,項目名稱:ORL,代碼行數:27,代碼來源:website.php

示例2: has_role

 protected function has_role($roles)
 {
     if (!$this->template->is_logged_in) {
         return false;
     }
     if (!is_array($roles)) {
         $roles = array($roles);
     }
     foreach ($roles as $role) {
         if ($this->auth->get_user()->has_role($role)) {
             return true;
         }
     }
     return false;
 }
開發者ID:vitch,項目名稱:kohana-kadmium,代碼行數:15,代碼來源:auth.php

示例3: save

 /**
  * 保存訂單
  * @param $data 訂單數據
  */
 protected function save($data)
 {
     if (!$this->order) {
         $this->order = \Model_Order::forge();
     }
     $this->order->set($data);
     if (!$this->order->order_no) {
         $this->order->order_no = $this->generate_order_no();
     }
     if (!$this->order->buyer_id) {
         $this->order->buyer_id = \Auth::check() ? \Auth::get_user()->id : 0;
     }
     if (!$this->order->from_id) {
         $this->order->from_id = \Session::get('seller', false) ? \Session::get('seller')->id : 0;
     }
     if (!$this->order->order_status) {
         $this->order->order_status = 'WAIT_PAYMENT';
     }
     $this->original_fee = $this->order->total_fee - $this->order->preferential_fee;
     //保存訂單
     if (!$this->order->save()) {
         return false;
     }
     //發送下單成功模板消息
     $params = ['first' => ['value' => '訂單支付成功', 'color' => '#D02090'], 'keyword1' => ['value' => $this->order->order_no, 'color' => '#D02090'], 'keyword2' => ['value' => $this->order->order_name, 'color' => '#D02090'], 'keyword3' => ['value' => $this->order->total_fee, 'color' => '#D02090'], 'remark' => ['value' => '', 'color' => '#D02090']];
     $this->sendMsgTemplate('tQ46mymM617VOKpNv6rbg5hBQpXIle8EC64n-ozbSSw', $params, '');
     //清理購物車
     foreach ($this->order->details as $item) {
         $trollery = \Model_Trolley::find_one_by('goods_id', $item->id);
         if ($trollery === null) {
             continue;
         }
         $trollery->delete();
     }
 }
開發者ID:wxl2012,項目名稱:wx,代碼行數:39,代碼來源:basecontroller.php

示例4: action_qr

 /**
  * 生成二維碼
  *
  * @param content 生成二維碼的內容
  * @param errLevel 容錯級別 取值範圍 L、M、Q、H
  * @param size 生成圖片大小 取值範圍 1 ~ 10
  * @param outtype 輸出類型
  */
 public function action_qr()
 {
     $data = \Input::get();
     $user_id = \Auth::check() ? \Auth::get_user()->id : 0;
     $time = time();
     $errLevel = \Input::get('level', 'L');
     $size = \Input::get('size', 10);
     //添加LOGO
     //$logo_file = DOCROOT . 'uploads/images/demo/mall/icon.jpg';
     $logo_file = false;
     //指定輸出目錄
     $output_path = '/uploads' . (\Auth::check() ? '/' . \Auth::get_user()->id : '') . '/images/qrcodes/' . date('Ymd');
     //指定文件名稱
     $image = "qrcode_{$time}_{$user_id}.png";
     //檢測目錄是否存在,並創建目錄
     $qr_path = DOCROOT . "{$output_path}";
     if (!file_exists($qr_path)) {
         $temp = DOCROOT;
         foreach (explode('/', $output_path) as $key => $value) {
             $temp .= "/{$value}";
             if (!file_exists($temp)) {
                 mkdir($temp);
             }
         }
     }
     $qr_path = "{$qr_path}/{$image}";
     \QRcode::png($data['content'], $qr_path, $errLevel, $size, 2);
     $QR = imagecreatefromstring(file_get_contents($qr_path));
     if ($logo_file) {
         $logo = imagecreatefromstring(file_get_contents($logo_file));
         $QR_width = imagesx($QR);
         //二維碼圖片寬度
         $QR_height = imagesy($QR);
         //二維碼圖片高度
         $logo_width = imagesx($logo);
         //logo圖片寬度
         $logo_height = imagesy($logo);
         //logo圖片高度
         $logo_qr_width = $QR_width / 5;
         $scale = $logo_width / $logo_qr_width;
         $logo_qr_height = $logo_height / $scale;
         $from_width = ($QR_width - $logo_qr_width) / 2;
         //重新組合圖片並調整大小
         imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);
     }
     if (!isset($data['outtype']) || $data['outtype'] == 'file') {
         imagepng($QR, $qr_path);
         echo "<img src='{$output_path}/{$image}'>";
     } else {
         if ($data['outtype'] == 'browser') {
             imagepng($QR);
         } else {
             if ($data['outtype'] == 'url') {
                 echo "{$output_path}/{$image}";
             }
         }
     }
 }
開發者ID:wxl2012,項目名稱:wx,代碼行數:66,代碼來源:image.php

示例5: action_login

 public function action_login()
 {
     if ($this->_auth->logged_in()) {
         $this->_message = __("Already logged in");
         return;
     }
     $data = json_decode($this->request->body(), true);
     $username = $data['username'];
     $password = $data['password'];
     $remember = Arr::get($data, 'remember', FALSE);
     if (!$this->_auth->login($username, $password, $remember)) {
         $this->_message = __("Username or password is wrong.");
         return;
     }
     $this->_message = __("Login succeeded");
     $this->_user = $this->_auth->get_user();
     $this->_user->reload();
 }
開發者ID:ragchuck,項目名稱:ra-Log,代碼行數:18,代碼來源:auth.php

示例6: _redirectIfLoggedIn

 private function _redirectIfLoggedIn(Auth $authentic)
 {
     // See if the user is already logged in
     if ($authentic->logged_in()) {
         $this->user = $authentic->get_user();
         // Load the user's info into the current class, in case it's needed
         $this->_redirectPriorPage();
     }
 }
開發者ID:swk,項目名稱:bluebox,代碼行數:9,代碼來源:user.php

示例7: get_user

 /**
  * Gets the currently logged in user from the session (with auto_login check).
  * Returns $default if no user is currently logged in.
  *
  * @param   mixed $default to return in case user isn't logged in
  *
  * @return  mixed
  */
 public function get_user($default = null)
 {
     $user = parent::get_user($default);
     if ($user === $default) {
         // check for "remembered" login
         if (($user = $this->auto_login()) === false) {
             return $default;
         }
     }
     return $user;
 }
開發者ID:s4urp8n,項目名稱:kohana-admin,代碼行數:19,代碼來源:ORM.php

示例8: action_login

 public function action_login()
 {
     if (\Auth::check()) {
         $redirect = "/admin";
         if (isset($data['to_url'])) {
             $redirect = $data['to_url'];
         }
         \Response::redirect($redirect);
     }
     \View::set_global(array('menu' => 'admin-home', 'title' => '登錄係統', 'action' => 'login'));
     if (\Input::method() == 'POST') {
         if (\Auth::login()) {
             if (\Auth::get_user()->username == 'admin') {
                 \Response::redirect('/admin');
             }
             $employee = \Model_Employee::query()->where('parent_id', \Auth::get_user()->id)->get_one();
             if (!$employee) {
                 \Session::set_flash('msg', ['status' => 'err', 'msg' => '非法登錄,多次嘗試登錄,您的帳戶將被封鎖!', 'title' => '警告', 'sub_title' => '非法登錄', 'icon' => 'exclamation-circle', 'color' => '#d9534f']);
                 return $this->not_login_alert();
             }
             // 保存會話信息: 當前登錄人員的身份、所屬商戶、微信公眾號信息
             \Session::set('seller', $employee->seller);
             \Session::set('people', $employee->people);
             \Session::set('employee', $employee);
             // 查詢當前商戶默認公眾號信息
             $accounts = \Model_WXAccount::query()->where(['seller_id' => $employee->seller->id])->get();
             $account = false;
             if (count($accounts) > 1) {
                 foreach ($accounts as $item) {
                     if ($account->is_default == 1) {
                         $account = $item;
                         break;
                     }
                 }
             } else {
                 $account = current($accounts);
             }
             \Session::set('WXAccount', $account);
             //獲取API訪問令牌
             $result = \handler\common\UrlTool::request(\Config::get('base_url') . 'api/token.json?user_id=' . \Auth::get_user()->id);
             $token = json_decode($result->body);
             \Session::set('access_token', $token->access_token);
             $redirect = "/admin";
             if (isset($data['to_url'])) {
                 $redirect = $data['to_url'];
             }
             \Response::redirect($redirect);
         }
         \Session::set_flash('msg', array('status' => 'err', 'msg' => '登錄失敗', 'errcode' => 20));
     }
     return \Response::forge(\View::forge("ace/login"));
 }
開發者ID:wxl2012,項目名稱:wx,代碼行數:52,代碼來源:home.php

示例9: action_cashback_members

 public function action_cashback_members()
 {
     $params = [];
     $params['items'] = \Model_MemberRecommendRelation::childMembers(\Auth::get_user()->id);
     /*foreach ($members as $member){
           echo "{$member->member_id}[{$member->depth}級]: " . count($member->member->orders) . '單<br>';
           foreach ($member->member->orders as $order) {
               echo '付款金額:' . ($order->original_fee) . '應分總額:' . ($order->original_fee * 0.1 * 0.5);
           }
       }*/
     \View::set_global($params);
     $this->template->content = \View::forge("{$this->theme}/order/members");
 }
開發者ID:wxl2012,項目名稱:wx,代碼行數:13,代碼來源:order.php

示例10: action_address_save

 public function action_address_save()
 {
     $msg = ['status' => 'err', 'msg' => '', 'errcode' => 10];
     $data = \Input::post();
     $address = \Model_PeopleAddress::forge($data);
     $address->parent_id = \Auth::get_user()->id;
     if ($address->save()) {
         $address->country;
         $address->province;
         $address->city;
         $address->county;
         $msg = ['status' => 'succ', 'msg' => '', 'errcode' => 0, 'data' => $address];
     }
     return $this->response($msg, 200);
 }
開發者ID:wxl2012,項目名稱:wx,代碼行數:15,代碼來源:member.php

示例11: __construct

 public function __construct()
 {
     parent::__construct();
     $this->session = Session::instance();
     $authentic = new Auth();
     if (!$authentic->logged_in('admin')) {
         // redirect from the login page back to this page
         $this->session->set("requested_url", "/" . url::current());
         url::redirect('/auth/login/');
     } else {
         //now you have access to user information stored in the database
         $this->user = $authentic->get_user();
     }
     $this->template->title = $this->template->document_title = 'Site Admin';
 }
開發者ID:actuosus,項目名稱:kohana_admin,代碼行數:15,代碼來源:admin.php

示例12: __construct

 public function __construct()
 {
     parent::__construct();
     $this->session = Session::instance();
     $this->cache = Cache::instance();
     $authentic = new Auth();
     if (!$authentic->logged_in()) {
         $this->session->set("requested_url", "/" . url::current());
         // this will redirect from the login page back to this page/
         url::redirect('/auth');
     } else {
         $this->user = $authentic->get_user();
         //now you have access to user information stored in the database
     }
 }
開發者ID:humbleBeginner,項目名稱:inventory-pho2,代碼行數:15,代碼來源:welcome.php

示例13: office

 public function office()
 {
     $auth = new Auth();
     $office_id = $auth->get_user()->office_id;
     $items = $this->item_model->getAllOnStock();
     foreach ($items as $key => $value) {
         $arr[$key] = $value;
     }
     $items = $arr;
     $budget_record = $this->budget_model->getOne($office_id);
     foreach ($items as $key => $value) {
         $arr[$key] = $value;
     }
     $items = $arr;
     echo json_encode(compact('items', 'budget_record'));
 }
開發者ID:humbleBeginner,項目名稱:inventory-pho2,代碼行數:16,代碼來源:ajax_source.php

示例14: action_bid

 /**
  * 出價
  * @param int $id 拍品ID
  */
 public function action_bid($id = 0)
 {
     if (\Input::method() == 'POST') {
         $msg = ['status' => 'err', 'msg' => '', 'errcode' => 10];
         $order_no = \Model_Order::get_order_on();
         $data = ['order_no' => $order_no, 'order_type' => 'AUCTION', 'buyer_id' => \Auth::get_user()->id, 'from_id' => \Session::get('seller')->id, 'total_fee' => \Input::post('bid'), 'original_fee' => \Input::post('bid')];
         $order = \Model_Order::forge($data);
         $order->details = [\Model_OrderDetail::forge(['goods_id' => $id, 'num' => 1, 'price' => \Input::post('bid')])];
         if ($order->save()) {
             $msg = ['status' => 'succ', 'msg' => '', 'errcode' => 0];
         }
         if (\Input::is_ajax()) {
             die(json_encode($msg));
         }
         \Session::set_flash('msg', $msg);
     }
 }
開發者ID:wxl2012,項目名稱:wx,代碼行數:21,代碼來源:lot.php

示例15: get_upload_path

 /**
  * 獲取用戶上傳文件存儲的路徑及訪問地址
  *
  * @param module 資源存儲的類型(請參考config/global.php文件中的folders數組)
  */
 public static function get_upload_path($module = 4, $coustom = '')
 {
     \Config::load('global');
     $folders = \Config::get('folders');
     $root = \Config::get('root_directory');
     $host = str_replace('.', '', \Input::server('HTTP_HOST'));
     $user_id = \Auth::check() ? \Auth::get_user()->id : '0';
     //資源訪問主機域名如:http://img1.evxin.com
     $resUrl = \Config::get('resource_url') !== false ? \Config::get('resource_url') : '';
     //資源物理路徑
     $uploadPath = \Config::get('upload_path') !== false ? \Config::get('upload_path') : '';
     $user_id = $module == 4 ? '' : "/{$user_id}/";
     $ymd = date('/Ymd');
     //完整物理路徑=服務器物理路徑+當前域名+資源存儲目錄+年月日
     $path = "{$root}/{$host}/{$folders[$module]}{$user_id}{$ymd}/" . ($coustom ? "{$coustom}/" : '');
     $url = "{$resUrl}/{$path}";
     return array('root_directory' => $uploadPath, 'path' => $path, 'url' => $url);
 }
開發者ID:wxl2012,項目名稱:wx,代碼行數:23,代碼來源:uploadhandler.php


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