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;
        }
    }
  • 相关阅读:
    Python之旅.第十章.mysql..
    Python之旅.第十章.mysql.
    Python之旅.第十章.mysql.
    Python之旅.第十章.mysql。
    Mac 移动光标和删除
    网络编程——socket开发
    闭包(closure)
    命名空间 and 作用域
    Function
    for循环的禁忌
  • 原文地址:https://www.cnblogs.com/xiondun/p/12509064.html
Copyright © 2011-2022 走看看