예제 #1
0
 function import_vcard($params)
 {
     include_once 'class.imap_functions.inc.php';
     $objImap = new imap_functions();
     $msg_number = $params['msg_number'];
     $idx_file = $params['idx_file'];
     $msg_part = $params['msg_part'];
     $msg_folder = $params['msg_folder'];
     $from_ajax = $params['from_ajax'];
     $encoding = strtolower($params['encoding']);
     $fileContent = "";
     $cirus_delimiter = $params['cirus_delimiter'];
     $expFolder = explode($cirus_delimiter, $msg_folder);
     if ($msg_number != null && $msg_part != null && $msg_folder != null && intval($idx_file == '0' ? '1' : $idx_file)) {
         require_once PHPGW_INCLUDE_ROOT . '/expressoMail/inc/class.attachment.inc.php';
         $attachmentObj = new attachment();
         $attachmentObj->setStructureFromMail($msg_folder, $msg_number);
         $fileContent = $attachmentObj->getAttachment($msg_part);
         $info = $attachmentObj->getAttachmentInfo($msg_part);
         $filename = $info['name'];
     } else {
         $filename = $idx_file;
     }
     // It's necessary to access calendar method.
     $GLOBALS['phpgw_info']['flags']['noappheader'] = True;
     $GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
     $GLOBALS['phpgw_info']['flags']['currentapp'] = 'calendar';
     if (isset($params['selected']) || isset($params['readable'])) {
         $_REQUEST['data'] = $fileContent;
         $_REQUEST['type'] = 'iCal';
         $_REQUEST['params']['calendar'] = isset($params['selected']) ? $params['selected'] : false;
         $_REQUEST['readable'] = isset($params['readable']) && $params['readable'] ? true : false;
         $_REQUEST['analize'] = isset($params['analize']) ? true : false;
         $_REQUEST['params']['status'] = isset($params['status']) ? $params['status'] : false;
         $_REQUEST['params']['owner'] = $params['uidAccount'];
         if (isset($params['acceptedSuggestion'])) {
             $_REQUEST['params']['acceptedSuggestion'] = $params['acceptedSuggestion'];
             $_REQUEST['params']['from'] = $params['from'];
         }
         ob_start();
         include_once PHPGW_INCLUDE_ROOT . '/prototype/converter.php';
         $output = ob_get_clean();
         $valid = json_decode($output, true);
         if ($_REQUEST['readable']) {
             if (!is_array($valid)) {
                 $output = unserialize($output);
                 foreach ($output as $key => $value) {
                     return $value;
                 }
             }
             return false;
         }
         if (empty($output)) {
             return "error";
         }
         return "ok";
     }
     include_once PHPGW_INCLUDE_ROOT . '/header.inc.php';
     $uiicalendar = CreateObject("calendar.uiicalendar");
     if (strtoupper($expFolder[0]) == 'USER' && $expFolder[1]) {
         include_once 'class.ldap_functions.inc.php';
         $ldap = new ldap_functions();
         $account['uid'] = $expFolder[1];
         $account['uidnumber'] = $ldap->uid2uidnumber($expFolder[1]);
         $account['mail'] = $ldap->getMailByUid($expFolder[1]);
         return $uiicalendar->import_from_mail($fileContent, $from_ajax, $account);
     } else {
         return $uiicalendar->import_from_mail($fileContent, $from_ajax);
     }
 }
 function getForwardingAttachment($folder, $uid, $part, $rfc_822bodies = true, $info = true)
 {
     include_once dirname(__FILE__) . '/class.attachment.inc.php';
     $attachment = new attachment();
     $attachment->decodeConf['rfc_822bodies'] = $rfc_822bodies;
     //Forçar a não decodificação de mensagens em anexo.
     $folder = urldecode($folder);
     $attachment->setStructureFromMail($folder, $uid);
     if ($info === true) {
         $return = $attachment->getAttachmentInfo($part);
         $return['source'] = $attachment->getAttachment($part);
         return $return;
     }
     return $attachment->getAttachment($part);
 }
예제 #3
0
 function download_all_attachments($params)
 {
     require_once dirname(__FILE__) . '/class.attachment.inc.php';
     $atObj = new attachment();
     $atObj->setStructureFromMail($params['folder'], $params['num_msg']);
     $attachments = $atObj->getAttachmentsInfo();
     $id_number = $params['num_msg'];
     $tempDir = $this->tempDir;
     $tempSubDir = $_SESSION['phpgw_session']['session_id'];
     $fileNames = '';
     exec('mkdir ' . $tempDir . '/' . $tempSubDir . '; cd ' . $tempDir . '/' . $tempSubDir);
     $this->folder = $params['folder'];
     $this->folder = mb_convert_encoding($this->folder, "UTF7-IMAP", "UTF-8");
     $fileNames = array();
     $attachments_count = count($attachments);
     for ($i = 0; $i < $attachments_count; ++$i) {
         $attachments[$i]['name'] = $this->remove_accents($attachments[$i]['name']);
         $fileNames[$i] = $attachments[$i]['name'];
     }
     $attachments_count = count($attachments);
     for ($i = 0; $i < $attachments_count; ++$i) {
         $fileName = $attachments[$i]['name'];
         $result = array_keys($fileNames, $fileName);
         // Detecta duplicatas
         if (count($result) > 1) {
             $result_count = count($result);
             for ($j = 1; $j < $result_count; ++$j) {
                 $replacement = '(' . $j . ')$0';
                 if (preg_match('/\\.\\w{2,4}$/', $fileName)) {
                     $fileNames[$result[$j]] = preg_replace('/\\.\\w{2,4}$/', $replacement, $fileName);
                 } else {
                     $fileNames[$result[$j]] .= "({$j})";
                 }
                 $attachments[$result[$j]]['name'] = $fileNames[$result[$j]];
             }
         }
         // Fim detecta duplicatas
         $f = fopen($tempDir . '/' . $tempSubDir . '/' . $fileName, "wb");
         if (!$f) {
             return False;
         }
         $fileContent = $atObj->getAttachment($attachments[$i]['pid']);
         fputs($f, $fileContent);
         fclose($f);
     }
     imap_close($this->mbox_stream);
     $nameFileZip = '';
     if (!empty($fileNames)) {
         $nameFileZip = $this->createFileZip($fileNames, $tempDir . '/' . $tempSubDir);
         if ($nameFileZip) {
             $file = $tempDir . '/' . $tempSubDir . '/' . $nameFileZip;
         } else {
             $file = false;
         }
     } else {
         $file = false;
     }
     include_once dirname(__FILE__) . '/../../prototype/library/utils/Logger.php';
     Logger::info('expressomail', 'downloadAllAttachment', $atObj->messageId);
     return $file;
 }
예제 #4
0
		* Expresso Livre                                                           * 
		* http://www.expressolivre.org                                             * 
		* --------------------------------------------                             * 
		*  This program is free software; you can redistribute it and/or modify it * 
		*  under the terms of the GNU General Public License as published by the   * 
		*  Free Software Foundation; either version 2 of the License, or (at your  * 
		*  option) any later version.                                              * 
		\**************************************************************************/
/*
 * Requieres
 */
require_once '../../header.session.inc.php';
require_once dirname(__FILE__) . '/class.attachment.inc.php';
//------------------------//
/*
 * Get variables
 */
$msgFolder = $_GET['msg_folder'];
$msgNumber = $_GET['msg_num'];
$embeddedPart = $_GET['msg_part'];
//-------------------------------------//
/*
 * Main
 */
$attachmentObj = new attachment();
$attachmentObj->setStructureFromMail($msgFolder, $msgNumber);
$fileContent = $attachmentObj->getAttachment($embeddedPart);
header("Content-Type: image/jpeg");
header("Content-Disposition: inline");
echo $fileContent;
//------------------------------------------//