Example #1
0
 public function __construct(\Application $application)
 {
     parent::__construct($application);
     $this->repository = PDORepositoryFactory::get("\\plugin\\Slider\\model\\Slide", \Database::GetConnection());
     $this->AdminController = new controller\AdminController($this->application, $this->repository);
     $this->PublicController = new controller\PublicController($this->application, $this->repository);
 }
Example #2
0
 public function __construct()
 {
     $this->conn = \Database::GetConnection();
 }
Example #3
0
<?php

$my_file = APP_ROOT . 'src' . DIRECTORY_SEPARATOR . 'Settings.php';
if (file_exists($my_file)) {
    die("Something is not right here...");
}
if (isset($_POST['submit'])) {
    $content = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . "settings-default.php");
    $content = str_replace("[DatabaseDSN::Placeholder]", $_POST['db_dsn'], $content);
    $content = str_replace("[DatabaseUsername::Placeholder]", $_POST['db_username'], $content);
    $content = str_replace("[DatabasePassword::Placeholder]", $_POST['db_password'], $content);
    $content = str_replace("[DatabaseDatabase::Placeholder]", $_POST['db_database'], $content);
    $handle = fopen($my_file, 'w');
    fwrite($handle, $content);
    try {
        $conn = Database::GetConnection();
        $authentication = new \plugin\Authentication\model\UserModel();
        $authentication->Install();
        $user = new \plugin\Authentication\model\User($_POST['cms_username'], $_POST['cms_password']);
        $authentication->Create($user);
        $settings = new \plugin\Settings\model\SettingModel();
        $settings->Install();
        $setting = new \plugin\Settings\model\Setting("page-site-title", $_POST['title'], "The name of your website");
        $settings->Save($setting);
    } catch (\Exception $e) {
        debug($e->getMessage());
        unlink($my_file);
    }
}
?>
<!doctype html>
Example #4
0
 protected function RemoveTable($table)
 {
     \Database::GetConnection()->exec("\n          DROP TABLE IF EXISTS `{$table}`\n        ");
 }
Example #5
0
 public static function IsInstalled()
 {
     try {
         $result = \Database::GetConnection()->query("SELECT 1 FROM user LIMIT 1");
     } catch (\Exception $e) {
         return FALSE;
     }
     // Result is either boolean FALSE (no table found) or PDOStatement Object (table found)
     return $result !== FALSE;
 }