From a4fe5de0ec975f32047a77f7b08472cd077a8dc3 Mon Sep 17 00:00:00 2001 From: fidian Date: Sat, 3 Mar 2001 16:20:31 +0000 Subject: [PATCH] * HTML cleaned up a bit * Allows for multiple attachments, guaranteed. Apparently, GenerateRandomString was producing the exact same string for a second file attached. This would of course overwrite the currently existing attachment in both the $attachments array and on disk. The first one would be gone. The code (two lines) fixes this by checking if that $localfilename is already defined in $attachments, and will generate a new $localfilename if it does. What I can't figure out is how in the world did GenerateRandomString produce the exact same string with two completely different page requests. We generate a key based on the time, remote user's information, and Apache's unique ID that it sends along. Also, it was supposed to generate 32 characters of lowercase, uppercase, and numbers. That creates a string with 62^32 different possibilities. That seems pretty wide open, but apparently it caused problems. Well, problems are solved now by simply checking if the string was used already. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1162 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- src/compose.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/compose.php b/src/compose.php index abb60da2..d9110e2c 100644 --- a/src/compose.php +++ b/src/compose.php @@ -41,8 +41,10 @@ include("../src/load_prefs.php"); if (!isset($attachments)) + { $attachments = array(); - + } + // This function is used when not sending or adding attachments function newMail () { global $forward_id, $imapConnection, $msg, $ent_num, $body_ary, $body, @@ -300,20 +302,19 @@ } // This code is for attachments - echo " \n"; - echo " \n"; - echo "
"._("Attach:"); - echo " \n"; + echo " \n"; + echo " "._("Attach:"); + echo " \n"; echo " \n"; echo "   \n"; echo " \n"; echo " \n"; if (count($attachments) > 0) { - echo "\n"; + echo "\n"; echo " "; - echo ""; - while (list($localname, $remotename) = each($attachments)) { + echo ""; + foreach ($attachments as $localname => $remotename) { echo "\n"; echo "$remotename
\n"; } @@ -376,6 +377,8 @@ is_logged_in(); $localfilename = GenerateRandomString(32, '', 7); + while (isset($attachments[$localfilename])) + $localfilename = GenerateRandomString(32, '', 7); if (!@rename($HTTP_POST_FILES['attachfile']['tmp_name'], $attachment_dir.$localfilename)) { if (!@copy($HTTP_POST_FILES['attachfile']['tmp_name'], $attachment_dir.$localfilename)) { -- 2.25.1