$a["mtime"];
}
# usort function for sorting by array's "name"
# Does "natural" sorting so "28 Days Later" comes before "2099 Hulk"
function compareNames($a, $b) {
if ( $a["name"] == $b["name"] ) return 0;
return strnatcasecmp($a["name"], $b["name"]);
}
$compath = $_SESSION['compath'];
$fullcompath = COMICSDIR . $compath . (($compath == "/") ? "" : "/") . "/";
if ( !is_dir($fullcompath) ) {
$compath = "/";
$fullcompath = COMICSDIR . $compath . (($compath == "/") ? "" : "/") . "/";
$_SESSION['compath'] = $compath;
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
$query = "SELECT comic, issue FROM pagetracker WHERE username=:username";
//$query = "SELECT comic, issue FROM pagetracker WHERE username=:username ORDER BY lastupdate DESC";
$sth = $globaldbh->prepare($query);
$sth->bindValue(":username", $_SESSION['username'], PDO::PARAM_STR);
$sth->execute();
$comics_read = array();
$issues_read = array();
while ( $row = $sth->fetch(PDO::FETCH_ASSOC) ) {
$comics_read[$row['comic']] = true;
$issues_read[$row['issue']] = true;
}
$adultcomics = array_flip(getAdultComics());
$folders = array();
$issues = array();
$entries = scandir($fullcompath);
$data["makethumb"] = array();
foreach ( $entries as $entry ) {
if ( ($entry == ".") || ($entry == "..") ) continue;
if ( (ADULTMODE || !$_SESSION['adult']) && isset($adultcomics[$entry]) ) continue;
$info = array();
$info["name"] = $entry;
$info["namesafe"] = htmlspecialchars($entry, ENT_QUOTES);
if ( is_dir($fullcompath . $entry) ) {
$info["comname"] = (strpos($entry, " - ") !== false) ? str_replace(" - ", "
", $entry) : $entry;
$info["newpath"] = $compath . (($compath == "/") ? "" : "/") . $entry;
if ( $_SESSION["sortorder"] == SORTBYDATE ) $info["mtime"] = filemtime($fullcompath . $entry);
//$info["thumburl"] = htmlentities(THUMBSDIR . $compath . (($compath == "/") ? "" : "/") . $entry, ENT_QUOTES) . ".jpg";
$info["thumburl"] = THUMBSDIR . $compath . (($compath == "/") ? "" : "/") . $entry . ".jpg";
if ( isset($comics_read[$entry]) ) {
$info["read"] = true;
$readclass = " readborder";
} else {
$info["read"] = false;
$readclass = "";
}
$info["div"] = "