Example #1
0
 public function download_files_as_zip($idlist = array())
 {
     $zip = new ZipArchive();
     $randomid = generate_random_string(16);
     $filename = DIR_BASE . "tmp/" . $randomid;
     if ($zip->open($filename, ZIPARCHIVE::CREATE) != true) {
         exit("cannot open <{$filename}>\n");
     }
     $this->model_search_message->connect_to_pilergetd();
     foreach ($idlist as $id) {
         $piler_id = $this->model_search_message->get_piler_id_by_id($id);
         $rawemail = $this->model_search_message->get_raw_message($piler_id);
         $zip->addFromString($piler_id . ".eml", $rawemail);
         AUDIT(ACTION_DOWNLOAD_MESSAGE, '', '', $id, '');
     }
     $this->model_search_message->disconnect_from_pilergetd();
     $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);
 }
Example #2
0
 public function index()
 {
     $this->id = "content";
     $this->template = "message/headers.tpl";
     $this->layout = "common/layout-empty";
     $request = Registry::get('request');
     $db = Registry::get('db');
     $this->load->model('search/search');
     $this->load->model('search/message');
     $this->document->title = $this->data['text_message'];
     $this->data['id'] = @$this->request->get['id'];
     $messageid = 0;
     if (!verify_piler_id($this->data['id'])) {
         AUDIT(ACTION_UNKNOWN, '', '', $this->data['id'], 'unknown id: ' . $this->data['id']);
         die("invalid id: " . $this->data['id']);
     }
     $this->data['attachment'] = $this->model_search_message->get_attachment_by_id($this->data['id']);
     if (!isset($this->data['attachment']['filename'])) {
         die("invalid filename");
     }
     $messageid = $this->model_search_message->get_id_by_piler_id($this->data['attachment']['piler_id']);
     AUDIT(ACTION_DOWNLOAD_ATTACHMENT, '', '', $messageid, $this->data['id']);
     header("Cache-Control: public, must-revalidate");
     header("Pragma: no-cache");
     header("Content-Type: application/octet-stream");
     header("Content-Disposition: attachment; filename=\"" . $this->data['attachment']['filename'] . "\"");
     header("Content-Transfer-Encoding: binary\n");
     print $this->data['attachment']['attachment'];
     exit;
 }
Example #3
0
 public function index()
 {
     $this->id = "content";
     $this->template = "message/journal.tpl";
     $this->layout = "common/layout-empty";
     $request = Registry::get('request');
     $db = Registry::get('db');
     $this->load->model('search/search');
     $this->load->model('search/message');
     $this->load->model('user/user');
     $this->document->title = $this->data['text_message'];
     $this->data['id'] = @$this->request->get['id'];
     if (!verify_piler_id($this->data['id'])) {
         AUDIT(ACTION_UNKNOWN, '', '', $this->data['id'], 'unknown id: ' . $this->data['id']);
         die("invalid id: " . $this->data['id']);
     }
     if (!$this->model_search_search->check_your_permission_by_id($this->data['id'])) {
         AUDIT(ACTION_UNAUTHORIZED_VIEW_MESSAGE, '', '', $this->data['id'], '');
         die("no permission for " . $this->data['id']);
     }
     AUDIT(ACTION_VIEW_JOURNAL, '', '', $this->data['id'], '');
     if (Registry::get('auditor_user') == 1) {
         $this->data['rcpt'] = $this->model_search_search->get_message_addresses_in_my_domain($this->data['id']);
     }
     $this->data['piler_id'] = $this->model_search_message->get_piler_id_by_id($this->data['id']);
     $this->data['data'] = $this->model_search_message->get_message_journal($this->data['piler_id']);
     $this->render();
 }
Example #4
0
 public function index()
 {
     $this->id = "content";
     $this->template = "message/headers.tpl";
     $this->layout = "common/layout-empty";
     $request = Registry::get('request');
     $db = Registry::get('db');
     $this->load->model('search/search');
     $this->load->model('search/message');
     $this->load->model('message/zip');
     $this->document->title = $this->data['text_message'];
     $this->data['id'] = @$this->request->get['id'];
     if (!verify_piler_id($this->data['id'])) {
         AUDIT(ACTION_UNKNOWN, '', '', $this->data['id'], 'unknown id: ' . $this->data['id']);
         die("invalid id: " . $this->data['id']);
     }
     if (!$this->model_search_search->check_your_permission_by_id($this->data['id'])) {
         AUDIT(ACTION_UNAUTHORIZED_VIEW_MESSAGE, '', '', $this->data['id'], '');
         die("no permission for " . $this->data['id']);
     }
     $this->data['piler_id'] = $this->model_search_message->get_piler_id_by_id($this->data['id']);
     //AUDIT(ACTION_DOWNLOAD_ATTACHMENT, '', '', $messageid, $this->data['id']);
     $this->model_message_zip->download_attachments_as_zip($this->data['piler_id']);
     exit;
 }
Example #5
0
 public function index()
 {
     $this->id = "content";
     $this->template = "message/headers.tpl";
     $this->layout = "common/layout-empty";
     $request = Registry::get('request');
     $db = Registry::get('db');
     $this->load->model('search/search');
     $this->load->model('search/message');
     $this->document->title = $this->data['text_message'];
     $this->data['id'] = @$this->request->get['id'];
     if (!verify_piler_id($this->data['id'])) {
         AUDIT(ACTION_UNKNOWN, '', '', $this->data['id'], 'unknown id: ' . $this->data['id']);
         die("invalid id: " . $this->data['id']);
     }
     if (!$this->model_search_search->check_your_permission_by_id($this->data['id'])) {
         AUDIT(ACTION_UNAUTHORIZED_VIEW_MESSAGE, '', '', $this->data['id'], '');
         die("no permission for " . $this->data['id']);
     }
     AUDIT(ACTION_DOWNLOAD_MESSAGE, '', '', $this->data['id'], '');
     $this->data['piler_id'] = $this->model_search_message->get_piler_id_by_id($this->data['id']);
     header("Cache-Control: public, must-revalidate");
     header("Pragma: no-cache");
     header("Content-Type: application/octet-stream");
     header("Content-Disposition: attachment; filename=" . $this->data['piler_id'] . ".eml");
     header("Content-Transfer-Encoding: binary\n");
     $this->model_search_message->connect_to_pilergetd();
     $msg = $this->model_search_message->get_raw_message($this->data['piler_id']);
     $this->model_search_message->disconnect_from_pilergetd();
     $this->model_search_message->remove_journal($msg);
     print $msg;
 }
Example #6
0
 public function check_for_account($google_account = array())
 {
     $session = Registry::get('session');
     $query = $this->db->query("SELECT " . TABLE_USER . ".username, " . TABLE_USER . ".uid, " . TABLE_USER . ".realname, " . TABLE_USER . ".dn, " . TABLE_USER . ".password, " . TABLE_USER . ".isadmin, " . TABLE_USER . ".domain FROM " . TABLE_USER . ", " . TABLE_EMAIL . " WHERE " . TABLE_EMAIL . ".email=? AND " . TABLE_EMAIL . ".uid=" . TABLE_USER . ".uid", array($google_account['email']));
     if ($query->num_rows == 1) {
         $user = $query->row;
     } else {
         $d = explode('@', $google_account['email']);
         $user['uid'] = $this->model_user_user->get_next_uid();
         $user['username'] = $google_account['email'];
         $user['realname'] = $google_account['name'];
         $user['email'] = $google_account['email'];
         $user['domain'] = $d[1];
         $user['dn'] = '*';
         $user['isadmin'] = 0;
         $user['password'] = generate_random_string(12);
         $user['group'] = '';
         $user['folder'] = '';
         $this->model_user_user->add_user($user);
         $this->model_domain_domain->addDomain($user['domain'], $user['domain']);
     }
     $session->set("username", $user['username']);
     $session->set("uid", $user['uid']);
     $session->set("admin_user", 0);
     $session->set("email", $user['username']);
     $session->set("domain", $query->row['domain']);
     $session->set("realname", $query->row['realname']);
     $session->set("emails", $this->model_user_user->get_users_all_email_addresses($user['uid']));
     $session->set("folders", $this->model_folder_folder->get_all_folder_ids($user['uid']));
     $session->set("extra_folders", $this->model_folder_folder->get_all_extra_folder_ids($user['uid']));
     AUDIT(ACTION_LOGIN, $user['username'], '', '', 'successful auth against Google');
 }
Example #7
0
 public function index()
 {
     $this->id = "content";
     $this->template = "message/headers.tpl";
     $this->layout = "common/layout-empty";
     $request = Registry::get('request');
     $db = Registry::get('db');
     $this->load->model('search/search');
     $this->load->model('search/message');
     $this->load->model('user/user');
     $this->document->title = $this->data['text_message'];
     $this->data['id'] = $this->request->post['id'];
     if (!verify_piler_id($this->data['id'])) {
         AUDIT(ACTION_UNKNOWN, '', '', $this->data['id'], 'unknown id: ' . $this->data['id']);
         die("invalid id: " . $this->data['id']);
     }
     if (!$this->model_search_search->check_your_permission_by_id($this->data['id'])) {
         AUDIT(ACTION_UNAUTHORIZED_VIEW_MESSAGE, '', '', $this->data['id'], '');
         die("no permission for " . $this->data['id']);
     }
     AUDIT(ACTION_NOT_SPAM, '', '', $this->data['id'], '');
     if (DEFAULT_RETENTION > 30) {
         $this->model_search_message->not_spam($this->data['id']);
     }
 }
Example #8
0
 public function download_files_as_zip($idlist = array())
 {
     $zip = new ZipArchive();
     $pid = array();
     $randomid = generate_random_string(16);
     $filename = DIR_BASE . "tmp/" . $randomid;
     if ($zip->open($filename, ZIPARCHIVE::CREATE) != true) {
         exit("cannot open <{$filename}>\n");
     }
     $imgs = array();
     foreach ($idlist as $id) {
         $piler_id = $this->model_search_message->get_piler_id_by_id($id);
         array_push($pid, $piler_id);
         $attachments = $this->model_search_message->get_attachment_list($piler_id);
         $images = array();
         foreach ($attachments as $a) {
             if (preg_match("/image/", $a['type'])) {
                 $attachment = $this->model_search_message->get_attachment_by_id($a['id']);
                 $fp = fopen(DIR_BASE . 'tmp/' . $a['id'], "w+");
                 if ($fp) {
                     fwrite($fp, $attachment['attachment']);
                     fclose($fp);
                     $images[] = array('id' => $a['id'], 'name' => $attachment['filename']);
                     $imgs[] = array('name' => $a['id']);
                 }
             }
         }
         $message = $this->model_search_message->extract_message($piler_id);
         $page = $message['from'] . "<br />\n";
         $page .= $message['to'] . "<br />\n";
         $page .= $message['subject'] . "<br />\n";
         $page .= $message['date'] . "<br />\n";
         $page .= "<hr />\n" . $message['message'];
         $this->create_pdf_from_eml($piler_id, $page, $images);
         foreach ($imgs as $img) {
             unlink(DIR_BASE . 'tmp/' . $img['name']);
         }
         $zip->addFile(DIR_BASE . 'tmp/' . $piler_id . '.pdf', $piler_id . '.pdf');
         AUDIT(ACTION_DOWNLOAD_MESSAGE, '', '', $id, '');
     }
     $zip->close();
     foreach ($pid as $piler_id) {
         unlink(DIR_BASE . 'tmp/' . $piler_id . '.pdf');
     }
     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);
 }
Example #9
0
function logout()
{
    $session = Registry::get('session');
    AUDIT(ACTION_LOGOUT, $session->get("email"), '', '', '');
    $session->set("username", "");
    $session->set("admin_user", 0);
    $session->remove("username");
    $session->remove("admin_user");
    Registry::set('username', '');
    session_destroy();
}
Example #10
0
 public function index()
 {
     $this->id = "content";
     $this->template = "user/settings.tpl";
     $this->layout = "common/layout";
     $request = Registry::get('request');
     $session = Registry::get('session');
     $db = Registry::get('db');
     $this->load->model('user/auth');
     $this->load->model('user/prefs');
     $this->load->model('user/user');
     $this->load->model('group/group');
     require DIR_BASE . 'system/helper/PHPGangsta_GoogleAuthenticator.php';
     $this->data['ga'] = $this->model_user_prefs->get_ga_settings($session->get('username'));
     $this->document->title = $this->data['text_settings'];
     $d = $r = '';
     $auditemails = $auditdomains = $auditgroups = $auditfolders = '';
     $auditemails = implode(", ", $session->get("emails"));
     $_auditdomains = $session->get("auditdomains");
     foreach ($_auditdomains as $d) {
         $auditdomains .= ', ' . $d;
     }
     $auditdomains = preg_replace("/^,\\s/", "", $auditdomains);
     $auditgroups = preg_replace("/\\s/", ", ", $this->model_group_group->get_groups_by_email($session->get("emails")));
     $folders = $session->get("folders");
     foreach ($folders as $r) {
         $auditfolders .= ', ' . $r;
     }
     $auditfolders = preg_replace("/^,\\s/", "", $auditfolders);
     if ($auditemails) {
         $this->data['emails'] = $auditemails;
     } else {
         $this->data['emails'] = $this->data['text_none_found'];
     }
     if ($auditdomains) {
         $this->data['domains'] = $auditdomains;
     } else {
         $this->data['domains'] = $this->data['text_none_found'];
     }
     if ($auditgroups) {
         $this->data['groups'] = $auditgroups;
     } else {
         $this->data['groups'] = $this->data['text_none_found'];
     }
     if ($auditfolders) {
         $this->data['folders'] = $auditfolders;
     } else {
         $this->data['folders'] = $this->data['text_none_found'];
     }
     if (isset($this->request->post['pagelen']) && isset($this->request->post['theme'])) {
         $this->model_user_prefs->set_user_preferences(Registry::get('username'), $this->request->post);
         AUDIT(ACTION_CHANGE_USER_SETTINGS, '', '', '', 'pagelen:' . $this->request->post['pagelen'] . ', theme:' . $this->request->post['theme'] . ', lang:' . $this->request->post['lang']);
         if (isAdminUser() == 1) {
             header("Location: " . SITE_URL . "index.php?route=health/health");
             return;
         }
         header("Location: " . SITE_URL . "search.php");
         return;
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && PASSWORD_CHANGE_ENABLED == 1 && $this->validate() == true) {
         if ($this->model_user_auth->change_password(Registry::get('username'), $this->request->post['password']) == 1) {
             $this->data['x'] = $this->data['text_password_changed'];
         } else {
             $this->data['x'] = $this->data['text_failed_to_change_password'];
         }
     }
     $this->data['page_len'] = get_page_length();
     $this->data['theme'] = $session->get("theme");
     $this->data['lang'] = $session->get("lang");
     $this->render();
 }
Example #11
0
 public function index()
 {
     $this->id = "content";
     $this->template = "message/restore.tpl";
     $this->layout = "common/layout-empty";
     $session = Registry::get('session');
     $request = Registry::get('request');
     $db = Registry::get('db');
     $this->load->model('search/search');
     $this->load->model('search/message');
     $this->load->model('user/user');
     $this->load->model('mail/mail');
     $this->document->title = $this->data['text_message'];
     $this->data['id'] = @$this->request->get['id'];
     $rcpt = array();
     if (RESTORE_OVER_IMAP == 1) {
         require_once 'Zend/Mail/Protocol/Imap.php';
         require_once 'Zend/Mail/Storage/Imap.php';
     }
     if (Registry::get('auditor_user') == 1) {
         $this->data['id'] = @$this->request->post['id'];
         $this->request->post['rcpt'] = urldecode($this->request->post['rcpt']);
         $rcpt = preg_split("/\\s/", $this->request->post['rcpt']);
     }
     if (!verify_piler_id($this->data['id'])) {
         AUDIT(ACTION_UNKNOWN, '', '', $this->data['id'], 'unknown piler id: ' . $this->data['id']);
         die("invalid id: " . $this->data['id']);
     }
     if (!$this->model_search_search->check_your_permission_by_id($this->data['id'])) {
         AUDIT(ACTION_UNAUTHORIZED_VIEW_MESSAGE, '', '', $this->data['id'], '');
         die("no permission for " . $this->data['id']);
     }
     AUDIT(ACTION_RESTORE_MESSAGE, '', '', $this->data['id'], '');
     $this->data['username'] = Registry::get('username');
     /* send the email to all the recipients of the original email if we are admin or auditor users */
     if (Registry::get('auditor_user') == 0) {
         array_push($rcpt, $session->get("email"));
     }
     $this->data['data'] = $this->data['text_failed_to_restore'];
     if (count($rcpt) > 0) {
         $this->data['piler_id'] = $this->model_search_message->get_piler_id_by_id($this->data['id']);
         $this->model_search_message->connect_to_pilergetd();
         $msg = $this->model_search_message->get_raw_message($this->data['piler_id']);
         $this->model_search_message->disconnect_from_pilergetd();
         $this->model_search_message->remove_journal($msg);
         if (RESTORE_OVER_IMAP == 1) {
             if ($this->model_mail_mail->connect_imap()) {
                 $x = $this->imap->append('INBOX', $msg);
                 $this->model_mail_mail->disconnect_imap();
             } else {
                 $x = 0;
             }
         } else {
             if (RESTORE_EMAILS_AS_ATTACHMENT == 1) {
                 $msg = $this->model_mail_mail->message_as_rfc822_attachment($this->data['id'], $msg, $rcpt[0]);
                 $x = $this->model_mail_mail->send_smtp_email(SMARTHOST, SMARTHOST_PORT, SMTP_DOMAIN, SMTP_FROMADDR, $rcpt, $msg);
             } else {
                 $x = $this->model_mail_mail->send_smtp_email(SMARTHOST, SMARTHOST_PORT, SMTP_DOMAIN, SMTP_FROMADDR, $rcpt, "Received: by piler" . EOL . PILER_HEADER_FIELD . $this->data['id'] . EOL . $msg);
             }
         }
         if ($x == 1) {
             $this->data['data'] = $this->data['text_restored'];
         }
     }
     $this->render();
 }
Example #12
0
 public function check_ntlm_auth()
 {
     $ldap_auditor_member_dn = LDAP_AUDITOR_MEMBER_DN;
     $ldap_admin_member_dn = LDAP_ADMIN_MEMBER_DN;
     $role = 0;
     if (!isset($_SERVER['REMOTE_USER']) || $_SERVER['REMOTE_USER'] == '') {
         return 0;
     }
     $u = explode("\\", $_SERVER['REMOTE_USER']);
     if (isset($u[1])) {
         $username = $u[1];
     } else {
         $username = $_SERVER['REMOTE_USER'];
     }
     if (ENABLE_SYSLOG == 1) {
         syslog(LOG_INFO, "sso login: {$username}");
     }
     $ldap = new LDAP(LDAP_HOST, LDAP_HELPER_DN, LDAP_HELPER_PASSWORD);
     if ($ldap->is_bind_ok()) {
         $query = $ldap->query(LDAP_BASE_DN, "(&(objectClass=user)(samaccountname=" . $username . "))", array());
         if (isset($query->row['dn'])) {
             $a = $query->row;
             if (isset($a['mail']['count'])) {
                 $username = $a['mail'][0];
             } else {
                 $username = $a['mail'];
             }
             $username = strtolower(preg_replace("/^smtp\\:/i", "", $username));
             if ($username == '') {
                 syslog(LOG_INFO, "no email address found for " . $a['dn']);
                 return 0;
             }
             $query = $ldap->query(LDAP_BASE_DN, "(|(&(objectClass=user)(proxyAddresses=smtp:{$username}))(&(objectClass=group)(member={$username}))(&(objectClass=group)(member=" . stripslashes($a['dn']) . ")))", array());
             $emails = $this->get_email_array_from_ldap_attr($query->rows);
             $extra_emails = $this->model_user_user->get_email_addresses_from_groups($emails);
             $emails = array_merge($emails, $extra_emails);
             if ($this->check_ldap_membership($ldap_auditor_member_dn, $query->rows) == 1) {
                 $role = 2;
             }
             if ($this->check_ldap_membership($ldap_admin_member_dn, $query->rows) == 1) {
                 $role = 1;
             }
             $this->add_session_vars($a['cn'], $username, $emails, $role);
             $this->model_user_prefs->get_user_preferences($username);
             AUDIT(ACTION_LOGIN, $username, '', '', 'successful auth against LDAP');
             return 1;
         }
     }
     return 0;
 }
Example #13
0
 public function update_search_term($term = '')
 {
     if ($term == '') {
         return 0;
     }
     AUDIT(ACTION_SEARCH, '', '', '', $term);
     $session = Registry::get('session');
     $query = $this->db->query("UPDATE " . TABLE_SEARCH . " SET ts=? WHERE term=? AND email=?", array(time(), $term, $session->get("email")));
     return $this->db->countAffected();
 }
Example #14
0
 public function index()
 {
     $this->id = "content";
     $this->template = "message/view.tpl";
     $this->layout = "common/layout-empty";
     $session = Registry::get('session');
     $request = Registry::get('request');
     $db = Registry::get('db');
     $this->load->model('search/search');
     $this->load->model('search/message');
     $this->load->model('audit/audit');
     $this->load->model('user/user');
     $this->document->title = $this->data['text_message'];
     $this->data['id'] = '';
     $this->data['search'] = '';
     $this->data['rcpt'] = array();
     if (isset($_SERVER['REQUEST_URI'])) {
         $a = preg_split("/\\//", $_SERVER['REQUEST_URI']);
         $this->data['id'] = $a[count($a) - 1];
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST') {
         $this->data['id'] = $this->request->post['id'];
         $this->data['search'] = $this->request->post['search'];
     }
     if (substr($this->data['id'], 0, 1) == 'a') {
         $this->template = "message/auto.tpl";
         $this->data['id'] = substr($this->data['id'], 1, 200);
     }
     if (!verify_piler_id($this->data['id'])) {
         AUDIT(ACTION_UNKNOWN, '', '', $this->data['id'], 'unknown id: ' . $this->data['id']);
         die("invalid id: " . $this->data['id']);
     }
     if (!$this->model_search_search->check_your_permission_by_id($this->data['id'])) {
         AUDIT(ACTION_UNAUTHORIZED_VIEW_MESSAGE, '', '', $this->data['id'], '');
         die("no permission for " . $this->data['id']);
     }
     AUDIT(ACTION_VIEW_MESSAGE, '', '', $this->data['id'], '');
     $this->data['username'] = Registry::get('username');
     if (Registry::get('auditor_user') == 1) {
         $this->data['rcpt'] = $this->model_search_search->get_message_addresses_in_my_domain($this->data['id']);
     }
     /* fix username if we are admin */
     if (isset($this->request->get['user']) && strlen($this->request->get['user']) > 1 && (Registry::get('admin_user') == 1 || $this->model_user_user->isUserInMyDomain($this->request->get['user']) == 1)) {
         $this->data['username'] = $this->request->get['user'];
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && isset($this->request->post['tag'])) {
         $this->model_search_message->add_message_tag($this->data['id'], $session->get("uid"), $this->request->post['tag']);
         header("Location: " . $_SERVER['HTTP_REFERER']);
         exit;
     }
     $this->data['piler_id'] = $this->model_search_message->get_piler_id_by_id($this->data['id']);
     $this->data['attachments'] = $this->model_search_message->get_attachment_list($this->data['piler_id']);
     $this->data['message'] = $this->model_search_message->extract_message($this->data['piler_id'], $this->data['search']);
     $this->data['message']['tag'] = $this->model_search_message->get_message_tag($this->data['id'], $session->get("uid"));
     $this->data['message']['note'] = $this->model_search_message->get_message_note($this->data['id'], $session->get("uid"));
     $this->data['spam'] = $this->model_search_message->is_message_spam($this->data['id']);
     $this->data['images'] = array();
     foreach ($this->data['attachments'] as $a) {
         if (preg_match("/image/", $a['type'])) {
             $attachment = $this->model_search_message->get_attachment_by_id($a['id']);
             $fp = fopen(DIR_BASE . 'tmp/' . "i." . $a['id'], "w+");
             if ($fp) {
                 fwrite($fp, $attachment['attachment']);
                 fclose($fp);
                 $this->data['images'][] = array('name' => "i." . $a['id']);
             }
         }
     }
     $this->render();
 }
Example #15
0
 public function index()
 {
     $this->id = "content";
     $this->template = "message/bulkrestore.tpl";
     $this->layout = "common/layout-empty";
     $session = Registry::get('session');
     $request = Registry::get('request');
     $db = Registry::get('db');
     $imap_ok = 0;
     $email = '';
     $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');
     $this->document->title = $this->data['text_message'];
     if (!isset($this->request->post['idlist']) || $this->request->post['idlist'] == '') {
         die("no idlist parameter given");
     }
     $idlist = $this->model_search_search->check_your_permission_by_id_list(explode(",", $this->request->post['idlist']));
     $download = $this->request->post['download'];
     if (isset($this->request->post['email'])) {
         $email = $this->request->post['email'];
     }
     if ($download == 1) {
         $this->model_message_restore->download_files_as_zip($idlist);
         exit;
     }
     $this->data['username'] = Registry::get('username');
     $this->data['restored'] = 0;
     if (RESTORE_OVER_IMAP == 1) {
         require_once 'Zend/Mail/Protocol/Imap.php';
         require_once 'Zend/Mail/Storage/Imap.php';
         $imap_ok = $this->model_mail_mail->connect_imap();
         if (!$imap_ok) {
             syslog(LOG_INFO, "imap connection failed for bulkrestore");
         }
     }
     $this->model_search_message->connect_to_pilergetd();
     foreach ($idlist as $id) {
         AUDIT(ACTION_RESTORE_MESSAGE, '', '', $id, '');
         $rcpt = array();
         /* send the email to all the recipients of the original email if you are an auditor user */
         if (Registry::get('auditor_user') == 1) {
             if ($email) {
                 $rcpt[0] = $email;
             } else {
                 $rcpt[0] = $session->get("email");
             }
         } else {
             array_push($rcpt, $session->get("email"));
         }
         if (count($rcpt) > 0) {
             $piler_id = $this->model_search_message->get_piler_id_by_id($id);
             $msg = $this->model_search_message->get_raw_message($piler_id);
             $this->model_search_message->remove_journal($msg);
             if (RESTORE_OVER_IMAP == 1) {
                 if ($imap_ok) {
                     $x = $this->imap->append('INBOX', $msg);
                 } else {
                     $x = 0;
                 }
             } else {
                 if (RESTORE_EMAILS_AS_ATTACHMENT == 1) {
                     $msg = $this->model_mail_mail->message_as_rfc822_attachment($piler_id, $msg, $rcpt[0]);
                     $x = $this->model_mail_mail->send_smtp_email(SMARTHOST, SMARTHOST_PORT, SMTP_DOMAIN, SMTP_FROMADDR, $rcpt, $msg);
                 } else {
                     $x = $this->model_mail_mail->send_smtp_email(SMARTHOST, SMARTHOST_PORT, SMTP_DOMAIN, SMTP_FROMADDR, $rcpt, "Received: by piler" . EOL . PILER_HEADER_FIELD . $id . EOL . $msg);
                 }
             }
             if ($x == 1) {
                 $this->data['restored']++;
             }
         }
     }
     $this->model_search_message->disconnect_from_pilergetd();
     if (RESTORE_OVER_IMAP == 1) {
         $this->model_mail_mail->disconnect_imap();
     }
     $this->render();
 }