<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');
/*
 * 访问权限管理
 */

class Permission {

    var $CI;

    public function __construct() {
        $this->CI = & get_instance();
    }

    function is_admin($auto_redirect = true) 
    {
        $referer_url='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
        $this->CI->session->set_userdata('login_referer', $referer_url);
        if ($this->CI->session->userdata('admin_chtcdn') === FALSE) {
            if ($auto_redirect) 
            {
                redirect(site_url('login/index'));
            } 
            else 
            {
                return false;
            }
        } 
        else 
        {
            return true;
        }
    }

}
