szurubooru/src/core.php

44 lines
1.3 KiB
PHP
Raw Normal View History

2013-10-09 19:23:39 +02:00
<?php
2013-11-05 14:42:46 +01:00
define('SZURU_VERSION', '0.3.0');
2013-10-20 11:12:56 +02:00
define('SZURU_LINK', 'http://github.com/rr-/szurubooru');
2013-11-17 13:02:41 +01:00
$startTime = microtime(true);
2013-10-12 22:54:25 +02:00
2013-11-13 23:36:58 +01:00
$requiredExtensions = ['pdo', 'pdo_sqlite', 'gd', 'openssl'];
foreach ($requiredExtensions as $ext)
if (!extension_loaded($ext))
die('PHP extension "' . $ext . '" must be enabled to continue.' . PHP_EOL);
2013-10-09 19:23:39 +02:00
date_default_timezone_set('UTC');
setlocale(LC_CTYPE, 'en_US.UTF-8');
ini_set('memory_limit', '128M');
2013-10-09 19:23:39 +02:00
define('DS', DIRECTORY_SEPARATOR);
2013-11-13 23:36:58 +01:00
require_once __DIR__ . '/../lib/php-markdown/Michelf/Markdown.php';
require_once __DIR__ . '/../lib/redbean/RedBean/redbean.inc.php';
require_once __DIR__ . '/../lib/chibi-core/Facade.php';
2013-10-09 19:23:39 +02:00
2013-11-17 13:02:41 +01:00
\Chibi\AutoLoader::init(__DIR__);
\Chibi\Facade::init();
$config = \Chibi\Registry::getConfig();
$context = \Chibi\Registry::getContext();
$context->startTime = $startTime;
2013-10-12 14:53:47 +02:00
R::setup('sqlite:' . $config->main->dbPath);
2013-10-20 11:05:46 +02:00
R::freeze(true);
R::dependencies(['tag' => ['post'], 'favoritee' => ['post', 'user'], 'comment' => ['post', 'user']]);
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);
2013-10-16 19:45:57 +02:00
function queryLogger()
{
static $queryLogger = null;
if ($queryLogger === null)
$queryLogger = RedBean_Plugin_QueryLogger::getInstanceAndAttach(R::getDatabaseAdapter());
return $queryLogger;
}
queryLogger();