mirror of
https://bitbucket.org/jsuto/piler.git
synced 2025-06-12 23:27:03 +02:00
added bulk download feature
This commit is contained in:
45
webui/model/message/restore.php
Normal file
45
webui/model/message/restore.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
class ModelMessageRestore extends Model {
|
||||
|
||||
|
||||
public function download_files_as_zip($idlist = array()) {
|
||||
|
||||
$zip = new ZipArchive();
|
||||
|
||||
$randomid = generate_random_string(16);
|
||||
|
||||
$filename = DIR_TMP . "/" . $randomid;
|
||||
|
||||
if($zip->open($filename, ZIPARCHIVE::CREATE) != true) { exit("cannot open <$filename>\n"); }
|
||||
|
||||
foreach($idlist as $id) {
|
||||
$rawemail = $this->model_search_message->get_raw_message($id);
|
||||
$zip->addFromString($id . ".eml", $rawemail);
|
||||
|
||||
AUDIT(ACTION_DOWNLOAD_MESSAGE, '', '', $id, '');
|
||||
}
|
||||
|
||||
|
||||
$zip->close();
|
||||
|
||||
|
||||
header("Cache-Control: public, must-revalidate");
|
||||
header("Pragma: no-cache");
|
||||
header("Content-Type: application/zip");
|
||||
header("Expires: 0");
|
||||
header("Content-Length: " . filesize($filename));
|
||||
header("Content-Disposition: attachment; filename=archive-$randomid.zip");
|
||||
header("Content-Transfer-Encoding: binary\n");
|
||||
|
||||
readfile($filename);
|
||||
|
||||
unlink($filename);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
Reference in New Issue
Block a user