/**
  * add list data in db table
  *
  * @param array $data
  */
 function perform(&$data)
 {
     // get list messages attachment folder string
     $list_folder = commonUtil::unique_md5_str();
     if (!@mkdir(SF_BASE_DIR . '/data/earchive/' . $list_folder, SF_DIR_MODE)) {
         trigger_error("Cannot create list messages attachment folder! Contact the administrator.\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         return FALSE;
     }
     $lid = $this->B->db->nextId($this->B->sys['db']['table_prefix'] . 'earchive_lists');
     if (MDB2::isError($lid)) {
         trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         return FALSE;
     }
     $sql = '
         INSERT INTO 
             ' . $this->B->sys['db']['table_prefix'] . 'earchive_lists
             (lid,name,email,emailserver,description,folder,status)
         VALUES
             (' . $lid . ',
              "' . $data['name'] . '",
              "' . $data['email'] . '",
              "' . $data['emailserver'] . '",
              "' . $data['description'] . '",
              "' . $list_folder . '",
              ' . $data['status'] . ')';
     $result = $this->B->db->query($sql);
     if (MDB2::isError($result)) {
         trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         return FALSE;
     }
     return TRUE;
 }
 /**
  * add_registered_user_data
  *
  * @param int $uid user ID
  * @return mixed md5_str|false
  */
 function _add_registered_user_data($uid)
 {
     $md5_str = commonUtil::unique_md5_str();
     $_time = date("Y-m-d H:i:s", time());
     $sql = '
         INSERT INTO 
             ' . $this->B->sys['db']['table_prefix'] . 'user_registered
             (uid,md5_str,reg_date)
         VALUES
             (' . $uid . ',
              "' . $md5_str . '",
              "' . $_time . '")';
     $res = $this->B->db->query($sql);
     if (DB::isError($res)) {
         trigger_error($res->getMessage() . "\n" . $res->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         return FALSE;
     }
     return $md5_str;
 }
 $body = $msg->getBody($mid, $pid);
 $mbody = '';
 if ($body['ftype'] == 'text/plain') {
     $mess = str_replace("<", "&lt;", $body['message']);
     $mess = str_replace(">", "&gt;", $mess);
     $data['body'] = $this->B->db->quoteSmart(nl2br($this->B->e_util->html_activate_links($mess)));
 } else {
     $data['body'] = $this->B->db->quoteSmart($body['message']);
 }
 $mes_folder = FALSE;
 $is_attach = FALSE;
 // check if there are attachments attachments
 if (isset($msg->attachPid[$mid]) && count($msg->attachPid[$mid]) > 0) {
     $is_attach = TRUE;
     // get list messages attachment folder string
     $mes_folder = commonUtil::unique_md5_str();
     $data['folder'] = $this->B->db->quoteSmart($mes_folder);
 } else {
     $data['folder'] = '0';
 }
 $_content = '';
 if (FALSE === ($message_id = $this->B->earchive->add_message($data))) {
     trigger_error('Cannot add message: ' . var_export($data) . __FILE__ . ' ' . __LINE__, E_USER_ERROR);
     continue;
     // switch to next message
 }
 // index content
 $_content = $data['subject'] . ' ' . $data['sender'] . ' ' . $data['body'];
 $word_indexer->indexing_words($_content, 'earchive_words_crc32', array('mid' => $message_id, 'lid' => $account['lid']));
 // Now the attachments
 if (TRUE === $is_attach) {
 /**
  * fetch all messages from one account
  *
  * @param array $account account data
  */
 function _fetch_messages(&$account)
 {
     // Retrieve message count
     $msgcount = $this->_msg->messageCount();
     if ($msgcount > 0) {
         /*
          * Each message of a mailbox is numbered offset from 1
          * Create the $mid (message id) and recursively gather
          * message information.
          */
         for ($mid = 1; $mid <= $msgcount; $mid++) {
             // init message data array
             $this->_message_data = array('lid' => $account['lid'], 'message_id' => "", 'root_id' => "", 'parent_id' => "", 'enc_type' => "", 'sender' => "", 'subject' => "", 'mdate' => "", 'body' => "", 'folder' => "", 'header' => "");
             // add blank message in db table to get message id
             $message_id = M(MOD_EARCHIVE, 'add_message', $this->_message_data);
             // Parse header information
             $this->_msg->getHeaders($mid);
             // fetch header data
             $this->_fetch_headers($mid);
             // Parse inline/attachment information specific to this part id
             //
             // See member variables begining with in or attach for
             // available information
             $this->_msg->getParts($mid);
             //echo $this->_msg->msg[$mid]['pid'];
             //echo '<pre>';var_dump($this->_msg); echo '</pre><br><br><br>';
             $this->_msg->getParts($mid, $this->_msg->msg[$mid]['pid']);
             //echo '<pre>';var_dump($this->_msg->msg); echo '</pre>';
             // fetch body data
             $this->_fetch_body($mid);
             $this->_message_data['folder'] = $_folder = commonUtil::unique_md5_str();
             if ($this->B->sys['module']['earchive']['get_header'] == TRUE) {
                 $this->_message_data['header'] = $this->_msg->getRawHeaders($mid);
             } else {
                 $this->_message_data['header'] = "'" . "" . "'";
             }
             // update message in db table
             if (FALSE == M(MOD_EARCHIVE, 'update_message', array('mid' => $message_id, 'fields' => $this->_message_data))) {
                 // Clean up left over variables
                 $this->_msg->unsetParts($mid);
                 $this->_msg->unsetHeaders($mid);
                 trigger_error('Cannot add message: ' . var_export($this->_message_data) . __FILE__ . ' ' . __LINE__, E_USER_ERROR);
                 continue;
                 // switch to next message
             }
             // fetch attachments data
             $this->_fetch_attach($message_id, $mid, $account, $_folder);
             // Clean up left over variables
             $this->_msg->unsetParts($mid);
             $this->_msg->unsetHeaders($mid);
             // delte message from inbox
             $this->_msg->delete($mid);
             // prepare content for indexing
             $_content = $this->_message_data['subject'] . ' ' . $this->_message_data['sender'] . ' ' . $this->_message_data['body'];
             // indexing content
             M(MOD_EARCHIVE, 'word_indexer', array('content' => $_content, 'mid' => $message_id, 'lid' => $account['lid']));
         }
     }
 }
示例#5
0
    exit;
}
// Init form field values
$B->form_error = FALSE;
$B->form_name = '';
$B->form_emailserver = '';
$B->form_email = '';
$B->form_description = '';
$B->form_status = '';
// Check if some form fields are empty
if (empty($_POST['name']) || empty($_POST['emailserver']) || empty($_POST['email'])) {
    // if empty assign form field with old values
    $B->form_name = htmlspecialchars(commonUtil::stripSlashes($_POST['name']));
    $B->form_emailserver = htmlspecialchars(commonUtil::stripSlashes($_POST['emailserver']));
    $B->form_email = htmlspecialchars(commonUtil::stripSlashes($_POST['email']));
    $B->form_description = htmlspecialchars(commonUtil::stripSlashes($_POST['description']));
    $B->form_status = $_POST['status'];
    $B->form_error = 'You have fill out all fields!';
} else {
    // get list messages attachment folder string
    $list_folder = commonUtil::unique_md5_str();
    if (!@mkdir(SF_BASE_DIR . '/data/earchive/' . $list_folder, SF_DIR_MODE)) {
        $B->form_error = 'Cannot create list messages attachment folder! Contact the administrator.';
    }
    // add new email lsit
    $B->tmp_data = array('name' => $B->db->quoteSmart(commonUtil::stripSlashes($_POST['name'])), 'emailserver' => $B->db->quoteSmart(commonUtil::stripSlashes($_POST['emailserver'])), 'email' => $B->db->quoteSmart(commonUtil::stripSlashes($_POST['email'])), 'description' => $B->db->quoteSmart(commonUtil::stripSlashes($_POST['description'])), 'folder' => $B->db->quoteSmart($list_folder), 'status' => (int) $_POST['status']);
    if (FALSE === $B->form_error && FALSE !== $B->earchive->add_list($B->tmp_data)) {
        @header('Location: ' . SF_BASE_LOCATION . '/admin/index.php?m=EARCHIVE');
        exit;
    }
}
 /**
  * fetch all messages from one account
  *
  * @param array $account account data
  */
 function _fetch_messages(&$account)
 {
     // Retrieve message count
     $msgcount = $this->_msg->messageCount();
     if ($msgcount > 0) {
         /*
          * Each message of a mailbox is numbered offset from 1
          * Create the $mid (message id) and recursively gather
          * message information.
          */
         for ($mid = 1; $mid <= $msgcount; $mid++) {
             // init message data array
             $this->_message_data = array('lid' => 0, 'sender' => '', 'subject' => '', 'mdate' => '', 'body' => '', 'folder' => '');
             // Parse inline/attachment information specific to this part id
             //
             // See member variables begining with in or attach for
             // available information
             $this->_msg->getParts($mid, 0, false, array('retrieve_all' => TRUE));
             // Parse header information
             $this->_msg->getHeaders($mid);
             // fetch header data
             $this->_fetch_headers($mid);
             // fetch body data
             $this->_fetch_body($mid);
             // list id of this message
             $this->_message_data['lid'] = $account['lid'];
             $this->_message_data['folder'] = $this->B->db->escape($_folder = commonUtil::unique_md5_str());
             // add message in db table
             if (FALSE == ($message_id = $this->B->M(MOD_EARCHIVE, 'add_message', $this->_message_data))) {
                 // Clean up left over variables
                 $this->_msg->unsetParts($mid);
                 $this->_msg->unsetHeaders($mid);
                 trigger_error('Cannot add message: ' . var_export($this->_message_data) . __FILE__ . ' ' . __LINE__, E_USER_ERROR);
                 continue;
                 // switch to next message
             }
             // fetch attachments data
             $this->_fetch_attach($message_id, $mid, $account, $_folder);
             // Clean up left over variables
             $this->_msg->unsetParts($mid);
             $this->_msg->unsetHeaders($mid);
             // delte message from inbox
             $this->_msg->delete($mid);
             // indexing content
             $_content = $this->_message_data['subject'] . ' ' . $this->_message_data['sender'] . ' ' . $this->_message_data['body'];
             $this->_word_indexer->indexing_words($_content, 'earchive_words_crc32', array('mid' => $message_id, 'lid' => $account['lid']));
         }
     }
 }