Changed regexps
authorfidian <fidian@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 31 Jan 2001 18:43:47 +0000 (18:43 +0000)
committerfidian <fidian@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 31 Jan 2001 18:43:47 +0000 (18:43 +0000)
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
functions/array.php

index c83d4faa524a0e850e221f24149fa7f933b07e3e..2e2ccfda3192a5474199624d3da4d7ca9c510fa4 100644 (file)
@@ -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']) 
       // 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;
         $ret = $this->search($expression, $bnum);
         if(!is_array($ret))
            return $ret;
-            usort($ret, 'cmp');
+            usort($ret, 'addressbook_cmp');
             return $ret;
       }
 
            $userdata['nickname'] = $userdata['email'];
         }
 
-        if(eregi("[\: \|\#\"\!]", $userdata['nickname'])) {
+        if(eregi('[\\: \\|\\#\"\\!]', $userdata['nickname'])) {
            $this->error = _("Nickname contain illegal characters");
            return false;
         }
            return false;
         }
 
-        if(eregi("[\: \|\#\"\!]", $userdata['nickname'])) {
+        if(eregi('[\\: \\|\\#"\\!]', $userdata['nickname'])) {
            $this->error = _("Nickname contain illegal characters");
            return false;
         }
index 5d959fe1441d4a219b5d1daddb572b0714d4a85f..a64eb60779d60515a5381ed635a3031abb4ee558 100644 (file)
          $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;
                $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) {