Пример #1
0
 /**
  * getInstance
  * @return MDL_Locator
  */
 public static function getInstance()
 {
     if (NULL === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Пример #2
0
 private function __construct()
 {
     $this->locator = MDL_Locator::getInstance();
     $this->header['javascript'] = $this->header['stylesheet'] = array();
     //設置默認時區
     date_default_timezone_set(MDL_Config::getInstance()->getVar('time_zone'));
 }
Пример #3
0
 public function getURL($byname = true)
 {
     if ($byname) {
         $id = $this->getName();
     } else {
         $id = $this->getID();
     }
     return MDL_Locator::getInstance()->getURL('problem/' . $id);
 }
Пример #4
0
 /**
  * Construct and initilize
  */
 public function __construct()
 {
     $this->config = MDL_Config::getInstance();
     $this->acl = MDL_ACL::getInstance();
     $this->locator = MDL_Locator::getInstance();
     $this->view = MDL_View::getInstance();
     $this->view->setTheme($this->config->getVar('theme'));
     $this->path_option = BFL_PathOption::getInstance();
 }
Пример #5
0
 public static function sendRequest($judger, $task)
 {
     $judger_url = $judger->getConfig()->getRemoteURL();
     $public_key = $judger->getConfig()->getRemoteKey();
     $return_url = MDL_Config::getInstance()->getVar('judge_return_site') . MDL_Locator::getInstance()->getURL('judge_return');
     $task = array('prob_name' => $task['prob_name'], 'task_name' => $task['task_name'], 'source_file' => $task['src_name'], 'language' => $task['language'], 'return_url' => "{$return_url}?record_id={$task['record_id']}", 'public_key' => self::getPublicKey());
     $client = new BFL_RemoteAccess_Client($judger_url, $public_key, 1);
     $client->judge($task);
 }
Пример #6
0
 public static function sendValidationCode($user_name, $email, $validation_code)
 {
     $server_name = BFL_General::getServerName();
     $site_address = BFL_General::getServerAddress();
     $options = array('user_name' => $user_name, 'code' => $validation_code);
     $validation_address = MDL_Locator::getInstance()->getURL('passport_dovalidation', $options);
     if (strpos($validation_address, $site_address) !== 0) {
         $validation_address = $site_address . $validation_address;
     }
     $site_name = MDL_Config::getInstance()->getVar('site_name');
     $view = MDL_View::getInstance();
     $view->validation = array('user_name' => $user_name, 'site_name' => $site_name, 'site_address' => $site_address, 'validation_address' => $validation_address);
     $message = $view->render('text/email_validation.php');
     $mail_sender = new BFL_Mail($email, $site_name, $message);
     $mail_sender->setFrom($site_name . " <vakuum@{$server_name}>");
     return $mail_sender->send();
 }
Пример #7
0
 /**
  *
  * @param Exception $exception
  */
 public static function exceptionHandler($exception)
 {
     //撤銷數據庫改動
     $db = BFL_Database::getInstance();
     $db->rollback();
     if ($exception instanceof MDL_Exception) {
         $desc = BFL_Serializer::transmitEncode($exception->getDesc());
         MDL_Locator::getInstance()->redirect(self::$error_page, NULL, '?' . $desc);
     } else {
         if (DEBUG) {
             echo $exception->getMessage();
             $error_massage = $exception->getTraceAsString();
         } else {
             if ($exception instanceof PDOException) {
                 $error_massage = "DB Error";
             } else {
                 $error_massage = "Vakuum Error";
             }
         }
         die($error_massage);
     }
 }
Пример #8
0
 public function getURL()
 {
     return MDL_Locator::getInstance()->getURL('user/detail') . '/' . $this->getName();
 }
Пример #9
0
 public function getURL()
 {
     return MDL_Locator::getInstance()->getURL('record/detail/' . $this->getID());
 }
Пример #10
0
 public static function initialize()
 {
     $view = MDL_View::getInstance();
     $view->header['stylesheet']['list_navigation'] = MDL_Locator::makePublicURL(BFL_Register::getVar('plugin_file') . 'style.css');
 }
Пример #11
0
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();
Пример #12
0
 public function getURL($options = array())
 {
     $path_option = $query_string = array();
     foreach ($this->path_option as $key => $value) {
         if (isset($options[$key])) {
             $path_option[$key] = $options[$key];
             unset($options[$key]);
         } else {
             $path_option[$key] = $value;
         }
     }
     foreach ($this->query_string as $key => $value) {
         if (isset($options[$key])) {
             $query_string[$key] = $options[$key];
             unset($options[$key]);
         } else {
             $query_string[$key] = $value;
         }
     }
     foreach ($options as $key => $value) {
         $path_option[$key] = $value;
     }
     return MDL_Locator::makeURL($this->base_path, $path_option, $query_string);
 }
Пример #13
0
            ?>
		<?php 
            foreach ($problems as $problem) {
                ?>
			<?php 
                $record = $contest_user->getLastRecordWithProblem($problem);
                ?>
			<td>
			<?php 
                if ($record != NULL) {
                    ?>
				<?php 
                    echo $this->formatTimeSection($record->getSubmitTime() - $contest_start_time);
                    ?>
				<?php 
                    $record_url = MDL_Locator::makeURL('contest/record', array('contest' => $contest->getID(), 'user' => $contest_user->getUser()->getID(), 'problem' => $problem->getID()));
                    ?>
				<br /><?php 
                    echo (int) $contest_user->getScoreWithProblem($problem);
                    ?>
				<a href="<?php 
                    echo $record_url;
                    ?>
">(<?php 
                    echo count($contest_user->getRecordsWithProblem($problem));
                    ?>
)</a>
			<?php 
                }
                ?>
			</td>
Пример #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;
 }
Пример #15
0
 protected function getCommonURL()
 {
     return MDL_Locator::makePublicURL('public/common/');
 }