2017-03-30 16:49:48 -04:00
|
|
|
<?php declare(strict_types=1);
|
2015-06-16 11:11:35 -04:00
|
|
|
/**
|
2017-03-30 16:49:48 -04:00
|
|
|
* Hummingbird Anime List Client
|
2015-11-16 11:40:01 -05:00
|
|
|
*
|
2018-08-22 13:48:27 -04:00
|
|
|
* An API client for Kitsu to manage anime and manga watch lists
|
2015-11-16 11:40:01 -05:00
|
|
|
*
|
2021-02-04 11:57:01 -05:00
|
|
|
* PHP version 8
|
2016-08-30 10:57:41 -04:00
|
|
|
*
|
2015-11-16 11:40:01 -05:00
|
|
|
* @package HummingbirdAnimeClient
|
2016-08-30 10:57:41 -04:00
|
|
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
2021-01-13 01:52:03 -05:00
|
|
|
* @copyright 2015 - 2021 Timothy J. Warren
|
2016-08-30 10:57:41 -04:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
2020-12-10 17:06:50 -05:00
|
|
|
* @version 5.2
|
2017-03-30 16:49:48 -04:00
|
|
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
2015-06-16 11:11:35 -04:00
|
|
|
*/
|
2017-03-30 16:49:48 -04:00
|
|
|
|
2016-12-20 12:58:37 -05:00
|
|
|
namespace Aviat\AnimeClient;
|
|
|
|
|
2018-08-24 14:37:53 -04:00
|
|
|
use Aviat\AnimeClient\Types\Config as ConfigType;
|
2021-02-18 12:48:59 -05:00
|
|
|
use Whoops\Handler;
|
2020-03-12 12:04:20 -04:00
|
|
|
use Whoops\Run;
|
2021-02-18 12:48:59 -05:00
|
|
|
use Whoops\Util;
|
2017-03-30 16:57:58 -04:00
|
|
|
use function Aviat\Ion\_dir;
|
2015-10-09 14:34:55 -04:00
|
|
|
|
2018-10-26 13:08:45 -04:00
|
|
|
setlocale(LC_CTYPE, 'en_US');
|
|
|
|
|
2017-02-22 15:08:29 -05:00
|
|
|
// Load composer autoloader
|
2017-12-06 14:40:13 -05:00
|
|
|
require_once __DIR__ . '/vendor/autoload.php';
|
2015-09-14 10:54:50 -04:00
|
|
|
|
2020-05-08 19:15:21 -04:00
|
|
|
if (file_exists('.is-dev'))
|
2018-08-08 13:05:38 -04:00
|
|
|
{
|
2020-03-12 12:04:20 -04:00
|
|
|
$whoops = new Run;
|
2021-02-18 12:48:59 -05:00
|
|
|
$whoops->pushHandler(new Handler\PrettyPageHandler);
|
|
|
|
|
|
|
|
if (Util\Misc::isAjaxRequest()) {
|
|
|
|
$whoops->pushHandler(new Handler\JsonResponseHandler);
|
|
|
|
}
|
|
|
|
|
2018-08-08 13:05:38 -04:00
|
|
|
$whoops->register();
|
|
|
|
}
|
2017-12-08 22:32:00 -05:00
|
|
|
|
2016-01-06 15:44:40 -05:00
|
|
|
// Define base directories
|
|
|
|
$APP_DIR = _dir(__DIR__, 'app');
|
2017-02-10 15:50:07 -05:00
|
|
|
$APPCONF_DIR = _dir($APP_DIR, 'appConf');
|
2016-01-06 15:44:40 -05:00
|
|
|
$CONF_DIR = _dir($APP_DIR, 'config');
|
|
|
|
|
2015-10-09 14:34:55 -04:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Dependency Injection setup
|
|
|
|
// -----------------------------------------------------------------------------
|
2018-11-27 14:57:27 -05:00
|
|
|
$baseConfig = require "{$APPCONF_DIR}/base_config.php";
|
|
|
|
$di = require "{$APP_DIR}/bootstrap.php";
|
2016-01-06 15:44:40 -05:00
|
|
|
|
2020-12-11 15:37:55 -05:00
|
|
|
$config = loadConfig($CONF_DIR);
|
2018-10-08 15:45:46 -04:00
|
|
|
|
2018-11-27 14:57:27 -05:00
|
|
|
$overrideFile = "{$CONF_DIR}/admin-override.toml";
|
2018-10-08 15:45:46 -04:00
|
|
|
$overrideConfig = file_exists($overrideFile)
|
|
|
|
? loadTomlFile($overrideFile)
|
|
|
|
: [];
|
|
|
|
|
2018-10-08 16:38:08 -04:00
|
|
|
$configArray = array_replace_recursive($baseConfig, $config, $overrideConfig);
|
2016-02-10 17:30:45 -05:00
|
|
|
|
2020-04-22 07:53:52 -04:00
|
|
|
$checkedConfig = ConfigType::check($configArray);
|
2020-04-22 11:39:44 -04:00
|
|
|
|
|
|
|
// Set the timezone for date display
|
|
|
|
// First look in app config, then PHP config, and at last
|
|
|
|
// resort, just set to UTC.
|
|
|
|
$timezone = ini_get('date.timezone');
|
2021-02-16 14:43:51 -05:00
|
|
|
if (is_array($checkedConfig) && array_key_exists('timezone', $checkedConfig) && ! empty($checkedConfig['timezone']))
|
2020-04-22 11:39:44 -04:00
|
|
|
{
|
|
|
|
date_default_timezone_set($checkedConfig['timezone']);
|
|
|
|
}
|
2021-02-11 19:54:22 -05:00
|
|
|
else if (is_string($timezone) && $timezone !== '')
|
2020-04-22 11:39:44 -04:00
|
|
|
{
|
|
|
|
date_default_timezone_set($timezone);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
date_default_timezone_set('UTC');
|
|
|
|
}
|
|
|
|
|
2018-08-24 14:37:53 -04:00
|
|
|
$container = $di($checkedConfig);
|
2016-02-10 17:30:45 -05:00
|
|
|
|
2016-01-06 15:44:40 -05:00
|
|
|
// Unset 'constants'
|
2018-08-24 14:37:53 -04:00
|
|
|
unset($APP_DIR, $CONF_DIR, $APPCONF_DIR);
|
2016-01-06 15:44:40 -05:00
|
|
|
|
2015-10-09 14:34:55 -04:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Dispatch to the current route
|
|
|
|
// -----------------------------------------------------------------------------
|
2017-12-06 14:40:13 -05:00
|
|
|
$container->get('dispatcher')();
|