2013-08-09 18:57:25 +02:00
|
|
|
<?php
|
2018-06-27 18:09:41 +01:00
|
|
|
|
2022-04-13 21:04:10 +02:00
|
|
|
require_once __DIR__ . '/lib/rssbridge.php';
|
2018-06-27 18:09:41 +01:00
|
|
|
|
2022-08-06 22:46:28 +02:00
|
|
|
try {
|
|
|
|
Configuration::verifyInstallation();
|
|
|
|
Configuration::loadConfiguration();
|
2022-08-02 15:03:54 +02:00
|
|
|
|
2022-08-06 22:46:28 +02:00
|
|
|
date_default_timezone_set(Configuration::getConfig('system', 'timezone'));
|
2022-08-02 15:03:54 +02:00
|
|
|
|
2022-08-06 22:46:28 +02:00
|
|
|
define('CUSTOM_CACHE_TIMEOUT', Configuration::getConfig('cache', 'custom_timeout'));
|
2022-08-02 15:03:54 +02:00
|
|
|
|
2022-08-06 22:46:28 +02:00
|
|
|
$authenticationMiddleware = new AuthenticationMiddleware();
|
|
|
|
if (Configuration::getConfig('authentication', 'enable')) {
|
|
|
|
$authenticationMiddleware();
|
|
|
|
}
|
2022-07-10 20:05:27 +02:00
|
|
|
|
2022-07-10 19:50:51 +02:00
|
|
|
if (isset($argv)) {
|
|
|
|
parse_str(implode('&', array_slice($argv, 1)), $cliArgs);
|
|
|
|
$request = $cliArgs;
|
|
|
|
} else {
|
|
|
|
$request = $_GET;
|
|
|
|
}
|
|
|
|
foreach ($request as $key => $value) {
|
|
|
|
if (! is_string($value)) {
|
2022-08-06 22:46:28 +02:00
|
|
|
throw new \Exception("Query parameter \"$key\" is not a string.");
|
2022-07-10 19:50:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-06 12:14:04 +02:00
|
|
|
$actionFactory = new ActionFactory();
|
2016-09-10 21:01:02 +02:00
|
|
|
|
2022-07-08 21:06:14 +02:00
|
|
|
if (array_key_exists('action', $request)) {
|
|
|
|
$action = $actionFactory->create($request['action']);
|
|
|
|
|
|
|
|
$action->execute($request);
|
2018-07-21 18:15:07 +02:00
|
|
|
} else {
|
2019-02-06 18:34:51 +01:00
|
|
|
$showInactive = filter_input(INPUT_GET, 'show_inactive', FILTER_VALIDATE_BOOLEAN);
|
2018-11-10 22:26:56 +01:00
|
|
|
echo BridgeList::create($showInactive);
|
2016-09-10 21:01:02 +02:00
|
|
|
}
|
2022-06-24 18:29:35 +02:00
|
|
|
} catch (\Throwable $e) {
|
2018-10-24 15:50:48 +02:00
|
|
|
error_log($e);
|
2022-07-08 20:39:13 +02:00
|
|
|
|
|
|
|
$message = sprintf(
|
|
|
|
'Uncaught Exception %s: %s at %s line %s',
|
|
|
|
get_class($e),
|
|
|
|
$e->getMessage(),
|
|
|
|
trim_path_prefix($e->getFile()),
|
|
|
|
$e->getLine()
|
|
|
|
);
|
|
|
|
|
|
|
|
http_response_code(500);
|
2022-07-08 14:17:25 +02:00
|
|
|
print render('error.html.php', [
|
2022-07-08 20:39:13 +02:00
|
|
|
'message' => $message,
|
|
|
|
'stacktrace' => create_sane_stacktrace($e),
|
2022-07-08 14:17:25 +02:00
|
|
|
]);
|
2013-08-09 18:57:25 +02:00
|
|
|
}
|