权限校验部分
新建CommonAction类文件,写入以下代码<?php <br />
class CommonAction extends Action{<br>
//初始化方法,调用方法时会先执行<br>
function _initialize(){<br>
header('Content-Type:text/html;charset=utf-8');<br>
import('ORG.Util.Cookie');<br>
// 用户权限检查<br>
if (C('USER_AUTH_ON') && !in_array(MODULE_NAME, explode(',', C('NOT_AUTH_MODULE')))) {<br>
import('ORG.Util.RBAC');<br>
if (!RBAC::AccessDecision()) {<br>
//检查认证识别号<br>
if (!$_SESSION [C('USER_AUTH_KEY')]) {<br>
//跳转到认证网关<br>
redirect(PHP_FILE . C('USER_AUTH_GATEWAY'));<br>
}else{<br>
echo L('_VALID_ACCESS_');<br>
exit();<br>
}<br>
// 没有权限 抛出错误<br>
if (C('RBAC_ERROR_PAGE')) {<br>
// 定义权限错误页面<br>
redirect(C('RBAC_ERROR_PAGE'));<br>
} else {<br>
if (C('GUEST_AUTH_ON')) {<br>
$this->assign('jumpUrl', PHP_FILE . C('USER_AUTH_GATEWAY'));<br>
}<br>
// 提示错误信息<br>
$this->error(L('_VALID_ACCESS_'));<br>
}<br>
}<br>
}<br>
}
到此RBAC权限判断就基本完成,是不是没有想象中那么难?如果看完这几篇文章还是不明白,欢迎加我QQ544828662咨询。
AD:真正免费,域名+虚机+企业邮箱=0元

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6
Visual web development tools
