From 5780917e82ebd7f96af1dc882fba5e44ba4cc39e Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Thu, 21 Nov 2013 14:23:20 +0100 Subject: [PATCH] Moved stuff to /data/ "Stuff" means: - Config - Local config - SQLite db file - Files - Thumbnails - Logs --- .gitignore => data/.gitignore | 0 config.ini => data/config.ini | 14 +++++++------- {files => data/files}/.gitignore | 0 {logs => data/logs}/.gitignore | 0 {thumbs => data/thumbs}/.gitignore | 0 src/core.php | 27 +++++++++++++++++++++------ 6 files changed, 28 insertions(+), 13 deletions(-) rename .gitignore => data/.gitignore (100%) rename config.ini => data/config.ini (93%) rename {files => data/files}/.gitignore (100%) rename {logs => data/logs}/.gitignore (100%) rename {thumbs => data/thumbs}/.gitignore (100%) diff --git a/.gitignore b/data/.gitignore similarity index 100% rename from .gitignore rename to data/.gitignore diff --git a/config.ini b/data/config.ini similarity index 93% rename from config.ini rename to data/config.ini index 3905d9c3..b8b0cd35 100644 --- a/config.ini +++ b/data/config.ini @@ -2,13 +2,13 @@ prettyPrint=1 [main] -dbPath=./db.sqlite -filesPath=./files/ -thumbsPath=./thumbs/ -mediaPath=./public_html/media/ -title=szurubooru -salt = "1A2/$_4xVa" -logsPath=./logs/ +dbPath = "./data/db.sqlite" +filesPath = "./data/files/" +thumbsPath = "./data/thumbs/" +logsPath = "./data/logs/" +mediaPath = "./public_html/media/" +title = "szurubooru" +salt = "1A2/$_4xVa" [misc] featuredPostMaxDays=7 diff --git a/files/.gitignore b/data/files/.gitignore similarity index 100% rename from files/.gitignore rename to data/files/.gitignore diff --git a/logs/.gitignore b/data/logs/.gitignore similarity index 100% rename from logs/.gitignore rename to data/logs/.gitignore diff --git a/thumbs/.gitignore b/data/thumbs/.gitignore similarity index 100% rename from thumbs/.gitignore rename to data/thumbs/.gitignore diff --git a/src/core.php b/src/core.php index 41e6c470..241ed27f 100644 --- a/src/core.php +++ b/src/core.php @@ -2,30 +2,45 @@ define('SZURU_VERSION', '0.4.1'); define('SZURU_LINK', 'http://github.com/rr-/szurubooru'); +//basic settings and preparation define('DS', DIRECTORY_SEPARATOR); $startTime = microtime(true); $rootDir = __DIR__ . DS . '..' . DS; +date_default_timezone_set('UTC'); +setlocale(LC_CTYPE, 'en_US.UTF-8'); +ini_set('memory_limit', '128M'); +//extension sanity checks $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); -date_default_timezone_set('UTC'); -setlocale(LC_CTYPE, 'en_US.UTF-8'); -ini_set('memory_limit', '128M'); - +//basic include calls, autoloader init require_once $rootDir . 'lib' . DS . 'php-markdown' . DS . 'Michelf' . DS . 'Markdown.php'; require_once $rootDir . 'lib' . DS . 'redbean' . DS . 'RedBean' . DS . 'redbean.inc.php'; require_once $rootDir . 'lib' . DS . 'chibi-core' . DS . 'Facade.php'; - \Chibi\AutoLoader::init(__DIR__); + +//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); + +//prepare context \Chibi\Facade::init(); -$config = \Chibi\Registry::getConfig(); $context = \Chibi\Registry::getContext(); $context->startTime = $startTime; $context->rootDir = $rootDir; +//load database R::setup('sqlite:' . $config->main->dbPath); R::freeze(true); R::dependencies(['tag' => ['post'], 'favoritee' => ['post', 'user'], 'comment' => ['post', 'user']]);