Exemplo n.º 1
0
 /**
  * 系统运行
  */
 public static function run()
 {
     self::init();
     load_class('core_uri')->set_rewrite();
     // 传入应用目录, 返回控制器对象
     $handle_controller = self::create_controller(load_class('core_uri')->controller, load_class('core_uri')->app_dir);
     $action_method = load_class('core_uri')->action . '_action';
     // 判断
     if (!is_object($handle_controller) or !method_exists($handle_controller, $action_method)) {
         HTTP::error_404();
     }
     if (method_exists($handle_controller, 'get_access_rule')) {
         $access_rule = $handle_controller->get_access_rule();
     }
     // 判断访问规则使用白名单还是黑名单, 默认使用黑名单
     if ($access_rule) {
         // 黑名单, 黑名单中的检查 'white' 白名单,白名单以外的检查 (默认是黑名单检查)
         if (isset($access_rule['rule_type']) and $access_rule['rule_type'] == 'white') {
             if (!$access_rule['actions'] or !in_array(load_class('core_uri')->action, $access_rule['actions'])) {
                 self::login();
             }
         } else {
             if (isset($access_rule['actions']) and in_array(load_class('core_uri')->action, $access_rule['actions'])) {
                 self::login();
             }
         }
     } else {
         self::login();
     }
     // 执行
     if (!$_GET['id'] and method_exists($handle_controller, load_class('core_uri')->action . '_square_action')) {
         $action_method = load_class('core_uri')->action . '_square_action';
     }
     $handle_controller->{$action_method}();
 }
Exemplo n.º 2
0
 public function index_action()
 {
     if (!($page_info = $this->model('page')->get_page_by_url_token($_GET['id'])) or $page_info['enabled'] == 0) {
         HTTP::error_404();
     }
     if ($page_info['title']) {
         TPL::assign('page_title', $page_info['title']);
     }
     if ($page_info['keywords']) {
         TPL::set_meta('keywords', $page_info['keywords']);
     }
     if ($page_info['description']) {
         TPL::set_meta('description', $page_info['description']);
     }
     TPL::assign('page_info', $page_info);
     TPL::output('page/index');
 }