Compare commits
6 Commits
5e58c8e28f
...
b02d2ac1c1
| Author | SHA1 | Date | |
|---|---|---|---|
| b02d2ac1c1 | |||
| 9fd372c6d0 | |||
| 8d30dd172e | |||
| b9b92ab1e4 | |||
| d0b610f572 | |||
| 7b95cd8923 |
|
|
@ -20,18 +20,16 @@ if ( !$validated ) {
|
|||
# usort function for sorting by array's "mtime"
|
||||
# Return 1 or -1 in reverse order so newest is first
|
||||
function compareDates($a, $b) {
|
||||
if ( $a["mtime"] == $b["mtime"] ) return 0;
|
||||
return ($a["mtime"] < $b["mtime"]) ? 1 : -1;
|
||||
return $b["mtime"] <=> $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 strnatcmp($a["name"], $b["name"]);
|
||||
return strnatcasecmp($a["name"], $b["name"]);
|
||||
}
|
||||
|
||||
$adultcomics = getAdultComics();
|
||||
|
||||
$compath = $_SESSION['compath'];
|
||||
$fullcompath = COMICSDIR . $compath . (($compath == "/") ? "" : "/") . "/";
|
||||
|
|
@ -52,9 +50,10 @@ $sth->execute();
|
|||
$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'];
|
||||
$comics_read[$row['comic']] = true;
|
||||
$issues_read[$row['issue']] = true;
|
||||
}
|
||||
$adultcomics = array_flip(getAdultComics());
|
||||
|
||||
$folders = array();
|
||||
$issues = array();
|
||||
|
|
@ -62,24 +61,24 @@ $entries = scandir($fullcompath);
|
|||
$data["makethumb"] = array();
|
||||
foreach ( $entries as $entry ) {
|
||||
if ( ($entry == ".") || ($entry == "..") ) continue;
|
||||
if ( (ADULTMODE || !$_SESSION['adult']) && in_array($entry, $adultcomics) ) 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(" - ", "<br />", $entry) : $entry;
|
||||
$info["newpath"] = $compath . (($compath == "/") ? "" : "/") . $entry;
|
||||
$info["mtime"] = filemtime($fullcompath . $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 ( in_array($entry, $comics_read) ) {
|
||||
if ( isset($comics_read[$entry]) ) {
|
||||
$info["read"] = true;
|
||||
$readclass = " readborder";
|
||||
} else {
|
||||
$info["read"] = false;
|
||||
$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"]}\" >";
|
||||
$info["div"] .= "<img class='thumbnail' src=\"{$info["thumburl"]}\"><br clear=all />{$info["comname"]}</div>";
|
||||
$folders[] = $info;
|
||||
} else {
|
||||
|
|
@ -96,9 +95,9 @@ foreach ( $entries as $entry ) {
|
|||
}
|
||||
//$info["comname"] = substr(((strpos($entry, " - ") !== false) ? str_replace(" - ", "<br />", $entry) : $entry), 0, -4);
|
||||
$info["relcomic"] = base64_encode($compath . (($compath == "/") ? "" : "/") . $entry);
|
||||
$info["mtime"] = filemtime($fullcompath . $entry);
|
||||
if ( $_SESSION["sortorder"] == SORTBYDATE ) $info["mtime"] = filemtime($fullcompath . $entry);
|
||||
$info["thumburl"] = THUMBSDIR . $compath . (($compath == "/") ? "" : "/") . $withoutext . ".jpg";
|
||||
if ( in_array($entry, $issues_read) ) {
|
||||
if ( isset($issues_read[$entry]) ) {
|
||||
$info["read"] = true;
|
||||
$readclass = " readborder";
|
||||
} else {
|
||||
|
|
@ -109,7 +108,7 @@ foreach ( $entries as $entry ) {
|
|||
$info["div"] .= "<img class='issue thumbnail' 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>";
|
||||
$issues[] = $info;
|
||||
$thumbfile = "../" . THUMBSDIR . $data['compath'] . "/" . $info['comname'] . ".jpg";
|
||||
//$thumbfile = "../" . THUMBSDIR . $data['compath'] . "/" . $info['comname'] . ".jpg";
|
||||
}
|
||||
}
|
||||
if ( isset($info["thumburl"]) && !file_exists("../" . $info["thumburl"]) ) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ if ( !$validated ) {
|
|||
}
|
||||
|
||||
if ( isset($_REQUEST['comic']) ) {
|
||||
$comicfull = realpath(COMICSDIR . base64_decode(urldecode($_REQUEST['comic'])));
|
||||
$comicfull = realpath(COMICSDIR . base64_decode($_REQUEST['comic']));
|
||||
$data["filename"] = basename($comicfull);
|
||||
if ( $comicfull === false ) exit();
|
||||
if ( substr($comicfull, 0, strlen(COMICSDIR)) != COMICSDIR ) exit();
|
||||
|
|
@ -62,33 +62,54 @@ if ( $extracted ) {
|
|||
$files[] = basename($i);
|
||||
}
|
||||
} else {
|
||||
if ( $ext == "cbz" ) {
|
||||
$magic = file_get_contents($comicfull, false, null, 0, 4);
|
||||
if ( substr($magic, 0, 2) === "PK" ) {
|
||||
$comtype = "cbz";
|
||||
} elseif ( $magic === "Rar!" ) {
|
||||
$comtype = "cbr";
|
||||
}
|
||||
if ( $comtype == "cbz" ) {
|
||||
$zip = new ZipArchive();
|
||||
$opened = $zip->open($comicfull);
|
||||
for ( $i=0; $i<$zip->numFiles; $i++ ) {
|
||||
$imgname = basename($zip->getNameIndex($i));
|
||||
if ( ! isset(pathinfo($imgname)['extension']) ) continue;
|
||||
$myext = strtolower(pathinfo($imgname)['extension']);
|
||||
if ( ! in_array($myext, VALIDIMAGETYPES) ) continue;
|
||||
$imgname = str_replace("#", "", $imgname);
|
||||
$imgcontents = $zip->getFromIndex($i);
|
||||
$written = file_put_contents($comicoutputfull . $imgname, $imgcontents);
|
||||
if ( $written ) $files[] = $imgname;
|
||||
if ( !$opened ) {
|
||||
$data["error"] = true;
|
||||
$data["message"] = "Error opening comic file";
|
||||
} else {
|
||||
for ( $i=0; $i<$zip->numFiles; $i++ ) {
|
||||
$imgname = basename($zip->getNameIndex($i));
|
||||
if ( ! isset(pathinfo($imgname)['extension']) ) continue;
|
||||
if ( (substr($imgname, 0, 8) == "__MACOSX") || (substr($imgname, 0, 2) == "._") ) continue;
|
||||
$myext = strtolower(pathinfo($imgname)['extension']);
|
||||
if ( ! in_array($myext, VALIDIMAGETYPES) ) continue;
|
||||
$imgname = str_replace("#", "", $imgname);
|
||||
$imgcontents = $zip->getFromIndex($i);
|
||||
$written = file_put_contents($comicoutputfull . $imgname, $imgcontents);
|
||||
if ( $written ) $files[] = $imgname;
|
||||
}
|
||||
$zip->close();
|
||||
}
|
||||
} elseif ( $ext == "cbr" ) {
|
||||
} elseif ( $comtype == "cbr" ) {
|
||||
$rar = RarArchive::open($comicfull);
|
||||
$entries = $rar->getEntries();
|
||||
foreach ( $entries as $entry ) {
|
||||
$outfile = str_replace("#", "", basename($entry->getName()));
|
||||
if ( ! isset(pathinfo($outfile)['extension']) ) continue;
|
||||
$myext = strtolower(pathinfo($outfile)['extension']);
|
||||
if ( ! in_array($myext, VALIDIMAGETYPES) ) continue;
|
||||
$entry->extract(false, $comicoutputfull . $outfile);
|
||||
$files[] = basename($outfile);
|
||||
if ( $rar === false ) {
|
||||
$data["error"] = true;
|
||||
$data["message"] = "Error opening comic file";
|
||||
} else {
|
||||
$entries = $rar->getEntries();
|
||||
foreach ( $entries as $entry ) {
|
||||
$outfile = str_replace("#", "", basename($entry->getName()));
|
||||
if ( ! isset(pathinfo($outfile)['extension']) ) continue;
|
||||
if ( (substr($outfile, 0, 8) == "__MACOSX") || (substr($outfile, 0, 2) == "._") ) continue;
|
||||
$myext = strtolower(pathinfo($outfile)['extension']);
|
||||
if ( ! in_array($myext, VALIDIMAGETYPES) ) continue;
|
||||
$entry->extract(false, $comicoutputfull . $outfile);
|
||||
$files[] = basename($outfile);
|
||||
}
|
||||
unset($entry);
|
||||
$rar->close();
|
||||
}
|
||||
unset($entry);
|
||||
} else {
|
||||
exit();
|
||||
$data["error"] = true;
|
||||
$data["message"] = "Error invalid comic file format";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,8 +62,8 @@ a, a:link, a:visited, a:active {
|
|||
|
||||
.item {
|
||||
cursor: pointer;
|
||||
width: 25vw;
|
||||
height: calc(25vw * 1.5 + 2em);
|
||||
width: 20vw;
|
||||
height: calc(20vw * 1.5 + 2em);
|
||||
margin: 5px;
|
||||
border: 2px solid var(--foreground-color);
|
||||
padding: 2px;
|
||||
|
|
@ -73,7 +73,7 @@ a, a:link, a:visited, a:active {
|
|||
}
|
||||
|
||||
.thumbnail {
|
||||
width: 95%;
|
||||
width: 98%;
|
||||
}
|
||||
|
||||
.readborder {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user