From b9bfd165b055eac4f5e62438ae78eaab01cbb90e Mon Sep 17 00:00:00 2001 From: thomppj Date: Wed, 31 Jan 2001 18:27:06 +0000 Subject: [PATCH] Correct changes of "" to ''. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1015 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/abook_database.php | 14 ++--- functions/addressbook.php | 102 +++++++++++++++++------------------ functions/array.php | 12 ++--- functions/auth.php | 2 +- functions/date.php | 82 ++++++++++++++-------------- 5 files changed, 107 insertions(+), 105 deletions(-) diff --git a/functions/abook_database.php b/functions/abook_database.php index 62a2610b..bc9fede2 100644 --- a/functions/abook_database.php +++ b/functions/abook_database.php @@ -27,15 +27,15 @@ ** $Id$ **/ - require_once("DB.php"); + require_once('DB.php'); class abook_database extends addressbook_backend { - var $btype = "local"; - var $bname = "database"; + var $btype = 'local'; + var $bname = 'database'; - var $dsn = ""; - var $table = ""; - var $owner = ""; + var $dsn = ''; + var $table = ''; + var $owner = ''; var $dbh = false; var $writeable = true; @@ -207,7 +207,7 @@ // See if user exist already $ret = $this->lookup($userdata['nickname']); if(!empty($ret)) - return $this->set_error(sprintf(_((User \'%s\' already exist"), + return $this->set_error(sprintf(_("User '%s' already exist"), $ret['nickname'])); // Create query diff --git a/functions/addressbook.php b/functions/addressbook.php index baaff51b..c83d4faa 100644 --- a/functions/addressbook.php +++ b/functions/addressbook.php @@ -11,8 +11,8 @@ $addressbook_php = true; // Include backends here. - include("../functions/abook_local_file.php"); - include("../functions/abook_ldap_server.php"); + include('../functions/abook_local_file.php'); + include('../functions/abook_ldap_server.php'); // Create and initialize an addressbook object. @@ -24,9 +24,9 @@ $abook = new AddressBook; // Always add a local backend - $filename = sprintf("%s%s.abook", $data_dir, $username); - $r = $abook->add_backend("local_file", Array("filename" => $filename, - "create" => true)); + $filename = sprintf('%s%s.abook', $data_dir, $username); + $r = $abook->add_backend('local_file', Array('filename' => $filename, + 'create' => true)); if(!$r && $showerr) { printf(_("Error opening file %s"), $filename); exit; @@ -36,15 +36,15 @@ return $abook; // Load configured LDAP servers (if PHP has LDAP support) - if(is_array($ldap_server) && function_exists("ldap_connect")) { + if(is_array($ldap_server) && function_exists('ldap_connect')) { reset($ldap_server); while(list($undef,$param) = each($ldap_server)) { if(is_array($param)) { - $r = $abook->add_backend("ldap_server", $param); + $r = $abook->add_backend('ldap_server', $param); if(!$r && $showerr) { - printf(" "._("Error initializing LDAP server %s:"). - "
\n", $param["host"]); - printf(" ".$abook->error); + printf(' ' . _("Error initializing LDAP server %s:") . + "
\n", $param['host']); + print(' ' . $abook->error); exit; } } @@ -59,11 +59,11 @@ // Had to move this function outside of the Addressbook Class // PHP 4.0.4 Seemed to be having problems with inline functions. function cmp($a,$b) { - if($a["backend"] > $b["backend"]) + if($a['backend'] > $b['backend']) return 1; - else if($a["backend"] < $b["backend"]) + else if($a['backend'] < $b['backend']) return -1; - return (strtolower($a["name"]) > strtolower($b["name"])) ? 1 : -1; + return (strtolower($a['name']) > strtolower($b['name'])) ? 1 : -1; } @@ -76,9 +76,9 @@ class AddressBook { var $backends = array(); var $numbackends = 0; - var $error = ""; + var $error = ''; var $localbackend = 0; - var $localbackendname = ""; + var $localbackendname = ''; // Constructor function. function AddressBook() { @@ -87,7 +87,7 @@ // Return an array of backends of a given type, // or all backends if no type is specified. - function get_backend_list($type = "") { + function get_backend_list($type = '') { $ret = array(); for($i = 1 ; $i <= $this->numbackends ; $i++) { if(empty($type) || $type == $this->backends[$i]->btype) { @@ -104,8 +104,8 @@ // (without the abook_ prefix), and $param is an optional // mixed variable that is passed to the backend constructor. // See each of the backend classes for valid parameters. - function add_backend($backend, $param = "") { - $backend_name = "abook_".$backend; + function add_backend($backend, $param = '') { + $backend_name = 'abook_' . $backend; eval("\$newback = new $backend_name(\$param);"); if(!empty($newback->error)) { $this->error = $newback->error; @@ -118,7 +118,7 @@ $this->backends[$this->numbackends] = $newback; // 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->localbackendname = $newback->sname; } @@ -131,20 +131,20 @@ // all backends of a given type. function search($expression, $bnum = -1) { $ret = array(); - $this->error = ""; + $this->error = ''; // Search all backends if($bnum == -1) { - $sel = $this->get_backend_list(""); + $sel = $this->get_backend_list(''); $failed = 0; for($i = 0 ; $i < sizeof($sel) ; $i++) { $backend = &$sel[$i]; - $backend->error = ""; + $backend->error = ''; $res = $backend->search($expression); if(is_array($res)) { $ret = array_merge($ret, $res); } else { - $this->error = $this->error . "
\n". $backend->error; + $this->error .= "
\n" . $backend->error; $failed++; } } @@ -159,7 +159,7 @@ else { $ret = $this->backends[$bnum]->search($expression); if(!is_array($ret)) { - $this->error = $this->error . "
\n". $this->backends[$bnum]->error; + $this->error .= "
\n" . $this->backends[$bnum]->error; return false; } } @@ -194,10 +194,10 @@ } } - $sel = $this->get_backend_list("local"); + $sel = $this->get_backend_list('local'); for($i = 0 ; $i < sizeof($sel) ; $i++) { $backend = &$sel[$i]; - $backend->error = ""; + $backend->error = ''; $res = $backend->lookup($alias); if(is_array($res)) { if(!empty($res)) @@ -217,13 +217,13 @@ $ret = array(); if($bnum == -1) - $sel = $this->get_backend_list("local"); + $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 = ""; + $backend->error = ''; $res = $backend->list_addr(); if(is_array($res)) { $ret = array_merge($ret, $res); @@ -247,20 +247,20 @@ $this->error = _("Invalid input data"); return false; } - if(empty($userdata["firstname"]) && - empty($userdata["lastname"])) { + if(empty($userdata['firstname']) && + empty($userdata['lastname'])) { $this->error = _("Name is missing"); return false; } - if(empty($userdata["email"])) { + if(empty($userdata['email'])) { $this->error = _("E-mail address is missing"); return false; } - if(empty($userdata["nickname"])) { - $userdata["nickname"] = $userdata["email"]; + if(empty($userdata['nickname'])) { + $userdata['nickname'] = $userdata['email']; } - if(eregi("[\: \|\#\"\!]", $userdata["nickname"])) { + if(eregi("[\: \|\#\"\!]", $userdata['nickname'])) { $this->error = _("Nickname contain illegal characters"); return false; } @@ -328,23 +328,23 @@ $this->error = _("Invalid input data"); return false; } - if(empty($userdata["firstname"]) && - empty($userdata["lastname"])) { + if(empty($userdata['firstname']) && + empty($userdata['lastname'])) { $this->error = _("Name is missing"); return false; } - if(empty($userdata["email"])) { + if(empty($userdata['email'])) { $this->error = _("E-mail address is missing"); return false; } - if(eregi("[\: \|\#\"\!]", $userdata["nickname"])) { + if(eregi("[\: \|\#\"\!]", $userdata['nickname'])) { $this->error = _("Nickname contain illegal characters"); return false; } - if(empty($userdata["nickname"])) { - $userdata["nickname"] = $userdata["email"]; + if(empty($userdata['nickname'])) { + $userdata['nickname'] = $userdata['email']; } // Check that specified backend is writable @@ -374,18 +374,18 @@ class addressbook_backend { // Variables that all backends must provide. - var $btype = "dummy"; - var $bname = "dummy"; - var $sname = "Dummy 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. var $bnum = -1; - var $error = ""; + var $error = ''; var $writeable = false; function set_error($string) { - $this->error = "[" . $this->sname . "] " . $string; + $this->error = '[' . $this->sname . '] ' . $string; return false; } @@ -393,32 +393,32 @@ // ========================== Public ======================== function search($expression) { - $this->set_error("search not implemented"); + $this->set_error('search not implemented'); return false; } function lookup($alias) { - $this->set_error("lookup not implemented"); + $this->set_error('lookup not implemented'); return false; } function list_addr() { - $this->set_error("list_addr not implemented"); + $this->set_error('list_addr not implemented'); return false; } function add($userdata) { - $this->set_error("add not implemented"); + $this->set_error('add not implemented'); return false; } function remove($alias) { - $this->set_error("delete not implemented"); + $this->set_error('delete not implemented'); return false; } function modify($alias, $newuserdata) { - $this->set_error("modify not implemented"); + $this->set_error('modify not implemented'); return false; } diff --git a/functions/array.php b/functions/array.php index b59f21c9..5d959fe1 100644 --- a/functions/array.php +++ b/functions/array.php @@ -15,10 +15,10 @@ // These should be $this->col and $this->dir in a class // Would beat using globals if(!is_array($col)){ - $col = array("$col"); + $col = array($col); } - $GLOBALS["col"] = $col; // Column or Columns as an array - $GLOBALS["dir"] = $dir; // Direction, a positive number for ascending a negative for descending + $GLOBALS['col'] = $col; // Column or Columns as an array + $GLOBALS['dir'] = $dir; // Direction, a positive number for ascending a negative for descending usort($ary,'comp2'); return $ary; @@ -28,13 +28,13 @@ global $col; global $dir; $c = count($col) -1; - if ($a["$col[$i]"] == $b["$col[$i]"]){ + if ($a[$col[$i]] == $b[$col[$i]]){ $r = 0; while($i < $c && $r == 0){ $i++; $r = comp2($a,$b,$i); } - } elseif($a["$col[$i]"] < $b["$col[$i]"]){ + } elseif($a[$col[$i]] < $b[$col[$i]]){ $r = -1 * $dir; // Im not sure why you must * dir here, but it wont work just before the return... } else { $r = 1 * $dir; @@ -58,7 +58,7 @@ $key=0; $array2 = array(); while ($key < count($array1)) { - array_push($array2, $array1[$key]["$column"]); + array_push($array2, $array1[$key][$column]); $key++; } diff --git a/functions/auth.php b/functions/auth.php index fec8c1b3..f302a496 100644 --- a/functions/auth.php +++ b/functions/auth.php @@ -11,7 +11,7 @@ $auth_php = true; function is_logged_in () { - if (!session_is_registered("user_is_logged_in")) { + if (!session_is_registered('user_is_logged_in')) { echo _("You must login first."); echo "\n\n"; exit; diff --git a/functions/date.php b/functions/date.php index d814c513..1b281153 100644 --- a/functions/date.php +++ b/functions/date.php @@ -5,7 +5,7 @@ ** Takes a date and parses it into a usable format. The form that a ** date SHOULD arrive in is: ** 29 Jun 1999 09:52:11 -0500 (EDT) - ** (as specified in RFC 822) -- "Tue" is optional + ** (as specified in RFC 822) -- 'Tue' is optional ** ** $Id$ **/ @@ -15,37 +15,37 @@ // corrects a time stamp to be the local time function getGMTSeconds($stamp, $gmt) { global $invert_time; - if (($gmt == "Pacific") || ($gmt == "PST")) - $gmt = "-0800"; - else if (($gmt == "EDT")) - $gmt = "-0400"; - else if (($gmt == "Eastern") || ($gmt == "EST") || ($gmt == "CDT")) - $gmt = "-0500"; - else if (($gmt == "Central") || ($gmt == "CST") || ($gmt == "MDT")) - $gmt = "-0600"; - else if (($gmt == "Mountain") || ($gmt == "MST") || ($gmt == "PDT")) - $gmt = "-0700"; - else if ($gmt == "BST") - $gmt = "+0100"; - else if ($gmt == "EET") - $gmt = "+0200"; - else if ($gmt == "GMT") - $gmt = "+0000"; - else if ($gmt == "HKT") - $gmt = "+0800"; - else if ($gmt == "IST") - $gmt = "+0200"; - else if ($gmt == "JST") - $gmt = "+0900"; - else if ($gmt == "MET") - $gmt = "+0100"; - else if ($gmt == "MET DST" || $gmt == "METDST") - $gmt = "+0200"; + if (($gmt == 'Pacific') || ($gmt == 'PST')) + $gmt = '-0800'; + else if (($gmt == 'EDT')) + $gmt = '-0400'; + else if (($gmt == 'Eastern') || ($gmt == 'EST') || ($gmt == 'CDT')) + $gmt = '-0500'; + else if (($gmt == 'Central') || ($gmt == 'CST') || ($gmt == 'MDT')) + $gmt = '-0600'; + else if (($gmt == 'Mountain') || ($gmt == 'MST') || ($gmt == 'PDT')) + $gmt = '-0700'; + else if ($gmt == 'BST') + $gmt = '+0100'; + else if ($gmt == 'EET') + $gmt = '+0200'; + else if ($gmt == 'GMT') + $gmt = '+0000'; + else if ($gmt == 'HKT') + $gmt = '+0800'; + else if ($gmt == 'IST') + $gmt = '+0200'; + else if ($gmt == 'JST') + $gmt = '+0900'; + else if ($gmt == 'MET') + $gmt = '+0100'; + else if ($gmt == 'MET DST' || $gmt == 'METDST') + $gmt = '+0200'; - if (substr($gmt, 0, 1) == "-") { + if (substr($gmt, 0, 1) == '-') { $neg = true; $gmt = substr($gmt, 1, strlen($gmt)); - } else if (substr($gmt, 0, 1) == "+") { + } else if (substr($gmt, 0, 1) == '+') { $neg = false; $gmt = substr($gmt, 1, strlen($gmt)); } else @@ -59,7 +59,7 @@ $gmt = "+$gmt"; /** now find what the server is at **/ - $current = date("Z", time()); + $current = date('Z', time()); if ($invert_time) $current = - $current; $stamp = (int)$stamp - (int)$gmt + (int)$current; @@ -68,26 +68,26 @@ } function getLongDateString($stamp) { - return date("D, F j, Y g:i a", $stamp); + return date('D, F j, Y g:i a', $stamp); } function getDateString($stamp) { global $invert_time; $now = time(); - $dateZ = date("Z", $now); + $dateZ = date('Z', $now); if ($invert_time) $dateZ = - $dateZ; $midnight = $now - ($now % 86400) - $dateZ; if ($midnight < $stamp) { // Today - return date("g:i a", $stamp); + return date('g:i a', $stamp); } else if ($midnight - (60 * 60 * 24 * 6) < $stamp) { // This week - return date("D, g:i a", $stamp); + return date('D, g:i a', $stamp); } else { // before this week - return date("M j, Y", $stamp); + return date('M j, Y', $stamp); } } @@ -109,7 +109,7 @@ // array is an integer or not. // Since the day of week is optional, this check is needed. // - // The old code used eregi("mon|tue|wed|thu|fri|sat|sun", + // The old code used eregi('mon|tue|wed|thu|fri|sat|sun', // $dateParts[0], $tmp) to find if the first element was the // day of week or day of month. This is an expensive call // (processing time) to have inside a loop. Doing it this way @@ -120,21 +120,23 @@ // getHour, getMinute, and getSecond. // if (intval(trim($dateParts[0])) > 0) { - $string = $dateParts[0] . " " . $dateParts[1] . " " . $dateParts[2] . " " . $dateParts[3]; + $string = $dateParts[0] . ' ' . $dateParts[1] . ' ' . + $dateParts[2] . ' ' . $dateParts[3]; return getGMTSeconds(strtotime($string), $dateParts[4]); } - $string = $dateParts[0] . " " . $dateParts[1] . " " . $dateParts[2] . " " . $dateParts[3] . " " . $dateParts[4]; + $string = $dateParts[0] . ' ' . $dateParts[1] . ' ' . + $dateParts[2] . ' ' . $dateParts[3] . ' ' . $dateParts[4]; if (isset($dateParts[5])) return getGMTSeconds(strtotime($string), $dateParts[5]); else - return getGMTSeconds(strtotime($string), ""); + return getGMTSeconds(strtotime($string), ''); } // I use this function for profiling. Should never be called in // actual versions of squirrelmail released to public. function getmicrotime() { $mtime = microtime(); - $mtime = explode(" ",$mtime); + $mtime = explode(' ',$mtime); $mtime = $mtime[1] + $mtime[0]; return ($mtime); } -- 2.25.1