瀏覽代碼

Minor cleanups

Fredrik Jervfors 21 年之前
父節點
當前提交
3b83c567dd

+ 33 - 34
functions/abook_database.php

@@ -1,5 +1,5 @@
 <?php
 <?php
-   
+
 /**
 /**
  * abook_database.php
  * abook_database.php
  *
  *
@@ -32,7 +32,7 @@
  * @subpackage addressbook
  * @subpackage addressbook
  */
  */
 
 
-/** Needs the DB functions */   
+/** Needs the DB functions */
 if (!include_once('DB.php')) {
 if (!include_once('DB.php')) {
     // same error also in db_prefs.php
     // same error also in db_prefs.php
     require_once(SM_PATH . 'functions/display_messages.php');
     require_once(SM_PATH . 'functions/display_messages.php');
@@ -51,31 +51,31 @@ if (!include_once('DB.php')) {
 class abook_database extends addressbook_backend {
 class abook_database extends addressbook_backend {
     var $btype = 'local';
     var $btype = 'local';
     var $bname = 'database';
     var $bname = 'database';
-      
+
     var $dsn       = '';
     var $dsn       = '';
     var $table     = '';
     var $table     = '';
     var $owner     = '';
     var $owner     = '';
     var $dbh       = false;
     var $dbh       = false;
-      
+
     var $writeable = true;
     var $writeable = true;
-      
+
     /* ========================== Private ======================= */
     /* ========================== Private ======================= */
-      
+
     /* Constructor */
     /* Constructor */
     function abook_database($param) {
     function abook_database($param) {
         $this->sname = _("Personal address book");
         $this->sname = _("Personal address book");
-         
+
         if (is_array($param)) {
         if (is_array($param)) {
-            if (empty($param['dsn']) || 
-                empty($param['table']) || 
+            if (empty($param['dsn']) ||
+                empty($param['table']) ||
                 empty($param['owner'])) {
                 empty($param['owner'])) {
                 return $this->set_error('Invalid parameters');
                 return $this->set_error('Invalid parameters');
             }
             }
-            
+
             $this->dsn   = $param['dsn'];
             $this->dsn   = $param['dsn'];
             $this->table = $param['table'];
             $this->table = $param['table'];
             $this->owner = $param['owner'];
             $this->owner = $param['owner'];
-            
+
             if (!empty($param['name'])) {
             if (!empty($param['name'])) {
                $this->sname = $param['name'];
                $this->sname = $param['name'];
             }
             }
@@ -94,29 +94,29 @@ class abook_database extends addressbook_backend {
             return $this->set_error('Invalid argument to constructor');
             return $this->set_error('Invalid argument to constructor');
         }
         }
     }
     }
-      
-      
+
+
     /* Open the database. New connection if $new is true */
     /* Open the database. New connection if $new is true */
     function open($new = false) {
     function open($new = false) {
         $this->error = '';
         $this->error = '';
-         
+
         /* Return true is file is open and $new is unset */
         /* Return true is file is open and $new is unset */
         if ($this->dbh && !$new) {
         if ($this->dbh && !$new) {
             return true;
             return true;
         }
         }
-         
+
         /* Close old file, if any */
         /* Close old file, if any */
         if ($this->dbh) {
         if ($this->dbh) {
             $this->close();
             $this->close();
         }
         }
-         
+
         $dbh = DB::connect($this->dsn, true);
         $dbh = DB::connect($this->dsn, true);
-         
+
         if (DB::isError($dbh)) {
         if (DB::isError($dbh)) {
             return $this->set_error(sprintf(_("Database error: %s"),
             return $this->set_error(sprintf(_("Database error: %s"),
                                             DB::errorMessage($dbh)));
                                             DB::errorMessage($dbh)));
         }
         }
-         
+
         $this->dbh = $dbh;
         $this->dbh = $dbh;
         return true;
         return true;
     }
     }
@@ -128,7 +128,7 @@ class abook_database extends addressbook_backend {
     }
     }
 
 
     /* ========================== Public ======================== */
     /* ========================== Public ======================== */
-     
+
     /* Search the file */
     /* Search the file */
     function &search($expr) {
     function &search($expr) {
         $ret = array();
         $ret = array();
@@ -169,19 +169,19 @@ class abook_database extends addressbook_backend {
         }
         }
         return $ret;
         return $ret;
     }
     }
-     
+
     /* Lookup alias */
     /* Lookup alias */
     function &lookup($alias) {
     function &lookup($alias) {
         if (empty($alias)) {
         if (empty($alias)) {
             return array();
             return array();
         }
         }
-         
+
         $alias = strtolower($alias);
         $alias = strtolower($alias);
 
 
         if (!$this->open()) {
         if (!$this->open()) {
             return false;
             return false;
         }
         }
-         
+
         $query = sprintf("SELECT * FROM %s WHERE owner='%s' AND LOWER(nickname)='%s'",
         $query = sprintf("SELECT * FROM %s WHERE owner='%s' AND LOWER(nickname)='%s'",
                          $this->table, $this->owner, $this->dbh->quoteString($alias));
                          $this->table, $this->owner, $this->dbh->quoteString($alias));
 
 
@@ -211,7 +211,7 @@ class abook_database extends addressbook_backend {
         if (!$this->open()) {
         if (!$this->open()) {
             return false;
             return false;
         }
         }
-	
+
 	if(isset($this->listing) && !$this->listing) {
 	if(isset($this->listing) && !$this->listing) {
 	    return array();
 	    return array();
 	}
 	}
@@ -221,7 +221,7 @@ class abook_database extends addressbook_backend {
                          $this->table, $this->owner);
                          $this->table, $this->owner);
 
 
         $res = $this->dbh->query($query);
         $res = $this->dbh->query($query);
-        
+
         if (DB::isError($res)) {
         if (DB::isError($res)) {
             return $this->set_error(sprintf(_("Database error: %s"),
             return $this->set_error(sprintf(_("Database error: %s"),
                                             DB::errorMessage($res)));
                                             DB::errorMessage($res)));
@@ -249,7 +249,7 @@ class abook_database extends addressbook_backend {
         if (!$this->open()) {
         if (!$this->open()) {
             return false;
             return false;
         }
         }
-         
+
         /* See if user exist already */
         /* See if user exist already */
         $ret = $this->lookup($userdata['nickname']);
         $ret = $this->lookup($userdata['nickname']);
         if (!empty($ret)) {
         if (!empty($ret)) {
@@ -263,9 +263,9 @@ class abook_database extends addressbook_backend {
                          "'%s','%s','%s')",
                          "'%s','%s','%s')",
                          $this->table, $this->owner,
                          $this->table, $this->owner,
                          $this->dbh->quoteString($userdata['nickname']),
                          $this->dbh->quoteString($userdata['nickname']),
-                         $this->dbh->quoteString($userdata['firstname']), 
+                         $this->dbh->quoteString($userdata['firstname']),
                          $this->dbh->quoteString($userdata['lastname']),
                          $this->dbh->quoteString($userdata['lastname']),
-                         $this->dbh->quoteString($userdata['email']), 
+                         $this->dbh->quoteString($userdata['email']),
                          $this->dbh->quoteString($userdata['label']) );
                          $this->dbh->quoteString($userdata['label']) );
 
 
          /* Do the insert */
          /* Do the insert */
@@ -288,7 +288,7 @@ class abook_database extends addressbook_backend {
         if (!$this->open()) {
         if (!$this->open()) {
             return false;
             return false;
         }
         }
-         
+
         /* Create query */
         /* Create query */
         $query = sprintf("DELETE FROM %s WHERE owner='%s' AND (",
         $query = sprintf("DELETE FROM %s WHERE owner='%s' AND (",
                          $this->table, $this->owner);
                          $this->table, $this->owner);
@@ -321,7 +321,7 @@ class abook_database extends addressbook_backend {
         if (!$this->open()) {
         if (!$this->open()) {
             return false;
             return false;
         }
         }
-         
+
          /* See if user exist */
          /* See if user exist */
         $ret = $this->lookup($alias);
         $ret = $this->lookup($alias);
         if (empty($ret)) {
         if (empty($ret)) {
@@ -333,11 +333,11 @@ class abook_database extends addressbook_backend {
         $query = sprintf("UPDATE %s SET nickname='%s', firstname='%s', ".
         $query = sprintf("UPDATE %s SET nickname='%s', firstname='%s', ".
                          "lastname='%s', email='%s', label='%s' ".
                          "lastname='%s', email='%s', label='%s' ".
                          "WHERE owner='%s' AND nickname='%s'",
                          "WHERE owner='%s' AND nickname='%s'",
-                         $this->table, 
+                         $this->table,
                          $this->dbh->quoteString($userdata['nickname']),
                          $this->dbh->quoteString($userdata['nickname']),
-                         $this->dbh->quoteString($userdata['firstname']), 
+                         $this->dbh->quoteString($userdata['firstname']),
                          $this->dbh->quoteString($userdata['lastname']),
                          $this->dbh->quoteString($userdata['lastname']),
-                         $this->dbh->quoteString($userdata['email']), 
+                         $this->dbh->quoteString($userdata['email']),
                          $this->dbh->quoteString($userdata['label']),
                          $this->dbh->quoteString($userdata['label']),
                          $this->owner,
                          $this->owner,
                          $this->dbh->quoteString($alias) );
                          $this->dbh->quoteString($alias) );
@@ -354,6 +354,5 @@ class abook_database extends addressbook_backend {
     }
     }
 } /* End of class abook_database */
 } /* End of class abook_database */
 
 
-
 // vim: et ts=4
 // vim: et ts=4
-?>
+?>

+ 24 - 24
functions/abook_global_file.php

@@ -37,15 +37,15 @@ class abook_global_file extends addressbook_backend {
     function abook_global_file() {
     function abook_global_file() {
         global $address_book_global_filename;
         global $address_book_global_filename;
         $this->global_filename = $address_book_global_filename;
         $this->global_filename = $address_book_global_filename;
-      
+
         $this->sname = _("Global address book");
         $this->sname = _("Global address book");
- 
+
         $this->open(true);
         $this->open(true);
     }
     }
 
 
     /* Open the addressbook file and store the file pointer.
     /* Open the addressbook file and store the file pointer.
-     * Use $file as the file to open, or the class' own 
-     * filename property. If $param is empty and file is  
+     * Use $file as the file to open, or the class' own
+     * filename property. If $param is empty and file is
      * open, do nothing. */
      * open, do nothing. */
     function open($new = false) {
     function open($new = false) {
         $this->error = '';
         $this->error = '';
@@ -54,27 +54,27 @@ class abook_global_file extends addressbook_backend {
         if($this->filehandle && !$new) {
         if($this->filehandle && !$new) {
             return true;
             return true;
         }
         }
- 
+
         /* Check that new file exists */
         /* Check that new file exists */
-        if (! file_exists($this->global_filename) || 
+        if (! file_exists($this->global_filename) ||
             ! is_readable($this->global_filename)) {
             ! is_readable($this->global_filename)) {
             return $this->set_error($this->global_filename . ': ' .
             return $this->set_error($this->global_filename . ': ' .
                 _("No such file or directory"));
                 _("No such file or directory"));
         }
         }
- 
+
         /* Close old file, if any */
         /* Close old file, if any */
         if ($this->filehandle) {
         if ($this->filehandle) {
             $this->close();
             $this->close();
         }
         }
-        
+
         /* Open file, read only. */
         /* Open file, read only. */
         $fh = @fopen($this->global_filename, 'r');
         $fh = @fopen($this->global_filename, 'r');
         $this->writeable  = false;
         $this->writeable  = false;
         if(! $fh) {
         if(! $fh) {
-            return $this->set_error($this->global_filename . ': ' . 
+            return $this->set_error($this->global_filename . ': ' .
                 _("Open failed"));
                 _("Open failed"));
         }
         }
- 
+
         $this->filehandle = &$fh;
         $this->filehandle = &$fh;
         return true;
         return true;
     }
     }
@@ -88,7 +88,7 @@ class abook_global_file extends addressbook_backend {
     }
     }
 
 
     /* ========================== Public ======================== */
     /* ========================== Public ======================== */
-    
+
     /* Search the file */
     /* Search the file */
     function search($expr) {
     function search($expr) {
 
 
@@ -96,19 +96,19 @@ class abook_global_file extends addressbook_backend {
         if(is_array($expr)) {
         if(is_array($expr)) {
             return;
             return;
         }
         }
- 
+
         /* Make regexp from glob'ed expression
         /* Make regexp from glob'ed expression
          * May want to quote other special characters like (, ), -, [, ], etc. */
          * May want to quote other special characters like (, ), -, [, ], etc. */
         $expr = str_replace('?', '.', $expr);
         $expr = str_replace('?', '.', $expr);
         $expr = str_replace('*', '.*', $expr);
         $expr = str_replace('*', '.*', $expr);
- 
+
         $res = array();
         $res = array();
         if(!$this->open()) {
         if(!$this->open()) {
             return false;
             return false;
         }
         }
- 
+
         @rewind($this->filehandle);
         @rewind($this->filehandle);
-        
+
         while ($row = @fgetcsv($this->filehandle, 2048, '|')) {
         while ($row = @fgetcsv($this->filehandle, 2048, '|')) {
             $line = join(' ', $row);
             $line = join(' ', $row);
             if (eregi($expr, $line)) {
             if (eregi($expr, $line)) {
@@ -122,21 +122,21 @@ class abook_global_file extends addressbook_backend {
                                'source'    => &$this->sname);
                                'source'    => &$this->sname);
             }
             }
         }
         }
-        
+
         return $res;
         return $res;
     }
     }
-    
+
     /* Lookup alias */
     /* Lookup alias */
     function lookup($alias) {
     function lookup($alias) {
         if (empty($alias)) {
         if (empty($alias)) {
             return array();
             return array();
         }
         }
- 
+
         $alias = strtolower($alias);
         $alias = strtolower($alias);
-        
+
         $this->open();
         $this->open();
         @rewind($this->filehandle);
         @rewind($this->filehandle);
-        
+
         while ($row = @fgetcsv($this->filehandle, 2048, '|')) {
         while ($row = @fgetcsv($this->filehandle, 2048, '|')) {
             if (strtolower($row[0]) == $alias) {
             if (strtolower($row[0]) == $alias) {
                 return array('nickname'  => $row[0],
                 return array('nickname'  => $row[0],
@@ -149,7 +149,7 @@ class abook_global_file extends addressbook_backend {
                              'source'    => &$this->sname);
                              'source'    => &$this->sname);
             }
             }
         }
         }
-      
+
         return array();
         return array();
     }
     }
 
 
@@ -158,7 +158,7 @@ class abook_global_file extends addressbook_backend {
         $res = array();
         $res = array();
         $this->open();
         $this->open();
         @rewind($this->filehandle);
         @rewind($this->filehandle);
-        
+
         while ($row = @fgetcsv($this->filehandle, 2048, '|')) {
         while ($row = @fgetcsv($this->filehandle, 2048, '|')) {
             $res[] = array('nickname'  => $row[0],
             $res[] = array('nickname'  => $row[0],
                            'name'      => $row[1] . ' ' . $row[2],
                            'name'      => $row[1] . ' ' . $row[2],
@@ -189,6 +189,6 @@ class abook_global_file extends addressbook_backend {
         $this->set_error(_("Can not modify global address book"));
         $this->set_error(_("Can not modify global address book"));
         return false;
         return false;
     }
     }
-     
+
 } /* End of class abook_local_file */
 } /* End of class abook_local_file */
-?>
+?>

+ 29 - 29
functions/abook_ldap_server.php

@@ -90,7 +90,7 @@ class abook_ldap_server extends addressbook_backend {
             else {
             else {
                 $this->sname = $param['name'];
                 $this->sname = $param['name'];
             }
             }
-            
+
             $this->open(true);
             $this->open(true);
         } else {
         } else {
             $this->set_error('Invalid argument to constructor');
             $this->set_error('Invalid argument to constructor');
@@ -101,21 +101,21 @@ class abook_ldap_server extends addressbook_backend {
     /* Open the LDAP server. New connection if $new is true */
     /* Open the LDAP server. New connection if $new is true */
     function open($new = false) {
     function open($new = false) {
         $this->error = '';
         $this->error = '';
-  
+
         /* Connection is already open */
         /* Connection is already open */
         if($this->linkid != false && !$new) {
         if($this->linkid != false && !$new) {
             return true;
             return true;
         }
         }
-  
+
         $this->linkid = @ldap_connect($this->server, $this->port);
         $this->linkid = @ldap_connect($this->server, $this->port);
         if(!$this->linkid) {
         if(!$this->linkid) {
             if(function_exists('ldap_error')) {
             if(function_exists('ldap_error')) {
-                return $this->set_error(ldap_error($this->linkid)); 
+                return $this->set_error(ldap_error($this->linkid));
             } else {
             } else {
                 return $this->set_error('ldap_connect failed');
                 return $this->set_error('ldap_connect failed');
             }
             }
         }
         }
-	
+
 	if(!empty($this->protocol)) {
 	if(!empty($this->protocol)) {
             if(!@ldap_set_option($this->linkid, LDAP_OPT_PROTOCOL_VERSION, $this->protocol)) {
             if(!@ldap_set_option($this->linkid, LDAP_OPT_PROTOCOL_VERSION, $this->protocol)) {
                 if(function_exists('ldap_error')) {
                 if(function_exists('ldap_error')) {
@@ -137,7 +137,7 @@ class abook_ldap_server extends addressbook_backend {
         } else {
         } else {
     	    if(!@ldap_bind($this->linkid)) {
     	    if(!@ldap_bind($this->linkid)) {
         	if(function_exists('ldap_error')) {
         	if(function_exists('ldap_error')) {
-            	    return $this->set_error(ldap_error($this->linkid)); 
+            	    return $this->set_error(ldap_error($this->linkid));
         	} else {
         	} else {
             	    return $this->set_error('anonymous ldap_bind failed');
             	    return $this->set_error('anonymous ldap_bind failed');
         	}
         	}
@@ -145,7 +145,7 @@ class abook_ldap_server extends addressbook_backend {
         }
         }
 
 
         $this->bound = true;
         $this->bound = true;
-        
+
         return true;
         return true;
     }
     }
 
 
@@ -177,64 +177,64 @@ class abook_ldap_server extends addressbook_backend {
         }
         }
     }
     }
 
 
-    
+
     /* ========================== Public ======================== */
     /* ========================== Public ======================== */
 
 
     /* Search the LDAP server */
     /* Search the LDAP server */
     function search($expr) {
     function search($expr) {
-  
+
         /* To be replaced by advanded search expression parsing */
         /* To be replaced by advanded search expression parsing */
         if(is_array($expr)) return false;
         if(is_array($expr)) return false;
-  
+
         /* Encode the expression */
         /* Encode the expression */
         $expr = $this->charset_encode($expr);
         $expr = $this->charset_encode($expr);
         if(strstr($expr, '*') === false) {
         if(strstr($expr, '*') === false) {
             $expr = "*$expr*";
             $expr = "*$expr*";
         }
         }
         $expression = "cn=$expr";
         $expression = "cn=$expr";
-  
+
         /* Make sure connection is there */
         /* Make sure connection is there */
         if(!$this->open()) {
         if(!$this->open()) {
             return false;
             return false;
         }
         }
-  
+
         $sret = @ldap_search($this->linkid, $this->basedn, $expression,
         $sret = @ldap_search($this->linkid, $this->basedn, $expression,
-            array('dn', 'o', 'ou', 'sn', 'givenname', 
+            array('dn', 'o', 'ou', 'sn', 'givenname',
             'cn', 'mail', 'telephonenumber'),
             'cn', 'mail', 'telephonenumber'),
             0, $this->maxrows, $this->timeout);
             0, $this->maxrows, $this->timeout);
-  
+
         /* Should get error from server using the ldap_error() function,
         /* Should get error from server using the ldap_error() function,
          * but it only exist in the PHP LDAP documentation. */
          * but it only exist in the PHP LDAP documentation. */
         if(!$sret) {
         if(!$sret) {
             if(function_exists('ldap_error')) {
             if(function_exists('ldap_error')) {
-                return $this->set_error(ldap_error($this->linkid)); 
+                return $this->set_error(ldap_error($this->linkid));
             } else {
             } else {
-                return $this->set_error('ldap_search failed');       
+                return $this->set_error('ldap_search failed');
             }
             }
         }
         }
-        
+
         if(@ldap_count_entries($this->linkid, $sret) <= 0) {
         if(@ldap_count_entries($this->linkid, $sret) <= 0) {
             return array();
             return array();
         }
         }
-  
+
         /* Get results */
         /* Get results */
         $ret = array();
         $ret = array();
         $returned_rows = 0;
         $returned_rows = 0;
         $res = @ldap_get_entries($this->linkid, $sret);
         $res = @ldap_get_entries($this->linkid, $sret);
         for($i = 0 ; $i < $res['count'] ; $i++) {
         for($i = 0 ; $i < $res['count'] ; $i++) {
             $row = $res[$i];
             $row = $res[$i];
-           
+
             /* Extract data common for all e-mail addresses
             /* Extract data common for all e-mail addresses
              * of an object. Use only the first name */
              * of an object. Use only the first name */
             $nickname = $this->charset_decode($row['dn']);
             $nickname = $this->charset_decode($row['dn']);
             $fullname = $this->charset_decode($row['cn'][0]);
             $fullname = $this->charset_decode($row['cn'][0]);
-           
+
             if(empty($row['telephonenumber'][0])) {
             if(empty($row['telephonenumber'][0])) {
                 $phone = '';
                 $phone = '';
             } else {
             } else {
                 $phone = $this->charset_decode($row['telephonenumber'][0]);
                 $phone = $this->charset_decode($row['telephonenumber'][0]);
             }
             }
-           
+
             if(!empty($row['ou'][0])) {
             if(!empty($row['ou'][0])) {
                 $label = $this->charset_decode($row['ou'][0]);
                 $label = $this->charset_decode($row['ou'][0]);
             }
             }
@@ -243,19 +243,19 @@ class abook_ldap_server extends addressbook_backend {
             } else {
             } else {
                 $label = '';
                 $label = '';
             }
             }
-           
+
             if(empty($row['givenname'][0])) {
             if(empty($row['givenname'][0])) {
                 $firstname = '';
                 $firstname = '';
             } else {
             } else {
                 $firstname = $this->charset_decode($row['givenname'][0]);
                 $firstname = $this->charset_decode($row['givenname'][0]);
             }
             }
-           
+
             if(empty($row['sn'][0])) {
             if(empty($row['sn'][0])) {
                 $surname = '';
                 $surname = '';
             } else {
             } else {
                 $surname = $this->charset_decode($row['sn'][0]);
                 $surname = $this->charset_decode($row['sn'][0]);
             }
             }
-           
+
             /* Add one row to result for each e-mail address */
             /* Add one row to result for each e-mail address */
             if(isset($row['mail']['count'])) {
             if(isset($row['mail']['count'])) {
                 for($j = 0 ; $j < $row['mail']['count'] ; $j++) {
                 for($j = 0 ; $j < $row['mail']['count'] ; $j++) {
@@ -268,10 +268,10 @@ class abook_ldap_server extends addressbook_backend {
                    'phone'     => $phone,
                    'phone'     => $phone,
                    'backend'   => $this->bnum,
                    'backend'   => $this->bnum,
                    'source'    => &$this->sname));
                    'source'    => &$this->sname));
-                    
+
                     // Limit number of hits
                     // Limit number of hits
                     $returned_rows++;
                     $returned_rows++;
-                    if(($returned_rows >= $this->maxrows) && 
+                    if(($returned_rows >= $this->maxrows) &&
                        ($this->maxrows > 0) ) {
                        ($this->maxrows > 0) ) {
                         ldap_free_result($sret);
                         ldap_free_result($sret);
                         return $ret;
                         return $ret;
@@ -280,9 +280,9 @@ class abook_ldap_server extends addressbook_backend {
                 } // for($j ...)
                 } // for($j ...)
 
 
             } // isset($row['mail']['count'])
             } // isset($row['mail']['count'])
- 
+
         }
         }
-  
+
         ldap_free_result($sret);
         ldap_free_result($sret);
         return $ret;
         return $ret;
     } /* end search() */
     } /* end search() */
@@ -297,4 +297,4 @@ class abook_ldap_server extends addressbook_backend {
      *
      *
      * Careful with this -- it could get quite large for big sites. */
      * Careful with this -- it could get quite large for big sites. */
 }
 }
-?>
+?>

+ 41 - 41
functions/abook_local_file.php

@@ -63,7 +63,7 @@ class abook_local_file extends addressbook_backend {
             if(!empty($param['name'])) {
             if(!empty($param['name'])) {
                 $this->sname = $param['name'];
                 $this->sname = $param['name'];
             }
             }
-           
+
             $this->open(true);
             $this->open(true);
         } else {
         } else {
             $this->set_error('Invalid argument to constructor');
             $this->set_error('Invalid argument to constructor');
@@ -71,27 +71,27 @@ class abook_local_file extends addressbook_backend {
     }
     }
 
 
     /* Open the addressbook file and store the file pointer.
     /* Open the addressbook file and store the file pointer.
-     * Use $file as the file to open, or the class' own 
-     * filename property. If $param is empty and file is  
+     * Use $file as the file to open, or the class' own
+     * filename property. If $param is empty and file is
      * open, do nothing. */
      * open, do nothing. */
     function open($new = false) {
     function open($new = false) {
         $this->error = '';
         $this->error = '';
         $file   = $this->filename;
         $file   = $this->filename;
         $create = $this->create;
         $create = $this->create;
-  
+
         /* Return true is file is open and $new is unset */
         /* Return true is file is open and $new is unset */
         if($this->filehandle && !$new) {
         if($this->filehandle && !$new) {
             return true;
             return true;
         }
         }
-  
+
         /* Check that new file exitsts */
         /* Check that new file exitsts */
         if((!(file_exists($file) && is_readable($file))) && !$create) {
         if((!(file_exists($file) && is_readable($file))) && !$create) {
             return $this->set_error("$file: " . _("No such file or directory"));
             return $this->set_error("$file: " . _("No such file or directory"));
         }
         }
-  
+
         /* Close old file, if any */
         /* Close old file, if any */
         if($this->filehandle) { $this->close(); }
         if($this->filehandle) { $this->close(); }
-        
+
         /* Open file. First try to open for reading and writing,
         /* Open file. First try to open for reading and writing,
          * but fall back to read only. */
          * but fall back to read only. */
         umask($this->umask);
         umask($this->umask);
@@ -124,7 +124,7 @@ class abook_local_file extends addressbook_backend {
     /* Lock the datafile - try 20 times in 5 seconds */
     /* Lock the datafile - try 20 times in 5 seconds */
     function lock() {
     function lock() {
         for($i = 0 ; $i < 20 ; $i++) {
         for($i = 0 ; $i < 20 ; $i++) {
-            if(flock($this->filehandle, 2 + 4)) 
+            if(flock($this->filehandle, 2 + 4))
                 return true;
                 return true;
             else
             else
                 usleep(250000);
                 usleep(250000);
@@ -146,7 +146,7 @@ class abook_local_file extends addressbook_backend {
         if(!$newfh) {
         if(!$newfh) {
             return $this->set_error($this->filename. '.tmp:' . _("Open failed"));
             return $this->set_error($this->filename. '.tmp:' . _("Open failed"));
         }
         }
-        
+
         for($i = 0, $cnt=sizeof($rows) ; $i < $cnt ; $i++) {
         for($i = 0, $cnt=sizeof($rows) ; $i < $cnt ; $i++) {
             if(is_array($rows[$i])) {
             if(is_array($rows[$i])) {
                 for($j = 0, $cnt_part=count($rows[$i]) ; $j < $cnt_part ; $j++) {
                 for($j = 0, $cnt_part=count($rows[$i]) ; $j < $cnt_part ; $j++) {
@@ -157,7 +157,7 @@ class abook_local_file extends addressbook_backend {
                     return $this->set_error($this->filename . '.tmp:' . _("Write failed"));
                     return $this->set_error($this->filename . '.tmp:' . _("Write failed"));
                 }
                 }
             }
             }
-        }       
+        }
 
 
         fclose($newfh);
         fclose($newfh);
         if (!@copy($this->filename . '.tmp' , $this->filename)) {
         if (!@copy($this->filename . '.tmp' , $this->filename)) {
@@ -168,26 +168,26 @@ class abook_local_file extends addressbook_backend {
         $this->open(true);
         $this->open(true);
         return true;
         return true;
     }
     }
-    
+
     /* ========================== Public ======================== */
     /* ========================== Public ======================== */
-    
+
     /* Search the file */
     /* Search the file */
     function search($expr) {
     function search($expr) {
 
 
         /* To be replaced by advanded search expression parsing */
         /* To be replaced by advanded search expression parsing */
         if(is_array($expr)) { return; }
         if(is_array($expr)) { return; }
-  
+
         /* Make regexp from glob'ed expression
         /* Make regexp from glob'ed expression
          * May want to quote other special characters like (, ), -, [, ], etc. */
          * May want to quote other special characters like (, ), -, [, ], etc. */
         $expr = str_replace('?', '.', $expr);
         $expr = str_replace('?', '.', $expr);
         $expr = str_replace('*', '.*', $expr);
         $expr = str_replace('*', '.*', $expr);
-  
+
         $res = array();
         $res = array();
         if(!$this->open()) {
         if(!$this->open()) {
             return false;
             return false;
         }
         }
         @rewind($this->filehandle);
         @rewind($this->filehandle);
-        
+
         while ($row = @fgetcsv($this->filehandle, 2048, '|')) {
         while ($row = @fgetcsv($this->filehandle, 2048, '|')) {
             $line = join(' ', $row);
             $line = join(' ', $row);
             if(eregi($expr, $line)) {
             if(eregi($expr, $line)) {
@@ -201,10 +201,10 @@ class abook_local_file extends addressbook_backend {
                     'source'    => &$this->sname));
                     'source'    => &$this->sname));
             }
             }
         }
         }
-        
+
         return $res;
         return $res;
     }
     }
-    
+
     /* Lookup alias */
     /* Lookup alias */
     function lookup($alias) {
     function lookup($alias) {
         if(empty($alias)) {
         if(empty($alias)) {
@@ -212,10 +212,10 @@ class abook_local_file extends addressbook_backend {
         }
         }
 
 
         $alias = strtolower($alias);
         $alias = strtolower($alias);
-        
+
         $this->open();
         $this->open();
         @rewind($this->filehandle);
         @rewind($this->filehandle);
-        
+
         while ($row = @fgetcsv($this->filehandle, 2048, '|')) {
         while ($row = @fgetcsv($this->filehandle, 2048, '|')) {
             if(strtolower($row[0]) == $alias) {
             if(strtolower($row[0]) == $alias) {
                 return array('nickname'  => $row[0],
                 return array('nickname'  => $row[0],
@@ -228,7 +228,7 @@ class abook_local_file extends addressbook_backend {
                   'source'    => &$this->sname);
                   'source'    => &$this->sname);
             }
             }
         }
         }
-        
+
         return array();
         return array();
     }
     }
 
 
@@ -237,7 +237,7 @@ class abook_local_file extends addressbook_backend {
         $res = array();
         $res = array();
         $this->open();
         $this->open();
         @rewind($this->filehandle);
         @rewind($this->filehandle);
-      
+
         while ($row = @fgetcsv($this->filehandle, 2048, '|')) {
         while ($row = @fgetcsv($this->filehandle, 2048, '|')) {
             array_push($res, array('nickname'  => $row[0],
             array_push($res, array('nickname'  => $row[0],
                 'name'      => $row[1] . ' ' . $row[2],
                 'name'      => $row[1] . ' ' . $row[2],
@@ -262,7 +262,7 @@ class abook_local_file extends addressbook_backend {
             return $this->set_error(sprintf(_("User '%s' already exist"),
             return $this->set_error(sprintf(_("User '%s' already exist"),
                    $ret['nickname']));
                    $ret['nickname']));
         }
         }
-  
+
         /* Here is the data to write */
         /* Here is the data to write */
         $data = $this->quotevalue($userdata['nickname']) . '|' .
         $data = $this->quotevalue($userdata['nickname']) . '|' .
                 $this->quotevalue($userdata['firstname']) . '|' .
                 $this->quotevalue($userdata['firstname']) . '|' .
@@ -274,31 +274,31 @@ class abook_local_file extends addressbook_backend {
         $data = ereg_replace("[\r\n]", ' ', $data);
         $data = ereg_replace("[\r\n]", ' ', $data);
         /* Add linefeed at end */
         /* Add linefeed at end */
         $data = $data . "\n";
         $data = $data . "\n";
-  
+
         /* Reopen file, just to be sure */
         /* Reopen file, just to be sure */
         $this->open(true);
         $this->open(true);
         if(!$this->writeable) {
         if(!$this->writeable) {
             return $this->set_error(_("Addressbook is read-only"));
             return $this->set_error(_("Addressbook is read-only"));
         }
         }
-  
+
         /* Lock the file */
         /* Lock the file */
         if(!$this->lock()) {
         if(!$this->lock()) {
             return $this->set_error(_("Could not lock datafile"));
             return $this->set_error(_("Could not lock datafile"));
         }
         }
-  
+
         /* Write */
         /* Write */
         $r = sq_fwrite($this->filehandle, $data);
         $r = sq_fwrite($this->filehandle, $data);
-  
+
         /* Unlock file */
         /* Unlock file */
         $this->unlock();
         $this->unlock();
-  
+
         /* Test write result */
         /* Test write result */
         if($r === FALSE) {
         if($r === FALSE) {
         	/* Fail */
         	/* Fail */
         	$this->set_error(_("Write to addressbook failed"));
         	$this->set_error(_("Write to addressbook failed"));
 		return FALSE;
 		return FALSE;
 	}
 	}
-  
+
         return TRUE;
         return TRUE;
     }
     }
 
 
@@ -307,13 +307,13 @@ class abook_local_file extends addressbook_backend {
         if(!$this->writeable) {
         if(!$this->writeable) {
             return $this->set_error(_("Addressbook is read-only"));
             return $this->set_error(_("Addressbook is read-only"));
         }
         }
-        
+
         /* Lock the file to make sure we're the only process working
         /* Lock the file to make sure we're the only process working
          * on it. */
          * on it. */
         if(!$this->lock()) {
         if(!$this->lock()) {
             return $this->set_error(_("Could not lock datafile"));
             return $this->set_error(_("Could not lock datafile"));
         }
         }
-  
+
         /* Read file into memory, ignoring nicknames to delete */
         /* Read file into memory, ignoring nicknames to delete */
         @rewind($this->filehandle);
         @rewind($this->filehandle);
         $i = 0;
         $i = 0;
@@ -323,13 +323,13 @@ class abook_local_file extends addressbook_backend {
                 $rows[$i++] = $row;
                 $rows[$i++] = $row;
             }
             }
         }
         }
-  
+
         /* Write data back */
         /* Write data back */
         if(!$this->overwrite($rows)) {
         if(!$this->overwrite($rows)) {
             $this->unlock();
             $this->unlock();
             return false;
             return false;
         }
         }
-  
+
         $this->unlock();
         $this->unlock();
         return true;
         return true;
     }
     }
@@ -339,21 +339,21 @@ class abook_local_file extends addressbook_backend {
         if(!$this->writeable) {
         if(!$this->writeable) {
             return $this->set_error(_("Addressbook is read-only"));
             return $this->set_error(_("Addressbook is read-only"));
         }
         }
-  
+
         /* See if user exists */
         /* See if user exists */
         $ret = $this->lookup($alias);
         $ret = $this->lookup($alias);
         if(empty($ret)) {
         if(empty($ret)) {
             return $this->set_error(sprintf(_("User '%s' does not exist"),
             return $this->set_error(sprintf(_("User '%s' does not exist"),
                 $alias));
                 $alias));
         }
         }
-  
+
         /* Lock the file to make sure we're the only process working
         /* Lock the file to make sure we're the only process working
          * on it. */
          * on it. */
         if(!$this->lock()) {
         if(!$this->lock()) {
             return $this->set_error(_("Could not lock datafile"));
             return $this->set_error(_("Could not lock datafile"));
         }
         }
-  
-        /* Read file into memory, modifying the data for the 
+
+        /* Read file into memory, modifying the data for the
          * user identified by $alias */
          * user identified by $alias */
         $this->open(true);
         $this->open(true);
         @rewind($this->filehandle);
         @rewind($this->filehandle);
@@ -366,21 +366,21 @@ class abook_local_file extends addressbook_backend {
                 $rows[$i++] = array(0 => $userdata['nickname'],
                 $rows[$i++] = array(0 => $userdata['nickname'],
                                     1 => $userdata['firstname'],
                                     1 => $userdata['firstname'],
                                     2 => $userdata['lastname'],
                                     2 => $userdata['lastname'],
-                                    3 => $userdata['email'], 
+                                    3 => $userdata['email'],
                                     4 => $userdata['label']);
                                     4 => $userdata['label']);
             }
             }
         }
         }
-  
+
         /* Write data back */
         /* Write data back */
         if(!$this->overwrite($rows)) {
         if(!$this->overwrite($rows)) {
             $this->unlock();
             $this->unlock();
             return false;
             return false;
         }
         }
-  
+
         $this->unlock();
         $this->unlock();
         return true;
         return true;
     }
     }
-     
+
     /* Function for quoting values before saving */
     /* Function for quoting values before saving */
     function quotevalue($value) {
     function quotevalue($value) {
         /* Quote the field if it contains | or ". Double quotes need to
         /* Quote the field if it contains | or ". Double quotes need to
@@ -392,4 +392,4 @@ class abook_local_file extends addressbook_backend {
     }
     }
 
 
 } /* End of class abook_local_file */
 } /* End of class abook_local_file */
-?>
+?>

+ 49 - 48
functions/addressbook.php

@@ -1,4 +1,5 @@
 <?php
 <?php
+
 /**
 /**
  * addressbook.php
  * addressbook.php
  *
  *
@@ -105,7 +106,7 @@ function addressbook_init($showerr = true, $onlylocal = false) {
     $hookReturn = do_hook('abook_init', $abook, $r);
     $hookReturn = do_hook('abook_init', $abook, $r);
     $abook = $hookReturn[1];
     $abook = $hookReturn[1];
     $r = $hookReturn[2];
     $r = $hookReturn[2];
-    
+
     if ($onlylocal) {
     if ($onlylocal) {
         return $abook;
         return $abook;
     }
     }
@@ -135,7 +136,7 @@ function addressbook_init($showerr = true, $onlylocal = false) {
  *   Had to move this function outside of the Addressbook Class
  *   Had to move this function outside of the Addressbook Class
  *   PHP 4.0.4 Seemed to be having problems with inline functions.
  *   PHP 4.0.4 Seemed to be having problems with inline functions.
  *   Note: this can return now since we don't support 4.0.4 anymore.
  *   Note: this can return now since we don't support 4.0.4 anymore.
- */    
+ */
 function addressbook_cmp($a,$b) {
 function addressbook_cmp($a,$b) {
 
 
     if($a['backend'] > $b['backend']) {
     if($a['backend'] > $b['backend']) {
@@ -143,7 +144,7 @@ function addressbook_cmp($a,$b) {
     } else if($a['backend'] < $b['backend']) {
     } else if($a['backend'] < $b['backend']) {
         return -1;
         return -1;
     }
     }
-    
+
     return (strtolower($a['name']) > strtolower($b['name'])) ? 1 : -1;
     return (strtolower($a['name']) > strtolower($b['name'])) ? 1 : -1;
 
 
 }
 }
@@ -162,7 +163,7 @@ class AddressBook {
     var $error       = '';
     var $error       = '';
     var $localbackend = 0;
     var $localbackend = 0;
     var $localbackendname = '';
     var $localbackendname = '';
-    
+
       // Constructor function.
       // Constructor function.
     function AddressBook() {
     function AddressBook() {
         $localbackendname = _("Personal address book");
         $localbackendname = _("Personal address book");
@@ -203,7 +204,7 @@ class AddressBook {
 
 
         $newback->bnum = $this->numbackends;
         $newback->bnum = $this->numbackends;
         $this->backends[$this->numbackends] = $newback;
         $this->backends[$this->numbackends] = $newback;
-        
+
         /* Store ID of first local backend added */
         /* Store ID of first local backend added */
         if ($this->localbackend == 0 && $newback->btype == 'local') {
         if ($this->localbackend == 0 && $newback->btype == 'local') {
             $this->localbackend = $this->numbackends;
             $this->localbackend = $this->numbackends;
@@ -215,7 +216,7 @@ class AddressBook {
 
 
 
 
     /*
     /*
-     * This function takes a $row array as returned by the addressbook 
+     * This function takes a $row array as returned by the addressbook
      * search and returns an e-mail address with the full name or
      * search and returns an e-mail address with the full name or
      * nickname optionally prepended.
      * nickname optionally prepended.
      */
      */
@@ -278,11 +279,11 @@ class AddressBook {
 
 
     /* Return a sorted search */
     /* Return a sorted search */
     function s_search($expression, $bnum = -1) {
     function s_search($expression, $bnum = -1) {
-    
+
         $ret = $this->search($expression, $bnum);
         $ret = $this->search($expression, $bnum);
         if ( is_array( $ret ) ) {
         if ( is_array( $ret ) ) {
             usort($ret, 'addressbook_cmp');
             usort($ret, 'addressbook_cmp');
-        }    
+        }
         return $ret;
         return $ret;
     }
     }
 
 
@@ -292,9 +293,9 @@ class AddressBook {
      *  local backends.
      *  local backends.
      */
      */
     function lookup($alias, $bnum = -1) {
     function lookup($alias, $bnum = -1) {
-    
+
         $ret = array();
         $ret = array();
-    
+
         if ($bnum > -1) {
         if ($bnum > -1) {
             $res = $this->backends[$bnum]->lookup($alias);
             $res = $this->backends[$bnum]->lookup($alias);
             if (is_array($res)) {
             if (is_array($res)) {
@@ -304,7 +305,7 @@ class AddressBook {
                return false;
                return false;
             }
             }
         }
         }
-    
+
         $sel = $this->get_backend_list('local');
         $sel = $this->get_backend_list('local');
         for ($i = 0 ; $i < sizeof($sel) ; $i++) {
         for ($i = 0 ; $i < sizeof($sel) ; $i++) {
             $backend = &$sel[$i];
             $backend = &$sel[$i];
@@ -318,7 +319,7 @@ class AddressBook {
                return false;
                return false;
             }
             }
         }
         }
-        
+
         return $ret;
         return $ret;
     }
     }
 
 
@@ -326,13 +327,13 @@ class AddressBook {
     /* Return all addresses */
     /* Return all addresses */
     function list_addr($bnum = -1) {
     function list_addr($bnum = -1) {
         $ret = array();
         $ret = array();
-        
+
         if ($bnum == -1) {
         if ($bnum == -1) {
             $sel = $this->get_backend_list('local');
             $sel = $this->get_backend_list('local');
         } else {
         } else {
             $sel = array(0 => &$this->backends[$bnum]);
             $sel = array(0 => &$this->backends[$bnum]);
         }
         }
-        
+
         for ($i = 0 ; $i < sizeof($sel) ; $i++) {
         for ($i = 0 ; $i < sizeof($sel) ; $i++) {
             $backend = &$sel[$i];
             $backend = &$sel[$i];
             $backend->error = '';
             $backend->error = '';
@@ -344,7 +345,7 @@ class AddressBook {
                return false;
                return false;
             }
             }
         }
         }
-        
+
         return $ret;
         return $ret;
     }
     }
 
 
@@ -354,7 +355,7 @@ class AddressBook {
      * to, or false if it failed.
      * to, or false if it failed.
      */
      */
     function add($userdata, $bnum) {
     function add($userdata, $bnum) {
-    
+
         /* Validate data */
         /* Validate data */
         if (!is_array($userdata)) {
         if (!is_array($userdata)) {
             $this->error = _("Invalid input data");
             $this->error = _("Invalid input data");
@@ -371,18 +372,18 @@ class AddressBook {
         if (empty($userdata['nickname'])) {
         if (empty($userdata['nickname'])) {
             $userdata['nickname'] = $userdata['email'];
             $userdata['nickname'] = $userdata['email'];
         }
         }
-        
+
         if (eregi('[ \\:\\|\\#\\"\\!]', $userdata['nickname'])) {
         if (eregi('[ \\:\\|\\#\\"\\!]', $userdata['nickname'])) {
             $this->error = _("Nickname contains illegal characters");
             $this->error = _("Nickname contains illegal characters");
             return false;
             return false;
         }
         }
-        
+
         /* Check that specified backend accept new entries */
         /* Check that specified backend accept new entries */
         if (!$this->backends[$bnum]->writeable) {
         if (!$this->backends[$bnum]->writeable) {
             $this->error = _("Addressbook is read-only");
             $this->error = _("Addressbook is read-only");
             return false;
             return false;
         }
         }
-        
+
         /* Add address to backend */
         /* Add address to backend */
         $res = $this->backends[$bnum]->add($userdata);
         $res = $this->backends[$bnum]->add($userdata);
         if ($res) {
         if ($res) {
@@ -391,7 +392,7 @@ class AddressBook {
             $this->error = $this->backends[$bnum]->error;
             $this->error = $this->backends[$bnum]->error;
             return false;
             return false;
         }
         }
-        
+
         return false;  // Not reached
         return false;  // Not reached
     } /* end of add() */
     } /* end of add() */
 
 
@@ -401,23 +402,23 @@ class AddressBook {
      * If $alias is an array, all users in the array are removed.
      * If $alias is an array, all users in the array are removed.
      */
      */
     function remove($alias, $bnum) {
     function remove($alias, $bnum) {
-    
+
         /* Check input */
         /* Check input */
         if (empty($alias)) {
         if (empty($alias)) {
             return true;
             return true;
         }
         }
-        
+
         /* Convert string to single element array */
         /* Convert string to single element array */
         if (!is_array($alias)) {
         if (!is_array($alias)) {
             $alias = array(0 => $alias);
             $alias = array(0 => $alias);
         }
         }
-        
-        /* Check that specified backend is writeable */
+
+        /* Check that specified backend is writable */
         if (!$this->backends[$bnum]->writeable) {
         if (!$this->backends[$bnum]->writeable) {
             $this->error = _("Addressbook is read-only");
             $this->error = _("Addressbook is read-only");
             return false;
             return false;
         }
         }
-        
+
         /* Remove user from backend */
         /* Remove user from backend */
         $res = $this->backends[$bnum]->remove($alias);
         $res = $this->backends[$bnum]->remove($alias);
         if ($res) {
         if ($res) {
@@ -426,7 +427,7 @@ class AddressBook {
             $this->error = $this->backends[$bnum]->error;
             $this->error = $this->backends[$bnum]->error;
             return false;
             return false;
         }
         }
-        
+
         return FALSE;  /* Not reached */
         return FALSE;  /* Not reached */
     } /* end of remove() */
     } /* end of remove() */
 
 
@@ -436,12 +437,12 @@ class AddressBook {
      * If $alias is an array, all users in the array are removed.
      * If $alias is an array, all users in the array are removed.
      */
      */
     function modify($alias, $userdata, $bnum) {
     function modify($alias, $userdata, $bnum) {
-    
+
         /* Check input */
         /* Check input */
         if (empty($alias) || !is_string($alias)) {
         if (empty($alias) || !is_string($alias)) {
             return true;
             return true;
         }
         }
-        
+
         /* Validate data */
         /* Validate data */
         if(!is_array($userdata)) {
         if(!is_array($userdata)) {
             $this->error = _("Invalid input data");
             $this->error = _("Invalid input data");
@@ -455,22 +456,22 @@ class AddressBook {
             $this->error = _("E-mail address is missing");
             $this->error = _("E-mail address is missing");
             return false;
             return false;
         }
         }
-        
+
         if (eregi('[\\: \\|\\#"\\!]', $userdata['nickname'])) {
         if (eregi('[\\: \\|\\#"\\!]', $userdata['nickname'])) {
             $this->error = _("Nickname contains illegal characters");
             $this->error = _("Nickname contains illegal characters");
             return false;
             return false;
         }
         }
-        
+
         if (empty($userdata['nickname'])) {
         if (empty($userdata['nickname'])) {
             $userdata['nickname'] = $userdata['email'];
             $userdata['nickname'] = $userdata['email'];
         }
         }
-        
-        /* Check that specified backend is writeable */
+
+        /* Check that specified backend is writable */
         if (!$this->backends[$bnum]->writeable) {
         if (!$this->backends[$bnum]->writeable) {
             $this->error = _("Addressbook is read-only");;
             $this->error = _("Addressbook is read-only");;
             return false;
             return false;
         }
         }
-        
+
         /* Modify user in backend */
         /* Modify user in backend */
         $res = $this->backends[$bnum]->modify($alias, $userdata);
         $res = $this->backends[$bnum]->modify($alias, $userdata);
         if ($res) {
         if ($res) {
@@ -479,11 +480,11 @@ class AddressBook {
             $this->error = $this->backends[$bnum]->error;
             $this->error = $this->backends[$bnum]->error;
             return false;
             return false;
         }
         }
-        
+
         return FALSE;  /* Not reached */
         return FALSE;  /* Not reached */
     } /* end of modify() */
     } /* end of modify() */
-    
-    
+
+
 } /* End of class Addressbook */
 } /* End of class Addressbook */
 
 
 /**
 /**
@@ -496,7 +497,7 @@ class addressbook_backend {
     var $btype      = 'dummy';
     var $btype      = 'dummy';
     var $bname      = 'dummy';
     var $bname      = 'dummy';
     var $sname      = 'Dummy backend';
     var $sname      = 'Dummy backend';
-    
+
     /*
     /*
      * Variables common for all backends, but that
      * Variables common for all backends, but that
      * should not be changed by the backends.
      * should not be changed by the backends.
@@ -504,40 +505,40 @@ class addressbook_backend {
     var $bnum       = -1;
     var $bnum       = -1;
     var $error      = '';
     var $error      = '';
     var $writeable  = false;
     var $writeable  = false;
-    
+
     function set_error($string) {
     function set_error($string) {
         $this->error = '[' . $this->sname . '] ' . $string;
         $this->error = '[' . $this->sname . '] ' . $string;
         return false;
         return false;
     }
     }
-    
-    
+
+
     /* ========================== Public ======================== */
     /* ========================== Public ======================== */
-    
+
     function search($expression) {
     function search($expression) {
         $this->set_error('search not implemented');
         $this->set_error('search not implemented');
         return false;
         return false;
     }
     }
-    
+
     function lookup($alias) {
     function lookup($alias) {
         $this->set_error('lookup not implemented');
         $this->set_error('lookup not implemented');
         return false;
         return false;
     }
     }
-    
+
     function list_addr() {
     function list_addr() {
         $this->set_error('list_addr not implemented');
         $this->set_error('list_addr not implemented');
         return false;
         return false;
     }
     }
-    
+
     function add($userdata) {
     function add($userdata) {
         $this->set_error('add not implemented');
         $this->set_error('add not implemented');
         return false;
         return false;
     }
     }
-    
+
     function remove($alias) {
     function remove($alias) {
         $this->set_error('delete not implemented');
         $this->set_error('delete not implemented');
         return false;
         return false;
     }
     }
-    
+
     function modify($alias, $newuserdata) {
     function modify($alias, $newuserdata) {
         $this->set_error('modify not implemented');
         $this->set_error('modify not implemented');
         return false;
         return false;
@@ -618,7 +619,7 @@ function get_abook_sort() {
  * @param string $alt_tag alt tag value (string visible to text only browsers)
  * @param string $alt_tag alt tag value (string visible to text only browsers)
  * @param integer $Down sort value when list is sorted ascending
  * @param integer $Down sort value when list is sorted ascending
  * @param integer $Up sort value when list is sorted descending
  * @param integer $Up sort value when list is sorted descending
- * @return string html code with sorting images and urls 
+ * @return string html code with sorting images and urls
  */
  */
 function show_abook_sort_button($abook_sort_order, $alt_tag, $Down, $Up ) {
 function show_abook_sort_button($abook_sort_order, $alt_tag, $Down, $Up ) {
     global $form_url;
     global $form_url;
@@ -656,7 +657,7 @@ if (isset($address_book_global_filename)) {
 }
 }
 
 
 /* Only load database backend if database is configured */
 /* Only load database backend if database is configured */
-if((isset($addrbook_dsn) && !empty($addrbook_dsn)) || 
+if((isset($addrbook_dsn) && !empty($addrbook_dsn)) ||
  (isset($addrbook_global_dsn) && !empty($addrbook_global_dsn)) ) {
  (isset($addrbook_global_dsn) && !empty($addrbook_global_dsn)) ) {
   include_once(SM_PATH . 'functions/abook_database.php');
   include_once(SM_PATH . 'functions/abook_database.php');
 }
 }

+ 30 - 30
functions/attachment_common.php

@@ -91,23 +91,23 @@ function attachment_common_link_text(&$Args)
 {
 {
     /* If there is a text attachment, we would like to create a 'view' button
     /* If there is a text attachment, we would like to create a 'view' button
        that links to the text attachment viewer.
        that links to the text attachment viewer.
-      
+
        $Args[1] = the array of actions
        $Args[1] = the array of actions
-      
+
        Use our plugin name for adding an action
        Use our plugin name for adding an action
        $Args[1]['attachment_common'] = array for href and text
        $Args[1]['attachment_common'] = array for href and text
-      
+
        $Args[1]['attachment_common']['text'] = What is displayed
        $Args[1]['attachment_common']['text'] = What is displayed
        $Args[1]['attachment_common']['href'] = Where it links to
        $Args[1]['attachment_common']['href'] = Where it links to
-      
+
        This sets the 'href' of this plugin for a new link. */
        This sets the 'href' of this plugin for a new link. */
     sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
     sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
 
 
     $Args[1]['attachment_common']['href'] = SM_PATH . 'src/view_text.php?'. $QUERY_STRING;
     $Args[1]['attachment_common']['href'] = SM_PATH . 'src/view_text.php?'. $QUERY_STRING;
     $Args[1]['attachment_common']['href'] =
     $Args[1]['attachment_common']['href'] =
-          set_url_var($Args[1]['attachment_common']['href'], 
+          set_url_var($Args[1]['attachment_common']['href'],
 	  'ent_id',$Args[5]);
 	  'ent_id',$Args[5]);
-  
+
     /* The link that we created needs a name.  "view" will be displayed for
     /* The link that we created needs a name.  "view" will be displayed for
        all text attachments handled by this plugin. */
        all text attachments handled by this plugin. */
     $Args[1]['attachment_common']['text'] = _("view");
     $Args[1]['attachment_common']['text'] = _("view");
@@ -116,7 +116,7 @@ function attachment_common_link_text(&$Args)
        Where that link points to can be changed.  Just in case the link above
        Where that link points to can be changed.  Just in case the link above
        for viewing text attachments is not the same as the default link for
        for viewing text attachments is not the same as the default link for
        this file, we'll change it.
        this file, we'll change it.
-      
+
        This is a lot better in the image links, since the defaultLink will just
        This is a lot better in the image links, since the defaultLink will just
        download the image, but the one that we set it to will format the page
        download the image, but the one that we set it to will format the page
        to have an image tag in the center (looking a lot like this text viewer) */
        to have an image tag in the center (looking a lot like this text viewer) */
@@ -132,11 +132,11 @@ function attachment_common_link_message(&$Args)
        all text attachments handled by this plugin. */
        all text attachments handled by this plugin. */
     $Args[1]['attachment_common']['text'] = _("view");
     $Args[1]['attachment_common']['text'] = _("view");
 
 
-    $Args[6] = $Args[1]['attachment_common']['href'];    
+    $Args[6] = $Args[1]['attachment_common']['href'];
 }
 }
 
 
 
 
-function attachment_common_link_html(&$Args) 
+function attachment_common_link_html(&$Args)
 {
 {
     sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
     sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
 
 
@@ -144,7 +144,7 @@ function attachment_common_link_html(&$Args)
        /* why use the overridetype? can this be removed */
        /* why use the overridetype? can this be removed */
        '&amp;override_type0=text&amp;override_type1=html';
        '&amp;override_type0=text&amp;override_type1=html';
     $Args[1]['attachment_common']['href'] =
     $Args[1]['attachment_common']['href'] =
-          set_url_var($Args[1]['attachment_common']['href'], 
+          set_url_var($Args[1]['attachment_common']['href'],
 	  'ent_id',$Args[5]);
 	  'ent_id',$Args[5]);
 
 
     $Args[1]['attachment_common']['text'] = _("view");
     $Args[1]['attachment_common']['text'] = _("view");
@@ -157,20 +157,20 @@ function attachment_common_link_image(&$Args)
     global $attachment_common_show_images, $attachment_common_show_images_list;
     global $attachment_common_show_images, $attachment_common_show_images_list;
 
 
     sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
     sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
-   
+
     $info['passed_id'] = $Args[3];
     $info['passed_id'] = $Args[3];
     $info['mailbox'] = $Args[4];
     $info['mailbox'] = $Args[4];
     $info['ent_id'] = $Args[5];
     $info['ent_id'] = $Args[5];
-    
+
     $attachment_common_show_images_list[] = $info;
     $attachment_common_show_images_list[] = $info;
-    
+
     $Args[1]['attachment_common']['href'] = SM_PATH . 'src/image.php?'. $QUERY_STRING;
     $Args[1]['attachment_common']['href'] = SM_PATH . 'src/image.php?'. $QUERY_STRING;
     $Args[1]['attachment_common']['href'] =
     $Args[1]['attachment_common']['href'] =
-          set_url_var($Args[1]['attachment_common']['href'], 
+          set_url_var($Args[1]['attachment_common']['href'],
 	  'ent_id',$Args[5]);
 	  'ent_id',$Args[5]);
-  
+
     $Args[1]['attachment_common']['text'] = _("view");
     $Args[1]['attachment_common']['text'] = _("view");
-    
+
     $Args[6] = $Args[1]['attachment_common']['href'];
     $Args[6] = $Args[1]['attachment_common']['href'];
 
 
 }
 }
@@ -179,14 +179,14 @@ function attachment_common_link_image(&$Args)
 function attachment_common_link_vcard(&$Args)
 function attachment_common_link_vcard(&$Args)
 {
 {
     sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
     sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
- 
+
     $Args[1]['attachment_common']['href'] = SM_PATH . 'src/vcard.php?'. $QUERY_STRING;
     $Args[1]['attachment_common']['href'] = SM_PATH . 'src/vcard.php?'. $QUERY_STRING;
     $Args[1]['attachment_common']['href'] =
     $Args[1]['attachment_common']['href'] =
-          set_url_var($Args[1]['attachment_common']['href'], 
+          set_url_var($Args[1]['attachment_common']['href'],
 	  'ent_id',$Args[5]);
 	  'ent_id',$Args[5]);
-  
+
     $Args[1]['attachment_common']['text'] = _("Business Card");
     $Args[1]['attachment_common']['text'] = _("Business Card");
-  
+
     $Args[6] = $Args[1]['attachment_common']['href'];
     $Args[6] = $Args[1]['attachment_common']['href'];
 }
 }
 
 
@@ -194,23 +194,23 @@ function attachment_common_link_vcard(&$Args)
 function attachment_common_octet_stream(&$Args)
 function attachment_common_octet_stream(&$Args)
 {
 {
     global $FileExtensionToMimeType;
     global $FileExtensionToMimeType;
-   
+
     do_hook('attachment_common-load_mime_types');
     do_hook('attachment_common-load_mime_types');
-   
+
     ereg('\\.([^\\.]+)$', $Args[7], $Regs);
     ereg('\\.([^\\.]+)$', $Args[7], $Regs);
-  
+
     $Ext = strtolower($Regs[1]);
     $Ext = strtolower($Regs[1]);
-   
+
     if ($Ext == '' || ! isset($FileExtensionToMimeType[$Ext]))
     if ($Ext == '' || ! isset($FileExtensionToMimeType[$Ext]))
-        return;       
-   
-    $Ret = do_hook('attachment ' . $FileExtensionToMimeType[$Ext], 
-        $Args[1], $Args[2], $Args[3], $Args[4], $Args[5], $Args[6], 
+        return;
+
+    $Ret = do_hook('attachment ' . $FileExtensionToMimeType[$Ext],
+        $Args[1], $Args[2], $Args[3], $Args[4], $Args[5], $Args[6],
         $Args[7], $Args[8], $Args[9]);
         $Args[7], $Args[8], $Args[9]);
-       
+
     foreach ($Ret as $a => $b) {
     foreach ($Ret as $a => $b) {
         $Args[$a] = $b;
         $Args[$a] = $b;
     }
     }
 }
 }
 
 
-?>
+?>

+ 8 - 8
functions/auth.php

@@ -42,16 +42,16 @@ function is_logged_in() {
     if ( sqsession_is_registered('user_is_logged_in') ) {
     if ( sqsession_is_registered('user_is_logged_in') ) {
         return;
         return;
     } else {
     } else {
-        global $PHP_SELF, $session_expired_post, 
+        global $PHP_SELF, $session_expired_post,
 	       $session_expired_location, $squirrelmail_language;
 	       $session_expired_location, $squirrelmail_language;
 
 
         /*  First we store some information in the new session to prevent
         /*  First we store some information in the new session to prevent
          *  information-loss.
          *  information-loss.
          */
          */
-	 
+
 	$session_expired_post = $_POST;
 	$session_expired_post = $_POST;
         $session_expired_location = $PHP_SELF;
         $session_expired_location = $PHP_SELF;
-        if (!sqsession_is_registered('session_expired_post')) {    
+        if (!sqsession_is_registered('session_expired_post')) {
            sqsession_register($session_expired_post,'session_expired_post');
            sqsession_register($session_expired_post,'session_expired_post');
         }
         }
         if (!sqsession_is_registered('session_expired_location')) {
         if (!sqsession_is_registered('session_expired_location')) {
@@ -98,7 +98,7 @@ function cram_md5_response ($username,$password,$challenge) {
  */
  */
 function digest_md5_response ($username,$password,$challenge,$service,$host) {
 function digest_md5_response ($username,$password,$challenge,$service,$host) {
   $result=digest_md5_parse_challenge($challenge);
   $result=digest_md5_parse_challenge($challenge);
-  
+
 // verify server supports qop=auth
 // verify server supports qop=auth
   // $qop = explode(",",$result['qop']);
   // $qop = explode(",",$result['qop']);
   //if (!in_array("auth",$qop)) {
   //if (!in_array("auth",$qop)) {
@@ -139,7 +139,7 @@ function digest_md5_response ($username,$password,$challenge,$service,$host) {
   $reply .= ',qop=' . $qop_value;
   $reply .= ',qop=' . $qop_value;
   $reply = base64_encode($reply);
   $reply = base64_encode($reply);
   return $reply . "\r\n";
   return $reply . "\r\n";
- 
+
 }
 }
 
 
 /**
 /**
@@ -219,14 +219,14 @@ function hmac_md5($data, $key='') {
     return $hmac;
     return $hmac;
 }
 }
 
 
-/** 
+/**
  * Fillin user and password based on SMTP auth settings.
  * Fillin user and password based on SMTP auth settings.
  *
  *
  * @param string $user Reference to SMTP username
  * @param string $user Reference to SMTP username
  * @param string $pass Reference to SMTP password (unencrypted)
  * @param string $pass Reference to SMTP password (unencrypted)
  */
  */
 function get_smtp_user(&$user, &$pass) {
 function get_smtp_user(&$user, &$pass) {
-    global $username, $smtp_auth_mech, 
+    global $username, $smtp_auth_mech,
            $smtp_sitewide_user, $smtp_sitewide_pass;
            $smtp_sitewide_user, $smtp_sitewide_pass;
 
 
     if ($smtp_auth_mech == 'none') {
     if ($smtp_auth_mech == 'none') {
@@ -242,4 +242,4 @@ function get_smtp_user(&$user, &$pass) {
     }
     }
 }
 }
 
 
-?>
+?>

+ 1 - 1
functions/constants.php

@@ -55,4 +55,4 @@ define('SMPREF_JS_AUTODETECT', 2);
 
 
 do_hook('loading_constants');
 do_hook('loading_constants');
 
 
-?>
+?>

+ 1 - 1
functions/db_prefs.php

@@ -397,4 +397,4 @@ function getSig($data_dir, $username, $number) {
 }
 }
 
 
 // vim: et ts=4
 // vim: et ts=4
-?>
+?>

+ 28 - 28
functions/global.php

@@ -6,9 +6,9 @@
  * Copyright (c) 1999-2004 The SquirrelMail Project Team
  * Copyright (c) 1999-2004 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  *
- * This includes code to update < 4.1.0 globals to the newer format 
+ * This includes code to update < 4.1.0 globals to the newer format
  * It also has some session register functions that work across various
  * It also has some session register functions that work across various
- * php versions. 
+ * php versions.
  *
  *
  * @version $Id$
  * @version $Id$
  * @package squirrelmail
  * @package squirrelmail
@@ -18,10 +18,10 @@
 require_once(SM_PATH . 'config/config.php');
 require_once(SM_PATH . 'config/config.php');
 
 
 /** set the name of the session cookie */
 /** set the name of the session cookie */
-if(isset($session_name) && $session_name) {  
-    ini_set('session.name' , $session_name);  
-} else {  
-    ini_set('session.name' , 'SQMSESSID');  
+if(isset($session_name) && $session_name) {
+    ini_set('session.name' , $session_name);
+} else {
+    ini_set('session.name' , 'SQMSESSID');
 }
 }
 
 
 /** If magic_quotes_runtime is on, SquirrelMail breaks in new and creative ways.
 /** If magic_quotes_runtime is on, SquirrelMail breaks in new and creative ways.
@@ -54,23 +54,23 @@ if (get_magic_quotes_gpc()) {
 
 
 $_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']);
 $_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']);
 
 
-/** 
- * returns true if current php version is at mimimum a.b.c 
- * 
+/**
+ * returns true if current php version is at mimimum a.b.c
+ *
  * Called: check_php_version(4,1)
  * Called: check_php_version(4,1)
  * @param int a major version number
  * @param int a major version number
  * @param int b minor version number
  * @param int b minor version number
  * @param int c release number
  * @param int c release number
  * @return bool
  * @return bool
  */
  */
-function check_php_version ($a = '0', $b = '0', $c = '0')             
+function check_php_version ($a = '0', $b = '0', $c = '0')
 {
 {
     return version_compare ( PHP_VERSION, "$a.$b.$c", 'ge' );
     return version_compare ( PHP_VERSION, "$a.$b.$c", 'ge' );
 }
 }
 
 
 /**
 /**
- * returns true if the current internal SM version is at minimum a.b.c 
- * These are plain integer comparisons, as our internal version is 
+ * returns true if the current internal SM version is at minimum a.b.c
+ * These are plain integer comparisons, as our internal version is
  * constructed by us, as an array of 3 ints.
  * constructed by us, as an array of 3 ints.
  *
  *
  * Called: check_sm_version(1,3,3)
  * Called: check_sm_version(1,3,3)
@@ -90,8 +90,8 @@ function check_sm_version($a = 0, $b = 0, $c = 0)
            $SQM_INTERNAL_VERSION[1] == $b &&
            $SQM_INTERNAL_VERSION[1] == $b &&
            $SQM_INTERNAL_VERSION[2] < $c ) ) {
            $SQM_INTERNAL_VERSION[2] < $c ) ) {
         return FALSE;
         return FALSE;
-    } 
-    return TRUE;  
+    }
+    return TRUE;
 }
 }
 
 
 
 
@@ -123,8 +123,8 @@ function sqsession_register ($var, $name) {
 
 
     sqsession_is_active();
     sqsession_is_active();
 
 
-    $_SESSION["$name"] = $var; 
-    
+    $_SESSION["$name"] = $var;
+
     session_register("$name");
     session_register("$name");
 }
 }
 
 
@@ -138,7 +138,7 @@ function sqsession_unregister ($name) {
     sqsession_is_active();
     sqsession_is_active();
 
 
     unset($_SESSION[$name]);
     unset($_SESSION[$name]);
-    
+
     session_unregister("$name");
     session_unregister("$name");
 }
 }
 
 
@@ -151,11 +151,11 @@ function sqsession_unregister ($name) {
 function sqsession_is_registered ($name) {
 function sqsession_is_registered ($name) {
     $test_name = &$name;
     $test_name = &$name;
     $result = false;
     $result = false;
-    
+
     if (isset($_SESSION[$test_name])) {
     if (isset($_SESSION[$test_name])) {
         $result = true;
         $result = true;
     }
     }
-    
+
     return $result;
     return $result;
 }
 }
 
 
@@ -170,14 +170,14 @@ define('SQ_FORM',6);
 
 
 /**
 /**
  * Search for the var $name in $_SESSION, $_POST, $_GET,
  * Search for the var $name in $_SESSION, $_POST, $_GET,
- * $_COOKIE, or $_SERVER and set it in provided var. 
+ * $_COOKIE, or $_SERVER and set it in provided var.
  *
  *
  * If $search is not provided,  or == SQ_INORDER, it will search
  * If $search is not provided,  or == SQ_INORDER, it will search
  * $_SESSION, then $_POST, then $_GET. Otherwise,
  * $_SESSION, then $_POST, then $_GET. Otherwise,
- * use one of the defined constants to look for 
+ * use one of the defined constants to look for
  * a var in one place specifically.
  * a var in one place specifically.
  *
  *
- * Note: $search is an int value equal to one of the 
+ * Note: $search is an int value equal to one of the
  * constants defined above.
  * constants defined above.
  *
  *
  * example:
  * example:
@@ -196,8 +196,8 @@ function sqgetGlobalVar($name, &$value, $search = SQ_INORDER) {
        enclosing them in quotes will cause them to evaluate
        enclosing them in quotes will cause them to evaluate
        as strings. */
        as strings. */
     switch ($search) {
     switch ($search) {
-        /* we want the default case to be first here,  
-	   so that if a valid value isn't specified, 
+        /* we want the default case to be first here,
+	   so that if a valid value isn't specified,
 	   all three arrays will be searched. */
 	   all three arrays will be searched. */
       default:
       default:
       case SQ_INORDER: // check session, post, get
       case SQ_INORDER: // check session, post, get
@@ -220,13 +220,13 @@ function sqgetGlobalVar($name, &$value, $search = SQ_INORDER) {
         if ( isset($_GET[$name]) ) {
         if ( isset($_GET[$name]) ) {
             $value = $_GET[$name];
             $value = $_GET[$name];
             return TRUE;
             return TRUE;
-        } 
+        }
         /* NO IF HERE. FOR SQ_INORDER CASE, EXIT after GET */
         /* NO IF HERE. FOR SQ_INORDER CASE, EXIT after GET */
         break;
         break;
       case SQ_COOKIE:
       case SQ_COOKIE:
         if ( isset($_COOKIE[$name]) ) {
         if ( isset($_COOKIE[$name]) ) {
             $value = $_COOKIE[$name];
             $value = $_COOKIE[$name];
-            return TRUE; 
+            return TRUE;
         }
         }
         break;
         break;
       case SQ_SERVER:
       case SQ_SERVER:
@@ -278,7 +278,7 @@ function sqsession_destroy() {
  */
  */
 
 
 function sqsession_is_active() {
 function sqsession_is_active() {
-    
+
     $sessid = session_id();
     $sessid = session_id();
     if ( empty( $sessid ) ) {
     if ( empty( $sessid ) ) {
         session_start();
         session_start();
@@ -286,4 +286,4 @@ function sqsession_is_active() {
 }
 }
 
 
 // vim: et ts=4
 // vim: et ts=4
-?>
+?>

+ 5 - 5
functions/html.php

@@ -51,7 +51,7 @@ function html_tag( $tag,                // Tag to output
         }
         }
 
 
         if ( $bgcolor <> '' ) {
         if ( $bgcolor <> '' ) {
-            $bgc = " bgcolor=\"$bgcolor\""; 
+            $bgc = " bgcolor=\"$bgcolor\"";
         }
         }
 
 
         switch ( $align ) {
         switch ( $align ) {
@@ -84,7 +84,7 @@ function html_tag( $tag,                // Tag to output
             $ret .= ">$val</$tag>";
             $ret .= ">$val</$tag>";
         } else {
         } else {
             $ret .= '>';
             $ret .= '>';
-        } 
+        }
 
 
         return( $ret );
         return( $ret );
     }
     }
@@ -100,7 +100,7 @@ function html_tag( $tag,                // Tag to output
                        '/.+(\\?'.$var.')=(.*)$/AU',     /* at front and only var */
                        '/.+(\\?'.$var.')=(.*)$/AU',     /* at front and only var */
                        '/.+(\\&'.$var.')=(.*)$/AU'      /* at the end */
                        '/.+(\\&'.$var.')=(.*)$/AU'      /* at the end */
                      );
                      );
-	preg_replace('/&amp;/','&',$url);	     
+	preg_replace('/&amp;/','&',$url);
         switch (true) {
         switch (true) {
             case (preg_match($pat_a[0],$url,$regs)):
             case (preg_match($pat_a[0],$url,$regs)):
                 $k = $regs[1];
                 $k = $regs[1];
@@ -151,7 +151,7 @@ function html_tag( $tag,                // Tag to output
     function echo_template_var($var, $format_ar = array() ) {
     function echo_template_var($var, $format_ar = array() ) {
         $frm_last = count($format_ar) -1;
         $frm_last = count($format_ar) -1;
 
 
-        if (isset($format_ar[0])) echo $format_ar[0]; 
+        if (isset($format_ar[0])) echo $format_ar[0];
             $i = 1;
             $i = 1;
 
 
         switch (true) {
         switch (true) {
@@ -179,4 +179,4 @@ function html_tag( $tag,                // Tag to output
             echo $format_ar[$frm_last];
             echo $format_ar[$frm_last];
         }
         }
     }
     }
-?>
+?>

+ 46 - 46
functions/i18n.php

@@ -27,7 +27,7 @@ require_once(SM_PATH . 'functions/global.php');
  * If Japanese translation is used - function returns string converted to euc-jp
  * If Japanese translation is used - function returns string converted to euc-jp
  * If iconv or recode functions are enabled and translation uses utf-8 - function returns utf-8 encoded string.
  * If iconv or recode functions are enabled and translation uses utf-8 - function returns utf-8 encoded string.
  * If $charset is not supported - function returns unconverted string.
  * If $charset is not supported - function returns unconverted string.
- * 
+ *
  * sanitizing of html tags is also done by this function.
  * sanitizing of html tags is also done by this function.
  *
  *
  * @param string $charset
  * @param string $charset
@@ -62,8 +62,8 @@ function charset_decode ($charset, $string) {
               $charset = "iso-8859-8";
               $charset = "iso-8859-8";
 
 
     /*
     /*
-     * Recode converts html special characters automatically if you use 
-     * 'charset..html' decoding. There is no documented way to put -d option 
+     * Recode converts html special characters automatically if you use
+     * 'charset..html' decoding. There is no documented way to put -d option
      * into php recode function call.
      * into php recode function call.
      */
      */
     if ( $use_php_recode ) {
     if ( $use_php_recode ) {
@@ -89,7 +89,7 @@ function charset_decode ($charset, $string) {
     // If we don't use recode and iconv, we'll do it old way.
     // If we don't use recode and iconv, we'll do it old way.
 
 
     /* All HTML special characters are 7 bit and can be replaced first */
     /* All HTML special characters are 7 bit and can be replaced first */
-    
+
     $string = htmlspecialchars ($string);
     $string = htmlspecialchars ($string);
 
 
     /* controls cpu and memory intensive decoding cycles */
     /* controls cpu and memory intensive decoding cycles */
@@ -112,7 +112,7 @@ function charset_decode ($charset, $string) {
  * @param string $string
  * @param string $string
  * @param string $charset
  * @param string $charset
  * @param boolean $htmlencode keep htmlspecialchars encoding
  * @param boolean $htmlencode keep htmlspecialchars encoding
- * @param string 
+ * @param string
  */
  */
 function charset_encode($string,$charset,$htmlencode=true) {
 function charset_encode($string,$charset,$htmlencode=true) {
   global $default_charset;
   global $default_charset;
@@ -159,7 +159,7 @@ function charset_convert($in_charset,$string,$out_charset,$htmlencode=true) {
 function fixcharset($charset) {
 function fixcharset($charset) {
     // minus removed from function names
     // minus removed from function names
     $charset=str_replace('-','_',$charset);
     $charset=str_replace('-','_',$charset);
-    
+
     // windows-125x and cp125x charsets
     // windows-125x and cp125x charsets
     $charset=str_replace('windows_','cp',$charset);
     $charset=str_replace('windows_','cp',$charset);
 
 
@@ -178,18 +178,18 @@ function fixcharset($charset) {
  * if $do_search is true, then scan the browser information
  * if $do_search is true, then scan the browser information
  * for a possible language that we know
  * for a possible language that we know
  *
  *
- * Function sets system locale environment (LC_ALL, LANG, LANGUAGE), 
+ * Function sets system locale environment (LC_ALL, LANG, LANGUAGE),
  * gettext translation bindings and html header information.
  * gettext translation bindings and html header information.
  *
  *
  * Function returns error codes, if there is some fatal error.
  * Function returns error codes, if there is some fatal error.
- *  0 = no error, 
- *  1 = mbstring support is not present, 
+ *  0 = no error,
+ *  1 = mbstring support is not present,
  *  2 = mbstring support is not present, user's translation reverted to en_US.
  *  2 = mbstring support is not present, user's translation reverted to en_US.
  *
  *
  * @param string $sm_language translation used by user's interface
  * @param string $sm_language translation used by user's interface
  * @param bool $do_search use browser's preferred language detection functions. Defaults to false.
  * @param bool $do_search use browser's preferred language detection functions. Defaults to false.
  * @param bool $default set $sm_language to $squirrelmail_default_language if language detection fails or language is not set. Defaults to false.
  * @param bool $default set $sm_language to $squirrelmail_default_language if language detection fails or language is not set. Defaults to false.
- * @return int function execution error codes. 
+ * @return int function execution error codes.
  */
  */
 function set_up_language($sm_language, $do_search = false, $default = false) {
 function set_up_language($sm_language, $do_search = false, $default = false) {
 
 
@@ -208,13 +208,13 @@ function set_up_language($sm_language, $do_search = false, $default = false) {
     if ($do_search && ! $sm_language && isset($accept_lang)) {
     if ($do_search && ! $sm_language && isset($accept_lang)) {
         $sm_language = substr($accept_lang, 0, 2);
         $sm_language = substr($accept_lang, 0, 2);
     }
     }
-    
+
     if ((!$sm_language||$default) && isset($squirrelmail_default_language)) {
     if ((!$sm_language||$default) && isset($squirrelmail_default_language)) {
         $squirrelmail_language = $squirrelmail_default_language;
         $squirrelmail_language = $squirrelmail_default_language;
         $sm_language = $squirrelmail_default_language;
         $sm_language = $squirrelmail_default_language;
     }
     }
     $sm_notAlias = $sm_language;
     $sm_notAlias = $sm_language;
- 
+
     // Catching removed translation
     // Catching removed translation
     // System reverts to English translation if user prefs contain translation
     // System reverts to English translation if user prefs contain translation
     // that is not available in $languages array
     // that is not available in $languages array
@@ -253,7 +253,7 @@ function set_up_language($sm_language, $do_search = false, $default = false) {
         setlocale(LC_ALL, $longlocale);
         setlocale(LC_ALL, $longlocale);
 
 
         // Set text direction/alignment variables
         // Set text direction/alignment variables
-        if (isset($languages[$sm_notAlias]['DIR']) && 
+        if (isset($languages[$sm_notAlias]['DIR']) &&
             $languages[$sm_notAlias]['DIR'] == 'rtl') {
             $languages[$sm_notAlias]['DIR'] == 'rtl') {
           /**
           /**
            * Text direction
            * Text direction
@@ -350,7 +350,7 @@ if (! isset($squirrelmail_language)) {
  *
  *
  * Structure of array:
  * Structure of array:
  * $languages['language']['variable'] = 'value'
  * $languages['language']['variable'] = 'value'
- * 
+ *
  * Possible 'variable' names:
  * Possible 'variable' names:
  *  NAME      - Translation name in English
  *  NAME      - Translation name in English
  *  CHARSET   - Encoding used by translation
  *  CHARSET   - Encoding used by translation
@@ -359,7 +359,7 @@ if (! isset($squirrelmail_language)) {
  *  LOCALE    - Full locale name (in xx_XX.charset format)
  *  LOCALE    - Full locale name (in xx_XX.charset format)
  *  DIR       - Text direction. Used to define Right-to-Left languages. Possible values 'rtl' or 'ltr'. If undefined - defaults to 'ltr'
  *  DIR       - Text direction. Used to define Right-to-Left languages. Possible values 'rtl' or 'ltr'. If undefined - defaults to 'ltr'
  *  XTRA_CODE - translation uses special functions. See doc/i18n.txt
  *  XTRA_CODE - translation uses special functions. See doc/i18n.txt
- * 
+ *
  * Each 'language' definition requires NAME+CHARSET or ALIAS variables.
  * Each 'language' definition requires NAME+CHARSET or ALIAS variables.
  *
  *
  * @name $languages
  * @name $languages
@@ -713,7 +713,7 @@ function japanese_xtra() {
                 $detect_encoding == 'EUC-JP' ||
                 $detect_encoding == 'EUC-JP' ||
                 $detect_encoding == 'SJIS' ||
                 $detect_encoding == 'SJIS' ||
                 $detect_encoding == 'UTF-8') {
                 $detect_encoding == 'UTF-8') {
-                
+
                 $ret = mb_convert_kana(mb_convert_encoding($ret, 'EUC-JP', 'AUTO'), "KV");
                 $ret = mb_convert_kana(mb_convert_encoding($ret, 'EUC-JP', 'AUTO'), "KV");
             }
             }
             break;
             break;
@@ -723,13 +723,13 @@ function japanese_xtra() {
                 $detect_encoding == 'EUC-JP' ||
                 $detect_encoding == 'EUC-JP' ||
                 $detect_encoding == 'SJIS' ||
                 $detect_encoding == 'SJIS' ||
                 $detect_encoding == 'UTF-8') {
                 $detect_encoding == 'UTF-8') {
-                
+
                 $ret = mb_convert_encoding(mb_convert_kana($ret, "KV"), 'JIS', 'AUTO');
                 $ret = mb_convert_encoding(mb_convert_kana($ret, "KV"), 'JIS', 'AUTO');
             }
             }
             break;
             break;
         case 'strimwidth':
         case 'strimwidth':
             $width = func_get_arg(2);
             $width = func_get_arg(2);
-            $ret = mb_strimwidth($ret, 0, $width, '...'); 
+            $ret = mb_strimwidth($ret, 0, $width, '...');
             break;
             break;
         case 'encodeheader':
         case 'encodeheader':
             $result = '';
             $result = '';
@@ -744,7 +744,7 @@ function japanese_xtra() {
                         if ($prevcsize == 1) {
                         if ($prevcsize == 1) {
                             $result .= $tmpstr;
                             $result .= $tmpstr;
                         } else {
                         } else {
-                            $result .= str_replace(' ', '', 
+                            $result .= str_replace(' ', '',
                                                    mb_encode_mimeheader($tmpstr,'iso-2022-jp','B',''));
                                                    mb_encode_mimeheader($tmpstr,'iso-2022-jp','B',''));
                         }
                         }
                         $tmpstr = $tmp;
                         $tmpstr = $tmp;
@@ -788,23 +788,23 @@ function japanese_xtra() {
             $no_end = "\x5c\x24\x28\x5b\x7b\xa1\xf2\x5c\xa1\xc6\xa1\xc8\xa1\xd2\xa1" .
             $no_end = "\x5c\x24\x28\x5b\x7b\xa1\xf2\x5c\xa1\xc6\xa1\xc8\xa1\xd2\xa1" .
                 "\xd4\xa1\xd6\xa1\xd8\xa1\xda\xa1\xcc\xa1\xf0\xa1\xca\xa1\xce\xa1\xd0\xa1\xef";
                 "\xd4\xa1\xd6\xa1\xd8\xa1\xda\xa1\xcc\xa1\xf0\xa1\xca\xa1\xce\xa1\xd0\xa1\xef";
             $wrap = func_get_arg(2);
             $wrap = func_get_arg(2);
-            
-            if (strlen($ret) >= $wrap && 
+
+            if (strlen($ret) >= $wrap &&
                 substr($ret, 0, 1) != '>' &&
                 substr($ret, 0, 1) != '>' &&
                 strpos($ret, 'http://') === FALSE &&
                 strpos($ret, 'http://') === FALSE &&
                 strpos($ret, 'https://') === FALSE &&
                 strpos($ret, 'https://') === FALSE &&
                 strpos($ret, 'ftp://') === FALSE) {
                 strpos($ret, 'ftp://') === FALSE) {
-                
+
                 $ret = mb_convert_kana($ret, "KV");
                 $ret = mb_convert_kana($ret, "KV");
 
 
                 $line_new = '';
                 $line_new = '';
                 $ptr = 0;
                 $ptr = 0;
-                
+
                 while ($ptr < strlen($ret) - 1) {
                 while ($ptr < strlen($ret) - 1) {
                     $l = mb_strcut($ret, $ptr, $wrap);
                     $l = mb_strcut($ret, $ptr, $wrap);
                     $ptr += strlen($l);
                     $ptr += strlen($l);
                     $tmp = $l;
                     $tmp = $l;
-                    
+
                     $l = mb_strcut($ret, $ptr, 2);
                     $l = mb_strcut($ret, $ptr, 2);
                     while (strlen($l) != 0 && mb_strpos($no_begin, $l) !== FALSE ) {
                     while (strlen($l) != 0 && mb_strpos($no_begin, $l) !== FALSE ) {
                         $tmp .= $l;
                         $tmp .= $l;
@@ -836,7 +836,7 @@ function japanese_xtra() {
 /**
 /**
  * Japanese decoding function
  * Japanese decoding function
  *
  *
- * converts string to euc-jp, if string uses JIS, EUC-JP, ShiftJIS or UTF-8 
+ * converts string to euc-jp, if string uses JIS, EUC-JP, ShiftJIS or UTF-8
  * charset. Needs mbstring support in php.
  * charset. Needs mbstring support in php.
  * @param string $ret text, that has to be converted
  * @param string $ret text, that has to be converted
  * @return string converted string
  * @return string converted string
@@ -872,7 +872,7 @@ function japanese_xtra_encode($ret) {
             $detect_encoding == 'EUC-JP' ||
             $detect_encoding == 'EUC-JP' ||
             $detect_encoding == 'SJIS' ||
             $detect_encoding == 'SJIS' ||
             $detect_encoding == 'UTF-8') {
             $detect_encoding == 'UTF-8') {
-            
+
             $ret = mb_convert_encoding(mb_convert_kana($ret, "KV"), 'JIS', 'AUTO');
             $ret = mb_convert_encoding(mb_convert_kana($ret, "KV"), 'JIS', 'AUTO');
         }
         }
     }
     }
@@ -901,7 +901,7 @@ function japanese_xtra_encodeheader($ret) {
                     if ($prevcsize == 1) {
                     if ($prevcsize == 1) {
                         $result .= $tmpstr;
                         $result .= $tmpstr;
                     } else {
                     } else {
-                        $result .= str_replace(' ', '', 
+                        $result .= str_replace(' ', '',
                                                mb_encode_mimeheader($tmpstr,'iso-2022-jp','B',''));
                                                mb_encode_mimeheader($tmpstr,'iso-2022-jp','B',''));
                     }
                     }
                     $tmpstr = $tmp;
                     $tmpstr = $tmp;
@@ -924,7 +924,7 @@ function japanese_xtra_encodeheader($ret) {
 /**
 /**
  * Japanese header decoding function
  * Japanese header decoding function
  *
  *
- * return human readable string from mime header. string is returned in euc-jp 
+ * return human readable string from mime header. string is returned in euc-jp
  * charset.
  * charset.
  * @param string $ret header string
  * @param string $ret header string
  * @return string decoded header string
  * @return string decoded header string
@@ -963,7 +963,7 @@ function japanese_xtra_downloadfilename($ret,$useragent) {
 
 
 /**
 /**
  * Japanese wordwrap function
  * Japanese wordwrap function
- * 
+ *
  * wraps text at set number of symbols
  * wraps text at set number of symbols
  * @param string $ret text
  * @param string $ret text
  * @param integer $wrap number of symbols per line
  * @param integer $wrap number of symbols per line
@@ -982,23 +982,23 @@ function japanese_xtra_wordwrap($ret,$wrap) {
             "\xa8\xa1\xa9\xa1\xcf\xa1\xd1";
             "\xa8\xa1\xa9\xa1\xcf\xa1\xd1";
         $no_end = "\x5c\x24\x28\x5b\x7b\xa1\xf2\x5c\xa1\xc6\xa1\xc8\xa1\xd2\xa1" .
         $no_end = "\x5c\x24\x28\x5b\x7b\xa1\xf2\x5c\xa1\xc6\xa1\xc8\xa1\xd2\xa1" .
             "\xd4\xa1\xd6\xa1\xd8\xa1\xda\xa1\xcc\xa1\xf0\xa1\xca\xa1\xce\xa1\xd0\xa1\xef";
             "\xd4\xa1\xd6\xa1\xd8\xa1\xda\xa1\xcc\xa1\xf0\xa1\xca\xa1\xce\xa1\xd0\xa1\xef";
- 
-        if (strlen($ret) >= $wrap && 
+
+        if (strlen($ret) >= $wrap &&
             substr($ret, 0, 1) != '>' &&
             substr($ret, 0, 1) != '>' &&
             strpos($ret, 'http://') === FALSE &&
             strpos($ret, 'http://') === FALSE &&
             strpos($ret, 'https://') === FALSE &&
             strpos($ret, 'https://') === FALSE &&
             strpos($ret, 'ftp://') === FALSE) {
             strpos($ret, 'ftp://') === FALSE) {
 
 
             $ret = mb_convert_kana($ret, "KV");
             $ret = mb_convert_kana($ret, "KV");
-           
+
             $line_new = '';
             $line_new = '';
             $ptr = 0;
             $ptr = 0;
-        
+
             while ($ptr < strlen($ret) - 1) {
             while ($ptr < strlen($ret) - 1) {
                 $l = mb_strcut($ret, $ptr, $wrap);
                 $l = mb_strcut($ret, $ptr, $wrap);
                 $ptr += strlen($l);
                 $ptr += strlen($l);
                 $tmp = $l;
                 $tmp = $l;
-            
+
                 $l = mb_strcut($ret, $ptr, 2);
                 $l = mb_strcut($ret, $ptr, 2);
                 while (strlen($l) != 0 && mb_strpos($no_begin, $l) !== FALSE ) {
                 while (strlen($l) != 0 && mb_strpos($no_begin, $l) !== FALSE ) {
                     $tmp .= $l;
                     $tmp .= $l;
@@ -1069,7 +1069,7 @@ function japanese_xtra_strimwidth($ret,$width) {
  * Korean downloaded filename processing functions
  * Korean downloaded filename processing functions
  *
  *
  * @param string default return value
  * @param string default return value
- * @return string 
+ * @return string
  */
  */
 function korean_xtra_downloadfilename($ret) {
 function korean_xtra_downloadfilename($ret) {
     $ret = str_replace("\x0D\x0A", '', $ret);  /* Hanmail's CR/LF Clear */
     $ret = str_replace("\x0D\x0A", '', $ret);  /* Hanmail's CR/LF Clear */
@@ -1090,9 +1090,9 @@ function korean_xtra_downloadfilename($ret) {
 
 
 /**
 /**
  * Replaces non-braking spaces inserted by some browsers with regular space
  * Replaces non-braking spaces inserted by some browsers with regular space
- * 
- * This function can be used to replace non-braking space symbols 
- * that are inserted in forms by some browsers instead of normal 
+ *
+ * This function can be used to replace non-braking space symbols
+ * that are inserted in forms by some browsers instead of normal
  * space symbol.
  * space symbol.
  *
  *
  * @param string $string Text that needs to be cleaned
  * @param string $string Text that needs to be cleaned
@@ -1133,14 +1133,14 @@ switch($output_charset):
    return $string;
    return $string;
 endswitch;
 endswitch;
 
 
-// return space instead of non-braking space. 
+// return space instead of non-braking space.
  return str_replace($nbsp,' ',$string);
  return str_replace($nbsp,' ',$string);
 }
 }
 
 
 /**
 /**
  * Function informs if it is safe to convert given charset to the one that is used by user.
  * Function informs if it is safe to convert given charset to the one that is used by user.
  *
  *
- * It is safe to use conversion only if user uses utf-8 encoding and when 
+ * It is safe to use conversion only if user uses utf-8 encoding and when
  * converted charset is similar to the one that is used by user.
  * converted charset is similar to the one that is used by user.
  *
  *
  * @param string $input_charset Charset of text that needs to be converted
  * @param string $input_charset Charset of text that needs to be converted
@@ -1160,7 +1160,7 @@ function is_conversion_safe($input_charset) {
  // Charsets that are similar
  // Charsets that are similar
 switch ($default_charset):
 switch ($default_charset):
 case "windows-1251":
 case "windows-1251":
-      if ( $input_charset == "iso-8859-5" || 
+      if ( $input_charset == "iso-8859-5" ||
            $input_charset == "koi8-r" ||
            $input_charset == "koi8-r" ||
            $input_charset == "koi8-u" ) {
            $input_charset == "koi8-u" ) {
         return true;
         return true;
@@ -1168,22 +1168,22 @@ case "windows-1251":
         return false;
         return false;
      }
      }
 case "windows-1257":
 case "windows-1257":
-  if ( $input_charset == "iso-8859-13" || 
+  if ( $input_charset == "iso-8859-13" ||
        $input_charset == "iso-8859-4" ) {
        $input_charset == "iso-8859-4" ) {
     return true;
     return true;
   } else {
   } else {
     return false;
     return false;
   }
   }
 case "iso-8859-4":
 case "iso-8859-4":
-  if ( $input_charset == "iso-8859-13" || 
+  if ( $input_charset == "iso-8859-13" ||
        $input_charset == "windows-1257" ) {
        $input_charset == "windows-1257" ) {
      return true;
      return true;
   } else {
   } else {
      return false;
      return false;
   }
   }
 case "iso-8859-5":
 case "iso-8859-5":
-  if ( $input_charset == "windows-1251" || 
-       $input_charset == "koi8-r" || 
+  if ( $input_charset == "windows-1251" ||
+       $input_charset == "koi8-r" ||
        $input_charset == "koi8-u" ) {
        $input_charset == "koi8-u" ) {
      return true;
      return true;
   } else {
   } else {
@@ -1198,7 +1198,7 @@ case "iso-8859-13":
   }
   }
 case "koi8-r":
 case "koi8-r":
   if ( $input_charset == "windows-1251" ||
   if ( $input_charset == "windows-1251" ||
-       $input_charset == "iso-8859-5" || 
+       $input_charset == "iso-8859-5" ||
        $input_charset == "koi8-u" ) {
        $input_charset == "koi8-u" ) {
      return true;
      return true;
   } else {
   } else {

+ 1 - 1
functions/identity.php

@@ -51,4 +51,4 @@ function get_identities() {
     return $identities;
     return $identities;
 }
 }
 
 
-?>
+?>

+ 1 - 1
functions/imap.php

@@ -20,4 +20,4 @@ require_once(SM_PATH . 'functions/imap_messages.php');
 require_once(SM_PATH . 'functions/imap_general.php');
 require_once(SM_PATH . 'functions/imap_general.php');
 require_once(SM_PATH . 'functions/imap_search.php');
 require_once(SM_PATH . 'functions/imap_search.php');
 
 
-?>
+?>

+ 1 - 0
functions/imap_mailbox.php

@@ -1,4 +1,5 @@
 <?php
 <?php
+
 /**
 /**
  * imap_mailbox.php
  * imap_mailbox.php
  *
  *

+ 6 - 6
functions/imap_search.php

@@ -25,7 +25,7 @@ function sqimap_search($imapConnection, $search_where, $search_what, $mailbox,
                        $color, $search_position = '', $search_all, $count_all) {
                        $color, $search_position = '', $search_all, $count_all) {
 
 
     global $message_highlight_list, $squirrelmail_language, $languages,
     global $message_highlight_list, $squirrelmail_language, $languages,
-           $index_order, $pos, $allow_charset_search, 
+           $index_order, $pos, $allow_charset_search,
 	   $imap_server_type;
 	   $imap_server_type;
 
 
     $pos = $search_position;
     $pos = $search_position;
@@ -39,7 +39,7 @@ function sqimap_search($imapConnection, $search_where, $search_what, $mailbox,
     $multi_search = explode(' ', $search_what);
     $multi_search = explode(' ', $search_what);
     $search_string = '';
     $search_string = '';
 
 
-    /* it seems macosx does not support the prefered search 
+    /* it seems macosx does not support the prefered search
        syntax so we fall back to the older style. This IMAP
        syntax so we fall back to the older style. This IMAP
        server has a problem with multiple search terms. Instead
        server has a problem with multiple search terms. Instead
        of returning the messages that match all the terms it
        of returning the messages that match all the terms it
@@ -71,7 +71,7 @@ function sqimap_search($imapConnection, $search_where, $search_what, $mailbox,
     if ($allow_charset_search && isset($languages[$squirrelmail_language]['CHARSET']) &&
     if ($allow_charset_search && isset($languages[$squirrelmail_language]['CHARSET']) &&
         $languages[$squirrelmail_language]['CHARSET']) {
         $languages[$squirrelmail_language]['CHARSET']) {
         $ss = "SEARCH CHARSET "
         $ss = "SEARCH CHARSET "
-            . strtoupper($languages[$squirrelmail_language]['CHARSET']) 
+            . strtoupper($languages[$squirrelmail_language]['CHARSET'])
             . " ALL $search_string";
             . " ALL $search_string";
     } else {
     } else {
         $ss = "SEARCH ALL $search_string";
         $ss = "SEARCH ALL $search_string";
@@ -81,10 +81,10 @@ function sqimap_search($imapConnection, $search_where, $search_what, $mailbox,
     $readin = sqimap_run_command($imapConnection, $ss, false, $result, $message, TRUE);
     $readin = sqimap_run_command($imapConnection, $ss, false, $result, $message, TRUE);
 
 
     /* try US-ASCII charset if search fails */
     /* try US-ASCII charset if search fails */
-    if (isset($languages[$squirrelmail_language]['CHARSET']) 
+    if (isset($languages[$squirrelmail_language]['CHARSET'])
         && strtolower($result) == 'no') {
         && strtolower($result) == 'no') {
         $ss = "SEARCH CHARSET \"US-ASCII\" ALL $search_string";
         $ss = "SEARCH CHARSET \"US-ASCII\" ALL $search_string";
-        $readin = sqimap_run_command ($imapConnection, $ss, true, 
+        $readin = sqimap_run_command ($imapConnection, $ss, true,
                                       $result, $message);
                                       $result, $message);
     }
     }
 
 
@@ -126,4 +126,4 @@ function sqimap_search($imapConnection, $search_where, $search_what, $mailbox,
 
 
 
 
 
 
-?>
+?>

+ 8 - 8
functions/imap_utf7_local.php

@@ -22,11 +22,11 @@
  */
  */
 function sqimap_mb_convert_encoding($str, $to_encoding, $from_encoding, $default_charset)
 function sqimap_mb_convert_encoding($str, $to_encoding, $from_encoding, $default_charset)
 {
 {
-  // Allows mbstring functions only with iso-8859-*, utf-8 and 
+  // Allows mbstring functions only with iso-8859-*, utf-8 and
   // iso-2022-jp (Japanese)
   // iso-2022-jp (Japanese)
   // koi8-r and gb2312 can be added only in php 4.3+
   // koi8-r and gb2312 can be added only in php 4.3+
   if ( stristr($default_charset, 'iso-8859-') ||
   if ( stristr($default_charset, 'iso-8859-') ||
-       stristr($default_charset, 'utf-8') || 
+       stristr($default_charset, 'utf-8') ||
        stristr($default_charset, 'iso-2022-jp') ) {
        stristr($default_charset, 'iso-2022-jp') ) {
     if (function_exists('mb_convert_encoding')) {
     if (function_exists('mb_convert_encoding')) {
       return mb_convert_encoding($str, $to_encoding, $from_encoding);
       return mb_convert_encoding($str, $to_encoding, $from_encoding);
@@ -37,7 +37,7 @@ function sqimap_mb_convert_encoding($str, $to_encoding, $from_encoding, $default
 
 
 function imap_utf7_encode_local($s) {
 function imap_utf7_encode_local($s) {
     global $languages, $squirrelmail_language;
     global $languages, $squirrelmail_language;
-    
+
     if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
     if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
         function_exists($languages[$squirrelmail_language]['XTRA_CODE'].'_utf7_imap_encode')) {
         function_exists($languages[$squirrelmail_language]['XTRA_CODE'].'_utf7_imap_encode')) {
         return call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_utf7_imap_encode', $s);
         return call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_utf7_imap_encode', $s);
@@ -54,8 +54,8 @@ function imap_utf7_encode_local($s) {
         return $utf7_s;
         return $utf7_s;
     }
     }
 
 
-    // Later code works only for ISO-8859-1 
-    
+    // Later code works only for ISO-8859-1
+
 	$b64_s = '';	// buffer for substring to be base64-encoded
 	$b64_s = '';	// buffer for substring to be base64-encoded
 	$utf7_s = '';	// imap-utf7-encoded string
 	$utf7_s = '';	// imap-utf7-encoded string
 	for ($i = 0; $i < strlen($s); $i++) {
 	for ($i = 0; $i < strlen($s); $i++) {
@@ -90,7 +90,7 @@ function imap_utf7_encode_local($s) {
 
 
 function imap_utf7_decode_local($s) {
 function imap_utf7_decode_local($s) {
     global $languages, $squirrelmail_language;
     global $languages, $squirrelmail_language;
-    
+
     if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
     if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
         function_exists($languages[$squirrelmail_language]['XTRA_CODE'] . '_utf7_imap_decode')) {
         function_exists($languages[$squirrelmail_language]['XTRA_CODE'] . '_utf7_imap_decode')) {
         return call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_utf7_imap_decode', $s);
         return call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_utf7_imap_decode', $s);
@@ -108,7 +108,7 @@ function imap_utf7_decode_local($s) {
     }
     }
 
 
     // Later code works only for ISO-8859-1
     // Later code works only for ISO-8859-1
-    
+
 	$b64_s = '';
 	$b64_s = '';
 	$iso_8859_1_s = '';
 	$iso_8859_1_s = '';
 	for ($i = 0, $len = strlen($s); $i < $len; $i++) {
 	for ($i = 0, $len = strlen($s); $i < $len; $i++) {
@@ -223,4 +223,4 @@ function decodeBASE64($s) {
 	return $d;
 	return $d;
 }
 }
 
 
-?>
+?>

+ 1 - 1
functions/index.php

@@ -20,4 +20,4 @@ header("Location:../index.php");
 
 
 /* pretty impressive huh? */
 /* pretty impressive huh? */
 
 
-?>
+?>

+ 133 - 133
functions/mailbox_display.php

@@ -1,17 +1,17 @@
 <?php
 <?php
 
 
 /**
 /**
-* mailbox_display.php
-*
-* Copyright (c) 1999-2004 The SquirrelMail Project Team
-* Licensed under the GNU GPL. For full terms see the file COPYING.
-*
-* This contains functions that display mailbox information, such as the
-* table row that has sender, date, subject, etc...
-*
-* @version $Id$
-* @package squirrelmail
-*/
+ * mailbox_display.php
+ *
+ * Copyright (c) 1999-2004 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * This contains functions that display mailbox information, such as the
+ * table row that has sender, date, subject, etc...
+ *
+ * @version $Id$
+ * @package squirrelmail
+ */
 
 
 /** The standard includes.. */
 /** The standard includes.. */
 require_once(SM_PATH . 'functions/strings.php');
 require_once(SM_PATH . 'functions/strings.php');
@@ -24,18 +24,18 @@ require_once(SM_PATH . 'functions/mime.php');
 require_once(SM_PATH . 'functions/forms.php');
 require_once(SM_PATH . 'functions/forms.php');
 
 
 /**
 /**
-* default value for page_selector_max
-*/
+ * default value for page_selector_max
+ */
 define('PG_SEL_MAX', 10);
 define('PG_SEL_MAX', 10);
 
 
 /**
 /**
-* The number of pages to cache msg headers
-*/
+ * The number of pages to cache msg headers
+ */
 define('SQM_MAX_PAGES_IN_CACHE',5);
 define('SQM_MAX_PAGES_IN_CACHE',5);
 
 
 /**
 /**
-* Sort constants used for sorting of messages
-*/
+ * Sort constants used for sorting of messages
+ */
 define('SQSORT_NONE',0);
 define('SQSORT_NONE',0);
 define('SQSORT_DATE_ASC',1);
 define('SQSORT_DATE_ASC',1);
 define('SQSORT_DATE_DEC',2);
 define('SQSORT_DATE_DEC',2);
@@ -63,8 +63,8 @@ define('SQM_MAX_MBX_IN_CACHE',3);
 // define('MBX_PREF_FUTURE',unique integer key);
 // define('MBX_PREF_FUTURE',unique integer key);
 
 
 /**
 /**
-* @param mixed $start UNDOCUMENTED
-*/
+ * @param mixed $start UNDOCUMENTED
+ */
 function elapsed($start) {
 function elapsed($start) {
 
 
     $end = microtime();
     $end = microtime();
@@ -80,11 +80,11 @@ function elapsed($start) {
 }
 }
 
 
 /**
 /**
-* Displays message header row in messages list
-*
-* @param  array $aMsg contains all message related parameters
-* @return void
-*/
+ * Displays message header row in messages list
+ *
+ * @param  array $aMsg contains all message related parameters
+ * @return void
+ */
 
 
 function printMessageInfo($aMsg) {
 function printMessageInfo($aMsg) {
     // FIX ME, remove these globals as well by adding an array as argument for the user settings
     // FIX ME, remove these globals as well by adding an array as argument for the user settings
@@ -710,12 +710,12 @@ function sqm_api_mailbox_select($imapConnection,$mailbox,$aConfig,$aProps) {
 
 
 
 
 /**
 /**
-* Does the $srt $_GET var to field mapping
-*
-* @param int $srt Field to sort on
-* @param bool $bServerSort Server sorting is true
-* @return string $sSortField Field to sort on
-*/
+ * Does the $srt $_GET var to field mapping
+ *
+ * @param int $srt Field to sort on
+ * @param bool $bServerSort Server sorting is true
+ * @return string $sSortField Field to sort on
+ */
 function getSortField($sort,$bServerSort) {
 function getSortField($sort,$bServerSort) {
     switch($sort) {
     switch($sort) {
         case SQSORT_NONE:
         case SQSORT_NONE:
@@ -932,10 +932,10 @@ function fetchMessageHeaders($imapConnection, &$aMailbox) {
             }
             }
 
 
             /**
             /**
-            * retrieve messages by sequence id's and fetch the UID to retrieve
-            * the UID. for sorted lists this is not needed because a UID FETCH
-            * automaticly add the UID value in fetch results
-            **/
+             * retrieve messages by sequence id's and fetch the UID to retrieve
+             * the UID. for sorted lists this is not needed because a UID FETCH
+             * automaticly add the UID value in fetch results
+             **/
             $aFetchItems[] = 'UID';
             $aFetchItems[] = 'UID';
 
 
             //create id range
             //create id range
@@ -999,12 +999,12 @@ function fetchMessageHeaders($imapConnection, &$aMailbox) {
 }
 }
 
 
 /**
 /**
-* This function loops through a group of messages in the mailbox
-* and shows them to the user.
-*
-* @param mixed $imapConnection
-* @param array $aMailbox associative array with mailbox related vars
-*/
+ * This function loops through a group of messages in the mailbox
+ * and shows them to the user.
+ *
+ * @param mixed $imapConnection
+ * @param array $aMailbox associative array with mailbox related vars
+ */
 function showMessagesForMailbox($imapConnection, &$aMailbox) {
 function showMessagesForMailbox($imapConnection, &$aMailbox) {
     global $color;
     global $color;
 
 
@@ -1063,15 +1063,15 @@ function showMessagesForMailbox($imapConnection, &$aMailbox) {
 }
 }
 
 
 /**
 /**
-* Function to map an uid list with a msg header array by uid
-* The mapped headers are printed with printMessage
-* aMailbox parameters contains info about the page we are on, the
-* used search criteria, the number of messages to show
-*
-* @param resource $imapConnection socket handle to imap
-* @param array    $aMailbox array with required elements MSG_HEADERS, UIDSET, OFFSET, LIMIT
-* @return void
-**/
+ * Function to map an uid list with a msg header array by uid
+ * The mapped headers are printed with printMessage
+ * aMailbox parameters contains info about the page we are on, the
+ * used search criteria, the number of messages to show
+ *
+ * @param resource $imapConnection socket handle to imap
+ * @param array    $aMailbox array with required elements MSG_HEADERS, UIDSET, OFFSET, LIMIT
+ * @return void
+ **/
 function displayMessageArray($imapConnection, $aMailbox) {
 function displayMessageArray($imapConnection, $aMailbox) {
     $iSetIndx    = $aMailbox['SETINDEX'];
     $iSetIndx    = $aMailbox['SETINDEX'];
     $aId         = $aMailbox['UIDSET'][$iSetIndx];
     $aId         = $aMailbox['UIDSET'][$iSetIndx];
@@ -1123,15 +1123,15 @@ function displayMessageArray($imapConnection, $aMailbox) {
 }
 }
 
 
 /**
 /**
-* Displays the standard message list header.
-*
-* To finish the table, you need to do a "</table></table>";
-*
-* @param resource $imapConnection
-* @param array    $aMailbox associative array with mailbox related information
-* @param string   $msg_cnt_str
-* @param string   $paginator Paginator string
-*/
+ * Displays the standard message list header.
+ *
+ * To finish the table, you need to do a "</table></table>";
+ *
+ * @param resource $imapConnection
+ * @param array    $aMailbox associative array with mailbox related information
+ * @param string   $msg_cnt_str
+ * @param string   $paginator Paginator string
+ */
 function mail_message_listing_beginning ($imapConnection,
 function mail_message_listing_beginning ($imapConnection,
                                          $aMailbox,
                                          $aMailbox,
                                          $msg_cnt_str = '',
                                          $msg_cnt_str = '',
@@ -1256,13 +1256,13 @@ function mail_message_listing_beginning ($imapConnection,
 }
 }
 
 
 /**
 /**
-* Function to add the last row in a message list, it contains the paginator and info about
-* the number of messages.
-*
-* @param integer $num_msgs number of messages in a mailbox
-* @param string  $paginator_str Paginator string  [Prev | Next]  [ 1 2 3 ... 91 92 94 ]  [Show all]
-* @param string  $msg_cnt_str   Message count string Viewing Messages: 21 to 1861 (20 total)
-*/
+ * Function to add the last row in a message list, it contains the paginator and info about
+ * the number of messages.
+ *
+ * @param integer $num_msgs number of messages in a mailbox
+ * @param string  $paginator_str Paginator string  [Prev | Next]  [ 1 2 3 ... 91 92 94 ]  [Show all]
+ * @param string  $msg_cnt_str   Message count string Viewing Messages: 21 to 1861 (20 total)
+ */
 function mail_message_listing_end($num_msgs, $paginator_str, $msg_cnt_str) {
 function mail_message_listing_end($num_msgs, $paginator_str, $msg_cnt_str) {
 global $color;
 global $color;
 if ($num_msgs) {
 if ($num_msgs) {
@@ -1294,10 +1294,10 @@ if ($num_msgs) {
 }
 }
 
 
 /**
 /**
-* Prints the table header for the messages list view
-*
-* @param array $aMailbox
-*/
+ * Prints the table header for the messages list view
+ *
+ * @param array $aMailbox
+ */
 function printHeader($aMailbox) {
 function printHeader($aMailbox) {
     global $index_order, $internal_date_sort, $color;
     global $index_order, $internal_date_sort, $color;
 
 
@@ -1310,7 +1310,7 @@ function printHeader($aMailbox) {
     echo html_tag( 'tr' ,'' , 'center', $color[5] );
     echo html_tag( 'tr' ,'' , 'center', $color[5] );
 
 
     /* calculate the width of the subject column based on the
     /* calculate the width of the subject column based on the
-    * widths of the other columns */
+     * widths of the other columns */
     $widths = array(1=>1,2=>25,3=>5,4=>0,5=>1,6=>5);
     $widths = array(1=>1,2=>25,3=>5,4=>0,5=>1,6=>5);
     $subjectwidth = 100;
     $subjectwidth = 100;
     foreach($index_order as $item) {
     foreach($index_order as $item) {
@@ -1376,12 +1376,12 @@ function printHeader($aMailbox) {
 
 
 
 
 /**
 /**
-* This function shows the sort button. Isn't this a good comment?
-*
-* @param array $aMailbox
-* @param integer $Down
-* @param integer $Up
-*/
+ * This function shows the sort button. Isn't this a good comment?
+ *
+ * @param array $aMailbox
+ * @param integer $Down
+ * @param integer $Up
+ */
 function ShowSortButton($aMailbox, $Down, $Up ) {
 function ShowSortButton($aMailbox, $Down, $Up ) {
     global $PHP_SELF;
     global $PHP_SELF;
 
 
@@ -1412,10 +1412,10 @@ function ShowSortButton($aMailbox, $Down, $Up ) {
 }
 }
 
 
 /**
 /**
-* FIXME: Undocumented function
-*
-* @param array $aMailbox
-*/
+ * FIXME: Undocumented function
+ *
+ * @param array $aMailbox
+ */
 function get_selectall_link($aMailbox) {
 function get_selectall_link($aMailbox) {
     global $checkall, $javascript_on;
     global $checkall, $javascript_on;
     global $PHP_SELF;
     global $PHP_SELF;
@@ -1469,13 +1469,13 @@ function get_selectall_link($aMailbox) {
 }
 }
 
 
 /**
 /**
-* This function computes the "Viewing Messages..." string.
-*
-* @param integer $start_msg first message number
-* @param integer $end_msg last message number
-* @param integer $num_msgs total number of message in folder
-* @return string
-*/
+ * This function computes the "Viewing Messages..." string.
+ *
+ * @param integer $start_msg first message number
+ * @param integer $end_msg last message number
+ * @param integer $num_msgs total number of message in folder
+ * @return string
+ */
 function get_msgcnt_str($start_msg, $end_msg, $num_msgs) {
 function get_msgcnt_str($start_msg, $end_msg, $num_msgs) {
     /* Compute the $msg_cnt_str. */
     /* Compute the $msg_cnt_str. */
     $result = '';
     $result = '';
@@ -1492,14 +1492,14 @@ function get_msgcnt_str($start_msg, $end_msg, $num_msgs) {
 }
 }
 
 
 /**
 /**
-* Generate a paginator link.
-*
-* @param mixed $box Mailbox name
-* @param mixed $start_msg Message Offset
-* @param mixed $use
-* @param string $text text used for paginator link
-* @return string
-*/
+ * Generate a paginator link.
+ *
+ * @param mixed $box Mailbox name
+ * @param mixed $start_msg Message Offset
+ * @param mixed $use
+ * @param string $text text used for paginator link
+ * @return string
+ */
 function get_paginator_link($box, $start_msg, $text) {
 function get_paginator_link($box, $start_msg, $text) {
     sqgetGlobalVar('PHP_SELF',$php_self,SQ_SERVER);
     sqgetGlobalVar('PHP_SELF',$php_self,SQ_SERVER);
     $result = "<a href=\"$php_self?startMessage=$start_msg&amp;mailbox=$box\" "
     $result = "<a href=\"$php_self?startMessage=$start_msg&amp;mailbox=$box\" "
@@ -1509,15 +1509,15 @@ function get_paginator_link($box, $start_msg, $text) {
 }
 }
 
 
 /**
 /**
-* This function computes the paginator string.
-*
-* @param string  $box      mailbox name
-* @param integer $iOffset  offset in total number of messages
-* @param integer $iTotal   total number of messages
-* @param integer $iLimit   maximum number of messages to show on a page
-* @param bool    $bShowAll show all messages at once (non paginate mode)
-* @return string $result   paginate string with links to pages
-*/
+ * This function computes the paginator string.
+ *
+ * @param string  $box      mailbox name
+ * @param integer $iOffset  offset in total number of messages
+ * @param integer $iTotal   total number of messages
+ * @param integer $iLimit   maximum number of messages to show on a page
+ * @param bool    $bShowAll show all messages at once (non paginate mode)
+ * @return string $result   paginate string with links to pages
+ */
 function get_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll) {
 function get_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll) {
     global $username, $data_dir;
     global $username, $data_dir;
     sqgetGlobalVar('PHP_SELF',$php_self,SQ_SERVER);
     sqgetGlobalVar('PHP_SELF',$php_self,SQ_SERVER);
@@ -1680,9 +1680,9 @@ function get_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll) {
 
 
     /* Put all the pieces of the paginator string together. */
     /* Put all the pieces of the paginator string together. */
     /**
     /**
-    * Hairy code... But let's leave it like it is since I am not certain
-    * a different approach would be any easier to read. ;)
-    */
+     * Hairy code... But let's leave it like it is since I am not certain
+     * a different approach would be any easier to read. ;)
+     */
     $result = '';
     $result = '';
     if ( $prv_str || $nxt_str ) {
     if ( $prv_str || $nxt_str ) {
 
 
@@ -1710,8 +1710,8 @@ function get_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll) {
 }
 }
 
 
 /**
 /**
-* FIXME: Undocumented function
-*/
+ * FIXME: Undocumented function
+ */
 function truncateWithEntities($subject, $trim_at)
 function truncateWithEntities($subject, $trim_at)
 {
 {
     $ent_strlen = strlen($subject);
     $ent_strlen = strlen($subject);
@@ -1721,11 +1721,11 @@ function truncateWithEntities($subject, $trim_at)
     global $languages, $squirrelmail_language;
     global $languages, $squirrelmail_language;
 
 
     /*
     /*
-    * see if this is entities-encoded string
-    * If so, Iterate through the whole string, find out
-    * the real number of characters, and if more
-    * than $trim_at, substr with an updated trim value.
-    */
+     * see if this is entities-encoded string
+     * If so, Iterate through the whole string, find out
+     * the real number of characters, and if more
+     * than $trim_at, substr with an updated trim value.
+     */
     $trim_val = $trim_at;
     $trim_val = $trim_at;
     $ent_offset = 0;
     $ent_offset = 0;
     $ent_loc = 0;
     $ent_loc = 0;
@@ -1753,8 +1753,8 @@ function truncateWithEntities($subject, $trim_at)
 }
 }
 
 
 /**
 /**
-* FIXME: Undocumented function
-*/
+ * FIXME: Undocumented function
+ */
 function processSubject($subject, $threadlevel = 0) {
 function processSubject($subject, $threadlevel = 0) {
     /* Shouldn't ever happen -- caught too many times in the IMAP functions */
     /* Shouldn't ever happen -- caught too many times in the IMAP functions */
     if ($subject == '') {
     if ($subject == '') {
@@ -1773,15 +1773,15 @@ function processSubject($subject, $threadlevel = 0) {
 
 
 
 
 /**
 /**
-* Creates button
-*
-* @deprecated see form functions available in 1.5.1 and 1.4.3.
-* @param string $type
-* @param string $name
-* @param string $value
-* @param string $js
-* @param bool $enabled
-*/
+ * Creates button
+ *
+ * @deprecated see form functions available in 1.5.1 and 1.4.3.
+ * @param string $type
+ * @param string $name
+ * @param string $value
+ * @param string $js
+ * @param bool $enabled
+ */
 function getButton($type, $name, $value, $js = '', $enabled = TRUE) {
 function getButton($type, $name, $value, $js = '', $enabled = TRUE) {
     $disabled = ( $enabled ? '' : 'disabled ' );
     $disabled = ( $enabled ? '' : 'disabled ' );
     $js = ( $js ? $js.' ' : '' );
     $js = ( $js ? $js.' ' : '' );
@@ -1793,11 +1793,11 @@ function getButton($type, $name, $value, $js = '', $enabled = TRUE) {
 }
 }
 
 
 /**
 /**
-* Puts string into cell, aligns it and adds <small> tag
-*
-* @param string $string string
-* @param string $align alignment
-*/
+ * Puts string into cell, aligns it and adds <small> tag
+ *
+ * @param string $string string
+ * @param string $align alignment
+ */
 function getSmallStringCell($string, $align) {
 function getSmallStringCell($string, $align) {
     return html_tag('td',
     return html_tag('td',
                     '<small>' . $string . ':&nbsp; </small>',
                     '<small>' . $string . ':&nbsp; </small>',
@@ -1807,9 +1807,9 @@ function getSmallStringCell($string, $align) {
 }
 }
 
 
 /**
 /**
-* This should go in imap_mailbox.php
-* @param string $mailbox
-*/
+ * This should go in imap_mailbox.php
+ * @param string $mailbox
+ */
 function handleAsSent($mailbox) {
 function handleAsSent($mailbox) {
     global $handleAsSent_result;
     global $handleAsSent_result;
 
 

+ 12 - 12
functions/options.php

@@ -154,7 +154,7 @@ class SquirrelOption {
     function createHTMLWidget() {
     function createHTMLWidget() {
         global $javascript_on;
         global $javascript_on;
 
 
-        // Use new value if available 
+        // Use new value if available
         if (!empty($this->new_value)) {
         if (!empty($this->new_value)) {
             $tempValue = $this->value;
             $tempValue = $this->value;
             $this->value = $this->new_value;
             $this->value = $this->new_value;
@@ -197,7 +197,7 @@ class SquirrelOption {
 
 
         /* Add the "post script" for this option. */
         /* Add the "post script" for this option. */
         $result .= $this->post_script;
         $result .= $this->post_script;
-        
+
         // put correct value back if need be
         // put correct value back if need be
         if (!empty($this->new_value)) {
         if (!empty($this->new_value)) {
             $this->value = $tempValue;
             $this->value = $tempValue;
@@ -227,7 +227,7 @@ class SquirrelOption {
         }
         }
 
 
         $result = "<input type=\"text\" name=\"new_$this->name\" value=\"" .
         $result = "<input type=\"text\" name=\"new_$this->name\" value=\"" .
-            htmlspecialchars($this->value) . 
+            htmlspecialchars($this->value) .
             "\" size=\"$width\" $this->script />$this->trailing_text\n";
             "\" size=\"$width\" $this->script />$this->trailing_text\n";
         return ($result);
         return ($result);
     }
     }
@@ -239,7 +239,7 @@ class SquirrelOption {
         /* Add each possible value to the select list. */
         /* Add each possible value to the select list. */
         foreach ($this->possible_values as $real_value => $disp_value) {
         foreach ($this->possible_values as $real_value => $disp_value) {
             /* Start the next new option string. */
             /* Start the next new option string. */
-            $new_option = '<option value="' . 
+            $new_option = '<option value="' .
                 htmlspecialchars($real_value) . '"';
                 htmlspecialchars($real_value) . '"';
 
 
             /* If this value is the current value, select it. */
             /* If this value is the current value, select it. */
@@ -267,24 +267,24 @@ class SquirrelOption {
 
 
         /* Add each possible value to the select list. */
         /* Add each possible value to the select list. */
         foreach ($this->possible_values as $real_value => $disp_value) {
         foreach ($this->possible_values as $real_value => $disp_value) {
-            if ( is_array($disp_value) ) { 
+            if ( is_array($disp_value) ) {
               /* For folder list, we passed in the array of boxes.. */
               /* For folder list, we passed in the array of boxes.. */
               $new_option = sqimap_mailbox_option_list(0, $selected, 0, $disp_value);
               $new_option = sqimap_mailbox_option_list(0, $selected, 0, $disp_value);
             } else {
             } else {
               /* Start the next new option string. */
               /* Start the next new option string. */
               $new_option = '<option value="' . htmlspecialchars($real_value) . '"';
               $new_option = '<option value="' . htmlspecialchars($real_value) . '"';
-  
+
               /* If this value is the current value, select it. */
               /* If this value is the current value, select it. */
               if ($real_value == $this->value) {
               if ($real_value == $this->value) {
                  $new_option .= ' selected="selected"';
                  $new_option .= ' selected="selected"';
               }
               }
-  
+
               /* Add the display value to our option string. */
               /* Add the display value to our option string. */
               $new_option .= '>' . htmlspecialchars($disp_value) . "</option>\n";
               $new_option .= '>' . htmlspecialchars($disp_value) . "</option>\n";
             }
             }
             /* And add the new option string to our select tag. */
             /* And add the new option string to our select tag. */
             $result .= $new_option;
             $result .= $new_option;
-        }        
+        }
         /* Close the select tag and return our happy result. */
         /* Close the select tag and return our happy result. */
         $result .= "</select>\n";
         $result .= "</select>\n";
         return ($result);
         return ($result);
@@ -322,11 +322,11 @@ class SquirrelOption {
     }
     }
 
 
     function createWidget_Float() {
     function createWidget_Float() {
-        
+
         global $javascript_on;
         global $javascript_on;
 
 
         // add onChange javascript handler to a regular string widget
         // add onChange javascript handler to a regular string widget
-        // which will strip out all non-numeric (period also OK) chars 
+        // which will strip out all non-numeric (period also OK) chars
         if ($javascript_on)
         if ($javascript_on)
            return preg_replace('/\/>/', ' onChange="origVal=this.value; newVal=\'\'; '
            return preg_replace('/\/>/', ' onChange="origVal=this.value; newVal=\'\'; '
                     . 'for (i=0;i<origVal.length;i++) { if ((origVal.charAt(i)>=\'0\' '
                     . 'for (i=0;i<origVal.length;i++) { if ((origVal.charAt(i)>=\'0\' '
@@ -340,11 +340,11 @@ class SquirrelOption {
     function createWidget_Boolean() {
     function createWidget_Boolean() {
         /* Do the whole current value thing. */
         /* Do the whole current value thing. */
         if ($this->value != SMPREF_NO) {
         if ($this->value != SMPREF_NO) {
-            $yes_chk = ' checked=""';
+            $yes_chk = ' checked="checked"';
             $no_chk = '';
             $no_chk = '';
         } else {
         } else {
             $yes_chk = '';
             $yes_chk = '';
-            $no_chk = ' checked=""';
+            $no_chk = ' checked="checked"';
         }
         }
 
 
         /* Build the yes choice. */
         /* Build the yes choice. */

+ 15 - 15
functions/page_header.php

@@ -46,16 +46,16 @@ function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE
         echo '<link rel="stylesheet" type="text/css" href="' .
         echo '<link rel="stylesheet" type="text/css" href="' .
              $base_uri . 'themes/css/'.$custom_css.'" />';
              $base_uri . 'themes/css/'.$custom_css.'" />';
     }
     }
-    
+
     if ($squirrelmail_language == 'ja_JP') {
     if ($squirrelmail_language == 'ja_JP') {
         echo "<!-- \xfd\xfe -->\n";
         echo "<!-- \xfd\xfe -->\n";
         echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp" />' . "\n";
         echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp" />' . "\n";
     }
     }
-    
+
     if ($do_hook) {
     if ($do_hook) {
         do_hook('generic_header');
         do_hook('generic_header');
     }
     }
-    
+
     echo "\n<title>$title</title>$xtra\n";
     echo "\n<title>$title</title>$xtra\n";
 
 
     /* work around IE6's scrollbar bug */
     /* work around IE6's scrollbar bug */
@@ -63,9 +63,9 @@ function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE
 <style type="text/css">
 <style type="text/css">
 <!--
 <!--
   /* avoid stupid IE6 bug with frames and scrollbars */
   /* avoid stupid IE6 bug with frames and scrollbars */
-  body { 
-      voice-family: "\"}\""; 
-      voice-family: inherit; 
+  body {
+      voice-family: "\"}\"";
+      voice-family: inherit;
       width: expression(document.documentElement.clientWidth - 30);
       width: expression(document.documentElement.clientWidth - 30);
   }
   }
 -->
 -->
@@ -139,8 +139,8 @@ function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
         $compose_uri = $base_uri.'src/compose.php?newmessage=1';
         $compose_uri = $base_uri.'src/compose.php?newmessage=1';
     $session = 0;
     $session = 0;
     }
     }
-  
-    if($javascript_on) { 
+
+    if($javascript_on) {
 
 
       switch ( $module ) {
       switch ( $module ) {
         case 'src/read_body.php':
         case 'src/read_body.php':
@@ -232,12 +232,12 @@ function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
                         "document.forms[i-1].elements[pos].focus();\n".
                         "document.forms[i-1].elements[pos].focus();\n".
                     "}\n".
                     "}\n".
                 "}\n";
                 "}\n";
-        
+
             $js .= "// -->\n".
             $js .= "// -->\n".
                  "</script>\n";
                  "</script>\n";
             $onload = 'onload="checkForm();"';
             $onload = 'onload="checkForm();"';
             displayHtmlHeader ('SquirrelMail', $js);
             displayHtmlHeader ('SquirrelMail', $js);
-            break;   
+            break;
 
 
         default:
         default:
             $js = '<script language="JavaScript" type="text/javascript">' .
             $js = '<script language="JavaScript" type="text/javascript">' .
@@ -263,7 +263,7 @@ function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
                     "}\n".
                     "}\n".
             "$xtra\n".
             "$xtra\n".
                 "}\n";
                 "}\n";
-        
+
                 if ($compose_new_win == '1') {
                 if ($compose_new_win == '1') {
                     if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
                     if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
                         $compose_width = '640';
                         $compose_width = '640';
@@ -283,10 +283,10 @@ function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
 
 
                 }
                 }
             $js .= "// -->\n". "</script>\n";
             $js .= "// -->\n". "</script>\n";
-    
+
             $onload = 'onload="checkForm();"';
             $onload = 'onload="checkForm();"';
             displayHtmlHeader ('SquirrelMail', $js);
             displayHtmlHeader ('SquirrelMail', $js);
-            break;   
+            break;
 
 
         }
         }
     } else {
     } else {
@@ -416,7 +416,7 @@ function compose_Header($color, $mailbox) {
                  "</script>\n";
                  "</script>\n";
             $onload = 'onload="checkForm();"';
             $onload = 'onload="checkForm();"';
             displayHtmlHeader (_("Compose"), $js);
             displayHtmlHeader (_("Compose"), $js);
-            break;   
+            break;
         }
         }
     } else {
     } else {
         /* javascript off */
         /* javascript off */
@@ -427,4 +427,4 @@ function compose_Header($color, $mailbox) {
     echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
     echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
 }
 }
 
 
-?>
+?>

+ 4 - 4
functions/prefs.php

@@ -20,7 +20,7 @@ sqgetGlobalVar('prefs_are_cached', $prefs_are_cached, SQ_SESSION );
 
 
 if ( !sqsession_is_registered('prefs_are_cached') ||
 if ( !sqsession_is_registered('prefs_are_cached') ||
      !isset( $prefs_cache) ||
      !isset( $prefs_cache) ||
-     !is_array( $prefs_cache) 
+     !is_array( $prefs_cache)
    ) {
    ) {
     $prefs_are_cached = false;
     $prefs_are_cached = false;
     $prefs_cache = array();
     $prefs_cache = array();
@@ -53,7 +53,7 @@ function getHashedFile($username, $dir, $datafile, $hash_search = true) {
     if (substr($dir, -1) == '/') {
     if (substr($dir, -1) == '/') {
         $dir = substr($dir, 0, strlen($dir) - 1);
         $dir = substr($dir, 0, strlen($dir) - 1);
     }
     }
-    
+
     /* Compute the hash for this user and extract the hash directories. */
     /* Compute the hash for this user and extract the hash directories. */
     $hash_dirs = computeHashDirs($username);
     $hash_dirs = computeHashDirs($username);
 
 
@@ -82,7 +82,7 @@ function getHashedFile($username, $dir, $datafile, $hash_search = true) {
             }
             }
         }
         }
     }
     }
-     
+
     /* Return the full hashed datafile path. */
     /* Return the full hashed datafile path. */
     return ($result);
     return ($result);
 }
 }
@@ -103,7 +103,7 @@ function getHashedDir($username, $dir, $hash_dirs = '') {
     if (substr($dir, -1) == '/') {
     if (substr($dir, -1) == '/') {
         $dir = substr($dir, 0, strlen($dir) - 1);
         $dir = substr($dir, 0, strlen($dir) - 1);
     }
     }
-    
+
     /* If necessary, populate the hash dir variable. */
     /* If necessary, populate the hash dir variable. */
     if ($hash_dirs == '') {
     if ($hash_dirs == '') {
         $hash_dirs = computeHashDirs($username);
         $hash_dirs = computeHashDirs($username);

+ 1 - 1
functions/tree.php

@@ -143,7 +143,7 @@ function walkTreeInPostOrderCreatingFoldersUnderTrash($index, $imap_stream, $tre
 
 
     if ($tree[$index]['doIHaveChildren']) {
     if ($tree[$index]['doIHaveChildren']) {
         sqimap_mailbox_create($imap_stream, $trash_folder . $delimiter . $subFolderName, "");
         sqimap_mailbox_create($imap_stream, $trash_folder . $delimiter . $subFolderName, "");
-        $mbx_response = sqimap_mailbox_select($imap_stream, $tree[$index]['value']);	    
+        $mbx_response = sqimap_mailbox_select($imap_stream, $tree[$index]['value']);
         $messageCount = $mbx_response['EXISTS'];
         $messageCount = $mbx_response['EXISTS'];
         if ($messageCount > 0) {
         if ($messageCount > 0) {
             sqimap_messages_copy($imap_stream, 1, '*', $trash_folder . $delimiter . $subFolderName);
             sqimap_messages_copy($imap_stream, 1, '*', $trash_folder . $delimiter . $subFolderName);

+ 4 - 4
functions/url_parser.php

@@ -85,8 +85,8 @@ $url_parser_url_tokens = array(
     'news://');
     'news://');
 
 
 global $url_parser_poss_ends;
 global $url_parser_poss_ends;
-$url_parser_poss_ends = array(' ', "\n", "\r", '<', '>', ".\r", ".\n", 
-    '.&nbsp;', '&nbsp;', ')', '(', '&quot;', '&lt;', '&gt;', '.<', 
+$url_parser_poss_ends = array(' ', "\n", "\r", '<', '>', ".\r", ".\n",
+    '.&nbsp;', '&nbsp;', ')', '(', '&quot;', '&lt;', '&gt;', '.<',
     ']', '[', '{', '}', "\240", ', ', '. ', ",\n", ",\r");
     ']', '[', '{', '}', "\240", ', ', '. ', ",\n", ",\r");
 
 
 
 
@@ -197,5 +197,5 @@ function parseUrl (&$body) {
         $start   = $target_pos;
         $start   = $target_pos;
         $blength = strlen($body);
         $blength = strlen($body);
     }
     }
-} 
-?>
+}
+?>