mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 17:29:21 +02:00

commit 94a61f32ae20d6b772ac90ef68ff983e1a082422 Merge: 57772569 8227303b Author: slawkens <slawkens@gmail.com> Date: Sat Nov 11 11:11:13 2023 +0100 Merge branch 'develop' into feature/debug-bar commit 577725690d177c6bb3af440e51b27a81b1723818 Author: slawkens <slawkens@gmail.com> Date: Mon Aug 21 11:08:12 2023 +0200 Add option to enable debugbar, even if dev mode is disabled commit c227fd4e9655f2dd7c1de0955f99e607c6881cbf Merge: 9fef84bf a692607c Author: slawkens <slawkens@gmail.com> Date: Mon Aug 21 10:20:04 2023 +0200 Merge branch 'develop' into feature/debug-bar commit 9fef84bffe63eb7bf0fcf68811873393164cb543 Author: slawkens <slawkens@gmail.com> Date: Fri Aug 11 06:39:50 2023 +0200 Fix debugBar mysql logs (Thanks @gpedro) commit dedd54286f6f086cb78287a5c1cd0f8cc9155984 Author: slawkens <slawkens@gmail.com> Date: Thu Aug 10 13:21:36 2023 +0200 Log PDO queries, as stated in docs, but doesn't work yet (don't know the reason) commit 7403a24030d75e525467dcaad937a4b14fd4ffae Author: slawkens <slawkens@gmail.com> Date: Thu Aug 10 13:21:20 2023 +0200 Use dev-master, cause of some bugs appearing commit cc7aec8e28c8839b2640ca9a7f62a1b4464fdbb3 Author: slawkens <slawkens@gmail.com> Date: Thu Aug 10 13:05:02 2023 +0200 Init debugBar
178 lines
4.4 KiB
PHP
178 lines
4.4 KiB
PHP
<?php
|
|
/**
|
|
* Initialize some defaults
|
|
*
|
|
* @package MyAAC
|
|
* @author Slawkens <slawkens@gmail.com>
|
|
* @copyright 2019 MyAAC
|
|
* @link https://my-aac.org
|
|
*/
|
|
|
|
use MyAAC\CsrfToken;
|
|
|
|
defined('MYAAC') or die('Direct access not allowed!');
|
|
|
|
if(!isset($config['installed']) || !$config['installed']) {
|
|
throw new RuntimeException('MyAAC has not been installed yet or there was error during installation. Please install again.');
|
|
}
|
|
|
|
use DebugBar\StandardDebugBar;
|
|
|
|
if(config('env') === 'dev') {
|
|
require SYSTEM . 'exception.php';
|
|
}
|
|
|
|
if (config('env') === 'dev' || getBoolean(config('enable_debugbar'))) {
|
|
$debugBar = new StandardDebugBar();
|
|
}
|
|
|
|
if(empty($config['server_path'])) {
|
|
throw new RuntimeException('Server Path has been not set. Go to config.php and set it.');
|
|
}
|
|
|
|
// take care of trailing slash at the end
|
|
if($config['server_path'][strlen($config['server_path']) - 1] !== '/')
|
|
$config['server_path'] .= '/';
|
|
|
|
// enable gzip compression if supported by the browser
|
|
if(isset($config['gzip_output']) && $config['gzip_output'] && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('ob_gzhandler'))
|
|
ob_start('ob_gzhandler');
|
|
|
|
// cache
|
|
require_once SYSTEM . 'libs/cache.php';
|
|
$cache = Cache::getInstance();
|
|
|
|
// event system
|
|
require_once SYSTEM . 'hooks.php';
|
|
$hooks = new Hooks();
|
|
$hooks->load();
|
|
|
|
// twig
|
|
require_once SYSTEM . 'twig.php';
|
|
|
|
// action, used by many pages
|
|
$action = $_REQUEST['action'] ?? '';
|
|
define('ACTION', $action);
|
|
|
|
// trim values we receive
|
|
if(isset($_POST))
|
|
{
|
|
foreach($_POST as $var => $value) {
|
|
if(is_string($value)) {
|
|
$_POST[$var] = trim($value);
|
|
}
|
|
}
|
|
}
|
|
if(isset($_GET))
|
|
{
|
|
foreach($_GET as $var => $value) {
|
|
if(is_string($value))
|
|
$_GET[$var] = trim($value);
|
|
}
|
|
}
|
|
if(isset($_REQUEST))
|
|
{
|
|
foreach($_REQUEST as $var => $value) {
|
|
if(is_string($value))
|
|
$_REQUEST[$var] = trim($value);
|
|
}
|
|
}
|
|
|
|
// load otserv config file
|
|
$config_lua_reload = true;
|
|
if($cache->enabled()) {
|
|
$tmp = null;
|
|
if($cache->fetch('server_path', $tmp) && $tmp == $config['server_path']) {
|
|
$tmp = null;
|
|
if($cache->fetch('config_lua', $tmp) && $tmp) {
|
|
$config['lua'] = unserialize($tmp);
|
|
$config_lua_reload = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
if($config_lua_reload) {
|
|
$config['lua'] = load_config_lua($config['server_path'] . 'config.lua');
|
|
|
|
// cache config
|
|
if($cache->enabled()) {
|
|
$cache->set('config_lua', serialize($config['lua']), 120);
|
|
$cache->set('server_path', $config['server_path']);
|
|
}
|
|
}
|
|
unset($tmp);
|
|
|
|
if(isset($config['lua']['servername']))
|
|
$config['lua']['serverName'] = $config['lua']['servername'];
|
|
|
|
if(isset($config['lua']['houserentperiod']))
|
|
$config['lua']['houseRentPeriod'] = $config['lua']['houserentperiod'];
|
|
|
|
// localize data/ directory based on data directory set in config.lua
|
|
foreach(array('dataDirectory', 'data_directory', 'datadir') as $key) {
|
|
if(!isset($config['lua'][$key][0])) {
|
|
break;
|
|
}
|
|
|
|
$foundValue = $config['lua'][$key];
|
|
if($foundValue[0] !== '/') {
|
|
$foundValue = $config['server_path'] . $foundValue;
|
|
}
|
|
|
|
if($foundValue[strlen($foundValue) - 1] !== '/') {// do not forget about trailing slash
|
|
$foundValue .= '/';
|
|
}
|
|
}
|
|
|
|
if(!isset($foundValue)) {
|
|
$foundValue = $config['server_path'] . 'data/';
|
|
}
|
|
|
|
$config['data_path'] = $foundValue;
|
|
unset($foundValue);
|
|
|
|
|
|
// POT
|
|
require_once SYSTEM . 'libs/pot/OTS.php';
|
|
$ots = POT::getInstance();
|
|
$eloquentConnection = null;
|
|
require_once SYSTEM . 'database.php';
|
|
|
|
// execute migrations
|
|
require SYSTEM . 'migrate.php';
|
|
|
|
// settings
|
|
require_once LIBS . 'Settings.php';
|
|
$settings = Settings::getInstance();
|
|
$settings->load();
|
|
|
|
// csrf protection
|
|
$token = getSession('csrf_token');
|
|
if (!isset($token) || !$token) {
|
|
CsrfToken::generate();
|
|
}
|
|
|
|
// deprecated config values
|
|
require_once SYSTEM . 'compat/config.php';
|
|
|
|
date_default_timezone_set(setting('core.date_timezone'));
|
|
|
|
setting(
|
|
[
|
|
'core.account_create_character_create',
|
|
setting('core.account_create_character_create') && (!setting('core.mail_enabled') || !setting('core.account_mail_verify'))
|
|
]
|
|
);
|
|
|
|
$settingsItemImagesURL = setting('core.item_images_url');
|
|
if($settingsItemImagesURL[strlen($settingsItemImagesURL) - 1] !== '/') {
|
|
setting(['core.item_images_url', $settingsItemImagesURL . '/']);
|
|
}
|
|
|
|
define('USE_ACCOUNT_NAME', $db->hasColumn('accounts', 'name'));
|
|
define('USE_ACCOUNT_NUMBER', $db->hasColumn('accounts', 'number'));
|
|
define('USE_ACCOUNT_SALT', $db->hasColumn('accounts', 'salt'));
|
|
|
|
require LIBS . 'Towns.php';
|
|
Towns::load();
|