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