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.

155 lines
4.9KB

  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <?php
  4. /**
  5. * COPS (Calibre OPDS PHP Server) Configuration check
  6. *
  7. * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
  8. * @author Sébastien Lucas <sebastien@slucas.fr>
  9. *
  10. */
  11. require_once ("config.php");
  12. require_once ("base.php");
  13. header ("Content-Type:text/html; charset=UTF-8");
  14. $err = getURLParam ("err", -1);
  15. $error = NULL;
  16. switch ($err) {
  17. case 1 :
  18. $error = "Database error";
  19. break;
  20. }
  21. ?>
  22. <head>
  23. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  24. <title>COPS Configuration Check</title>
  25. <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss ()) ?>" media="screen" />
  26. </head>
  27. <body>
  28. <div class="container">
  29. <header>
  30. <div class="headcenter">
  31. <h1>COPS Configuration Check</h1>
  32. </div>
  33. </header>
  34. <div id="content" style="display: none;"></div>
  35. <section>
  36. <?php
  37. if (!is_null ($error)) {
  38. ?>
  39. <article class="frontpage">
  40. <h2>You've been redirected because COPS is not configured properly</h2>
  41. <h4><?php echo $error ?></h4>
  42. </article>
  43. <?php
  44. }
  45. ?>
  46. <article class="frontpage">
  47. <h2>Check if GD is properly installed and loaded</h2>
  48. <h4>
  49. <?php
  50. if (extension_loaded('gd') && function_exists('gd_info')) {
  51. echo "OK";
  52. } else {
  53. echo "Please install the php5-gd extension and make sure it's enabled";
  54. }
  55. ?>
  56. </h4>
  57. </article>
  58. <article class="frontpage">
  59. <h2>Check if Sqlite is properly installed and loaded</h2>
  60. <h4>
  61. <?php
  62. if (extension_loaded('pdo_sqlite')) {
  63. echo "OK";
  64. } else {
  65. echo "Please install the php5-sqlite extension and make sure it's enabled";
  66. }
  67. ?>
  68. </h4>
  69. </article>
  70. <article class="frontpage">
  71. <h2>Check if libxml is properly installed and loaded</h2>
  72. <h4>
  73. <?php
  74. if (extension_loaded('libxml')) {
  75. echo "OK";
  76. } else {
  77. echo "Please make sure libxml is enabled";
  78. }
  79. ?>
  80. </h4>
  81. </article>
  82. <?php
  83. $i = 0;
  84. foreach (Base::getDbList () as $name => $database) {
  85. ?>
  86. <article class="frontpage">
  87. <h2>Check if Calibre database path is not an URL</h2>
  88. <h4>
  89. <?php
  90. if (!preg_match ("#^http#", $database)) {
  91. echo "OK";
  92. } else {
  93. echo "Calibre path has to be local (no URL allowed)";
  94. }
  95. ?>
  96. </h4>
  97. </article>
  98. <article class="frontpage">
  99. <h2>Check if Calibre database file exists and is readable</h2>
  100. <?php
  101. if (is_readable (Base::getDbFileName ($i))) {
  102. echo "{$name} OK";
  103. } else {
  104. echo "{$name} File " . Base::getDbFileName ($i) . " not found,
  105. Please check
  106. <ul>
  107. <li>Value of \$config['calibre_directory'] in config_local.php</li>
  108. <li>Value of <a href='http://php.net/manual/en/ini.core.php#ini.open-basedir'>open_basedir</a> in your php.ini</li>
  109. <li>The access rights of the Calibre Database</li>
  110. <li>Synology users please read <a href='https://github.com/seblucas/cops/wiki/Howto---Synology'>this</a></li>
  111. </ul>";
  112. }
  113. ?>
  114. </article>
  115. <article class="frontpage">
  116. <h2>Check if Calibre database file can be opened with PHP</h2>
  117. <h4>
  118. <?php
  119. try {
  120. $db = new PDO('sqlite:'. Base::getDbFileName ($i));
  121. echo "{$name} OK";
  122. } catch (Exception $e) {
  123. echo "{$name} If the file is readable, check your php configuration. Exception detail : " . $e;
  124. }
  125. ?>
  126. </h4>
  127. </article>
  128. <article class="frontpage">
  129. <h2>Check if Calibre database file contains at least some of the needed tables</h2>
  130. <h4>
  131. <?php
  132. try {
  133. $db = new PDO('sqlite:'. Base::getDbFileName ($i));
  134. $count = $db->query("select count(*) FROM sqlite_master WHERE type='table' AND name in ('books', 'authors', 'tags', 'series')")->fetchColumn();
  135. if ($count == 4) {
  136. echo "{$name} OK";
  137. } else {
  138. echo "{$name} Not all Calibre tables were found. Are you you're using the correct database.";
  139. }
  140. } catch (Exception $e) {
  141. echo "{$name} If the file is readable, check your php configuration. Exception detail : " . $e;
  142. }
  143. ?>
  144. </h4>
  145. </article>
  146. <?php $i++; } ?>
  147. </section>
  148. <footer></footer>
  149. </div>
  150. </body>
  151. </html>