Compare commits

...

2 Commits

Author SHA1 Message Date
ecad8d90d6 Fix conditional indentation. Add vim modeline. 2025-09-30 14:09:44 -04:00
bd56aee162 Add error handling to jQuery AJAX calls 2025-09-29 10:58:38 -04:00
2 changed files with 35 additions and 11 deletions

View File

@ -17,38 +17,38 @@ if ( php_sapi_name() != "cli" ) {
// This session variable is TRUE when successfully logged in // This session variable is TRUE when successfully logged in
// If set to true, and using default authentication, no login will be required // If set to true, and using default authentication, no login will be required
if ( !isset($_SESSION['validated']) ) { if ( !isset($_SESSION['validated']) ) {
$_SESSION['validated'] = false; $_SESSION['validated'] = false;
} }
// This session variable is set to the current browsing folder. // This session variable is set to the current browsing folder.
// It is relative to the COMICSDIR constant defined in variables.php // It is relative to the COMICSDIR constant defined in variables.php
if ( !isset($_SESSION['compath']) ) { if ( !isset($_SESSION['compath']) ) {
$_SESSION['compath'] = '/'; $_SESSION['compath'] = '/';
} }
if ( $_SESSION['compath'] == "" ) $_SESSION['compath'] = "/"; if ( $_SESSION['compath'] == "" ) $_SESSION['compath'] = "/";
// This session variable is set to the current comic in Base64 // This session variable is set to the current comic in Base64
if ( !isset($_SESSION['comfile']) ) { if ( !isset($_SESSION['comfile']) ) {
$_SESSION['comfile'] = ""; $_SESSION['comfile'] = "";
} }
// Initialize the hash session variable used for SSO // Initialize the hash session variable used for SSO
// Set the hash to the passed in value if it exists // Set the hash to the passed in value if it exists
if ( !isset($_SESSION['hash']) ) { if ( !isset($_SESSION['hash']) ) {
$_SESSION['hash'] = ""; $_SESSION['hash'] = "";
} }
if ( isset($_REQUEST['hash']) ) { if ( isset($_REQUEST['hash']) ) {
$_SESSION['hash'] = $_REQUEST['hash']; $_SESSION['hash'] = $_REQUEST['hash'];
} }
// Sorting for folders. // Sorting for folders.
// Valid values (from constants): SORTBYNAME, SORTBYDATE // Valid values (from constants): SORTBYNAME, SORTBYDATE
if ( !isset($_SESSION['sortorder']) ) { if ( !isset($_SESSION['sortorder']) ) {
$_SESSION['sortorder'] = SORTBYDATE; $_SESSION['sortorder'] = SORTBYDATE;
} }
} }
// Make our PDO database connection which will be used in all scripts // Make our PDO database connection which will be used in all scripts
$globaldbh = new PDO("mysql:host=" . DBHOST . ";dbname=" . DBNAME, DBUSER, DBPASS); $globaldbh = new PDO("mysql:host=" . DBHOST . ";dbname=" . DBNAME, DBUSER, DBPASS);
?> // vim: sw=4 ts=4 et ai mouse-=a:

View File

@ -38,6 +38,10 @@ function getSortOrder(refresh = true) {
$("#sortorder").html(data.order); $("#sortorder").html(data.order);
if ( refresh ) getFolderContents(); if ( refresh ) getFolderContents();
} }
},
error : function(xhr, stat, err) {
console.log(xhr.status);
console.log(err);
} }
}); });
} }
@ -59,6 +63,10 @@ function cycleSortOrder() {
$("#sortorder").html(data.order); $("#sortorder").html(data.order);
getFolderContents(); getFolderContents();
} }
},
error : function(xhr, stat, err) {
console.log(xhr.status);
console.log(err);
} }
}); });
} }
@ -97,7 +105,11 @@ function getFolderContents() {
$(".folder").click(function() { changeFolder($(this).data("name"), $(this).data("path")); }); $(".folder").click(function() { changeFolder($(this).data("name"), $(this).data("path")); });
$(".issue").click(function() { $(this).parent().addClass("readborder"); showComic($(this).data("relcomic"), $(this).data("comname")); }); $(".issue").click(function() { $(this).parent().addClass("readborder"); showComic($(this).data("relcomic"), $(this).data("comname")); });
toastr.remove(); toastr.remove();
} },
error : function(xhr, stat, err) {
console.log(xhr.status);
console.log(err);
}
}); });
} }
@ -141,7 +153,11 @@ function changeFolder(name, path) {
foldername = data.foldername; foldername = data.foldername;
toastr.remove(); toastr.remove();
getFolderContents(); getFolderContents();
} },
error : function(xhr, stat, err) {
console.log(xhr.status);
console.log(err);
}
}); });
} }
@ -166,7 +182,11 @@ function updateCurrentPage() {
return; return;
} }
console.log(data.message); console.log(data.message);
} },
error : function(xhr, stat, err) {
console.log(xhr.status);
console.log(err);
}
}); });
} }
@ -196,7 +216,11 @@ function showComic(comic, name) {
startAt: data.startindex, startAt: data.startindex,
beforeSetContent: updateCurrentPage beforeSetContent: updateCurrentPage
}); });
} },
error : function(xhr, stat, err) {
console.log(xhr.status);
console.log(err);
}
}); });
} }