2013-10-09 19:23:39 +02:00
|
|
|
<?php
|
2014-02-13 09:39:09 +01:00
|
|
|
define('SZURU_VERSION', '0.6.1');
|
2013-10-20 11:12:56 +02:00
|
|
|
define('SZURU_LINK', 'http://github.com/rr-/szurubooru');
|
|
|
|
|
2013-11-21 14:23:20 +01:00
|
|
|
//basic settings and preparation
|
2013-11-17 14:39:50 +01:00
|
|
|
define('DS', DIRECTORY_SEPARATOR);
|
2013-11-17 13:02:41 +01:00
|
|
|
$startTime = microtime(true);
|
2013-11-17 14:39:50 +01:00
|
|
|
$rootDir = __DIR__ . DS . '..' . DS;
|
2013-11-21 14:23:20 +01:00
|
|
|
date_default_timezone_set('UTC');
|
|
|
|
setlocale(LC_CTYPE, 'en_US.UTF-8');
|
|
|
|
ini_set('memory_limit', '128M');
|
2013-10-12 22:54:25 +02:00
|
|
|
|
2013-11-21 14:23:20 +01:00
|
|
|
//basic include calls, autoloader init
|
2013-11-17 14:39:50 +01:00
|
|
|
require_once $rootDir . 'lib' . DS . 'php-markdown' . DS . 'Michelf' . DS . 'Markdown.php';
|
|
|
|
require_once $rootDir . 'lib' . DS . 'chibi-core' . DS . 'Facade.php';
|
2014-02-28 20:35:12 +01:00
|
|
|
\Chibi\AutoLoader::init([__DIR__, $rootDir . 'lib' . DS . 'chibi-sql']);
|
2013-11-21 14:23:20 +01:00
|
|
|
|
|
|
|
//load config manually
|
|
|
|
$configPaths =
|
|
|
|
[
|
|
|
|
$rootDir . DS . 'data' . DS . 'config.ini',
|
|
|
|
$rootDir . DS . 'data' . DS . 'local.ini',
|
|
|
|
];
|
|
|
|
$config = new \Chibi\Config();
|
|
|
|
foreach ($configPaths as $path)
|
|
|
|
if (file_exists($path))
|
|
|
|
$config->loadIni($path);
|
|
|
|
\Chibi\Registry::setConfig($config);
|
|
|
|
|
2013-12-14 11:14:36 +01:00
|
|
|
//extension sanity checks
|
|
|
|
$requiredExtensions = ['pdo', 'pdo_' . $config->main->dbDriver, 'gd', 'openssl', 'fileinfo'];
|
|
|
|
foreach ($requiredExtensions as $ext)
|
|
|
|
if (!extension_loaded($ext))
|
|
|
|
die('PHP extension "' . $ext . '" must be enabled to continue.' . PHP_EOL);
|
|
|
|
|
2013-11-21 14:23:20 +01:00
|
|
|
//prepare context
|
2013-11-17 13:02:41 +01:00
|
|
|
\Chibi\Facade::init();
|
|
|
|
$context = \Chibi\Registry::getContext();
|
|
|
|
$context->startTime = $startTime;
|
2013-11-17 14:39:50 +01:00
|
|
|
$context->rootDir = $rootDir;
|
2013-10-12 14:53:47 +02:00
|
|
|
|
2014-02-28 20:35:12 +01:00
|
|
|
\Chibi\Database::connect(
|
|
|
|
$config->main->dbDriver,
|
|
|
|
TextHelper::absolutePath($config->main->dbLocation),
|
|
|
|
$config->main->dbUser,
|
|
|
|
$config->main->dbPass);
|
2013-10-12 14:53:47 +02:00
|
|
|
|
|
|
|
//wire models
|
|
|
|
foreach (\Chibi\AutoLoader::getAllIncludablePaths() as $path)
|
|
|
|
if (preg_match('/Model/', $path))
|
|
|
|
\Chibi\AutoLoader::safeInclude($path);
|