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;
    }
    
  • 相关阅读:
    uniapp 请求附近地址列表
    uniapp 图片视频上传
    城市定位
    日历签到
    uniapp拼团倒计时函数
    时间过滤器
    倒计时函数
    vuex的使用
    毛玻璃效果
    Pullword 中文分词
  • 原文地址:https://www.cnblogs.com/jiqing9006/p/11268345.html
Copyright © 2011-2022 走看看