forked from mikespub-org/seblucas-cops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeed.php
45 lines (39 loc) · 1.13 KB
/
feed.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
<?php
/**
* COPS (Calibre OPDS PHP Server) main script
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Sébastien Lucas <[email protected]>
*
*/
use SebLucas\Cops\Input\Config;
use SebLucas\Cops\Input\Request;
use SebLucas\Cops\Output\OPDSRenderer;
use SebLucas\Cops\Pages\PageId;
require_once __DIR__ . '/config.php';
$request = new Request();
$page = $request->get('page', PageId::INDEX);
$query = $request->get('query');
if ($query) {
$page = PageId::OPENSEARCH_QUERY;
}
// @todo handle special case of OPDS not expecting filter while HTML does better
$request->set('filter', null);
if (Config::get('fetch_protect') == '1') {
session_start();
if (!isset($_SESSION['connected'])) {
$_SESSION['connected'] = 0;
}
}
header('Content-Type:application/xml');
$OPDSRender = new OPDSRenderer();
switch ($page) {
case PageId::OPENSEARCH :
echo $OPDSRender->getOpenSearch($request);
return;
default:
$currentPage = PageId::getPage($page, $request);
$currentPage->InitializeContent();
echo $OPDSRender->render($currentPage, $request);
return;
}