prepare($query); $sth->execute($fields); $comics_read = array(); $issues_read = array(); while ( $row = $sth->fetch(PDO::FETCH_ASSOC) ) { if ( !in_array($row['comic'], $comics_read) ) $comics_read[] = $row['comic']; if ( !in_array($row['issue'], $issues_read) ) $issues_read[] = $row['issue']; } $data = array(); $folders = array(); $issues = array(); $entries = scandir($fullcompath); foreach ( $entries as $entry ) { if ( ($entry == ".") || ($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; $info["mtime"] = filemtime($fullcompath . $entry); //$info["thumburl"] = htmlentities(THUMBSDIR . $compath . (($compath == "/") ? "" : "/") . $entry, ENT_QUOTES) . ".jpg"; $info["thumburl"] = THUMBSDIR . $compath . (($compath == "/") ? "" : "/") . $entry . ".jpg"; if ( in_array($entry, $comics_read) ) { $info["read"] = true; $readclass = " readborder"; } else { $info["read"] = false; $readclass = ""; } $info["div"] = "
"; $info["div"] .= "
{$info["comname"]}
"; $folders[] = $info; } else { if ( (substr($entry, -3) == "cbz") || (substr($entry, -3) == "cbr") ) { $info["comname"] = substr(((strpos($entry, " - ") !== false) ? str_replace(" - ", "
", $entry) : $entry), 0, -4); $info["relcomic"] = base64_encode($compath . (($compath == "/") ? "" : "/") . $entry); $info["mtime"] = filemtime($fullcompath . $entry); $info["thumburl"] = htmlentities(THUMBSDIR . $compath . (($compath == "/") ? "" : "/") . substr($entry, 0, -4), ENT_QUOTES) . ".jpg"; if ( in_array($entry, $issues_read) ) { $info["read"] = true; $readclass = " readborder"; } else { $info["read"] = false; $readclass = ""; } $info["div"] = "
"; $info["div"] .= ""; $info["div"] .= "
{$info["comname"]}
"; $issues[] = $info; } } if ( isset($info["thumburl"]) && !file_exists("../" . $info["thumburl"]) ) { $havethumb = makeThumb($fullcompath . $entry); } } // Sort folders based on current sort order if ( $_SESSION["sortorder"] == SORTBYNAME ) { usort($folders, "compareNames"); } else { usort($folders, "compareDates"); } // Always sort issues by name usort($issues, "compareNames"); $data["compath"] = $compath; $data["contents"] = array_merge($folders, $issues); header('Content-Type: application/json'); echo json_encode($data); exit(); // vim: set ts=4 sw=4 et: