From 23d6bd09c631285eae8c45af3a37aa7c86be3cfa Mon Sep 17 00:00:00 2001 From: thomppj Date: Sat, 3 Nov 2001 23:49:22 +0000 Subject: [PATCH] Some user interface changes. General cleanup of code all over the place. Addition of a file to hold constants. Addition of code to do Javascript autodetection, settings, etc. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1688 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/array.php | 15 +- functions/constants.php | 21 ++ functions/mailbox_display.php | 408 +++++++++++++++++++--------------- functions/options.php | 6 +- functions/strings.php | 388 ++++++++++++++++++-------------- src/left_main.php | 37 +-- src/load_prefs.php | 11 +- src/login.php | 271 +++++++++++----------- src/options.php | 134 ++--------- src/options_display.php | 12 +- src/redirect.php | 221 +++++++++--------- src/right_main.php | 214 +++++++++--------- src/validate.php | 58 +---- 13 files changed, 919 insertions(+), 877 deletions(-) create mode 100644 functions/constants.php diff --git a/functions/array.php b/functions/array.php index 638153ab..e7d8237c 100644 --- a/functions/array.php +++ b/functions/array.php @@ -1,13 +1,12 @@ diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index b521590b..c43e14aa 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -1,13 +1,15 @@ $bold"; if (! isset($search_stuff)) { $search_stuff = ''; } - echo "= 1) { + if ($num_msgs >= 1) { if ($sort < 6) { - $id = range(1, $numMessages); + $id = range(1, $num_msgs); } else { // if it's not sorted - if ($startMessage + ($show_num - 1) < $numMessages) { - $endMessage = $startMessage + ($show_num-1); + if ($start_msg + ($show_num - 1) < $num_msgs) { + $end_msg = $start_msg + ($show_num-1); } else { - $endMessage = $numMessages; + $end_msg = $num_msgs; } - if ($endMessage < $startMessage) { - $startMessage = $startMessage - $show_num; - if ($startMessage < 1) { - $startMessage = 1; + if ($end_msg < $start_msg) { + $start_msg = $start_msg - $show_num; + if ($start_msg < 1) { + $start_msg = 1; } } - $real_startMessage = $numMessages - $startMessage + 1; - $real_endMessage = $numMessages - $startMessage - $show_num + 2; + $real_startMessage = $num_msgs - $start_msg + 1; + $real_endMessage = $num_msgs - $start_msg - $show_num + 2; if ($real_endMessage <= 0) { $real_endMessage = 1; } @@ -227,16 +229,16 @@ $j = 0; if ($sort == 6) { - $end = $startMessage + $show_num - 1; - if ($numMessages < $show_num) { - $end_loop = $numMessages; - } else if ($end > $numMessages) { - $end_loop = $numMessages - $startMessage + 1; + $end = $start_msg + $show_num - 1; + if ($num_msgs < $show_num) { + $end_loop = $num_msgs; + } else if ($end > $num_msgs) { + $end_loop = $num_msgs - $start_msg + 1; } else { $end_loop = $show_num; } } else { - $end = $numMessages; + $end = $num_msgs; $end_loop = $end; } @@ -294,7 +296,7 @@ $i = 0; $j = 0; - while ($j < $numMessages) { + while ($j < $num_msgs) { if (isset($messages[$j]['FLAG_DELETED']) && $messages[$j]['FLAG_DELETED'] == true) { $j++; continue; @@ -304,7 +306,7 @@ $i++; $j++; } - $numMessages = $i; + $num_msgs = $i; } else { if (!isset($messages)) { $messages = array(); @@ -314,7 +316,7 @@ } // There's gotta be messages in the array for it to sort them. - if ($numMessages > 0 && ! $use_cache) { + if ($num_msgs > 0 && ! $use_cache) { /** 0 = Date (up) 4 = Subject (up) ** 1 = Date (dn) 5 = Subject (dn) ** 2 = Name (up) @@ -339,14 +341,14 @@ } session_register('msort'); } - displayMessageArray($imapConnection, $numMessages, $startMessage, $msgs, $msort, $mailbox, $sort, $color,$show_num); + displayMessageArray($imapConnection, $num_msgs, $start_msg, $msgs, $msort, $mailbox, $sort, $color,$show_num); session_register('msgs'); } /******************************************************************/ /* Generic function to convert the msgs array into an HTML table. */ /******************************************************************/ - function displayMessageArray($imapConnection, $numMessages, $startMessage, &$msgs, $msort, $mailbox, $sort, $color,$show_num) { + function displayMessageArray($imapConnection, $num_msgs, $start_msg, &$msgs, $msort, $mailbox, $sort, $color, $show_num) { global $folder_prefix, $sent_folder; global $imapServerAddress, $data_dir, $username, $use_mailbox_cache; global $index_order, $real_endMessage, $real_startMessage, $checkall; @@ -355,146 +357,93 @@ if (!session_is_registered('msgs')) { session_register('msgs'); } if (!session_is_registered('msort')) { session_register('msort'); } - if ($startMessage + ($show_num - 1) < $numMessages) { - $endMessage = $startMessage + ($show_num-1); + if ($start_msg + ($show_num - 1) < $num_msgs) { + $end_msg = $start_msg + ($show_num-1); } else { - $endMessage = $numMessages; + $end_msg = $num_msgs; } - if ($endMessage < $startMessage) { - $startMessage = $startMessage - $show_num; - if ($startMessage < 1) { $startMessage = 1; } + if ($end_msg < $start_msg) { + $start_msg = $start_msg - $show_num; + if ($start_msg < 1) { $start_msg = 1; } } - $nextGroup = $startMessage + $show_num; - $prevGroup = $startMessage - $show_num; $urlMailbox = urlencode($mailbox); do_hook('mailbox_index_before'); - $Message = ''; - if ($startMessage < $endMessage) { - $Message = sprintf( _("Viewing Messages: %s to %s (%s total)"), $startMessage, $endMessage, $numMessages ); - } elseif ($startMessage == $endMessage) { - $Message = _("Viewing Message: 1 (1 total)"); - } else { - $Message = '
'; - } + $msg_cnt_str = get_msgcnt_str($start_msg, $end_msg, $num_msgs); + $paginator_str = get_paginator_str($urlMailbox, $start_msg, $end_msg, $num_msgs, $show_num); - if ($sort == 6) { - $use = 0; - } else { - $use = 1; - } - $lMore = ''; - $rMore = ''; - if (($nextGroup <= $numMessages) && ($prevGroup >= 0)) { - $lMore = "
". _("Previous") . ''; - $rMore = "". _("Next") ."\n"; - } else if (($nextGroup > $numMessages) && ($prevGroup >= 0)) { - $lMore = "". _("Previous") . ''; - $rMore = ""._("Next")."\n"; - } else if (($nextGroup <= $numMessages) && ($prevGroup < 0)) { - $lMore = ""._("Previous") . ''; - $rMore = "". _("Next") ."\n"; - } - if ($lMore <> '') { - $lMore .= ' | '; - } - - /* Page selector block. Following code computes page links. */ - $mMore = ''; - if (!getPref($data_dir, $username, 'page_selector') - && ($numMessages > $show_num)) { - $j = intval( $numMessages / $show_num ); // Max pages - $k = max( 1, $j / getPref($data_dir, $username, 'page_selector_max', PG_SEL_MAX ) ); - if ($numMessages % $show_num <> 0 ) { - $j++; - } - $startMessage = min( $startMessage, $numMessages ); - $p = intval( $startMessage / $show_num ) + 1; - $i = 1; - while( $i < $p ) { - $pg = intval( $i ); - $start = ( ($pg-1) * $show_num ) + 1; - $mMore .= "$pg "; - $i += $k; - } - $mMore .= "$p "; - $i += $k; - while( $i <= $j ) { - $pg = intval( $i ); - $start = ( ($pg-1) * $show_num ) + 1; - $mMore .= "$pg "; - $i+=$k; - } - $mMore .= ' | '; + if (! isset($msg)) { + $msg = ''; } - if (! isset($msg)) - $msg = ''; - mail_message_listing_beginning($imapConnection, - "move_messages.php?msg=$msg&mailbox=$urlMailbox&startMessage=$startMessage", - $mailbox, $sort, $Message, $lMore . $mMore . $rMore, $startMessage); + mail_message_listing_beginning + ($imapConnection, + "move_messages.php?msg=$msg&mailbox=$urlMailbox&startMessage=$start_msg", + $mailbox, $sort, $msg_cnt_str, $paginator_str, $start_msg); - $groupNum = $startMessage % ($show_num - 1); - $real_startMessage = $startMessage; + $groupNum = $start_msg % ($show_num - 1); + $real_startMessage = $start_msg; if ($sort == 6) { - if ($endMessage - $startMessage < $show_num - 1) { - $endMessage = $endMessage - $startMessage + 1; - $startMessage = 1; - } else if ($startMessage > $show_num) { - $endMessage = $show_num; - $startMessage = 1; + if ($end_msg - $start_msg < $show_num - 1) { + $end_msg = $end_msg - $start_msg + 1; + $start_msg = 1; + } else if ($start_msg > $show_num) { + $end_msg = $show_num; + $start_msg = 1; } } - $endVar = $endMessage + 1; + $endVar = $end_msg + 1; - // loop through and display the info for each message. + /* Loop through and display the info for each message. */ $t = 0; // $t is used for the checkbox number - if ($numMessages == 0) { // if there's no messages in this folder - echo "

". _("THIS FOLDER IS EMPTY") ."
 
"; - } else if ($startMessage == $endMessage) { // if there's only one message in the box, handle it different. - if ($sort != 6) - $i = $startMessage; - else - $i = 1; - reset($msort); - $k = 0; - do { - $key = key($msort); - next($msort); - $k++; - } while (isset ($key) && ($k < $i)); - printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0); + if ($num_msgs == 0) { // if there's no messages in this folder + echo "\n"; + echo "

". _("THIS FOLDER IS EMPTY") ."
 
\n"; + echo ""; + } else if ($start_msg == $end_msg) { + /* If there's only one message in the box, handle it differently. */ + if ($sort != 6) { + $i = $start_msg; + } else { + $i = 1; + } + + reset($msort); + $k = 0; + do { + $key = key($msort); + next($msort); + $k++; + } while (isset ($key) && ($k < $i)); + printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0); } else { - $i = $startMessage; - - reset($msort); - $k = 0; - do { - $key = key($msort); - next($msort); - $k++; - } while (isset ($key) && ($k < $i)); - - do { - printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0); - $key = key($msort); - $t++; - $i++; - next($msort); - } while ($i && $i < $endVar); + $i = $start_msg; + + reset($msort); + $k = 0; + do { + $key = key($msort); + next($msort); + $k++; + } while (isset ($key) && ($k < $i)); + + do { + printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0); + $key = key($msort); + $t++; + $i++; + next($msort); + } while ($i && $i < $endVar); } echo ''; echo "" . "" . - "
". - "
$lMore$mMore$rMore$Message
". + "". + "
$paginator_str$msg_cnt_str
". "". ""; /** End of message-list table */ @@ -503,8 +452,10 @@ echo "\n"; } - /* Displays the standard message list header. - * To finish the table, you need to do a ""; + /** + * Displays the standard message list header. To finish the table, + * you need to do a ""; + * * $moveURL is the URL to submit the delete/move form to * $mailbox is the current mailbox * $sort is the current sorting method (-1 for no sorting available [searches]) @@ -513,25 +464,27 @@ */ function mail_message_listing_beginning ($imapConnection, $moveURL, $mailbox = '', $sort = -1, - $Message = '', $More = '', $startMessage = 1) { + $msg_cnt_str = '', $paginator = '', $start_msg = 1) { global $color, $index_order, $auto_expunge, $move_to_trash; global $checkall, $sent_folder, $draft_folder; $urlMailbox = urlencode($mailbox); - /** This is the beginning of the message list table. It wraps around all messages */ - echo "
$Message
" . - ''; + /**************************************************** + * This is the beginning of the message list table. * + * It wraps around all messages * + ****************************************************/ + echo "
\n"; - echo ""; + echo ""; /** The delete and move options */ - echo "
"; - - echo "
' . - "$More"; - ShowSelectAllLink($startMessage, $sort); - echo "
\n
"; + echo " \n"; + echo " \n"; + echo ' \n"; + echo " \n"; + echo "
$paginator' . get_selectall_link($start_msg, $sort) . "$msg_cnt_str
\n"; + echo "
"; + echo "
"; echo "\n
\n"; echo "\n"; @@ -645,10 +598,11 @@ '" BORDER=0 WIDTH=12 HEIGHT=10>'; } - function ShowSelectAllLink($startMessage, $sort) { + function get_selectall_link($start_msg, $sort) { global $checkall, $PHP_SELF, $what, $where, $mailbox; - echo ' \n\n"; + $result .= "%s to %s (%s total)"), $start_msg, $end_msg, $num_msgs); + } else if ($start_msg == $end_msg) { + $result = sprintf(_("Viewing Message: %s (1 total)"), $start_msg); + } else { + $result = '
'; + } + + /* Return our result string. */ + return ($result); + } + + /** + * This function computes the paginator string. + */ + function get_paginator_str + ($urlMailbox, $start_msg, $end_msg, $num_msgs, $show_num) { + $nextGroup = $start_msg + $show_num; + $prevGroup = $start_msg - $show_num; + + if ($sort == 6) { + $use = 0; + } else { + $use = 1; + } + $lMore = ''; + $rMore = ''; + if (($nextGroup <= $num_msgs) && ($prevGroup >= 0)) { + $lMore = "
". _("Previous") . ''; + $rMore = "". _("Next") ."\n"; + } else if (($nextGroup > $num_msgs) && ($prevGroup >= 0)) { + $lMore = "". _("Previous") . ''; + $rMore = ""._("Next")."\n"; + } else if (($nextGroup <= $num_msgs) && ($prevGroup < 0)) { + $lMore = ""._("Previous") . ''; + $rMore = "". _("Next") ."\n"; + } + if ($lMore <> '') { + $lMore .= ' | '; + } + + /* Page selector block. Following code computes page links. */ + $mMore = ''; + if (!getPref($data_dir, $username, 'page_selector') + && ($num_msgs > $show_num)) { + $j = intval( $num_msgs / $show_num ); // Max pages + $k = max( 1, $j / getPref($data_dir, $username, 'page_selector_max', PG_SEL_MAX ) ); + if ($num_msgs % $show_num <> 0 ) { + $j++; + } + $start_msgs = min( $start_msgs, $num_msgs ); + $p = intval( $start_msgs / $show_num ) + 1; + $i = 1; + while( $i < $p ) { + $pg = intval( $i ); + $start = ( ($pg-1) * $show_num ) + 1; + $mMore .= "$pg "; + $i += $k; + } + $mMore .= "$p "; + $i += $k; + while( $i <= $j ) { + $pg = intval( $i ); + $start = ( ($pg-1) * $show_num ) + 1; + $mMore .= "$pg "; + $i+=$k; + } + $mMore .= ' | '; + } + + /* Return the resulting string. */ + return ($lMore . $mMore . $rMore); + } + + function processSubject($subject) { // Shouldn't ever happen -- caught too many times in the IMAP functions if ($subject == '') return _("(no subject)"); diff --git a/functions/options.php b/functions/options.php index 82dbe55a..29f5a9c4 100644 --- a/functions/options.php +++ b/functions/options.php @@ -64,11 +64,13 @@ } function OptionText( $title, $name, $value, $size ) { - echo "\n"; + } + function OptionHidden( $name, $value ) { + echo "\n"; } function OptionCheck( $title, $name, $value, $comment ) { @@ -94,4 +96,4 @@ } -?> \ No newline at end of file +?> diff --git a/functions/strings.php b/functions/strings.php index afafffba..b3c2f763 100644 --- a/functions/strings.php +++ b/functions/strings.php @@ -1,25 +1,37 @@ ]*)([^\t >].*)?$", $line, $regs); $beginning_spaces = $regs[1]; @@ -107,31 +125,28 @@ } - // Does the opposite of sqWordWrap() - function sqUnWordWrap(&$body) - { + /** + * Does the opposite of sqWordWrap() + */ + function sqUnWordWrap(&$body) { $lines = explode("\n", $body); $body = ""; $PreviousSpaces = ""; - for ($i = 0; $i < count($lines); $i ++) - { + for ($i = 0; $i < count($lines); $i ++) { ereg("^([\t >]*)([^\t >].*)?$", $lines[$i], $regs); $CurrentSpaces = $regs[1]; - if (isset($regs[2])) + if (isset($regs[2])) { $CurrentRest = $regs[2]; - if ($i == 0) - { + } + + if ($i == 0) { $PreviousSpaces = $CurrentSpaces; $body = $lines[$i]; - } - else if ($PreviousSpaces == $CurrentSpaces && // Do the beginnings match - strlen($lines[$i - 1]) > 65 && // Over 65 characters long - strlen($CurrentRest)) // and there's a line to continue with - { + } else if (($PreviousSpaces == $CurrentSpaces) // Do the beginnings match + && (strlen($lines[$i - 1]) > 65) // Over 65 characters long + && strlen($CurrentRest)) { // and there's a line to continue with $body .= ' ' . $CurrentRest; - } - else - { + } else { $body .= "\n" . $lines[$i]; $PreviousSpaces = $CurrentSpaces; } @@ -140,8 +155,10 @@ } - /** Returns an array of email addresses **/ - /* Be cautious of "user@host.com" */ + /** + * Returns an array of email addresses. + * Be cautious of "user@host.com" + */ function parseAddrs($text) { if (trim($text) == "") return array(); @@ -157,7 +174,9 @@ return $array; } - /** Returns a line of comma separated email addresses from an array **/ + /** + * Returns a line of comma separated email addresses from an array. + */ function getLineOfAddrs($array) { if (is_array($array)) { $to_line = implode(', ', $array); @@ -192,30 +211,26 @@ $Quotes = 0; $pos = 0; - while (1) - { - if ($line[$pos] == ' ') - { + while (1) { + if ($line[$pos] == ' ') { $pos ++; - } - else if (strpos($line, '>', $pos) === $pos) - { + } else if (strpos($line, '>', $pos) === $pos) { $pos += 4; $Quotes ++; - } - else - { + } else { break; } } if ($Quotes > 1) { - if (! isset($color[14])) + if (! isset($color[14])) { $color[14] = '#FF0000'; + } $line = '' . $line . ''; } elseif ($Quotes) { - if (! isset($color[13])) + if (! isset($color[13])) { $color[13] = '#800000'; + } $line = '' . $line . ''; } @@ -224,11 +239,6 @@ $body = '
' . implode("\n", $body_ary) . '
'; } - /* SquirrelMail version number -- DO NOT CHANGE */ - global $version; - $version = '1.2.0 [cvs]'; - - function find_mailbox_name ($mailbox) { if (ereg(" *\"([^\r\n\"]*)\"[ \r\n]*$", $mailbox, $regs)) return $regs[1]; @@ -237,27 +247,31 @@ } + /** + * This determines the location to forward to relative to your server. + * If this doesnt work correctly for you (although it should), you can + * remove all this code except the last two lines, and change the header() + * function to look something like this, customized to the location of + * SquirrelMail on your server: + * + * http://www.myhost.com/squirrelmail/src/login.php + */ function get_location () { - # This determines the location to forward to relative - # to your server. If this doesnt work correctly for - # you (although it should), you can remove all this - # code except the last two lines, and change the header() - # function to look something like this, customized to - # the location of SquirrelMail on your server: - # - # http://www.myhost.com/squirrelmail/src/login.php global $PHP_SELF, $SERVER_NAME, $HTTP_HOST, $SERVER_PORT, $HTTP_SERVER_VARS; - // Get the path + /* Get the path. */ $path = substr($PHP_SELF, 0, strrpos($PHP_SELF, '/')); - // Check if this is a HTTPS or regular HTTP request + /* Check if this is a HTTPS or regular HTTP request. */ $proto = 'http://'; - // If you have 'SSLOptions +StdEnvVars' in your apache config - // OR if you have HTTPS in your HTTP_SERVER_VARS - // OR if you are on port 443 + + /* + * If you have 'SSLOptions +StdEnvVars' in your apache config + * OR if you have HTTPS in your HTTP_SERVER_VARS + * OR if you are on port 443 + */ $getEnvVar = getenv('HTTPS'); if ((isset($getEnvVar) && !strcasecmp($getEnvVar, 'on')) || (isset($HTTP_SERVER_VARS['HTTPS'])) || @@ -268,18 +282,14 @@ // Get the hostname from the Host header or server config. $host = ''; - if (isset($HTTP_HOST) && !empty($HTTP_HOST)) - { + if (isset($HTTP_HOST) && !empty($HTTP_HOST)) { $host = $HTTP_HOST; - } - else if (isset($SERVER_NAME) && !empty($SERVER_NAME)) - { + } else if (isset($SERVER_NAME) && !empty($SERVER_NAME)) { $host = $SERVER_NAME; } $port = ''; - if (! strstr($host, ':')) - { + if (! strstr($host, ':')) { if (isset($SERVER_PORT)) { if (($SERVER_PORT != 80 && $proto == 'http://') || ($SERVER_PORT != 443 && $proto == 'https://')) { @@ -288,25 +298,24 @@ } } - if ($host) - return $proto . $host . $port . $path; - - // Fallback is to omit the server name and use a relative URI, - // although this is not RFC 2616 compliant. - return $path; + /* Fallback is to omit the server name and use a relative */ + /* URI, although this is not RFC 2616 compliant. */ + return ($host ? $proto . $host . $port . $path : $path); } - // These functions are used to encrypt the passowrd before it is - // stored in a cookie. + /** + * These functions are used to encrypt the passowrd before it is + * stored in a cookie. + */ function OneTimePadEncrypt ($string, $epad) { - $pad = base64_decode($epad); - $encrypted = ''; - for ($i = 0; $i < strlen ($string); $i++) { - $encrypted .= chr (ord($string[$i]) ^ ord($pad[$i])); - } + $pad = base64_decode($epad); + $encrypted = ''; + for ($i = 0; $i < strlen ($string); $i++) { + $encrypted .= chr (ord($string[$i]) ^ ord($pad[$i])); + } - return base64_encode($encrypted); + return base64_encode($encrypted); } function OneTimePadDecrypt ($string, $epad) { @@ -321,37 +330,29 @@ } - // Randomize the mt_rand() function. Toss this in strings or - // integers and it will seed the generator appropriately. - // With strings, it is better to get them long. Use md5() to - // lengthen smaller strings. - function sq_mt_seed($Val) - { + /** + * Randomize the mt_rand() function. Toss this in strings or integers + * and it will seed the generator appropriately. With strings, it is + * better to get them long. Use md5() to lengthen smaller strings. + */ + function sq_mt_seed($Val) { // if mt_getrandmax() does not return a 2^n - 1 number, // this might not work well. This uses $Max as a bitmask. $Max = mt_getrandmax(); - if (! is_int($Val)) - { - if (function_exists('crc32')) - { + if (! is_int($Val)) { + if (function_exists('crc32')) { $Val = crc32($Val); - } - else - { + } else { $Str = $Val; $Pos = 0; $Val = 0; $Mask = $Max / 2; $HighBit = $Max ^ $Mask; - while ($Pos < strlen($Str)) - { - if ($Val & $HighBit) - { + while ($Pos < strlen($Str)) { + if ($Val & $HighBit) { $Val = (($Val & $Mask) << 1) + 1; - } - else - { + } else { $Val = ($Val & $Mask) << 1; } $Val ^= $Str[$Pos]; @@ -360,36 +361,40 @@ } } - if ($Val < 0) - $Val *= -1; - if ($Val = 0) - return; + if ($Val < 0) { + $Val *= -1; + } + + if ($Val = 0) { + return; + } mt_srand(($Val ^ mt_rand(0, $Max)) & $Max); } - // This function initializes the random number generator fairly well. - // It also only initializes it once, so you don't accidentally get - // the same 'random' numbers twice in one session. - function sq_mt_randomize() - { + /** + * This function initializes the random number generator fairly well. + * It also only initializes it once, so you don't accidentally get + * the same 'random' numbers twice in one session. + */ + function sq_mt_randomize() { global $REMOTE_PORT, $REMOTE_ADDR, $UNIQUE_ID; static $randomized; - if ($randomized) - return; + if ($randomized) { + return; + } - // Global + /* Global. */ sq_mt_seed((int)((double) microtime() * 1000000)); sq_mt_seed(md5($REMOTE_PORT . $REMOTE_ADDR . getmypid())); - // getrusage + /* getrusage */ if (function_exists('getrusage')) { // Avoid warnings with Win32 $dat = @getrusage(); - if (isset($dat) && is_array($dat)) - { + if (isset($dat) && is_array($dat)) { $Str = ''; foreach ($dat as $k => $v) { @@ -416,75 +421,81 @@ return base64_encode($pad); } - // Check if we have a required PHP-version. Return TRUE if we do, - // or FALSE if we don't. - // To check for 4.0.1, use sqCheckPHPVersion(4,0,1) - // To check for 4.0b3, use sqCheckPHPVersion(4,0,-3) - // Does not handle betas like 4.0.1b1 or development versions + /** + * Check if we have a required PHP-version. Return TRUE if we do, + * or FALSE if we don't. + * + * To check for 4.0.1, use sqCheckPHPVersion(4,0,1) + * To check for 4.0b3, use sqCheckPHPVersion(4,0,-3) + * + * Does not handle betas like 4.0.1b1 or development versions + */ function sqCheckPHPVersion($major, $minor, $release) { $ver = phpversion(); eregi('^([0-9]+)\\.([0-9]+)(.*)', $ver, $regs); - // Parse the version string + /* Parse the version string. */ $vmajor = strval($regs[1]); $vminor = strval($regs[2]); $vrel = $regs[3]; - if($vrel[0] == ".") + if($vrel[0] == ".") { $vrel = strval(substr($vrel, 1)); - if($vrel[0] == 'b' || $vrel[0] == 'B') + } + if($vrel[0] == 'b' || $vrel[0] == 'B') { $vrel = - strval(substr($vrel, 1)); - if($vrel[0] == 'r' || $vrel[0] == 'R') + } + if($vrel[0] == 'r' || $vrel[0] == 'R') { $vrel = - strval(substr($vrel, 2))/10; + } - // Compare major version - if($vmajor < $major) return false; - if($vmajor > $major) return true; + /* Compare major version. */ + if ($vmajor < $major) { return false; } + if ($vmajor > $major) { return true; } - // Major is the same. Compare minor - if($vminor < $minor) return false; - if($vminor > $minor) return true; + /* Major is the same. Compare minor. */ + if ($vminor < $minor) { return false; } + if ($vminor > $minor) { return true; } - // Major and minor is the same as the required one. - // Compare release - if($vrel >= 0 && $release >= 0) { // Neither are beta + /* Major and minor is the same as the required one. Compare release */ + if ($vrel >= 0 && $release >= 0) { // Neither are beta if($vrel < $release) return false; - } else if($vrel >= 0 && $release < 0){ // This is not beta, required is beta + } else if($vrel >= 0 && $release < 0) { // This is not beta, required is beta return true; - } else if($vrel < 0 && $release >= 0){ // This is beta, require not beta + } else if($vrel < 0 && $release >= 0){ // This is beta, require not beta return false; - } else { // Both are beta + } else { // Both are beta if($vrel > $release) return false; } return true; } - /* Returns a string showing the size of the message/attachment */ - function show_readable_size($bytes) - { + /** + * Returns a string showing the size of the message/attachment. + */ + function show_readable_size($bytes) { $bytes /= 1024; $type = 'k'; - if ($bytes / 1024 > 1) - { + if ($bytes / 1024 > 1) { $bytes /= 1024; $type = 'm'; } - if ($bytes < 10) - { + if ($bytes < 10) { $bytes *= 10; settype($bytes, 'integer'); $bytes /= 10; - } - else + } else { settype($bytes, 'integer'); + } return $bytes . ' ' . $type . ''; } - /* Generates a random string from the caracter set you pass in + /** + * Generates a random string from the caracter set you pass in * * Flags: * 1 = add lowercase a-z to $chars @@ -492,17 +503,20 @@ * 4 = add numbers 0-9 to $chars */ - function GenerateRandomString($size, $chars, $flags = 0) - { - if ($flags & 0x1) + function GenerateRandomString($size, $chars, $flags = 0) { + if ($flags & 0x1) { $chars .= 'abcdefghijklmnopqrstuvwxyz'; - if ($flags & 0x2) + } + if ($flags & 0x2) { $chars .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; - if ($flags & 0x4) + } + if ($flags & 0x4) { $chars .= '0123456789'; + } - if ($size < 1 || strlen($chars) < 1) + if (($size < 1) || (strlen($chars) < 1)) { return ''; + } sq_mt_randomize(); // Initialize the random number generator @@ -514,9 +528,47 @@ return $String; } - function quoteIMAP($str) - { + function quoteIMAP($str) { return ereg_replace('(["\\])', '\\\\1', $str); } -?> \ No newline at end of file + /** + * Trims every element in the array + */ + function TrimArray(&$array) { + foreach ($array as $k => $v) { + global $$k; + if (is_array($$k)) { + foreach ($$k as $k2 => $v2) { + $$k[$k2] = substr($v2, 1); + } + } else { + $$k = substr($v, 1); + } + + /* Re-assign back to array. */ + $array[$k] = $$k; + } + } + + /** + * Removes slashes from every element in the array + */ + function RemoveSlashes(&$array) { + foreach ($array as $k => $v) { + global $$k; + if (is_array($$k)) { + foreach ($$k as $k2 => $v2) { + $newArray[stripslashes($k2)] = stripslashes($v2); + } + $$k = $newArray; + } else { + $$k = stripslashes($v); + } + + /* Re-assign back to the array. */ + $array[$k] = $$k; + } + } + +?> diff --git a/src/left_main.php b/src/left_main.php index c73b998d..a15cec3a 100644 --- a/src/left_main.php +++ b/src/left_main.php @@ -1,14 +1,14 @@ '; echo _("Folders") . "
\n\n"; + /* First, display the clock. */ if ($hour_format == 1) { - if ($date_format == 4) + if ($date_format == 4) { $hr = "G:i:s"; - else + } else { $hr = "G:i"; + } } else { - if ($date_format == 4) + if ($date_format == 4) { $hr = "g:i:s a"; - else + } else { $hr = "g:i a"; + } } switch( $date_format ) { @@ -184,14 +187,18 @@ default: $clk = date("D, ".$hr, time()); } + $clk = str_replace(' ',' ',$clk); + + echo '
' . str_replace(' ',' ',_("Last Refresh")) + . ": $clk
"; - echo '
' . _("Last Refresh") . ":
$clk"; - echo '
'; + /* Next, display the refresh button. */ echo '('; echo _("refresh folder list"); echo ')
'; $delimeter = sqimap_get_delimiter($imapConnection); + /* Lastly, display the folder list. */ if (isset($collapse_folders) && $collapse_folders) { /* If directed, collapse or uncollapse a folder. */ if (isset($fold)) { diff --git a/src/load_prefs.php b/src/load_prefs.php index e87fd833..b55a4b30 100644 --- a/src/load_prefs.php +++ b/src/load_prefs.php @@ -14,7 +14,7 @@ require_once('../src/validate.php'); /**************************************************************/ - /* Following code should be removed in the next foo_once step + /* Following code should be removed in the next foo_once step */ if (defined('load_prefs_php')) { return; } define('load_prefs_php', true); /**************************************************************/ @@ -24,6 +24,7 @@ if (! isset($color)) { $color = array(); } require_once('../functions/prefs.php'); require_once('../functions/plugin.php'); + require_once('../functions/constants.php'); if (!isset($username)) { $username = ''; } checkForPrefs($data_dir, $username); @@ -193,11 +194,15 @@ /* show_html_default is a int value. */ $show_html_default = intval(getPref($data_dir, $username, 'show_html_default', 1 ) ); - /* SqClock into the core */ + /* SqClock now in the core */ global $date_format, $hour_format, $username, $data_dir; - $date_format = getPref($data_dir, $username, 'date_format', 3); $hour_format = getPref($data_dir, $username, 'hour_format', 2); + /* Load the javascript settings. */ + global $javascript_setting, $javascript_on; + $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT); + $javascript_on = getPref($data_dir, $username, 'javascript_on', true); + do_hook("loading_prefs"); ?> diff --git a/src/login.php b/src/login.php index 716f0f0c..1d285904 100644 --- a/src/login.php +++ b/src/login.php @@ -1,149 +1,154 @@ $v) - { - $key = strtolower($k); - $value = urlencode($v); - if ($key == 'cc') - $rcptaddress .= '&send_to_cc=' . $value; - elseif ($key == 'bcc') - $rcptaddress .= '&send_to_bcc=' . $value; - elseif ($key == 'subject') - $rcptaddress .= '&subject=' . $value; - elseif ($key == 'body') - $rcptaddress .= '&body=' . $value; - } + /* At this point, we have parsed a lot of the mailto stuff. */ + /* Let's do the rest -- CC, BCC, Subject, Body */ + /* Note: They can all be case insensitive */ + foreach ($GLOBALS as $k => $v) { + $key = strtolower($k); + $value = urlencode($v); + if ($key == 'cc') { + $rcptaddress .= '&send_to_cc=' . $value; + } else if ($key == 'bcc') { + $rcptaddress .= '&send_to_bcc=' . $value; + } else if ($key == 'subject') { + $rcptaddress .= '&subject=' . $value; + } else if ($key == 'body') { + $rcptaddress .= '&body=' . $value; + } + } - // Double-encode in this fashion to get past redirect.php properly - $rcptaddress = urlencode($rcptaddress); - } + /* Double-encode in this fashion to get past redirect.php properly. */ + $rcptaddress = urlencode($rcptaddress); + } - require_once('../functions/strings.php'); - require_once('../config/config.php'); - require_once('../functions/i18n.php'); - require_once('../functions/plugin.php'); + require_once('../functions/strings.php'); + require_once('../config/config.php'); + require_once('../functions/i18n.php'); + require_once('../functions/plugin.php'); + require_once('../functions/constants.php'); - // $squirrelmail_language is set by a cookie when the user selects - // language and logs out - set_up_language($squirrelmail_language, true); + /* + * $squirrelmail_language is set by a cookie when the user selects + * language and logs out + */ + set_up_language($squirrelmail_language, true); - // Need the base URI to set the cookies. (Same code as in webmail.php) - ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs); - $base_uri = $regs[1]; + /* Need the base URI to set the cookies. (Same code as in webmail.php). */ + ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs); + $base_uri = $regs[1]; + @session_destroy(); - @session_destroy(); - // In case the last session was not terminated properly, make sure - // we get a new one. - $cookie_params = session_get_cookie_params(); - setcookie(session_name(),'',0,$cookie_params['path'].$cookie_params['domain']); - setcookie('username', '', 0, $base_uri); - setcookie('key', '', 0, $base_uri); - header ('Pragma: no-cache'); + /* + * In case the last session was not terminated properly, make sure + * we get a new one. + */ + $cookie_params = session_get_cookie_params(); + setcookie(session_name(),'',0,$cookie_params['path'].$cookie_params['domain']); + setcookie('username', '', 0, $base_uri); + setcookie('key', '', 0, $base_uri); + header ('Pragma: no-cache'); - do_hook('login_cookie'); + do_hook('login_cookie'); - echo '' . - "\n\n" . - "\n" . - "\n"; + echo '' . + "\n\n" . + "\n" . + "\n"; - if ($theme_css != "") - echo "\n"; + if ($theme_css != "") { + echo "\n"; + } - echo ''; - echo $org_name . ' - ' . _("Login"); - echo "\n"; - echo "\n"; - echo "\n"; + /* Output the javascript onload function. */ + echo "\n"; + + /* Set the title of this page. */ + echo "$org_name - " . _("Login") . "\n"; + echo "\n"; + echo "\n"; - $username_form_name = 'login_username'; - $password_form_name = 'secretkey'; - do_hook('login_top'); + $username_form_name = 'login_username'; + $password_form_name = 'secretkey'; + do_hook('login_top'); + + $loginname_value = (isset($loginname) ? htmlspecialchars($loginname) : ''); - echo "
\n"; - echo "
"; - printf (_("SquirrelMail version %s"), $version); - echo "
\n"; - echo _("By the SquirrelMail Development Team"); - echo "
\n"; - echo "
$title: " . "" . "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo "
"; - printf (_("%s Login"), $org_name); - echo "
\n"; - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - if ($rcptaddress != '') { - echo " \n"; - } - echo " \n"; - echo "
\n"; - echo _("Name:"); - echo " \n"; - echo " \n"; - echo "
\n"; - echo _("Password:"); - echo " \n"; - echo " \n"; - echo "
\n"; - echo "
\n"; - echo '
\n"; - echo "
\n"; - echo "\n"; - do_hook('login_form'); - echo "
\n"; - do_hook('login_bottom'); -?> - - + echo "
"; + echo "
\n"; + echo ' ' . sprintf (_("SquirrelMail version %s"), $version) . "
\n"; + echo ' ' . _("By the SquirrelMail Development Team") . "
\n"; + echo "
\n"; + echo "\n"; + echo " "; + echo " \n"; + echo " \n"; + echo "
\n"; + echo '
' . sprintf (_("%s Login"), $org_name) . "
\n"; + echo "
\n"; + echo " \n"; + echo ' \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo ' \n"; + echo " \n"; + echo " \n"; + echo "
' . _("Name:") . "\n"; + echo " \n"; + echo "
' . _("Password:") . "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + if ($rcptaddress != '') { + echo " \n"; + } + echo "
\n"; + echo '
\n"; + echo "
\n"; + + do_hook('login_form'); + echo "\n"; + + do_hook('login_bottom'); + echo "\n"; + echo "\n"; +?> diff --git a/src/options.php b/src/options.php index 1c306714..edc0b786 100644 --- a/src/options.php +++ b/src/options.php @@ -82,6 +82,7 @@ setPref($data_dir, $username, 'chosen_theme', $chosentheme); setPref($data_dir, $username, 'language', $language); setPref($data_dir, $username, 'use_javascript_addr_book', $javascript_abook); + setPref($data_dir, $username, 'javascript_setting', $new_javascript_setting); setPref($data_dir, $username, 'show_num', $shownum); setPref($data_dir, $username, 'wrap_at', $wrapat); setPref($data_dir, $username, 'editor_size', $editorsize); @@ -116,6 +117,17 @@ setPref($data_dir, $username, 'page_selector', 1); } + $js_autodetect_results = (isset($js_autodetect_results) ? $js_autodetect_results : SMPREF_JS_OFF); + if ($new_javascript_setting == SMPREF_JS_AUTODETECT) { + if ($js_autodetect_results == SMPREF_JS_ON) { + setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON); + } else { + setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF); + } + } else { + setPref($data_dir, $username, 'javascript_on', $new_javascript_setting); + } + do_hook('options_display_save'); echo '
'._("Successfully saved display preferences!").'
'; @@ -213,13 +225,13 @@ /* Let's sort Javascript Option Pages to the bottom. */ /*****************************************************/ foreach ($optionpages as $optpage) { - if ($optpage['js']) { + if (!$optpage['js']) { + $reg_optionpages[] = $optpage; + } else if ($javascript_on == SMPREF_JS_ON) { $js_optionpages[] = $optpage; - } else { - $nojs_optionpages[] = $optpage; } } - $optionpages = array_merge($nojs_optionpages, $js_optionpages); + $optionpages = array_merge($reg_optionpages, $js_optionpages); /********************************************/ /* Now, print out each option page section. */ @@ -271,121 +283,9 @@ /*******************************************************************/ /** - * This function prints out an option page row. All it actually - * does is call the three functions below. + * This function prints out an option page row. */ function print_optionpages_row($leftopt, $rightopt = false) { - if ($rightopt == false) { - if ($leftopt['js']) { - print_optionpages_row_fulljs($leftopt); - } else { - print_optionpages_row_nojs($leftopt); - } - } else { - if ($leftopt['js']) { - if ($rightopt['js']) { - print_optionpages_row_fulljs($leftopt, $rightopt); - } else { - print_optionpages_row_partjs($leftopt, $rightopt); - } - } else { - print_optionpages_row_nojs($leftopt, $rightopt); - } - } - } - - /** - * This function prints out an option page row: in which the left - * Left: options for functionality that do not require javascript - * Right: options for functionality that do not require javascript - */ - function print_optionpages_row_nojs($leftopt, $rightopt = false) { - global $color; -?> - - -
- - - - - - - - - - - - - - - - - - - -
- -   - -  
- -   - -  
-
- - - -
- - - - - - - - - - - - - - - - - - - -
- -   - -  
- -   - -  
-
- diff --git a/src/options_display.php b/src/options_display.php index a59e46e2..69cba54b 100644 --- a/src/options_display.php +++ b/src/options_display.php @@ -39,6 +39,12 @@ array( '1' => _("JavaScript"), '0' => _("HTML") ), $use_javascript_addr_book ); + OptionSelect( _("Use Javascript"), 'new_javascript_setting', + array(SMPREF_JS_AUTODETECT => _("Autodetect"), + SMPREF_JS_ON => _("Always"), + SMPREF_JS_OFF => _("Never") ), + $javascript_setting ); + OptionHidden('js_autodetect_results', SMPREF_JS_OFF); OptionText( _("Number of Messages to Index"), 'shownum', $show_num, 5 ); OptionText( _("Wrap incoming text at"), 'wrapat', $wrap_at, 5 ); OptionText( _("Size of editor window"), 'editorsize', $editor_size, 5 ); @@ -105,6 +111,10 @@
+ +
- \ No newline at end of file + diff --git a/src/redirect.php b/src/redirect.php index 5f4b1b21..02892c32 100644 --- a/src/redirect.php +++ b/src/redirect.php @@ -1,102 +1,123 @@ \n"; - echo "

"; - echo "
"; - echo ""._("You must be logged in to access this page.")."
"; - echo ""._("Go to the login page")."\n"; - echo "
"; - echo "\n"; - exit; - } - - // Refresh the language cookie. - if (isset($squirrelmail_language)) { - setcookie('squirrelmail_language', $squirrelmail_language, time()+2592000,$base_uri); - } - - - require_once('../functions/prefs.php'); - require_once('../functions/imap.php'); - require_once('../functions/plugin.php'); - - if (!session_is_registered('user_is_logged_in')) { - do_hook ('login_before'); - - $onetimepad = OneTimePadCreate(strlen($secretkey)); - $key = OneTimePadEncrypt($secretkey, $onetimepad); - session_register('onetimepad'); - // verify that username and password are correct - if ($force_username_lowercase) - $login_username = strtolower($login_username); - - $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0); - if (!$imapConnection) { - echo "\n"; - echo "

"; - echo "
"; - echo ""._("There was an error contacting the mail server.")."
"; - echo _("Contact your administrator for help.")."\n"; - echo "
"; - echo "\n"; - exit; - } else { - $delimiter = sqimap_get_delimiter ($imapConnection); - } - sqimap_logout($imapConnection); - - $username = $login_username; - session_register ('username'); - setcookie('key', $key, 0, $base_uri); - setcookie('delimiter', $delimiter, 0, $base_uri); - do_hook ('login_verified'); - } - - $user_is_logged_in = true; - session_register ('user_is_logged_in'); - $just_logged_in = true; - session_register ('just_logged_in'); - - if(isset($rcptemail)) - header("Location: webmail.php?right_frame=compose.php&rcptaddress=" . - urlencode($rcptemail)); - else - header("Location: webmail.php"); + /** + * redirect.php + * Derived from webmail.php by Ralf Kraudelt + * + * Copyright (c) 1999-2001 The Squirrelmail Development Team + * Licensed under the GNU GPL. For full terms see the file COPYING. + * + * Prevents users from reposting their form data after a successful logout. + * + * $Id$ + */ + + require_once('../functions/i18n.php'); + require_once('../functions/strings.php'); + require_once('../config/config.php'); + + /* Before starting the session, the base URI must be known. Assuming */ + /* that this file is in the src/ subdirectory (or something). */ + ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs); + $base_uri = $regs[1]; + + header('Pragma: no-cache'); + $location = get_location(); + + session_set_cookie_params (0, $base_uri); + session_start(); + + session_unregister ('user_is_logged_in'); + session_register ('base_uri'); + + if (! isset($squirrelmail_language)) { + $squirrelmail_language = ''; + } + set_up_language($squirrelmail_language, true); + + if (!isset($login_username)) { + echo "\n"; + echo "

\n"; + echo "
\n"; + echo ' ' . _("You must be logged in to access this page.") . "
"; + echo ' ' . _("Go to the login page") . "\n"; + echo "
\n"; + echo "\n"; + exit; + } + + /* Refresh the language cookie. */ + if (isset($squirrelmail_language)) { + setcookie('squirrelmail_language', $squirrelmail_language, time()+2592000,$base_uri); + } + + require_once('../functions/prefs.php'); + require_once('../functions/imap.php'); + require_once('../functions/plugin.php'); + require_once('../functions/constants.php'); + + if (!session_is_registered('user_is_logged_in')) { + do_hook ('login_before'); + + $onetimepad = OneTimePadCreate(strlen($secretkey)); + $key = OneTimePadEncrypt($secretkey, $onetimepad); + session_register('onetimepad'); + + /* Verify that username and password are correct. */ + if ($force_username_lowercase) { + $login_username = strtolower($login_username); + } + + $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0); + if (!$imapConnection) { + echo "\n"; + echo "

"; + echo "
"; + echo ""._("There was an error contacting the mail server.")."
"; + echo _("Contact your administrator for help.")."\n"; + echo "
"; + echo "\n"; + exit; + } else { + $delimiter = sqimap_get_delimiter ($imapConnection); + } + sqimap_logout($imapConnection); + + $username = $login_username; + session_register ('username'); + setcookie('key', $key, 0, $base_uri); + setcookie('delimiter', $delimiter, 0, $base_uri); + do_hook ('login_verified'); + } + + /* Set the login variables. */ + $user_is_logged_in = true; + $just_logged_in = true; + + /* And register with them with the session. */ + session_register ('user_is_logged_in'); + session_register ('just_logged_in'); + + /* Complete autodetection of Javascript. */ + $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT); + $js_autodetect_results = (isset($js_autodetect_results) ? $js_autodetect_results : SMPREF_JS_OFF); + if ($javascript_setting == SMPREF_JS_AUTODETECT) { + if ($js_autodetect_results == SMPREF_JS_ON) { + setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON); + } else { + setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF); + } + } else { + setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF); + } + + /* Compute the URL to forward the user to. */ + if(isset($rcptemail)) { + $redirect_url = 'webmail.php?right_frame=compose.php&rcptaddress='; + $redirect_url .= urlencode($rcptemail); + } else { + $redirect_url = 'webmail.php'; + } + + /* Send them off to the appropriate page. */ + header("Location: $redirect_url"); ?> diff --git a/src/right_main.php b/src/right_main.php index 03ea014f..d63a634d 100644 --- a/src/right_main.php +++ b/src/right_main.php @@ -1,115 +1,129 @@ $note
\n"; - - if ($just_logged_in == true) { - $just_logged_in = false; - - if (strlen(trim($motd)) > 0) { - echo "
" . - '
' . - "" . - "' . - '
$motd"; - do_hook('motd'); - echo '
' . - '
'; - } - } + /** + * right_main.php + * + * Copyright (c) 1999-2001 The Squirrelmail Development Team + * Licensed under the GNU GPL. For full terms see the file COPYING. + * + * This is where the mailboxes are listed. This controls most of what + * goes on in SquirrelMail. + * + * $Id$ + */ + + require_once('../src/validate.php'); + require_once('../functions/imap.php'); + require_once('../functions/date.php'); + require_once('../functions/array.php'); + require_once('../functions/mime.php'); + require_once('../functions/mailbox_display.php'); + require_once('../functions/display_messages.php'); + + /*********************************************************** + * incoming variables from URL: * + * $sort Direction to sort by date * + * values: 0 - descending order * + * values: 1 - ascending order * + * $startMessage Message to start at * + * $mailbox Full Mailbox name * + * * + * incoming from cookie: * + * $username duh * + * $key pass * + ***********************************************************/ + + /* Open a connection on the imap port (143) */ + $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); + + if (isset($newsort) && $newsort != $sort) { + setPref($data_dir, $username, 'sort', $newsort); + } + + /* If the page has been loaded without a specific mailbox, */ + /* send them to the inbox */ + if (!isset($mailbox)) { + $mailbox = 'INBOX'; + $startMessage = 1; + } + + /* compensate for the UW vulnerability. */ + if ($imap_server_type == 'uw' && (strstr($mailbox, '../') !== false || + substr($mailbox, 0, 1) == '/')) { + $mailbox = 'INBOX'; + } + + sqimap_mailbox_select($imapConnection, $mailbox); + displayPageHeader($color, $mailbox); + echo "
\n"; + + do_hook('right_main_after_header'); + + if (isset($note)) { + echo "
$note

\n"; + } + + if ($just_logged_in == true) { + $just_logged_in = false; + + if (strlen(trim($motd)) > 0) { + echo "
" . + '
' . + "" . + "' . + '
$motd"; + do_hook('motd'); + echo '
' . + '
'; + } + } if (isset($newsort)) { $sort = $newsort; session_register('sort'); } - // Check to see if we can use cache or not. Currently the only time when you wont use it is - // when a link on the left hand frame is used. Also check to make sure we actually have the - // array in the registered session data. :) - if (! isset($use_mailbox_cache)) - $use_mailbox_cache = 0; - if ($use_mailbox_cache && session_is_registered('msgs')) { - showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache); - } else { - if (session_is_registered('msgs')) - unset($msgs); - if (session_is_registered('msort')) - unset($msort); - if (session_is_registered('numMessages')) + /********************************************************************* + * Check to see if we can use cache or not. Currently the only time * + * when you will not use it is when a link on the left hand frame is * + * used. Also check to make sure we actually have the array in the * + * registered session data. :) * + *********************************************************************/ + if (! isset($use_mailbox_cache)) { + $use_mailbox_cache = 0; + } + + if ($use_mailbox_cache && session_is_registered('msgs')) { + showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache); + } else { + if (session_is_registered('msgs')) { + unset($msgs); + } + + if (session_is_registered('msort')) { + unset($msort); + } + + if (session_is_registered('numMessages')) { unset($numMessages); + } + + $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox); - $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox); + showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache); - showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache); + if (session_is_registered('msgs') && isset($msgs)) { + session_register('msgs'); + } - if (session_is_registered('msgs') && isset($msgs)) - session_register('msgs'); - if (session_is_registered('msort') && isset($msort)) - session_register('msort'); - session_register('numMessages'); - } + if (session_is_registered('msort') && isset($msort)) { + session_register('msort'); + } + + session_register('numMessages'); + } - do_hook('right_main_bottom'); - sqimap_logout ($imapConnection); + do_hook('right_main_bottom'); + sqimap_logout ($imapConnection); ?> diff --git a/src/validate.php b/src/validate.php index c74be9c4..0c0688c1 100644 --- a/src/validate.php +++ b/src/validate.php @@ -14,6 +14,7 @@ session_start(); require_once('../functions/i18n.php'); require_once('../functions/auth.php'); + require_once('../functions/strings.php'); is_logged_in(); @@ -52,54 +53,15 @@ } } - /************************************/ - /* Trims every element in the array */ - /************************************/ - function TrimArray(&$array) { - foreach ($array as $k => $v) { - global $$k; - if (is_array($$k)) { - foreach ($$k as $k2 => $v2) { - $$k[$k2] = substr($v2, 1); - } - } else { - $$k = substr($v, 1); - } - - /* Re-assign back to array. */ - $array[$k] = $$k; - } - } - - - /***************************************************/ - /* Removes slashes from every element in the array */ - /***************************************************/ - function RemoveSlashes(&$array) { - foreach ($array as $k => $v) { - global $$k; - if (is_array($$k)) { - foreach ($$k as $k2 => $v2) { - $newArray[stripslashes($k2)] = stripslashes($v2); - } - $$k = $newArray; - } else { - $$k = stripslashes($v); - } - - /* Re-assign back to the array. */ - $array[$k] = $$k; - } - } - - /** - * Everyone needs stuff from config, and config needs stuff from - * strings.php, so include them both here. - * - * Include them down here instead of at the top so that all config - * variables overwrite any passed in variables (for security). - */ - require_once('../functions/strings.php'); + /** + * Everyone needs stuff from config, and config needs stuff from + * strings.php, so include them both here. Actually, strings is + * included at the top now as the string array functions have + * been moved into it. + * + * Include them down here instead of at the top so that all config + * variables overwrite any passed in variables (for security). + */ require_once('../config/config.php'); require_once('../src/load_prefs.php'); require_once('../functions/page_header.php'); -- 2.25.1