forked from Cavemanon/cavepaintings
download all images function for admin
This commit is contained in:
parent
1fd565fa87
commit
07e786101d
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,8 +1,10 @@
|
||||
.svn
|
||||
backup
|
||||
data
|
||||
config.php
|
||||
images
|
||||
imgdump-*.zip
|
||||
thumbs
|
||||
data
|
||||
sql.log
|
||||
shimmie.log
|
||||
!lib/images
|
||||
|
@ -82,6 +82,9 @@ class AdminPage extends SimpleExtension {
|
||||
$this->reset_imageids();
|
||||
$redirect = true;
|
||||
break;
|
||||
case 'image dump':
|
||||
$this->imgdump($page);
|
||||
break;
|
||||
}
|
||||
|
||||
if($redirect) {
|
||||
@ -218,5 +221,28 @@ class AdminPage extends SimpleExtension {
|
||||
$count = (count($image)) + 1;
|
||||
$database->execute("ALTER TABLE images AUTO_INCREMENT=".$count);
|
||||
}
|
||||
|
||||
private function imgdump($page) {
|
||||
global $database;
|
||||
$zip = new ZipArchive;
|
||||
$images = $database->get_all("SELECT * FROM images");
|
||||
$filename = 'imgdump-'.date('Ymd').'.zip';
|
||||
|
||||
if($zip->open($filename, 1 ? ZIPARCHIVE::OVERWRITE:ZIPARCHIVE::CREATE)===TRUE){
|
||||
foreach($images as $img){
|
||||
$hash = $img["hash"];
|
||||
preg_match("^[A-Za-z0-9]{2}^", $hash, $matches);
|
||||
$img_loc = "images/".$matches[0]."/".$hash;
|
||||
if(file_exists($img_loc)){
|
||||
$zip->addFile($img_loc, $hash.".".$img["ext"]);
|
||||
}
|
||||
|
||||
}
|
||||
$zip->close();
|
||||
}
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link($filename)); //Fairly sure there is better way to do this..
|
||||
//TODO: Delete file after downloaded?
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -27,6 +27,7 @@ class AdminPageTheme extends Themelet {
|
||||
<option value='purge unused tags'>Purge unused tags</option>
|
||||
<option value='database dump'>Download database contents</option>
|
||||
<option value='reset image ids'>Reset image ids</option>
|
||||
<option value='image dump'>Download all images</option>
|
||||
<!--<option value='convert to innodb'>Convert database to InnoDB (MySQL only)</option>-->
|
||||
</select>
|
||||
<input type='submit' value='Go'>
|
||||
|
Loading…
Reference in New Issue
Block a user