Browse Source

Removed a lot of the warnings generated when PHP has all warnings enabled.
This is not done yet, but it is a VERY good start.
Added $Id$ tags to a lot of the files.

Tyler Akins 24 years ago
parent
commit
de965920f1
53 changed files with 275 additions and 92 deletions
  1. 2 0
      config/conf.pl
  2. 2 0
      functions/abook_database.php
  3. 2 0
      functions/abook_ldap_server.php
  4. 2 0
      functions/abook_local_file.php
  5. 1 0
      functions/addressbook.php
  6. 2 1
      functions/array.php
  7. 1 0
      functions/auth.php
  8. 1 0
      functions/date.php
  9. 1 0
      functions/display_messages.php
  10. 2 0
      functions/imap.php
  11. 12 2
      functions/imap_general.php
  12. 5 3
      functions/imap_mailbox.php
  13. 14 7
      functions/imap_messages.php
  14. 2 1
      functions/imap_search.php
  15. 58 11
      functions/mailbox_display.php
  16. 22 8
      functions/mime.php
  17. 1 0
      functions/page_header.php
  18. 4 2
      functions/plugin.php
  19. 2 0
      functions/prefs.php
  20. 2 0
      functions/smtp.php
  21. 10 4
      functions/strings.php
  22. 3 0
      functions/tree.php
  23. 1 0
      functions/url_parser.php
  24. 1 0
      src/addrbook_popup.php
  25. 2 0
      src/addrbook_search.php
  26. 5 1
      src/addrbook_search_html.php
  27. 18 7
      src/addressbook.php
  28. 14 9
      src/compose.php
  29. 4 3
      src/delete_message.php
  30. 2 0
      src/download.php
  31. 2 0
      src/empty_trash.php
  32. 7 3
      src/folders.php
  33. 2 0
      src/folders_create.php
  34. 2 0
      src/folders_delete.php
  35. 2 0
      src/folders_rename_do.php
  36. 2 0
      src/folders_rename_getname.php
  37. 2 0
      src/folders_subscribe.php
  38. 1 0
      src/help.php
  39. 7 4
      src/left_main.php
  40. 2 1
      src/load_prefs.php
  41. 7 5
      src/move_messages.php
  42. 6 5
      src/options.php
  43. 1 0
      src/options_display.php
  44. 1 0
      src/options_folder.php
  45. 1 0
      src/options_highlight.php
  46. 1 0
      src/options_order.php
  47. 3 2
      src/options_personal.php
  48. 5 3
      src/read_body.php
  49. 1 0
      src/redirect.php
  50. 7 3
      src/right_main.php
  51. 8 3
      src/search.php
  52. 3 2
      src/signout.php
  53. 4 2
      src/webmail.php

+ 2 - 0
config/conf.pl

@@ -3,6 +3,8 @@
 # Luke Ehresman (luke@squirrelmail.org)
 #
 # A simple configure script to configure squirrelmail
+#
+# $Id$
 ############################################################              
 $conf_pl_version = "x62";
 

+ 2 - 0
functions/abook_database.php

@@ -23,6 +23,8 @@
     **
     **  NOTE. This class should not be used directly. Use the
     **        "AddressBook" class instead.
+    **
+    ** $Id$
     **/
    
    require_once("DB.php");

+ 2 - 0
functions/abook_ldap_server.php

@@ -20,6 +20,8 @@
    **
    **  NOTE. This class should not be used directly. Use the
    **        "AddressBook" class instead.
+   **
+   ** $Id$
    **/
 
    class abook_ldap_server extends addressbook_backend {

+ 2 - 0
functions/abook_local_file.php

@@ -14,6 +14,8 @@
    **
    **  NOTE. This class should not be used directly. Use the
    **        "AddressBook" class instead.
+   **
+   ** $Id$
    **/
 
    class abook_local_file extends addressbook_backend {

+ 1 - 0
functions/addressbook.php

@@ -5,6 +5,7 @@
    **
    **  Functions and classes for the addressbook system.
    **
+   **  $Id$
    **/
     
    $addressbook_php = true;

+ 2 - 1
functions/array.php

@@ -5,6 +5,7 @@
     **  This contains functions that work with array manipulation.  They
     **  will help sort, and do other types of things with arrays
     **
+    **  $Id$
     **/
 
    $array_php = true;
@@ -19,7 +20,7 @@
       $GLOBALS["col"] = $col;  // Column or Columns as an array
       $GLOBALS["dir"] = $dir;  // Direction, a positive number for ascending a negative for descending
 
-      usort($ary,comp2);
+      usort($ary,'comp2');
       return $ary;
   }
 

+ 1 - 0
functions/auth.php

@@ -5,6 +5,7 @@
  **
  ** Contains functions used to do authentication.
  **
+ ** $Id$
  **/
 
    $auth_php = true;

+ 1 - 0
functions/date.php

@@ -7,6 +7,7 @@
     **        <Tue,> 29 Jun 1999 09:52:11 -0500 (EDT)
     **  (as specified in RFC 822) -- "Tue" is optional
     **
+    **  $Id$
     **/
 
    $date_php = true;

+ 1 - 0
functions/display_messages.php

@@ -5,6 +5,7 @@
     **  This contains all messages, including information, error, and just
     **  about any other message you can think of.
     **
+    ** $Id$
     **/
 
     $display_messages_php = true;

+ 2 - 0
functions/imap.php

@@ -1,6 +1,8 @@
 <?php
    /**  This just includes the different sections of the imap functions.
     **  They have been organized into these sections for simplicity sake.
+    **
+    **  $Id$
     **/
 
    $imap_php = true;

+ 12 - 2
functions/imap_general.php

@@ -3,6 +3,8 @@
     **  imap.php
     **
     **  This implements all functions that do general imap functions.
+    **
+    **  $Id$
     **/
 
    $imap_general_debug = false;
@@ -16,10 +18,15 @@
       global $color, $squirrelmail_language, $imap_general_debug;
 
       $read = fgets($imap_stream, 9096);
+
       if (ereg("^\* [0-9]+ FETCH.*{([0-9]+)}", $read, $regs)) {
          $size = $regs[1];
+      } else {
+         $size = 0;
       }
       
+      $data = Array();
+      
       $continue = true;
       while ($continue) {
          // Continue if needed for this single line
@@ -202,8 +209,11 @@ function sqimap_capability($imap_stream, $capability) {
 
 		$c = explode(' ', $read[0]);
 		for ($i=2; $i < count($c); $i++) {
-			list($k, $v) = explode('=', $c[$i]);
-			$sqimap_capabilities[$k] = ($v)?$v:TRUE;
+			$cap_list = explode('=', $c[$i]);
+			if (isset($cap_list[1]))
+			    $sqimap_capabilities[$cap_list[0]] = $cap_list[1];
+			else
+ 			    $sqimap_capabilities[$cap_list[0]] = TRUE;
 		}
 	}
 	return $sqimap_capabilities[$capability];

+ 5 - 3
functions/imap_mailbox.php

@@ -3,6 +3,8 @@
     **  imap_mailbox.php
     **
     **  This impliments all functions that manipulate mailboxes
+    **
+    **  $Id$
     **/
 
    /******************************************************************************
@@ -257,7 +259,7 @@
       if ($list_special_folders_first == true) {
 
          // Then list special folders and their subfolders
-         for ($i = 0 ; $i <= count($boxes) ; $i++) {
+         for ($i = 0 ; $i < count($boxes) ; $i++) {
             if ($move_to_trash &&
 	        eregi("^" . quotemeta($trash_folder) . "(" .
 		quotemeta($dm) . ".*)?$", $boxes[$i]["unformatted"])) {
@@ -273,9 +275,9 @@
          }
 
          // Put INBOX.* folders ahead of the rest
-         for ($i = 0; $i <= count($boxes); $i++) {
+         for ($i = 0; $i < count($boxes); $i++) {
             if (eregi("^inbox\.", $boxes[$i]["unformatted"]) &&
-                ($boxes[$i]["used"] == false)) {
+                (!isset($boxes[$i]["used"]) || $boxes[$i]["used"] == false)) {
                $boxesnew[] = $boxes[$i];
                $boxes[$i]["used"] = true;
             }

+ 14 - 7
functions/imap_messages.php

@@ -2,7 +2,9 @@
    /**
     **  imap_messages.php
     **
-    **  This implements functions that manipulate messages 
+    **  This implements functions that manipulate messages
+    **
+    **  $Id$
     **/
 
    if (!isset($mime_php)) include "../functions/mime.php";
@@ -51,7 +53,8 @@
     **  Returns some general header information -- FROM, DATE, and SUBJECT
     ******************************************************************************/
    class small_header {
-      var $from, $subject, $date, $to, $priority, $message_id;
+      var $from = '', $subject = '', $date = '', $to = '', 
+          $priority = 0, $message_id = 0, $cc = '';
    }
 	 
    function sqimap_get_small_header ($imap_stream, $id, $sent) {
@@ -63,6 +66,11 @@
       $from = _("Unknown Sender");
       $priority = "0";
       $messageid = "<>";
+      $cc = "";
+      $to = "";
+      $date = "";
+      $type[0] = "";
+      $type[1] = "";
 
       $g = 0;
       for ($i = 0; $i < count($read); $i++) {
@@ -128,7 +136,7 @@
       $header->size = $size;
       $header->type0 = $type[0];
       $header->type1 = $type[1];
-
+      
       return $header;
    }
 
@@ -149,8 +157,7 @@
     ******************************************************************************/
    function sqimap_get_message ($imap_stream, $id, $mailbox) {
       $header = sqimap_get_message_header($imap_stream, $id, $mailbox);
-      $msg = sqimap_get_message_body($imap_stream, &$header);
-      return $msg;
+      return sqimap_get_message_body($imap_stream, &$header);
    }
 
    /******************************************************************************
@@ -291,7 +298,7 @@
          /** FROM **/
          else if (strtolower(substr($read[$i], 0, 5)) == "from:") {
             $hdr->from = trim(substr($read[$i], 5, strlen($read[$i]) - 6));
-            if ($hdr->replyto == "")
+            if (! isset($hdr->replyto) || $hdr->replyto == "")
                $hdr->replyto = $hdr->from;
             $i++;
          }
@@ -369,7 +376,7 @@
     ******************************************************************************/
    function sqimap_get_message_body ($imap_stream, &$header) {
       $id = $header->id;
-      return decodeMime($imap_stream, $body, &$header);
+      return decodeMime($imap_stream, &$header);
    }
 
 

+ 2 - 1
functions/imap_search.php

@@ -1,6 +1,7 @@
-<?php     
+<?php 
 /******************************************************************
  ** IMAP SEARCH ROUTIES
+ ** $Id$
  *****************************************************************/
    if (!isset($imap_php))
       include("../functions/imap.php");

+ 58 - 11
functions/mailbox_display.php

@@ -6,6 +6,7 @@
     **  This contains functions that display mailbox information, such as the
     **  table row that has sender, date, subject, etc...
     **
+    **  $Id$
     **/
 
    $mailbox_display_php = true;
@@ -27,10 +28,46 @@
 
       echo "<TR>\n";
 
-      if ($msg["FLAG_FLAGGED"] == true) { $flag = "<font color=$color[2]>"; $flag_end = "</font>"; }
-      if ($msg["FLAG_SEEN"] == false) { $bold = "<b>"; $bold_end = "</b>"; }
-      if ($mailbox == $sent_folder) { $italic = "<i>"; $italic_end = "</i>"; }
-      if ($msg["FLAG_DELETED"]) { $fontstr = "<font color=\"$color[9]\">"; $fontstr_end = "</font>"; }
+      if (isset($msg['FLAG_FLAGGED']) && $msg["FLAG_FLAGGED"] == true) 
+      { 
+         $flag = "<font color=$color[2]>"; 
+	 $flag_end = "</font>"; 
+      }
+      else
+      {
+         $flag = "";
+	 $flag_end = "";
+      }
+      if (isset($msg['FLAG_SEEN']) && $msg["FLAG_SEEN"] == false) 
+      { 
+         $bold = "<b>"; 
+	 $bold_end = "</b>"; 
+      }
+      else
+      {
+         $bold = "";
+	 $bold_end = "";
+      }
+      if ($mailbox == $sent_folder) 
+      { 
+         $italic = "<i>"; 
+	 $italic_end = "</i>"; 
+      }
+      else
+      {
+         $italic = "";
+	 $italic_end = "";
+      }
+      if (isset($msg['FLAG_DELETED']) && $msg["FLAG_DELETED"])
+      { 
+         $fontstr = "<font color=\"$color[9]\">"; 
+	 $fontstr_end = "</font>"; 
+      }
+      else
+      {
+         $fontstr = "";
+	 $fontstr_end = "";
+      }
 
       for ($i=0; $i < count($message_highlight_list); $i++) {
          if (trim($message_highlight_list[$i]["value"]) != "") {
@@ -46,7 +83,7 @@
          }
       }
 
-      if (!$hlt_color)
+      if (!isset($hlt_color))
          $hlt_color = $color[4];
 
       if ($where && $what) {
@@ -71,14 +108,17 @@
                break;
             case 4: # subject
                echo "   <td bgcolor=$hlt_color>$bold";
-			   echo "<a href=\"read_body.php?mailbox=$urlMailbox&passed_id=".$msg["ID"]."&startMessage=$startMessage&show_more=0$search_stuff\"";
-			   do_hook("subject_link");
-			   echo ">$flag$subject$flag_end</a>$bold_end</td>\n";
+	       if (! isset($search_stuff))
+	           $search_stuff = "";
+	       echo "<a href=\"read_body.php?mailbox=$urlMailbox&passed_id=".$msg["ID"]."&startMessage=$startMessage&show_more=0$search_stuff\"";
+	       do_hook("subject_link");
+	       echo ">$flag$subject$flag_end</a>$bold_end</td>\n";
                break;
             case 5: # flags
                $stuff = false;
                echo "   <td bgcolor=$hlt_color align=center width=1% nowrap><b><small>\n";
-               if ($msg["FLAG_ANSWERED"] == true) {
+               if (isset($msg['FLAG_ANSWERED']) && 
+	           $msg["FLAG_ANSWERED"] == true) {
                   echo "A\n";
                   $stuff = true;
                }
@@ -90,7 +130,7 @@
                   echo "<font color=$color[1]>!</font>\n";
                   $stuff = true;
                }
-               if ($msg["FLAG_DELETED"]) {
+               if (isset($msg['FLAG_DELETED']) && $msg["FLAG_DELETED"]) {
                   echo "<font color=\"$color[1]\">D</font>\n";
                   $stuff = true;
                }
@@ -189,6 +229,7 @@
          } else {
             $end = $numMessages;
          }
+	 if ($end > $numMessages) $end = $numMessages;
          while ($j < $end) {
             $date[$j] = ereg_replace("  ", " ", $date[$j]);
             $tmpdate = explode(" ", trim($date[$j]));
@@ -234,7 +275,8 @@
 
          /* Only ignore messages flagged as deleted if we are using a
           * trash folder or auto_expunge */
-         if (($move_to_trash || $auto_expunge) && $sort != 6)
+         if (((isset($move_to_trash) && $move_to_trash) 
+	      || (isset($auto_expunge) && $auto_expunge)) && $sort != 6)
          {
             /** Find and remove the ones that are deleted */
             $i = 0;
@@ -251,6 +293,8 @@
             }
             $numMessages = $i;
          } else {
+	    if (! isset($messages))
+	        $messages = array();
             $msgs = $messages;
          }
       }         
@@ -341,6 +385,8 @@
          $More .= "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
       }
 
+      if (! isset($msg))
+          $msg = "";
       mail_message_listing_beginning($imapConnection,
          "move_messages.php?msg=$msg&mailbox=$urlMailbox&startMessage=$startMessage",
           $mailbox, $sort, $Message, $More, $startMessage);
@@ -370,6 +416,7 @@
          else
             $i = 1;
          reset($msort);
+	 $k = 0;
          do {
             $key = key($msort);
             next($msort);

+ 22 - 8
functions/mime.php

@@ -4,6 +4,7 @@
     ** This contains the functions necessary to detect and decode MIME
     ** messages.
     **
+    ** $Id$
     **/
 
    $debug_mime = false;
@@ -23,10 +24,11 @@
       /** msg_header contains generic variables for values that **/
       /** could be in a header.                                 **/
       
-      var $type0, $type1, $boundary, $charset, $encoding, $size;
-      var $to, $from, $date, $cc, $bcc, $reply_to, $subject;
-      var $id, $mailbox, $description;
-      var $entity_id, $message_id, $charset;
+      var $type0 = '', $type1 = '', $boundary = '', $charset = '';
+      var $encoding = '', $size = 0, $to = '', $from = '', $date = '';
+      var $cc = '', $bcc = '', $reply_to = '', $subject = '';
+      var $id = 0, $mailbox = '', $description = '';
+      var $entity_id = 0, $message_id = 0;
    }
    
    class message {
@@ -58,14 +60,17 @@
       
       $id = $header->id;
       fputs ($imap_stream, "a001 FETCH $id BODYSTRUCTURE\r\n");
+      //
+      // This should use sqimap_read_data instead of reading it itself
+      //
       $read = fgets ($imap_stream, 10000);
       $response = substr($read, 0, 4);
+      $bodystructure = "";
       while ($response != "a001") {
          $bodystructure .= $read;
          $read = fgets ($imap_stream, 10000);
          $response = substr($read, 0, 4);
       }
-   //   $read = strtolower($bodystructure);
       $read = $bodystructure;
 
       if ($debug_mime) echo "<tt>$read</tt><br><br>\n";
@@ -168,6 +173,7 @@
             // loop through until we find the matching quote, and return that as a string
             $pos = 1;
             $char = substr($structure, $pos, 1);
+	    $text = "";
             while ($char != "\"" && $pos < strlen($structure)) {
                $text .= $char;
                $pos++;
@@ -178,6 +184,8 @@
             // comment me
             $end = mime_match_parenthesis (0, $structure);
             $sub = substr($structure, 1, $end-1);
+	    if (! isset($properties))
+	        $properties = array();
             $properties = mime_get_props($properties, $sub);
             $structure = substr($structure, strlen($sub) + 2);
          } else {
@@ -288,6 +296,7 @@
          if ($char == "\"") {
             $pos = 1;
             $char = substr($structure, $pos, 1);
+	    $tmp = "";
             while ($char != "\"" && $pos < strlen($structure)) {
                $tmp .= $char;
                $pos++;
@@ -299,6 +308,7 @@
             if ($char == "\"") {
                $pos = 1;
                $char = substr($structure, $pos, 1);
+	       $value = "";
                while ($char != "\"" && $pos < strlen($structure)) {
                   $value .= $char;
                   $pos++;
@@ -312,6 +322,8 @@
             } else if ($char == "(") {
                $end = mime_match_parenthesis (0, $structure);
                $sub = substr($structure, 1, $end-1);
+	       if (! isset($props))
+	           $props = array();
                $props = mime_get_props($props, $sub);
                $structure = substr($structure, strlen($sub) + 2);
             }
@@ -423,7 +435,7 @@
    /** This is the first function called.  It decides if this is a multipart
        message or if it should be handled as a single entity
     **/
-   function decodeMime ($imap_stream, $body, $header) {
+   function decodeMime ($imap_stream, $header) {
       global $username, $key, $imapServerAddress, $imapPort;
       return mime_structure ($imap_stream, $header);
    }
@@ -464,7 +476,9 @@
          if ($message->header->type0 == "text") {
             if ($message->header->type1 == "plain" ||
                 $message->header->type1 == "html") {
-               return $message->header->entity_id; 
+	       if (isset($message->header->entity_id))
+                   return $message->header->entity_id;
+	       return 0;
             }
          } else {
             for ($i=0; $message->entities[$i]; $i++) {
@@ -507,7 +521,7 @@
    
          /** Display the ATTACHMENTS: message if there's more than one part **/
          $body .= "</TD></TR></TABLE>";
-         if ($message->entities) {
+         if (isset($message->entities)) {
             $body .= formatAttachments ($message, $ent_num, $message->header->mailbox, $id);
          }
       } else {

+ 1 - 0
functions/page_header.php

@@ -4,6 +4,7 @@
     **
     **  Prints the page header (duh)
     **
+    **  $Id$
     **/
 
    session_start();

+ 4 - 2
functions/plugin.php

@@ -12,6 +12,7 @@
  **
  ** Documentation on how to write plugins might show up some time.
  **
+ ** $Id$
  **/
 
 
@@ -31,7 +32,8 @@
    function do_hook ($name) {
       global $squirrelmail_plugin_hooks;
       $Data = func_get_args();
-      if (is_array($squirrelmail_plugin_hooks[$name])) {
+      if (isset($squirrelmail_plugin_hooks[$name]) && 
+          is_array($squirrelmail_plugin_hooks[$name])) {
          foreach ($squirrelmail_plugin_hooks[$name] as $id => $function) {
             // Add something to set correct gettext domain for plugin
             if (function_exists($function)) {
@@ -46,7 +48,7 @@
   }
 
    // On startup, register all plugins configured for use
-   if (is_array($plugins))
+   if (isset($plugins) && is_array($plugins))
       foreach ($plugins as $id => $name)
          use_plugin($name);
 

+ 2 - 0
functions/prefs.php

@@ -3,6 +3,8 @@
     **  prefs.php
     **
     **  This contains functions for manipulating user preferences
+    **
+    **  $Id$
     **/
 
    $prefs_php = true;

+ 2 - 0
functions/smtp.php

@@ -3,6 +3,8 @@
     **
     ** This contains all the functions needed to send messages through
     ** an smtp server or sendmail.
+    **
+    ** $Id$
     **/
 
    $smtp_php = true;

+ 10 - 4
functions/strings.php

@@ -290,6 +290,7 @@
    // 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]));
       }
@@ -300,7 +301,7 @@
    function OneTimePadDecrypt ($string, $epad) {
       $pad = base64_decode($epad);
       $encrypted = base64_decode ($string);
-      
+      $decrypted = "";
       for ($i = 0; $i < strlen ($encrypted); $i++) {
 	 $decrypted .= chr (ord($encrypted[$i]) ^ ord($pad[$i]));
       }
@@ -375,8 +376,12 @@
       // getrusage
       if (function_exists("getrusage")) {
          $dat = getrusage();
-	 sq_mt_seed(md5($dat["ru_nswap"] . $dat["ru_majflt"] . 
-	    $dat["ru_utime.tv_sec"] . $dat["ru_utime.tv_usec"]));
+	 $Str = "";
+	 foreach ($dat as $k => $v)
+	 {
+	     $Str .= "$k = $v\n";
+	 }
+	 sq_mt_seed(md5($Str));
       }
       
       // Apache-specific
@@ -387,7 +392,8 @@
    
    function OneTimePadCreate ($length=100) {
       sq_mt_randomize();
-      
+
+      $pad = "";
       for ($i = 0; $i < $length; $i++) {
 	 $pad .= chr(mt_rand(0,255));
       }

+ 3 - 0
functions/tree.php

@@ -1,4 +1,7 @@
 <?php
+
+   /* $Id$ */
+
    $tree_php = true;
 
    if (!isset($imap_php))

+ 1 - 0
functions/url_parser.php

@@ -1,5 +1,6 @@
 <?php
    /* URL Passing code to allow links from with in emails */
+   /* $Id$ */
 
    $url_parser_php = true;
 

+ 1 - 0
src/addrbook_popup.php

@@ -7,6 +7,7 @@
     **
     **  Frameset for the JavaScript version of the address book.
     **
+    **  $Id$
     **/
 
    session_start();

+ 2 - 0
src/addrbook_search.php

@@ -10,6 +10,8 @@
     **  NOTE: A lot of this code is similar to the code in
     **        addrbook_search_html.html -- If you change one,
     **        change the other one too!
+    **
+    **  $Id$
     **/
 
    // Function to include JavaScript code

+ 5 - 1
src/addrbook_search_html.php

@@ -12,6 +12,8 @@
     **  NOTE: A lot of this code is similar to the code in
     **        addrbook_search.html -- If you change one, change
     **        the other one too!
+    **
+    **  $Id$
     **/
 
    session_start();
@@ -134,6 +136,8 @@
    print "<CENTER>\n";
    printf("  <nobr><STRONG>%s</STRONG>\n", _("Search for"));
    addr_insert_hidden();
+   if (! isset($addrquery))
+       $addrquery = "";
    printf("  <INPUT TYPE=text NAME=addrquery VALUE=\"%s\" SIZE=26>\n",
           htmlspecialchars($addrquery));
 
@@ -169,7 +173,7 @@
    // Show personal addressbook
    if(!isset($addrquery) || !empty($listall)) {
 
-      if($backend != -1 || !isset($addrquery)) {
+      if((isset($backend) && $backend != -1) || !isset($addrquery)) {
          if(!isset($addrquery)) 
             $backend = $abook->localbackend;
 

+ 18 - 7
src/addressbook.php

@@ -7,18 +7,19 @@
     **
     **  Manage personal address book.
     **
+    **  $Id$
     **/
 
    session_start();
 
+   if (!isset($strings_php))
+      include("../functions/strings.php");
    if (!isset($config_php))
       include("../config/config.php");
    if (!isset($array_php))
       include("../functions/array.php");
    if (!isset($auth_php))
       include("../functions/auth.php");
-   if (!isset($strings_php))
-      include("../functions/strings.php");
    if (!isset($page_header_php))
       include("../functions/page_header.php");
    if (!isset($display_messages_php))
@@ -47,28 +48,38 @@
       printf("<TD BGCOLOR=\"%s\" ALIGN=left>".
 	     "<INPUT NAME=\"%s[nickname]\" SIZE=15 VALUE=\"%s\">".
 	     "&nbsp;<SMALL>%s</SMALL></TD></TR>\n",
-	     $color[4], $name, htmlspecialchars($values["nickname"]), 
+	     $color[4], $name, 
+	     (isset($values["nickname"]))?
+	         htmlspecialchars($values["nickname"]):"",
 	     _("Must be unique"));
       printf("<TR><TD WIDTH=50 BGCOLOR=\"$color[4]\" ALIGN=RIGHT>%s:</TD>",
 	     _("E-mail address"));
       printf("<TD BGCOLOR=\"%s\" ALIGN=left>".
 	     "<INPUT NAME=\"%s[email]\" SIZE=45 VALUE=\"%s\"></TD></TR>\n",
-	     $color[4], $name, htmlspecialchars($values["email"]));
+	     $color[4], $name, 
+	     (isset($values["email"]))?
+	         htmlspecialchars($values["email"]):"");
       printf("<TR><TD WIDTH=50 BGCOLOR=\"$color[4]\" ALIGN=RIGHT>%s:</TD>",
 	     _("First name"));
       printf("<TD BGCOLOR=\"%s\" ALIGN=left>".
 	     "<INPUT NAME=\"%s[firstname]\" SIZE=45 VALUE=\"%s\"></TD></TR>\n",
-	     $color[4], $name, htmlspecialchars($values["firstname"]));
+	     $color[4], $name, 
+	     (isset($values["firstname"]))?
+	         htmlspecialchars($values["firstname"]):"");
       printf("<TR><TD WIDTH=50 BGCOLOR=\"$color[4]\" ALIGN=RIGHT>%s:</TD>",
 	     _("Last name"));
       printf("<TD BGCOLOR=\"%s\" ALIGN=left>".
 	     "<INPUT NAME=\"%s[lastname]\" SIZE=45 VALUE=\"%s\"></TD></TR>\n",
-	     $color[4], $name, htmlspecialchars($values["lastname"]));
+	     $color[4], $name, 
+	     (isset($values["lastname"]))?
+	         htmlspecialchars($values["lastname"]):"");
       printf("<TR><TD WIDTH=50 BGCOLOR=\"$color[4]\" ALIGN=RIGHT>%s:</TD>",
 	     _("Additional info"));
       printf("<TD BGCOLOR=\"%s\" ALIGN=left>".
 	     "<INPUT NAME=\"%s[label]\" SIZE=45 VALUE=\"%s\"></TD></TR>\n",
-	     $color[4], $name, htmlspecialchars($values["label"]));
+	     $color[4], $name, 
+	     (isset($values["label"]))?
+	         htmlspecialchars($values["label"]):"");
 
       printf("<TR><TD COLSPAN=2 BGCOLOR=\"%s\" ALIGN=center>\n".
 	     "<INPUT TYPE=submit NAME=\"%s[SUBMIT]\" VALUE=\"%s\"></TD></TR>\n",

+ 14 - 9
src/compose.php

@@ -11,14 +11,16 @@
     **  - Start new mail
     **  - Add an attachment
     **  - Send mail
+    **
+    ** $Id$
     **/
 
    session_start();
 
-   if (!isset($config_php))
-      include("../config/config.php");
    if (!isset($strings_php))
       include("../functions/strings.php");
+   if (!isset($config_php))
+      include("../config/config.php");
    if (!isset($page_header_php))
       include("../functions/page_header.php");
    if (!isset($imap_php))
@@ -53,7 +55,7 @@
          $id = $reply_id;
 
 
-      if ($id) {
+      if (isset($id)) {
          sqimap_mailbox_select($imapConnection, $mailbox);
          $message = sqimap_get_message($imapConnection, $id, $mailbox);
          $orig_header = $message->header;
@@ -397,11 +399,14 @@
       $mailbox = "INBOX";
 
    if(isset($send)) {
-      if ($HTTP_POST_FILES['attachfile']['tmp_name'] &&
+      if (isset($HTTP_POST_FILES['attachfile']) &&
+          $HTTP_POST_FILES['attachfile']['tmp_name'] &&
           $HTTP_POST_FILES['attachfile']['tmp_name'] != 'none')
           $AttachFailure = saveAttachedFiles();
-      if (checkInput(false) && ! $AttachFailure) {
+      if (checkInput(false) && ! isset($AttachFailure)) {
          $urlMailbox = urlencode ($mailbox);
+	 if (! isset($reply_id))
+	     $reply_id = 0;
          sendMessage($send_to, $send_to_cc, $send_to_bcc, $subject, $body, $reply_id);
          header ("Location: right_main.php?mailbox=$urlMailbox&sort=$sort&startMessage=1");
       } else {
@@ -416,7 +421,7 @@
          showInputForm();
          //sqimap_logout($imapConnection);
       }
-   } else if ($html_addr_search_done) {
+   } else if (isset($html_addr_search_done)) {
       is_logged_in();
       displayPageHeader($color, $mailbox);
 
@@ -437,7 +442,7 @@
       }
       
       showInputForm();
-   } else if ($html_addr_search) {
+   } else if (isset($html_addr_search)) {
       // I am using an include so as to elminiate an extra unnecessary click.  If you
       // can think of a better way, please implement it.
       include ("./addrbook_search_html.php");
@@ -457,7 +462,7 @@
       }
 
       showInputForm();
-	} else if ($smtpErrors) {
+	} else if (isset($smtpErrors)) {
       $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
       displayPageHeader($color, $mailbox);
 
@@ -473,7 +478,7 @@
 
       $newmail = true;
 		
-      if ($forward_id && $ent_num)  getAttachments(0);
+      if (isset($forward_id) && isset($ent_num))  getAttachments(0);
               
       newMail();
       showInputForm();

+ 4 - 3
src/delete_message.php

@@ -6,15 +6,16 @@
     **  Licensed under the GNU GPL. For full terms see the file COPYING.
     **
     **  Deletes a meesage from the IMAP server 
-    **  
+    **
+    **  $Id$
     **/
 
    session_start();
 
-   if (!isset($config_php))
-      include("../config/config.php");
    if (!isset($strings_php))
       include("../functions/strings.php");
+   if (!isset($config_php))
+      include("../config/config.php");
    if (!isset($page_header_php))
       include("../functions/page_header.php");
    if (!isset($display_message_php))

+ 2 - 0
src/download.php

@@ -7,6 +7,8 @@
     **
     **  Handles attachment downloads to the users computer.
     **  Also allows displaying of attachments when possible.
+    **
+    **  $Id$
     **/
 
    if (!isset($config_php))

+ 2 - 0
src/empty_trash.php

@@ -7,6 +7,8 @@
     **
     **  Handles deleting messages from the trash folder without
     **  deleting subfolders.
+    **
+    **  $Id$
     **/
 
    session_start();

+ 7 - 3
src/folders.php

@@ -8,14 +8,16 @@
     **  Handles all interaction between the user and the other folder
     **  scripts which do most of the work. Also handles the Special
     **  Folders.
+    **
+    **  $Id$
     **/
 
    session_start();
 
-   if (!isset($config_php))
-      include("../config/config.php");
    if (!isset($strings_php))
       include("../functions/strings.php");
+   if (!isset($config_php))
+      include("../config/config.php");
    if (!isset($page_header_php))
       include("../functions/page_header.php");
    if (!isset($imap_php))
@@ -36,7 +38,9 @@
    echo "   </b></TD></TR>\n";
    echo "</TABLE>\n";
 
-   if ($success || $sent_create == "true" || $trash_create == "true") {
+   if ((isset($success) && $success) || 
+       (isset($sent_create) && $sent_create == "true") || 
+       (isset($trash_create) && $trash_create == "true")) {
       echo "<table width=100% align=center cellpadding=3 cellspacing=0 border=0>\n";
       echo "   <tr><td><center>\n";
       if ($success == "subscribe") {

+ 2 - 0
src/folders_create.php

@@ -7,6 +7,8 @@
     **
     **  Creates folders on the IMAP server. 
     **  Called from folders.php
+    **
+    **  $Id$
     **/
 
    session_start();

+ 2 - 0
src/folders_delete.php

@@ -7,6 +7,8 @@
     **
     **  Deltes folders from the IMAP server. 
     **  Called from the folders.php
+    **
+    **  $Id$
     **/
 
    session_start();

+ 2 - 0
src/folders_rename_do.php

@@ -7,6 +7,8 @@
     **
     **  Does the actual renaming of files on the IMAP server. 
     **  Called from the folders.php
+    **
+    **  $Id$
     **/
 
    session_start();

+ 2 - 0
src/folders_rename_getname.php

@@ -7,6 +7,8 @@
     **
     **  Gets folder names and enables renaming
     **  Called from folders.php
+    **
+    **  $Id$
     **/
 
    session_start();

+ 2 - 0
src/folders_subscribe.php

@@ -7,6 +7,8 @@
     **
     **  Subscribe and unsubcribe form folders. 
     **  Called from folders.php
+    **
+    **  $Id$
     **/
 
    session_start();

+ 1 - 0
src/help.php

@@ -7,6 +7,7 @@
     **
     **  Displays help for the user
     **
+    **  $Id$
     **/
 
    session_start();

+ 7 - 4
src/left_main.php

@@ -7,6 +7,7 @@
     **  This is the code for the left bar.  The left bar shows the folders
     **  available, and has cookie information.
     **
+    **  $Id$
     **/
 
    session_start();
@@ -24,12 +25,12 @@
    }
 
 
+   if (!isset($strings_php))
+      include("../functions/strings.php");
    if (!isset($config_php))
       include("../config/config.php");
    if (!isset($array_php))
       include("../functions/array.php");
-   if (!isset($strings_php))
-      include("../functions/strings.php");
    if (!isset($imap_php))
       include("../functions/imap.php");
    if (!isset($page_header_php))
@@ -76,7 +77,7 @@
          }
       }
       
-      $line .= "<NOBR>";
+      $line = "<NOBR>";
       if ($unseen > 0)
          $line .= "<B>";
 
@@ -99,7 +100,7 @@
       if ($unseen > 0)
          $line .= "</B>";
       
-      if ($unseen_found) {
+      if (isset($unseen_found) && $unseen_found) {
          $line .= "&nbsp;<small>$unseen_string</small>";
       }
 
@@ -148,6 +149,8 @@
             $line .= replace_spaces($mailbox);
             $line .= "</FONT>";
          } else {
+	    if (! isset($boxes[$i]["unseen"])) 
+	        $boxes[$i]["unseen"] = 0;
             $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $boxes[$i]["unseen"]);
          }
       } else {

+ 2 - 1
src/load_prefs.php

@@ -8,6 +8,7 @@
     **  Loads preferences from the $username.pref file used by almost
     **  every other script in the source directory and alswhere.
     **
+    **  $Id$
     **/
 
    if (!isset($config_php))
@@ -59,7 +60,7 @@
       }
    }
 
-    if (!$download_php) session_register("theme_css");
+    if (!isset($download_php)) session_register("theme_css");
 
    $use_javascript_addr_book = getPref($data_dir, $username, "use_javascript_addr_book");
    if ($use_javascript_addr_book == "")

+ 7 - 5
src/move_messages.php

@@ -6,14 +6,16 @@
     **  Licensed under the GNU GPL. For full terms see the file COPYING.
     **
     **  Enables message moving between folders on the IMAP server.
+    **
+    **  $Id$
     **/
 
    session_start();
 
-   if (!isset($config_php))
-      include("../config/config.php");
    if (!isset($strings_php))
       include("../functions/strings.php");
+   if (!isset($config_php))
+      include("../config/config.php");
    if (!isset($page_header_php))
       include("../functions/page_header.php");
    if (!isset($display_messages_php))
@@ -50,7 +52,7 @@
    sqimap_mailbox_select($imapConnection, $mailbox);
 
    // expunge-on-demand if user isn't using move_to_trash or auto_expunge
-   if($expungeButton) {
+   if(isset($expungeButton)) {
      sqimap_mailbox_expunge($imapConnection, $mailbox, true);
      $location = get_location();
      if ($where && $what)
@@ -59,7 +61,7 @@
        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($undeleteButton) {
+   elseif(isset($undeleteButton)) {
       if (is_array($msg) == 1) {
          // Removes \Deleted flag from selected messages
          $j = 0;
@@ -86,7 +88,7 @@
       }
    }
    // If the delete button was pressed, the moveButton variable will not be set.
-   elseif (!$moveButton) {
+   elseif (!isset($moveButton)) {
       if (is_array($msg) == 1) {
          // Marks the selected messages ad 'Deleted'
          $j = 0;

+ 6 - 5
src/options.php

@@ -8,14 +8,15 @@
     **  Displays the options page. Pulls from proper user preference files
     **  and config.php. Displays preferences as selected and other options.
     **
+    **  $Id$
     **/
 
    session_start();
 
-   if (!isset($config_php))
-      include("../config/config.php");
    if (!isset($strings_php))
       include("../functions/strings.php");
+   if (!isset($config_php))
+      include("../config/config.php");
    if (!isset($page_header_php))
       include("../functions/page_header.php");
    if (!isset($display_messages_php))
@@ -46,7 +47,7 @@
 </td></tr></table>
 
 <?php
-   if ($submit_personal) {
+   if (isset($submit_personal)) {
       # Save personal information
       if (isset($full_name)) setPref($data_dir, $username, "full_name", sqStripSlashes($full_name));
       if (isset($email_address)) setPref($data_dir, $username, "email_address", sqStripSlashes($email_address));
@@ -57,7 +58,7 @@
       do_hook("options_personal_save");
       
       echo "<br><center><b>"._("Successfully saved personal information!")."</b></center><br>";
-   } else if ($submit_display) {  
+   } else if (isset($submit_display)) {  
       # Save display preferences
       setPref($data_dir, $username, "chosen_theme", $chosentheme);
       setPref($data_dir, $username, "show_num", $shownum);
@@ -74,7 +75,7 @@
 
       echo "<br><center><b>"._("Successfully saved display preferences!")."</b><br>";
       echo "<a href=\"../src/webmail.php\" target=_top>" . _("Refresh Page") . "</a></center><br>";
-   } else if ($submit_folder) { 
+   } else if (isset($submit_folder)) { 
       # Save folder preferences
       if ($trash != "none") {
          setPref($data_dir, $username, "move_to_trash", true);

+ 1 - 0
src/options_display.php

@@ -7,6 +7,7 @@
     **
     **  Displays all optinos about display preferences
     **
+    **  $Id$
     **/
 
    session_start();

+ 1 - 0
src/options_folder.php

@@ -7,6 +7,7 @@
     **
     **  Displays all options relating to folders
     **
+    **  $Id$
     **/
 
    session_start();

+ 1 - 0
src/options_highlight.php

@@ -7,6 +7,7 @@
     **
     **  Displays message highlighting options
     **
+    **  $Id$
     **/
 
    session_start();

+ 1 - 0
src/options_order.php

@@ -7,6 +7,7 @@
     **
     **  Displays message highlighting options
     **
+    **  $Id$
     **/
 
    session_start();

+ 3 - 2
src/options_personal.php

@@ -7,14 +7,15 @@
     **
     **  Displays all options relating to personal information
     **
+    **  $Id$
     **/
 
    session_start();
 
-   if (!isset($config_php))
-      include("../config/config.php");
    if (!isset($strings_php))
       include("../functions/strings.php");
+   if (!isset($config_php))
+      include("../config/config.php");
    if (!isset($page_header_php))
       include("../functions/page_header.php");
    if (!isset($display_messages_php))

+ 5 - 3
src/read_body.php

@@ -7,14 +7,16 @@
    **
    **  This file is used for reading the msgs array and displaying
    **  the resulting emails in the right frame.
+   **
+   **  $Id$
    **/
 
    session_start();
 
-   if (!isset($config_php))
-      include("../config/config.php");
    if (!isset($strings_php))
       include("../functions/strings.php");
+   if (!isset($config_php))
+      include("../config/config.php");
    if (!isset($page_header_php))
       include("../functions/page_header.php");
    if (!isset($imap_php))
@@ -32,7 +34,7 @@
    do_hook("html_top");
    displayPageHeader($color, $mailbox);
 
-   if ($view_hdr) {
+   if (isset($view_hdr)) {
       fputs ($imapConnection, "a003 FETCH $passed_id BODY[HEADER]\r\n");
       $read = sqimap_read_data ($imapConnection, "a003", true, $a, $b); 
       

+ 1 - 0
src/redirect.php

@@ -10,6 +10,7 @@
     **  prevents users from reposting their form data after a
     **  successful logout
     **
+    **  $Id$
     **/
 
    if (!isset($strings_php))

+ 7 - 3
src/right_main.php

@@ -8,6 +8,7 @@
     **  This is where the mailboxes are listed.  This controls most of what
     **  goes on in SquirrelMail.
     **
+    **  $Id$
     **/
 
    if (!isset($i18n_php))
@@ -27,12 +28,12 @@
       exit;
    }
 
+   if (!isset($strings_php))
+      include("../functions/strings.php");
    if (!isset($config_php))
       include("../config/config.php");
    if (!isset($imap_php))
       include("../functions/imap.php");
-   if (!isset($strings_php))
-      include("../functions/strings.php");
    if (!isset($date_php))
       include("../functions/date.php");
    if (!isset($page_header_php))
@@ -89,7 +90,8 @@
 
    do_hook("right_main_after_header");
    
-   if ($just_logged_in == 1 && strlen(trim($motd)) > 0) {
+   if (isset($just_logged_in) && $just_logged_in == 1 && 
+       strlen(trim($motd)) > 0) {
       echo "<center><br>\n";
       echo "<table width=70% cellpadding=0 cellspacing=0 border=0><tr><td bgcolor=\"$color[9]\">\n";
       echo "<table width=100% cellpadding=5 cellspacing=1 border=0><tr><td bgcolor=\"$color[4]\">\n";
@@ -107,6 +109,8 @@
    // 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 {

+ 8 - 3
src/search.php

@@ -1,4 +1,7 @@
 <?php
+
+   /* $Id$ */
+
    session_start();
 
    if(!isset($logged_in)) {
@@ -18,12 +21,12 @@
       exit;
    }
 
+   if (!isset($strings_php))
+      include("../functions/strings.php");
    if (!isset($i18n_php))
       include("../functions/i18n.php");
    if (!isset($config_php))
       include("../config/config.php");
-   if (!isset($strings_php))
-      include("../functions/strings.php");
    if (!isset($page_header_php))
       include("../functions/page_header.php");
    if (!isset($imap_php))
@@ -66,6 +69,8 @@
    echo "         </SELECT></SMALL></TT>";
    echo "       </TD>\n";
    echo "        <TD ALIGN=\"CENTER\" WIDTH=33%>\n";
+   if (!isset($what))
+       $what = "";
    $what_disp = ereg_replace(",", " ", $what);
    $what_disp = str_replace("\\\\", "\\", $what_disp);
    $what_disp = str_replace("\\\"", "\"", $what_disp);
@@ -103,7 +108,7 @@
    echo "</FORM>";
    echo "</td></tr></table>";
    do_hook("search_after_form");
-   if ($where && $what) {   
+   if (isset($where) && $where && isset($what) && $what) {   
       sqimap_mailbox_select($imapConnection, $mailbox);
       sqimap_search($imapConnection, $where, $what, $mailbox, $color);
    }

+ 3 - 2
src/signout.php

@@ -1,6 +1,4 @@
 <?php
-   session_start();
-
    /**
     **  signout.php -- cleans up session and logs the user out
     **
@@ -10,8 +8,11 @@
     **  Cleans up after the user. Resets cookies and terminates
     **  session.
     **
+    **  $Id$
     **/
 
+   session_start();
+
    include ("../src/load_prefs.php");
 
    if (!isset($config_php))

+ 4 - 2
src/webmail.php

@@ -10,6 +10,7 @@
     **  shown can be given as parameters. If the user is not logged in
     **  this file will verify username and password.
     **
+    **  $Id$
     **/
 
    session_start();
@@ -30,6 +31,8 @@
       exit;
    }
 
+   if (!isset($strings_php))
+      include ("../functions/strings.php");
    include ("../config/config.php");
    include ("../functions/prefs.php");
    include ("../functions/imap.php");
@@ -37,8 +40,7 @@
       include ("../functions/plugin.php");
    if (!isset($auth_php))
       include ("../functions/auth.php");
-   if (!isset($strings_php))
-      include ("../functions/strings.php");
+
 
    include ("../src/load_prefs.php");