forked from mkucej/i-librarian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetails.php
321 lines (212 loc) · 16.7 KB
/
details.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
<?php
include_once 'data.php';
include_once 'functions.php';
function formatBytes($size, $precision = 1) {
$base = log($size) / log(1024);
$suffixes = array('', 'k', 'M', 'G', 'T');
return round(pow(1024, $base - floor($base)), $precision) . ' ' . $suffixes[floor($base)];
}
if (isset($_SESSION['auth']) && isset($_SESSION['permissions']) && $_SESSION['permissions'] == 'A') {
// Save Libre Office path.
if (!empty($_GET['soffice_path'])) {
database_connect(IL_USER_DATABASE_PATH, 'users');
save_settings($dbHandle, array('global_soffice_path' => $_GET['soffice_path']));
$dbHandle = null;
die();
}
session_write_close();
include_once 'functions.php';
print '<b> Installation Details:</b>';
print '<table border="0" cellpadding="0" cellspacing="0" style="width: 100%">';
if ($hosted == false) {
print "<tr><td class=\"details alternating_row\" style=\"width: 100%\" colspan=4>Required software:</td></tr>";
print "<tr><td class=\"details\" style=\"white-space: nowrap\">PHP version</td>";
print "<td class=\"details\">>5.4.0</td><td class=\"details\">" . PHP_VERSION . "</td>";
print "<td class=\"details\">";
print version_compare(PHP_VERSION, "5.4.0", "<") ? "<span style=\" font-weight: bold\">!!!</span>" : "<span style=\" font-weight: bold\">OK</span>";
print "</td></tr>";
database_connect(IL_DATABASE_PATH, 'library');
$sqlite_version = $dbHandle->query("SELECT sqlite_version()");
$dbHandle = null;
$sqlite_version = $sqlite_version->fetchColumn();
print "<tr><td class=\"details\" style=\"white-space: nowrap\">SQLite database version</td>";
print "<td class=\"details\">>3.7.11</td><td class=\"details\">$sqlite_version</td>";
print "<td class=\"details\" style=\"\">";
print version_compare($sqlite_version, "3.7.11", "<") ? "<span style=\" font-weight: bold\">!!!</span>" : "<span style=\" font-weight: bold\">OK</span>";
print "</td></tr>";
print "<tr><td class=\"details alternating_row\" style=\"width: 100%\" colspan=4>Required PHP extensions:</td></tr>";
$extensions = array('pdo' => 'built-in SQLite database',
'pdo_sqlite' => 'built-in SQLite database',
'gd' => 'icon views and PDF viewer',
'fileinfo' => 'file type detection',
'openssl' => 'secure HTTP connections',
'zip' => 'export to ZIP');
while (list($extension, $feature) = each($extensions)) {
print "<tr><td class=\"details\" style=\"white-space: nowrap\">$extension</td><td class=\"details\" style=\"white-space: nowrap\">$feature</td>";
if (extension_loaded($extension)) {
print "<td class=\"details\">installed</td><td class=\"details\" style=\" font-weight: bold\">OK</td></tr>";
} else {
print "<td class=\"details\">not installed</td><td class=\"details\" style=\" font-weight: bold\">!!!</td></tr>";
}
}
print "<tr><td class=\"details alternating_row\" style=\"width: 100%\" colspan=4>Optional PHP extensions:</td></tr>";
$extensions = array('ldap' => 'LDAP authentication');
while (list($extension, $feature) = each($extensions)) {
print "<tr><td class=\"details\" style=\"white-space: nowrap\">$extension</td><td class=\"details\" style=\"white-space: nowrap\">$feature</td>";
if (extension_loaded($extension)) {
print "<td class=\"details\">installed</td><td class=\"details\" style=\" font-weight: bold\">OK</td></tr>";
} else {
print "<td class=\"details\">not installed</td><td class=\"details\" style=\" font-weight: bold\">!!!</td></tr>";
}
}
print "<tr><td class=\"details alternating_row\" style=\"width: 100%\" colspan=4>";
print "Required php.ini settings:</td></tr>";
$directives = array(
'file_uploads' => '1',
'upload_max_filesize' => '200M',
'post_max_size' => '800M',
'max_input_time' => '60',
'max_input_vars' => '10000');
while (list($directive, $value) = each($directives)) {
if (intval(ini_get($directive)) < intval($value)) {
print "<tr><td class=\"details\" style=\"white-space: nowrap\">$directive</td>";
print "<td class=\"details\" style=\"\">recommended $value</td>";
print "<td class=\"details\" style=\"\">" . ini_get($directive) . "</td>";
print "<td class=\"details\" style=\" font-weight: bold\">!!!</td></tr>";
} else {
print "<tr><td class=\"details\" style=\"white-space: nowrap\">$directive</td>";
print "<td class=\"details\" style=\"\">recommended $value</td>";
print "<td class=\"details\" style=\"\">" . ini_get($directive) . "</td>";
print "<td class=\"details\" style=\" font-weight: bold\">OK</td></tr>";
}
}
if (ini_get('open_basedir') != false) {
print "<tr><td class=\"details\" style=\"white-space: nowrap\">open_basedir</td>";
print "<td class=\"details\" style=\"\">required disabled</td>";
print "<td class=\"details\" style=\"\">" . ini_get('open_basedir') . "</td>";
print "<td class=\"details\" style=\" font-weight: bold\">!!!</td></tr>";
} else {
print "<tr><td class=\"details\" style=\"white-space: nowrap\">open_basedir</td>";
print "<td class=\"details\" style=\"\">required disabled</td>";
print "<td class=\"details\" style=\"\">disabled</td>";
print "<td class=\"details\" style=\" font-weight: bold\">OK</td></tr>";
}
if (ini_get('allow_url_fopen') != true) {
print "<tr><td class=\"details\" style=\"white-space: nowrap\">allow_url_fopen</td>";
print "<td class=\"details\" style=\"\">required On</td>";
print "<td class=\"details\" style=\"\">Off</td>";
print "<td class=\"details\" style=\" font-weight: bold\">!!!</td></tr>";
} else {
print "<tr><td class=\"details\" style=\"white-space: nowrap\">allow_url_fopen</td>";
print "<td class=\"details\" style=\"\">required On</td>";
print "<td class=\"details\" style=\"\">On</td>";
print "<td class=\"details\" style=\" font-weight: bold\">OK</td></tr>";
}
print "<tr><td class=\"details alternating_row\" style=\"width: 100%\" colspan=4>Required binary executables:</td></tr>";
print "<tr><td class=\"details\" style=\"white-space: nowrap;height:19px;line-height:19px\">Pdftotext</td>";
print "<td class=\"details\" style=\"white-space: nowrap;height:19px;line-height:19px\">PDF full-text search</td>";
print '<td class="details" id="details-1" style="white-space: nowrap;height:19px;line-height:19px"><img src="img/ajaxloader.gif" style="vertical-align:middle"></td>';
print '<td class="details" id="details-2" style="font-weight: bold;height:19px;line-height:19px"><img src="img/ajaxloader.gif" style="vertical-align:middle"></td>';
print '</tr>';
print "<tr><td class=\"details\" style=\"white-space: nowrap;height:19px;line-height:19px\">Pdfinfo</td>";
print "<td class=\"details\" style=\"white-space: nowrap;height:19px;line-height:19px\">built-in PDF viewer</td>";
print '<td class="details" id="details-3" style="white-space: nowrap;height:19px;line-height:19px"><img src="img/ajaxloader.gif" style="vertical-align:middle"></td>';
print '<td class="details" id="details-4" style="font-weight: bold;height:19px;line-height:19px"><img src="img/ajaxloader.gif" style="vertical-align:middle"></td>';
print '</tr>';
print "<tr><td class=\"details\" style=\"white-space: nowrap;height:19px;line-height:19px\">Pdftohtml</td>";
print "<td class=\"details\" style=\"white-space: nowrap;height:19px;line-height:19px\">PDF search in the built-in PDF viewer</td>";
print '<td class="details" id="details-5" style="white-space: nowrap;height:19px;line-height:19px"><img src="img/ajaxloader.gif" style="vertical-align:middle"></td>';
print '<td class="details" id="details-6" style="font-weight: bold;height:19px;line-height:19px"><img src="img/ajaxloader.gif" style="vertical-align:middle"></td>';
print '</tr>';
print "<tr><td class=\"details\" style=\"white-space: nowrap;height:19px;line-height:19px\">Ghostscript</td>";
print "<td class=\"details\" style=\"white-space: nowrap;height:19px;line-height:19px\">icon views, built-in PDF viewer</td>";
print '<td class="details" id="details-7" style="white-space: nowrap;height:19px;line-height:19px"><img src="img/ajaxloader.gif" style="vertical-align:middle"></td>';
print '<td class="details" id="details-8" style="font-weight: bold;height:19px;line-height:19px"><img src="img/ajaxloader.gif" style="vertical-align:middle"></td>';
print '</tr>';
print "<tr><td class=\"details\" style=\"white-space: nowrap;height:19px;line-height:19px\">Pdfdetach</td>";
print "<td class=\"details\" style=\"white-space: nowrap;height:19px;line-height:19px\">unpacking PDF-attached files</td>";
print '<td class="details" id="details-11" style="white-space: nowrap;height:19px;line-height:19px"><img src="img/ajaxloader.gif" style="vertical-align:middle"></td>';
print '<td class="details" id="details-12" style="font-weight: bold;height:19px;line-height:19px"><img src="img/ajaxloader.gif" style="vertical-align:middle"></td>';
print '</tr>';
print "<tr><td class=\"details alternating_row\" style=\"width: 100%\" colspan=4>Optional binary executables:</td></tr>";
print "<tr><td class=\"details\" style=\"white-space: nowrap;height:19px;line-height:19px\">Tesseract OCR</td>";
print "<td class=\"details\" style=\"white-space: nowrap;height:19px;line-height:19px\">optical character recognition</td>";
print '<td class="details" id="details-13" style="white-space: nowrap;height:19px;line-height:19px"><img src="img/ajaxloader.gif" style="vertical-align:middle"></td>';
print '<td class="details" id="details-14" style="font-weight: bold;height:19px;line-height:19px"><img src="img/ajaxloader.gif" style="vertical-align:middle"></td>';
print '</tr>';
print "<tr><td class=\"details\" style=\"white-space: nowrap;height:19px;line-height:19px\">LibreOffice</td>";
print "<td class=\"details\" style=\"white-space: nowrap;height:19px;line-height:19px\">office documents import and conversion</td>";
print '<td class="details" id="details-15" style="white-space: nowrap;height:19px;line-height:19px"><img src="img/ajaxloader.gif" style="vertical-align:middle"></td>';
print '<td class="details" id="details-16" style="font-weight: bold;height:19px;line-height:19px"><img src="img/ajaxloader.gif" style="vertical-align:middle"></td></tr>';
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
if (empty($_SESSION['soffice_path'])) {
// Translate default LibreOffice path.
exec('echo %PROGRAMFILES%\\LibreOffice 4\\program', $output);
$soffice_path = $output[0];
} else {
$soffice_path = $_SESSION['soffice_path'];
}
// If LibreOffice not there, prompt for new path.
if (!is_executable($soffice_path[0] . DIRECTORY_SEPARATOR . 'soffice.exe')) {
echo '<tr><td class="details">LibreOffice Path:</td><td class="details" colspan=3>';
echo '<form id="details-form"><input type="text" name="soffice_path" value="' . $soffice_path . '" style="width:30em">';
echo ' <span class="ui-state-default"> Save </span></form>';
echo '</td></tr>';
}
}
echo "</td>";
print "<tr><td class=\"details alternating_row\" style=\"width: 100%\" colspan=4>I, Librarian " . $version . " is installed in \"" . __DIR__ . "\":</td></tr>";
print "<tr><td class=\"details\" style=\"white-space: nowrap\">Path to PDF files:</td><td class=\"details\" style=\"font-size: 11px\">" . IL_PDF_PATH . "</td>";
if (is_writable(IL_PDF_PATH) && @file_exists(IL_PDF_PATH . DIRECTORY_SEPARATOR . '.')) {
print "<td class=\"details\" style=\"white-space: nowrap\">writable, executable</td><td class=\"details\" style=\" font-weight: bold\">OK</td></tr>";
} else {
print "<td class=\"details\" style=\"white-space: nowrap\">not writable or executable</td><td class=\"details\" style=\" font-weight: bold\">!!!</td></tr>";
}
print "<tr><td class=\"details\" style=\"white-space: nowrap\">Path to supplementary files:</td><td class=\"details\" style=\"font-size: 11px\">" . IL_SUPPLEMENT_PATH . "</td>";
if (is_writable(IL_SUPPLEMENT_PATH) && @file_exists(IL_SUPPLEMENT_PATH . DIRECTORY_SEPARATOR . '.')) {
print "<td class=\"details\" style=\"white-space: nowrap\">writable, executable</td><td class=\"details\" style=\" font-weight: bold\">OK</td></tr>";
} else {
print "<td class=\"details\" style=\"white-space: nowrap\">not writable or executable</td><td class=\"details\" style=\" font-weight: bold\">!!!</td></tr>";
}
print "<tr><td class=\"details\" style=\"white-space: nowrap\">Path to database files:</td><td class=\"details\" style=\"font-size: 11px\">" . IL_DATABASE_PATH . "</td>";
if (is_writable(IL_DATABASE_PATH) && @file_exists(IL_DATABASE_PATH . DIRECTORY_SEPARATOR . '.')) {
print "<td class=\"details\" style=\"white-space: nowrap\">writable, executable</td><td class=\"details\" style=\" font-weight: bold\">OK</td></tr>";
} else {
print "<td class=\"details\" style=\"white-space: nowrap\">not writable or executable</td><td class=\"details\" style=\" font-weight: bold\">!!!</td></tr>";
}
print "<tr><td class=\"details\" style=\"white-space: nowrap\">Path to PDF images:</td><td class=\"details\" style=\"font-size: 11px\">" . IL_IMAGE_PATH . "</td>";
if (is_writable(IL_IMAGE_PATH) && @file_exists(IL_IMAGE_PATH . DIRECTORY_SEPARATOR . '.')) {
print "<td class=\"details\" style=\"white-space: nowrap\">writable, executable</td><td class=\"details\" style=\" font-weight: bold\">OK</td></tr>";
} else {
print "<td class=\"details\" style=\"white-space: nowrap\">not writable or executable</td><td class=\"details\" style=\" font-weight: bold\">!!!</td></tr>";
}
print "<tr><td class=\"details\" style=\"white-space: nowrap\">Temporary directory:</td><td class=\"details\" style=\"font-size: 11px\">" . IL_TEMP_PATH . " <span id=\"clear-trash\" class=\"ui-state-default\"> <i class=\"fa fa-trash-o\"></i> Clear </span></td>";
if (is_writable(IL_TEMP_PATH) && @file_exists(IL_TEMP_PATH . DIRECTORY_SEPARATOR . '.')) {
print "<td class=\"details\" style=\"white-space: nowrap\">writable, executable</td><td class=\"details\" style=\" font-weight: bold\">OK</td></tr>";
} else {
print "<td class=\"details\" style=\"white-space: nowrap\">not writable or executable</td><td class=\"details\" style=\" font-weight: bold\">!!!</td></tr>";
}
}
print "<tr><td class=\"details alternating_row\" style=\"width: 100%\" colspan=4>SQLite database files:</td></tr>";
$database_files = scandir(IL_DATABASE_PATH);
while (list($key, $database_file) = each($database_files)) {
if (substr($database_file, -4) == '.sq3') {
$dbsize = filesize(IL_DATABASE_PATH . DIRECTORY_SEPARATOR . $database_file);
$dbsize = formatBytes($dbsize);
print "<tr><td class=\"details\">$database_file</td>";
print "<td class=\"details\"><div class=\"file-size\" style=\"width:7em;float:left\">" . $dbsize . "B</div>";
print ' <span class="ui-state-default integrity" data-db="' . basename($database_file, '.sq3') . '"> Check Integrity </span>';
print ' <span class="ui-state-default vacuum" data-db="' . basename($database_file, '.sq3') . '"> Vacuum </span>';
print '</td>';
if (is_writable(IL_DATABASE_PATH . DIRECTORY_SEPARATOR . $database_file)) {
print "<td class=\"details\" style=\"white-space: nowrap\">writable</td><td class=\"details\" style=\" font-weight: bold\">OK</td></tr>";
} else {
print "<td class=\"details\" style=\"white-space: nowrap\">not writable</td><td class=\"details\" style=\" font-weight: bold\">!!!</td></tr>";
}
}
}
print '</table><br>';
} else {
print 'Super User authorization required.';
}
?>