forked from RSS-Bridge/rss-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
56 lines (45 loc) · 1.53 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
require_once __DIR__ . '/lib/rssbridge.php';
try {
Configuration::verifyInstallation();
Configuration::loadConfiguration();
date_default_timezone_set(Configuration::getConfig('system', 'timezone'));
define('CUSTOM_CACHE_TIMEOUT', Configuration::getConfig('cache', 'custom_timeout'));
$authenticationMiddleware = new AuthenticationMiddleware();
if (Configuration::getConfig('authentication', 'enable')) {
$authenticationMiddleware();
}
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)) {
throw new \Exception("Query parameter \"$key\" is not a string.");
}
}
$actionFactory = new ActionFactory();
if (array_key_exists('action', $request)) {
$action = $actionFactory->create($request['action']);
$action->execute($request);
} else {
$showInactive = filter_input(INPUT_GET, 'show_inactive', FILTER_VALIDATE_BOOLEAN);
echo BridgeList::create($showInactive);
}
} catch (\Throwable $e) {
error_log($e);
$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', [
'message' => $message,
'stacktrace' => create_sane_stacktrace($e),
]);
}