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