38 lines
1 KiB
PHP
38 lines
1 KiB
PHP
<?php
|
|
namespace Uiharu;
|
|
|
|
use Index\Autoloader;
|
|
use Index\Environment;
|
|
use Index\Data\ConnectionFailedException;
|
|
use Index\Data\DbTools;
|
|
|
|
define('UIH_STARTUP', microtime(true));
|
|
define('UIH_ROOT', __DIR__);
|
|
define('UIH_DEBUG', is_file(UIH_ROOT . '/.debug'));
|
|
define('UIH_PUBLIC', UIH_ROOT . '/public');
|
|
define('UIH_SOURCE', UIH_ROOT . '/src');
|
|
define('UIH_LIBRARY', UIH_ROOT . '/lib');
|
|
define('UIH_VERSION', '20220715');
|
|
|
|
require_once UIH_LIBRARY . '/index/index.php';
|
|
|
|
Autoloader::addNamespace(__NAMESPACE__, UIH_SOURCE);
|
|
Environment::setDebug(UIH_DEBUG);
|
|
|
|
mb_internal_encoding('utf-8');
|
|
date_default_timezone_set('utc');
|
|
|
|
$configPath = UIH_ROOT . '/config.ini';
|
|
if(!is_file($configPath))
|
|
die('Uiharu configuration is missing.');
|
|
|
|
Config::load($configPath);
|
|
if(!Config::has('Database', 'dsn'))
|
|
die('Uiharu database is not configured.');
|
|
|
|
try {
|
|
$db = DbTools::create(Config::get('Database', 'dsn'));
|
|
} catch(ConnectionFailedException $ex) {
|
|
echo '<h3>Unable to connect to database</h3>';
|
|
die($ex->getMessage());
|
|
}
|