Example #1
0
 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;
             }
         }
     }
 }
Example #2
0
 protected function __construct()
 {
     $this->query_string = $_GET;
     $this->request_path = BFL_Register::getVar('request_path');
     $this->base_path = BFL_Register::getVar('base_path');
     BFL_Register::unsetVar('request_path');
     BFL_Register::unsetVar('base_path');
     $this->base_path .= '/' . $this->getPathSection(0) . '/' . $this->getPathSection(1);
     if ($this->base_path[0] == '/') {
         $this->base_path = substr($this->base_path, 1);
     }
     $path = $this->request_path;
     unset($path[1], $path[2]);
     $iskey = false;
     $key = '';
     $result = array();
     foreach ($path as $item) {
         $iskey = !$iskey;
         if ($iskey) {
             $key = $item;
         } else {
             $result[$key] = $item;
         }
     }
     $this->path_option = $result;
 }
Example #3
0
 public function getVar($key)
 {
     $preference = BFL_Register::getVar('user_preference');
     if (isset($preference['key'])) {
         return $preference['key'];
     }
     return parent::getVar($key);
 }
Example #4
0
 public function ACT_sendvalidation()
 {
     if (!$this->acl->check('unvalidated')) {
         $this->deny();
     }
     $user = BFL_Register::getVar('personal');
     MDL_User_Edit::sendValidationCode($user['user_name'], $user['email'], $user['validation_code']);
     $this->locator->redirect('user_space');
 }
Example #5
0
 protected function connect()
 {
     $db_info = BFL_Register::getVar('db_info');
     BFL_Register::unsetVar('db_info');
     try {
         $dsn = $db_info['type'] . ':host=' . $db_info['host'] . ';dbname=' . $db_info['name'];
         $this->pdo = new PDO($dsn, $db_info['user'], $db_info['password']);
         $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         $this->pdo->exec('SET NAMES UTF8');
     } catch (PDOException $e) {
         die("Database Error: " . $e->getMessage());
     }
 }
Example #6
0
 public function allowAdmin()
 {
     if ($this->check('administrator')) {
         if (DEBUG) {
             if (!BFL_Register::haveVar('warning_adminaccess')) {
                 BFL_Register::setVar('warning_adminaccess', true);
                 echo 'Warning: This page is not allowed to access by general users.';
             }
         }
         return true;
     }
     return false;
 }
Example #7
0
 public function ACT_doedit()
 {
     if (!$this->acl->check(array('general', 'unvalidated'))) {
         $this->deny();
     }
     $user = BFL_Register::getVar('personal');
     $user_id = $this->acl->getUser()->getID();
     $user_name = $user['user_name'];
     $user_info = array('user_id' => $user_id, 'user_name' => $user_name, 'user_password_correct' => $user['user_password'], 'user_password' => $_POST['user_password'], 'user_password_original' => $_POST['user_password_original'], 'user_password_repeat' => $_POST['user_password_repeat'], 'user_nickname' => $_POST['user_nickname'], 'email' => $_POST['email'], 'website' => $_POST['website'], 'memo' => $_POST['memo'], 'identity' => $user['identity']);
     MDL_User_Edit::edit($user_info);
     //TODO success message
     $this->locator->redirect('user_space');
 }
Example #8
0
 public static function load_plugins($plugins_path)
 {
     $dh = opendir($plugins_path);
     while ($file = readdir($dh)) {
         if ($file != "." && $file != "..") {
             $plugin_file = $plugins_path . $file . '/';
             if (is_dir($plugin_file)) {
                 $interface = $plugin_file . 'interface.php';
                 if (file_exists($interface)) {
                     self::$plugins[] = strtolower($file);
                     BFL_Register::setVar('plugin_file', $plugin_file);
                     include_once $interface;
                     BFL_Register::unsetVar('plugin_file');
                 }
             }
         }
     }
     closedir($dh);
 }
Example #9
0
 private function formatPath()
 {
     $this->request_path = explode('/', $this->request_path);
     unset($this->request_path[0]);
     foreach ($this->request_path as $key => $value) {
         $this->request_path[$key] = strtolower($value);
     }
     BFL_Register::setVar('request_path', $this->request_path);
     BFL_Register::setVar('base_path', $this->base_path);
 }
Example #10
0
 protected static function passwordEncrypt($password)
 {
     return md5(sha1($password, true) . BFL_Register::getVar('password_encode_word'));
 }
Example #11
0
<?php

require_once 'function.php';
$this->header['stylesheet']['global'] = $this->getViewURL() . 'style/screen.css';
$this->header['javascript']['jquery'] = $this->getCommonURL() . 'script/jquery-1.4.2.js';
$this->header['javascript']['jquery-ajaxqueue'] = $this->getCommonURL() . 'script/jquery-ajaxqueue.js';
$this->header['javascript']['admin-global'] = $this->getViewURL() . 'script/global.js';
$current_user = BFL_Register::getVar('personal');
Example #12
0
 public static function initialize()
 {
     $view = MDL_View::getInstance();
     $view->header['stylesheet']['list_navigation'] = MDL_Locator::makePublicURL(BFL_Register::getVar('plugin_file') . 'style.css');
 }
Example #13
0
<?php

require_once 'library/global.php';
require_once 'library/BFL/BFL_Loader.php';
//初始化自動加載器
BFL_Loader::setBFLPath('./library/BFL/');
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();
//加載插件
Example #14
0
 public static function initialize()
 {
     self::$plugin_file = BFL_Register::getVar('plugin_file');
     self::$plugin_path = MDL_Config::getInstance()->getVar('root_path') . self::$plugin_file;
     self::$plugin_request = MDL_Locator::getInstance()->getURL('plugin_request') . '/' . self::$plugin_name;
 }