/** * LoadContent from pop content * * @param object $content content from pop * * @return bool */ function loadContentFromPop($content) { switch ($this->subtype) { case 'SVG+XML': return $this->_content = CPop::decodeMail($this->encoding, $content); break; default: return $this->_content = base64_encode(CPop::decodeMail($this->encoding, $content)); break; } }
* @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html */ CCanDo::checkRead(); $user = CMediusers::get(); $mail_id = CValue::get("mail_id"); $log_pop = new CSourcePOP(); $log_pop->name = "user-pop-" . $user->_id; $log_pop->loadMatchingObject(); if (!$log_pop) { CAppUI::stepAjax("Source POP indisponible", UI_MSG_ERROR); } if (!$mail_id) { CAppUI::stepAjax("CSourcePOP-error-mail_id", UI_MSG_ERROR); } //pop init $pop = new CPop($log_pop); $pop->open(); //mail $mail = new CUserMail(); $head = $pop->header($mail_id); $content = $pop->getFullBody($_mail, false, false, true); $hash = $mail_unseen->makeHash($head, $content); $mail->loadMatchingFromHash($hash); if ($mail->_id && !$mail->text_plain_id) { $mail->setHeaderFromSource($head); $mail->setContentFromSource($pop->getFullBody($_mail, false, false, true)); $mail->date_read = CMbDT::dateTime(); $mail->user_id = $user->_id; //text plain if ($mail->_text_plain) { $textP = new CContentAny();
$mail_id = CValue::get("mail_id"); //pop init //mail $mail = new CUserMail(); $mail->load($mail_id); $mail->loadRefsFwd(); $mail->checkHprim(); //HprimMedecin $mail->checkApicrypt(); //HprimMedecin //pop account $log_pop = new CSourcePOP(); $log_pop->load($mail->account_id); //if not read email, send the seen flag to server if (!$mail->date_read && !CAppUI::pref("markMailOnServerAsRead")) { $pop = new CPop($log_pop); $pop->open(); $pop->setflag($mail->uid, "\\Seen"); $pop->close(); } $mail->date_read = CMbDT::dateTime(); $mail->store(); //get the CFile attachments $nbAttachPicked = 0; $nbAttach = count($mail->_attachments); foreach ($mail->_attachments as $_att) { $_att->loadRefsFwd(); if ($_att->_file->_id) { $nbAttachPicked++; } }
/** * create the CFiles attached to the mail * * @param CMailAttachments[] $attachList The list of CMailAttachment * @param CPop $popClient the CPop client * * @return void */ function attachFiles($attachList, $popClient) { //size limit $size_required = CAppUI::pref("getAttachmentOnUpdate"); if ($size_required == "") { $size_required = 0; } foreach ($attachList as $_attch) { $_attch->mail_id = $this->_id; $_attch->loadMatchingObject(); if (!$_attch->_id) { $_attch->store(); } //si preference taille ok OU que la piece jointe est incluse au texte => CFile if ($_attch->bytes <= $size_required || $_attch->disposition == "INLINE") { $file = new CFile(); $file->setObject($_attch); $file->author_id = CAppUI::$user->_id; if (!$file->loadMatchingObject()) { $file_pop = $popClient->decodeMail($_attch->encoding, $popClient->openPart($this->uid, $_attch->getpartDL())); $file->file_name = $_attch->name; //apicrypt attachment if (strpos($_attch->name, ".apz") !== false) { $file_pop = CApicrypt::uncryptAttachment($popClient->source->object_id, $file_pop); } //file type detection $first = is_array($file_pop) ? reset($file_pop) : $file_pop; $mime = $this->extensionDetection($first); //file name $infos = pathinfo($_attch->name); $extension = $infos['extension']; $mime_extension = strtolower(end(explode("/", $mime))); if (strtolower($extension) != $mime_extension) { $file->file_name = $infos['filename'] . "." . $mime_extension; } $file->file_type = $mime ? $mime : $_attch->getType($_attch->type, $_attch->subtype); $file->fillFields(); $file->updateFormFields(); $file->putContent($file_pop); $file->store(); } } } }
function isAuthentificate() { $pop = new CPop($this); if (!$pop->open()) { return false; } $pop->close(); return true; }
* @version $Revision$ * @author SARL OpenXtrem */ CCanDo::checkRead(); CPop::checkImapLib(); $account_id = CValue::get("account_id"); $user = CMediusers::get(); //get account $account_pop = new CSourcePOP(); $account_pop->load($account_id); //get the list $mail = new CUserMail(); $where = array(); $where[] = "date_read IS NULL AND account_id = '{$account_id}' AND account_class = 'CSourcePOP'"; $mails = $mail->loadList($where); $pop = new CPop($account_pop); $pop->open(); $count = 0; /** @var $mails CUserMail[] */ foreach ($mails as $_mail) { if ($pop->setflag($_mail->uid, "\\Seen")) { $_mail->date_read = CMbDT::dateTime(); if (!($msg = $_mail->store())) { $count++; } } } $pop->close(); if ($count > 0) { CAppUI::stepAjax("CUserMail-markedAsRead", UI_MSG_OK, $count); } else {
$firstEmailDate = CUserMail::getFirstMailDate($_source->_id); $firstCheck = $firstEmailDate; $firstCheck = CMbDT::dateTime("+1 DAY", $firstCheck); $month_number = CMbDT::format($firstCheck, "%m"); $month = reset(array_keys(CFTP::$month_to_number, $month_number)); $dateIMAP = CMbDT::format($firstCheck, "%d-{$month}-%Y"); } else { $lastEmailDate = CUserMail::getLastMailDate($_source->_id); $firstCheck = $lastEmailDate; $firstCheck = CMbDT::dateTime("-1 DAY", $firstCheck); $month_number = CMbDT::format($firstCheck, "%m"); $month = reset(array_keys(CFTP::$month_to_number, $month_number)); $dateIMAP = CMbDT::format($firstCheck, "%d-{$month}-%Y"); } //pop open account $pop = new CPop($_source); if (!$pop->open()) { CAppUI::stepAjax("Impossible de se connecter à la source (open) %s", UI_MSG_WARNING, $_source->_view); continue; } //If import mode (get before actual) if ($import) { $unseen = $pop->search('BEFORE "' . $dateIMAP . '"', true); } else { $unseen = $pop->search('SINCE "' . $dateIMAP . '"', true); } $results = count($unseen); $total = imap_num_msg($pop->_mailbox); //if get last email => check if uid server is > maxuidMb // @TODO : temporarly removed, we already get the more recent mail for filter /*if (!$import) {
* @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ * @link http://www.mediboard.org */ CCanDo::checkAdmin(); $mail_id = CValue::get("id"); //usermail $mail = new CUserMail(); $mail->load($mail_id); $mail->loadAttachments(); //client POP $clientPOP = new CSourcePOP(); $clientPOP->load($mail->account_id); $pop = new CPop($clientPOP); if (!$pop->open()) { return; } //overview $overview = $pop->header($mail->uid); $msgno = $overview->msgno; $infos = $pop->infos($msgno); //structure $structure = $pop->structure($mail->uid); //content $content = $pop->getFullBody($mail->uid); //attachments $attachments = array(); $_attachments = $pop->getListAttachments($mail->uid); foreach ($_attachments as $_attach) {
$user = CMediusers::get(); $mail_id = CValue::get("mail_id"); $part = CValue::get("part"); $log_pop = new CSourcePOP(); $log_pop->name = "user-pop-" . $user->_id; $log_pop->loadMatchingObject(); if (!$log_pop) { CAppUI::stepAjax("Source POP indisponible", UI_MSG_ERROR); } if (!$mail_id) { CAppUI::stepAjax("CSourcePOP-error-mail_id", UI_MSG_ERROR); } $mail = new CUserMail(); $mail->load($mail_id); if ($mail->_id) { $pop = new CPop($log_pop); $pop->open(); $attach = new CMailAttachments(); $struct = $pop->structure($mail->uid); $parts = explode(".", $part); //recursive parts foreach ($parts as $key => $value) { $struct = $struct->parts[$value]; } $attach->loadFromHeader($struct); $attach->part = $part; $attach->loadContentFromPop($pop->openPart($mail->uid, $attach->getpartDL())); $smarty = new CSmartyDP(); $smarty->assign("_attachment", $attach); $smarty->display("inc_show_attachments.tpl"); $pop->close();
if ($msg = $attachment->store()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } else { CAppUI::stepAjax("CMailAttachments-msg-attachmentLinked-success", UI_MSG_OK); } } } else { // pop $account = new CSourcePOP(); $account->load($mail->account_id); $pop = new CPop($account); $pop->open(); $file = new CFile(); $file->setObject($object); $file->author_id = CAppUI::$user->_id; $pop = new CPop($account); $pop->open(); $file_pop = $pop->decodeMail($attachment->encoding, $pop->openPart($mail->uid, $attachment->getpartDL())); $pop->close(); $file->file_name = $attachment->name; $file->file_type = $attachment->getType($attachment->type, $attachment->subtype); $file->fillFields(); $file->putContent($file_pop); if ($str = $file->store()) { CAppUI::stepAjax($str, UI_MSG_ERROR); } else { $attachment->file_id = $file->_id; $attachment->store(); } } }
* @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ // Check params if (null == ($exchange_source_name = CValue::get("exchange_source_name"))) { CAppUI::stepAjax("CExchangeSource-error-noSourceName", UI_MSG_ERROR); } if (null == ($type_action = CValue::get("type_action"))) { CAppUI::stepAjax("CExchangeSource-error-noTestDefined", UI_MSG_ERROR); } /** @var CSourcePOP $exchange_source */ $exchange_source = CExchangeSource::get($exchange_source_name, "pop", true, null, false); if (!$exchange_source->_id) { CAppUI::stepAjax("CExchangeSource-error-unsavedParameters", UI_MSG_ERROR); } $pop = new CPop($exchange_source); switch ($type_action) { case 'connexion': try { if ($pop->open()) { CAppUI::stepAjax("CSourcePOP-info-connection-established@%s:%s", UI_MSG_OK, $exchange_source->host, $exchange_source->port); } } catch (CMbException $e) { $e->stepAjax(UI_MSG_WARNING); } break; case 'listBox': try { if ($pop->open()) { $boxes = imap_list($pop->_mailbox, $pop->_server, "*"); CAppUI::stepAjax("OK, %d comptes", UI_MSG_OK, count($boxes));