From f1b6765b8877d83607a9b0fc28ccdf877067aca3 Mon Sep 17 00:00:00 2001 From: wangchunsheng Date: Fri, 12 Nov 2010 05:31:01 +0000 Subject: [PATCH] * rewrite the common module. --- module/common/control.php | 278 +++++++---------------------- module/common/model.php | 255 ++++++++++++++++++++++++++ module/common/view/footer.html.php | 2 +- module/common/view/header.html.php | 6 +- 4 files changed, 320 insertions(+), 221 deletions(-) diff --git a/module/common/control.php b/module/common/control.php index 106f7cbb06..2820415912 100644 --- a/module/common/control.php +++ b/module/common/control.php @@ -27,7 +27,7 @@ class common extends control } /** - * 检查用户对当前的请求有没有权限。如果没有权限,则跳转到登陆界面。 + * Check the user has permission to access this method, if not, locate to the login page or deny page. * * @access public * @return void @@ -36,242 +36,57 @@ class common extends control { $module = $this->app->getModuleName(); $method = $this->app->getMethodName(); - if($module == 'user') - { - if($method == 'login' or $method == 'logout' or $method == 'deny') return true; - } - elseif($module == 'api' and $method == 'getsessionid') - { - return true; - } - elseif($module == 'misc' and $method == 'about') - { - return true; - } + if($this->common->isOpenMethod($module, $method)) return true; + if(isset($this->app->user) and $this->app->user->account == 'guest' and $this->server->php_auth_user) $this->common->identifyPhpAuth(); if(isset($this->app->user)) { - if(!common::hasPriv($module, $method)) - { - $vars = "module=$module&method=$method"; - if(isset($_SERVER['HTTP_REFERER'])) - { - $referer = helper::safe64Encode($_SERVER['HTTP_REFERER']); - $vars .= "&referer=$referer"; - } - $denyLink = $this->createLink('user', 'deny', $vars); - - /* Fix the bug of IE: use js locate, can't get the referer. */ - if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) - { - echo <<