blob: 17613e9276cdb2e28c62bda02e20dcd431402b09 (
plain)
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
|
<?php
$format = $_REQUEST['format'];
if (!in_array($format, ['atom', 'rss'])) {
header('HTTP/1.1 400');
die('Invalid feed format.');
}
$params = explode('/', $_REQUEST['query']);
if (count($params) < 2) {
header('HTTP/1.1 400');
die('Not enough parameters.');
}
$provider = ucfirst(array_shift($params));
$feed = array_shift($params);
$parsedParams = [];
foreach ($params as $param) {
$splitParam = explode(':', $param, 2);
$parsedParams[$splitParam[0]] = count($splitParam) > 1 ? $plitParam[1] : TRUE;
}
require_once('../providers/' . $provider . '.php');
$provider = '\\Providers\\' . $provider;
$provider = new $provider($feed, $parsedParams);
$content = $provider->get();
require_once('../lib/smarty3/Smarty.class.php');
$smarty = new Smarty();
$smarty->setCacheDir('../cache/smarty');
$smarty->setCompileDir('../cache/smarty/compile');
$smarty->setTemplateDir('../templates');
$smarty->assign('feedID', 'http://rss.emkael.info'.$_SERVER['REQUEST_URI']);
$smarty->assign('feedTitle', $provider->title());
$smarty->assign('cacheTime', $provider->cacheTime());
$smarty->assign('user', $feed);
$smarty->assign('content', $provider->get());
switch ($format) {
case 'rss':
header('Content-Type: application/rss+xml');
$smarty->display('rss.tpl');
break;
case 'atom':
default:
header('Content-Type: application/atom+xml');
$smarty->display('atom.tpl');
break;
}
?>
|