2022-07-14 20:42:37 +00:00
|
|
|
<?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');
|
2023-01-25 13:37:38 +00:00
|
|
|
define('UIH_VERSION', '20230125');
|
2022-07-14 20:42:37 +00:00
|
|
|
|
|
|
|
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());
|
|
|
|
}
|
2022-07-15 22:20:20 +00:00
|
|
|
|
|
|
|
$ctx = new UihContext($db);
|