forked from seblucas/cops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckconfig.php
144 lines (139 loc) · 4.58 KB
/
checkconfig.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
/**
* COPS (Calibre OPDS PHP Server) Configuration check
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Sébastien Lucas <[email protected]>
*
*/
require_once ("config.php");
require_once ("base.php");
header ("Content-Type:text/html; charset=UTF-8");
$err = getURLParam ("err", -1);
$error = NULL;
switch ($err) {
case 1 :
$error = "Database error";
break;
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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("style.css") ?>" media="screen" />
</head>
<body>
<div class="container">
<header>
<div class="headcenter">
<h1>COPS Configuration Check</h1>
</div>
</header>
<div id="content" style="display: none;"></div>
<section>
<?php
if (!is_null ($error)) {
?>
<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 GD is properly installed and loaded</h2>
<h4>
<?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";
}
?>
</h4>
</article>
<article class="frontpage">
<h2>Check if Sqlite is properly installed and loaded</h2>
<h4>
<?php
if (extension_loaded('pdo_sqlite')) {
echo "OK";
} else {
echo "Please install the php5-sqlite extension and make sure it's enabled";
}
?>
</h4>
</article>
<article class="frontpage">
<h2>Check if libxml is properly installed and loaded</h2>
<h4>
<?php
if (extension_loaded('libxml')) {
echo "OK";
} else {
echo "Please make sure libxml is enabled";
}
?>
</h4>
</article>
<?php
$i = 0;
foreach (Base::getDbList () as $name => $database) {
?>
<article class="frontpage">
<h2>Check if Calibre database file exists and is readable</h2>
<?php
if (is_readable (Base::getDbFileName ($i))) {
echo "{$name} OK";
} else {
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>";
}
?>
</article>
<article class="frontpage">
<h2>Check if Calibre database file can be opened with PHP</h2>
<h4>
<?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;
}
?>
</h4>
</article>
<article class="frontpage">
<h2>Check if Calibre database file contains at least some of the needed tables</h2>
<h4>
<?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 you're using the correct database.";
}
} catch (Exception $e) {
echo "{$name} If the file is readable, check your php configuration. Exception detail : " . $e;
}
?>
</h4>
</article>
<?php $i++; } ?>
</section>
<footer></footer>
</div>
</body>
</html>