当前位置: 首页>>代码示例>>PHP>>正文


PHP Base::getSession方法代码示例

本文整理汇总了PHP中Base::getSession方法的典型用法代码示例。如果您正苦于以下问题:PHP Base::getSession方法的具体用法?PHP Base::getSession怎么用?PHP Base::getSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Base的用法示例。


在下文中一共展示了Base::getSession方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: logout

 function logout()
 {
     $session = Base::getSession();
     $referer = $session->get('_referer');
     $result = $session->restart();
     $session->set('_referer', $referer);
     self::set_public_user();
     return $result;
 }
开发者ID:ejailesb,项目名称:repo_empr,代码行数:9,代码来源:authenticate.php

示例2: getSystemMessages

 public static function getSystemMessages()
 {
     $session = Base::getSession();
     $types = $session->getFlash();
     return \GCore\Helpers\Message::render($types);
 }
开发者ID:vstorm83,项目名称:propertease,代码行数:6,代码来源:app_j.php

示例3: authorized

 public static function authorized($path, $action = 'access', $owner_id = null, $user_id = null)
 {
     $user = Base::getUser();
     //owner admin access
     if ((int) $user['id'] === 1) {
         return true;
     }
     //login/logout can be always accessed
     if (($path == '\\GCore\\Admin\\Controllers\\Users' or $path == '\\GCore\\Controllers\\Users') and ($action == 'login' or $action == 'logout')) {
         return true;
     }
     $groups = Authenticate::get_user_groups($user_id);
     if (!empty($owner_id) and $owner_id == $user['id']) {
         $groups[] = 'owner';
     }
     $return = false;
     //build search branches based on current loaded class
     if (is_array($path)) {
         $tests = $path;
     } else {
         $branches = explode("\\", $path);
         $tests = array();
         for ($i = 0; $i = count($branches) - 1; $i++) {
             $tests[] = implode("\\", $branches);
             array_pop($branches);
         }
     }
     //check cache
     $cache = (bool) Base::getConfig('cache_permissions');
     if ($cache === true) {
         $session = Base::getSession();
         $cached_permissions = $session->get('acos_permissions.' . $user['id'], array());
         if (in_array('owner', $groups)) {
             $cache_key = md5(serialize($tests) . $action . $owner_id);
         } else {
             $cache_key = md5(serialize($tests) . $action);
         }
         if (array_key_exists($cache_key, $cached_permissions)) {
             $return = $cached_permissions[$cache_key];
             goto end;
         }
     }
     $paths_key = md5(serialize($tests));
     if (!isset(self::$lookups[$paths_key])) {
         $Acl_model = new \GCore\Admin\Models\Acl();
         $acls = $Acl_model->find('all', array('conditions' => array('aco' => $tests, 'enabled' => 1), 'order' => array('aco DESC')));
         self::$lookups[$paths_key] = $acls;
     } else {
         $acls = self::$lookups[$paths_key];
     }
     if (empty($acls)) {
         //no ACL results found matching this ACO
         $return = false;
         goto end;
     }
     foreach ($acls as $k => $acl) {
         $p_action = $action;
         if (!empty($acl['Acl']['rules'][$p_action])) {
             //main action rules found, goto permissions check
         } elseif (!empty($acl['Acl']['rules']['access'])) {
             //main action not found, but access action found, let's use it
             $p_action = 'access';
         } else {
             //neither the main action nor the default one found under this path, or maybe no permissions set, go to the next one.
             continue;
         }
         //check groups action's rules
         $result = self::check_rules($acl['Acl']['rules'][$p_action], $groups);
         if (!is_null($result)) {
             $return = $result;
             goto end;
         }
         //looks like all permissions in this path are not set or inheriting, go to next path
         continue;
     }
     //we looped all pathes with no matches, return denied
     $return = false;
     end:
     //store into cache
     if ($cache === true) {
         $session = Base::getSession();
         $cached_permissions = $session->get('acos_permissions.' . $user['id'], array());
         if (in_array('owner', $groups)) {
             $cache_key = md5(serialize($tests) . $action . $owner_id);
         } else {
             $cache_key = md5(serialize($tests) . $action);
         }
         $cached_permissions[$cache_key] = $return;
         $session->set('acos_permissions.' . $user['id'], $cached_permissions);
     } else {
         $session = Base::getSession();
         $session->set('acos_permissions.' . $user['id'], array());
     }
     return $return;
 }
开发者ID:ejailesb,项目名称:repo_empr,代码行数:95,代码来源:authorize.php

示例4: _paginate

 function _paginate()
 {
     $model_class = !empty($this->paginate_model) ? $this->paginate_model : null;
     if (empty($model_class)) {
         $alias = $this->get_main_model();
         if (!empty($alias)) {
             $model_class = $this->{$alias};
         } else {
             return;
         }
     }
     $prefix = '';
     if (!empty($this->paginate_prefix)) {
         $prefix = '.' . $this->paginate_prefix;
     }
     //check if we should process pagination
     if (!empty($model_class) and in_array('\\GCore\\Helpers\\Paginator', $this->helpers) or in_array('\\GCore\\Helpers\\Paginator', array_keys($this->helpers))) {
         $session = Base::getSession();
         $k = array_search('\\GCore\\Helpers\\Paginator', $this->helpers);
         if ($k !== false) {
             unset($this->helpers[$k]);
         }
         $page = Request::data(\GCore\Libs\Base::getConfig('page_url_param_name', 'page'), $session->get(get_class($this) . $prefix . '.' . $model_class->alias . '.page', 1));
         $page = $page < 1 ? 1 : $page;
         $active_limit = !empty($model_class->page_limit) ? $model_class->page_limit : Base::getConfig('list_limit', 30);
         $limit = Request::data('limit', $session->get(get_class($this) . $prefix . '.' . $model_class->alias . '.limit', $active_limit));
         if ($limit == 0 or $limit > Base::getConfig('max_list_limit', 1000)) {
             $limit = Base::getConfig('max_list_limit', 1000);
         }
         if (!empty($model_class->limit)) {
             $limit = $model_class->limit;
         }
         if (!empty($model_class->page)) {
             $page = $model_class->page;
         }
         $offset = ($page - 1) * (int) $limit;
         $total = !empty($this->paginate_total) ? $this->paginate_total : $model_class->find('count', array('cache' => true));
         $bad_page = false;
         if ($offset >= $total) {
             //$page = ceil($total/$limit);
             $bad_page = true;
             $page = ceil($total / $limit);
             $offset = $limit * ($page - 1);
         }
         $page = $page < 1 ? 1 : $page;
         $offset = $offset < 0 ? 0 : $offset;
         $this->helpers['\\GCore\\Helpers\\Paginator']['limit'] = $limit;
         $this->helpers['\\GCore\\Helpers\\Paginator']['page'] = $page;
         $this->helpers['\\GCore\\Helpers\\Paginator']['offset'] = $offset;
         $this->helpers['\\GCore\\Helpers\\Paginator']['page_param'] = \GCore\Libs\Base::getConfig('page_url_param_name', 'page');
         if (!$bad_page) {
             $session->set(get_class($this) . $prefix . '.' . $model_class->alias . '.page', $page);
         }
         $session->set(get_class($this) . $prefix . '.' . $model_class->alias . '.limit', $limit);
         $this->helpers['\\GCore\\Helpers\\Paginator']['total'] = $total;
         //page (limit and offset) should be set after the count query
         $model_class->page = $page;
         $model_class->page_limit = $limit;
     }
 }
开发者ID:ejailesb,项目名称:repo_empr,代码行数:60,代码来源:gcontroller.php

示例5: send

 public static function send($to = array(), $subject = '', $body = '', $attachments = array(), $other = array())
 {
     if (!class_exists('PHPMailer')) {
         require_once \GCore\C::get('GCORE_FRONT_PATH') . 'vendors' . DS . 'phpmailer' . DS . 'PHPMailerAutoload.php';
     }
     $mail = new \PHPMailer();
     $mail->CharSet = 'utf-8';
     //get recipients
     foreach ((array) $to as $address) {
         $mail->AddAddress(trim($address));
     }
     //subject
     $mail->Subject = $subject;
     //reply to
     $reply_name = !empty($other['reply_name']) ? $other['reply_name'] : Base::getConfig('mail_reply_name');
     $reply_email = !empty($other['reply_email']) ? $other['reply_email'] : Base::getConfig('mail_reply_email');
     if (!empty($reply_name) and !empty($reply_email)) {
         $mail->AddReplyTo($reply_email, $reply_name);
     }
     //from
     $from_name = !empty($other['from_name']) ? $other['from_name'] : Base::getConfig('mail_from_name');
     $from_email = !empty($other['from_email']) ? $other['from_email'] : Base::getConfig('mail_from_email');
     $mail->SetFrom($from_email, $from_name);
     //set custom headers
     if (!empty($other['custom'])) {
         foreach ($other['custom'] as $k => $v) {
             $mail->addCustomHeader($k . ': ' . $v);
         }
     }
     //set CC and BCC
     if (!empty($other['cc'])) {
         foreach ($other['cc'] as $k => $cc) {
             $mail->AddCC($cc);
         }
     }
     if (!empty($other['bcc'])) {
         foreach ($other['bcc'] as $k => $bcc) {
             $mail->AddBCC($bcc);
         }
     }
     if ((bool) Base::getConfig('smtp', 0) === true or Base::getConfig('mail_method', 'phpmail') == 'smtp') {
         $mail->IsSMTP();
         if (Base::getConfig('smtp_username') and Base::getConfig('smtp_password')) {
             $mail->SMTPAuth = true;
         }
         if (Base::getConfig('smtp_secure')) {
             $mail->SMTPSecure = Base::getConfig('smtp_secure');
         }
         $mail->Host = Base::getConfig('smtp_host');
         $mail->Port = Base::getConfig('smtp_port');
         $mail->Username = Base::getConfig('smtp_username');
         $mail->Password = Base::getConfig('smtp_password');
     } else {
         if (Base::getConfig('mail_method', 'phpmail') == 'sendmail') {
             $mail->IsSendmail();
         }
     }
     if (!isset($other['type']) or $other['type'] == 'html') {
         $mail->AltBody = strip_tags($body);
         //'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
         //$body = nl2br($body);
         //$mail->MsgHTML($body);
         $mail->Body = $body;
         $mail->IsHTML(true);
     } else {
         $mail->Body = $body;
         $mail->IsHTML(false);
     }
     $mail->SMTPDebug = (int) Base::getConfig('smtp_debug', 0);
     //attachments
     foreach ((array) $attachments as $attachment) {
         if (is_array($attachment) and !empty($attachment['path'])) {
             $attachment = array_merge(array('name' => basename($attachment['path']), 'type' => 'application/octet-stream', 'encoding' => 'base64'), $attachment);
             $mail->AddAttachment($attachment['path'], $attachment['name'], $attachment['encoding'], $attachment['type']);
         } else {
             $mail->AddAttachment($attachment);
         }
     }
     if (!$mail->Send()) {
         $session = Base::getSession();
         $session->setFlash('warning', 'Mailer Error: ' . $mail->ErrorInfo);
         return false;
     }
     return true;
 }
开发者ID:ejailesb,项目名称:repo_empr,代码行数:85,代码来源:mailer.php

示例6: dispatch

 function dispatch($content_only = false, $check_perm = true)
 {
     Event::trigger('on_before_dispatch', $this);
     $session = Base::getSession();
     reset:
     //if no action set, set it to index
     if (strlen(trim($this->action)) == 0) {
         $this->action = 'index';
     }
     //set admin path
     $site = '';
     if ($this->site == 'admin') {
         $site = '\\Admin';
     }
     //load the extension class
     $controller = !empty($this->controller) ? '\\Controllers\\' . Str::camilize($this->controller) : '\\' . Str::camilize($this->extension);
     $extension = !empty($this->extension) ? '\\Extensions\\' . Str::camilize($this->extension) : '';
     $classname = '\\GCore' . $site . $extension . $controller;
     $this->tvout = strlen(Request::data('tvout', null)) > 0 ? Request::data('tvout') : $this->tvout;
     //set referer
     if (!$content_only) {
         if (!($this->controller == 'users' and ($this->action == 'login' or $this->action == 'logout' or $this->action == 'register')) and (!empty($this->extension) or !empty($this->controller)) and $this->tvout == 'index') {
             $session->set('_referer', Url::current());
         } else {
             //$session->set('_referer', 'index.php');
         }
     }
     //check permissions
     if ($check_perm and !Authorize::authorized($classname, $this->action)) {
         if ($content_only) {
             return;
         }
         $this->redirect(r_('index.php?cont=users&act=login'));
     }
     //if the extension class not found or the action function not found then load an error
     if (!class_exists($classname) or !in_array($this->action, get_class_methods($classname)) and !in_array('__call', get_class_methods($classname)) or substr($this->action, 0, 1) == '_') {
         $this->controller = 'errors';
         $this->action = 'e404';
         //reset the controller
         $classname = '\\GCore\\Controllers\\Errors';
         \GCore\Libs\Env::e404();
         //we need the rendered content only
         if ($content_only) {
             return;
         }
     }
     //load language file
     if (!empty($extension)) {
         Lang::load($site . $extension);
     }
     //set theme
     $doc = Document::getInstance($this->site, $this->thread);
     $doc->theme = 'bootstrap3';
     //'gcoreui';//'semantic1';
     $theme = \GCore\Helpers\Theme::getInstance();
     // in gcore app, bootstrap should be always loaded first with jquery
     //load class and run the action
     ${$classname} = new $classname($this->site, $this->thread);
     ob_start();
     $continue = ${$classname}->_initialize();
     //check and read cache
     if (!empty(${$classname}->cache)) {
         if (!is_array(${$classname}->cache)) {
             ${$classname}->cache = array();
         }
         if (empty(${$classname}->cache['time'])) {
             ${$classname}->cache['time'] = Base::getConfig('app_cache_expiry', 900);
         }
         if (empty(${$classname}->cache['title'])) {
             ${$classname}->cache['title'] = File::makeSafe($classname . '_' . $this->action);
         } else {
             ${$classname}->cache['title'] = File::makeSafe(${$classname}->cache['title']);
         }
         if (empty(${$classname}->cache['key'])) {
             ${$classname}->cache['key'] = 'cached_view';
         } else {
             ${$classname}->cache['key'] = 'cached_view_' . ${$classname}->cache['key'];
         }
         $cache = Cache::getInstance(${$classname}->cache['title'], array('expiration' => ${$classname}->cache['time']));
         $cached_view = $cache->get(${$classname}->cache['key']);
         $cached = false;
         if (!empty($cached_view)) {
             $cached = true;
             $continue = false;
             echo $cached_view;
         }
     }
     if ($continue !== false) {
         ${$classname}->{$this->action}();
         if ($this->reset === true) {
             $this->reset = false;
             goto reset;
         }
         //initialize and render view
         $view = new View();
         $view->initialize(${$classname});
         $view->renderView($this->action);
     }
     //get the action output buffer
     $this->buffer = ob_get_clean();
//.........这里部分代码省略.........
开发者ID:ejailesb,项目名称:repo_empr,代码行数:101,代码来源:app.php


注:本文中的Base::getSession方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。