Code Cleaning
authorphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 23 Jan 2002 18:12:37 +0000 (18:12 +0000)
committerphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 23 Jan 2002 18:12:37 +0000 (18:12 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2221 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/imap_mailbox.php
functions/tree.php
src/delete_message.php
src/download.php
src/empty_trash.php
src/move_messages.php
src/vcard.php
src/webmail.php

index 746a438bb5029098cc0d2a4bb9b1104a3411da3e..375b97bfee4262691b5e23d3750cf131d60af45e 100755 (executable)
@@ -43,8 +43,7 @@ function isBoxBelow( $box2, $box1 ) {
 function isSpecialMailbox( $box ) {
 
     global $trash_folder, $sent_folder, $draft_folder,
-           $move_to_trash, $move_to_sent, $save_as_draft,
-           $delimiter, $folder_prefix, $imap_server_type;
+           $move_to_trash, $move_to_sent, $save_as_draft;
 
     $ret = ( (strtolower($box) == 'inbox') ||
              ( $move_to_trash && isBoxBelow( $box, $trash_folder ) ) ||
@@ -357,13 +356,13 @@ function user_strcasecmp($a, $b) {
  **  See comment on sqimap_mailbox_parse() for info about the returned array.
  ******************************************************************************/
 function sqimap_mailbox_list ($imap_stream) {
+
     global $data_dir, $username, $list_special_folders_first,
            $folder_prefix, $trash_folder, $sent_folder, $draft_folder,
            $move_to_trash, $move_to_sent, $save_as_draft,
            $delimiter;
 
-    $inbox_in_list = false;
-    $inbox_subscribed = false;
+    $inbox_in_list = $inbox_subscribed = FALSE;
 
     require_once('../src/load_prefs.php');
     require_once('../functions/array.php');
@@ -495,6 +494,7 @@ function sqimap_mailbox_list ($imap_stream) {
     }
 
     return( $boxesnew );
+
 }
 
 /*
@@ -505,9 +505,7 @@ function sqimap_mailbox_list_all ($imap_stream)
     global $list_special_folders_first, $folder_prefix;
     global $delimiter;
 
-    if (!function_exists('ary_sort')) {
-        include_once('../functions/array.php');
-    }
+    require_once('../functions/array.php');
 
     $ssid = sqimap_session_id();
     $lsid = strlen( $ssid );
@@ -529,7 +527,7 @@ function sqimap_mailbox_list_all ($imap_stream)
         if (substr($read_ary[$i], 0, $lsid) != $ssid ) {
 
             /* Store the raw IMAP reply */
-            $boxes[$g]["raw"] = $read_ary[$i];
+            $boxes[$g]['raw'] = $read_ary[$i];
 
             /* Count number of delimiters ($delimiter) in folder name */
             $mailbox = find_mailbox_name($read_ary[$i]);
index 5d9657943c8db0cc2e1955194da26d71f56ae00c..e9de9f00893502092d39f8a42797a3060298b97d 100644 (file)
  * $Id$
  */
 
-/*****************************************************************/
-/*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!!           ***/
-/*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION.             ***/
-/***    + Base level indent should begin at left margin, as    ***/
-/***      the require_once below.                              ***/
-/***    + All identation should consist of four space blocks   ***/
-/***    + Tab characters are evil.                             ***/
-/***    + all comments should use "slash-star ... star-slash"  ***/
-/***      style -- no pound characters, no slash-slash style   ***/
-/***    + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD      ***/
-/***      ALWAYS USE { AND } CHARACTERS!!!                     ***/
-/***    + Please use ' instead of ", when possible. Note "     ***/
-/***      should always be used in _( ) function calls.        ***/
-/*** Thank you for your help making the SM code more readable. ***/
-/*****************************************************************/
-
 require_once('../functions/imap.php');
 
 /**
@@ -36,121 +20,121 @@ require_once('../functions/imap.php');
  * Recursive function to find the correct parent for a new node
  */
 
-   function findParentForChild($value, $treeIndexToStart, $tree) {
-      // is $value in $tree[$treeIndexToStart]['value']
-      if ((isset($tree[$treeIndexToStart])) && (strstr($value, $tree[$treeIndexToStart]['value']))) {
-         // do I have children, if not then must be a childnode of the current node
-         if ($tree[$treeIndexToStart]['doIHaveChildren']) {
+function findParentForChild($value, $treeIndexToStart, $tree) {
+    // is $value in $tree[$treeIndexToStart]['value']
+    if ((isset($tree[$treeIndexToStart])) && (strstr($value, $tree[$treeIndexToStart]['value']))) {
+        // do I have children, if not then must be a childnode of the current node
+        if ($tree[$treeIndexToStart]['doIHaveChildren']) {
             // loop through each subNode checking to see if we are a subNode of one of them
             for ($i=0;$i< count($tree[$treeIndexToStart]['subNodes']);$i++) {
-               $result = findParentForChild($value, $tree[$treeIndexToStart]['subNodes'][$i], $tree);
-               if ($result > -1)
-                  return $result;
+            $result = findParentForChild($value, $tree[$treeIndexToStart]['subNodes'][$i], $tree);
+            if ($result > -1)
+                return $result;
             }
             // if we aren't a child of one of the subNodes, must be a child of current node
             return $treeIndexToStart;
-         } else
+        } else
             return $treeIndexToStart;
-      } else {
-         // we aren't a child of this node at all
-         return -1;
-      }
-   }  
-
-   function addChildNodeToTree($comparisonValue, $value, &$tree) {
-      $parentNode = findParentForChild($comparisonValue, 0, $tree);
-
-      // create a new subNode
-      $newNodeIndex = count($tree);
-      $tree[$newNodeIndex]['value'] = $value;
-      $tree[$newNodeIndex]['doIHaveChildren'] = false;
-
-      if ($tree[$parentNode]['doIHaveChildren'] == false) {
-         // make sure the parent knows it has children
-         $tree[$parentNode]['subNodes'][0] = $newNodeIndex;
-         $tree[$parentNode]['doIHaveChildren'] = true;
-      } else {
-         $nextSubNode = count($tree[$parentNode]['subNodes']);
-         // make sure the parent knows it has children
-         $tree[$parentNode]['subNodes'][$nextSubNode] = $newNodeIndex;
-      }
-   }
-
-   function walkTreeInPreOrderEmptyTrash($index, $imap_stream, $tree) {
-      global $trash_folder;
-      if ($tree[$index]['doIHaveChildren']) {
-         for ($j = 0; $j < count($tree[$index]['subNodes']); $j++) {
+    } else {
+        // we aren't a child of this node at all
+        return -1;
+    }
+}
+
+function addChildNodeToTree($comparisonValue, $value, &$tree) {
+    $parentNode = findParentForChild($comparisonValue, 0, $tree);
+
+    // create a new subNode
+    $newNodeIndex = count($tree);
+    $tree[$newNodeIndex]['value'] = $value;
+    $tree[$newNodeIndex]['doIHaveChildren'] = false;
+
+    if ($tree[$parentNode]['doIHaveChildren'] == false) {
+        // make sure the parent knows it has children
+        $tree[$parentNode]['subNodes'][0] = $newNodeIndex;
+        $tree[$parentNode]['doIHaveChildren'] = true;
+    } else {
+        $nextSubNode = count($tree[$parentNode]['subNodes']);
+        // make sure the parent knows it has children
+        $tree[$parentNode]['subNodes'][$nextSubNode] = $newNodeIndex;
+    }
+}
+
+function walkTreeInPreOrderEmptyTrash($index, $imap_stream, $tree) {
+    global $trash_folder;
+    if ($tree[$index]['doIHaveChildren']) {
+        for ($j = 0; $j < count($tree[$index]['subNodes']); $j++) {
             walkTreeInPreOrderEmptyTrash($tree[$index]['subNodes'][$j], $imap_stream, $tree);
-         }
-         if ($tree[$index]['value'] != $trash_folder) {
+        }
+        if ($tree[$index]['value'] != $trash_folder) {
             sqimap_mailbox_delete($imap_stream, $tree[$index]['value']);
-         } else {
+        } else {
             $numMessages = sqimap_get_num_messages($imap_stream, $trash_folder);
             if ($numMessages > 0) {
-               sqimap_mailbox_select($imap_stream, $trash_folder);
-               sqimap_messages_flag ($imap_stream, 1, $numMessages, 'Deleted');
-               sqimap_mailbox_expunge($imap_stream, $trash_folder, true);
+            sqimap_mailbox_select($imap_stream, $trash_folder);
+            sqimap_messages_flag ($imap_stream, 1, $numMessages, 'Deleted');
+            sqimap_mailbox_expunge($imap_stream, $trash_folder, true);
             }
-         }
-      } else {
-         if ($tree[$index]['value'] != $trash_folder) {
+        }
+    } else {
+        if ($tree[$index]['value'] != $trash_folder) {
             sqimap_mailbox_delete($imap_stream, $tree[$index]['value']);
-         } else {
+        } else {
             $numMessages = sqimap_get_num_messages($imap_stream, $trash_folder);
             if ($numMessages > 0) {
-               sqimap_mailbox_select($imap_stream, $trash_folder);
-               sqimap_messages_flag ($imap_stream, 1, $numMessages, 'Deleted');
-               sqimap_mailbox_expunge($imap_stream, $trash_folder, true);
+            sqimap_mailbox_select($imap_stream, $trash_folder);
+            sqimap_messages_flag ($imap_stream, 1, $numMessages, 'Deleted');
+            sqimap_mailbox_expunge($imap_stream, $trash_folder, true);
             }
-         }
-      }
-   }
-   
-   function walkTreeInPreOrderDeleteFolders($index, $imap_stream, $tree) {
-      if ($tree[$index]['doIHaveChildren']) {
-         for ($j = 0; $j < count($tree[$index]['subNodes']); $j++) {
+        }
+    }
+}
+
+function walkTreeInPreOrderDeleteFolders($index, $imap_stream, $tree) {
+    if ($tree[$index]['doIHaveChildren']) {
+        for ($j = 0; $j < count($tree[$index]['subNodes']); $j++) {
             walkTreeInPreOrderDeleteFolders($tree[$index]['subNodes'][$j], $imap_stream, $tree);
-         }
-         sqimap_mailbox_delete($imap_stream, $tree[$index]['value']);
-      } else {
-         sqimap_mailbox_delete($imap_stream, $tree[$index]['value']);
-      }
-   }
-
-   function walkTreeInPostOrderCreatingFoldersUnderTrash($index, $imap_stream, $tree, $topFolderName) {
-      global $trash_folder, $delimiter;
-
-      $position = strrpos($topFolderName, $delimiter) + 1;
-      $subFolderName = substr($tree[$index]['value'], $position);
-
-      if ($tree[$index]['doIHaveChildren']) {
-         sqimap_mailbox_create($imap_stream, $trash_folder . $delimiter . $subFolderName, "");
-         sqimap_mailbox_select($imap_stream, $tree[$index]['value']);
-        
-         $messageCount = sqimap_get_num_messages($imap_stream, $tree[$index]['value']);
-         if ($messageCount > 0)
+        }
+        sqimap_mailbox_delete($imap_stream, $tree[$index]['value']);
+    } else {
+        sqimap_mailbox_delete($imap_stream, $tree[$index]['value']);
+    }
+}
+
+function walkTreeInPostOrderCreatingFoldersUnderTrash($index, $imap_stream, $tree, $topFolderName) {
+    global $trash_folder, $delimiter;
+
+    $position = strrpos($topFolderName, $delimiter) + 1;
+    $subFolderName = substr($tree[$index]['value'], $position);
+
+    if ($tree[$index]['doIHaveChildren']) {
+        sqimap_mailbox_create($imap_stream, $trash_folder . $delimiter . $subFolderName, "");
+        sqimap_mailbox_select($imap_stream, $tree[$index]['value']);
+
+        $messageCount = sqimap_get_num_messages($imap_stream, $tree[$index]['value']);
+        if ($messageCount > 0)
             sqimap_messages_copy($imap_stream, 1, $messageCount, $trash_folder . $delimiter . $subFolderName);
-         
-         for ($j = 0;$j < count($tree[$index]['subNodes']); $j++)
+
+        for ($j = 0;$j < count($tree[$index]['subNodes']); $j++)
             walkTreeInPostOrderCreatingFoldersUnderTrash($tree[$index]['subNodes'][$j], $imap_stream, $tree, $topFolderName);
-      } else {
-         sqimap_mailbox_create($imap_stream, $trash_folder . $delimiter . $subFolderName, '');
-         sqimap_mailbox_select($imap_stream, $tree[$index]['value']);
-         
-         $messageCount = sqimap_get_num_messages($imap_stream, $tree[$index]['value']);
-         if ($messageCount > 0)
+    } else {
+        sqimap_mailbox_create($imap_stream, $trash_folder . $delimiter . $subFolderName, '');
+        sqimap_mailbox_select($imap_stream, $tree[$index]['value']);
+
+        $messageCount = sqimap_get_num_messages($imap_stream, $tree[$index]['value']);
+        if ($messageCount > 0)
             sqimap_messages_copy($imap_stream, 1, $messageCount, $trash_folder . $delimiter . $subFolderName);
-      }
-   }
+    }
+}
 
-   function simpleWalkTreePre($index, $tree) {
-      if ($tree[$index]['doIHaveChildren']) {
-         for ($j = 0; $j < count($tree[$index]['subNodes']); $j++) {
+function simpleWalkTreePre($index, $tree) {
+    if ($tree[$index]['doIHaveChildren']) {
+        for ($j = 0; $j < count($tree[$index]['subNodes']); $j++) {
             simpleWalkTreePre($tree[$index]['subNodes'][$j], $tree);
-         }
-         echo $tree[$index]['value'] . '<br>';
-      } else {
-         echo $tree[$index]['value'] . '<br>';
-      }
-   }
+        }
+        echo $tree[$index]['value'] . '<br>';
+    } else {
+        echo $tree[$index]['value'] . '<br>';
+    }
+}
 ?>
index ba73607edbbe4aaec85bb7183bcbb13d60502698..18629228eab559a096b56fa4b444b1447a9885a2 100644 (file)
@@ -6,44 +6,32 @@
  * Copyright (c) 1999-2002 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
- * Deletes a meesage from the IMAP server 
+ * Deletes a meesage from the IMAP server
  *
  * $Id$
  */
 
-/*****************************************************************/
-/*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!!           ***/
-/*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION.             ***/
-/***    + Base level indent should begin at left margin, as    ***/
-/***      the require_once below looks.                        ***/
-/***    + All identation should consist of four space blocks   ***/
-/***    + Tab characters are evil.                             ***/
-/***    + all comments should use "slash-star ... star-slash"  ***/
-/***      style -- no pound characters, no slash-slash style   ***/
-/***    + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD      ***/
-/***      ALWAYS USE { AND } CHARACTERS!!!                     ***/
-/***    + Please use ' instead of ", when possible. Note "     ***/
-/***      should always be used in _( ) function calls.        ***/
-/*** Thank you for your help making the SM code more readable. ***/
-/*****************************************************************/
-
 require_once('../src/validate.php');
 require_once('../functions/display_messages.php');
 require_once('../functions/imap.php');
 
-   $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+
+sqimap_mailbox_select($imapConnection, $mailbox);
 
-   sqimap_mailbox_select($imapConnection, $mailbox);
-   
-   sqimap_messages_delete($imapConnection, $message, $message, $mailbox);
-   if ($auto_expunge)
-      sqimap_mailbox_expunge($imapConnection, $mailbox, true);
+sqimap_messages_delete($imapConnection, $message, $message, $mailbox);
+if ($auto_expunge) {
+    sqimap_mailbox_expunge($imapConnection, $mailbox, true);
+}
 
-   $location = get_location();
-   if (isset($where) && isset($what))
-      header ("Location: $location/search.php?where=".urlencode($where)."&what=".urlencode($what)."&mailbox=".urlencode($mailbox));
-   else   
-      header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=".urlencode($mailbox));
+$location = get_location();
+if (isset($where) && isset($what)) {
+    header("Location: $location/search.php?where=" . urlencode($where) .
+           '&what=' . urlencode($what) . '&mailbox=' . urlencode($mailbox));
+} else {
+    header("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=" .
+           urlencode($mailbox));
+}
 
-   sqimap_logout($imapConnection);
+sqimap_logout($imapConnection);
 ?>
index abbadcbd3ec72d5cdf00a518ed4922586c4cd7be..d78999d1b11ce6793eac99a6c7cfa08c275753fb 100644 (file)
  * $Id$
  */
 
-/*****************************************************************/
-/*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!!           ***/
-/*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION.             ***/
-/***    + Base level indent should begin at left margin, as    ***/
-/***      the require_once below looks.                        ***/
-/***    + All identation should consist of four space blocks   ***/
-/***    + Tab characters are evil.                             ***/
-/***    + all comments should use "slash-star ... star-slash"  ***/
-/***      style -- no pound characters, no slash-slash style   ***/
-/***    + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD      ***/
-/***      ALWAYS USE { AND } CHARACTERS!!!                     ***/
-/***    + Please use ' instead of ", when possible. Note "     ***/
-/***      should always be used in _( ) function calls.        ***/
-/*** Thank you for your help making the SM code more readable. ***/
-/*****************************************************************/
-
-define('download_php', true);  // Used for preferences
-
 require_once('../src/validate.php');
 require_once('../functions/imap.php');
 require_once('../functions/mime.php');
 require_once('../functions/date.php');
 
-   header("Pragma: ");
-   header("Cache-Control: cache");
-
-   function viewText($color, $body, $id, $entid, $mailbox, $type1, $wrap_at) {
-      global $where, $what, $charset;
-      global $startMessage;
-      
-      displayPageHeader($color, 'None');
-
-      echo "<BR><TABLE WIDTH=\"100%\" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">";
-      echo "<B><CENTER>";
-      echo _("Viewing a text attachment") . " - ";
-      if ($where && $what) {
-         // from a search
-         echo "<a href=\"read_body.php?mailbox=".urlencode($mailbox)."&passed_id=$id&where=".urlencode($where)."&what=".urlencode($what)."\">". _("View message") . "</a>";
-      } else {   
-         echo "<a href=\"read_body.php?mailbox=".urlencode($mailbox)."&passed_id=$id&startMessage=$startMessage&show_more=0\">". _("View message") . "</a>";
-      }   
-
-      $urlmailbox = urlencode($mailbox);
-      echo "</b></td><tr><tr><td><CENTER><A HREF=\"../src/download.php?absolute_dl=true&passed_id=$id&passed_ent_id=$entid&mailbox=$urlmailbox\">";
-      echo _("Download this as a file");
-      echo "</A></CENTER><BR>";
-      echo "</CENTER></B>";
-      echo "</TD></TR></TABLE>";
-
-      echo "<TABLE WIDTH=\"98%\" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">";
-      echo "<TR><TD BGCOLOR=\"$color[4]\"><TT>";
-
-      if ($type1 == 'html') {
-         $body = MagicHTML( $body, $id );
-      } else {
-         translateText($body, $wrap_at, $charset);
-      }
-      
-      flush();
-      echo $body;
-
-      echo "</TT></TD></TR></TABLE>";
-   }
-
-   $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
-   sqimap_mailbox_select($imapConnection, $mailbox);
-
-   // $message contains all information about the message
-   // including header and body
-   $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
-   $top_header = $message->header;
-
-   // lets redefine message as this particular entity that we wish to display.
-   // it should hold only the header for this entity.  We need to fetch the body
-   // yet before we can display anything.
-   $message = getEntity($message, $passed_ent_id);
-
-   $header = $message->header;
-
-   $charset = $header->charset;
-   $type0 = $header->type0;
-   $type1 = $header->type1;
-   if (isset($override_type0))
-       $type0 = $override_type0;
-   if (isset($override_type1))
-       $type1 = $override_type1;
-   $filename = decodeHeader($header->filename);
-   if (!$filename) {
-      $filename = decodeHeader($header->name);
-   }
-
-   if (strlen($filename) < 1) {
-      if ($type1 == 'plain' && $type0 == 'text') {
-          $suffix = 'txt';
-      } else if ($type1 == 'richtext' && $type0 == 'text') {
-          $suffix = 'rtf';
-      } else if ($type1 == 'postscript' && $type0 == 'application') {
-          $suffix = 'ps';
-      } else if ($type1 == 'message' && $type0 == 'rfc822') {
-          $suffix = 'msg';
-      } else {
-          $suffix = $type1;
-      }
-
-      $filename = "untitled$passed_ent_id.$suffix";
-   }
-
-   // Note:
-   //    The following sections display the attachment in different
-   //    ways depending on how they choose.  The first way will download
-   //    under any circumstance.  This sets the Content-type to be
-   //    applicatin/octet-stream, which should be interpreted by the
-   //    browser as "download me".
-   //      The second method (view) is used for images or other formats
-   //    that should be able to be handled by the browser.  It will
-   //    most likely display the attachment inline inside the browser.
-   //      And finally, the third one will be used by default.  If it
-   //    is displayable (text or html), it will load them up in a text
-   //    viewer (built in to squirrelmail).  Otherwise, it sets the
-   //    content-type as application/octet-stream
-   
-   if (isset($absolute_dl) && $absolute_dl == "true") {
-      switch($type0) {
-         case "text":
-           DumpHeaders($type0, $type1, $filename, 1);
+header('Pragma: ');
+header('Cache-Control: cache');
+
+function viewText($color, $body, $id, $entid, $mailbox, $type1, $wrap_at) {
+    global $where, $what, $charset;
+    global $startMessage;
+
+    displayPageHeader($color, 'None');
+
+    echo "<BR><TABLE WIDTH=\"100%\" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">".
+         "<B><CENTER>".
+         _("Viewing a text attachment") . " - ";
+    if ($where && $what) {
+        // from a search
+        echo "<a href=\"read_body.php?mailbox=".urlencode($mailbox)."&passed_id=$id&where=".urlencode($where)."&what=".urlencode($what)."\">". _("View message") . "</a>";
+    } else {
+        echo "<a href=\"read_body.php?mailbox=".urlencode($mailbox)."&passed_id=$id&startMessage=$startMessage&show_more=0\">". _("View message") . "</a>";
+    }
+
+    $urlmailbox = urlencode($mailbox);
+    echo "</b></td><tr><tr><td><CENTER><A HREF=\"../src/download.php?absolute_dl=true&passed_id=$id&passed_ent_id=$entid&mailbox=$urlmailbox\">".
+         _("Download this as a file").
+         "</A></CENTER><BR>".
+         "</CENTER></B>".
+         "</TD></TR></TABLE>".
+         "<TABLE WIDTH=\"98%\" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">".
+         "<TR><TD BGCOLOR=\"$color[4]\"><TT>";
+
+    if ($type1 == 'html') {
+        $body = MagicHTML( $body, $id );
+    } else {
+        translateText($body, $wrap_at, $charset);
+    }
+
+    flush();
+    echo $body .
+         "</TT></TD></TR></TABLE>";
+}
+
+$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+sqimap_mailbox_select($imapConnection, $mailbox);
+
+/*
+ * $message contains all information about the message
+ * including header and body
+ */
+$message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
+$top_header = $message->header;
+
+/*
+ * lets redefine message as this particular entity that we wish to display.
+ * it should hold only the header for this entity.  We need to fetch the body
+ * yet before we can display anything.
+ */
+$message = getEntity($message, $passed_ent_id);
+
+$header = $message->header;
+
+$charset = $header->charset;
+$type0 = $header->type0;
+$type1 = $header->type1;
+if (isset($override_type0)) {
+    $type0 = $override_type0;
+}
+if (isset($override_type1)) {
+    $type1 = $override_type1;
+}
+$filename = decodeHeader($header->filename);
+if (!$filename) {
+    $filename = decodeHeader($header->name);
+}
+
+if (strlen($filename) < 1) {
+    if ($type1 == 'plain' && $type0 == 'text') {
+        $suffix = 'txt';
+    } else if ($type1 == 'richtext' && $type0 == 'text') {
+        $suffix = 'rtf';
+    } else if ($type1 == 'postscript' && $type0 == 'application') {
+        $suffix = 'ps';
+    } else if ($type1 == 'message' && $type0 == 'rfc822') {
+        $suffix = 'msg';
+    } else {
+        $suffix = $type1;
+    }
+
+    $filename = "untitled$passed_ent_id.$suffix";
+}
+
+/*
+ * Note:
+ *    The following sections display the attachment in different
+ *    ways depending on how they choose.  The first way will download
+ *    under any circumstance.  This sets the Content-type to be
+ *    applicatin/octet-stream, which should be interpreted by the
+ *    browser as "download me".
+ *      The second method (view) is used for images or other formats
+ *    that should be able to be handled by the browser.  It will
+ *    most likely display the attachment inline inside the browser.
+ *      And finally, the third one will be used by default.  If it
+ *    is displayable (text or html), it will load them up in a text
+ *    viewer (built in to squirrelmail).  Otherwise, it sets the
+ *    content-type as application/octet-stream
+ */
+if (isset($absolute_dl) && $absolute_dl == 'true') {
+    switch($type0) {
+    case 'text':
+        DumpHeaders($type0, $type1, $filename, 1);
+        $body = mime_fetch_body($imapConnection, $passed_id, $passed_ent_id);
+        $body = decodeBody($body, $header->encoding);
+        if ($type1 == 'plain' && isset($showHeaders)) {
+            echo _("Subject") . ": " . decodeHeader($top_header->subject) . "\n".
+                 "   " . _("From") . ": " . decodeHeader($top_header->from) . "\n".
+                 "     " . _("To") . ": " . decodeHeader(getLineOfAddrs($top_header->to)) . "\n".
+                 "   " . _("Date") . ": " . getLongDateString($top_header->date) . "\n\n";
+        } elseif ($type1 == 'html' && isset($showHeaders)) {
+            echo '<table><tr><th align=right>' . _("Subject").
+                 ':</th><td>' . decodeHeader($top_header->subject).
+                 "</td></tr>\n<tr><th align=right>" . _("From").
+                 ':</th><td>' . decodeHeader($top_header->from).
+                 "</td></tr>\n<tr><th align=right>" . _("To").
+                 ':</th><td>' . decodeHeader(getLineOfAddrs($top_header->to)).
+                 "</td></tr>\n<tr><th align=right>" . _("Date").
+                 ':</th><td>' . getLongDateString($top_header->date).
+                 "</td></tr>\n</table>\n<hr>\n";
+        }
+        echo $body;
+        break;
+    default:
+        DumpHeaders($type0, $type1, $filename, 1);
+        mime_print_body_lines ($imapConnection, $passed_id, $passed_ent_id, $header->encoding);
+        break;
+    }
+} else {
+    switch ($type0) {
+    case 'text':
+        if ($type1 == 'plain' || $type1 == 'html') {
             $body = mime_fetch_body($imapConnection, $passed_id, $passed_ent_id);
             $body = decodeBody($body, $header->encoding);
-            if ($type1 == "plain" && isset($showHeaders)) {
-               echo _("Subject") . ": " . decodeHeader($top_header->subject) . "\n";
-               echo "   " . _("From") . ": " . decodeHeader($top_header->from) . "\n";
-               echo "     " . _("To") . ": " . decodeHeader(getLineOfAddrs($top_header->to)) . "\n";
-               echo "   " . _("Date") . ": " . getLongDateString($top_header->date) . "\n\n";
-            }
-           elseif ($type1 == "html" && isset($showHeaders)) {
-              echo '<table><tr><th align=right>' . _("Subject");
-              echo ':</th><td>' . decodeHeader($top_header->subject);
-              echo "</td></tr>\n<tr><th align=right>" . _("From");
-              echo ':</th><td>' . decodeHeader($top_header->from);
-              echo "</td></tr>\n<tr><th align=right>" . _("To");
-              echo ':</th><td>' . decodeHeader(getLineOfAddrs($top_header->to));
-              echo "</td></tr>\n<tr><th align=right>" . _("Date");
-              echo ':</th><td>' . getLongDateString($top_header->date);
-              echo "</td></tr>\n</table>\n<hr>\n";
-           }
-            echo $body;
-            break;
-         default:
-           DumpHeaders($type0, $type1, $filename, 1);
-            mime_print_body_lines ($imapConnection, $passed_id, $passed_ent_id, $header->encoding);
-            break;
-      }
-   } else {
-      switch ($type0) {
-         case "text":
-            if ($type1 == "plain" || $type1 == "html") {
-                $body = mime_fetch_body($imapConnection, $passed_id, $passed_ent_id);
-                $body = decodeBody($body, $header->encoding);
-                viewText($color, $body, $passed_id, $passed_ent_id, $mailbox, $type1, $wrap_at);
-            } else {
-               DumpHeaders($type0, $type1, $filename, 0);
-                $body = mime_fetch_body($imapConnection, $passed_id, $passed_ent_id);
-                $body = decodeBody($body, $header->encoding);
-                echo $body;
-            }
-            break;
-         case "message":
+            viewText($color, $body, $passed_id, $passed_ent_id, $mailbox, $type1, $wrap_at);
+        } else {
+            DumpHeaders($type0, $type1, $filename, 0);
             $body = mime_fetch_body($imapConnection, $passed_id, $passed_ent_id);
             $body = decodeBody($body, $header->encoding);
-            viewText($color, $body, $passed_id, $passed_ent_id, $mailbox, $type1, $wrap_at);
-            break;
-         default:
-           DumpHeaders($type0, $type1, $filename, 0);
-            mime_print_body_lines ($imapConnection, $passed_id, $passed_ent_id, $header->encoding);
-            break;
-      }
-   }
-   
-   
-   // This function is verified to work with Netscape and the *very latest*
-   // version of IE.  I don't know if it works with Opera, but it should now.
-   function DumpHeaders($type0, $type1, $filename, $force)
-   {
-      global $HTTP_USER_AGENT;
-      
-      $isIE = 0;
-      if (strstr($HTTP_USER_AGENT, 'compatible; MSIE ') !== false &&
-          strstr($HTTP_USER_AGENT, 'Opera') === false) {
+            echo $body;
+        }
+        break;
+    case 'message':
+        $body = mime_fetch_body($imapConnection, $passed_id, $passed_ent_id);
+        $body = decodeBody($body, $header->encoding);
+        viewText($color, $body, $passed_id, $passed_ent_id, $mailbox, $type1, $wrap_at);
+        break;
+    default:
+        DumpHeaders($type0, $type1, $filename, 0);
+        mime_print_body_lines ($imapConnection, $passed_id, $passed_ent_id, $header->encoding);
+        break;
+    }
+}
+
+
+/*
+ * This function is verified to work with Netscape and the *very latest*
+ * version of IE.  I don't know if it works with Opera, but it should now.
+ */
+function DumpHeaders($type0, $type1, $filename, $force) {
+    global $HTTP_USER_AGENT;
+
+    $isIE = 0;
+    if (strstr($HTTP_USER_AGENT, 'compatible; MSIE ') !== false &&
+        strstr($HTTP_USER_AGENT, 'Opera') === false) {
         $isIE = 1;
-      }
-      
-      $filename = ereg_replace('[^-a-zA-Z0-9\.]', '_', $filename);
-      
-      // A Pox on Microsoft and it's Office!
-      if (! $force)
-      {
-          // Try to show in browser window
-          header("Content-Disposition: inline; filename=\"$filename\"");
-         header("Content-Type: $type0/$type1; name=\"$filename\"");
-      }
-      else
-      {
-          // Try to pop up the "save as" box
-         // IE makes this hard.  It pops up 2 save boxes, or none.
-         // http://support.microsoft.com/support/kb/articles/Q238/5/88.ASP
-         // But, accordint to Microsoft, it is "RFC compliant but doesn't
-         // take into account some deviations that allowed within the
-         // specification."  Doesn't that mean RFC non-compliant?
-         // http://support.microsoft.com/support/kb/articles/Q258/4/52.ASP
-         //
-         // The best thing you can do for IE is to upgrade to the latest
-         // version
-          if ($isIE) {
-            // http://support.microsoft.com/support/kb/articles/Q182/3/15.asp
-            // Do not have quotes around filename, but that applied to
-            // "attachment"... does it apply to inline too?
-            //
-            // This combination seems to work mostly.  IE 5.5 SP 1 has
-            // known issues (see the Microsoft Knowledge Base)
-             header("Content-Disposition: inline; filename=$filename");
-             
-            // This works for most types, but doesn't work with Word files
-             header("Content-Type: application/download; name=\"$filename\"");
-
-             // These are spares, just in case.  :-)
-             //header("Content-Type: $type0/$type1; name=\"$filename\"");
-             //header("Content-Type: application/x-msdownload; name=\"$filename\"");
-             //header("Content-Type: application/octet-stream; name=\"$filename\"");
-         } else {
-             header("Content-Disposition: attachment; filename=\"$filename\"");
-            // application/octet-stream forces download for Netscape
-             header("Content-Type: application/octet-stream; name=\"$filename\"");
-         }
-      }
-   }
+    }
+
+    $filename = ereg_replace('[^-a-zA-Z0-9\.]', '_', $filename);
+
+    // A Pox on Microsoft and it's Office!
+    if (! $force) {
+        // Try to show in browser window
+        header("Content-Disposition: inline; filename=\"$filename\"");
+        header("Content-Type: $type0/$type1; name=\"$filename\"");
+    } else {
+        // Try to pop up the "save as" box
+        // IE makes this hard.  It pops up 2 save boxes, or none.
+        // http://support.microsoft.com/support/kb/articles/Q238/5/88.ASP
+        // But, accordint to Microsoft, it is "RFC compliant but doesn't
+        // take into account some deviations that allowed within the
+        // specification."  Doesn't that mean RFC non-compliant?
+        // http://support.microsoft.com/support/kb/articles/Q258/4/52.ASP
+        //
+        // The best thing you can do for IE is to upgrade to the latest
+        // version
+        if ($isIE) {
+            // http://support.microsoft.com/support/kb/articles/Q182/3/15.asp
+            // Do not have quotes around filename, but that applied to
+            // "attachment"... does it apply to inline too?
+            //
+            // This combination seems to work mostly.  IE 5.5 SP 1 has
+            // known issues (see the Microsoft Knowledge Base)
+            header("Content-Disposition: inline; filename=$filename");
+
+            // This works for most types, but doesn't work with Word files
+            header("Content-Type: application/download; name=\"$filename\"");
+
+            // These are spares, just in case.  :-)
+            //header("Content-Type: $type0/$type1; name=\"$filename\"");
+            //header("Content-Type: application/x-msdownload; name=\"$filename\"");
+            //header("Content-Type: application/octet-stream; name=\"$filename\"");
+        } else {
+            header("Content-Disposition: attachment; filename=\"$filename\"");
+            // application/octet-stream forces download for Netscape
+            header("Content-Type: application/octet-stream; name=\"$filename\"");
+        }
+    }
+}
 ?>
index 0e845c57b6a3bf36b017248c4ed4f40decead0e5..18d89d94ec35777a19a41b29967ac010280b8955 100644 (file)
  * $Id$
  */
 
-/*****************************************************************/
-/*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!!           ***/
-/*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION.             ***/
-/***    + Base level indent should begin at left margin, as    ***/
-/***      the require_once below looks.                        ***/
-/***    + All identation should consist of four space blocks   ***/
-/***    + Tab characters are evil.                             ***/
-/***    + all comments should use "slash-star ... star-slash"  ***/
-/***      style -- no pound characters, no slash-slash style   ***/
-/***    + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD      ***/
-/***      ALWAYS USE { AND } CHARACTERS!!!                     ***/
-/***    + Please use ' instead of ", when possible. Note "     ***/
-/***      should always be used in _( ) function calls.        ***/
-/*** Thank you for your help making the SM code more readable. ***/
-/*****************************************************************/
-
 require_once('../src/validate.php');
 require_once('../functions/display_messages.php');
 require_once('../functions/imap.php');
 require_once('../functions/array.php');
 require_once('../functions/tree.php');
 
-   $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+$imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+
+sqimap_mailbox_list($imap_stream);
 
-   sqimap_mailbox_list($imap_stream);
+$mailbox = $trash_folder;
+$boxes = sqimap_mailbox_list($imap_stream);
+global $delimiter;
 
-   $mailbox = $trash_folder;
-   $boxes = sqimap_mailbox_list($imap_stream);
-   global $delimiter;
-   
-   // According to RFC2060, a DELETE command should NOT remove inferiors (sub folders)
-   //    so lets go through the list of subfolders and remove them before removing the
-   //    parent.
+/*
+ * According to RFC2060, a DELETE command should NOT remove inferiors (sub folders)
+ *    so lets go through the list of subfolders and remove them before removing the
+ *    parent.
+ */
+
+/** First create the top node in the tree **/
+for ($i = 0;$i < count($boxes);$i++) {
+    if (($boxes[$i]["unformatted"] == $mailbox) && (strlen($boxes[$i]["unformatted"]) == strlen($mailbox))) {
+        $foldersTree[0]["value"] = $mailbox;
+        $foldersTree[0]["doIHaveChildren"] = false;
+        continue;
+    }
+}
+/*
+ * Now create the nodes for subfolders of the parent folder
+ * You can tell that it is a subfolder by tacking the mailbox delimiter
+ *    on the end of the $mailbox string, and compare to that.
+ */
+$j = 0;
+for ($i = 0;$i < count($boxes);$i++) {
+    if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox . $delimiter)) == ($mailbox . $delimiter)) {
+        addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]["unformatted-dm"], $foldersTree);
+    }
+}
 
-   /** First create the top node in the tree **/
-   for ($i = 0;$i < count($boxes);$i++) {
-      if (($boxes[$i]["unformatted"] == $mailbox) && (strlen($boxes[$i]["unformatted"]) == strlen($mailbox))) {
-         $foldersTree[0]["value"] = $mailbox;
-         $foldersTree[0]["doIHaveChildren"] = false;
-         continue;
-      }
-   }
-   // Now create the nodes for subfolders of the parent folder 
-   // You can tell that it is a subfolder by tacking the mailbox delimiter
-   //    on the end of the $mailbox string, and compare to that.
-   $j = 0;
-   for ($i = 0;$i < count($boxes);$i++) {
-      if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox . $delimiter)) == ($mailbox . $delimiter)) {
-         addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]["unformatted-dm"], $foldersTree);
-      }
-   }
-   
-   // now lets go through the tree and delete the folders
-   walkTreeInPreOrderEmptyTrash(0, $imap_stream, $foldersTree);
+// now lets go through the tree and delete the folders
+walkTreeInPreOrderEmptyTrash(0, $imap_stream, $foldersTree);
 
-   $location = get_location();
-   header ("Location: $location/left_main.php");
+$location = get_location();
+header ("Location: $location/left_main.php");
 
-   sqimap_logout($imap_stream);
+sqimap_logout($imap_stream);
 ?>
index fb46544b8395658b359397785fa54c5a0fb43b5a..74320bf3874683c69a2ac4137c968ba94d2201b6 100644 (file)
  * $Id$
  */
 
-/*****************************************************************/
-/*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!!           ***/
-/*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION.             ***/
-/***    + Base level indent should begin at left margin, as    ***/
-/***      the require_once below looks.                        ***/
-/***    + All identation should consist of four space blocks   ***/
-/***    + Tab characters are evil.                             ***/
-/***    + all comments should use "slash-star ... star-slash"  ***/
-/***      style -- no pound characters, no slash-slash style   ***/
-/***    + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD      ***/
-/***      ALWAYS USE { AND } CHARACTERS!!!                     ***/
-/***    + Please use ' instead of ", when possible. Note "     ***/
-/***      should always be used in _( ) function calls.        ***/
-/*** Thank you for your help making the SM code more readable. ***/
-/*****************************************************************/
-
 require_once('../src/validate.php');
 require_once('../functions/display_messages.php');
 require_once('../functions/imap.php');
 
-   function putSelectedMessagesIntoString($msg) {
-      $j = 0;
-      $i = 0;
-      $firstLoop = true;
-      
-      // If they have selected nothing msg is size one still, but will
-      // be an infinite loop because we never increment j. so check to
-      // see if msg[0] is set or not to fix this.
-      while (($j < count($msg)) && ($msg[0])) {
-         if ($msg[$i]) {
+function putSelectedMessagesIntoString($msg) {
+    $j = 0;
+    $i = 0;
+    $firstLoop = true;
+
+    // If they have selected nothing msg is size one still, but will
+    // be an infinite loop because we never increment j. so check to
+    // see if msg[0] is set or not to fix this.
+    while (($j < count($msg)) && ($msg[0])) {
+        if ($msg[$i]) {
             if ($firstLoop != true)
-               $selectedMessages .= "&";
+            $selectedMessages .= "&";
             else
-               $firstLoop = false;
+            $firstLoop = false;
 
             $selectedMessages .= "selMsg[$j]=$msg[$i]";
-            
+
             $j++;
-         }
-         $i++;
-      }
-   }
-
-   $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
-   sqimap_mailbox_select($imapConnection, $mailbox);
-
-   // expunge-on-demand if user isn't using move_to_trash or auto_expunge
-   if(isset($expungeButton)) {
-     sqimap_mailbox_expunge($imapConnection, $mailbox, true);
-     $location = get_location();
-     if ($where && $what)
-       header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
-     else   
-       header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
-   }
-   // undelete messages if user isn't using move_to_trash or auto_expunge
-   elseif(isset($undeleteButton)) {
-      if (is_array($msg) == 1) {
-         // Removes \Deleted flag from selected messages
-         $j = 0;
-         $i = 0;
-      
-         // If they have selected nothing msg is size one still, but will be an infinite
-         //    loop because we never increment j.  so check to see if msg[0] is set or not to fix this.
-         while ($j < count($msg)) {
+        }
+        $i++;
+    }
+}
+
+$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+sqimap_mailbox_select($imapConnection, $mailbox);
+
+// expunge-on-demand if user isn't using move_to_trash or auto_expunge
+if(isset($expungeButton)) {
+    sqimap_mailbox_expunge($imapConnection, $mailbox, true);
+    $location = get_location();
+    if ($where && $what) {
+        header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
+    } else {
+        header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
+    }
+
+} elseif(isset($undeleteButton)) {
+    // undelete messages if user isn't using move_to_trash or auto_expunge
+
+    if (is_array($msg) == 1) {
+        // Removes \Deleted flag from selected messages
+        $j = 0;
+        $i = 0;
+
+        // If they have selected nothing msg is size one still, but will be an infinite
+        //    loop because we never increment j.  so check to see if msg[0] is set or not to fix this.
+        while ($j < count($msg)) {
             if ($msg[$i]) {
-              sqimap_messages_remove_flag ($imapConnection, $msg[$i], $msg[$i], "Deleted");
-               $j++;
+            sqimap_messages_remove_flag ($imapConnection, $msg[$i], $msg[$i], "Deleted");
+            $j++;
             }
             $i++;
-         }
-         $location = get_location();
+        }
+        $location = get_location();
 
-         if ($where && $what)
+        if ($where && $what)
             header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
-         else   
+        else
             header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
-      } else {
-         displayPageHeader($color, $mailbox);
-         error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
-      }
-   }
-   // If the delete button was pressed, the moveButton variable will not be set.
-   elseif (!isset($moveButton)) {
-      if (is_array($msg) == 1) {
-         // Marks the selected messages as 'Deleted'
-         $j = 0;
-         $i = 0;
-      
-         // If they have selected nothing msg is size one still, but will be an infinite
-         //    loop because we never increment j.  so check to see if msg[0] is set or not to fix this.
-         while ($j < count($msg)) {
+    } else {
+        displayPageHeader($color, $mailbox);
+        error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
+    }
+} elseif (!isset($moveButton)) {
+    // If the delete button was pressed, the moveButton variable will not be set.
+    if (is_array($msg) == 1) {
+        // Marks the selected messages as 'Deleted'
+        $j = 0;
+        $i = 0;
+
+        // If they have selected nothing msg is size one still, but will be an infinite
+        //    loop because we never increment j.  so check to see if msg[0] is set or not to fix this.
+        while ($j < count($msg)) {
             if (isset($msg[$i])) {
-               if (isset($markRead)) {
-                  sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Seen");
-               } else if (isset($markUnread)) {
-                   sqimap_messages_remove_flag($imapConnection, $msg[$i], $msg[$i], "Seen");
-               } else {
-                  sqimap_messages_delete($imapConnection, $msg[$i], $msg[$i], $mailbox);
-               }
-               $j++;
+                if (isset($markRead)) {
+                    sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Seen");
+                } else if (isset($markUnread)) {
+                    sqimap_messages_remove_flag($imapConnection, $msg[$i], $msg[$i], "Seen");
+                } else {
+                    sqimap_messages_delete($imapConnection, $msg[$i], $msg[$i], $mailbox);
+                }
+                $j++;
             }
             $i++;
-         }
-         if ($auto_expunge) {
+        }
+        if ($auto_expunge) {
             sqimap_mailbox_expunge($imapConnection, $mailbox, true);
-         }
-         $location = get_location();
-         if (isset($where) && isset($what))
+        }
+        $location = get_location();
+        if (isset($where) && isset($what)) {
             header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
-         else   
+        } else {
             header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
-      } else {
-         displayPageHeader($color, $mailbox);
-         error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
-      }
-   } else {    // Move messages
-      // lets check to see if they selected any messages
-      if (is_array($msg) == 1) {
-         $j = 0;
-         $i = 0;
-         // If they have selected nothing msg is size one still, but will be an infinite
-         //    loop because we never increment j.  so check to see if msg[0] is set or not to fix this.
-         while ($j < count($msg)) {
+        }
+    } else {
+        displayPageHeader($color, $mailbox);
+        error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
+    }
+} else {    // Move messages
+    // lets check to see if they selected any messages
+    if (is_array($msg) == 1) {
+        $j = 0;
+        $i = 0;
+
+        // If they have selected nothing msg is size one still, but will be an infinite
+        //    loop because we never increment j.  so check to see if msg[0] is set or not to fix this.
+        while ($j < count($msg)) {
             if (isset($msg[$i])) {
-               /** check if they would like to move it to the trash folder or not */
-               sqimap_messages_copy($imapConnection, $msg[$i], $msg[$i], $targetMailbox);
-               sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Deleted");
-               $j++;
+                /** check if they would like to move it to the trash folder or not */
+                sqimap_messages_copy($imapConnection, $msg[$i], $msg[$i], $targetMailbox);
+                sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Deleted");
+                $j++;
             }
             $i++;
-         }
-         if ($auto_expunge == true)
+        }
+        if ($auto_expunge == true)
             sqimap_mailbox_expunge($imapConnection, $mailbox, true);
 
-         $location = get_location();
-         if (isset($where) && isset($what))
+        $location = get_location();
+        if (isset($where) && isset($what))
             header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
-         else   
+        else
             header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
-      } else {
-         displayPageHeader($color, $mailbox);
-         error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
-      }
-   }
-
-   // Log out this session
-   sqimap_logout($imapConnection);
+    } else {
+        displayPageHeader($color, $mailbox);
+        error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
+    }
+}
+
+// Log out this session
+sqimap_logout($imapConnection);
 
 ?>
 </BODY></HTML>
index b070dd58ba81018c55dc621acb340ee70beaf32a..8aa55c2d5b32673ef6e283464df5e51d54e69905 100644 (file)
  * $Id$
  */
 
-/*****************************************************************/
-/*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!!           ***/
-/*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION.             ***/
-/***    + Base level indent should begin at left margin, as    ***/
-/***      the require_once below looks.                        ***/
-/***    + All identation should consist of four space blocks   ***/
-/***    + Tab characters are evil.                             ***/
-/***    + all comments should use "slash-star ... star-slash"  ***/
-/***      style -- no pound characters, no slash-slash style   ***/
-/***    + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD      ***/
-/***      ALWAYS USE { AND } CHARACTERS!!!                     ***/
-/***    + Please use ' instead of ", when possible. Note "     ***/
-/***      should always be used in _( ) function calls.        ***/
-/*** Thank you for your help making the SM code more readable. ***/
-/*****************************************************************/
-
 require_once('../src/validate.php');
 require_once('../functions/date.php');
 require_once('../functions/page_header.php');
 require_once('../functions/mime.php');
 require_once('../src/load_prefs.php');
 
-   $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
-   sqimap_mailbox_select($imapConnection, $mailbox);
+$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+sqimap_mailbox_select($imapConnection, $mailbox);
 
 
-   displayPageHeader($color, 'None');
+displayPageHeader($color, 'None');
 
-   echo '<br><table width="100%" border="0" cellspacing="0" cellpadding="2" ' .
-             'align="center">' . "\n" .
+echo '<br><table width="100%" border="0" cellspacing="0" cellpadding="2" ' .
+            'align="center">' . "\n" .
         '<tr><td bgcolor="' . $color[0] . '">' .
         '<b><center>' .
         _("Viewing a Business Card") . " - ";
-   if (isset($where) && isset($what)) {
-      // from a search
-      echo '<a href="../src/read_body.php?mailbox=' . urlencode($mailbox) .
-            '&passed_id=' . $passed_id . '&where=' . urlencode($where) . 
+if (isset($where) && isset($what)) {
+    // from a search
+    echo '<a href="../src/read_body.php?mailbox=' . urlencode($mailbox) .
+            '&passed_id=' . $passed_id . '&where=' . urlencode($where) .
             '&what=' . urlencode($what). '">' . _("View message") . '</a>';
-   } else {   
-      echo '<a href="../src/read_body.php?mailbox=' . urlencode($mailbox) .
-           '&passed_id=' . $passed_id . '&startMessage=' . $startMessage .
-           '&show_more=0">' . _("View message") . '</a>';
-   }   
-   echo '</center></b></td></tr>';
-
-   $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
-
-   $entity_vcard = getEntity($message,$passed_ent_id);
-   
-   $vcard = mime_fetch_body ($imapConnection, $passed_id, $passed_ent_id); 
-   $vcard = decodeBody($vcard, $entity_vcard->header->encoding);
-   $vcard = explode ("\n",$vcard);
-   foreach ($vcard as $l)
-   {
-     $k = substr($l, 0, strpos($l, ':'));
-     $v = substr($l, strpos($l, ':') + 1);
-     $attributes = explode(';', $k);
-     $k = strtolower(array_shift($attributes));
-     foreach ($attributes as $attr)
-     {
-         if ($attr == 'quoted-printable')
-           $v = quoted_printable_decode($v);
-         else
+} else {
+    echo '<a href="../src/read_body.php?mailbox=' . urlencode($mailbox) .
+        '&passed_id=' . $passed_id . '&startMessage=' . $startMessage .
+        '&show_more=0">' . _("View message") . '</a>';
+}
+echo '</center></b></td></tr>';
+
+$message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
+
+$entity_vcard = getEntity($message,$passed_ent_id);
+
+$vcard = mime_fetch_body ($imapConnection, $passed_id, $passed_ent_id);
+$vcard = decodeBody($vcard, $entity_vcard->header->encoding);
+$vcard = explode ("\n",$vcard);
+foreach ($vcard as $l) {
+    $k = substr($l, 0, strpos($l, ':'));
+    $v = substr($l, strpos($l, ':') + 1);
+    $attributes = explode(';', $k);
+    $k = strtolower(array_shift($attributes));
+    foreach ($attributes as $attr)     {
+        if ($attr == 'quoted-printable')
+        $v = quoted_printable_decode($v);
+        else
             $k .= ';' . $attr;
-     }
-    
-     $v = ereg_replace(';', "\n", $v);
-     $vcard_nice[$k] = $v;
-   }
-
-   if ($vcard_nice['version'] == '2.1') 
-   {
-      // get firstname and lastname for sm addressbook
-      $vcard_nice["firstname"] = substr($vcard_nice["n"],
-         strpos($vcard_nice["n"], "\n") + 1, strlen($vcard_nice["n"]));
-      $vcard_nice["lastname"] = substr($vcard_nice["n"], 0, 
-          strpos($vcard_nice["n"], "\n"));
-   }
-   else 
-   {
-      echo '<tr><td align=center>vCard Version ' . $vcard_nice['version'] . 
-           ' is not supported.  Some information might not be converted ' .
-          "correctly.</td></tr>\n";
-   }
-   
-   foreach ($vcard_nice as $k => $v)
-   {
-      $v = htmlspecialchars($v);
-      $v = trim($v);
-      $vcard_safe[$k] = trim(nl2br($v));
-   }
-
-   $ShowValues = array(
-     'fn' =>             _("Name"),
-     'title' =>          _("Title"),
-     'email;internet' => _("Email"),
-     'url' =>            _("Web Page"),
-     'org' =>            _("Organization / Department"),
-     'adr' =>            _("Address"),
-     'tel;work' =>       _("Work Phone"),
-     'tel;home' =>       _("Home Phone"),
-     'tel;cell' =>       _("Cellular Phone"),
-     'tel;fax' =>        _("Fax"),
-     'note' =>           _("Note"));
-   echo '<tr><td><br>' .
+    }
+
+    $v = ereg_replace(';', "\n", $v);
+    $vcard_nice[$k] = $v;
+}
+
+if ($vcard_nice['version'] == '2.1') {
+    // get firstname and lastname for sm addressbook
+    $vcard_nice["firstname"] = substr($vcard_nice["n"],
+    strpos($vcard_nice["n"], "\n") + 1, strlen($vcard_nice["n"]));
+    $vcard_nice["lastname"] = substr($vcard_nice["n"], 0,
+        strpos($vcard_nice["n"], "\n"));
+} else {
+    echo '<tr><td align=center>vCard Version ' . $vcard_nice['version'] .
+        ' is not supported.  Some information might not be converted ' .
+    "correctly.</td></tr>\n";
+}
+
+foreach ($vcard_nice as $k => $v) {
+    $v = htmlspecialchars($v);
+    $v = trim($v);
+    $vcard_safe[$k] = trim(nl2br($v));
+}
+
+$ShowValues = array(
+    'fn' =>             _("Name"),
+    'title' =>          _("Title"),
+    'email;internet' => _("Email"),
+    'url' =>            _("Web Page"),
+    'org' =>            _("Organization / Department"),
+    'adr' =>            _("Address"),
+    'tel;work' =>       _("Work Phone"),
+    'tel;home' =>       _("Home Phone"),
+    'tel;cell' =>       _("Cellular Phone"),
+    'tel;fax' =>        _("Fax"),
+    'note' =>           _("Note"));
+
+echo '<tr><td><br>' .
         '<TABLE border=0 cellpadding=2 cellspacing=0 align=center>' . "\n";
-   
-   if (isset($vcard_safe['email;internet'])) {
-      $vcard_safe['email;internet'] = '<A HREF="../src/compose.php?send_to=' .
-          $vcard_safe['email;internet'] . '">' . $vcard_safe['email;internet'] .
-          '</A>';
-   }
-   if (isset($vcard_safe['url'])) {
-      $vcard_safe['url'] = '<A HREF="' . $vcard_safe['url'] . '">' .
-          $vcard_safe['url'] . '</A>';
-   }
-   
-   foreach ($ShowValues as $k => $v)
-   {
-       if (isset($vcard_safe[$k]) && $vcard_safe[$k])
-       {
-           echo "<tr><td align=right><b>$v:</b></td><td>" . $vcard_safe[$k] .
+
+if (isset($vcard_safe['email;internet'])) {     $vcard_safe['email;internet'] = '<A HREF="../src/compose.php?send_to=' .
+        $vcard_safe['email;internet'] . '">' . $vcard_safe['email;internet'] .
+        '</A>';
+}
+if (isset($vcard_safe['url'])) {
+    $vcard_safe['url'] = '<A HREF="' . $vcard_safe['url'] . '">' .
+        $vcard_safe['url'] . '</A>';
+}
+
+foreach ($ShowValues as $k => $v) {
+    if (isset($vcard_safe[$k]) && $vcard_safe[$k])     {
+        echo "<tr><td align=right><b>$v:</b></td><td>" . $vcard_safe[$k] .
                 "</td><tr>\n";
-       }
-   }
+    }
+}
 
-   echo '</table>' .
+echo '</table>' .
         '<br>' .
         '</td></tr></table>' .
         '<table width="100%" border="0" cellspacing="0" cellpadding="2" ' .
-          'align="center">' .
+        'align="center">' .
         '<tr>' .
         '<td bgcolor="' . $color[0] . '">' .
         '<b><center>' .
@@ -158,49 +133,58 @@ require_once('../src/load_prefs.php');
         '<tr><td align=right><b>Note Field Contains:</b></td><td>' .
         '<select name="addaddr[label]">';
 
-   if (isset($vcard_nice['url'])) 
-      echo '<option value="' . htmlspecialchars($vcard_nice['url']) . 
-           '">' . _("Web Page") . "</option>\n";
-   if (isset($vcard_nice['adr']))
-      echo '<option value="' . $vcard_nice['adr'] . 
-           '">' . _("Address") . "</option>\n";
-   if (isset($vcard_nice['title']))
-      echo '<option value="' . $vcard_nice['title'] . 
-           '">' . _("Title") . "</option>\n";
-   if (isset($vcard_nice['org']))
-      echo '<option value="' . $vcard_nice['org'] . 
-           '">' . _("Organization / Department") . "</option>\n";
-   if (isset($vcard_nice['title']))
-      echo '<option value="' . $vcard_nice['title'] . 
-           '; ' . $vcard_nice['org'] . 
-           '">' . _("Title & Org. / Dept.") . "</option>\n";
-   if (isset($vcard_nice['tel;work']))
-      echo '<option value="' . $vcard_nice['tel;work'] . 
-           '">' . _("Work Phone") . "</option>\n";
-   if (isset($vcard_nice['tel;home']))
-      echo '<option value="' . $vcard_nice['tel;home'] . 
-           '">' . _("Home Phone") . "</option>\n";
-   if (isset($vcard_nice['tel;cell']))
-      echo '<option value="' . $vcard_nice['tel;cell'] . 
-           '">' . _("Cellular Phone") . "</option>\n";
-   if (isset($vcard_nice['tel;fax']))
-      echo '<option value="' . $vcard_nice['tel;fax'] . 
-           '">' . _("Fax") . "</option>\n";
-   if (isset($vcard_nice['note']))
-      echo '<option value="' . $vcard_nice['note'] . 
-           '">' . _("Note") . "</option>\n";
-
-   echo '</select>' .
+if (isset($vcard_nice['url'])) {
+    echo '<option value="' . htmlspecialchars($vcard_nice['url']) .
+        '">' . _("Web Page") . "</option>\n";
+}
+if (isset($vcard_nice['adr'])) {
+    echo '<option value="' . $vcard_nice['adr'] .
+        '">' . _("Address") . "</option>\n";
+}
+if (isset($vcard_nice['title'])) {
+    echo '<option value="' . $vcard_nice['title'] .
+        '">' . _("Title") . "</option>\n";
+}
+if (isset($vcard_nice['org'])) {
+    echo '<option value="' . $vcard_nice['org'] .
+        '">' . _("Organization / Department") . "</option>\n";
+}
+if (isset($vcard_nice['title'])) {
+    echo '<option value="' . $vcard_nice['title'] .
+        '; ' . $vcard_nice['org'] .
+        '">' . _("Title & Org. / Dept.") . "</option>\n";
+}
+if (isset($vcard_nice['tel;work'])) {
+    echo '<option value="' . $vcard_nice['tel;work'] .
+        '">' . _("Work Phone") . "</option>\n";
+}
+if (isset($vcard_nice['tel;home'])) {
+    echo '<option value="' . $vcard_nice['tel;home'] .
+        '">' . _("Home Phone") . "</option>\n";
+}
+if (isset($vcard_nice['tel;cell'])) {
+    echo '<option value="' . $vcard_nice['tel;cell'] .
+        '">' . _("Cellular Phone") . "</option>\n";
+}
+if (isset($vcard_nice['tel;fax'])) {
+    echo '<option value="' . $vcard_nice['tel;fax'] .
+        '">' . _("Fax") . "</option>\n";
+}
+if (isset($vcard_nice['note'])) {
+    echo '<option value="' . $vcard_nice['note'] .
+        '">' . _("Note") . "</option>\n";
+}
+echo '</select>' .
         '</td></tr>' .
         '<tr><td colspan=2 align=center>' .
         '<INPUT NAME="addaddr[email]" type=hidden value="' .
-       htmlspecialchars($vcard_nice['email;internet']) . '">' .
+        htmlspecialchars($vcard_nice['email;internet']) . '">' .
         '<INPUT NAME="addaddr[firstname]" type=hidden value="' .
-       $vcard_safe['firstname'] . '">' .
+        $vcard_safe['firstname'] . '">' .
         '<INPUT NAME="addaddr[lastname]" type=hidden value="' .
-       $vcard_safe['lastname'] . '">' .
+        $vcard_safe['lastname'] . '">' .
         '<INPUT TYPE=submit NAME="addaddr[SUBMIT]" ' .
-           'VALUE="Add to Address Book">' .
+        'VALUE="Add to Address Book">' .
         '</td></tr>' .
         '</table>' .
         '</FORM>' .
@@ -208,7 +192,7 @@ require_once('../src/load_prefs.php');
         '<tr><td align=center>' .
         '<a href="../src/download.php?absolute_dl=true&passed_id=' .
         $passed_id . '&mailbox=' . urlencode($mailbox) .
-       '&passed_ent_id=' . $passed_ent_id . '">' .
+        '&passed_ent_id=' . $passed_ent_id . '">' .
         _("Download this as a file") . '</A>' .
         '</TD></TR></TABLE>' .
 
@@ -216,3 +200,5 @@ require_once('../src/load_prefs.php');
         '<TR><TD BGCOLOR="' . $color[4] . '">' .
         '</TD></TR></TABLE>' .
         '</body></html>';
+
+?>
\ No newline at end of file
index 3f9c11199a59b2ae9166f5b170ebfecfa8f2a146..596a4ccc1f2211483bbe7737013d6d1201ff1e9d 100644 (file)
@@ -41,11 +41,9 @@ if ($my_language != $squirrelmail_language) {
 
 set_up_language(getPref($data_dir, $username, 'language'));
 
-echo "<html><head>\n";
-echo '<TITLE>';
-echo $org_title;
-echo '</TITLE>';
-   
+echo "<html><head>\n" .
+     "<TITLE>$org_title</TITLE>";
+
 $left_size = getPref($data_dir, $username, 'left_size');
 $location_of_bar = getPref($data_dir, $username, 'location_of_bar');
 if ($location_of_bar == '') {
@@ -58,8 +56,8 @@ if ($left_size == "") {
     else {
         $left_size = 200;
     }
-}      
-   
+}
+
 if ($location_of_bar == 'right') {
     echo "<FRAMESET COLS=\"*, $left_size\" BORDER=0>";
 }
@@ -87,17 +85,13 @@ if ($right_frame == 'right_main.php') {
     $urlMailbox = urlencode($mailbox);
     $right_frame_url =
         "right_main.php?mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage";
-}
-elseif ($right_frame == 'options.php') {
+} elseif ($right_frame == 'options.php') {
     $right_frame_url = 'options.php';
-}
-elseif ($right_frame == 'folders.php') {
+} elseif ($right_frame == 'folders.php') {
     $right_frame_url = 'folders.php';
-}
-elseif ($right_frame == 'compose.php') {
+} elseif ($right_frame == 'compose.php') {
     $right_frame_url = "compose.php?send_to=$rcptaddress";
-}
-else {
+} else {
     $right_frame_url = 'right_main.php';
 }