// of the $haystack is reached. $needle is a single character
//*************************************************************************
function readShortMailboxName($haystack, $needle) {
+ if ($needle == "") return $haystack;
if ($needle == ".") $needle = "\.";
ereg("([^$needle]+)$needle?$", $haystack, $regs);
return $regs[1];
}
+ //*************************************************************************
+ // Read from the back of $haystack until $needle is found, or the begining
+ // of the $haystack is reached. $needle is a single character
+ //*************************************************************************
+ function readMailboxParent($haystack, $needle) {
+ if ($needle == ".") $needle = "\.";
+ ereg("^(.+)$needle([^$needle]+)$needle?$", $haystack, $regs);
+ return $regs[1];
+ }
+
// Searches for the next position in a string minus white space
function next_pos_minus_white ($haystack, $pos) {
while (substr($haystack, $pos, 1) == " " ||
/* Be cautious of "user@host.com" */
function parseAddrs($text) {
if (trim($text) == "")
- return;
+ return array();
$text = str_replace(" ", "", $text);
$text = ereg_replace('"[^"]*"', "", $text);
$text = ereg_replace("\([^\)]*\)", "", $text);
}
/* SquirrelMail version number -- DO NOT CHANGE */
- $version = "1.0pre1 (cvs)";
+ $version = "1.0pre3 [cvs]";
function find_mailbox_name ($mailbox) {
// Check if this is a HTTPS or regular HTTP request
$proto = "http://";
- if(isset($HTTPS) && $HTTPS == 'on' ) {
+ if(isset($HTTPS) && !strcasecmp($HTTPS, 'on') ) {
$proto = "https://";
}
// These functions are used to encrypt the passowrd before it is
// stored in a cookie.
- function OneTimePadEncrypt ($string, $pad) {
+ function OneTimePadEncrypt ($string, $epad) {
+ $pad = base64_decode($epad);
for ($i = 0; $i < strlen ($string); $i++) {
$encrypted .= chr (ord($string[$i]) ^ ord($pad[$i]));
}
return base64_encode($encrypted);
}
- function OneTimePadDecrypt ($string, $pad) {
+ function OneTimePadDecrypt ($string, $epad) {
+ $pad = base64_decode($epad);
$encrypted = base64_decode ($string);
for ($i = 0; $i < strlen ($encrypted); $i++) {
$pad .= chr(mt_rand(0,255));
}
- return $pad;
+ return base64_encode($pad);
}
// Check if we have a required PHP-version. Return TRUE if we do,