2016-12-21 18:48:44 +01:00
|
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* COPS (Calibre OPDS PHP Server) main script
|
|
|
|
|
*
|
|
|
|
|
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
2016-12-22 01:51:06 +01:00
|
|
|
|
* @author S<EFBFBD>bastien Lucas <sebastien@slucas.fr>
|
2016-12-21 18:48:44 +01:00
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2016-12-22 01:51:06 +01:00
|
|
|
|
require_once ("config.php");
|
|
|
|
|
require_once ("base.php");
|
|
|
|
|
require_once ("author.php");
|
|
|
|
|
require_once ("serie.php");
|
|
|
|
|
require_once ("tag.php");
|
|
|
|
|
require_once ("book.php");
|
|
|
|
|
require_once ("OPDS_renderer.php");
|
2016-12-21 18:48:44 +01:00
|
|
|
|
|
2016-12-22 01:51:06 +01:00
|
|
|
|
header ("Content-Type:application/xml");
|
|
|
|
|
$page = getURLParam ("page", Base::PAGE_INDEX);
|
|
|
|
|
$query = getURLParam ("query");
|
|
|
|
|
$n = getURLParam ("n", "1");
|
|
|
|
|
if ($query)
|
2016-12-21 18:48:44 +01:00
|
|
|
|
$page = Base::PAGE_OPENSEARCH_QUERY;
|
2016-12-22 01:51:06 +01:00
|
|
|
|
$qid = getURLParam ("id");
|
2016-12-21 18:48:44 +01:00
|
|
|
|
|
2016-12-22 01:51:06 +01:00
|
|
|
|
if ($config ['cops_fetch_protect'] == "1") {
|
2016-12-21 18:48:44 +01:00
|
|
|
|
session_start();
|
|
|
|
|
if (!isset($_SESSION['connected'])) {
|
|
|
|
|
$_SESSION['connected'] = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-22 01:51:06 +01:00
|
|
|
|
$OPDSRender = new OPDSRenderer ();
|
2016-12-21 18:48:44 +01:00
|
|
|
|
|
|
|
|
|
switch ($page) {
|
|
|
|
|
case Base::PAGE_OPENSEARCH :
|
2016-12-22 01:51:06 +01:00
|
|
|
|
echo $OPDSRender->getOpenSearch ();
|
2016-12-21 18:48:44 +01:00
|
|
|
|
return;
|
|
|
|
|
default:
|
2016-12-22 01:51:06 +01:00
|
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
|
|
|
|
$currentPage->InitializeContent ();
|
|
|
|
|
echo $OPDSRender->render ($currentPage);
|
2016-12-21 18:48:44 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|