From d3cdb279bd61b172926b51d41d09c8a691d6c347 Mon Sep 17 00:00:00 2001 From: lkehresman Date: Thu, 6 Jan 2000 17:03:04 +0000 Subject: [PATCH] Added "Themes" to personal preferences git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@108 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- config/config.php | 17 +++++++++++++++-- config/deepocean_theme.php | 21 +++++++++++++++++++++ config/sandstorm_theme.php | 21 +++++++++++++++++++++ config/slashdot_theme.php | 22 ++++++++++++++++++++++ data/default_pref | 3 ++- functions/mailbox_display.php | 2 +- functions/mime.php | 9 ++++----- functions/prefs.php | 2 +- functions/smtp.php | 29 +++++++++++++++++++++-------- functions/strings.php | 2 +- src/compose.php | 1 + src/compose_send.php | 2 ++ src/delete_message.php | 2 ++ src/download.php | 6 ++++-- src/empty_trash.php | 2 ++ src/folders.php | 2 ++ src/folders_create.php | 2 ++ src/folders_delete.php | 2 ++ src/folders_rename_do.php | 2 ++ src/folders_rename_getname.php | 2 ++ src/left_main.php | 8 +++++--- src/load_prefs.php | 11 +++++++++++ src/move_messages.php | 2 ++ src/options.php | 33 +++++++++++++++++++++++++++++---- src/options_submit.php | 8 ++++---- src/read_body.php | 4 +++- src/right_main.php | 4 +++- src/signout.php | 2 ++ 28 files changed, 189 insertions(+), 34 deletions(-) create mode 100644 config/deepocean_theme.php create mode 100644 config/sandstorm_theme.php create mode 100644 config/slashdot_theme.php create mode 100644 src/load_prefs.php diff --git a/config/config.php b/config/config.php index f90446d9..a2541696 100644 --- a/config/config.php +++ b/config/config.php @@ -34,8 +34,21 @@ // // You can download themes from http://squirrelmail.sourceforge.net/index.php3?page=10 // -// Example: require("../config/default_theme.php"); - require("../config/default_theme.php"); +// To add a new theme to the options that users can choose from, just add +// a new number to the array at the bottom, and follow the pattern. + + $theme[0]["PATH"] = "../config/default_theme.php"; // This is your default theme. Can be theme. + $theme[0]["NAME"] = "Default"; + + $theme[1]["PATH"] = "../config/sandstorm_theme.php"; + $theme[1]["NAME"] = "Sand Storm"; + + $theme[2]["PATH"] = "../config/deepocean_theme.php"; + $theme[2]["NAME"] = "Deep Ocean"; + + $theme[3]["PATH"] = "../config/slashdot_theme.php"; + $theme[3]["NAME"] = "Slashdot"; + // Whether or not to use $color[11] for special folders. If not, special // folders will be the same color as the other folders diff --git a/config/deepocean_theme.php b/config/deepocean_theme.php new file mode 100644 index 00000000..a7408108 --- /dev/null +++ b/config/deepocean_theme.php @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/config/sandstorm_theme.php b/config/sandstorm_theme.php new file mode 100644 index 00000000..3229c61d --- /dev/null +++ b/config/sandstorm_theme.php @@ -0,0 +1,21 @@ + diff --git a/config/slashdot_theme.php b/config/slashdot_theme.php new file mode 100644 index 00000000..50122c5e --- /dev/null +++ b/config/slashdot_theme.php @@ -0,0 +1,22 @@ + \ No newline at end of file diff --git a/data/default_pref b/data/default_pref index b657b223..cc40cad8 100644 --- a/data/default_pref +++ b/data/default_pref @@ -1,2 +1,3 @@ -full_name=Luke Ehresman +full_name= reply_to= +chosen_theme=../config/default_theme.php diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index dfc852de..ba3b61b8 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -32,7 +32,7 @@ /** ** This function loops through a group of messages in the mailbox and shows them **/ - function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort) { + function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color) { include ("../config/config.php"); if (1 <= $numMessages) { diff --git a/functions/mime.php b/functions/mime.php index f81d08f0..3403e072 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -116,8 +116,7 @@ as the actual message in the HTML. It contains everything needed, including HTML Tags, Attachments at the bottom, etc. **/ - function formatBody($message) { - include ("../config/config.php"); + function formatBody($message, $color) { /** this if statement checks for the entity to show as the primary message. To add more of them, just put them in the order that is their priority. @@ -130,17 +129,17 @@ $body .= decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); } else if (containsType($message, "text", "plain", $ent_num)) { $tmpbody = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); - $body .= "" . nl2br($tmpbody) . ""; + $body .= "" . nl2br(trim($tmpbody)) . ""; } // add other primary displaying message types here else { // find any type that's displayable if (containsType($message, "text", "any_type", $ent_num)) { $tmpbody = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); - $body .= "" . nl2br($tmpbody) . ""; + $body .= "" . nl2br(trim($tmpbody)) . ""; } else if (containsType($message, "message", "any_type", $ent_num)) { $tmpbody = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); - $body .= "" . nl2br($tmpbody) . ""; + $body .= "" . nl2br(trim($tmpbody)) . ""; } } diff --git a/functions/prefs.php b/functions/prefs.php index 7253092b..5a2a89d4 100644 --- a/functions/prefs.php +++ b/functions/prefs.php @@ -15,7 +15,7 @@ $pref = fgets($file, 1024); if (substr($pref, 0, strpos($pref, "=")) == $string) { fclose($file); - return substr($pref, strpos($pref, "=")+1); + return trim(substr($pref, strpos($pref, "=")+1)); } } fclose($file); diff --git a/functions/smtp.php b/functions/smtp.php index 9d985d15..6a2e2ff5 100644 --- a/functions/smtp.php +++ b/functions/smtp.php @@ -18,63 +18,76 @@ function sendMessage($smtpServerAddress, $smtpPort, $username, $domain, $t, $c, $b, $subject, $body, $version) { include("../config/config.php"); + include("../functions/prefs.php"); $to = parseAddrs($t); $cc = parseAddrs($c); $bcc = parseAddrs($b); $body = stripslashes($body); - $from = "$username@$domain"; + $from_addr = "$username@$domain"; + $reply_to = getPref($username, "reply_to"); + $from = getPref($username, "full_name"); + if ($from == "") + $from = "<$username@$domain>"; + else + $from = $from . " <$username@$domain>"; + - echo ""; $smtpConnection = fsockopen($smtpServerAddress, $smtpPort, $errorNumber, $errorString); if (!$smtpConnection) { echo "Error connecting to SMTP Server.
"; echo "$errorNumber : $errorString
"; exit; - } else { - $tmp = fgets($smtpConnection, 1024); } + $tmp = nl2br(htmlspecialchars(fgets($smtpConnection, 1024))); $to_list = getLineOfAddrs($to); $cc_list = getLineOfAddrs($cc); /** Lets introduce ourselves */ fputs($smtpConnection, "HELO $domain\n"); + $tmp = nl2br(htmlspecialchars(fgets($smtpConnection, 1024))); /** Ok, who is sending the message? */ - fputs($smtpConnection, "MAIL FROM:<$from>\n"); + fputs($smtpConnection, "MAIL FROM:$from_addr\n"); + $tmp = nl2br(htmlspecialchars(fgets($smtpConnection, 1024))); /** send who the recipients are */ for ($i = 0; $i < count($to); $i++) { fputs($smtpConnection, "RCPT TO:<$to[$i]>\n"); + $tmp = nl2br(htmlspecialchars(fgets($smtpConnection, 1024))); } for ($i = 0; $i < count($cc); $i++) { fputs($smtpConnection, "RCPT TO:<$cc[$i]>\n"); + $tmp = nl2br(htmlspecialchars(fgets($smtpConnection, 1024))); } for ($i = 0; $i < count($bcc); $i++) { fputs($smtpConnection, "RCPT TO:<$bcc[$i]>\n"); + $tmp = nl2br(htmlspecialchars(fgets($smtpConnection, 1024))); } /** Lets start sending the actual message */ fputs($smtpConnection, "DATA\n"); + $tmp = nl2br(htmlspecialchars(fgets($smtpConnection, 1024))); fputs($smtpConnection, "Subject: $subject\n"); // Subject - fputs($smtpConnection, "From: <$from>\n"); // Subject + fputs($smtpConnection, "From: $from\n"); // Subject fputs($smtpConnection, "To: <$to_list>\n"); // Who it's TO if ($cc_list) { fputs($smtpConnection, "Cc: <$cc_list>\n"); // Who the CCs are } fputs($smtpConnection, "X-Mailer: SquirrelMail (version $version)\n"); // Identify SquirrelMail - fputs($smtpConnection, "Reply-To: $from\n"); + fputs($smtpConnection, "Reply-To: $reply_to\n"); fputs($smtpConnection, "MIME-Version: 1.0\n"); fputs($smtpConnection, "Content-Type: text/plain\n"); fputs($smtpConnection, "$body\n"); // send the body of the message fputs($smtpConnection, ".\n"); // end the DATA part + $tmp = nl2br(htmlspecialchars(fgets($smtpConnection, 1024))); + fputs($smtpConnection, "QUIT\n"); // log off - echo "
"; fclose($smtpConnection); } diff --git a/functions/strings.php b/functions/strings.php index 5afc65f5..38c8e7b0 100644 --- a/functions/strings.php +++ b/functions/strings.php @@ -86,5 +86,5 @@ } /* SquirrelMail version number -- DO NOT CHANGE */ - $version = "0.2.1"; + $version = "0.3pre1"; ?> diff --git a/src/compose.php b/src/compose.php index 1f26644b..ec97c741 100644 --- a/src/compose.php +++ b/src/compose.php @@ -7,6 +7,7 @@ include("../functions/date.php"); include("../functions/mime.php"); + include("../src/load_prefs.php"); echo "\n"; $imapConnection = loginToImapServer($username, $key, $imapServerAddress); diff --git a/src/compose_send.php b/src/compose_send.php index 9bbc254b..6bc1c75f 100644 --- a/src/compose_send.php +++ b/src/compose_send.php @@ -7,6 +7,8 @@ include("../functions/smtp.php"); include("../functions/display_messages.php"); + include("../src/load_prefs.php"); + if ($passed_body == "") { echo "\n"; displayPageHeader($color, "None"); diff --git a/src/delete_message.php b/src/delete_message.php index 5381264c..b7b87862 100644 --- a/src/delete_message.php +++ b/src/delete_message.php @@ -6,6 +6,8 @@ include("../functions/display_messages.php"); include("../functions/imap.php"); + include("../src/load_prefs.php"); + echo "\n"; $imapConnection = loginToImapServer($username, $key, $imapServerAddress); diff --git a/src/download.php b/src/download.php index 094dc04e..ce491fcf 100644 --- a/src/download.php +++ b/src/download.php @@ -7,6 +7,8 @@ include("../functions/mailbox.php"); include("../functions/date.php"); + include("../src/load_prefs.php"); + function viewText($color, $body, $id, $entid, $mailbox) { echo "\n"; displayPageHeader($color, "None"); @@ -16,7 +18,7 @@ echo ""; $urlmailbox = urlencode($mailbox); echo "
Download this as a file


"; - echo nl2br($body); + echo nl2br(trim($body)); echo ""; } @@ -41,7 +43,7 @@ $body = decodeBody($message["ENTITIES"][$passed_ent_id]["BODY"], $message["ENTITIES"][$passed_ent_id]["ENCODING"]); header("Content-type: $type0/$type1; name=\"$filename\""); header("Content-Disposition: attachment; filename=\"$filename\""); - echo $body; + echo trim($body); break; default: $body = decodeBody($message["ENTITIES"][$passed_ent_id]["BODY"], $message["ENTITIES"][$passed_ent_id]["ENCODING"]); diff --git a/src/empty_trash.php b/src/empty_trash.php index 3de63073..e4d230fe 100644 --- a/src/empty_trash.php +++ b/src/empty_trash.php @@ -7,6 +7,8 @@ include("../functions/imap.php"); include("../functions/array.php"); + include("../src/load_prefs.php"); + $imapConnection = loginToImapServer($username, $key, $imapServerAddress); getFolderList($imapConnection, $boxes); diff --git a/src/folders.php b/src/folders.php index e67e73fe..c3302899 100644 --- a/src/folders.php +++ b/src/folders.php @@ -6,6 +6,8 @@ include("../functions/mailbox.php"); include("../functions/array.php"); + include("../src/load_prefs.php"); + echo "\n"; displayPageHeader($color, "None"); diff --git a/src/folders_create.php b/src/folders_create.php index b34a5332..335aaeb2 100644 --- a/src/folders_create.php +++ b/src/folders_create.php @@ -6,6 +6,8 @@ include("../functions/imap.php"); include("../functions/display_messages.php"); + include("../src/load_prefs.php"); + echo "\n"; displayPageHeader($color, "None"); diff --git a/src/folders_delete.php b/src/folders_delete.php index 7b635a35..e0c08d0c 100644 --- a/src/folders_delete.php +++ b/src/folders_delete.php @@ -6,6 +6,8 @@ include("../functions/mailbox.php"); include("../functions/array.php"); + include("../src/load_prefs.php"); + echo "\n"; $imapConnection = loginToImapServer($username, $key, $imapServerAddress); getFolderList($imapConnection, $boxes); diff --git a/src/folders_rename_do.php b/src/folders_rename_do.php index b13ff6bd..cd6e399a 100644 --- a/src/folders_rename_do.php +++ b/src/folders_rename_do.php @@ -5,6 +5,8 @@ include("../functions/imap.php"); include("../functions/mailbox.php"); + include("../src/load_prefs.php"); + $imapConnection = loginToImapServer($username, $key, $imapServerAddress); $dm = findMailboxDelimeter($imapConnection); diff --git a/src/folders_rename_getname.php b/src/folders_rename_getname.php index bd78024c..b6461a51 100644 --- a/src/folders_rename_getname.php +++ b/src/folders_rename_getname.php @@ -5,6 +5,8 @@ include("../functions/imap.php"); include("../functions/mailbox.php"); + include("../src/load_prefs.php"); + $imapConnection = loginToImapServer($username, $key, $imapServerAddress); selectMailbox($imapConnection, $old, $numMessages); diff --git a/src/left_main.php b/src/left_main.php index 76da5f30..dea9fd58 100644 --- a/src/left_main.php +++ b/src/left_main.php @@ -20,7 +20,9 @@ include("../functions/imap.php"); include("../functions/mailbox.php"); - function formatMailboxName($imapConnection, $mailbox, $delimeter) { + include("../src/load_prefs.php"); + + function formatMailboxName($imapConnection, $mailbox, $delimeter, $color) { require ("../config/config.php"); $mailboxURL = urlencode($mailbox); @@ -101,10 +103,10 @@ $line .= readShortMailboxName($mailbox, $delimeter); $line .= ""; } else { - $line .= formatMailboxName($imapConnection, $mailbox, $delimeter); + $line .= formatMailboxName($imapConnection, $mailbox, $delimeter, $color); } } else { - $line .= formatMailboxName($imapConnection, $mailbox, $delimeter); + $line .= formatMailboxName($imapConnection, $mailbox, $delimeter, $color); } echo "$line
"; } diff --git a/src/load_prefs.php b/src/load_prefs.php new file mode 100644 index 00000000..97785f6f --- /dev/null +++ b/src/load_prefs.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/src/move_messages.php b/src/move_messages.php index eab4901e..8573b821 100644 --- a/src/move_messages.php +++ b/src/move_messages.php @@ -6,6 +6,8 @@ include("../functions/display_messages.php"); include("../functions/imap.php"); + include("../src/load_prefs.php"); + echo "\n"; function putSelectedMessagesIntoString($msg) { diff --git a/src/options.php b/src/options.php index 34a0bb90..f3aaea39 100644 --- a/src/options.php +++ b/src/options.php @@ -6,7 +6,9 @@ include("../functions/display_messages.php"); include("../functions/imap.php"); include("../functions/array.php"); - include("../functions/prefs.php"); + + include("../src/load_prefs.php"); + echo "\n"; displayPageHeader($color, "None"); @@ -27,7 +29,7 @@ echo "\n"; // FULL NAME echo " "; - echo " "; // REPLY-TO echo " "; - echo " "; echo " "; + // THEME + echo " "; + echo " "; + echo " "; + echo " "; + + echo "\n"; + + // SUBMIT BUTTON echo " "; echo " "; echo " "; echo " "; diff --git a/src/options_submit.php b/src/options_submit.php index 687c9ced..3f128602 100644 --- a/src/options_submit.php +++ b/src/options_submit.php @@ -6,20 +6,20 @@ include("../functions/display_messages.php"); include("../functions/imap.php"); include("../functions/array.php"); - include("../functions/prefs.php"); + + include("../src/load_prefs.php"); echo ""; - if ($auto_forward == true) - echo ""; echo "\n"; displayPageHeader($color, "None"); setPref($username, "full_name", $full_name); setPref($username, "reply_to", $reply_to); + setPref($username, "chosen_theme", $chosentheme); echo ""; echo "


Options Saved!

"; - echo "You will be automatically forwarded.
If not, click here"; + echo "Your options have been saved.
Click here to continue."; echo "
"; echo ""; ?> \ No newline at end of file diff --git a/src/read_body.php b/src/read_body.php index 32fd6ca0..61c31d27 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -7,6 +7,8 @@ include("../functions/mailbox.php"); include("../functions/date.php"); + include("../src/load_prefs.php"); + $imapConnection = loginToImapServer($username, $key, $imapServerAddress); selectMailbox($imapConnection, $mailbox, $numMessages); @@ -144,7 +146,7 @@ echo " "; echo "
"; + echo " "; echo " "; echo " Full Name:"; echo " "; @@ -40,7 +42,7 @@ echo "
"; + echo " "; echo " "; echo " Reply-to:"; echo " "; @@ -51,12 +53,35 @@ echo " "; echo "
"; + echo " "; + echo " Theme:"; + echo " "; + echo " "; + + echo " "; + echo "
"; echo " "; - echo " \n"; + echo "
\n"; echo "
\n"; - $body = formatBody($message); + $body = formatBody($message, $color); echo "
"; echo "$body"; diff --git a/src/right_main.php b/src/right_main.php index 1def94ed..988267b3 100644 --- a/src/right_main.php +++ b/src/right_main.php @@ -29,6 +29,8 @@ include("../functions/mailbox_display.php"); include("../functions/display_messages.php"); + include("../src/load_prefs.php"); + echo "\n"; echo ""; ///////////////////////////////////////////////////////////////////////////////// @@ -65,7 +67,7 @@ displayPageHeader($color, $mailbox); // Get the list of messages for this mailbox - showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort); + showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color); // close the connection fputs($imapConnection, "1 logout\n"); diff --git a/src/signout.php b/src/signout.php index 9936f307..9439d60f 100644 --- a/src/signout.php +++ b/src/signout.php @@ -17,6 +17,8 @@ \n"; echo "

"; echo " "; -- 2.25.1