From: Thijs K. <ki...@us...> - 2007-01-07 17:30:56
|
Update of /cvsroot/squirrelmail/squirrelmail/plugins/spamcop In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv7942/plugins/spamcop Modified Files: functions.php spamcop.php Log Message: Improve attachment file handling: use one new function to create a temp file for storing the attachment. This replaces the same code in five places. It also improves on the code, it's now much more safe against overwriting existing attachments by chance. Index: functions.php =================================================================== RCS file: /cvsroot/squirrelmail/squirrelmail/plugins/spamcop/functions.php,v retrieving revision 1.9 retrieving revision 1.10 diff -u -w -r1.9 -r1.10 --- functions.php 3 Jan 2007 09:03:58 -0000 1.9 +++ functions.php 7 Jan 2007 17:30:11 -0000 1.10 @@ -180,9 +180,7 @@ */ function spamcop_getMessage_RFC822_Attachment($message, $composeMessage, $passed_id, $passed_ent_id='', $imapConnection) { - global $attachment_dir, $username; - $hashed_attachment_dir = getHashedDir($username, $attachment_dir); if (!$passed_ent_id) { $body_a = sqimap_run_command($imapConnection, 'FETCH '.$passed_id.' RFC822', @@ -198,21 +196,12 @@ array_shift($body_a); $body = implode('', $body_a) . "\r\n"; - $localfilename = GenerateRandomString(32, 'FILE', 7); - $full_localfilename = "$hashed_attachment_dir/$localfilename"; - $fp = fopen( $full_localfilename, 'w'); + $filename = sq_get_attach_tempfile(); + $fp = fopen($filename, 'wb'); fwrite ($fp, $body); fclose($fp); - - /* dirty relative dir fix */ - if (substr($attachment_dir,0,3) == '../') { - $attachment_dir = substr($attachment_dir,3); - $hashed_attachment_dir = getHashedDir($username, $attachment_dir); - } - $full_localfilename = "$hashed_attachment_dir/$localfilename"; - $composeMessage->initAttachment('message/rfc822','email.txt', - $full_localfilename); + $filename); } return $composeMessage; } Index: spamcop.php =================================================================== RCS file: /cvsroot/squirrelmail/squirrelmail/plugins/spamcop/spamcop.php,v retrieving revision 1.43 retrieving revision 1.44 diff -u -w -r1.43 -r1.44 --- spamcop.php 5 Aug 2006 14:49:49 -0000 1.43 +++ spamcop.php 7 Jan 2007 17:30:12 -0000 1.44 @@ -23,6 +23,8 @@ /* plugin functions */ include_once(SM_PATH . 'plugins/spamcop/functions.php'); +include_once(SM_PATH . 'functions/compose.php'); + /* GLOBALS */ sqgetGlobalVar('mailbox', $mailbox, SQ_GET); |