1
0
Fork 0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-03-20 23:22:56 +03:00
rss-bridge/index.php

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
1.4 KiB
PHP
Raw Normal View History

<?php
require_once __DIR__ . '/lib/rssbridge.php';
Configuration::verifyInstallation();
Configuration::loadConfiguration();
Authentication::showPromptIfNeeded();
2016-09-10 21:01:02 +02:00
try {
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)) {
http_response_code(400);
print render('error.html.php', [
'title' => '400 Bad Request',
'message' => "Query parameter \"$key\" is not a string.",
]);
exit(1);
}
}
2022-07-06 12:14:04 +02:00
$actionFactory = new ActionFactory();
2016-09-10 21:01:02 +02:00
if (array_key_exists('action', $request)) {
$action = $actionFactory->create($request['action']);
$action->execute($request);
} else {
2019-02-06 18:34:51 +01:00
$showInactive = filter_input(INPUT_GET, 'show_inactive', FILTER_VALIDATE_BOOLEAN);
echo BridgeList::create($showInactive);
2016-09-10 21:01:02 +02:00
}
2022-06-24 18:29:35 +02:00
} catch (\Throwable $e) {
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);
print render('error.html.php', [
2022-07-08 20:39:13 +02:00
'message' => $message,
'stacktrace' => create_sane_stacktrace($e),
]);
}