['Tag', 'tags'], 'lib/pages' => ['Page', 'pages'], 'lib/posts' => ['Post', 'posts'], 'lib/uploads' => ['Upload', 'uploads'], 'engine/model' => ['model'], 'engine/skin' => ['SkinContext'], ]; if (str_ends_with($class, 'Handler')) { $path = APP_ROOT.'/handler/'.str_replace('\\', '/', $class).'.php'; } else { foreach ($libs as $lib_file => $class_names) { if (in_array($class, $class_names)) { $path = APP_ROOT.'/'.$lib_file.'.php'; break; } } } if (!isset($path)) $path = APP_ROOT.'/lib/'.$class.'.php'; if (!is_file($path)) return; require_once $path; }); if (!file_exists(APP_ROOT.'/config.yaml')) die('Fatal: config.yaml not found'); $config = yaml_parse_file(APP_ROOT.'/config.yaml'); if ($config === false) die('Fatal: failed to parse config.yaml'); // i know what i'm doing. do you? umask($config['umask']); require_once 'functions.php'; require_once 'engine/mysql.php'; require_once 'engine/router.php'; require_once 'engine/request.php'; require_once 'engine/logging.php'; try { if (is_cli()) { verify_hostname($config['domain']); $_SERVER['HTTP_HOST'] = $config['domain']; $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; } else { verify_hostname(); if (array_key_exists('HTTP_X_REAL_IP', $_SERVER)) $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_REAL_IP']; require_once 'engine/strings.php'; require_once 'engine/skin.php'; require_once 'lib/admin.php'; } } catch (RuntimeException $e) { die('Fatal error: '.$e->getMessage()); } $__logger = is_dev() ? new FileLogger(APP_ROOT.'/log/debug.log') : new DatabaseLogger(); $__logger->enable(); if (!is_dev()) { if (file_exists(APP_ROOT.'/config-static.php')) $config['static'] = require_once 'config-static.php'; else die('confic-static.php not found'); // turn off errors output on production domains error_reporting(0); ini_set('display_errors', 0); } if (!is_cli()) { $__lang = Strings::getInstance(); $__lang->load('main'); } require 'vendor/autoload.php';