cops/checkconfig.php

260 lines
8.5 KiB
PHP
Raw Permalink Normal View History

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<?php
/**
* COPS (Calibre OPDS PHP Server) Configuration check
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author S<EFBFBD>bastien Lucas <sebastien@slucas.fr>
*
*/
2013-12-05 11:52:51 +02:00
require_once ("config.php");
require_once ("base.php");
2013-12-05 11:52:51 +02:00
2013-05-16 15:41:24 +03:00
header ("Content-Type:text/html; charset=UTF-8");
2013-12-05 11:52:51 +02:00
$err = getURLParam ("err", -1);
$full = getURLParam ("full");
$error = NULL;
switch ($err) {
case 1 :
$error = "Database error";
break;
}
?>
<head>
<meta charset="utf-8">
2013-05-16 18:22:21 +03:00
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>COPS Configuration Check</title>
<link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss ()) ?>" media="screen" />
</head>
<body>
<div class="container">
2013-05-16 15:41:24 +03:00
<header>
<div class="headcenter">
2013-05-16 15:41:24 +03:00
<h1>COPS Configuration Check</h1>
</div>
2013-05-16 15:41:24 +03:00
</header>
<div id="content" style="display: none;"></div>
2013-05-16 15:41:24 +03:00
<section>
<?php
if (!is_null ($error)) {
?>
2013-05-16 15:41:24 +03:00
<article class="frontpage">
<h2>You've been redirected because COPS is not configured properly</h2>
<h4><?php echo $error ?></h4>
</article>
<?php
}
?>
<article class="frontpage">
<h2>Check if PHP version is correct</h2>
<h4>
<?php
if (defined('PHP_VERSION_ID')) {
if (PHP_VERSION_ID >= 50300) {
echo "OK (" . PHP_VERSION . ")";
} else {
echo "Please install PHP >= 5.3 (" . PHP_VERSION . ")";
}
} else {
echo "Please install PHP >= 5.3";
}
?>
</h4>
</article>
2013-05-16 15:41:24 +03:00
<article class="frontpage">
<h2>Check if GD is properly installed and loaded</h2>
<h4>
2013-12-05 11:52:51 +02:00
<?php
if (extension_loaded('gd') && function_exists('gd_info')) {
echo "OK";
} else {
echo "Please install the php5-gd extension and make sure it's enabled";
}
?>
2013-05-16 15:41:24 +03:00
</h4>
</article>
<article class="frontpage">
<h2>Check if Sqlite is properly installed and loaded</h2>
<h4>
2013-12-05 11:52:51 +02:00
<?php
if (extension_loaded('pdo_sqlite')) {
echo "OK";
} else {
echo "Please install the php5-sqlite extension and make sure it's enabled";
}
?>
2013-05-16 15:41:24 +03:00
</h4>
</article>
<article class="frontpage">
<h2>Check if libxml is properly installed and loaded</h2>
<h4>
2013-12-05 11:52:51 +02:00
<?php
if (extension_loaded('libxml')) {
echo "OK";
} else {
echo "Please make sure libxml is enabled";
}
?>
2013-05-16 15:41:24 +03:00
</h4>
</article>
<article class="frontpage">
<h2>Check if Json is properly installed and loaded</h2>
<h4>
<?php
if (extension_loaded('json')) {
echo "OK";
} else {
echo "Please install the php5-json extension and make sure it's enabled";
}
?>
</h4>
</article>
<article class="frontpage">
<h2>Check if mbstring is properly installed and loaded</h2>
<h4>
<?php
if (extension_loaded('mbstring')) {
echo "OK";
} else {
echo "Please install the php5-mbstring extension and make sure it's enabled";
}
?>
</h4>
</article>
<article class="frontpage">
<h2>Check if intl is properly installed and loaded</h2>
<h4>
<?php
if (extension_loaded('intl')) {
echo "OK";
} else {
echo "Please install the php5-intl extension and make sure it's enabled";
}
?>
</h4>
</article>
<article class="frontpage">
<h2>Check if Normalizer class is properly installed and loaded</h2>
<h4>
<?php
if (class_exists("Normalizer", $autoload = false)) {
echo "OK";
} else {
echo "Please make sure intl is enabled in your php.ini";
}
?>
</h4>
2013-05-16 15:41:24 +03:00
</article>
<article class="frontpage">
<h2>Check if the rendering will be done on client side or server side</h2>
<h4>
2013-12-05 11:52:51 +02:00
<?php
if (useServerSideRendering ()) {
echo "Server side rendering";
} else {
echo "Client side rendering";
}
?>
</h4>
</article>
2013-12-05 11:52:51 +02:00
<?php
$i = 0;
2013-12-05 11:52:51 +02:00
foreach (Base::getDbList () as $name => $database) {
?>
<article class="frontpage">
<h2>Check if Calibre database path is not an URL</h2>
<h4>
<?php
if (!preg_match ("#^http#", $database)) {
echo "OK";
} else {
echo "Calibre path has to be local (no URL allowed)";
}
?>
</h4>
</article>
2013-05-16 15:41:24 +03:00
<article class="frontpage">
<h2>Check if Calibre database file exists and is readable</h2>
2014-03-02 18:12:04 +02:00
<h4>
2013-12-05 11:52:51 +02:00
<?php
if (is_readable (Base::getDbFileName ($i))) {
echo "{$name} OK";
} else {
2013-12-05 11:52:51 +02:00
echo "{$name} File " . Base::getDbFileName ($i) . " not found,
Please check
<ul>
<li>Value of \$config['calibre_directory'] in config_local.php</li>
<li>Value of <a href='http://php.net/manual/en/ini.core.php#ini.open-basedir'>open_basedir</a> in your php.ini</li>
<li>The access rights of the Calibre Database</li>
<li>Synology users please read <a href='https://github.com/seblucas/cops/wiki/Howto---Synology'>this</a></li>
</ul>";
}
?>
2014-03-02 18:12:04 +02:00
</h4>
2013-05-16 15:41:24 +03:00
</article>
<?php if (is_readable (Base::getDbFileName ($i))) { ?>
2013-05-16 15:41:24 +03:00
<article class="frontpage">
<h2>Check if Calibre database file can be opened with PHP</h2>
<h4>
2013-12-05 11:52:51 +02:00
<?php
try {
$db = new PDO('sqlite:'. Base::getDbFileName ($i));
echo "{$name} OK";
} catch (Exception $e) {
echo "{$name} If the file is readable, check your php configuration. Exception detail : " . $e;
}
?>
2013-05-16 15:41:24 +03:00
</h4>
</article>
<article class="frontpage">
<h2>Check if Calibre database file contains at least some of the needed tables</h2>
<h4>
2013-12-05 11:52:51 +02:00
<?php
try {
$db = new PDO('sqlite:'. Base::getDbFileName ($i));
$count = $db->query("select count(*) FROM sqlite_master WHERE type='table' AND name in ('books', 'authors', 'tags', 'series')")->fetchColumn();
if ($count == 4) {
echo "{$name} OK";
} else {
echo "{$name} Not all Calibre tables were found. Are you sure you're using the correct database.";
}
} catch (Exception $e) {
echo "{$name} If the file is readable, check your php configuration. Exception detail : " . $e;
}
?>
2013-05-16 15:41:24 +03:00
</h4>
</article>
<?php if ($full) { ?>
<article class="frontpage">
<h2>Check if all Calibre books are found</h2>
<h4>
2013-12-05 11:52:51 +02:00
<?php
try {
$db = new PDO('sqlite:'. Base::getDbFileName ($i));
$result = $db->prepare("select books.path || '/' || data.name || '.' || lower (format) as fullpath from data join books on data.book = books.id");
$result->execute ();
while ($post = $result->fetchObject ())
{
if (!is_file (Base::getDbDirectory ($i) . $post->fullpath)) {
echo "<p>" . Base::getDbDirectory ($i) . $post->fullpath . "</p>";
}
}
} catch (Exception $e) {
echo "{$name} If the file is readable, check your php configuration. Exception detail : " . $e;
}
?>
</h4>
</article>
<?php } ?>
<?php } ?>
<?php $i++; } ?>
2013-05-16 15:41:24 +03:00
</section>
2013-05-16 15:42:56 +03:00
<footer></footer>
</div>
</body>
</html>