Example #1
0
 public static function Instance($database = NULL)
 {
     if (!isset(self::$instances[$database])) {
         if (is_null($database)) {
             $db_info = Config::Get('database');
         } else {
             $db_info = array('name' => $database);
         }
         $db_file = Config::Path(Config::DIR_DATA . DIRECTORY_SEPARATOR . $db_info['name'] . SQLite::DB_EXTENSION);
         if (!file_exists($db_file)) {
             $schema = file_get_contents(Config::Path(Config::DIR_DATA . DIRECTORY_SEPARATOR . $db_info['name'] . SQLite::INIT_EXTENSION));
             $schema = str_replace("\n", ' ', $schema);
             $schema = str_replace("\r", ' ', $schema);
             $db = new SQLite3($db_file, SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
             $db->exec($schema);
         }
         // load database
         self::$instances[$database] = new PDO('sqlite:' . $db_file);
         if (Config::Get('debug')) {
             self::$instances[$database]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         } else {
             self::$instances[$database]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
         }
         self::$instances[$database]->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
     }
     self::$access++;
     return self::$instances[$database];
 }
Example #2
0
             }
         }
         $u->setPassword($_POST['pass']);
         if (!$u->save()) {
             throw new \Exception('Unable to add the user. Please contact the webmaster.');
         }
         foreach ($settings as $key => $value) {
             $s = new Setting($key);
             if ($s->getValue() != $settings[$key]) {
                 $s->setValue($value);
                 if (!$s->save()) {
                     throw new \Exception('Unable to save the new value for ' . $key . '.');
                 }
             }
         }
         touch(Config::Path(Config::DIR_DATA . '/installed'));
         header('Location: ' . $this->URL('manage'));
         exit;
     } catch (\Exception $e) {
         $this->assign('form_error', $e->getMessage());
     }
 } else {
     if (!empty($_GET['force-erase'])) {
         $this->assign('form_data', array('email' => htmlspecialchars($_GET['force-erase'])));
     }
 }
 $this->page('manage/installation');
 $this->assign('default_app_name', Setting::DefaultSetting('app_name'));
 $this->assign('default_app_title', Setting::DefaultSetting('app_title'));
 $this->assign('default_app_copyright', Setting::DefaultSetting('app_copyright'));
 $this->getToken();
Example #3
0
 protected function controllerPage()
 {
     $GLOBALS['app'] = $this;
     $controller = Config::Path(DIRECTORY_SEPARATOR . Config::DIR_PAGES . DIRECTORY_SEPARATOR . $this->page . '.php');
     if (file_exists($controller)) {
         require_once $controller;
     }
 }