diff --git a/util/Makefile.in b/util/Makefile.in index fb5f228e..34e8e120 100644 --- a/util/Makefile.in +++ b/util/Makefile.in @@ -28,6 +28,7 @@ all: install: $(INSTALL) -m 0755 $(srcdir)/ldap_sync.php $(DESTDIR)$(libexecdir)/piler + $(INSTALL) -m 0755 $(srcdir)/daily-report.php $(DESTDIR)$(libexecdir)/piler clean: diff --git a/webui/config.php b/webui/config.php index 334bb733..366ec7ac 100644 --- a/webui/config.php +++ b/webui/config.php @@ -22,6 +22,7 @@ define('ICON_ATTACHMENT', '/view/theme/default/images/attachment_icon.png'); define('ICON_TAG', '/view/theme/default/images/tag_blue.png'); define('ICON_GREEN_OK', '/view/theme/default/images/green_ok.png'); define('ICON_RED_X', '/view/theme/default/images/red_x.png'); +define('ICON_DOWNLOAD', '/view/theme/default/images/download_icon.jpg'); define('MAX_CGI_FROM_SUBJ_LEN', 45); define('PAGE_LEN', 20); @@ -53,6 +54,7 @@ define('DIR_APPLICATION', DIR_BASE . 'controller/'); define('DIR_THEME', DIR_BASE . 'view/theme/'); define('DIR_REPORT', DIR_BASE . 'reports/'); define('DIR_LOG', DIR_BASE . 'log/'); +define('DIR_TMP', DIR_BASE . 'tmp/'); define('DIR_STORE', '/var/piler/store'); define('DIR_STAT', '/var/piler/stat'); diff --git a/webui/controller/message/bulkrestore.php b/webui/controller/message/bulkrestore.php index f97a4b8d..08718302 100644 --- a/webui/controller/message/bulkrestore.php +++ b/webui/controller/message/bulkrestore.php @@ -14,6 +14,7 @@ class ControllerMessageBulkrestore extends Controller { $this->load->model('search/search'); $this->load->model('search/message'); + $this->load->model('message/restore'); $this->load->model('user/user'); $this->load->model('mail/mail'); @@ -24,13 +25,28 @@ class ControllerMessageBulkrestore extends Controller { list($a, $idlist) = $this->model_search_search->check_your_permission_by_id_list(explode(",", $this->request->post['idlist'])); + $download = $this->request->post['download']; + + + if($download == 1) { + $this->model_message_restore->download_files_as_zip($idlist); + exit; + } + $this->data['username'] = Registry::get('username'); $rcpt = array(); - array_push($rcpt, $_SESSION['email']); + /* send the email to all the recipients of the original email if we are admin or auditor users */ + + if(Registry::get('admin_user') == 1 || Registry::get('auditor_user') == 1) { + $rcpt = $this->model_search_search->get_message_recipients($this->data['id']); + } + else { + array_push($rcpt, $_SESSION['email']); + } $this->data['restored'] = 0; @@ -45,6 +61,7 @@ class ControllerMessageBulkrestore extends Controller { if($x == 1) { $this->data['restored']++; } } + $this->render(); } diff --git a/webui/model/message/restore.php b/webui/model/message/restore.php new file mode 100644 index 00000000..f080b865 --- /dev/null +++ b/webui/model/message/restore.php @@ -0,0 +1,45 @@ +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); + + } + + +} + + +?> diff --git a/webui/system/misc.php b/webui/system/misc.php index 929c2d81..36d13cb9 100644 --- a/webui/system/misc.php +++ b/webui/system/misc.php @@ -163,8 +163,7 @@ function verify_piler_id($id = '') { } -function createTempName($dir = '', $prefix = '') { - $length = 8; +function generate_random_string($length = 8) { $rnd = ""; $aZ09 = array_merge(range('A', 'Z'), range('a', 'z'),range(0, 9)); @@ -172,7 +171,12 @@ function createTempName($dir = '', $prefix = '') { $rnd .= $aZ09[mt_rand(0, count($aZ09)-1)]; } - return $dir . "/" . $prefix . $rnd; + return $rnd; +} + + +function createTempName($dir = '', $prefix = '') { + return $dir . "/" . $prefix . generate_random_string(8); } diff --git a/webui/tmp/.htaccess b/webui/tmp/.htaccess new file mode 100644 index 00000000..ff2beb84 --- /dev/null +++ b/webui/tmp/.htaccess @@ -0,0 +1,2 @@ +order deny,allow +deny from all diff --git a/webui/view/javascript/piler.js b/webui/view/javascript/piler.js index c22731a0..52e05d0b 100644 --- a/webui/view/javascript/piler.js +++ b/webui/view/javascript/piler.js @@ -385,7 +385,7 @@ function tag_search_results(url){ } -function restore_selected_emails(url) { +function assemble_idlist() { var a = document.getElementById('results'); var idlist = ""; @@ -407,6 +407,14 @@ function restore_selected_emails(url) { } } + return idlist; +} + + +function restore_selected_emails(url) { + + var idlist = assemble_idlist(); + if(idlist) { var http = getXMLHttp(); @@ -414,10 +422,9 @@ function restore_selected_emails(url) { document.getElementById('A1').innerHTML = '
spinner
'; - http.open("POST", url, true); - params = "idlist=" + idlist; + params = "idlist=" + idlist + "&download=0"; http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http.setRequestHeader("Content-length", params.length); @@ -438,7 +445,69 @@ function restore_selected_emails(url) { http.send(params); } - //document.getElementById('A1').innerHTML = ' '; +} + + +function download_selected_emails(url) { + var hiddenField; + var idlist = assemble_idlist(); + + if(idlist) { + + var form = document.createElement("form"); + + form.setAttribute("method", "post"); + form.setAttribute("action", url); + form.setAttribute("name", "download"); + + hiddenField = document.createElement("input"); + + hiddenField.setAttribute("type", "hidden"); + hiddenField.setAttribute("name", "download"); + hiddenField.setAttribute("value", "1"); + form.appendChild(hiddenField); + + hiddenField = document.createElement("input"); + + hiddenField.setAttribute("type", "hidden"); + hiddenField.setAttribute("name", "idlist"); + hiddenField.setAttribute("value", idlist); + form.appendChild(hiddenField); + + document.body.appendChild(form); + form.submit(); + } +} + + +function toggle_bulk_check() { + var isChecked = document.getElementById('bulkcheck').value; + + var a = document.getElementById('results'); + + len = a.childNodes.length; + + for(i=0; i 0){ ?> -
 
-
 
+
+
aaa
@@ -79,7 +79,7 @@
.
', BALLOON, true, ABOVE, true)" onmouseout="UnTip();">
- +
0) { ?>