[ 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/includes/functions/ -> compatibility.php (source)

   1  <?php
   2  /*
   3    $Id: compatibility.php,v 1.19 2003/04/09 16:12:54 project3000 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    Modified by Marco Canini, <m.canini@libero.it>
  13    - Fixed a bug with arrays in $HTTP_xxx_VARS
  14  */
  15  
  16  ////
  17  // Recursively handle magic_quotes_gpc turned off.
  18  // This is due to the possibility of have an array in
  19  // $HTTP_xxx_VARS
  20  // Ie, products attributes
  21    function do_magic_quotes_gpc(&$ar) {
  22      if (!is_array($ar)) return false;
  23  
  24      while (list($key, $value) = each($ar)) {
  25        if (is_array($ar[$key])) {
  26          do_magic_quotes_gpc($ar[$key]);
  27        } else {
  28          $ar[$key] = addslashes($value);
  29        }
  30      }
  31    }
  32  
  33  // $HTTP_xxx_VARS are always set on php4
  34    if (!is_array($HTTP_GET_VARS)) $HTTP_GET_VARS = array();
  35    if (!is_array($HTTP_POST_VARS)) $HTTP_POST_VARS = array();
  36    if (!is_array($HTTP_COOKIE_VARS)) $HTTP_COOKIE_VARS = array();
  37  
  38  // handle magic_quotes_gpc turned off.
  39    if (!get_magic_quotes_gpc()) {
  40      do_magic_quotes_gpc($HTTP_GET_VARS);
  41      do_magic_quotes_gpc($HTTP_POST_VARS);
  42      do_magic_quotes_gpc($HTTP_COOKIE_VARS);
  43    }
  44  
  45    if (!function_exists('array_splice')) {
  46      function array_splice(&$array, $maximum) {
  47        if (sizeof($array) >= $maximum) {
  48          for ($i=0; $i<$maximum; $i++) {
  49            $new_array[$i] = $array[$i];
  50          }
  51          $array = $new_array;
  52        }
  53      }
  54    }
  55  
  56    if (!function_exists('in_array')) {
  57      function in_array($lookup_value, $lookup_array) {
  58        reset($lookup_array);
  59        while (list($key, $value) = each($lookup_array)) {
  60          if ($value == $lookup_value) return true;
  61        }
  62  
  63        return false;
  64      }
  65    }
  66  
  67    if (!function_exists('array_reverse')) {
  68      function array_reverse($array) {
  69        for ($i=0, $n=sizeof($array); $i<$n; $i++) $array_reversed[$i] = $array[($n-$i-1)];
  70  
  71        return $array_reversed;
  72      }
  73    }
  74  
  75    if (!function_exists('constant')) {
  76      function constant($constant) {
  77        eval("\$temp=$constant;");
  78  
  79        return $temp;
  80      }
  81    }
  82  
  83    if (!function_exists('is_null')) {
  84      function is_null($value) {
  85        if (is_array($value)) {
  86          if (sizeof($value) > 0) {
  87            return false;
  88          } else {
  89            return true;
  90          }
  91        } else {
  92          if (($value != '') && ($value != 'NULL') && (strlen(trim($value)) > 0)) {
  93            return false;
  94          } else {
  95            return true;
  96          }
  97        }
  98      }
  99    }
 100  
 101    if (!function_exists('array_merge')) {
 102      function array_merge($array1, $array2, $array3 = '') {
 103        if (empty($array3) && !is_array($array3)) $array3 = array();
 104        while (list($key, $val) = each($array1)) $array_merged[$key] = $val;
 105        while (list($key, $val) = each($array2)) $array_merged[$key] = $val;
 106        if (sizeof($array3) > 0) while (list($key, $val) = each($array3)) $array_merged[$key] = $val;
 107  
 108        return (array) $array_merged;
 109      }
 110    }
 111  
 112    if (!function_exists('is_numeric')) {
 113      function is_numeric($param) {
 114        return ereg('^[0-9]{1,50}.?[0-9]{0,50}$', $param);
 115      }
 116    }
 117  
 118    if (!function_exists('array_slice')) {
 119      function array_slice($array, $offset, $length = 0) {
 120        if ($offset < 0 ) {
 121          $offset = sizeof($array) + $offset;
 122        }
 123        $length = ((!$length) ? sizeof($array) : (($length < 0) ? sizeof($array) - $length : $length + $offset));
 124        for ($i = $offset; $i<$length; $i++) {
 125          $tmp[] = $array[$i];
 126        }
 127  
 128        return $tmp;
 129      }
 130    }
 131  
 132    if (!function_exists('array_map')) {
 133      function array_map($callback, $array) {
 134        if (is_array($array)) {
 135          $_new_array = array();
 136          reset($array);
 137          while (list($key, $value) = each($array)) {
 138            $_new_array[$key] = array_map($callback, $array[$key]);
 139          }
 140          return $_new_array;
 141        } else {
 142          return $callback($array);
 143        }
 144      }
 145    }
 146  
 147    if (!function_exists('str_repeat')) {
 148      function str_repeat($string, $number) {
 149        $repeat = '';
 150  
 151        for ($i=0; $i<$number; $i++) {
 152          $repeat .= $string;
 153        }
 154  
 155        return $repeat;
 156      }
 157    }
 158  
 159    if (!function_exists('checkdnsrr')) {
 160      function checkdnsrr($host, $type) {
 161        if(tep_not_null($host) && tep_not_null($type)) {
 162          @exec("nslookup -type=$type $host", $output);
 163          while(list($k, $line) = each($output)) {
 164            if(eregi("^$host", $line)) {
 165              return true;
 166            }
 167          }
 168        }
 169        return false;
 170      }
 171    }
 172  ?>


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