public function deny($deny_administrator = false) { if (!$deny_administrator && $this->acl->allowAdmin()) { return; } throw new MDL_Exception(MDL_Exception::PERMISSION_DENIED); }
public static function getLoginedUserInformation() { $acl = MDL_ACL::getInstance(); $user_id = $acl->getUser()->getID(); if ($user_id != 0) { try { $user = MDL_User_Detail::getUser($user_id); BFL_Register::setVar('personal', $user); if (isset($user['identity'])) { $acl->setIdentity($user['identity']); } if (isset($user['preference'])) { $preference = BFL_XML::XML2Array($user['preference']); BFL_Register::setVar('user_preference', $preference); } } catch (MDL_Exception_User $e) { if ($e->testDesc(MDL_Exception_User::FIELD_USER, MDL_Exception_User::INVALID_USER_ID)) { $acl->resetSession(); $acl->initialize(SESSION_PREFIX, 'guest'); } else { throw $e; } } } }
/** * getInstance * @return MDL_ACL */ public static function getInstance() { if (NULL === self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
public function canView($key) { if ($this->getRankDisplay()->{$key}) { return true; } if (MDL_ACL::getInstance()->allowAdmin()) { return true; } }
<p>请注意,点击下面任意一个题目的链接以后即开始计时。</p> <table border="1"> <tr> <td>代号</td> <td>题目</td> <td>分值</td> <td>状态</td> </tr> <?php foreach ($contest_config->getProblems() as $problem) { ?> <?php $problem_url = $this->locator->getURL('contest/entry') . '/' . $contest_id . '/' . $problem->alias; ?> <?php $contest_user = new MDL_Contest_User($contest, MDL_ACL::getInstance()->getUser()); ?> <?php $record = $contest_user->getLastRecordWithProblem($problem); ?> <tr> <td><?php echo $problem->alias; ?> </td> <td><a href="<?php echo $problem_url; ?> "><?php echo $problem->getTitle(); ?>
public static function validate($user_name, $validation_code) { $user = MDL_User_Detail::getUserByName($user_name); if ($user['identity'] != 'unvalidated' || !isset($user['validation_code'])) { throw new MDL_Exception_User(MDL_Exception_User::UNVALIDATED_USER); } if ($user['validation_code'] == $validation_code) { $user_meta = new MDL_User_Meta($user['user_id']); $user_meta->setVar('identity', 'general'); $user_meta->unsetVar('validation_code'); MDL_User_Auth::logout(); MDL_ACL::getInstance()->setUser(new MDL_User($rs['user_id'])); } }
<?php $this->title = '个人中心'; $this->display('header.php'); ?> <a href="<?php echo $this->locator->getURL('user_edit'); ?> ">修改个人信息</a> <?php if (MDL_ACL::getInstance()->check('unvalidated')) { ?> <p><a href="<?php echo $this->locator->getURL('passport_sendvalidation'); ?> ">重新发送验证邮件</a></p> <?php } ?> <?php $this->display('footer.php');
BFL_Loader::setControllerPath('./library/application/controller/'); BFL_Loader::setModelPath('./library/application/model/'); //初始化計時器 BFL_Timer::initialize(); //設置運行時全局變量 BFL_Register::setVar('password_encode_word', PWD_ENCWORD); BFL_Register::setVar('db_info', getDBInfo()); //初始化數據庫事務處理 $db = BFL_Database::getInstance(); $db->beginTransaction(); //初始化參數表 $config = MDL_Config::getInstance(); //設置全局異常捕捉函數 set_exception_handler(array('MDL_GlobalControl', 'exceptionHandler')); //設置退出回調函數 register_shutdown_function(array('MDL_GlobalControl', 'shutdownHandler')); //檢查地址綁定 $bind_address = $config->getVar('site_address'); if ($bind_address != '' && $bind_address != BFL_General::getServerAddress()) { BFL_Controller::redirect($bind_address); } //初始化用戶會話 MDL_ACL::getInstance()->initialize(SESSION_PREFIX, 'guest'); MDL_User_Auth::getLoginedUserInformation(); //加載插件 MDL_Plugin::load_plugins(MDL_Locator::getInstance()->getFilePath('plugins')); //初始化前端控制器 $controller = BFL_Controller::getInstance(); $controller->setCustomControllerRouter('/admin', '_admin'); $controller->setNotFound(array('CTL_error', 'notFound')); $controller->dispatch();
?> <a href="<?php echo $this->locator->getURL('user_space'); ?> ">个人</a> <a href="<?php echo $this->locator->getURL('passport_dologout'); ?> ">登出</a> <?php } else { ?> <a href="<?php echo $this->locator->getURL('passport'); ?> ">登录</a> <?php } if (MDL_ACL::getInstance()->check('administrator')) { ?> <a href="<?php echo $this->locator->getURL('admin_index'); ?> ">后台管理</a> <?php } ?> </p> </div> <div id="content">