2013-10-09 19:23:39 +02:00
|
|
|
<?php
|
2013-10-12 22:54:25 +02:00
|
|
|
function trueStartTime()
|
|
|
|
{
|
|
|
|
static $time = null;
|
|
|
|
if ($time === null)
|
|
|
|
$time = microtime(true);
|
|
|
|
return $time;
|
|
|
|
}
|
|
|
|
trueStartTime();
|
|
|
|
|
2013-10-09 19:23:39 +02:00
|
|
|
require_once 'lib/redbean/RedBean/redbean.inc.php';
|
|
|
|
require_once 'lib/chibi-core/Facade.php';
|
2013-10-16 19:45:57 +02:00
|
|
|
require_once 'lib/chibi-core/Registry.php';
|
2013-10-09 19:23:39 +02:00
|
|
|
|
|
|
|
date_default_timezone_set('UTC');
|
|
|
|
setlocale(LC_CTYPE, 'en_US.UTF-8');
|
2013-10-13 13:34:30 +02:00
|
|
|
ini_set('memory_limit', '128M');
|
2013-10-09 19:23:39 +02:00
|
|
|
define('DS', DIRECTORY_SEPARATOR);
|
|
|
|
|
|
|
|
function configFactory()
|
|
|
|
{
|
2013-10-12 14:53:47 +02:00
|
|
|
static $config = null;
|
2013-10-09 19:23:39 +02:00
|
|
|
|
2013-10-12 14:53:47 +02:00
|
|
|
if ($config === null)
|
2013-10-09 19:23:39 +02:00
|
|
|
{
|
2013-10-12 14:53:47 +02:00
|
|
|
$config = new \Chibi\Config();
|
|
|
|
$configPaths =
|
|
|
|
[
|
|
|
|
__DIR__ . DS . '../config.ini',
|
|
|
|
__DIR__ . DS . '../local.ini'
|
|
|
|
];
|
|
|
|
$configPaths = array_filter($configPaths, 'file_exists');
|
|
|
|
|
|
|
|
foreach ($configPaths as $path)
|
|
|
|
{
|
|
|
|
$config->loadIni($path);
|
|
|
|
}
|
2013-10-09 19:23:39 +02:00
|
|
|
|
2013-10-12 14:53:47 +02:00
|
|
|
}
|
2013-10-09 19:23:39 +02:00
|
|
|
return $config;
|
|
|
|
}
|
2013-10-12 14:53:47 +02:00
|
|
|
|
|
|
|
$config = configFactory();
|
|
|
|
R::setup('sqlite:' . $config->main->dbPath);
|
2013-10-15 13:14:48 +02:00
|
|
|
R::dependencies(['tag' => ['post'], 'favoritee' => ['post', 'user']]);
|
2013-10-12 14:53:47 +02:00
|
|
|
|
|
|
|
//wire models
|
|
|
|
\Chibi\AutoLoader::init([$config->chibi->userCodeDir, __DIR__]);
|
|
|
|
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();
|