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 // } }
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; }
/** * 保存订单 * @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(); } }
/** * 生成二维码 * * @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}"; } } } }
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(); }
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(); } }
/** * 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; }
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")); }
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"); }
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); }
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'; }
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 } }
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')); }
/** * 出价 * @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); } }
/** * 获取用户上传文件存储的路径及访问地址 * * @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); }
public function before() { parent::before(); if ($this->getNotOpenidAllowed()) { return; } if (!\Agent::is_mobiledevice()) { $this->theme = 'mobile'; $this->template->set_filename('mobile/template'); } if (!\Auth::check()) { \Response::redirect('/admin/login'); } // 检测是否后台帐户 if (!\Session::get('employee', false) && \Auth::get_user()->username != 'admin') { \Auth::logout(); \Response::redirect('/admin/login'); } }
public function action_index() { $params = array('title' => '微信公众帐户列表——微信公众号管理', 'menu' => 'wxaccount', 'action_name' => '微信公众帐户列表'); $GLOBAL_OPTIONS = \Session::get('GLOBAL_OPTIONS'); if (\Auth::get_user()->username != 'admin' && isset($GLOBAL_OPTIONS['bind_wx_account_count']) && $GLOBAL_OPTIONS['bind_wx_account_count'] == 1) { $seller = \Session::get('seller'); $account_id = ''; if ($seller->wxaccounts) { $account_id = current($seller->wxaccounts)->id; } \Response::redirect("/admin/wxaccount/save/{$account_id}"); } $account = \Model_WXAccount::query(); if (\Auth::get_user()->username != 'admin') { $account->where('seller_id', \Session::get('seller')->id); } $params['items'] = $account->get(); \View::set_global($params); $this->template->content = \View::forge("ace/mp/account/index"); }
/** * Méthode : récuperer les informations utilisateur */ public function __construct() { parent::__construct(); if (!request::is_ajax()) { cookie::set('urlAdminUrl', url::current()); } $authentic = new Auth(); if ($authentic->logged_in()) { $this->user = $authentic->get_user(); $this->role->name = $this->user->roles->select_list('id', 'name'); $this->role->description = $this->user->roles->select_list('id', 'description'); if (Kohana::config('game.debug') && !in_array('admin', $this->role->name)) { $authentic = Auth::instance(); if ($authentic->logged_in()) { $authentic->logout(TRUE); } return url::redirect('auth?msg=' . urlencode(Kohana::lang('form.maintenance'))); } elseif (!in_array('login', $this->role->name)) { return url::redirect('auth'); } } }
public function has_access($condition, array $entity) { // get the group driver instance $group_driver = \Auth::group($entity[0]); // parse the requested permissions so we can check them $condition = static::_parse_conditions($condition); // if we couldn't parse the conditions, don't have a driver, or the driver doesn't export roles, bail out if (!is_array($condition) || empty($group_driver) || !is_callable(array($group_driver, 'get_roles'))) { return false; } // get the permission area and the permission rights to be checked $area = $condition[0]; // any actions defined? if (!is_array($condition[1]) and preg_match('#(.*)?\\[(.*)?\\]#', $condition[1], $matches)) { $rights = (array) $matches[1]; $actions = explode(',', $matches[2]); } else { $rights = (array) $condition[1]; $actions = array(); } // fetch the current user object $user = Auth::get_user(); // some storage to collect the current rights and revoked rights, and the global flag $current_rights = array(); $revoked_rights = array(); $global_access = null; // assemble the current users effective rights $cache_key = \Config::get('ormauth.cache_prefix', 'auth') . '.permissions.user_' . ($user ? $user->id : 0); try { list($current_rights, $revoked_rights, $global_access) = \Cache::get($cache_key); } catch (\CacheNotFoundException $e) { // get the role objects assigned to this group $current_roles = $entity[1]->roles; // if we have a user, add the roles directly assigned to the user if ($user) { $current_roles = \Arr::merge($current_roles, Auth::get_user()->roles); } foreach ($current_roles as $role) { // role grants all access if ($role->filter == 'A') { $global_access = true; } elseif ($role->filter == 'D') { $global_access = false; } elseif ($role->filter == 'R') { // fetch the permissions of this role foreach ($role->permissions as $permission) { isset($revoked_rights[$permission->area][$permission->permission]) or $revoked_rights[$permission->area][$permission->permission] = array(); foreach ($role->rolepermission as $rolepermission) { if ($rolepermission->role_id == $role->id and $rolepermission->perms_id == $permission->id) { $revoked_rights[$permission->area][$permission->permission] = array_merge($revoked_rights[$permission->area][$permission->permission], array_intersect_key($permission->actions ?: array(), array_flip($rolepermission->actions ?: array()))); break; } } } } else { // fetch the permissions of this role foreach ($role->permissions as $permission) { isset($current_rights[$permission->area][$permission->permission]) or $current_rights[$permission->area][$permission->permission] = array(); foreach ($role->rolepermission as $rolepermission) { if ($rolepermission->role_id == $role->id and $rolepermission->perms_id == $permission->id) { $current_rights[$permission->area][$permission->permission] = array_merge($current_rights[$permission->area][$permission->permission], array_intersect_key($permission->actions ?: array(), array_flip($rolepermission->actions ?: array()))); break; } } } } } // if this user doesn't have a global filter applied... if (is_array($current_rights)) { if ($user) { // add the users group rights foreach ($user->group->permissions as $permission) { isset($current_rights[$permission->area][$permission->permission]) or $current_rights[$permission->area][$permission->permission] = array(); foreach ($user->group->grouppermission as $grouppermission) { if ($grouppermission->group_id == $user->group_id and $grouppermission->perms_id == $permission->id) { $current_rights[$permission->area][$permission->permission] = array_merge($current_rights[$permission->area][$permission->permission], array_intersect_key($permission->actions ?: array(), array_flip($grouppermission->actions ?: array()))); break; } } } // add the users personal rights foreach ($user->permissions as $permission) { isset($current_rights[$permission->area][$permission->permission]) or $current_rights[$permission->area][$permission->permission] = array(); foreach ($user->userpermission as $userpermission) { if ($userpermission->user_id == $user->id and $userpermission->perms_id == $permission->id) { $current_rights[$permission->area][$permission->permission] = array_merge($current_rights[$permission->area][$permission->permission], array_intersect_key($permission->actions ?: array(), array_flip($userpermission->actions ?: array()))); break; } } } } } // save the rights in the cache \Cache::set($cache_key, array($current_rights, $revoked_rights, $global_access)); } // check for a revocation first foreach ($rights as $right) { // check revocation permissions if (isset($revoked_rights[$area]) and array_key_exists($right, $revoked_rights[$area])) { $revoked = true; // need to check any actions? foreach ($actions as $action) { if (!in_array($action, $revoked_rights[$area][$right])) { $revoked = false; break; } } // right revoked? if ($revoked) { return false; } } } // was a global filter applied? if (is_bool($global_access)) { // we're done here return $global_access; } // start checking rights, terminate false when right not found foreach ($rights as $right) { // check basic permissions if (!isset($current_rights[$area]) or !array_key_exists($right, $current_rights[$area])) { return false; } // need to check any actions? foreach ($actions as $action) { if (!in_array($action, $current_rights[$area][$right])) { return false; } } } // all necessary rights were found, return true return true; }
/** * Gets the currently logged in user from the session (with auto_login check). * Returns FALSE if no user is currently logged in. * * @return mixed */ public function get_user($default = NULL) { $user = parent::get_user($default); if (!$user) { // check for "remembered" login $user = $this->auto_login(); } return $user; }
public function __construct() { parent::__construct(); // Load cache $this->cache = new Cache(); // Load session $this->session = new Session(); // Load database $this->db = new Database(); $this->session = Session::instance(); $this->auth = Auth::instance(); // Themes Helper $this->themes = new Themes(); $this->themes->admin = TRUE; // Admin is not logged in, or this is a member (not admin) if (!$this->auth->logged_in('login')) { url::redirect('login'); } // Check if user has the right to see the admin panel if (!$this->auth->admin_access()) { // This user isn't allowed in the admin panel url::redirect('/'); } // Get the authenticated user $this->user = $this->auth->get_user(); // Set Table Prefix $this->table_prefix = Kohana::config('database.default.table_prefix'); // Get the no. of items to display setting $this->items_per_page = (int) Kohana::config('settings.items_per_page_admin'); $this->template->admin_name = $this->user->name; // Retrieve Default Settings $this->template->site_name = Kohana::config('settings.site_name'); $this->template->mapstraction = Kohana::config('settings.mapstraction'); $this->themes->api_url = Kohana::config('settings.api_url'); // Javascript Header $this->themes->map_enabled = FALSE; $this->themes->datepicker_enabled = FALSE; $this->themes->flot_enabled = FALSE; $this->themes->treeview_enabled = FALSE; $this->themes->protochart_enabled = FALSE; $this->themes->colorpicker_enabled = FALSE; $this->themes->editor_enabled = FALSE; $this->themes->tablerowsort_enabled = FALSE; $this->themes->json2_enabled = FALSE; $this->themes->hovertip_enabled = TRUE; $this->themes->slider_enabled = TRUE; $this->themes->js = ''; $this->template->form_error = FALSE; // Initialize some variables for raphael impact charts $this->themes->raphael_enabled = FALSE; $this->themes->impact_json = ''; // Generate main tab navigation list. $this->template->main_tabs = admin::main_tabs(); // Generate sub navigation list (in default layout, sits on right side). $this->template->main_right_tabs = admin::main_right_tabs($this->user); $this->template->this_page = ""; // Header Nav $header_nav = new View('header_nav'); $this->template->header_nav = $header_nav; $this->template->header_nav->loggedin_user = $this->user; $this->template->header_nav->loggedin_role = $this->user->dashboard(); $this->template->header_nav->site_name = Kohana::config('settings.site_name'); // Language switcher $this->template->languages = $this->themes->languages(); Event::add('ushahidi_filter.view_pre_render.admin_layout', array($this, '_pre_render')); }
/** * 获取当前用户的推荐人的微信OPENID * @return bool */ private function getParentWechatOpenid() { return 'oqTo9uJao4vdZy5EZH8yQgL_0SY0'; //获取上级用户 $members = \Model_MemberRecommendRelation::parentMember(\Auth::get_user()->id); if (!$members) { return false; } $member = current($members); $to_openid = false; //获取上级用户的微信信息 $wechat = \Model_Wechat::query()->where(['user_id' => $member->master_id])->get_one(); //获取上级用户的微信OPENID foreach ($wechat->ids as $openid) { if ($openid->account_id == \Session::get('WXAccount')->id) { $to_openid = $openid->openid; } } return $to_openid; }
/** * Gets the currently logged in user from the session (with auto_login check). * Returns FALSE if no user is currently logged in. * * @return mixed */ public function get_user($default = NULL) { // Load the session for the parent method $this->session(); $user = $this->_load_user(parent::get_user($default)); if (!($user and $user->loaded())) { // check for "remembered" login $user = $this->auto_login(); } return $user; }
public function getOfficeRequestStatistics() { if (request::is_ajax()) { $this->auto_render = FALSE; $auth = new Auth(); $office_id = $auth->get_user()->office_id; echo json_encode($this->request_model->office_report($office_id)); } }
public function index() { $this->document->title = "Dashboard"; $this->document->user = Auth::get_user(); $this->document->domains = Document::instance('hit')->distinct('host', array('user' => Auth::get_user()->_id)); }
public function get_user($default = NULL) { $user = parent::get_user($default); if (!$user) { // Пробуем аторизоваться из кук // Если раньше была авторизация с чекбоксом Запомнить меня $user = $this->auto_login(); } return $user; }
/** * Loads the template View object, if it is direct request * * @return void * @throws Http_Exception_415 If none of the accept-types are supported */ public function before() { // Execute parent::before first parent::before(); if ($this->bare == FALSE) { // Load the config $this->_config = Config::load('site'); if (Kohana::$profiling) { // Start a new benchmark token $this->_benchmark = Profiler::start('Gleez', ucfirst($this->request->controller()) . ' Controller'); } // Test whether the current request is command line request if (Kohana::$is_cli) { $this->_ajax = FALSE; $this->auto_render = FALSE; } // Test whether the current request is the first request if (!$this->request->is_initial()) { $this->_internal = TRUE; $this->auto_render = FALSE; } // Test whether the current request is ajax request if ($this->request->is_ajax()) { $this->_ajax = TRUE; $this->auto_render = FALSE; } // Test whether the current request is jquery mobile request. ugly hack if (Request::is_mobile() and $this->_config->get('mobile_theme', FALSE)) { $this->_ajax = FALSE; $this->auto_render = TRUE; } // Test whether the current request is datatables request if (Request::is_datatables()) { $this->_ajax = TRUE; $this->auto_render = FALSE; } $this->response->headers('X-Powered-By', Gleez::getVersion(TRUE, TRUE) . ' (' . Gleez::CODENAME . ')'); $this->_auth = Auth::instance(); // Get desired response formats $accept_types = Request::accept_type(); $accept_types = Arr::extract($accept_types, array_keys($this->_accept_formats)); // Set response format to first matched element $this->_response_format = $this->request->headers()->preferred_accept(array_keys($this->_accept_formats)); $site_name = Template::getSiteName(); $url = URL::site(NULL, TRUE); View::bind_global('site_name', $site_name); View::bind_global('site_url', $url); } if ($this->auto_render && $this->bare == FALSE) { // Throw exception if none of the accept-types are supported if (!($accept_types = array_filter($accept_types))) { throw new Http_Exception_415('Unsupported accept-type', 415); } // Initiate a Format instance $this->_format = Format::instance(); // Load the template $this->template = View::factory($this->template); $this->title_separator = $this->_config->get('title_separator', ' | '); $this->_widgets = Widgets::instance(); $this->template->_admin = Theme::$is_admin; // Set the destination & redirect url $this->_desti = array('destination' => $this->request->uri()); $this->redirect = $this->request->query('destination') !== NULL ? $this->request->query('destination') : array(); // Bind the generic page variables $this->template->set('site_name', Template::getSiteName())->set('site_slogan', $this->_config->get('site_slogan', __('Innovate IT')))->set('site_url', URL::site(NULL, TRUE))->set('site_logo', $this->_config->get('site_logo', FALSE))->set('sidebar_left', array())->set('sidebar_right', array())->set('column_class', '')->set('main_column', 12)->set('head_title', $this->title)->set('title', $this->title)->set('subtitle', $this->subtitle)->set('icon', $this->icon)->set('schemaType', $this->schemaType)->set('front', FALSE)->set('mission', FALSE)->set('tabs', FALSE)->set('subtabs', FALSE)->set('actions', FALSE)->set('_user', $this->_auth->get_user())->bind('datatables', $this->_datatables); // Page Title $this->title = ucwords($this->request->controller()); // Assign the default css files $this->_set_default_css(); // Assign the default js files $this->_set_default_js(); // Set default server headers $this->_set_default_server_headers(); // Set default meta data and media $this->_set_default_meta_links(); $this->_set_default_meta_tags(); /** * Make your view template available to all your other views * so easily you could access template variables */ View::bind_global('template', $this->template); } if (Kohana::$environment === Kohana::DEVELOPMENT) { Log::debug('Executing Controller [:controller] action [:action]', array(':controller' => $this->request->controller(), ':action' => $this->request->action())); } }
/** * 生成订单号 * * @return string */ public static function get_order_on() { $seller = \Session::get('seller', false); $wechat = \Session::get('wechat', false); $wxaccount = \Session::get('WXAccount', false); $user = \Auth::check() ? \Auth::get_user() : false; $seller = $seller ? $seller->id : 0; $user_id = $user ? $user->id : 0; $wechat_id = $wechat ? $wechat->id : 0; $account_id = $wxaccount ? $wxaccount->id : 0; $date = date('YmdHis'); return "{$date}{$user_id}{$wechat_id}{$seller}{$account_id}"; }
/** * Gets the currently logged in user from the session (with auto_login check). * Returns FALSE if no user is currently logged in. * * @return mixed */ public function get_user() { $user = parent::get_user(); if ($user === FALSE) { // check for "remembered" login $user = $this->auto_login(); } return $user; }