From 62f7daa5b0686061e12aeeee9866c195488c0d44 Mon Sep 17 00:00:00 2001 From: jervfors Date: Tue, 24 Aug 2004 00:40:28 +0000 Subject: [PATCH] Minor cleanups git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@7948 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/abook_database.php | 67 ++++---- functions/abook_global_file.php | 48 +++--- functions/abook_ldap_server.php | 58 +++---- functions/abook_local_file.php | 82 +++++----- functions/addressbook.php | 97 ++++++------ functions/attachment_common.php | 60 +++---- functions/auth.php | 16 +- functions/constants.php | 2 +- functions/db_prefs.php | 2 +- functions/global.php | 56 +++---- functions/html.php | 10 +- functions/i18n.php | 92 +++++------ functions/identity.php | 2 +- functions/imap.php | 2 +- functions/imap_mailbox.php | 1 + functions/imap_search.php | 12 +- functions/imap_utf7_local.php | 16 +- functions/index.php | 2 +- functions/mailbox_display.php | 266 ++++++++++++++++---------------- functions/options.php | 24 +-- functions/page_header.php | 30 ++-- functions/prefs.php | 8 +- functions/tree.php | 2 +- functions/url_parser.php | 8 +- 24 files changed, 482 insertions(+), 481 deletions(-) diff --git a/functions/abook_database.php b/functions/abook_database.php index 0377691c..20efeb65 100644 --- a/functions/abook_database.php +++ b/functions/abook_database.php @@ -1,5 +1,5 @@ sname = _("Personal address book"); - + if (is_array($param)) { - if (empty($param['dsn']) || - empty($param['table']) || + if (empty($param['dsn']) || + empty($param['table']) || empty($param['owner'])) { return $this->set_error('Invalid parameters'); } - + $this->dsn = $param['dsn']; $this->table = $param['table']; $this->owner = $param['owner']; - + if (!empty($param['name'])) { $this->sname = $param['name']; } @@ -94,29 +94,29 @@ class abook_database extends addressbook_backend { return $this->set_error('Invalid argument to constructor'); } } - - + + /* Open the database. New connection if $new is true */ function open($new = false) { $this->error = ''; - + /* Return true is file is open and $new is unset */ if ($this->dbh && !$new) { return true; } - + /* Close old file, if any */ if ($this->dbh) { $this->close(); } - + $dbh = DB::connect($this->dsn, true); - + if (DB::isError($dbh)) { return $this->set_error(sprintf(_("Database error: %s"), DB::errorMessage($dbh))); } - + $this->dbh = $dbh; return true; } @@ -128,7 +128,7 @@ class abook_database extends addressbook_backend { } /* ========================== Public ======================== */ - + /* Search the file */ function &search($expr) { $ret = array(); @@ -169,19 +169,19 @@ class abook_database extends addressbook_backend { } return $ret; } - + /* Lookup alias */ function &lookup($alias) { if (empty($alias)) { return array(); } - + $alias = strtolower($alias); if (!$this->open()) { return false; } - + $query = sprintf("SELECT * FROM %s WHERE owner='%s' AND LOWER(nickname)='%s'", $this->table, $this->owner, $this->dbh->quoteString($alias)); @@ -211,7 +211,7 @@ class abook_database extends addressbook_backend { if (!$this->open()) { return false; } - + if(isset($this->listing) && !$this->listing) { return array(); } @@ -221,7 +221,7 @@ class abook_database extends addressbook_backend { $this->table, $this->owner); $res = $this->dbh->query($query); - + if (DB::isError($res)) { return $this->set_error(sprintf(_("Database error: %s"), DB::errorMessage($res))); @@ -249,7 +249,7 @@ class abook_database extends addressbook_backend { if (!$this->open()) { return false; } - + /* See if user exist already */ $ret = $this->lookup($userdata['nickname']); if (!empty($ret)) { @@ -263,9 +263,9 @@ class abook_database extends addressbook_backend { "'%s','%s','%s')", $this->table, $this->owner, $this->dbh->quoteString($userdata['nickname']), - $this->dbh->quoteString($userdata['firstname']), + $this->dbh->quoteString($userdata['firstname']), $this->dbh->quoteString($userdata['lastname']), - $this->dbh->quoteString($userdata['email']), + $this->dbh->quoteString($userdata['email']), $this->dbh->quoteString($userdata['label']) ); /* Do the insert */ @@ -288,7 +288,7 @@ class abook_database extends addressbook_backend { if (!$this->open()) { return false; } - + /* Create query */ $query = sprintf("DELETE FROM %s WHERE owner='%s' AND (", $this->table, $this->owner); @@ -321,7 +321,7 @@ class abook_database extends addressbook_backend { if (!$this->open()) { return false; } - + /* See if user exist */ $ret = $this->lookup($alias); if (empty($ret)) { @@ -333,11 +333,11 @@ class abook_database extends addressbook_backend { $query = sprintf("UPDATE %s SET nickname='%s', firstname='%s', ". "lastname='%s', email='%s', label='%s' ". "WHERE owner='%s' AND nickname='%s'", - $this->table, + $this->table, $this->dbh->quoteString($userdata['nickname']), - $this->dbh->quoteString($userdata['firstname']), + $this->dbh->quoteString($userdata['firstname']), $this->dbh->quoteString($userdata['lastname']), - $this->dbh->quoteString($userdata['email']), + $this->dbh->quoteString($userdata['email']), $this->dbh->quoteString($userdata['label']), $this->owner, $this->dbh->quoteString($alias) ); @@ -354,6 +354,5 @@ class abook_database extends addressbook_backend { } } /* End of class abook_database */ - // vim: et ts=4 -?> +?> \ No newline at end of file diff --git a/functions/abook_global_file.php b/functions/abook_global_file.php index 7a8987fa..ef1f30a5 100644 --- a/functions/abook_global_file.php +++ b/functions/abook_global_file.php @@ -37,15 +37,15 @@ class abook_global_file extends addressbook_backend { function abook_global_file() { global $address_book_global_filename; $this->global_filename = $address_book_global_filename; - + $this->sname = _("Global address book"); - + $this->open(true); } /* 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. */ function open($new = false) { $this->error = ''; @@ -54,27 +54,27 @@ class abook_global_file extends addressbook_backend { if($this->filehandle && !$new) { return true; } - + /* Check that new file exists */ - if (! file_exists($this->global_filename) || + if (! file_exists($this->global_filename) || ! is_readable($this->global_filename)) { return $this->set_error($this->global_filename . ': ' . _("No such file or directory")); } - + /* Close old file, if any */ if ($this->filehandle) { $this->close(); } - + /* Open file, read only. */ $fh = @fopen($this->global_filename, 'r'); $this->writeable = false; if(! $fh) { - return $this->set_error($this->global_filename . ': ' . + return $this->set_error($this->global_filename . ': ' . _("Open failed")); } - + $this->filehandle = &$fh; return true; } @@ -88,7 +88,7 @@ class abook_global_file extends addressbook_backend { } /* ========================== Public ======================== */ - + /* Search the file */ function search($expr) { @@ -96,19 +96,19 @@ class abook_global_file extends addressbook_backend { if(is_array($expr)) { return; } - + /* Make regexp from glob'ed expression * May want to quote other special characters like (, ), -, [, ], etc. */ $expr = str_replace('?', '.', $expr); $expr = str_replace('*', '.*', $expr); - + $res = array(); if(!$this->open()) { return false; } - + @rewind($this->filehandle); - + while ($row = @fgetcsv($this->filehandle, 2048, '|')) { $line = join(' ', $row); if (eregi($expr, $line)) { @@ -122,21 +122,21 @@ class abook_global_file extends addressbook_backend { 'source' => &$this->sname); } } - + return $res; } - + /* Lookup alias */ function lookup($alias) { if (empty($alias)) { return array(); } - + $alias = strtolower($alias); - + $this->open(); @rewind($this->filehandle); - + while ($row = @fgetcsv($this->filehandle, 2048, '|')) { if (strtolower($row[0]) == $alias) { return array('nickname' => $row[0], @@ -149,7 +149,7 @@ class abook_global_file extends addressbook_backend { 'source' => &$this->sname); } } - + return array(); } @@ -158,7 +158,7 @@ class abook_global_file extends addressbook_backend { $res = array(); $this->open(); @rewind($this->filehandle); - + while ($row = @fgetcsv($this->filehandle, 2048, '|')) { $res[] = array('nickname' => $row[0], '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")); return false; } - + } /* End of class abook_local_file */ -?> +?> \ No newline at end of file diff --git a/functions/abook_ldap_server.php b/functions/abook_ldap_server.php index e60f8bd2..b030c55f 100644 --- a/functions/abook_ldap_server.php +++ b/functions/abook_ldap_server.php @@ -90,7 +90,7 @@ class abook_ldap_server extends addressbook_backend { else { $this->sname = $param['name']; } - + $this->open(true); } else { $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 */ function open($new = false) { $this->error = ''; - + /* Connection is already open */ if($this->linkid != false && !$new) { return true; } - + $this->linkid = @ldap_connect($this->server, $this->port); if(!$this->linkid) { if(function_exists('ldap_error')) { - return $this->set_error(ldap_error($this->linkid)); + return $this->set_error(ldap_error($this->linkid)); } else { return $this->set_error('ldap_connect failed'); } } - + if(!empty($this->protocol)) { if(!@ldap_set_option($this->linkid, LDAP_OPT_PROTOCOL_VERSION, $this->protocol)) { if(function_exists('ldap_error')) { @@ -137,7 +137,7 @@ class abook_ldap_server extends addressbook_backend { } else { if(!@ldap_bind($this->linkid)) { if(function_exists('ldap_error')) { - return $this->set_error(ldap_error($this->linkid)); + return $this->set_error(ldap_error($this->linkid)); } else { return $this->set_error('anonymous ldap_bind failed'); } @@ -145,7 +145,7 @@ class abook_ldap_server extends addressbook_backend { } $this->bound = true; - + return true; } @@ -177,64 +177,64 @@ class abook_ldap_server extends addressbook_backend { } } - + /* ========================== Public ======================== */ /* Search the LDAP server */ function search($expr) { - + /* To be replaced by advanded search expression parsing */ if(is_array($expr)) return false; - + /* Encode the expression */ $expr = $this->charset_encode($expr); if(strstr($expr, '*') === false) { $expr = "*$expr*"; } $expression = "cn=$expr"; - + /* Make sure connection is there */ if(!$this->open()) { return false; } - + $sret = @ldap_search($this->linkid, $this->basedn, $expression, - array('dn', 'o', 'ou', 'sn', 'givenname', + array('dn', 'o', 'ou', 'sn', 'givenname', 'cn', 'mail', 'telephonenumber'), 0, $this->maxrows, $this->timeout); - + /* Should get error from server using the ldap_error() function, * but it only exist in the PHP LDAP documentation. */ if(!$sret) { if(function_exists('ldap_error')) { - return $this->set_error(ldap_error($this->linkid)); + return $this->set_error(ldap_error($this->linkid)); } else { - return $this->set_error('ldap_search failed'); + return $this->set_error('ldap_search failed'); } } - + if(@ldap_count_entries($this->linkid, $sret) <= 0) { return array(); } - + /* Get results */ $ret = array(); $returned_rows = 0; $res = @ldap_get_entries($this->linkid, $sret); for($i = 0 ; $i < $res['count'] ; $i++) { $row = $res[$i]; - + /* Extract data common for all e-mail addresses * of an object. Use only the first name */ $nickname = $this->charset_decode($row['dn']); $fullname = $this->charset_decode($row['cn'][0]); - + if(empty($row['telephonenumber'][0])) { $phone = ''; } else { $phone = $this->charset_decode($row['telephonenumber'][0]); } - + if(!empty($row['ou'][0])) { $label = $this->charset_decode($row['ou'][0]); } @@ -243,19 +243,19 @@ class abook_ldap_server extends addressbook_backend { } else { $label = ''; } - + if(empty($row['givenname'][0])) { $firstname = ''; } else { $firstname = $this->charset_decode($row['givenname'][0]); } - + if(empty($row['sn'][0])) { $surname = ''; } else { $surname = $this->charset_decode($row['sn'][0]); } - + /* Add one row to result for each e-mail address */ if(isset($row['mail']['count'])) { for($j = 0 ; $j < $row['mail']['count'] ; $j++) { @@ -268,10 +268,10 @@ class abook_ldap_server extends addressbook_backend { 'phone' => $phone, 'backend' => $this->bnum, 'source' => &$this->sname)); - + // Limit number of hits $returned_rows++; - if(($returned_rows >= $this->maxrows) && + if(($returned_rows >= $this->maxrows) && ($this->maxrows > 0) ) { ldap_free_result($sret); return $ret; @@ -280,9 +280,9 @@ class abook_ldap_server extends addressbook_backend { } // for($j ...) } // isset($row['mail']['count']) - + } - + ldap_free_result($sret); return $ret; } /* end search() */ @@ -297,4 +297,4 @@ class abook_ldap_server extends addressbook_backend { * * Careful with this -- it could get quite large for big sites. */ } -?> +?> \ No newline at end of file diff --git a/functions/abook_local_file.php b/functions/abook_local_file.php index 37927100..04c1eaa2 100644 --- a/functions/abook_local_file.php +++ b/functions/abook_local_file.php @@ -63,7 +63,7 @@ class abook_local_file extends addressbook_backend { if(!empty($param['name'])) { $this->sname = $param['name']; } - + $this->open(true); } else { $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. - * 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. */ function open($new = false) { $this->error = ''; $file = $this->filename; $create = $this->create; - + /* Return true is file is open and $new is unset */ if($this->filehandle && !$new) { return true; } - + /* Check that new file exitsts */ if((!(file_exists($file) && is_readable($file))) && !$create) { return $this->set_error("$file: " . _("No such file or directory")); } - + /* Close old file, if any */ if($this->filehandle) { $this->close(); } - + /* Open file. First try to open for reading and writing, * but fall back to read only. */ umask($this->umask); @@ -124,7 +124,7 @@ class abook_local_file extends addressbook_backend { /* Lock the datafile - try 20 times in 5 seconds */ function lock() { for($i = 0 ; $i < 20 ; $i++) { - if(flock($this->filehandle, 2 + 4)) + if(flock($this->filehandle, 2 + 4)) return true; else usleep(250000); @@ -146,7 +146,7 @@ class abook_local_file extends addressbook_backend { if(!$newfh) { return $this->set_error($this->filename. '.tmp:' . _("Open failed")); } - + for($i = 0, $cnt=sizeof($rows) ; $i < $cnt ; $i++) { if(is_array($rows[$i])) { 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")); } } - } + } fclose($newfh); if (!@copy($this->filename . '.tmp' , $this->filename)) { @@ -168,26 +168,26 @@ class abook_local_file extends addressbook_backend { $this->open(true); return true; } - + /* ========================== Public ======================== */ - + /* Search the file */ function search($expr) { /* To be replaced by advanded search expression parsing */ if(is_array($expr)) { return; } - + /* Make regexp from glob'ed expression * May want to quote other special characters like (, ), -, [, ], etc. */ $expr = str_replace('?', '.', $expr); $expr = str_replace('*', '.*', $expr); - + $res = array(); if(!$this->open()) { return false; } @rewind($this->filehandle); - + while ($row = @fgetcsv($this->filehandle, 2048, '|')) { $line = join(' ', $row); if(eregi($expr, $line)) { @@ -201,10 +201,10 @@ class abook_local_file extends addressbook_backend { 'source' => &$this->sname)); } } - + return $res; } - + /* Lookup alias */ function lookup($alias) { if(empty($alias)) { @@ -212,10 +212,10 @@ class abook_local_file extends addressbook_backend { } $alias = strtolower($alias); - + $this->open(); @rewind($this->filehandle); - + while ($row = @fgetcsv($this->filehandle, 2048, '|')) { if(strtolower($row[0]) == $alias) { return array('nickname' => $row[0], @@ -228,7 +228,7 @@ class abook_local_file extends addressbook_backend { 'source' => &$this->sname); } } - + return array(); } @@ -237,7 +237,7 @@ class abook_local_file extends addressbook_backend { $res = array(); $this->open(); @rewind($this->filehandle); - + while ($row = @fgetcsv($this->filehandle, 2048, '|')) { array_push($res, array('nickname' => $row[0], '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"), $ret['nickname'])); } - + /* Here is the data to write */ $data = $this->quotevalue($userdata['nickname']) . '|' . $this->quotevalue($userdata['firstname']) . '|' . @@ -274,31 +274,31 @@ class abook_local_file extends addressbook_backend { $data = ereg_replace("[\r\n]", ' ', $data); /* Add linefeed at end */ $data = $data . "\n"; - + /* Reopen file, just to be sure */ $this->open(true); if(!$this->writeable) { return $this->set_error(_("Addressbook is read-only")); } - + /* Lock the file */ if(!$this->lock()) { return $this->set_error(_("Could not lock datafile")); } - + /* Write */ $r = sq_fwrite($this->filehandle, $data); - + /* Unlock file */ $this->unlock(); - + /* Test write result */ if($r === FALSE) { /* Fail */ $this->set_error(_("Write to addressbook failed")); return FALSE; } - + return TRUE; } @@ -307,13 +307,13 @@ class abook_local_file extends addressbook_backend { if(!$this->writeable) { return $this->set_error(_("Addressbook is read-only")); } - + /* Lock the file to make sure we're the only process working * on it. */ if(!$this->lock()) { return $this->set_error(_("Could not lock datafile")); } - + /* Read file into memory, ignoring nicknames to delete */ @rewind($this->filehandle); $i = 0; @@ -323,13 +323,13 @@ class abook_local_file extends addressbook_backend { $rows[$i++] = $row; } } - + /* Write data back */ if(!$this->overwrite($rows)) { $this->unlock(); return false; } - + $this->unlock(); return true; } @@ -339,21 +339,21 @@ class abook_local_file extends addressbook_backend { if(!$this->writeable) { return $this->set_error(_("Addressbook is read-only")); } - + /* See if user exists */ $ret = $this->lookup($alias); if(empty($ret)) { return $this->set_error(sprintf(_("User '%s' does not exist"), $alias)); } - + /* Lock the file to make sure we're the only process working * on it. */ if(!$this->lock()) { 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 */ $this->open(true); @rewind($this->filehandle); @@ -366,21 +366,21 @@ class abook_local_file extends addressbook_backend { $rows[$i++] = array(0 => $userdata['nickname'], 1 => $userdata['firstname'], 2 => $userdata['lastname'], - 3 => $userdata['email'], + 3 => $userdata['email'], 4 => $userdata['label']); } } - + /* Write data back */ if(!$this->overwrite($rows)) { $this->unlock(); return false; } - + $this->unlock(); return true; } - + /* Function for quoting values before saving */ function quotevalue($value) { /* 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 */ -?> +?> \ No newline at end of file diff --git a/functions/addressbook.php b/functions/addressbook.php index 18cf590c..22cc1c01 100644 --- a/functions/addressbook.php +++ b/functions/addressbook.php @@ -1,4 +1,5 @@ $b['backend']) { @@ -143,7 +144,7 @@ function addressbook_cmp($a,$b) { } else if($a['backend'] < $b['backend']) { return -1; } - + return (strtolower($a['name']) > strtolower($b['name'])) ? 1 : -1; } @@ -162,7 +163,7 @@ class AddressBook { var $error = ''; var $localbackend = 0; var $localbackendname = ''; - + // Constructor function. function AddressBook() { $localbackendname = _("Personal address book"); @@ -203,7 +204,7 @@ class AddressBook { $newback->bnum = $this->numbackends; $this->backends[$this->numbackends] = $newback; - + /* Store ID of first local backend added */ if ($this->localbackend == 0 && $newback->btype == 'local') { $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 * nickname optionally prepended. */ @@ -278,11 +279,11 @@ class AddressBook { /* Return a sorted search */ function s_search($expression, $bnum = -1) { - + $ret = $this->search($expression, $bnum); if ( is_array( $ret ) ) { usort($ret, 'addressbook_cmp'); - } + } return $ret; } @@ -292,9 +293,9 @@ class AddressBook { * local backends. */ function lookup($alias, $bnum = -1) { - + $ret = array(); - + if ($bnum > -1) { $res = $this->backends[$bnum]->lookup($alias); if (is_array($res)) { @@ -304,7 +305,7 @@ class AddressBook { return false; } } - + $sel = $this->get_backend_list('local'); for ($i = 0 ; $i < sizeof($sel) ; $i++) { $backend = &$sel[$i]; @@ -318,7 +319,7 @@ class AddressBook { return false; } } - + return $ret; } @@ -326,13 +327,13 @@ class AddressBook { /* Return all addresses */ function list_addr($bnum = -1) { $ret = array(); - + if ($bnum == -1) { $sel = $this->get_backend_list('local'); } else { $sel = array(0 => &$this->backends[$bnum]); } - + for ($i = 0 ; $i < sizeof($sel) ; $i++) { $backend = &$sel[$i]; $backend->error = ''; @@ -344,7 +345,7 @@ class AddressBook { return false; } } - + return $ret; } @@ -354,7 +355,7 @@ class AddressBook { * to, or false if it failed. */ function add($userdata, $bnum) { - + /* Validate data */ if (!is_array($userdata)) { $this->error = _("Invalid input data"); @@ -371,18 +372,18 @@ class AddressBook { if (empty($userdata['nickname'])) { $userdata['nickname'] = $userdata['email']; } - + if (eregi('[ \\:\\|\\#\\"\\!]', $userdata['nickname'])) { $this->error = _("Nickname contains illegal characters"); return false; } - + /* Check that specified backend accept new entries */ if (!$this->backends[$bnum]->writeable) { $this->error = _("Addressbook is read-only"); return false; } - + /* Add address to backend */ $res = $this->backends[$bnum]->add($userdata); if ($res) { @@ -391,7 +392,7 @@ class AddressBook { $this->error = $this->backends[$bnum]->error; return false; } - + return false; // Not reached } /* end of add() */ @@ -401,23 +402,23 @@ class AddressBook { * If $alias is an array, all users in the array are removed. */ function remove($alias, $bnum) { - + /* Check input */ if (empty($alias)) { return true; } - + /* Convert string to single element array */ if (!is_array($alias)) { $alias = array(0 => $alias); } - - /* Check that specified backend is writeable */ + + /* Check that specified backend is writable */ if (!$this->backends[$bnum]->writeable) { $this->error = _("Addressbook is read-only"); return false; } - + /* Remove user from backend */ $res = $this->backends[$bnum]->remove($alias); if ($res) { @@ -426,7 +427,7 @@ class AddressBook { $this->error = $this->backends[$bnum]->error; return false; } - + return FALSE; /* Not reached */ } /* end of remove() */ @@ -436,12 +437,12 @@ class AddressBook { * If $alias is an array, all users in the array are removed. */ function modify($alias, $userdata, $bnum) { - + /* Check input */ if (empty($alias) || !is_string($alias)) { return true; } - + /* Validate data */ if(!is_array($userdata)) { $this->error = _("Invalid input data"); @@ -455,22 +456,22 @@ class AddressBook { $this->error = _("E-mail address is missing"); return false; } - + if (eregi('[\\: \\|\\#"\\!]', $userdata['nickname'])) { $this->error = _("Nickname contains illegal characters"); return false; } - + if (empty($userdata['nickname'])) { $userdata['nickname'] = $userdata['email']; } - - /* Check that specified backend is writeable */ + + /* Check that specified backend is writable */ if (!$this->backends[$bnum]->writeable) { $this->error = _("Addressbook is read-only");; return false; } - + /* Modify user in backend */ $res = $this->backends[$bnum]->modify($alias, $userdata); if ($res) { @@ -479,11 +480,11 @@ class AddressBook { $this->error = $this->backends[$bnum]->error; return false; } - + return FALSE; /* Not reached */ } /* end of modify() */ - - + + } /* End of class Addressbook */ /** @@ -496,7 +497,7 @@ class addressbook_backend { var $btype = 'dummy'; var $bname = 'dummy'; var $sname = 'Dummy backend'; - + /* * Variables common for all backends, but that * should not be changed by the backends. @@ -504,40 +505,40 @@ class addressbook_backend { var $bnum = -1; var $error = ''; var $writeable = false; - + function set_error($string) { $this->error = '[' . $this->sname . '] ' . $string; return false; } - - + + /* ========================== Public ======================== */ - + function search($expression) { $this->set_error('search not implemented'); return false; } - + function lookup($alias) { $this->set_error('lookup not implemented'); return false; } - + function list_addr() { $this->set_error('list_addr not implemented'); return false; } - + function add($userdata) { $this->set_error('add not implemented'); return false; } - + function remove($alias) { $this->set_error('delete not implemented'); return false; } - + function modify($alias, $newuserdata) { $this->set_error('modify not implemented'); return false; @@ -618,7 +619,7 @@ function get_abook_sort() { * @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 $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 ) { global $form_url; @@ -656,7 +657,7 @@ if (isset($address_book_global_filename)) { } /* 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)) ) { include_once(SM_PATH . 'functions/abook_database.php'); } diff --git a/functions/attachment_common.php b/functions/attachment_common.php index dcb700c9..65bfba0d 100644 --- a/functions/attachment_common.php +++ b/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 that links to the text attachment viewer. - + $Args[1] = the array of actions - + Use our plugin name for adding an action $Args[1]['attachment_common'] = array for href and text - + $Args[1]['attachment_common']['text'] = What is displayed $Args[1]['attachment_common']['href'] = Where it links to - + This sets the 'href' of this plugin for a new link. */ 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'] = - set_url_var($Args[1]['attachment_common']['href'], + set_url_var($Args[1]['attachment_common']['href'], 'ent_id',$Args[5]); - + /* The link that we created needs a name. "view" will be displayed for all text attachments handled by this plugin. */ $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 for viewing text attachments is not the same as the default link for this file, we'll change it. - + 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 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. */ $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); @@ -144,7 +144,7 @@ function attachment_common_link_html(&$Args) /* why use the overridetype? can this be removed */ '&override_type0=text&override_type1=html'; $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]); $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; sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER); - + $info['passed_id'] = $Args[3]; $info['mailbox'] = $Args[4]; $info['ent_id'] = $Args[5]; - + $attachment_common_show_images_list[] = $info; - + $Args[1]['attachment_common']['href'] = SM_PATH . 'src/image.php?'. $QUERY_STRING; $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]); - + $Args[1]['attachment_common']['text'] = _("view"); - + $Args[6] = $Args[1]['attachment_common']['href']; } @@ -179,14 +179,14 @@ function attachment_common_link_image(&$Args) function attachment_common_link_vcard(&$Args) { sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER); - + $Args[1]['attachment_common']['href'] = SM_PATH . 'src/vcard.php?'. $QUERY_STRING; $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]); - + $Args[1]['attachment_common']['text'] = _("Business Card"); - + $Args[6] = $Args[1]['attachment_common']['href']; } @@ -194,23 +194,23 @@ function attachment_common_link_vcard(&$Args) function attachment_common_octet_stream(&$Args) { global $FileExtensionToMimeType; - + do_hook('attachment_common-load_mime_types'); - + ereg('\\.([^\\.]+)$', $Args[7], $Regs); - + $Ext = strtolower($Regs[1]); - + 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]); - + foreach ($Ret as $a => $b) { $Args[$a] = $b; } } -?> +?> \ No newline at end of file diff --git a/functions/auth.php b/functions/auth.php index 72a7b75e..caef3b5e 100644 --- a/functions/auth.php +++ b/functions/auth.php @@ -42,16 +42,16 @@ function is_logged_in() { if ( sqsession_is_registered('user_is_logged_in') ) { return; } else { - global $PHP_SELF, $session_expired_post, + global $PHP_SELF, $session_expired_post, $session_expired_location, $squirrelmail_language; /* First we store some information in the new session to prevent * information-loss. */ - + $session_expired_post = $_POST; $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'); } 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) { $result=digest_md5_parse_challenge($challenge); - + // verify server supports qop=auth // $qop = explode(",",$result['qop']); //if (!in_array("auth",$qop)) { @@ -139,7 +139,7 @@ function digest_md5_response ($username,$password,$challenge,$service,$host) { $reply .= ',qop=' . $qop_value; $reply = base64_encode($reply); return $reply . "\r\n"; - + } /** @@ -219,14 +219,14 @@ function hmac_md5($data, $key='') { return $hmac; } -/** +/** * Fillin user and password based on SMTP auth settings. * * @param string $user Reference to SMTP username * @param string $pass Reference to SMTP password (unencrypted) */ function get_smtp_user(&$user, &$pass) { - global $username, $smtp_auth_mech, + global $username, $smtp_auth_mech, $smtp_sitewide_user, $smtp_sitewide_pass; if ($smtp_auth_mech == 'none') { @@ -242,4 +242,4 @@ function get_smtp_user(&$user, &$pass) { } } -?> +?> \ No newline at end of file diff --git a/functions/constants.php b/functions/constants.php index d4b1d9b8..382d3cc9 100644 --- a/functions/constants.php +++ b/functions/constants.php @@ -55,4 +55,4 @@ define('SMPREF_JS_AUTODETECT', 2); do_hook('loading_constants'); -?> +?> \ No newline at end of file diff --git a/functions/db_prefs.php b/functions/db_prefs.php index 2e54bed2..91805d21 100644 --- a/functions/db_prefs.php +++ b/functions/db_prefs.php @@ -397,4 +397,4 @@ function getSig($data_dir, $username, $number) { } // vim: et ts=4 -?> +?> \ No newline at end of file diff --git a/functions/global.php b/functions/global.php index bed433d2..1330022c 100644 --- a/functions/global.php +++ b/functions/global.php @@ -6,9 +6,9 @@ * Copyright (c) 1999-2004 The SquirrelMail Project Team * 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 - * php versions. + * php versions. * * @version $Id$ * @package squirrelmail @@ -18,10 +18,10 @@ require_once(SM_PATH . 'config/config.php'); /** 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. @@ -54,23 +54,23 @@ if (get_magic_quotes_gpc()) { $_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) * @param int a major version number * @param int b minor version number * @param int c release number * @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' ); } /** - * 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. * * 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[2] < $c ) ) { return FALSE; - } - return TRUE; + } + return TRUE; } @@ -123,8 +123,8 @@ function sqsession_register ($var, $name) { sqsession_is_active(); - $_SESSION["$name"] = $var; - + $_SESSION["$name"] = $var; + session_register("$name"); } @@ -138,7 +138,7 @@ function sqsession_unregister ($name) { sqsession_is_active(); unset($_SESSION[$name]); - + session_unregister("$name"); } @@ -151,11 +151,11 @@ function sqsession_unregister ($name) { function sqsession_is_registered ($name) { $test_name = &$name; $result = false; - + if (isset($_SESSION[$test_name])) { $result = true; } - + return $result; } @@ -170,14 +170,14 @@ define('SQ_FORM',6); /** * 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 * $_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. * - * 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. * * example: @@ -196,8 +196,8 @@ function sqgetGlobalVar($name, &$value, $search = SQ_INORDER) { enclosing them in quotes will cause them to evaluate as strings. */ 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. */ default: case SQ_INORDER: // check session, post, get @@ -220,13 +220,13 @@ function sqgetGlobalVar($name, &$value, $search = SQ_INORDER) { if ( isset($_GET[$name]) ) { $value = $_GET[$name]; return TRUE; - } + } /* NO IF HERE. FOR SQ_INORDER CASE, EXIT after GET */ break; case SQ_COOKIE: if ( isset($_COOKIE[$name]) ) { $value = $_COOKIE[$name]; - return TRUE; + return TRUE; } break; case SQ_SERVER: @@ -278,7 +278,7 @@ function sqsession_destroy() { */ function sqsession_is_active() { - + $sessid = session_id(); if ( empty( $sessid ) ) { session_start(); @@ -286,4 +286,4 @@ function sqsession_is_active() { } // vim: et ts=4 -?> +?> \ No newline at end of file diff --git a/functions/html.php b/functions/html.php index 01e3ab15..91acef95 100644 --- a/functions/html.php +++ b/functions/html.php @@ -51,7 +51,7 @@ function html_tag( $tag, // Tag to output } if ( $bgcolor <> '' ) { - $bgc = " bgcolor=\"$bgcolor\""; + $bgc = " bgcolor=\"$bgcolor\""; } switch ( $align ) { @@ -84,7 +84,7 @@ function html_tag( $tag, // Tag to output $ret .= ">$val"; } else { $ret .= '>'; - } + } return( $ret ); } @@ -100,7 +100,7 @@ function html_tag( $tag, // Tag to output '/.+(\\?'.$var.')=(.*)$/AU', /* at front and only var */ '/.+(\\&'.$var.')=(.*)$/AU' /* at the end */ ); - preg_replace('/&/','&',$url); + preg_replace('/&/','&',$url); switch (true) { case (preg_match($pat_a[0],$url,$regs)): $k = $regs[1]; @@ -151,7 +151,7 @@ function html_tag( $tag, // Tag to output function echo_template_var($var, $format_ar = array() ) { $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; switch (true) { @@ -179,4 +179,4 @@ function html_tag( $tag, // Tag to output echo $format_ar[$frm_last]; } } -?> +?> \ No newline at end of file diff --git a/functions/i18n.php b/functions/i18n.php index 83dfe306..58ab06ce 100644 --- a/functions/i18n.php +++ b/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 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. - * + * * sanitizing of html tags is also done by this function. * * @param string $charset @@ -62,8 +62,8 @@ function charset_decode ($charset, $string) { $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. */ 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. /* All HTML special characters are 7 bit and can be replaced first */ - + $string = htmlspecialchars ($string); /* controls cpu and memory intensive decoding cycles */ @@ -112,7 +112,7 @@ function charset_decode ($charset, $string) { * @param string $string * @param string $charset * @param boolean $htmlencode keep htmlspecialchars encoding - * @param string + * @param string */ function charset_encode($string,$charset,$htmlencode=true) { global $default_charset; @@ -159,7 +159,7 @@ function charset_convert($in_charset,$string,$out_charset,$htmlencode=true) { function fixcharset($charset) { // minus removed from function names $charset=str_replace('-','_',$charset); - + // windows-125x and cp125x charsets $charset=str_replace('windows_','cp',$charset); @@ -178,18 +178,18 @@ function fixcharset($charset) { * if $do_search is true, then scan the browser information * 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. * * 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. * * @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 $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) { @@ -208,13 +208,13 @@ function set_up_language($sm_language, $do_search = false, $default = false) { if ($do_search && ! $sm_language && isset($accept_lang)) { $sm_language = substr($accept_lang, 0, 2); } - + if ((!$sm_language||$default) && isset($squirrelmail_default_language)) { $squirrelmail_language = $squirrelmail_default_language; $sm_language = $squirrelmail_default_language; } $sm_notAlias = $sm_language; - + // Catching removed translation // System reverts to English translation if user prefs contain translation // 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); // Set text direction/alignment variables - if (isset($languages[$sm_notAlias]['DIR']) && + if (isset($languages[$sm_notAlias]['DIR']) && $languages[$sm_notAlias]['DIR'] == 'rtl') { /** * Text direction @@ -350,7 +350,7 @@ if (! isset($squirrelmail_language)) { * * Structure of array: * $languages['language']['variable'] = 'value' - * + * * Possible 'variable' names: * NAME - Translation name in English * CHARSET - Encoding used by translation @@ -359,7 +359,7 @@ if (! isset($squirrelmail_language)) { * 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' * XTRA_CODE - translation uses special functions. See doc/i18n.txt - * + * * Each 'language' definition requires NAME+CHARSET or ALIAS variables. * * @name $languages @@ -713,7 +713,7 @@ function japanese_xtra() { $detect_encoding == 'EUC-JP' || $detect_encoding == 'SJIS' || $detect_encoding == 'UTF-8') { - + $ret = mb_convert_kana(mb_convert_encoding($ret, 'EUC-JP', 'AUTO'), "KV"); } break; @@ -723,13 +723,13 @@ function japanese_xtra() { $detect_encoding == 'EUC-JP' || $detect_encoding == 'SJIS' || $detect_encoding == 'UTF-8') { - + $ret = mb_convert_encoding(mb_convert_kana($ret, "KV"), 'JIS', 'AUTO'); } break; case 'strimwidth': $width = func_get_arg(2); - $ret = mb_strimwidth($ret, 0, $width, '...'); + $ret = mb_strimwidth($ret, 0, $width, '...'); break; case 'encodeheader': $result = ''; @@ -744,7 +744,7 @@ function japanese_xtra() { if ($prevcsize == 1) { $result .= $tmpstr; } else { - $result .= str_replace(' ', '', + $result .= str_replace(' ', '', mb_encode_mimeheader($tmpstr,'iso-2022-jp','B','')); } $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" . "\xd4\xa1\xd6\xa1\xd8\xa1\xda\xa1\xcc\xa1\xf0\xa1\xca\xa1\xce\xa1\xd0\xa1\xef"; $wrap = func_get_arg(2); - - if (strlen($ret) >= $wrap && + + if (strlen($ret) >= $wrap && substr($ret, 0, 1) != '>' && strpos($ret, 'http://') === FALSE && strpos($ret, 'https://') === FALSE && strpos($ret, 'ftp://') === FALSE) { - + $ret = mb_convert_kana($ret, "KV"); $line_new = ''; $ptr = 0; - + while ($ptr < strlen($ret) - 1) { $l = mb_strcut($ret, $ptr, $wrap); $ptr += strlen($l); $tmp = $l; - + $l = mb_strcut($ret, $ptr, 2); while (strlen($l) != 0 && mb_strpos($no_begin, $l) !== FALSE ) { $tmp .= $l; @@ -836,7 +836,7 @@ function japanese_xtra() { /** * 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. * @param string $ret text, that has to be converted * @return string converted string @@ -872,7 +872,7 @@ function japanese_xtra_encode($ret) { $detect_encoding == 'EUC-JP' || $detect_encoding == 'SJIS' || $detect_encoding == 'UTF-8') { - + $ret = mb_convert_encoding(mb_convert_kana($ret, "KV"), 'JIS', 'AUTO'); } } @@ -901,7 +901,7 @@ function japanese_xtra_encodeheader($ret) { if ($prevcsize == 1) { $result .= $tmpstr; } else { - $result .= str_replace(' ', '', + $result .= str_replace(' ', '', mb_encode_mimeheader($tmpstr,'iso-2022-jp','B','')); } $tmpstr = $tmp; @@ -924,7 +924,7 @@ function japanese_xtra_encodeheader($ret) { /** * 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. * @param string $ret header string * @return string decoded header string @@ -963,7 +963,7 @@ function japanese_xtra_downloadfilename($ret,$useragent) { /** * Japanese wordwrap function - * + * * wraps text at set number of symbols * @param string $ret text * @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"; $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"; - - if (strlen($ret) >= $wrap && + + if (strlen($ret) >= $wrap && substr($ret, 0, 1) != '>' && strpos($ret, 'http://') === FALSE && strpos($ret, 'https://') === FALSE && strpos($ret, 'ftp://') === FALSE) { $ret = mb_convert_kana($ret, "KV"); - + $line_new = ''; $ptr = 0; - + while ($ptr < strlen($ret) - 1) { $l = mb_strcut($ret, $ptr, $wrap); $ptr += strlen($l); $tmp = $l; - + $l = mb_strcut($ret, $ptr, 2); while (strlen($l) != 0 && mb_strpos($no_begin, $l) !== FALSE ) { $tmp .= $l; @@ -1069,7 +1069,7 @@ function japanese_xtra_strimwidth($ret,$width) { * Korean downloaded filename processing functions * * @param string default return value - * @return string + * @return string */ function korean_xtra_downloadfilename($ret) { $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 - * - * 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. * * @param string $string Text that needs to be cleaned @@ -1133,14 +1133,14 @@ switch($output_charset): return $string; endswitch; -// return space instead of non-braking space. +// return space instead of non-braking space. return str_replace($nbsp,' ',$string); } /** * 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. * * @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 switch ($default_charset): case "windows-1251": - if ( $input_charset == "iso-8859-5" || + if ( $input_charset == "iso-8859-5" || $input_charset == "koi8-r" || $input_charset == "koi8-u" ) { return true; @@ -1168,22 +1168,22 @@ case "windows-1251": return false; } case "windows-1257": - if ( $input_charset == "iso-8859-13" || + if ( $input_charset == "iso-8859-13" || $input_charset == "iso-8859-4" ) { return true; } else { return false; } case "iso-8859-4": - if ( $input_charset == "iso-8859-13" || + if ( $input_charset == "iso-8859-13" || $input_charset == "windows-1257" ) { return true; } else { return false; } 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" ) { return true; } else { @@ -1198,7 +1198,7 @@ case "iso-8859-13": } case "koi8-r": if ( $input_charset == "windows-1251" || - $input_charset == "iso-8859-5" || + $input_charset == "iso-8859-5" || $input_charset == "koi8-u" ) { return true; } else { diff --git a/functions/identity.php b/functions/identity.php index e4e0d4d1..a400321a 100644 --- a/functions/identity.php +++ b/functions/identity.php @@ -51,4 +51,4 @@ function get_identities() { return $identities; } -?> +?> \ No newline at end of file diff --git a/functions/imap.php b/functions/imap.php index 0f0bfb8f..cd2e55ba 100644 --- a/functions/imap.php +++ b/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_search.php'); -?> +?> \ No newline at end of file diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index e7b456e2..4faef27b 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -1,4 +1,5 @@ +?> \ No newline at end of file diff --git a/functions/imap_utf7_local.php b/functions/imap_utf7_local.php index 17961e14..86acabb7 100644 --- a/functions/imap_utf7_local.php +++ b/functions/imap_utf7_local.php @@ -22,11 +22,11 @@ */ 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) // koi8-r and gb2312 can be added only in php 4.3+ if ( stristr($default_charset, 'iso-8859-') || - stristr($default_charset, 'utf-8') || + stristr($default_charset, 'utf-8') || stristr($default_charset, 'iso-2022-jp') ) { if (function_exists('mb_convert_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) { global $languages, $squirrelmail_language; - + if (isset($languages[$squirrelmail_language]['XTRA_CODE']) && function_exists($languages[$squirrelmail_language]['XTRA_CODE'].'_utf7_imap_encode')) { 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; } - // 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 $utf7_s = ''; // imap-utf7-encoded string for ($i = 0; $i < strlen($s); $i++) { @@ -90,7 +90,7 @@ function imap_utf7_encode_local($s) { function imap_utf7_decode_local($s) { global $languages, $squirrelmail_language; - + if (isset($languages[$squirrelmail_language]['XTRA_CODE']) && function_exists($languages[$squirrelmail_language]['XTRA_CODE'] . '_utf7_imap_decode')) { 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 - + $b64_s = ''; $iso_8859_1_s = ''; for ($i = 0, $len = strlen($s); $i < $len; $i++) { @@ -223,4 +223,4 @@ function decodeBASE64($s) { return $d; } -?> +?> \ No newline at end of file diff --git a/functions/index.php b/functions/index.php index cd42c7b2..53a4e6bc 100644 --- a/functions/index.php +++ b/functions/index.php @@ -20,4 +20,4 @@ header("Location:../index.php"); /* pretty impressive huh? */ -?> +?> \ No newline at end of file diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index 53b67c41..08a51313 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -1,17 +1,17 @@ "; -* -* @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 ""; + * + * @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, $aMailbox, $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) { global $color; 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) { global $index_order, $internal_date_sort, $color; @@ -1310,7 +1310,7 @@ function printHeader($aMailbox) { echo html_tag( 'tr' ,'' , 'center', $color[5] ); /* 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); $subjectwidth = 100; 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 ) { 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) { global $checkall, $javascript_on; 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) { /* Compute the $msg_cnt_str. */ $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) { sqgetGlobalVar('PHP_SELF',$php_self,SQ_SERVER); $result = " tag -* -* @param string $string string -* @param string $align alignment -*/ + * Puts string into cell, aligns it and adds tag + * + * @param string $string string + * @param string $align alignment + */ function getSmallStringCell($string, $align) { return html_tag('td', '' . $string . ':  ', @@ -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) { global $handleAsSent_result; diff --git a/functions/options.php b/functions/options.php index dd64ca8e..f70fbf66 100644 --- a/functions/options.php +++ b/functions/options.php @@ -154,7 +154,7 @@ class SquirrelOption { function createHTMLWidget() { global $javascript_on; - // Use new value if available + // Use new value if available if (!empty($this->new_value)) { $tempValue = $this->value; $this->value = $this->new_value; @@ -197,7 +197,7 @@ class SquirrelOption { /* Add the "post script" for this option. */ $result .= $this->post_script; - + // put correct value back if need be if (!empty($this->new_value)) { $this->value = $tempValue; @@ -227,7 +227,7 @@ class SquirrelOption { } $result = "name\" value=\"" . - htmlspecialchars($this->value) . + htmlspecialchars($this->value) . "\" size=\"$width\" $this->script />$this->trailing_text\n"; return ($result); } @@ -239,7 +239,7 @@ class SquirrelOption { /* Add each possible value to the select list. */ foreach ($this->possible_values as $real_value => $disp_value) { /* Start the next new option string. */ - $new_option = '\n"; } /* And add the new option string to our select tag. */ $result .= $new_option; - } + } /* Close the select tag and return our happy result. */ $result .= "\n"; return ($result); @@ -322,11 +322,11 @@ class SquirrelOption { } function createWidget_Float() { - + global $javascript_on; // 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) return preg_replace('/\/>/', ' onChange="origVal=this.value; newVal=\'\'; ' . 'for (i=0;i=\'0\' ' @@ -340,11 +340,11 @@ class SquirrelOption { function createWidget_Boolean() { /* Do the whole current value thing. */ if ($this->value != SMPREF_NO) { - $yes_chk = ' checked=""'; + $yes_chk = ' checked="checked"'; $no_chk = ''; } else { $yes_chk = ''; - $no_chk = ' checked=""'; + $no_chk = ' checked="checked"'; } /* Build the yes choice. */ diff --git a/functions/page_header.php b/functions/page_header.php index fd072dc9..afbe6b89 100644 --- a/functions/page_header.php +++ b/functions/page_header.php @@ -46,16 +46,16 @@ function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE echo ''; } - + if ($squirrelmail_language == 'ja_JP') { echo "\n"; echo '' . "\n"; } - + if ($do_hook) { do_hook('generic_header'); } - + echo "\n$title$xtra\n"; /* work around IE6's scrollbar bug */ @@ -63,9 +63,9 @@ function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE