当前位置: 首页>>代码示例>>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;未经允许,请勿转载。