-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetbook.php
98 lines (82 loc) · 2.83 KB
/
getbook.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
<?php
if(isset($_GET['mylogin'])) $mylogin=$_GET['mylogin'];
else $mylogin="";
if(isset($_GET['mypass'])) $mypass=$_GET['mypass'];
else $mypass="";
require_once('./config/config.php');
if($protect==false) {
//OK
} else if($account[$mylogin]&&$account[$mylogin][0]==$mypass) {
//ok
if($account[$mylogin][1]=="Parental"&&$limited) {
$calibre=array_merge ($calibre, $limited);
}
} else {
erreur("login error");
}
if(isset($_GET['path'])) $path=$_GET['path'];
else $path="";
if(isset($_GET['filename'])) $filename=$_GET['filename'];
else $filename="";
if(isset($_GET['extension'])) $extension=$_GET['extension'];
else $extension="";
if(isset($_GET['base'])) $base=$_GET['base'];
else $base="";
$ebook=$calibre[$base].$path."/".$filename.".".$extension;
if(!file_exists ($ebook)) {
erreur('not available');
}
$mimetypes = array(
'azw' => 'application/x-mobipocket-ebook',
'azw3' => 'application/x-mobipocket-ebook',
'cbz' => 'application/x-cbz',
'cbr' => 'application/x-cbr',
'doc' => 'application/msword',
'epub' => 'application/epub+zip',
'fb2' => 'text/fb2+xml',
'kobo' => 'application/x-koboreader-ebook',
'mobi' => 'application/x-mobipocket-ebook',
'lit' => 'application/x-ms-reader',
'lrs' => 'text/x-sony-bbeb+xml',
'lrf' => 'application/x-sony-bbeb',
'lrx' => 'application/x-sony-bbeb',
'ncx' => 'application/x-dtbncx+xml',
'opf' => 'application/oebps-package+xml',
'otf' => 'application/x-font-opentype',
'pdb' => 'application/vnd.palm',
'pdf' => 'application/pdf',
'prc' => 'application/x-mobipocket-ebook',
'rtf' => 'application/rtf',
'svg' => 'image/svg+xml',
'ttf' => 'application/x-font-truetype',
'wmf' => 'image/wmf',
'xhtml' => 'application/xhtml+xml',
'xpgt' => 'application/adobe-page-template+xml',
'zip' => 'application/zip'
);
//Utile ?
//$expires = 60*60*24*14;
//header("Pragma: public");
//header("Cache-Control: maxage=".$expires);
//header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
//N'accepte que des fichier par les extension ci-dessus
//pour ne pas permettre le téléchargement de n'importe quoi...
if(array_key_exists ($extension, $mimetypes)) header("Content-Type: ".$mimetypes[$extenion]);
else erreur('unknown extension');
//Non géré: mise à jour epub
header('Content-Disposition: attachment; filename="'.basename ($ebook).'"');
if($XSendfile) {
header('X-Sendfile: '.realpath($ebook));
//Utile ?
//header("Content-Length: ".filesize($ebook));
} else {
//$fp = fopen($ebook, 'rb');
header("Content-Length: ".filesize($ebook));
//fpassthru($fp);
readfile($ebook);
}
function erreur($message) {
echo $message;
die();
}
?>