-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestexist.php
More file actions
111 lines (103 loc) · 3.06 KB
/
testexist.php
File metadata and controls
111 lines (103 loc) · 3.06 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My Readings - Test des bases Calibre</title>
<style type="text/css">
.titre {
font-size : 15pt;
color: #7f2323;
width: 100%;
background-color: #ababab;
font-weight: bold;
}
.soustitre {
color: #7382c1;
font-weight: bold;
}
.normal {
font-size : 12pt;
color: black;
font-weight: normal;
}
.normalmargin {
font-size : 12pt;
color: black;
font-weight: normal;
margin-left: 30px;
}
</style>
</head>
<body>
<?php
require_once('./config/confadmin.php');
if($_GET['admin_login']!=$adlogin||$_GET['admin_pw']!=$adpw) exit("Not login");
if(!file_exists('./config/config.php')) exit("No configuration file");
require_once('./config/config.php');
$languagejson="./resources/locale/admin_".$_GET['language'].".json";
if(!file_exists($languagejson)) $languagejson="./resources/locale/admin_en.json";
$json = file_get_contents($languagejson);
$json = json_decode($json, true);
$msg= $json['msg'];
if($calibre) {
if (!extension_loaded("sqlite3")) echo $msg["sqlite_ext"];
if($limited) $calibre=array_merge ($calibre, $limited);
foreach ($calibre as $key => $path) {
$connect=false;
$result="";
$nocover="";
echo '<div class="titre">'.$msg["test_lib"].$key.":</div>";
$COLUMNS="books.id as id, books.title as title, books.path as relativePath,
has_cover as hasCover";
$query="SELECT ".$COLUMNS." FROM books ORDER BY books.author_sort;";
try{
$pdo = new PDO('sqlite:'.$path.'metadata.db');
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // ERRMODE_WARNING | ERRMODE_EXCEPTION | ERRMODE_SILENT
$stmt = $pdo->prepare($query);
$stmt->execute(array());
$result = $stmt->fetchAll();
$connect=true;
} catch(Exception $e) {
echo '<p class="red">'.$msg["error_connect"].' - '.$e->getMessage()."</p>";
}
if($connect==true) {
echo '<p class="soustitre">'.$msg["access_error"].':</p><div class="normalmargin">';
$query2 = "select data.format as extension, data.name as filename, data.uncompressed_size as size from data where book = ?";
$erreur=false;
foreach ($result as $key => $book) {
if($book['hasCover']==1) {
$filename = $path.$book['relativePath'].'/cover.jpg';
if (!file_exists($filename)) {
$erreur=true;
echo $filename."<br />";
}
//echo $book['hasCover']." ".$book['relativePath']."<br />";
} else {
$nocover=$nocover.$book['id']." - ".$book['title']."<br />";
}
$stmt = $pdo->prepare($query2);
$stmt->execute(array($book['id']));
$epubs = $stmt->fetchAll();
foreach ($epubs as $key2 => $epub) {
$filename = $path.$book['relativePath'].'/'.$epub['filename'].'.'.strtolower($epub['extension']);
if (!file_exists($filename)) {
$erreur=true;
echo $filename."<br />";
}
}
}
if($erreur==false) echo $msg["noerror"]."</div>";
else echo "</div>";
if($nocover!="") {
echo '<p class="soustitre">'.$msg["nocover"].':</p><div class="normalmargin">'.$nocover."</div>";
}
echo '<p> </p>';
}
}
} else {
echo $msg["nocover"]."<br />";
}
?>
</body>
</html>