[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/ -> compatibility.php (source)

   1  <?php
   2  /**
   3   * compatibility functions
   4   *
   5   * This file contains a few functions that might be missing from the PHP build
   6   */
   7  
   8  if(!function_exists('ctype_space')) {
   9      /**
  10       * Check for whitespace character(s)
  11       *
  12       * @see ctype_space
  13       * @param string $text
  14       * @return bool
  15       */
  16      function ctype_space($text) {
  17          if(!is_string($text)) return false; #FIXME original treats between -128 and 255 inclusive as ASCII chars
  18          if(trim($text) === '') return true;
  19          return false;
  20      }
  21  }
  22  
  23  if(!function_exists('ctype_digit')) {
  24      /**
  25       * Check for numeric character(s)
  26       *
  27       * @see ctype_digit
  28       * @param string $text
  29       * @return bool
  30       */
  31      function ctype_digit($text) {
  32          if(!is_string($text)) return false; #FIXME original treats between -128 and 255 inclusive as ASCII chars
  33          if(preg_match('/^\d+$/', $text)) return true;
  34          return false;
  35      }
  36  }
  37  
  38  if(!function_exists('gzopen') && function_exists('gzopen64')) {
  39      /**
  40       * work around for PHP compiled against certain zlib versions #865
  41       *
  42       * @link http://stackoverflow.com/questions/23417519/php-zlib-gzopen-not-exists
  43       *
  44       * @param string $filename
  45       * @param string $mode
  46       * @param int    $use_include_path
  47       * @return mixed
  48       */
  49      function gzopen($filename, $mode, $use_include_path = 0) {
  50          return gzopen64($filename, $mode, $use_include_path);
  51      }
  52  }
  53  
  54  if(!function_exists('gzseek') && function_exists('gzseek64')) {
  55      /**
  56       * work around for PHP compiled against certain zlib versions #865
  57       *
  58       * @link http://stackoverflow.com/questions/23417519/php-zlib-gzopen-not-exists
  59       *
  60       * @param resource $zp
  61       * @param int      $offset
  62       * @param int      $whence
  63       * @return int
  64       */
  65      function gzseek($zp, $offset, $whence = SEEK_SET) {
  66          return gzseek64($zp, $offset, $whence);
  67      }
  68  }
  69  
  70  if(!function_exists('gztell') && function_exists('gztell64')) {
  71      /**
  72       * work around for PHP compiled against certain zlib versions #865
  73       *
  74       * @link   http://stackoverflow.com/questions/23417519/php-zlib-gzopen-not-exists
  75       *
  76       * @param resource $zp
  77       * @return int
  78       */
  79      function gztell($zp) {
  80          return gztell64($zp);
  81      }
  82  }
  83