From 485599c7720227664225597367495fd781c691b9 Mon Sep 17 00:00:00 2001 From: fidian Date: Wed, 31 Jan 2001 18:43:47 +0000 Subject: [PATCH] Changed regexps Altered function names to make them possibly collide with other functions less frequently Altered code for sorting to hopefully improve speed git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1017 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/addressbook.php | 10 +++++----- functions/array.php | 16 +++++++++------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/functions/addressbook.php b/functions/addressbook.php index c83d4faa..2e2ccfda 100644 --- a/functions/addressbook.php +++ b/functions/addressbook.php @@ -58,7 +58,7 @@ // 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) { + function addressbook_cmp($a,$b) { if($a['backend'] > $b['backend']) return 1; else if($a['backend'] < $b['backend']) @@ -106,7 +106,7 @@ // See each of the backend classes for valid parameters. function add_backend($backend, $param = '') { $backend_name = 'abook_' . $backend; - eval("\$newback = new $backend_name(\$param);"); + eval('$newback = new ' . $backend_name . '($param);'); if(!empty($newback->error)) { $this->error = $newback->error; return false; @@ -174,7 +174,7 @@ $ret = $this->search($expression, $bnum); if(!is_array($ret)) return $ret; - usort($ret, 'cmp'); + usort($ret, 'addressbook_cmp'); return $ret; } @@ -260,7 +260,7 @@ $userdata['nickname'] = $userdata['email']; } - if(eregi("[\: \|\#\"\!]", $userdata['nickname'])) { + if(eregi('[\\: \\|\\#\"\\!]', $userdata['nickname'])) { $this->error = _("Nickname contain illegal characters"); return false; } @@ -338,7 +338,7 @@ return false; } - if(eregi("[\: \|\#\"\!]", $userdata['nickname'])) { + if(eregi('[\\: \\|\\#"\\!]', $userdata['nickname'])) { $this->error = _("Nickname contain illegal characters"); return false; } diff --git a/functions/array.php b/functions/array.php index 5d959fe1..a64eb607 100644 --- a/functions/array.php +++ b/functions/array.php @@ -18,13 +18,17 @@ $col = array($col); } $GLOBALS['col'] = $col; // Column or Columns as an array + if ($dir > 0) + $dir = 1; + else + $dir = -1; $GLOBALS['dir'] = $dir; // Direction, a positive number for ascending a negative for descending - usort($ary,'comp2'); + usort($ary,'array_comp2'); return $ary; } - function comp2($a,$b,$i = 0) { + function array_comp2($a,$b,$i = 0) { global $col; global $dir; $c = count($col) -1; @@ -35,11 +39,9 @@ $r = comp2($a,$b,$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; - } - return $r; + return (- $dir); + } + return $dir; } function removeElement($array, $element) { -- 2.25.1