[ Index ]
 

Code source de osCommerce 2.2ms2-060817

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/catalog/admin/includes/functions/ -> compatibility.php (source)

   1  <?php
   2  /*
   3    $Id: compatibility.php,v 1.10 2003/06/23 01:20:05 hpdl Exp $
   4  
   5    osCommerce, Open Source E-Commerce Solutions
   6    http://www.oscommerce.com
   7  
   8    Copyright (c) 2006 osCommerce
   9  
  10    Released under the GNU General Public License
  11  */
  12  
  13  ////
  14  // Recursively handle magic_quotes_gpc turned off.
  15  // This is due to the possibility of have an array in
  16  // $HTTP_xxx_VARS
  17  // Ie, products attributes
  18    function do_magic_quotes_gpc(&$ar) {
  19      if (!is_array($ar)) return false;
  20  
  21      while (list($key, $value) = each($ar)) {
  22        if (is_array($ar[$key])) {
  23          do_magic_quotes_gpc($ar[$key]);
  24        } else {
  25          $ar[$key] = addslashes($value);
  26        }
  27      }
  28    }
  29  
  30  // $HTTP_xxx_VARS are always set on php4
  31    if (!is_array($HTTP_GET_VARS)) $HTTP_GET_VARS = array();
  32    if (!is_array($HTTP_POST_VARS)) $HTTP_POST_VARS = array();
  33    if (!is_array($HTTP_COOKIE_VARS)) $HTTP_COOKIE_VARS = array();
  34  
  35  // handle magic_quotes_gpc turned off.
  36    if (!get_magic_quotes_gpc()) {
  37      do_magic_quotes_gpc($HTTP_GET_VARS);
  38      do_magic_quotes_gpc($HTTP_POST_VARS);
  39      do_magic_quotes_gpc($HTTP_COOKIE_VARS);
  40    }
  41  
  42    if (!function_exists('is_numeric')) {
  43      function is_numeric($param) {
  44        return ereg("^[0-9]{1,50}.?[0-9]{0,50}$", $param);
  45      }
  46    }
  47  
  48    if (!function_exists('is_uploaded_file')) {
  49      function is_uploaded_file($filename) {
  50        if (!$tmp_file = get_cfg_var('upload_tmp_dir')) {
  51          $tmp_file = dirname(tempnam('', ''));
  52        }
  53  
  54        if (strchr($tmp_file, '/')) {
  55          if (substr($tmp_file, -1) != '/') $tmp_file .= '/';
  56        } elseif (strchr($tmp_file, '\\')) {
  57          if (substr($tmp_file, -1) != '\\') $tmp_file .= '\\';
  58        }
  59  
  60        return file_exists($tmp_file . basename($filename));
  61      }
  62    }
  63  
  64    if (!function_exists('move_uploaded_file')) {
  65      function move_uploaded_file($file, $target) {
  66        return copy($file, $target);
  67      }
  68    }
  69  
  70    if (!function_exists('checkdnsrr')) {
  71      function checkdnsrr($host, $type) {
  72        if(tep_not_null($host) && tep_not_null($type)) {
  73          @exec("nslookup -type=$type $host", $output);
  74          while(list($k, $line) = each($output)) {
  75            if(eregi("^$host", $line)) {
  76              return true;
  77            }
  78          }
  79        }
  80        return false;
  81      }
  82    }
  83  
  84    if (!function_exists('in_array')) {
  85      function in_array($lookup_value, $lookup_array) {
  86        reset($lookup_array);
  87        while (list($key, $value) = each($lookup_array)) {
  88          if ($value == $lookup_value) return true;
  89        }
  90  
  91        return false;
  92      }
  93    }
  94  
  95    if (!function_exists('array_merge')) {
  96      function array_merge($array1, $array2, $array3 = '') {
  97        if ($array3 == '') $array3 = array();
  98  
  99        while (list($key, $val) = each($array1)) $array_merged[$key] = $val;
 100        while (list($key, $val) = each($array2)) $array_merged[$key] = $val;
 101  
 102        if (sizeof($array3) > 0) while (list($key, $val) = each($array3)) $array_merged[$key] = $val;
 103  
 104        return (array)$array_merged;
 105      }
 106    }
 107  
 108    if (!function_exists('array_shift')) {
 109      function array_shift(&$array) {
 110        $i = 0;
 111        $shifted_array = array();
 112        reset($array);
 113        while (list($key, $value) = each($array)) {
 114          if ($i > 0) {
 115            $shifted_array[$key] = $value;
 116          } else {
 117            $return = $array[$key];
 118          }
 119          $i++;
 120        }
 121        $array = $shifted_array;
 122  
 123        return $return;
 124      }
 125    }
 126  
 127    if (!function_exists('array_reverse')) {
 128      function array_reverse($array) {
 129        $reversed_array = array();
 130  
 131        for ($i=sizeof($array)-1; $i>=0; $i--) {
 132          $reversed_array[] = $array[$i];
 133        }
 134  
 135        return $reversed_array;
 136      }
 137    }
 138  
 139    if (!function_exists('array_slice')) {
 140      function array_slice($array, $offset, $length = '0') {
 141        $length = abs($length);
 142  
 143        if ($length == 0) {
 144          $high = sizeof($array);
 145        } else {
 146          $high = $offset+$length;
 147        }
 148  
 149        for ($i=$offset; $i<$high; $i++) {
 150          $new_array[$i-$offset] = $array[$i];
 151        }
 152  
 153        return $new_array;
 154      }
 155    }
 156  ?>


Généré le : Mon Nov 26 19:48:25 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics