zoukankan      html  css  js  c++  java
  • php权限

    function authority($auth)
    {
        // pre($_SESSION);
        // pre(Session::get('role'));
        // $role_arr=explode(',', $_SESSION['role']);
        $role_arr = Session::get('role');
        if (!in_array($auth, $role_arr)) {
            if (!in_array('超级管理员', $role_arr)) {
                echo '<h2>没有权限!!你需要【' . $auth. '】的权限</h2>';
                die;
            }
        }
    }

    /**
     * 权限认证函数,传字符传,一次认证一个权限
     */
    function authority_view($quanxian)
    {
        // p($_SESSION);die;
        // $role_arr=explode(',', $_SESSION['role']);
        $role_arr = Session::get('role') == null ? $this->redirect('login/index') : Session::get('role');

        if (!in_array($quanxian, $role_arr)) {
            if (in_array('超级管理员', $role_arr)) {
                // echo '<h2>没有权限!!你需要【'.$quanxian.'】的权限</h2>';
                return true;
            } else {
                return false;
            }
        } else {
            return true;
        }
    }
  • 相关阅读:
    Net
    GUI
    第三方模块
    步入大四的第一天 2020/9/3
    期末复习计划及每日更新 8/10-9/2
    成都,come back 2020/8/10
    回家第三天 2020/7/31
    连续两天的好太阳的一天 2020/7/27
    规划规划,接下来的一个月该如何安排 7/25
    紧紧张张又兴兴奋奋的一天 2020/7/24
  • 原文地址:https://www.cnblogs.com/xiondun/p/12509064.html
Copyright © 2011-2022 走看看