本文整理匯總了PHP中RBAC類的典型用法代碼示例。如果您正苦於以下問題:PHP RBAC類的具體用法?PHP RBAC怎麽用?PHP RBAC使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了RBAC類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _initialize
function _initialize()
{
//echo '<pre>';print_r($_SESSION);exit;
//import('@.ORG.Util.Cookie');
// 用戶權限檢查
if (C('USER_AUTH_ON') && !in_array(MODULE_NAME, explode(',', C('NOT_AUTH_MODULE')))) {
// import('@.ORG.Util.RBAC');
if (!RBAC::AccessDecision()) {
//檢查認證識別號,沒有登錄的情況
if (!$_SESSION[C('USER_AUTH_KEY')]) {
//跳轉到認證網關
redirect(PHP_FILE . C('USER_AUTH_GATEWAY'));
}
// 沒有權限 拋出錯誤
if (C('RBAC_ERROR_PAGE')) {
// 定義權限錯誤頁麵
redirect(C('RBAC_ERROR_PAGE'));
} else {
if (C('GUEST_AUTH_ON')) {
$this->assign('jumpUrl', PHP_FILE . C('USER_AUTH_GATEWAY'));
}
// 提示錯誤信息
unset($_SESSION[C('USER_AUTH_KEY')]);
//不然在某些情況會在,登陸頁麵反複跳轉
$this->error(L('_VALID_ACCESS_'), PHP_FILE . C('USER_AUTH_GATEWAY'));
//$this->error(L('_VALID_ACCESS_'),__APP__ . C('USER_AUTH_GATEWAY'));
}
}
}
}
示例2: getAname
public function getAname($authId)
{
import('@.ORG.RBAC');
$groupList = RBAC::getFileGroupAccessList();
// 查詢菜單分組
$model = M("group");
//管理員排除驗證
if (!isset($_SESSION['a'])) {
$map['status'] = 1;
if ($groupList) {
$map['id'] = array(" in ", $groupList);
} else {
$map['id'] = 0;
}
} else {
$map['status'] = array('gt', 0);
}
$list = $model->where($map)->order("sorts asc")->select();
$pModel = D("Public");
$nlist = array();
foreach ($list as $key => $val) {
$nlist[$val['id']] = $pModel->menuLeftTree($val['id']);
}
return $nlist;
}
示例3: _initialize
function _initialize()
{
// 用戶權限檢查
if (C('USER_AUTH_ON') && !in_array(MODULE_NAME, explode(',', C('NOT_AUTH_MODULE')))) {
import('ORG.Util.RBAC');
if (!RBAC::AccessDecision()) {
//檢查認證識別號
if (!$_SESSION[C('USER_AUTH_KEY')]) {
//跳轉到認證網關
redirect(PHP_FILE . C('USER_AUTH_GATEWAY'));
}
// 沒有權限 拋出錯誤
if (C('RBAC_ERROR_PAGE')) {
// 定義權限錯誤頁麵
redirect(C('USER_AUTH_GATEWAY'));
} else {
if (C('GUEST_AUTH_ON')) {
$this->assign('jumpUrl', PHP_FILE . C('USER_AUTH_GATEWAY'));
}
// 提示錯誤信息
$this->error(L('_VALID_ACCESS_'));
}
}
if (!get_magic_quotes_gpc()) {
!empty($_POST) && Add_S($_POST);
!empty($_GET) && Add_S($_GET);
!empty($_COOKIE) && Add_S($_COOKIE);
!empty($_SESSION) && Add_S($_SESSION);
}
!empty($_FILES) && Add_S($_FILES);
}
}
示例4: AccessDecision
public static function AccessDecision($appName = APP_NAME)
{
if (RBAC::checkAccess()) {
$accessGuid = md5($appName . MODULE_NAME . ACTION_NAME);
if (empty($_SESSION[C('ADMIN_AUTH_KEY')])) {
if (C('USER_AUTH_TYPE') == 2) {
$accessList = RBAC::getAccessList($_SESSION[C('USER_AUTH_KEY')]);
} else {
if ($_SESSION[$accessGuid]) {
return true;
}
$accessList = $_SESSION['_ACCESS_LIST'];
}
$module = defined('P_MODULE_NAME') ? P_MODULE_NAME : MODULE_NAME;
if (!isset($accessList[strtoupper($appName)][strtoupper($module)][strtoupper(ACTION_NAME)])) {
$_SESSION[$accessGuid] = false;
return false;
} else {
$_SESSION[$accessGuid] = true;
}
} else {
return true;
}
}
return true;
}
示例5: _initialize
function _initialize()
{
import('@.ORG.Util.Cookie');
// 用戶權限檢查
if (C('USER_AUTH_ON') && !in_array(MODULE_NAME, explode(',', C('NOT_AUTH_MODULE')))) {
import('@.ORG.Util.RBAC');
if (!RBAC::AccessDecision()) {
//檢查認證識別號
if (!$_SESSION[C('USER_AUTH_KEY')]) {
//跳轉到認證網關
redirect(PHP_FILE . C('USER_AUTH_GATEWAY'));
}
// 沒有權限 拋出錯誤
if (C('RBAC_ERROR_PAGE')) {
// 定義權限錯誤頁麵
redirect(C('RBAC_ERROR_PAGE'));
} else {
if (C('GUEST_AUTH_ON')) {
$this->assign('jumpUrl', PHP_FILE . C('USER_AUTH_GATEWAY'));
}
// 提示錯誤信息
$this->error(L('_VALID_ACCESS_'));
}
}
}
}
示例6: RBAC
/**
* to get singleton instance
*
* @access public
* @return object
*/
public function &getSingleton()
{
if (self::$instance == null) {
self::$instance = new RBAC();
}
return self::$instance;
}
示例7: checkLogin
function checkLogin()
{
if (empty($_POST['username'])) {
$this->error('帳號錯誤!');
} elseif (empty($_POST['password'])) {
$this->error('密碼必須!');
}
//生成認證條件
$map = array();
// 支持使用綁定帳號登錄
$map['username'] = $_POST['username'];
import('ORG.Util.RBAC');
$authInfo = RBAC::authenticate($map);
//使用用戶名、密碼和狀態的方式進行認證
if (false === $authInfo) {
$this->error('帳號不存在或已禁用!');
} else {
if ($authInfo['password'] != md5($_POST['password'])) {
$this->error('密碼錯誤!');
}
$_SESSION[C('USER_AUTH_KEY')] = $authInfo['id'];
if ($authInfo['username'] == 'admin') {
$_SESSION['administrator'] = true;
}
// 緩存訪問權限
RBAC::saveAccessList();
$this->success('登錄成功!');
}
}
示例8: _initialize
protected function _initialize()
{
$sql = "SHOW COLUMNS FROM `" . C("DB_PREFIX") . "user`";
$COLUMNS = M()->query($sql);
foreach ($COLUMNS as $vo) {
$COLUMNS_array[] = $vo["Field"];
}
if (!in_array("is_admin", $COLUMNS_array)) {
$sql = "ALTER TABLE `" . C("DB_PREFIX") . "user` ADD `is_admin` INT NOT NULL DEFAULT '0'";
M()->query($sql);
}
if (!isset($_SESSION["username"])) {
$this->error("非法操作", U("System/Admin/index"));
}
parent::_initialize();
C("NOT_AUTH_ACTION", "");
C("NOT_AUTH_MODULE", "Admin");
if (C("USER_AUTH_ON") && !in_array(MODULE_NAME, explode(",", C("NOT_AUTH_MODULE")))) {
if (!RBAC::AccessDecision()) {
if (!$_SESSION[C("USER_AUTH_KEY")]) {
redirect(PHP_FILE . C("USER_AUTH_GATEWAY"));
}
if (C("RBAC_ERROR_PAGE")) {
redirect(C("RBAC_ERROR_PAGE"));
} else {
if (C("GUEST_AUTH_ON")) {
$this->assign("jumpUrl", PHP_FILE . C("USER_AUTH_GATEWAY"));
}
$this->error(L("_VALID_ACCESS_"));
}
}
}
$this->show_menu();
}
示例9: login
public function login()
{
if (!IS_POST) {
halt('頁麵不存在');
}
//sae平台特殊處理驗證碼
if (md5(strtoupper($_POST['code'])) != $_SESSION['verify']) {
//驗證錯誤處理代碼
$this->error('驗證碼錯誤');
}
// if(I('code', '', 'strtolower') != session('verify')){
// $this->error('驗證碼錯誤');
// }
$db = M('user');
$user = $db->where(array('username' => I('username')))->find();
if (!$user || $user['password'] != I('password', '', 'md5')) {
$this->error('username or password wrong!');
}
//更新最後一次登錄時間與IP
$data = array('id' => $user['id'], 'logintime' => time(), 'loginip' => get_client_ip());
$db->save($data);
session(C('USER_AUTH_KEY'), $user['id']);
session('username', $user['username']);
session('logintime', date('Y-m-d H:i:s', $user['logintime']));
session('loginip', $user['loginip']);
//超級管理員識別
if ($user['username'] == C('RBAC_SUPERADMIN')) {
session(C('ADMIN_AUTH_KEY'), true);
}
// p($_SESSION);
//讀取用戶權限
import('ORG.Util.RBAC');
RBAC::saveAccessList();
redirect(__GROUP__);
}
示例10: RBAC
/**
* to get singleton instance
*
* @access public
* @return object
*/
function &getSingleton()
{
if (self::$instance == NULL) {
self::$instance = new RBAC();
}
return self::$instance;
}
示例11: login
public function login()
{
if (!IS_POST) {
halt('頁麵不存在3');
}
// if(I('code','','md5')!=session('verify')){
// $this->error('驗證碼錯誤');
// }
$username = I('username');
$pwd = I('password', '', 'md5');
$user = M('user')->where(array('username' => $username))->find();
if (!$user || $user['password'] != $pwd) {
$this->error('賬號或密碼錯誤!');
}
if ($user['lock']) {
$this->error('用戶被鎖了');
}
$data = array('id' => $user['id'], 'logintime' => time(), 'loginip' => get_client_ip());
M('user')->save($data);
session(C('USER_AUTH_KEY'), $user['id']);
session('username', $user['username']);
session('logintime', date('Y-m-d H:i:s', $user['logintime']));
session('loginip', $user['loginip']);
//超級管理員識別
if ($user['username'] == C('RBAC_SUPERADMIN')) {
session(C('ADMIN_AUTH_KEY'), true);
}
//讀取用戶權限
import('ORG.Util.RBAC');
RBAC::saveAccessList();
p($_SESSION);
die;
$this->redirect('Admin/Index/index');
}
示例12: _initialize
protected function _initialize(){
if(!isset($_SESSION['username'])){$this->error('非法操作',U('System/Adminsaivi/index'));}
parent::_initialize();
if (C('USER_AUTH_ON') && !in_array(MODULE_NAME, explode(',', C('NOT_AUTH_MODULE')))) {
if (!RBAC::AccessDecision()) {
//檢查認證識別號
if (!$_SESSION [C('USER_AUTH_KEY')]) {
//跳轉到認證網關
redirect(PHP_FILE . C('USER_AUTH_GATEWAY'));
}
// 沒有權限 拋出錯誤
if (C('RBAC_ERROR_PAGE')) {
// 定義權限錯誤頁麵
redirect(C('RBAC_ERROR_PAGE'));
} else {
if (C('GUEST_AUTH_ON')) {
$this->assign('jumpUrl', PHP_FILE . C('USER_AUTH_GATEWAY'));
}
// 提示錯誤信息
$this->error(L('_VALID_ACCESS_'));
}
}
}
$this->show_menu();
}
示例13: login
public function login()
{
if (!IS_POST) {
_404('頁麵不存在');
}
/*if(I('code', '', 'md5') != session('verify')){
$this->error('驗證碼錯誤');
}*/
$username = I('username');
$pwd = I('password', '', 'md5');
$user = M('user')->where(array('username' => $username))->find();
if (!$user || $user['password'] != $pwd) {
$this->error('賬號或密碼錯誤');
} else {
if ($user['lock']) {
$this->error('用戶被鎖定');
}
}
//更新數據庫
$data = array('id' => $user['id'], 'loginTime' => time(), 'loginIp' => get_client_ip());
M('user')->save($data);
//讀取權限
session(C('USER_AUTH_KEY'), $user['id']);
session('username', $user['username']);
session('loginTime', date('y-m-d H:i:s'), $user['loginTime']);
session('loginIp', $user['loginIp']);
if ($user['username'] == C('RBAC_SUPERADMIN')) {
session(C('ADMIN_AUTH_KEY'), true);
}
import('ORG.Util.RBAC');
RBAC::saveAccessList();
//P($_SESSION);
//die();
$this->redirect('Admin/Index/index');
}
示例14: metodillo
function metodillo()
{
$sSQL = "SELECT * FROM PM_PARAMETERS WHERE PRM_ID = 'CAS_URL' ";
$aResSQL = executeQuery($sSQL);
if (count($aResSQL)) {
$sURL = $aResSQL[1]['PRM_VALUE'];
$sURI = $aResSQL[1]['PRM_VALUE_2'];
$res = false;
$RBAC = RBAC::getSingleton();
$RBAC->initRBAC();
require_once 'CAS-1.2.2/CAS.php';
phpCAS::client(CAS_VERSION_2_0, $sURL, 443, $sURI, false);
phpCAS::setNoCasServerValidation();
phpCAS::forceAuthentication();
if (phpCAS::isAuthenticated() == true) {
$sCasUser = phpCAS::getUser();
$sSQL = "SELECT USR_UID FROM USERS WHERE USR_USERNAME = '{$sCasUser}' ";
$aResSQL = executeQuery($sSQL);
if (count($aResSQL)) {
$nUserId = $aResSQL[1]['USR_UID'];
$RBAC->singleSignOn = true;
$RBAC->userObj->fields['USR_UID'] = $nUserId;
$RBAC->userObj->fields['USR_USERNAME'] = $sCasUser;
$res = true;
} else {
$res = false;
}
} else {
$res = false;
}
} else {
$res = false;
}
return $res;
}
示例15: login
public function login()
{
$systemConfig = (include WEB_ROOT . 'Common/systemConfig.php');
if (IS_POST) {
$pubmod = new PublicModel();
$returnLoginInfo = $pubmod->auth();
if ($returnLoginInfo['status'] == 1) {
$map = array();
// 支持使用綁定帳號登錄
$map['a_name'] = $this->_post('name');
import('ORG.Util.RBAC');
$authInfo = RBAC::authenticate($map);
$_SESSION[C('USER_AUTH_KEY')] = $authInfo['a_id'];
#var_dump($_SESSION[C('USER_AUTH_KEY')]);exit;
$_SESSION['a_name'] = $authInfo['a_name'];
if ($authInfo['a_name'] == C('ADMIN_AUTH_KEY')) {
//是否是管理員登錄
$_SESSION[C('ADMIN_AUTH_KEY')] = true;
}
// 緩存訪問權限
RBAC::saveAccessList();
$_SESSION['username'] = $authInfo['a_name'];
//記錄管理員log
$data = array("a_id" => $authInfo['a_id'], "l_content" => "管理員[" . $authInfo['a_name'] . "]於[" . date("Y-m-d H:i:s") . "]登錄了[唐亮工長俱樂部]後台管理係統!");
M("Log")->add($data);
$this->success("登錄成功", U("Index/index"));
exit;
} else {
$this->error($returnLoginInfo['info']);
exit;
}
}
$this->assign("systemConfig", $systemConfig);
$this->display();
}