[TEP-COMMIT] CVS: catalog/catalog/includes/functions compatibility.php,1.19,1.20

Harald Ponce de Leon <[email protected]>
Newsgroups gmane.comp.web.oscommerce.cvs
Message-ID <[email protected]>
Update of /cvsroot/tep/catalog/catalog/includes/functions
In directory sc8-pr-cvs1:/tmp/cvs-serv24161/functions

Modified Files:
	compatibility.php 
Log Message:
remove php 3 compatibility logic

reference the super global variables ($_GET, $_POST, ..) on PHP 4.0.x
servers (the $_SESSION variable is not referenced as it cannot be
referenced to (the session will not work))


Index: compatibility.php
===================================================================
RCS file: /cvsroot/tep/catalog/catalog/includes/functions/compatibility.php,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- compatibility.php	9 Apr 2003 16:12:54 -0000	1.19
+++ compatibility.php	17 Nov 2003 17:39:00 -0000	1.20
@@ -8,16 +8,18 @@
   Copyright (c) 2003 osCommerce
 
   Released under the GNU General Public License
-
-  Modified by Marco Canini, <[email protected]>
-  - Fixed a bug with arrays in $HTTP_xxx_VARS
 */
 
-////
+  if (PHP_VERSION < 4.1) {
+    if (isset($HTTP_SERVER_VARS)) $_SERVER =& $HTTP_SERVER_VARS;
+    if (isset($HTTP_GET_VARS)) $_GET =& $HTTP_GET_VARS;
+    if (isset($HTTP_POST_VARS)) $_POST =& $HTTP_POST_VARS;
+    if (isset($HTTP_COOKIE_VARS)) $_COOKIE =& $HTTP_COOKIE_VARS;
+    if (isset($HTTP_POST_FILES)) $_FILES =& $HTTP_POST_FILES;
+    if (isset($HTTP_ENV_VARS)) $_ENV =& $HTTP_ENV_VARS;
+  }
+
 // Recursively handle magic_quotes_gpc turned off.
-// This is due to the possibility of have an array in
-// $HTTP_xxx_VARS
-// Ie, products attributes
   function do_magic_quotes_gpc(&$ar) {
     if (!is_array($ar)) return false;
 
@@ -30,46 +32,10 @@
     }
   }
 
-// $HTTP_xxx_VARS are always set on php4
-  if (!is_array($HTTP_GET_VARS)) $HTTP_GET_VARS = array();
-  if (!is_array($HTTP_POST_VARS)) $HTTP_POST_VARS = array();
-  if (!is_array($HTTP_COOKIE_VARS)) $HTTP_COOKIE_VARS = array();
-
 // handle magic_quotes_gpc turned off.
   if (!get_magic_quotes_gpc()) {
-    do_magic_quotes_gpc($HTTP_GET_VARS);
-    do_magic_quotes_gpc($HTTP_POST_VARS);
-    do_magic_quotes_gpc($HTTP_COOKIE_VARS);
-  }
-
-  if (!function_exists('array_splice')) {
-    function array_splice(&$array, $maximum) {
-      if (sizeof($array) >= $maximum) {
-        for ($i=0; $i<$maximum; $i++) {
-          $new_array[$i] = $array[$i];
-        }
-        $array = $new_array;
-      }
-    }
-  }
-
-  if (!function_exists('in_array')) {
-    function in_array($lookup_value, $lookup_array) {
-      reset($lookup_array);
-      while (list($key, $value) = each($lookup_array)) {
-        if ($value == $lookup_value) return true;
-      }
-
-      return false;
-    }
-  }
-
-  if (!function_exists('array_reverse')) {
-    function array_reverse($array) {
-      for ($i=0, $n=sizeof($array); $i<$n; $i++) $array_reversed[$i] = $array[($n-$i-1)];
-
-      return $array_reversed;
-    }
+    do_magic_quotes_gpc($_GET);
+    do_magic_quotes_gpc($_POST);
   }
 
   if (!function_exists('constant')) {
@@ -80,82 +46,6 @@
     }
   }
 
-  if (!function_exists('is_null')) {
-    function is_null($value) {
-      if (is_array($value)) {
-        if (sizeof($value) > 0) {
-          return false;
-        } else {
-          return true;
-        }
-      } else {
-        if (($value != '') && ($value != 'NULL') && (strlen(trim($value)) > 0)) {
-          return false;
-        } else {
-          return true;
-        }
-      }
-    }
-  }
-
-  if (!function_exists('array_merge')) {
-    function array_merge($array1, $array2, $array3 = '') {
-      if (empty($array3) && !is_array($array3)) $array3 = array();
-      while (list($key, $val) = each($array1)) $array_merged[$key] = $val;
-      while (list($key, $val) = each($array2)) $array_merged[$key] = $val;
-      if (sizeof($array3) > 0) while (list($key, $val) = each($array3)) $array_merged[$key] = $val;
-
-      return (array) $array_merged;
-    }
-  }
-
-  if (!function_exists('is_numeric')) {
-    function is_numeric($param) {
-      return ereg('^[0-9]{1,50}.?[0-9]{0,50}$', $param);
-    }
-  }
-
-  if (!function_exists('array_slice')) {
-    function array_slice($array, $offset, $length = 0) {
-      if ($offset < 0 ) {
-        $offset = sizeof($array) + $offset;
-      }
-      $length = ((!$length) ? sizeof($array) : (($length < 0) ? sizeof($array) - $length : $length + $offset));
-      for ($i = $offset; $i<$length; $i++) {
-        $tmp[] = $array[$i];
-      }
-
-      return $tmp;
-    }
-  }
-
-  if (!function_exists('array_map')) {
-    function array_map($callback, $array) {
-      if (is_array($array)) {
-        $_new_array = array();
-        reset($array);
-        while (list($key, $value) = each($array)) {
-          $_new_array[$key] = array_map($callback, $array[$key]);
-        }
-        return $_new_array;
-      } else {
-        return $callback($array);
-      }
-    }
-  }
-
-  if (!function_exists('str_repeat')) {
-    function str_repeat($string, $number) {
-      $repeat = '';
-
-      for ($i=0; $i<$number; $i++) {
-        $repeat .= $string;
-      }
-
-      return $repeat;
-    }
-  }
-
   if (!function_exists('checkdnsrr')) {
     function checkdnsrr($host, $type) {
       if(tep_not_null($host) && tep_not_null($type)) {
@@ -167,6 +57,20 @@
         }
       }
       return false;
+    }
+  }
+
+  if (!function_exists('array_unique')) {
+    function array_unique($array) {
+      $tmp_array = array();
+
+      for ($i=0, $n=sizeof($array); $i<$n; $i++) {
+        if (!in_array($array[$i], $tmp_array)) {
+          $tmp_array[] = $array[$i];
+        }
+      }
+
+      return $tmp_array;
     }
   }
 ?>



-------------------------------------------------------
This SF. Net email is sponsored by: GoToMyPC
GoToMyPC is the fast, easy and secure way to access your computer from
any Web browser or wireless device. Click here to Try it Free!
https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.