diff --git a/.gitignore b/.gitignore index 6dd0495a..1258151b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ .svn +backup +data config.php images +imgdump-*.zip thumbs -data sql.log shimmie.log !lib/images diff --git a/contrib/admin/main.php b/contrib/admin/main.php index de3bf10a..c7e5b1a1 100644 --- a/contrib/admin/main.php +++ b/contrib/admin/main.php @@ -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? + } } ?> diff --git a/contrib/admin/theme.php b/contrib/admin/theme.php index 37d1f7e2..c1126fdb 100644 --- a/contrib/admin/theme.php +++ b/contrib/admin/theme.php @@ -27,6 +27,7 @@ class AdminPageTheme extends Themelet { +