Code

< 40 %
40-60 %
> 60 %
1
<?php
2
/**
3
 * COPS (Calibre OPDS PHP Server) main script
4
 *
5
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6
 * @author     Sébastien Lucas <[email protected]>
7
 *
8
 */
9
10
    require_once 'config.php';
11
    require_once 'base.php';
12
13
    header('Content-Type:application/xml');
14
    $page = getURLParam('page', Base::PAGE_INDEX);
15
    $query = getURLParam('query');
16
    $n = getURLParam('n', '1');
17
    if ($query) {
18
        $page = Base::PAGE_OPENSEARCH_QUERY;
19
    }
20
    $qid = getURLParam('id');
21
22
    if ($config ['cops_fetch_protect'] == '1') {
23
        session_start();
24
        if (!isset($_SESSION['connected'])) {
25
            $_SESSION['connected'] = 0;
26
        }
27
    }
28
29
    $OPDSRender = new OPDSRenderer();
30
31
    switch ($page) {
32
        case Base::PAGE_OPENSEARCH :
33
            echo $OPDSRender->getOpenSearch();
34
            return;
35
        default:
36
            $currentPage = Page::getPage($page, $qid, $query, $n);
37
            $currentPage->InitializeContent();
38
            echo $OPDSRender->render($currentPage);
39
            return;
40
    }
41