예제 #1
0
파일: modules.php 프로젝트: GordonDiggs/hm3
 public function process()
 {
     list($success, $form) = $this->process_form(array('nux_pass', 'nux_service', 'nux_email', 'nux_name'));
     if ($success) {
         if (Nux_Quick_Services::exists($form['nux_service'])) {
             $details = Nux_Quick_Services::details($form['nux_service']);
             $details['name'] = $form['nux_name'];
             Hm_IMAP_List::add(array('name' => $details['name'], 'server' => $details['server'], 'port' => $details['port'], 'tls' => $details['tls'], 'user' => $form['nux_email'], 'pass' => $form['nux_pass']));
             $servers = Hm_IMAP_List::dump(false, true);
             $ids = array_keys($servers);
             $new_id = array_pop($ids);
             $imap = Hm_IMAP_List::connect($new_id, false);
             if ($imap && $imap->get_state() == 'authenticated') {
                 if (isset($details['smtp'])) {
                     Hm_SMTP_List::add(array('name' => $details['name'], 'server' => $details['smtp']['server'], 'port' => $details['smtp']['port'], 'tls' => $details['smtp']['tls'], 'user' => $form['nux_email'], 'pass' => $form['nux_pass']));
                     $this->session->record_unsaved('SMTP server added');
                     $smtp_servers = Hm_SMTP_List::dump(false, true);
                     $this->user_config->set('smtp_servers', $smtp_servers);
                 }
                 $this->user_config->set('imap_servers', $servers);
                 Hm_IMAP_List::clean_up();
                 $user_data = $this->user_config->dump();
                 if (!empty($user_data)) {
                     $this->session->set('user_data', $user_data);
                 }
                 $this->session->record_unsaved('IMAP server added');
                 $this->session->record_unsaved('SMTP server added');
                 $this->session->secure_cookie($this->request, 'hm_reload_folders', '1');
                 Hm_Msgs::add('E-mail account successfully added');
                 $msgs = Hm_Msgs::get();
                 if (!empty($msgs)) {
                     $this->session->secure_cookie($this->request, 'hm_msgs', base64_encode(serialize($msgs)), 0);
                 }
                 $this->session->close_early();
                 $this->out('nux_account_added', true);
             } else {
                 Hm_IMAP_List::del($new_id);
                 Hm_Msgs::add('ERRAuthentication failed');
             }
         }
     }
 }
예제 #2
0
파일: modules.php 프로젝트: GordonDiggs/hm3
 /**
  * Fetch the content, message parts, and headers for the supplied message
  */
 public function process()
 {
     list($success, $form) = $this->process_form(array('imap_server_id', 'imap_msg_uid', 'folder'));
     if ($success) {
         $this->out('msg_text_uid', $form['imap_msg_uid']);
         $this->out('msg_server_id', $form['imap_server_id']);
         $this->out('msg_folder', $form['folder']);
         $part = false;
         $prefetch = false;
         if (isset($this->request->post['imap_msg_part']) && preg_match("/[0-9\\.]+/", $this->request->post['imap_msg_part'])) {
             $part = $this->request->post['imap_msg_part'];
         } elseif (isset($this->request->post['imap_prefetch']) && $this->request->post['imap_prefetch']) {
             $prefetch = true;
         }
         $cache = Hm_IMAP_List::get_cache($this->session, $form['imap_server_id']);
         $imap = Hm_IMAP_List::connect($form['imap_server_id'], $cache);
         if ($imap) {
             $imap->read_only = $prefetch;
             if ($imap->select_mailbox($form['folder'])) {
                 $msg_struct = $imap->get_message_structure($form['imap_msg_uid']);
                 $this->out('msg_struct', $msg_struct);
                 if ($part !== false) {
                     if ($part == 0) {
                         $max = 500000;
                     } else {
                         $max = false;
                     }
                     $struct = $imap->search_bodystructure($msg_struct, array('imap_part_number' => $part));
                     $msg_struct_current = array_shift($struct);
                     $msg_text = $imap->get_message_content($form['imap_msg_uid'], $part, $max, $msg_struct_current);
                     if (isset($msg_struct_current['subtype']) && strtolower($msg_struct_current['subtype'] == 'html')) {
                         $msg_text = add_attached_images($msg_text, $form['imap_msg_uid'], $msg_struct, $imap);
                     }
                 } else {
                     list($part, $msg_text) = $imap->get_first_message_part($form['imap_msg_uid'], 'text', false, $msg_struct);
                     $struct = $imap->search_bodystructure($msg_struct, array('imap_part_number' => $part));
                     $msg_struct_current = array_shift($struct);
                 }
                 $msg_headers = $imap->get_message_headers($form['imap_msg_uid']);
                 $this->out('msg_headers', $msg_headers);
                 $this->out('imap_msg_part', "{$part}");
                 if ($msg_struct_current) {
                     $this->out('msg_struct_current', $msg_struct_current);
                 }
                 $this->out('msg_text', $msg_text);
                 $this->out('msg_download_args', sprintf("page=message&uid=%d&list_path=imap_%d_%s&imap_download_message=1", $form['imap_msg_uid'], $form['imap_server_id'], $form['folder']));
                 if (!$prefetch) {
                     $this->session->set('reply_details', array('msg_struct' => $msg_struct_current, 'msg_text' => $msg_text, 'msg_headers' => $msg_headers));
                 }
             }
         }
     }
 }