From 1899535fbf952e57e08d3aadbf649a03932de93c Mon Sep 17 00:00:00 2001 From: fidian Date: Wed, 11 Oct 2000 16:48:02 +0000 Subject: [PATCH] Added the 'login_top' hook (was missing) (login.php) Made the username form name and password form name changeable (login.php) Added a random string generator function (strings.php) mimeBoundaryString now uses the random string generator (smtp.php) git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@791 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/smtp.php | 10 ++-------- functions/strings.php | 29 +++++++++++++++++++++++++++++ src/login.php | 9 +++++++-- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/functions/smtp.php b/functions/smtp.php index 6edb4488..88bfa9ee 100644 --- a/functions/smtp.php +++ b/functions/smtp.php @@ -77,14 +77,7 @@ static $mimeBoundaryString; if ($mimeBoundaryString == "") { - sq_mt_randomize(); // Initialize the random number generator - // Use all allowed chars besides space. - $Chrs = '\'()+,-./0123456789:=?ABCDEFGHIJKLMNOP' . - 'QRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz'; - // Create a LONG boundary to ensure no duplicates - while (strlen($mimeBoundaryString) < 70) { - $mimeBoundaryString .= $Chrs[mt_rand(0, strlen($Chrs))]; - } + $mimeBoundaryString = GenerateRandomString(70, '\'()+,-./:=?_', 7); } return $mimeBoundaryString; @@ -540,4 +533,5 @@ // Delete the files uploaded for attaching (if any). deleteAttachments(); } + ?> diff --git a/functions/strings.php b/functions/strings.php index b293a6c9..82d30580 100644 --- a/functions/strings.php +++ b/functions/strings.php @@ -417,4 +417,33 @@ return $bytes . ' ' . $type . ''; } + /* Generates a random string from the caracter set you pass in + * + * Flags: + * 1 = add lowercase a-z to $chars + * 2 = add uppercase A-Z to $chars + * 4 = add numbers 0-9 to $chars + */ + + function GenerateRandomString($size, $chars, $flags = 0) + { + if ($flags & 0x1) + $chars .= 'abcdefghijklmnopqrstuvwxyz'; + if ($flags & 0x2) + $chars .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + if ($flags & 0x4) + $chars .= '0123456789'; + + if ($size < 1 || strlen($chars) < 1) + return ""; + + sq_mt_randomize(); // Initialize the random number generator + + while (strlen($String) < $size) { + $String .= $chars[mt_rand(0, strlen($chars))]; + } + + return $String; + } + ?> diff --git a/src/login.php b/src/login.php index dc6447b1..ad71c775 100644 --- a/src/login.php +++ b/src/login.php @@ -61,6 +61,11 @@ echo "\n"; echo "\n"; echo "
\n"; + + $username_form_name = 'username'; + $password_form_name = 'secretkey'; + do_hook('login_top'); + echo "
\n"; echo "
"; printf (_("SquirrelMail version %s"), $version); @@ -81,13 +86,13 @@ echo " \n"; echo _("Name:"); echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo _("Password:"); echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; echo " \n"; echo " \n"; -- 2.25.1