Compare commits
5 Commits
078ea8d4fa
...
6460cfca37
| Author | SHA1 | Date | |
|---|---|---|---|
| 6460cfca37 | |||
| ee02a15182 | |||
| dca541c6b8 | |||
| b55e3c1d92 | |||
| 7aecf00971 |
|
|
@ -47,41 +47,52 @@ if ( $row = $sth->fetch(PDO::FETCH_ASSOC) ) {
|
||||||
}
|
}
|
||||||
$data["startindex"] = $currentpage;
|
$data["startindex"] = $currentpage;
|
||||||
|
|
||||||
|
$extracted = false;
|
||||||
if ( !is_dir($comicoutputfull) ) {
|
if ( !is_dir($comicoutputfull) ) {
|
||||||
mkdir($comicoutputfull, 0755, true);
|
mkdir($comicoutputfull, 0755, true);
|
||||||
|
} else {
|
||||||
|
touch($comicoutputfull);
|
||||||
|
$extracted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$files = array();
|
$files = array();
|
||||||
if ( $ext == "cbz" ) {
|
if ( $extracted ) {
|
||||||
$zip = new ZipArchive();
|
$contents = glob($comicoutputfull . "*");
|
||||||
$opened = $zip->open($comicfull);
|
foreach ( $contents as $i ) {
|
||||||
for ( $i=0; $i<$zip->numFiles; $i++ ) {
|
$files[] = basename($i);
|
||||||
$imgname = basename($zip->getNameIndex($i));
|
|
||||||
//$myext = substr($imgname, -3);
|
|
||||||
if ( ! isset(pathinfo($imgname)['extension']) ) continue;
|
|
||||||
$myext = strtolower(pathinfo($imgname)['extension']);
|
|
||||||
if ( ($myext == "jpeg") || ($myext == "jpg") || ($myext == "png") || ($myext == "webp") ) {
|
|
||||||
$imgname = str_replace("#", "", $imgname);
|
|
||||||
$imgcontents = $zip->getFromIndex($i);
|
|
||||||
$written = file_put_contents($comicoutputfull . $imgname, $imgcontents);
|
|
||||||
if ( $written ) $files[] = $imgname;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} elseif ( $ext == "cbr" ) {
|
|
||||||
$rar = RarArchive::open($comicfull);
|
|
||||||
$entries = $rar->getEntries();
|
|
||||||
foreach ( $entries as $entry ) {
|
|
||||||
$outfile = str_replace("#", "", basename($entry->getName()));
|
|
||||||
$entry->extract(false, $comicoutputfull . $outfile);
|
|
||||||
if ( ! isset(pathinfo($outfile)['extension']) ) continue;
|
|
||||||
$myext = strtolower(pathinfo($outfile)['extension']);
|
|
||||||
if ( ($myext == "jpeg") || ($myext == "jpg") || ($myext == "png") || ($myext == "webp") ) {
|
|
||||||
$files[] = basename($outfile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unset($entry);
|
|
||||||
} else {
|
} else {
|
||||||
exit();
|
if ( $ext == "cbz" ) {
|
||||||
|
$zip = new ZipArchive();
|
||||||
|
$opened = $zip->open($comicfull);
|
||||||
|
for ( $i=0; $i<$zip->numFiles; $i++ ) {
|
||||||
|
$imgname = basename($zip->getNameIndex($i));
|
||||||
|
//$myext = substr($imgname, -3);
|
||||||
|
if ( ! isset(pathinfo($imgname)['extension']) ) continue;
|
||||||
|
$myext = strtolower(pathinfo($imgname)['extension']);
|
||||||
|
if ( ($myext == "jpeg") || ($myext == "jpg") || ($myext == "png") || ($myext == "webp") ) {
|
||||||
|
$imgname = str_replace("#", "", $imgname);
|
||||||
|
$imgcontents = $zip->getFromIndex($i);
|
||||||
|
$written = file_put_contents($comicoutputfull . $imgname, $imgcontents);
|
||||||
|
if ( $written ) $files[] = $imgname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} elseif ( $ext == "cbr" ) {
|
||||||
|
$rar = RarArchive::open($comicfull);
|
||||||
|
$entries = $rar->getEntries();
|
||||||
|
foreach ( $entries as $entry ) {
|
||||||
|
$outfile = str_replace("#", "", basename($entry->getName()));
|
||||||
|
$entry->extract(false, $comicoutputfull . $outfile);
|
||||||
|
if ( ! isset(pathinfo($outfile)['extension']) ) continue;
|
||||||
|
$myext = strtolower(pathinfo($outfile)['extension']);
|
||||||
|
if ( ($myext == "jpeg") || ($myext == "jpg") || ($myext == "png") || ($myext == "webp") ) {
|
||||||
|
$files[] = basename($outfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($entry);
|
||||||
|
} else {
|
||||||
|
exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
natsort($files);
|
natsort($files);
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,14 @@ $projectRoot = dirname(dirname(__FILE__));
|
||||||
|
|
||||||
require "{$projectRoot}/header.php";
|
require "{$projectRoot}/header.php";
|
||||||
|
|
||||||
if ( $argc != 2 ) {
|
if ( $argc == 1 ) {
|
||||||
$daysToKeep = 10;
|
$daysToKeep = 10;
|
||||||
} else {
|
} else {
|
||||||
$daysToKeep = intval($argv[1]);
|
$daysToKeep = intval($argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$dryrun = (in_array("--dryrun", $argv)) ? true : false;
|
||||||
|
|
||||||
$ed = $projectRoot . "/" . EXTRACTSDIR;
|
$ed = $projectRoot . "/" . EXTRACTSDIR;
|
||||||
$now = time();
|
$now = time();
|
||||||
$maxAge = $now - (86400*$daysToKeep);
|
$maxAge = $now - (86400*$daysToKeep);
|
||||||
|
|
@ -21,7 +23,7 @@ foreach ( $files as $file ) {
|
||||||
if ( $file->isDir() && in_array($file->getExtension(), $validExtensions) ) {
|
if ( $file->isDir() && in_array($file->getExtension(), $validExtensions) ) {
|
||||||
if ( filemtime($file->getRealPath()) <= $maxAge ) {
|
if ( filemtime($file->getRealPath()) <= $maxAge ) {
|
||||||
echo "Found aged extracted comic: {$file->getFilename()}\n";
|
echo "Found aged extracted comic: {$file->getFilename()}\n";
|
||||||
exec("rm -rf \"{$file->getRealPath()}\"", $output, $retval);
|
if ( !$dryrun ) exec("rm -rf \"{$file->getRealPath()}\"", $output, $retval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ a, a:link, a:visited, a:active {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
border-bottom: 2px solid var(--default-color);
|
border-bottom: 2px solid var(--foreground-color);
|
||||||
}
|
}
|
||||||
.sorter {
|
.sorter {
|
||||||
float: left;
|
float: left;
|
||||||
|
|
@ -65,7 +65,7 @@ a, a:link, a:visited, a:active {
|
||||||
width: 330px;
|
width: 330px;
|
||||||
height: 495px;
|
height: 495px;
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
border: 2px solid var(--default-color);
|
border: 2px solid var(--foreground-color);
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,10 @@
|
||||||
<link rel="apple-touch-icon" sizes="512x512" href="img/comics_512.png" />
|
<link rel="apple-touch-icon" sizes="512x512" href="img/comics_512.png" />
|
||||||
<link rel="manifest" href="manifest.json" />
|
<link rel="manifest" href="manifest.json" />
|
||||||
<title>JAJ Comics</title>
|
<title>JAJ Comics</title>
|
||||||
<link rel='stylesheet' type='text/css' href='css/reset.css' media='screen' />
|
|
||||||
<link rel='stylesheet' type='text/css' href='css/comics.css' media='screen' />
|
|
||||||
<link rel="stylesheet" type="text/css" href="core/simpleLightbox.min.css" />
|
<link rel="stylesheet" type="text/css" href="core/simpleLightbox.min.css" />
|
||||||
<!-- <link rel="stylesheet" type="text/css" href="core/simple-lightbox.min.css" /> -->
|
<!-- <link rel="stylesheet" type="text/css" href="core/simple-lightbox.min.css" /> -->
|
||||||
<link rel="stylesheet" type="text/css" href="core/toastr.css" />
|
<link rel="stylesheet" type="text/css" href="core/toastr.css" />
|
||||||
|
<link rel='stylesheet' type='text/css' href='css/reset.css' media='screen' />
|
||||||
|
<link rel='stylesheet' type='text/css' href='css/comics.css' media='screen' />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,4 @@
|
||||||
Description="A script to remove extracted comics in webapp older than a set age (defaults to 10 days)"
|
Description="A script to remove extracted comics in webapp older than a set age (defaults to 10 days)"
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=/usr/bin/php /var/www/htdocs/comics/cron/clearExtracts.php
|
ExecStart=/usr/bin/php /var/www/htdocs/comics/cron/clearextracts.php
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user