zoukankan      html  css  js  c++  java
  • 无敌的路由分发

    private function _get_path_info()
    {
        $c_path_info = (string)$_SERVER['PATH_INFO'];       //找出当前的url
        $first_char  = substr($c_path_info, 0, 1);
        if ($first_char !== '/') {
            $c_path_info = '/' . $c_path_info;
        }
        if (!$c_path_info) {
            $c_path_info = '/';
        }
        if ($c_path_info === '/Index/index' || $c_path_info === '/Index' || $c_path_info === '/Index/') {
            $c_path_info = '/';
        }
        if ($c_path_info !== '/') {
            $c_path_info_arr = explode('/', $c_path_info);
            if (!$c_path_info_arr[2]) {
                $c_path_info = rtrim($c_path_info, '/');
                $c_path_info .= '/index';
            }
        }
    
        // 无敌的跳转
        if ((int)$_SESSION['_admin_super'] !== 1) {
            if ($c_path_info === '/') {
                // 判断是否有权限
                $role_powers       = explode('-', $_SESSION['_admin_power']);
                $action            = M('action');
                $first_action_info = $action->where(['id' => ['in', $role_powers], 'level' => 2])->find();
                $c_path_info       = $first_action_info['urls'];
                if ($c_path_info !== '/') {
                    $this->redirect($c_path_info);
                }
            } else {
                // 查询
                $action      = M('action');
                $action_info = $action->where(['urls' => $c_path_info, 'level' => 2])->find();
                $role_powers = explode('-', $_SESSION['_admin_power']);
                if ($action_info && !in_array($action_info['id'], $role_powers, false)) {
                    $current_action_info = $action->where(['id' => ['in', $role_powers], 'level' => 2, 'pid' => $action_info['pid']])->find();
                    $c_path_info         = $current_action_info['urls'];
                    if ($c_path_info !== '/') {
                        $this->redirect($c_path_info);
                    }
                }
            }
        }
        
        return $c_path_info;
    }
    
  • 相关阅读:
    各种插件
    如何在C#中选择正确的集合 转
    转载 hashtable和dictionary的区别
    堆和栈的区别 转载
    数据结构王道错题集2019版(上>一>四章)
    mongoDB连接数据库
    linuix没有网络
    rand函数
    mongodb学习(入门。。。。。)
    先随便写
  • 原文地址:https://www.cnblogs.com/jiqing9006/p/11268345.html
Copyright © 2011-2022 走看看