예제 #1
0
 static function init()
 {
     self::$time_start = sys_get_microtime();
     // clean request vars
     if (ini_get("magic_quotes_gpc") !== false and get_magic_quotes_gpc()) {
         modify::stripslashes($_REQUEST);
     }
     foreach ($_REQUEST as $key => $val) {
         if (is_array($val) and count($val) > 0) {
             $_REQUEST[$key] = array();
             foreach ($val as $val2) {
                 if (!is_array($val2)) {
                     $_REQUEST[$key][$val2] = $val2;
                 }
             }
         }
     }
     // set up smarty
     self::$smarty = new Smarty();
     self::$smarty->register_prefilter(array("modify", "urladdon_quote"));
     if (isset($_REQUEST["print"])) {
         self::$smarty->register_outputfilter(array("modify", "striplinksforms"));
     }
     if (isset($_REQUEST["print"])) {
         self::$smarty->assign("print", $_REQUEST["print"]);
     }
     self::$smarty->compile_dir = SIMPLE_CACHE . "/smarty";
     self::$smarty->template_dir = "templates";
     self::$smarty->config_dir = "templates/css";
     self::$smarty->compile_check = false;
     // refresh smarty cache
     if (DEBUG) {
         debug_check_tpl();
     }
     // set up database
     if (!sql_connect(SETUP_DB_HOST, SETUP_DB_USER, sys_decrypt(SETUP_DB_PW, sha1(SETUP_ADMIN_USER)), SETUP_DB_NAME)) {
         $err = sprintf("{t}Cannot connect to database %s on %s.{/t}\n", SETUP_DB_NAME, SETUP_DB_HOST) . sql_error();
         trigger_error($err, E_USER_ERROR);
         sys_die($err);
     }
     // verify credentials
     login_handle_login();
 }