}
$last = $body_part;
} elseif ($message->att_local_name) {
+ global $username, $attachment_dir;
+ $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
$filename = $message->att_local_name;
- $file = fopen ($filename, 'rb');
+ $file = fopen ($hashed_attachment_dir . '/' . $filename, 'rb');
while ($body_part = fgets($file, 4096)) {
// remove NUL characters
$body_part = str_replace("\0",'',$body_part);
$this->writeToStream($stream, $body_part);
}
} elseif ($message->att_local_name) {
+ global $username, $attachment_dir;
+ $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
$filename = $message->att_local_name;
- $file = fopen ($filename, 'rb');
+ $file = fopen ($hashed_attachment_dir . '/' . $filename, 'rb');
while ($tmp = fread($file, 570)) {
$body_part = chunk_split(base64_encode($tmp));
// Up to 4.3.10 chunk_split always appends a newline,
} else {
// these are the vars that we can set from the expired composed session
$compo_var_list = array ( 'send_to', 'send_to_cc','body','startMessage',
- 'passed_body','use_signature','signature','attachments','subject','newmail',
+ 'passed_body','use_signature','signature','subject','newmail',
'send_to_bcc', 'passed_id', 'mailbox', 'from_htmladdr_search', 'identity',
'draft_id', 'delete_draft', 'mailprio', 'edit_as_new', 'compose_messsages',
'composesession', 'request_mdn', 'request_dr');
* @return object
*/
function getAttachments($message, &$composeMessage, $passed_id, $entities, $imapConnection) {
- global $squirrelmail_language, $languages;
+ global $squirrelmail_language, $languages, $username, $attachment_dir;
if (!count($message->entities) ||
($message->type0 == 'message' && $message->type1 == 'rfc822')) {
function_exists($languages[$squirrelmail_language]['XTRA_CODE'] . '_encode')) {
$filename = call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_encode', $filename);
}
+
+ $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
$localfilename = sq_get_attach_tempfile();
$message->att_local_name = $localfilename;
$localfilename);
/* Write Attachment to file */
- $fp = fopen ($localfilename, 'wb');
+ $fp = fopen ($hashed_attachment_dir . '/' . $localfilename, 'wb');
mime_print_body_lines ($imapConnection, $passed_id, $message->entity_id, $message->header->encoding, $fp);
fclose ($fp);
}
array_pop($body_a);
$body = implode('', $body_a) . "\r\n";
+ global $username, $attachment_dir;
+ $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
$localfilename = sq_get_attach_tempfile();
- $fp = fopen($localfilename, 'wb');
+ $fp = fopen($hashed_attachment_dir . '/' . $localfilename, 'wb');
fwrite ($fp, $body);
fclose($fp);
$composeMessage->initAttachment('message/rfc822',$subject.'.msg',
}
$attach = array();
+ global $username, $attachment_dir;
+ $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
// composeMessage can be empty when coming from a restored session
if (is_object($composeMessage) && $composeMessage->entities) {
foreach ($composeMessage->entities as $key => $attachment) {
$a['Key'] = $key;
$a['FileName'] = $attached_filename;
$a['ContentType'] = $type;
- $a['Size'] = filesize($attached_file);
+ $a['Size'] = filesize($hashed_attachment_dir . '/' . $attached_file);
$attach[$key] = $a;
}
}
/* True if FAILURE */
function saveAttachedFiles($session) {
- global $compose_messages;
+ global $compose_messages, $username, $attachment_dir;
/* get out of here if no file was attached at all */
if (! is_uploaded_file($_FILES['attachfile']['tmp_name']) ) {
return true;
}
+ $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
$localfilename = sq_get_attach_tempfile();
+ $fullpath = $hashed_attachment_dir . '/' . $localfilename;
// m_u_f works better with restricted PHP installs (safe_mode, open_basedir),
// if that doesn't work, try a simple rename.
- if (!@move_uploaded_file($_FILES['attachfile']['tmp_name'],$localfilename)) {
- if (!@rename($_FILES['attachfile']['tmp_name'], $localfilename)) {
+ if (!@move_uploaded_file($_FILES['attachfile']['tmp_name'],$fullpath)) {
+ if (!@rename($_FILES['attachfile']['tmp_name'], $fullpath)) {
return true;
}
}