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.

260 lines
8.5KB

  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. $full = getURLParam ("full");
  16. $error = NULL;
  17. switch ($err) {
  18. case 1 :
  19. $error = "Database error";
  20. break;
  21. }
  22. ?>
  23. <head>
  24. <meta charset="utf-8">
  25. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  26. <title>COPS Configuration Check</title>
  27. <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss ()) ?>" media="screen" />
  28. </head>
  29. <body>
  30. <div class="container">
  31. <header>
  32. <div class="headcenter">
  33. <h1>COPS Configuration Check</h1>
  34. </div>
  35. </header>
  36. <div id="content" style="display: none;"></div>
  37. <section>
  38. <?php
  39. if (!is_null ($error)) {
  40. ?>
  41. <article class="frontpage">
  42. <h2>You've been redirected because COPS is not configured properly</h2>
  43. <h4><?php echo $error ?></h4>
  44. </article>
  45. <?php
  46. }
  47. ?>
  48. <article class="frontpage">
  49. <h2>Check if PHP version is correct</h2>
  50. <h4>
  51. <?php
  52. if (defined('PHP_VERSION_ID')) {
  53. if (PHP_VERSION_ID >= 50300) {
  54. echo "OK (" . PHP_VERSION . ")";
  55. } else {
  56. echo "Please install PHP >= 5.3 (" . PHP_VERSION . ")";
  57. }
  58. } else {
  59. echo "Please install PHP >= 5.3";
  60. }
  61. ?>
  62. </h4>
  63. </article>
  64. <article class="frontpage">
  65. <h2>Check if GD is properly installed and loaded</h2>
  66. <h4>
  67. <?php
  68. if (extension_loaded('gd') && function_exists('gd_info')) {
  69. echo "OK";
  70. } else {
  71. echo "Please install the php5-gd extension and make sure it's enabled";
  72. }
  73. ?>
  74. </h4>
  75. </article>
  76. <article class="frontpage">
  77. <h2>Check if Sqlite is properly installed and loaded</h2>
  78. <h4>
  79. <?php
  80. if (extension_loaded('pdo_sqlite')) {
  81. echo "OK";
  82. } else {
  83. echo "Please install the php5-sqlite extension and make sure it's enabled";
  84. }
  85. ?>
  86. </h4>
  87. </article>
  88. <article class="frontpage">
  89. <h2>Check if libxml is properly installed and loaded</h2>
  90. <h4>
  91. <?php
  92. if (extension_loaded('libxml')) {
  93. echo "OK";
  94. } else {
  95. echo "Please make sure libxml is enabled";
  96. }
  97. ?>
  98. </h4>
  99. </article>
  100. <article class="frontpage">
  101. <h2>Check if Json is properly installed and loaded</h2>
  102. <h4>
  103. <?php
  104. if (extension_loaded('json')) {
  105. echo "OK";
  106. } else {
  107. echo "Please install the php5-json extension and make sure it's enabled";
  108. }
  109. ?>
  110. </h4>
  111. </article>
  112. <article class="frontpage">
  113. <h2>Check if mbstring is properly installed and loaded</h2>
  114. <h4>
  115. <?php
  116. if (extension_loaded('mbstring')) {
  117. echo "OK";
  118. } else {
  119. echo "Please install the php5-mbstring extension and make sure it's enabled";
  120. }
  121. ?>
  122. </h4>
  123. </article>
  124. <article class="frontpage">
  125. <h2>Check if intl is properly installed and loaded</h2>
  126. <h4>
  127. <?php
  128. if (extension_loaded('intl')) {
  129. echo "OK";
  130. } else {
  131. echo "Please install the php5-intl extension and make sure it's enabled";
  132. }
  133. ?>
  134. </h4>
  135. </article>
  136. <article class="frontpage">
  137. <h2>Check if Normalizer class is properly installed and loaded</h2>
  138. <h4>
  139. <?php
  140. if (class_exists("Normalizer", $autoload = false)) {
  141. echo "OK";
  142. } else {
  143. echo "Please make sure intl is enabled in your php.ini";
  144. }
  145. ?>
  146. </h4>
  147. </article>
  148. <article class="frontpage">
  149. <h2>Check if the rendering will be done on client side or server side</h2>
  150. <h4>
  151. <?php
  152. if (useServerSideRendering ()) {
  153. echo "Server side rendering";
  154. } else {
  155. echo "Client side rendering";
  156. }
  157. ?>
  158. </h4>
  159. </article>
  160. <?php
  161. $i = 0;
  162. foreach (Base::getDbList () as $name => $database) {
  163. ?>
  164. <article class="frontpage">
  165. <h2>Check if Calibre database path is not an URL</h2>
  166. <h4>
  167. <?php
  168. if (!preg_match ("#^http#", $database)) {
  169. echo "OK";
  170. } else {
  171. echo "Calibre path has to be local (no URL allowed)";
  172. }
  173. ?>
  174. </h4>
  175. </article>
  176. <article class="frontpage">
  177. <h2>Check if Calibre database file exists and is readable</h2>
  178. <h4>
  179. <?php
  180. if (is_readable (Base::getDbFileName ($i))) {
  181. echo "{$name} OK";
  182. } else {
  183. echo "{$name} File " . Base::getDbFileName ($i) . " not found,
  184. Please check
  185. <ul>
  186. <li>Value of \$config['calibre_directory'] in config_local.php</li>
  187. <li>Value of <a href='http://php.net/manual/en/ini.core.php#ini.open-basedir'>open_basedir</a> in your php.ini</li>
  188. <li>The access rights of the Calibre Database</li>
  189. <li>Synology users please read <a href='https://github.com/seblucas/cops/wiki/Howto---Synology'>this</a></li>
  190. </ul>";
  191. }
  192. ?>
  193. </h4>
  194. </article>
  195. <?php if (is_readable (Base::getDbFileName ($i))) { ?>
  196. <article class="frontpage">
  197. <h2>Check if Calibre database file can be opened with PHP</h2>
  198. <h4>
  199. <?php
  200. try {
  201. $db = new PDO('sqlite:'. Base::getDbFileName ($i));
  202. echo "{$name} OK";
  203. } catch (Exception $e) {
  204. echo "{$name} If the file is readable, check your php configuration. Exception detail : " . $e;
  205. }
  206. ?>
  207. </h4>
  208. </article>
  209. <article class="frontpage">
  210. <h2>Check if Calibre database file contains at least some of the needed tables</h2>
  211. <h4>
  212. <?php
  213. try {
  214. $db = new PDO('sqlite:'. Base::getDbFileName ($i));
  215. $count = $db->query("select count(*) FROM sqlite_master WHERE type='table' AND name in ('books', 'authors', 'tags', 'series')")->fetchColumn();
  216. if ($count == 4) {
  217. echo "{$name} OK";
  218. } else {
  219. echo "{$name} Not all Calibre tables were found. Are you sure you're using the correct database.";
  220. }
  221. } catch (Exception $e) {
  222. echo "{$name} If the file is readable, check your php configuration. Exception detail : " . $e;
  223. }
  224. ?>
  225. </h4>
  226. </article>
  227. <?php if ($full) { ?>
  228. <article class="frontpage">
  229. <h2>Check if all Calibre books are found</h2>
  230. <h4>
  231. <?php
  232. try {
  233. $db = new PDO('sqlite:'. Base::getDbFileName ($i));
  234. $result = $db->prepare("select books.path || '/' || data.name || '.' || lower (format) as fullpath from data join books on data.book = books.id");
  235. $result->execute ();
  236. while ($post = $result->fetchObject ())
  237. {
  238. if (!is_file (Base::getDbDirectory ($i) . $post->fullpath)) {
  239. echo "<p>" . Base::getDbDirectory ($i) . $post->fullpath . "</p>";
  240. }
  241. }
  242. } catch (Exception $e) {
  243. echo "{$name} If the file is readable, check your php configuration. Exception detail : " . $e;
  244. }
  245. ?>
  246. </h4>
  247. </article>
  248. <?php } ?>
  249. <?php } ?>
  250. <?php $i++; } ?>
  251. </section>
  252. <footer></footer>
  253. </div>
  254. </body>
  255. </html>