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


PHP Factory::getAuth方法代码示例

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


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

示例1: Application

 /**
 	Get core application class
 		@public
 	**/
 static function &getApplication()
 {
     static $app;
     // create if don't exists
     if (!is_object($app)) {
         // single app instance only
         if (isset($GLOBALS['_globalapp'])) {
             $app = $GLOBALS['_globalapp'];
         } else {
             $app = new Application();
             // config
             $config =& Factory::getConfig();
             $app->set('config', $config);
             // authentication
             $auth =& Factory::getAuth();
             $app->set('auth', $auth);
             // set our timezone
             if (isset($config->timezone)) {
                 @(list($tz_script, $tz_db) = explode('|', $config->timezone));
                 date_default_timezone_set($tz_script);
             }
             $GLOBALS['_globalapp'] = $app;
         }
     }
     return $app;
 }
开发者ID:rudenyl,项目名称:kcms,代码行数:30,代码来源:framework.php

示例2: write

 /**
 	Save session data
 		@param $save_path string
 		@param $sess_name string
 		@abstract
 	**/
 function write($sess_id, $sess_data)
 {
     $auth =& Factory::getAuth();
     // update expiry
     $expiry = time() + $this->__maxlife;
     // check if exists
     $sql = "SELECT count(*) as found" . "\n FROM {TABLE_PREFIX}_session" . "\n WHERE `sess_id` = " . $this->__db->Quote($sess_id);
     $this->__db->query($sql);
     $found = (int) $this->__db->result();
     if ($found) {
         // update
         $sql = "UPDATE {TABLE_PREFIX}_session" . "\n SET `sess_expires` = " . $this->__db->Quote($expiry) . "\n ,`user_id` = " . $this->__db->Quote($auth->id) . "\n ,`sess_data` = " . $this->__db->Quote($sess_data) . "\n WHERE `sess_id` = " . $this->__db->Quote($sess_id);
     } else {
         $data = array('sess_expires' => $expiry, 'user_id' => $auth->id, 'sess_data' => $sess_data, 'sess_id' => $sess_id);
         $values = array();
         foreach ($data as $k => &$v) {
             $k = $this->__db->NameQuote($k);
             $values[$k] = $this->__db->Quote($v);
         }
         $keys = implode(',', array_keys($values));
         $values = implode(',', array_values($values));
         // add
         $sql = "INSERT INTO {TABLE_PREFIX}_session({$keys})" . "\n VALUES({$values})";
     }
     // commit
     $this->__db->query($sql);
     // get affected rows
     $result = $this->__db->affected_rows();
     return $result;
 }
开发者ID:rudenyl,项目名称:kcms,代码行数:36,代码来源:sessiondbhandler.class.php

示例3: hasPermission

 /**
 	Check if currently-logged user has permission
 		@param $task string
 		@public
 	**/
 function hasPermission($task)
 {
     // get logged in user
     $auth =& Factory::getAuth();
     if ($auth->level == 'admin') {
         return true;
         // always
     }
     if (isset($this->_perms['user'][$task][$auth->id])) {
         return $this->_perms['user'][$task][$auth->id];
     } else {
         if (isset($this->_perms['role'][$task][$auth->level])) {
             return $this->_perms['role'][$task][$auth->level];
         }
     }
     return false;
 }
开发者ID:rudenyl,项目名称:kcms,代码行数:22,代码来源:acl.class.php

示例4: render

 /**
 	Render module
 		@param $module object
 		@public
 	**/
 static function render($module, $custom = true)
 {
     $auth =& Factory::getAuth();
     $config =& Factory::getConfig();
     $html = '';
     if (isset($module->access) && ($module->access && !$auth->loggedIn())) {
         // no access
         return $html;
     }
     if ($custom) {
         if ($module->id) {
             // get layout from current template
             $tpl_path = PATH_TEMPLATES . DS . $config->template . DS . 'module.php';
             if (is_file($tpl_path)) {
                 // set params
                 $params = isset($module->params) ? $module->params : '';
                 $params = new Parameter($params);
                 ob_start();
                 require $tpl_path;
                 $html = ob_get_clean();
             } else {
                 // translate
                 self::__translate($module);
                 // just return the data
                 $html = $module->data;
                 // convert to SEF
                 self::__getSEFURL($html);
             }
         }
     } else {
         $module_path = BASE_PATH . DS . 'templates' . DS . $config->template . DS . 'modules' . DS . @$module->name . DS . @$module->name . '.php';
         // check admin
         $base_path = str_replace(DS . 'applications', '', PATH_APPLICATIONS);
         $base_path = str_replace(BASE_PATH, '', $base_path);
         $base_path = str_replace(DS, '/', $base_path);
         if ($base_path == $config->admin_path) {
             $module_path = null;
         }
         if (!is_file($module_path)) {
             $module_path = PATH_MODULES . DS . $module->name . DS . $module->name . '.php';
         }
         if (is_file($module_path)) {
             ob_start();
             // load module
             include $module_path;
             $html = ob_get_clean();
         }
     }
     return $html;
 }
开发者ID:rudenyl,项目名称:kcms,代码行数:55,代码来源:modulehelper.class.php


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