function savePop3Message($data) { global $osC_Session; $id = $data['id']; $email = toC_Email_Accounts_Admin::getCachedMessage($id); $email['to'] = $data['to']; $email['cc'] = $data['cc']; $email['bcc'] = $data['bcc']; $email['from'] = $data['from']; $email['sender'] = $data['sender']; $email['subject'] = $data['subject']; $email['reply_to'] = $data['reply_to']; $email['full_from'] = $data['full_from']; $email['body'] = $data['body']; $email['priority'] = $data['priority']; $email['content_type'] = $data['content_type']; $email['notification'] = $data['notification']; $attachments = array(); if (!empty($data['attachments']) && is_array($data['attachments'])) { $index = 0; $number = 2; $path = DIR_FS_CACHE_ADMIN . 'emails/attachments/' . $osC_Session->getID(); $osC_DirectoryListing = new osC_DirectoryListing($path); foreach ($osC_DirectoryListing->getFiles() as $file) { $attachments[] = array('id' => 0, 'number' => $number, 'index' => $index, 'name' => $file['name'], 'human_size' => imap::format_size(filesize($path . '/' . $file['name']))); $index++; $number++; } } $email['attachments'] = $attachments; $cache_file = DIR_FS_CACHE_ADMIN . 'emails/' . md5($this->getAccountId() . $this->getAccountEmail()) . '/messages/' . md5($id . $email['fetch_timestamp']) . '.php'; if ($handle = fopen($cache_file, 'w')) { $text = '<?php //created: {' . date("r") . '}' . "\n\n" . '$cacheFile = ' . var_export($email, true) . "\n\n" . '?>'; @fputs($handle, $text); @fclose($handle); } foreach ($attachments as $attachment) { $src_file = DIR_FS_CACHE_ADMIN . 'emails/' . 'attachments/' . $osC_Session->getID() . '/' . $attachment['name']; $dest_file = DIR_FS_CACHE_ADMIN . 'emails/' . md5($this->getAccountId() . $this->getAccountEmail()) . '/attachments' . '/' . md5($id . $email['fetch_timestamp']) . '-' . $attachment['number'] . '.php'; if (file_exists($src_file)) { @copy($src_file, $dest_file); } } return true; }