Compare commits
No commits in common. "5e58c8e28f47f723e34caf9cc6d7e2ed1006a74b" and "a3765e8eeefe8c6ff7fedfef80908542b5def6a4" have entirely different histories.
5e58c8e28f
...
a3765e8eee
|
|
@ -41,7 +41,6 @@ if ( !is_dir($fullcompath) ) {
|
||||||
$_SESSION['compath'] = $compath;
|
$_SESSION['compath'] = $compath;
|
||||||
setcookie("compath", $compath, time()+31536000, "/", "jaj.com", true);
|
setcookie("compath", $compath, time()+31536000, "/", "jaj.com", true);
|
||||||
}
|
}
|
||||||
session_write_close();
|
|
||||||
|
|
||||||
// Build up a list of comics and issues which have been read in descending order by lastupdate
|
// Build up a list of comics and issues which have been read in descending order by lastupdate
|
||||||
$query = "SELECT comic, issue FROM pagetracker WHERE username=:username";
|
$query = "SELECT comic, issue FROM pagetracker WHERE username=:username";
|
||||||
|
|
@ -80,7 +79,7 @@ foreach ( $entries as $entry ) {
|
||||||
$readclass = "";
|
$readclass = "";
|
||||||
}
|
}
|
||||||
$info["div"] = "<div class='item folder{$readclass}' data-path=\"{$info["newpath"]}\" data-name=\"{$info["comname"]}\">";
|
$info["div"] = "<div class='item folder{$readclass}' data-path=\"{$info["newpath"]}\" data-name=\"{$info["comname"]}\">";
|
||||||
$info["div"] .= "<img class='thumbnail' src=\"{$info["thumburl"]}\"><br clear=all />{$info["comname"]}</div>";
|
$info["div"] .= "<img src=\"{$info["thumburl"]}\"><br clear=all />{$info["comname"]}</div>";
|
||||||
$folders[] = $info;
|
$folders[] = $info;
|
||||||
} else {
|
} else {
|
||||||
if ( (substr($entry, -3) == "cbz") || (substr($entry, -3) == "cbr") ) {
|
if ( (substr($entry, -3) == "cbz") || (substr($entry, -3) == "cbr") ) {
|
||||||
|
|
@ -106,7 +105,7 @@ foreach ( $entries as $entry ) {
|
||||||
$readclass = "";
|
$readclass = "";
|
||||||
}
|
}
|
||||||
$info["div"] = "<div class='item{$readclass}'>";
|
$info["div"] = "<div class='item{$readclass}'>";
|
||||||
$info["div"] .= "<img class='issue thumbnail' data-relcomic=\"{$info["relcomic"]}\" data-comname=\"{$info["comname"]}\" border=0 src=\"{$info["thumburl"]}\">";
|
$info["div"] .= "<img class='issue' data-relcomic=\"{$info["relcomic"]}\" data-comname=\"{$info["comname"]}\" border=0 src=\"{$info["thumburl"]}\">";
|
||||||
$info["div"] .= "<br clear=all /><a href=\"downloadcomic.php?comic={$info["relcomic"]}\">{$info["comname"]}</a></div>";
|
$info["div"] .= "<br clear=all /><a href=\"downloadcomic.php?comic={$info["relcomic"]}\">{$info["comname"]}</a></div>";
|
||||||
$issues[] = $info;
|
$issues[] = $info;
|
||||||
$thumbfile = "../" . THUMBSDIR . $data['compath'] . "/" . $info['comname'] . ".jpg";
|
$thumbfile = "../" . THUMBSDIR . $data['compath'] . "/" . $info['comname'] . ".jpg";
|
||||||
|
|
|
||||||
11
ajax/sess.php
Normal file
11
ajax/sess.php
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require '../header.php';
|
||||||
|
|
||||||
|
require_login();
|
||||||
|
|
||||||
|
$data = $_SESSION;
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
echo json_encode($data);
|
||||||
|
exit();
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require '../header.php';
|
require '../header.php';
|
||||||
session_write_close();
|
|
||||||
$validated = require_login(NOREDIRECT);
|
$validated = require_login(NOREDIRECT);
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ if ( !$validated ) {
|
||||||
|
|
||||||
$newpath = urldecode($_REQUEST['path']);
|
$newpath = urldecode($_REQUEST['path']);
|
||||||
|
|
||||||
$comicfull = realpath(COMICSDIR . "/" . $newpath);
|
$comicfull = realpath(COMICSDIR . $newpath);
|
||||||
if ( ($newpath == "/") || ($comicfull === false) || (substr($comicfull, 0, strlen(COMICSDIR)) != COMICSDIR) ) {
|
if ( ($newpath == "/") || ($comicfull === false) || (substr($comicfull, 0, strlen(COMICSDIR)) != COMICSDIR) ) {
|
||||||
$_SESSION['compath'] = "/";
|
$_SESSION['compath'] = "/";
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ if ( isset($_REQUEST['comic']) ) {
|
||||||
|
|
||||||
$ext = strtolower(substr($comicfull, -3));
|
$ext = strtolower(substr($comicfull, -3));
|
||||||
$_SESSION['comfile'] = basename($comicfull);
|
$_SESSION['comfile'] = basename($comicfull);
|
||||||
session_write_close();
|
|
||||||
|
|
||||||
// Get the current page for this comic or 0 (zero) if never opened
|
// Get the current page for this comic or 0 (zero) if never opened
|
||||||
$query = "SELECT currentpage FROM pagetracker WHERE username=:username AND issue=:issue";
|
$query = "SELECT currentpage FROM pagetracker WHERE username=:username AND issue=:issue";
|
||||||
|
|
|
||||||
|
|
@ -62,18 +62,13 @@ a, a:link, a:visited, a:active {
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
width: 25vw;
|
width: 330px;
|
||||||
height: calc(25vw * 1.5 + 2em);
|
height: 495px;
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
border: 2px solid var(--foreground-color);
|
border: 2px solid var(--foreground-color);
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
font-size: 2vw;
|
|
||||||
}
|
|
||||||
|
|
||||||
.thumbnail {
|
|
||||||
width: 95%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.readborder {
|
.readborder {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.25, maximum-scale=3.0, user-scalable=yes" />
|
<meta name="viewport" content="width=device-width, initial-scale=0.38, minimum-scale=0.25, maximum-scale=3.0, user-scalable=yes" />
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||||
<meta name="mobile-web-app-capable" content="yes" />
|
<meta name="mobile-web-app-capable" content="yes" />
|
||||||
<link rel="icon" sizes="128x128" href="img/comics_128.png" />
|
<link rel="icon" sizes="128x128" href="img/comics_128.png" />
|
||||||
|
|
|
||||||
49
js/comics.js
49
js/comics.js
|
|
@ -1,22 +1,14 @@
|
||||||
let folderRequest = false;
|
const NOREFRESH = false;
|
||||||
let lightbox = null;
|
|
||||||
toastr.options.escapeHtml = true;
|
|
||||||
toastr.options.preventDuplicates = true;
|
|
||||||
|
|
||||||
// This function is executed after the page load completes on the client
|
// This function is executed after the page load completes on the client
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#path").click(function() { changeFolder("/"); });
|
$("#path").click(function() { changeFolder("/"); });
|
||||||
$("#sortorder").on("click", cycleSortOrder);
|
$("#sortorder").on("click", cycleSortOrder);
|
||||||
$("#list").on("click", ".folder", function() {
|
|
||||||
changeFolder($(this).data("path"));
|
|
||||||
});
|
|
||||||
$("#list").on("click", ".issue", function() {
|
|
||||||
$(this).parent().addClass("readborder");
|
|
||||||
showComic($(this).data("relcomic"), $(this).data("comname"));
|
|
||||||
});
|
|
||||||
getSortOrder();
|
getSortOrder();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var lightbox = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redirects the user to the login page by replacing the current location with "index.php".
|
* Redirects the user to the login page by replacing the current location with "index.php".
|
||||||
* Logs a message to the console before redirecting.
|
* Logs a message to the console before redirecting.
|
||||||
|
|
@ -38,12 +30,12 @@ function getSortOrder(refresh = true) {
|
||||||
if ( !data.validated ) {
|
if ( !data.validated ) {
|
||||||
redirectToLogin();
|
redirectToLogin();
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
$("#sortorder").html(data.order);
|
$("#sortorder").html(data.order);
|
||||||
if ( refresh ) getFolderContents();
|
if ( refresh ) getFolderContents();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error : function(xhr, stat, err) {
|
error : function(xhr, stat, err) {
|
||||||
toastr.error("There was an error retrieving the current sort order.", "API Error...", {timeOut: 15000});
|
|
||||||
console.log(xhr.status);
|
console.log(xhr.status);
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
|
|
@ -58,18 +50,17 @@ function getSortOrder(refresh = true) {
|
||||||
function cycleSortOrder() {
|
function cycleSortOrder() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : 'ajax/cyclesortorder.php',
|
url : 'ajax/cyclesortorder.php',
|
||||||
type : 'POST',
|
|
||||||
dataType : 'json',
|
dataType : 'json',
|
||||||
success : function(data, stat, jqo) {
|
success : function(data, stat, jqo) {
|
||||||
if ( !data.validated ) {
|
if ( !data.validated ) {
|
||||||
redirectToLogin();
|
redirectToLogin();
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
$("#sortorder").html(data.order);
|
$("#sortorder").html(data.order);
|
||||||
getFolderContents();
|
getFolderContents();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error : function(xhr, stat, err) {
|
error : function(xhr, stat, err) {
|
||||||
toastr.error("There was an error retrieving the cycling sort order.", "API Error...", {timeOut: 15000});
|
|
||||||
console.log(xhr.status);
|
console.log(xhr.status);
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
|
|
@ -83,15 +74,15 @@ function cycleSortOrder() {
|
||||||
* - Shows a loading notification to the user.
|
* - Shows a loading notification to the user.
|
||||||
* - Sends an AJAX request to retrieve folder contents as JSON.
|
* - Sends an AJAX request to retrieve folder contents as JSON.
|
||||||
* - If the user is not validated, redirects to the login page.
|
* - If the user is not validated, redirects to the login page.
|
||||||
|
* - Updates the current path and path navigator.
|
||||||
* - Appends each folder or issue entry to the list.
|
* - Appends each folder or issue entry to the list.
|
||||||
|
* - Attaches click handlers to folder and issue elements for navigation and reading.
|
||||||
* - Removes the loading notification upon completion.
|
* - Removes the loading notification upon completion.
|
||||||
*
|
*
|
||||||
* @function
|
* @function
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function getFolderContents() {
|
function getFolderContents() {
|
||||||
if ( folderRequest ) return;
|
|
||||||
folderRequest = true;
|
|
||||||
$("#list").html("");
|
$("#list").html("");
|
||||||
toastr.info("Loading folder contents. Comics containing a large number of issues, or issues with a large number of pages, that have not been opened recently may take some time to load. Thank you for your patience!", "Loading Contents...", {timeOut: 15000});
|
toastr.info("Loading folder contents. Comics containing a large number of issues, or issues with a large number of pages, that have not been opened recently may take some time to load. Thank you for your patience!", "Loading Contents...", {timeOut: 15000});
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
@ -102,16 +93,16 @@ function getFolderContents() {
|
||||||
redirectToLogin();
|
redirectToLogin();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$("#list").html(data.contents.map(e => e.div).join(""));
|
data.contents.forEach(function(entry, index) {
|
||||||
|
$("#list").append(entry.div);
|
||||||
|
});
|
||||||
|
$(".folder").click(function() { changeFolder($(this).data("path")); });
|
||||||
|
$(".issue").click(function() { $(this).parent().addClass("readborder"); showComic($(this).data("relcomic"), $(this).data("comname")); });
|
||||||
toastr.remove();
|
toastr.remove();
|
||||||
},
|
},
|
||||||
error : function(xhr, stat, err) {
|
error : function(xhr, stat, err) {
|
||||||
toastr.error("There was an error retrieving the current folder contents.", "API Error...", {timeOut: 15000});
|
|
||||||
console.log(xhr.status);
|
console.log(xhr.status);
|
||||||
console.log(err);
|
console.log(err);
|
||||||
},
|
|
||||||
complete : function(xhr, stat) {
|
|
||||||
folderRequest = false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -120,12 +111,12 @@ function getFolderContents() {
|
||||||
* Changes the current folder by sending an AJAX request to update the path on the server.
|
* Changes the current folder by sending an AJAX request to update the path on the server.
|
||||||
* Displays a notification to the user and updates global variables upon success.
|
* Displays a notification to the user and updates global variables upon success.
|
||||||
*
|
*
|
||||||
|
* @param {string} name - The display name of the folder to open.
|
||||||
* @param {string} path - The path of the folder to open.
|
* @param {string} path - The path of the folder to open.
|
||||||
*/
|
*/
|
||||||
function changeFolder(path) {
|
function changeFolder(path) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : 'ajax/setpath.php',
|
url : 'ajax/setpath.php',
|
||||||
type : 'POST',
|
|
||||||
data : {path: path},
|
data : {path: path},
|
||||||
dataType : 'json',
|
dataType : 'json',
|
||||||
success : function(data, stat, jqo) {
|
success : function(data, stat, jqo) {
|
||||||
|
|
@ -137,7 +128,6 @@ function changeFolder(path) {
|
||||||
getFolderContents();
|
getFolderContents();
|
||||||
},
|
},
|
||||||
error : function(xhr, stat, err) {
|
error : function(xhr, stat, err) {
|
||||||
toastr.error("There was an error setting the current folder.", "API Error...", {timeOut: 15000});
|
|
||||||
console.log(xhr.status);
|
console.log(xhr.status);
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
|
|
@ -154,10 +144,9 @@ function changeFolder(path) {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function updateCurrentPage() {
|
function updateCurrentPage() {
|
||||||
let currentPage = lightbox.currentPosition;
|
var currentPage = lightbox.currentPosition;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : 'ajax/setpage.php',
|
url : 'ajax/setpage.php',
|
||||||
type : 'POST',
|
|
||||||
data : {page: currentPage},
|
data : {page: currentPage},
|
||||||
dataType : 'json',
|
dataType : 'json',
|
||||||
success : function(data, stat, jqo) {
|
success : function(data, stat, jqo) {
|
||||||
|
|
@ -168,7 +157,6 @@ function updateCurrentPage() {
|
||||||
console.log(data.message);
|
console.log(data.message);
|
||||||
},
|
},
|
||||||
error : function(xhr, stat, err) {
|
error : function(xhr, stat, err) {
|
||||||
toastr.error("There was an error setting current page for comic.", "API Error...", {timeOut: 15000});
|
|
||||||
console.log(xhr.status);
|
console.log(xhr.status);
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
|
|
@ -182,7 +170,6 @@ function updateCurrentPage() {
|
||||||
function closeComic() {
|
function closeComic() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : 'ajax/closecomic.php',
|
url : 'ajax/closecomic.php',
|
||||||
type : 'POST',
|
|
||||||
dataType : 'json',
|
dataType : 'json',
|
||||||
success : function(data, stat, jqo) {
|
success : function(data, stat, jqo) {
|
||||||
if ( !data.validated ) {
|
if ( !data.validated ) {
|
||||||
|
|
@ -191,7 +178,6 @@ function closeComic() {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error : function(xhr, stat, err) {
|
error : function(xhr, stat, err) {
|
||||||
toastr.error("There was an error closing the current comic.", "API Error...", {timeOut: 15000});
|
|
||||||
console.log(xhr.status);
|
console.log(xhr.status);
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
|
|
@ -216,7 +202,7 @@ function showComic(comic, name) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
toastr.remove();
|
toastr.remove();
|
||||||
if ( data.images.length === 0 ) {
|
if ( data.images.length == 0 ) {
|
||||||
toastr.error("There doesn't seem to be any images in this comic. Please contact the admin!", "Comics is empty", {timeOut: 8000});
|
toastr.error("There doesn't seem to be any images in this comic. Please contact the admin!", "Comics is empty", {timeOut: 8000});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -229,7 +215,6 @@ function showComic(comic, name) {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error : function(xhr, stat, err) {
|
error : function(xhr, stat, err) {
|
||||||
toastr.error("There was an error showing selected comic contents.", "API Error...", {timeOut: 15000});
|
|
||||||
console.log(xhr.status);
|
console.log(xhr.status);
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user