Browse Source

Added a constat to all files in functions/ to be able to chech whether the
file has already been included.

gustavf 25 years ago
parent
commit
960fbbd382

+ 2 - 0
functions/array.php

@@ -7,6 +7,8 @@
     **
     **
     **/
     **/
 
 
+   $array_php = true;
+
    function ary_sort($ary,$col, $dir = 1){
    function ary_sort($ary,$col, $dir = 1){
       // The globals are used because USORT determines what is passed to comp2
       // The globals are used because USORT determines what is passed to comp2
       // These should be $this->col and $this->dir in a class
       // These should be $this->col and $this->dir in a class

+ 14 - 9
functions/date.php

@@ -9,6 +9,8 @@
     **
     **
     **/
     **/
 
 
+   $date_php = true;
+
    function getMinutes($hour) {
    function getMinutes($hour) {
       $date = $hour;
       $date = $hour;
 
 
@@ -196,16 +198,19 @@
        **        and everything would be bumped up one.
        **        and everything would be bumped up one.
        **/
        **/
 
 
-      // Simply check to see if the first element in the dateParts array is an integer or not.
+      // Simply check to see if the first element in the dateParts
+      // array is an integer or not.
       //    Since the day of week is optional, this check is needed.  
       //    Since the day of week is optional, this check is needed.  
       //    
       //    
-      //    The old code used eregi("mon|tue|wed|thu|fri|sat|sun", $dateParts[0], $tmp) 
-      //    to find if the first element was the day of week or day of month.  This is an
-      //    expensive call (processing time) to have inside a loop.  Doing it this way saves
-      //    quite a bit of time for large mailboxes.
+      //    The old code used eregi("mon|tue|wed|thu|fri|sat|sun",
+      //    $dateParts[0], $tmp) to find if the first element was the
+      //    day of week or day of month. This is an expensive call
+      //    (processing time) to have inside a loop. Doing it this way
+      //    saves quite a bit of time for large mailboxes.
       //
       //
-      //    It is also quicker to call explode only once rather than the 3 times it was getting
-      //    called by calling the functions getHour, getMinute, and getSecond.
+      //    It is also quicker to call explode only once rather than
+      //    the 3 times it was getting called by calling the functions
+      //    getHour, getMinute, and getSecond.
       //
       //
       if (intval(trim($dateParts[0])) > 0) {
       if (intval(trim($dateParts[0])) > 0) {
          $time = explode(":", $dateParts[3]);
          $time = explode(":", $dateParts[3]);
@@ -227,8 +232,8 @@
       return getGMTSeconds(mktime($d[0], $d[1], $d[2], $d[3], $d[4], $d[5]), $dateParts[5]);
       return getGMTSeconds(mktime($d[0], $d[1], $d[2], $d[3], $d[4], $d[5]), $dateParts[5]);
    }
    }
 
 
-   // I use this function for profiling.  Should never be called in actual versions of squirrelmail
-   //    released to public.
+   // I use this function for profiling. Should never be called in
+   // actual versions of squirrelmail released to public.
    function getmicrotime() {
    function getmicrotime() {
       $mtime = microtime();
       $mtime = microtime();
       $mtime = explode(" ",$mtime);
       $mtime = explode(" ",$mtime);

+ 2 - 0
functions/display_messages.php

@@ -7,6 +7,8 @@
     **
     **
     **/
     **/
 
 
+    $display_messages_php = true;
+
     function error_username_password_incorrect($color) {
     function error_username_password_incorrect($color) {
       echo "<BR>";
       echo "<BR>";
       echo "<TABLE COLS=1 WIDTH=75% NOBORDER BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
       echo "<TABLE COLS=1 WIDTH=75% NOBORDER BGCOLOR=\"$color[4]\" ALIGN=CENTER>";

+ 2 - 0
functions/imap.php

@@ -2,6 +2,8 @@
    /**  This just includes the different sections of the imap functions.
    /**  This just includes the different sections of the imap functions.
     **  They have been organized into these sections for simplicity sake.
     **  They have been organized into these sections for simplicity sake.
     **/
     **/
+
+   $imap_php = true;
    
    
    include ("../functions/imap_mailbox.php");
    include ("../functions/imap_mailbox.php");
    include ("../functions/imap_messages.php");
    include ("../functions/imap_messages.php");

+ 2 - 0
functions/mailbox_display.php

@@ -8,6 +8,8 @@
     **
     **
     **/
     **/
 
 
+   $mailbox_info = true;
+
    function printMessageInfo($imapConnection, $t, $i, $from, $subject, $dateString, $answered, $seen, $mailbox, $sort, $startMessage) {
    function printMessageInfo($imapConnection, $t, $i, $from, $subject, $dateString, $answered, $seen, $mailbox, $sort, $startMessage) {
       require ("../config/config.php");
       require ("../config/config.php");
 
 

+ 19 - 10
functions/mime.php

@@ -1,9 +1,12 @@
 <?
 <?
    /** mime.php
    /** mime.php
     **
     **
-    ** This contains the functions necessary to detect and decode MIME messages.
+    ** This contains the functions necessary to detect and decode MIME
+    ** messages.
+    **
     **/
     **/
 
 
+   $mime_php = true;
 
 
    if (!isset($i18n_php))
    if (!isset($i18n_php))
       include "../functions/i18n.php";
       include "../functions/i18n.php";
@@ -21,13 +24,15 @@
                $p = 0;
                $p = 0;
 
 
                /** Lets find the header for this entity **/
                /** Lets find the header for this entity **/
-               /** If the first line after the boundary is blank, we use default values **/
+               /** If the first line after the boundary is blank, we
+                   use default values **/
                if (trim($body[$j]) == "") {
                if (trim($body[$j]) == "") {
                   $ent_type0 = "text";
                   $ent_type0 = "text";
                   $ent_type1 = "plain";
                   $ent_type1 = "plain";
                   $charset = "us-ascii";
                   $charset = "us-ascii";
                   $j++;
                   $j++;
-               /** If the first line ISNT blank, read in the header for this entity **/
+               /** If the first line ISNT blank, read in the header
+                   for this entity **/
                } else {
                } else {
                   while ((substr(trim($body[$j]), 0, strlen("--$bound")) != "--$bound") && (trim($body[$j]) != "")) {
                   while ((substr(trim($body[$j]), 0, strlen("--$bound")) != "--$bound") && (trim($body[$j]) != "")) {
                      $entity_header[$p] = $body[$j];
                      $entity_header[$p] = $body[$j];
@@ -39,7 +44,8 @@
                }
                }
 
 
 
 
-               /** OK, we have the header information, now lets decide what to do with it **/
+               /** OK, we have the header information, now lets decide
+                   what to do with it **/
                if ($ent_type0 == "multipart") {
                if ($ent_type0 == "multipart") {
                   $y = 0;
                   $y = 0;
                   while (substr($body[$j], 0, strlen("--$bound--")) != "--$bound--") {
                   while (substr($body[$j], 0, strlen("--$bound--")) != "--$bound--") {
@@ -116,14 +122,16 @@
       return false;
       return false;
    }
    }
 
 
-   /** This returns a parsed string called $body.  That string can then be displayed
-       as the actual message in the HTML.   It contains everything needed, including
-       HTML Tags, Attachments at the bottom, etc.
+   /** This returns a parsed string called $body. That string can then
+       be displayed as the actual message in the HTML. It contains
+       everything needed, including HTML Tags, Attachments at the
+       bottom, etc.
     **/
     **/
    function formatBody($message, $color, $wrap_at) {
    function formatBody($message, $color, $wrap_at) {
 
 
-      /** this if statement checks for the entity to show as the primary message.  To
-          add more of them, just put them in the order that is their priority.
+      /** this if statement checks for the entity to show as the
+          primary message. To add more of them, just put them in the
+          order that is their priority.
        **/
        **/
       $id = $message["INFO"]["ID"];
       $id = $message["INFO"]["ID"];
       $urlmailbox = urlencode($message["INFO"]["MAILBOX"]);
       $urlmailbox = urlencode($message["INFO"]["MAILBOX"]);
@@ -143,7 +151,8 @@
          }
          }
       }
       }
 
 
-      /** If there are other types that shouldn't be formatted, add them here **/
+      /** If there are other types that shouldn't be formatted, add
+          them here **/
       if ($message["ENTITIES"][$ent_num]["TYPE1"] != "html")
       if ($message["ENTITIES"][$ent_num]["TYPE1"] != "html")
          $body = translateText($body, $wrap_at);
          $body = translateText($body, $wrap_at);
 
 

+ 2 - 0
functions/page_header.php

@@ -6,6 +6,8 @@
     **
     **
     **/
     **/
 
 
+   $page_header_php = true;
+
    // This is done to ensure that the character set is correct when
    // This is done to ensure that the character set is correct when
    // receiving input from HTTP forms
    // receiving input from HTTP forms
    header ("Content-Type: text/html; charset=iso-8859-1");
    header ("Content-Type: text/html; charset=iso-8859-1");

+ 4 - 1
functions/prefs.php

@@ -5,6 +5,8 @@
     **  This contains functions for manipulating user preferences
     **  This contains functions for manipulating user preferences
     **/
     **/
 
 
+   $prefs_php = true;
+
    /** returns the value for $string **/
    /** returns the value for $string **/
    function getPref($data_dir, $username, $string) {
    function getPref($data_dir, $username, $string) {
       $filename = "$data_dir$username.pref";
       $filename = "$data_dir$username.pref";
@@ -69,7 +71,8 @@
 
 
 
 
 
 
-   /** This checks if there is a pref file, if there isn't, it will create it. **/
+   /** This checks if there is a pref file, if there isn't, it will
+       create it. **/
    function checkForPrefs($data_dir, $username) {
    function checkForPrefs($data_dir, $username) {
       $filename = "$data_dir$username.pref";
       $filename = "$data_dir$username.pref";
       if (!file_exists($filename)) {
       if (!file_exists($filename)) {

+ 1 - 0
functions/smtp.php

@@ -5,6 +5,7 @@
     ** an smtp server or sendmail.
     ** an smtp server or sendmail.
     **/
     **/
 
 
+   $smtp_php = true;
 
 
    // Returns true only if this message is multipart
    // Returns true only if this message is multipart
    function isMultipart () {
    function isMultipart () {

+ 2 - 0
functions/strings.php

@@ -1,5 +1,7 @@
 <?
 <?
 
 
+   $strings_php = true;
+
    //*************************************************************************
    //*************************************************************************
    // Count the number of occurances of $needle are in $haystack.
    // Count the number of occurances of $needle are in $haystack.
    //*************************************************************************
    //*************************************************************************

+ 16 - 8
src/compose.php

@@ -7,14 +7,22 @@
     **  - Send mail
     **  - Send mail
     **/
     **/
 
 
-   include("../config/config.php");
-   include("../functions/strings.php");
-   include("../functions/page_header.php");
-   include("../functions/imap.php");
-   include("../functions/date.php");
-   include("../functions/mime.php");
-   include("../functions/smtp.php");
-   include("../functions/display_messages.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))
+      include("../functions/imap.php");
+   if (!isset($date_php))
+      include("../functions/date.php");
+   if (!isset($mime_php))
+      include("../functions/mime.php");
+   if (!isset($smtp_php))
+      include("../functions/smtp.php");
+   if (!isset($display_messages_php))
+      include("../functions/display_messages.php");
 
 
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
 
 

+ 10 - 5
src/delete_message.php

@@ -1,9 +1,14 @@
 <?
 <?
-   include("../config/config.php");
-   include("../functions/strings.php");
-   include("../functions/page_header.php");
-   include("../functions/display_messages.php");
-   include("../functions/imap.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($display_message_php))
+      include("../functions/display_messages.php");
+   if (!isset($imap_php))
+      include("../functions/imap.php");
 
 
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
 
 

+ 12 - 6
src/download.php

@@ -1,10 +1,16 @@
 <?
 <?
-   include("../config/config.php");
-   include("../functions/strings.php");
-   include("../functions/page_header.php");
-   include("../functions/imap.php");
-   include("../functions/mime.php");
-   include("../functions/date.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))
+      include("../functions/imap.php");
+   if (!isset($mime_php))
+      include("../functions/mime.php");
+   if (!isset($date_php))
+      include("../functions/date.php");
 
 
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
 
 

+ 10 - 5
src/folders.php

@@ -1,9 +1,14 @@
 <?
 <?
-   include("../config/config.php");
-   include("../functions/strings.php");
-   include("../functions/page_header.php");
-   include("../functions/imap.php");
-   include("../functions/array.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))
+      include("../functions/imap.php");
+   if (!isset($array_php))
+      include("../functions/array.php");
 
 
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
 
 

+ 10 - 5
src/folders_create.php

@@ -1,9 +1,14 @@
 <?
 <?
-   include("../config/config.php");
-   include("../functions/strings.php");
-   include("../functions/page_header.php");
-   include("../functions/imap.php");
-   include("../functions/display_messages.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))
+      include("../functions/imap.php");
+   if (!isset($display_messages_php))
+      include("../functions/display_messages.php");
 
 
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
 
 

+ 10 - 5
src/folders_delete.php

@@ -1,9 +1,14 @@
 <?
 <?
-   include("../config/config.php");
-   include("../functions/strings.php");
-   include("../functions/page_header.php");
-   include("../functions/imap.php");
-   include("../functions/array.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))
+      include("../functions/imap.php");
+   if (!isset($array_php))
+      include("../functions/array.php");
 
 
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
 
 

+ 8 - 4
src/folders_rename_do.php

@@ -1,8 +1,12 @@
 <?
 <?
-   include("../config/config.php");
-   include("../functions/strings.php");
-   include("../functions/page_header.php");
-   include("../functions/imap.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))
+      include("../functions/imap.php");
 
 
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
 
 

+ 8 - 4
src/folders_rename_getname.php

@@ -1,8 +1,12 @@
 <?
 <?
-   include("../config/config.php");
-   include("../functions/strings.php");
-   include("../functions/page_header.php");
-   include("../functions/imap.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))
+      include("../functions/imap.php");
 
 
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
 
 

+ 8 - 4
src/left_main.php

@@ -14,10 +14,14 @@
 ?>
 ?>
 <HTML>
 <HTML>
 <?
 <?
-   include("../config/config.php");
-   include("../functions/array.php");
-   include("../functions/strings.php");
-   include("../functions/imap.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");
 
 
    function formatMailboxName($imapConnection, $mailbox, $real_box, $delimeter, $color, $move_to_trash) {
    function formatMailboxName($imapConnection, $mailbox, $real_box, $delimeter, $color, $move_to_trash) {
       require ("../config/config.php");
       require ("../config/config.php");

+ 4 - 2
src/login.php

@@ -12,8 +12,10 @@
 ?>
 ?>
 <HTML>
 <HTML>
 <?
 <?
-   include("../config/config.php");
-   include("../functions/strings.php");
+   if (!isset($config_php))
+      include("../config/config.php");
+   if (!isset($strings_php))
+      include("../functions/strings.php");
 
 
    echo "<BODY TEXT=000000 BGCOLOR=FFFFFF LINK=0000CC VLINK=0000CC ALINK=0000CC>\n";
    echo "<BODY TEXT=000000 BGCOLOR=FFFFFF LINK=0000CC VLINK=0000CC ALINK=0000CC>\n";
  
  

+ 13 - 7
src/move_messages.php

@@ -1,9 +1,14 @@
 <?
 <?
-   include("../config/config.php");
-   include("../functions/strings.php");
-   include("../functions/page_header.php");
-   include("../functions/display_messages.php");
-   include("../functions/imap.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($display_messages_php))
+      include("../functions/display_messages.php");
+   if (!isset($imap_php))
+      include("../functions/imap.php");
 
 
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
 
 
@@ -14,8 +19,9 @@
       $i = 0;
       $i = 0;
       $firstLoop = true;
       $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.
+      // 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])) {
       while (($j < count($msg)) && ($msg[0])) {
          if ($msg[$i]) {
          if ($msg[$i]) {
             if ($firstLoop != true)
             if ($firstLoop != true)

+ 12 - 6
src/options.php

@@ -1,10 +1,16 @@
 <?
 <?
-   include("../config/config.php");
-   include("../functions/strings.php");
-   include("../functions/page_header.php");
-   include("../functions/display_messages.php");
-   include("../functions/imap.php");
-   include("../functions/array.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($display_messages_php))
+      include("../functions/display_messages.php");
+   if (!isset($imap_php))
+      include("../functions/imap.php");
+   if (!isset($array_php))
+      include("../functions/array.php");
 
 
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
 
 

+ 12 - 6
src/options_submit.php

@@ -1,10 +1,16 @@
 <?
 <?
-   include("../config/config.php");
-   include("../functions/strings.php");
-   include("../functions/page_header.php");
-   include("../functions/display_messages.php");
-   include("../functions/imap.php");
-   include("../functions/array.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($dipslay_messages_php))
+      include("../functions/display_messages.php");
+   if (!isset($imap_php))
+      include("../functions/imap.php");
+   if (!isset($array_php))
+      include("../functions/array.php");
 
 
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
 
 

+ 12 - 6
src/read_body.php

@@ -1,10 +1,16 @@
 <?
 <?
-   include("../config/config.php");
-   include("../functions/strings.php");
-   include("../functions/page_header.php");
-   include("../functions/imap.php");
-   include("../functions/mime.php");
-   include("../functions/date.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))
+      include("../functions/imap.php");
+   if (!isset($mime_php))
+      include("../functions/mime.php");
+   if (!isset($date_php))
+      include("../functions/date.php");
 
 
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
 
 

+ 18 - 9
src/right_main.php

@@ -20,15 +20,24 @@
       exit;
       exit;
    }
    }
 
 
-   include("../config/config.php");
-   include("../functions/imap.php");
-   include("../functions/strings.php");
-   include("../functions/date.php");
-   include("../functions/page_header.php");
-   include("../functions/array.php");
-   include("../functions/mime.php");
-   include("../functions/mailbox_display.php");
-   include("../functions/display_messages.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))
+      include("../functions/page_header.php");
+   if (!isset($array_php))
+      include("../functions/array.php");
+   if (!isset($mime_php))
+      include("../functions/mime.php");
+   if (!isset($mailbox_display_php))
+      include("../functions/mailbox_display.php");
+   if (!isset($display_messages_php))
+      include("../functions/display_messages.php");
 ?>
 ?>
 <HTML>
 <HTML>
 <FONT FACE="Arial,Helvetica">
 <FONT FACE="Arial,Helvetica">