[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

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

   1  <?php
   2  /*

   3  $Id: compatibility.php 3 2006-05-27 04:59:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax

   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      reset($ar);
  22      while (list($key, $value) = each($ar)) {
  23        if (is_array($ar[$key])) {
  24           do_magic_quotes_gpc($ar[$key]);
  25        } else {
  26          $ar[$key] = addslashes($value);
  27        }
  28      }
  29      reset($ar);
  30    }
  31  
  32    if (PHP_VERSION >= 4.1) {
  33      $HTTP_GET_VARS =& $_GET;
  34      $HTTP_POST_VARS =& $_POST;
  35      $HTTP_COOKIE_VARS =& $_COOKIE;
  36      $HTTP_SESSION_VARS =& $_SESSION;
  37      $HTTP_POST_FILES =& $_FILES;
  38      $HTTP_SERVER_VARS =& $_SERVER;
  39    } else {
  40      if (!is_array($HTTP_GET_VARS)) $HTTP_GET_VARS = array();
  41      if (!is_array($HTTP_POST_VARS)) $HTTP_POST_VARS = array();
  42      if (!is_array($HTTP_COOKIE_VARS)) $HTTP_COOKIE_VARS = array();
  43    }
  44  
  45  // handle magic_quotes_gpc turned off.

  46    if (!get_magic_quotes_gpc()) {
  47      do_magic_quotes_gpc($HTTP_GET_VARS);
  48      do_magic_quotes_gpc($HTTP_POST_VARS);
  49      do_magic_quotes_gpc($HTTP_COOKIE_VARS);
  50    }
  51  
  52    if (!function_exists('array_splice')) {
  53      function array_splice(&$array, $maximum) {
  54        if (sizeof($array) >= $maximum) {
  55          for ($i=0; $i<$maximum; $i++) {
  56            $new_array[$i] = $array[$i];
  57          }
  58          $array = $new_array;
  59        }
  60      }
  61    }
  62  
  63    if (!function_exists('in_array')) {
  64      function in_array($lookup_value, $lookup_array) {
  65        reset($lookup_array);
  66        while (list($key, $value) = each($lookup_array)) {
  67          if ($value == $lookup_value) return true;
  68        }
  69  
  70        return false;
  71      }
  72    }
  73  
  74    if (!function_exists('array_reverse')) {
  75      function array_reverse($array) {
  76        for ($i=0, $n=sizeof($array); $i<$n; $i++) $array_reversed[$i] = $array[($n-$i-1)];
  77  
  78        return $array_reversed;
  79      }
  80    }
  81  
  82    if (!function_exists('constant')) {
  83      function constant($constant) {
  84        eval("\$temp=$constant;");
  85  
  86        return $temp;
  87      }
  88    }
  89  
  90    if (!function_exists('is_null')) {
  91      function is_null($value) {
  92        if (is_array($value)) {
  93          if (sizeof($value) > 0) {
  94            return false;
  95          } else {
  96            return true;
  97          }
  98        } else {
  99          if (($value != '') && ($value != 'NULL') && (strlen(trim($value)) > 0)) {
 100            return false;
 101          } else {
 102            return true;
 103          }
 104        }
 105      }
 106    }
 107  
 108    if (!function_exists('array_merge')) {
 109      function array_merge($array1, $array2, $array3 = '') {
 110        if (empty($array3) && !is_array($array3)) $array3 = array();
 111        while (list($key, $val) = each($array1)) $array_merged[$key] = $val;
 112        while (list($key, $val) = each($array2)) $array_merged[$key] = $val;
 113        if (sizeof($array3) > 0) while (list($key, $val) = each($array3)) $array_merged[$key] = $val;
 114  
 115        return (array) $array_merged;
 116      }
 117    }
 118  
 119    if (!function_exists('is_numeric')) {
 120      function is_numeric($param) {
 121        return ereg('^[0-9]{1,50}.?[0-9]{0,50}$', $param);
 122      }
 123    }
 124  
 125    if (!function_exists('array_slice')) {
 126      function array_slice($array, $offset, $length = 0) {
 127        if ($offset < 0 ) {
 128          $offset = sizeof($array) + $offset;
 129        }
 130        $length = ((!$length) ? sizeof($array) : (($length < 0) ? sizeof($array) - $length : $length + $offset));
 131        for ($i = $offset; $i<$length; $i++) {
 132          $tmp[] = $array[$i];
 133        }
 134  
 135        return $tmp;
 136      }
 137    }
 138  
 139    if (!function_exists('array_map')) {
 140      function array_map($callback, $array) {
 141        if (is_array($array)) {
 142          $_new_array = array();
 143          reset($array);
 144          while (list($key, $value) = each($array)) {
 145            $_new_array[$key] = array_map($callback, $array[$key]);
 146          }
 147          return $_new_array;
 148        } else {
 149          return $callback($array);
 150        }
 151      }
 152    }
 153  
 154    if (!function_exists('str_repeat')) {
 155      function str_repeat($string, $number) {
 156        $repeat = '';
 157  
 158        for ($i=0; $i<$number; $i++) {
 159          $repeat .= $string;
 160        }
 161  
 162        return $repeat;
 163      }
 164    }
 165  
 166    if (!function_exists('checkdnsrr')) {
 167      function checkdnsrr($host, $type) {
 168        if(tep_not_null($host) && tep_not_null($type)) {
 169          @exec("nslookup -type=$type $host", $output);
 170          while(list($k, $line) = each($output)) {
 171            if(eregi("^$host", $line)) {
 172              return true;
 173            }
 174          }
 175        }
 176        return false;
 177      }
 178    }
 179  ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7