Add rewrite rule and a bit of JS tweaking to make book download URLs more clean

This commit is contained in:
Junior 2025-05-06 15:11:40 -04:00
parent e117a6f037
commit c175362563
2 changed files with 11 additions and 2 deletions

View File

@ -1 +1,6 @@
php_flag opcache.enable off
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^book/([0-9]+)/.*$ download.php?id=$1
</IfModule>

View File

@ -54,6 +54,10 @@ function redirectToLogin() {
window.location.replace("index.php");
}
function basename(str) {
return str.substr(str.lastIndexOf("/") + 1);
}
function getContents() {
if ( searchTimeout ) clearTimeout(searchTimeout);
var data = {};
@ -88,9 +92,9 @@ function getContents() {
if ( item.folder == true ) {
contents += '<div><span class="target folder" data-newpath="' + item.fullpath + '">' + item.displayname + "</span></div>";
} else {
contents += '<div><a href="download.php?id=' + item.id;
contents += '<div><a href="book/' + item.id + '/' + basename(item.displayname) + '"';
if ( item.displayname.substring(item.displayname.length - 4) == "epub" ) {
contents += '&file=' + item.displayname + '" target="_blank"';
contents += '" target="_blank"';
} else {
contents += '"';
}