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


PHP role::is_root方法代碼示例

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


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

示例1: is_allowed

 public static function is_allowed($permission = 'default', $site_id = 0, $type = NULL)
 {
     $verify = true;
     $site_ids = role::get_site_ids($type);
     //超級管理員root不需要檢查權限 zhu modify
     if (role::is_root()) {
         $verify = true;
     } else {
         if ($site_id > 0 && !in_array($site_id, $site_ids)) {
             $verify = false;
         }
         $acl = Session::instance()->get(self::$acl_tag);
         if ($acl) {
             $acl = unserialize($acl);
         } else {
             $acl = self::acl_init();
         }
         $manager = role::get_manager();
         $verify = $acl->is_allowed($manager["username"], $permission);
     }
     //驗證操作
     if ($verify) {
         return $site_ids;
     } else {
         if (request::is_ajax()) {
             $return_struct = array('status' => 0, 'code' => 501, 'msg' => Kohana::lang('o_global.access_denied'), 'content' => array());
             die(json_encode($return_struct));
         } else {
             $referrer = tool::referrer_url();
             remind::set('權限不足', $referrer, 'error');
         }
     }
 }
開發者ID:RenzcPHP,項目名稱:3dproduct,代碼行數:33,代碼來源:acltool.php

示例2: index

 function index()
 {
     //判斷用戶是否是已經登錄狀態
     $data = role::get_manager();
     if ($data['id'] > 0) {
         $data['success'] = 'true';
         $data['msg'] = 1;
     } else {
         $data['success'] = 'false';
         $data['msg'] = 1;
     }
     $username = $this->input->post('username');
     $password = $this->input->post('password');
     $secode = $this->input->post('secode');
     $remember = $this->input->post('remember');
     $data['success'] = 'false';
     //驗證登錄
     $manager = role::log_in($username, $password);
     if (isset($manager['username'])) {
         //判斷普通賬號的狀態、權限
         if (!role::is_root($manager['username'])) {
             if ($manager['active'] != 1) {
                 ulog::login($manager['id'], 1);
                 $data['msg'] = Kohana::lang('o_global.account_was_locked');
             }
             $actions = role::manager_actions($manager['id'], TRUE);
             if (count($actions) < 1) {
                 ulog::login($manager['id'], 2);
                 $data['msg'] = Kohana::lang('o_global.account_permission_enough');
             }
         }
         //是否記錄用戶名
         if ($remember == 1) {
             cookie::set('opococ_username', $username);
         } else {
             cookie::delete('opococ_username');
         }
         //清除記錄登錄錯誤記錄
         //Session::instance()->delete('login_error_count');
         //記入SESSION
         role::set_manager_session($manager);
         //記錄日誌
         ulog::login($manager['id']);
         $data['success'] = 'true';
         $data['msg'] = 1;
         /*if(empty($request_url))
         		{
         			remind::set(Kohana::lang('o_global.login_success'), '/index', 'success');
         		}
                    else
                    {
         			$request_url = url::base() . urldecode($request_url);
         			remind::set(Kohana::lang('o_global.login_success'), $request_url, 'success');
         		}*/
     }
     die(json_encode($data));
 }
開發者ID:RenzcPHP,項目名稱:3dproduct,代碼行數:57,代碼來源:user_login.php

示例3: __construct

 public function __construct()
 {
     parent::__construct();
     //zhu modify 隻允許root執行
     //$this->site_ids = role::check('manage_role');
     if (!role::is_root()) {
         remind::set(Kohana::lang('o_manage.only_root_do'), 'manage/manager');
     }
 }
開發者ID:RenzcPHP,項目名稱:3dproduct,代碼行數:9,代碼來源:role.php

示例4: __construct

 /**
  * Template loading and setup routine.
  */
 public function __construct()
 {
     parent::__construct();
     // checke request is ajax
     $this->ajax_request = request::is_ajax();
     // Load the template
     $this->template = new View($this->template);
     if ($this->auto_render == TRUE) {
         Event::add('system.post_controller', array($this, '_render'));
     }
     /**
      * 判斷用戶登錄情況
      */
     if (isset($_REQUEST['session_id'])) {
         $session = Session::instance($_REQUEST['session_id']);
         $manager = role::get_manager($_REQUEST['session_id']);
     } else {
         $session = Session::instance();
         $manager = role::get_manager();
     }
     /* 當前請求的URL */
     $current_url = urlencode(url::current(TRUE));
     //zhu
     if (isset($manager['id'])) {
         $active_time = $session->get('Opococ_manager_active_time');
         //用戶最後操作時間
         $session->set('Opococ_manager_active_time', time());
         //用戶最後操作時間
         $login_ip = $session->get('Opococ_manager_login_ip');
         //用戶登錄的IP
         //操作超時
         if (time() - $active_time > Kohana::config('login.time_out')) {
             $session->delete('Opococ_manager');
             $session->delete('Opococ_manager_active_time');
             $session->delete('Opococ_manager_login_ip');
             remind::set(Kohana::lang('o_global.first_login'), 'login?request_url=' . $current_url);
         }
         //用戶IP(登錄狀態更換IP需要重新登錄)
         $ip = tool::get_long_ip();
         if ($ip != $login_ip) {
             remind::set(Kohana::lang('o_global.login_again'), 'login?request_url=' . $current_url);
         }
         $this->manager = $manager;
         $this->manager_id = $manager['id'];
         $this->manager_name = $manager['name'];
         $this->manager_is_admin = role::is_root($manager['name']) ? 1 : $manager['is_admin'];
         $this->template->manager_data = $manager;
     } else {
         remind::set(Kohana::lang('o_global.first_login'), 'login?request_url=' . $current_url);
     }
 }
開發者ID:RenzcPHP,項目名稱:3dproduct,代碼行數:54,代碼來源:template.php

示例5: verify

 /**
  * 驗證是否有權限操作
  * @param string $model_flag
  * @return Boolean
  */
 public static function verify($permission = 'default')
 {
     $verify = false;
     //超級管理員root不需要檢查權限 zhu modify
     if (role::is_root()) {
         $verify = true;
     } else {
         $acl = Session::instance()->get(self::$acl_tag);
         if ($acl) {
             $acl = unserialize($acl);
         } else {
             $acl = self::acl_init();
         }
         $manager = self::get_manager();
         //d($manager, false);
         $verify = $acl->is_allowed($manager["username"], $permission);
     }
     //var_dump($verify);
     return $verify;
 }
開發者ID:RenzcPHP,項目名稱:3dproduct,代碼行數:25,代碼來源:role.php

示例6: delete

 /**
  * delete manager
  */
 public function delete($id)
 {
     role::check('delete_manager');
     //zhu add
     $this->_check_manager($id);
     /*if($id == $this->manager_id)
     		{
     			remind::set(Kohana::lang('o_manage.self_account_not_do'),'manage/manager');
     		}*/
     //不能刪除root
     $manager = Mymanager::instance($id)->get();
     if (role::is_root($manager['username'])) {
         remind::set(Kohana::lang('o_global.access_root_denied'), 'manage/manager');
     }
     if (Mymanager::instance($id)->delete()) {
         remind::set(Kohana::lang('o_global.delete_success'), 'manage/manager', 'success');
     } else {
         remind::set(Kohana::lang('o_global.delete_error'), 'manage/manager');
     }
 }
開發者ID:RenzcPHP,項目名稱:3dproduct,代碼行數:23,代碼來源:manager.php

示例7: index

 /**
  * log in
  */
 function index()
 {
     $this->logout(FALSE);
     /* 原請求頁麵 */
     $request_url = $this->input->get('request_url');
     //用戶名和密碼輸入錯誤三次後就需要輸入驗證碼
     $login_error_count = Session::instance()->get('login_error_count');
     if (!$login_error_count) {
         $login_error_count = 1;
         Session::instance()->set('login_error_count', $login_error_count);
     }
     //判斷用戶是否是已經登錄狀態
     $data = role::get_manager();
     //D($data);
     if ($data['id'] > 0) {
         remind::set(Kohana::lang('o_global.current_status_login'), '/', 'success');
     }
     //驗證碼KEY
     secoder::$seKey = 'opococ.secoder';
     //錯誤信息
     $message = remind::get_message();
     if (empty($message)) {
         $error_display = "none";
         $error = "";
     } else {
         $error_display = "";
         $error = $message;
     }
     //登錄
     if ($_POST) {
         $username = $this->input->post('username');
         $password = $this->input->post('password');
         $secode = $this->input->post('secode');
         $remember = $this->input->post('remember');
         //驗證驗證碼
         if ($login_error_count > 3 && !secoder::check($secode)) {
             remind::set(Kohana::lang('o_global.code_input_error'), 'login');
         }
         //驗證登錄
         $manager = role::log_in($username, $password);
         if (isset($manager['username'])) {
             //判斷普通賬號的狀態、權限
             if (!role::is_root($manager['username'])) {
                 if ($manager['active'] != 1) {
                     ulog::login($manager['id'], 1);
                     remind::set(Kohana::lang('o_global.account_was_locked'), 'login');
                 }
                 $actions = role::manager_actions($manager['id'], TRUE);
                 if (count($actions) < 1) {
                     ulog::login($manager['id'], 2);
                     remind::set(Kohana::lang('o_global.account_permission_enough'), 'login');
                 }
             }
             /* 是否記錄用戶名 */
             if ($remember == 1) {
                 cookie::set('opococ_username', $username);
             } else {
                 cookie::delete('opococ_username');
             }
             //清除記錄登錄錯誤記錄
             Session::instance()->delete('login_error_count');
             //記入SESSION
             role::set_manager_session($manager);
             //記錄日誌
             ulog::login($manager['id']);
             if (empty($request_url)) {
                 remind::set(Kohana::lang('o_global.login_success'), '/index', 'success');
             } else {
                 $request_url = url::base() . urldecode($request_url);
                 remind::set(Kohana::lang('o_global.login_success'), $request_url, 'success');
             }
         } else {
             ulog::login();
             $login_error_count++;
             Session::instance()->set('login_error_count', $login_error_count);
             remind::set(Kohana::lang('o_global.user_and_password_error'), 'login');
         }
     }
     /* 瀏覽器記錄的用戶名 */
     $username = cookie::get('opococ_username');
     $this->template = new View('login');
     $this->template->login_error_count = $login_error_count;
     $this->template->error = $error;
     $this->template->error_display = $error_display;
     $this->template->username = $username;
     $this->template->render(TRUE);
 }
開發者ID:RenzcPHP,項目名稱:3dproduct,代碼行數:90,代碼來源:login.php


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