2017-12-16 19:17:29 +00:00
|
|
|
<?php
|
|
|
|
namespace Misuzu;
|
|
|
|
|
|
|
|
require_once 'vendor/autoload.php';
|
2018-01-02 19:37:13 +00:00
|
|
|
|
2018-01-04 20:01:55 +00:00
|
|
|
$app = Application::start(
|
|
|
|
__DIR__ . '/config/config.ini',
|
|
|
|
IO\Directory::exists(__DIR__ . '/vendor/phpunit/phpunit')
|
|
|
|
);
|
2018-01-03 21:39:01 +00:00
|
|
|
$app->startDatabase();
|
2018-03-14 01:39:02 +00:00
|
|
|
|
|
|
|
if (PHP_SAPI !== 'cli') {
|
2018-03-24 04:31:42 +00:00
|
|
|
$storage_dir = $app->getStoragePath();
|
|
|
|
if (!$storage_dir->isReadable()
|
|
|
|
|| !$storage_dir->isWritable()) {
|
|
|
|
echo 'Cannot access storage directory.';
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$app->inDebugMode()) {
|
|
|
|
ob_start('ob_gzhandler');
|
|
|
|
}
|
2018-03-14 01:39:02 +00:00
|
|
|
|
2018-03-31 22:28:32 +00:00
|
|
|
if ($app->config->get('Auth', 'lockdown', 'bool', false)) {
|
|
|
|
http_response_code(503);
|
|
|
|
$app->startTemplating();
|
|
|
|
$app->templating->addPath('auth', __DIR__ . '/views/auth');
|
|
|
|
echo $app->templating->render('lockdown');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($_COOKIE['msz_uid'], $_COOKIE['msz_sid'])) {
|
|
|
|
$app->startSession((int)$_COOKIE['msz_uid'], $_COOKIE['msz_sid']);
|
2018-04-17 21:01:49 +00:00
|
|
|
$session = $app->getSession();
|
|
|
|
|
|
|
|
if ($session !== null) {
|
|
|
|
$session->user->last_seen = \Carbon\Carbon::now();
|
|
|
|
$session->user->last_ip = \Misuzu\Net\IPAddress::remote();
|
|
|
|
$session->user->save();
|
|
|
|
}
|
2018-03-31 22:28:32 +00:00
|
|
|
}
|
|
|
|
|
2018-03-28 00:35:37 +00:00
|
|
|
$manage_mode = starts_with($_SERVER['REQUEST_URI'], '/manage');
|
|
|
|
|
2018-03-14 01:39:02 +00:00
|
|
|
$app->startTemplating();
|
2018-03-28 00:35:37 +00:00
|
|
|
$app->templating->addPath('mio', __DIR__ . '/views/mio');
|
|
|
|
|
|
|
|
if ($manage_mode) {
|
2018-04-23 03:00:55 +00:00
|
|
|
if ($app->getSession() === null || $app->getSession()->user->user_id !== 1) {
|
2018-03-28 00:35:37 +00:00
|
|
|
http_response_code(403);
|
|
|
|
echo $app->templating->render('errors.403');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$app->templating->addPath('manage', __DIR__ . '/views/manage');
|
|
|
|
}
|
2018-03-14 01:39:02 +00:00
|
|
|
}
|