Add rewrite rule and a bit of JS tweaking to make book download URLs more clean
This commit is contained in:
		
							parent
							
								
									e117a6f037
								
							
						
					
					
						commit
						c175362563
					
				| 
						 | 
					@ -1 +1,6 @@
 | 
				
			||||||
php_flag opcache.enable off
 | 
					php_flag opcache.enable off
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<IfModule mod_rewrite.c>
 | 
				
			||||||
 | 
					  RewriteEngine on
 | 
				
			||||||
 | 
					  RewriteRule ^book/([0-9]+)/.*$ download.php?id=$1
 | 
				
			||||||
 | 
					</IfModule>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,6 +54,10 @@ function redirectToLogin() {
 | 
				
			||||||
   window.location.replace("index.php");
 | 
					   window.location.replace("index.php");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function basename(str) {
 | 
				
			||||||
 | 
					   return str.substr(str.lastIndexOf("/") + 1);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function getContents() {
 | 
					function getContents() {
 | 
				
			||||||
   if ( searchTimeout ) clearTimeout(searchTimeout);
 | 
					   if ( searchTimeout ) clearTimeout(searchTimeout);
 | 
				
			||||||
   var data = {};
 | 
					   var data = {};
 | 
				
			||||||
| 
						 | 
					@ -88,9 +92,9 @@ function getContents() {
 | 
				
			||||||
                       if ( item.folder == true ) {
 | 
					                       if ( item.folder == true ) {
 | 
				
			||||||
                          contents += '<div><span class="target folder" data-newpath="' + item.fullpath + '">' + item.displayname + "</span></div>";
 | 
					                          contents += '<div><span class="target folder" data-newpath="' + item.fullpath + '">' + item.displayname + "</span></div>";
 | 
				
			||||||
                       } else {
 | 
					                       } 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" ) {
 | 
					                          if ( item.displayname.substring(item.displayname.length - 4) == "epub" ) {
 | 
				
			||||||
                             contents += '&file=' + item.displayname + '" target="_blank"';
 | 
					                             contents += '" target="_blank"';
 | 
				
			||||||
                          } else {
 | 
					                          } else {
 | 
				
			||||||
                             contents += '"';
 | 
					                             contents += '"';
 | 
				
			||||||
                          }
 | 
					                          }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user