Calibre OPDS (and HTML) PHP Server : web-based light alternative to Calibre content server / Calibre2OPDS to serve ebooks (epub, mobi, pdf, ...) http://blog.slucas.fr/en/oss/calibre-opds-php-server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.2KB

  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 <sebastien@slucas.fr>
  7. *
  8. */
  9. require_once ("config.php");
  10. require_once ("base.php");
  11. require_once ("author.php");
  12. require_once ("serie.php");
  13. require_once ("tag.php");
  14. require_once ("book.php");
  15. require_once ("OPDS_renderer.php");
  16. header ("Content-Type:application/xml");
  17. $page = getURLParam ("page", Base::PAGE_INDEX);
  18. $query = getURLParam ("query");
  19. $n = getURLParam ("n", "1");
  20. if ($query)
  21. $page = Base::PAGE_OPENSEARCH_QUERY;
  22. $qid = getURLParam ("id");
  23. if ($config ['cops_fetch_protect'] == "1") {
  24. session_start();
  25. if (!isset($_SESSION['connected'])) {
  26. $_SESSION['connected'] = 0;
  27. }
  28. }
  29. $OPDSRender = new OPDSRenderer ();
  30. switch ($page) {
  31. case Base::PAGE_OPENSEARCH :
  32. echo $OPDSRender->getOpenSearch ();
  33. return;
  34. default:
  35. $currentPage = Page::getPage ($page, $qid, $query, $n);
  36. $currentPage->InitializeContent ();
  37. echo $OPDSRender->render ($currentPage);
  38. return;
  39. }