16589c60cSAndreas Gohr<?php 26589c60cSAndreas Gohr/** 36589c60cSAndreas Gohr * compatibility functions 46589c60cSAndreas Gohr * 56589c60cSAndreas Gohr * This file contains a few functions that might be missing from the PHP build 66589c60cSAndreas Gohr */ 76589c60cSAndreas Gohr 86589c60cSAndreas Gohrif(!function_exists('ctype_space')) { 96589c60cSAndreas Gohr /** 106589c60cSAndreas Gohr * Check for whitespace character(s) 116589c60cSAndreas Gohr * 126589c60cSAndreas Gohr * @see ctype_space 136589c60cSAndreas Gohr * @param string $text 146589c60cSAndreas Gohr * @return bool 156589c60cSAndreas Gohr */ 16*d868eb89SAndreas Gohr function ctype_space($text) 17*d868eb89SAndreas Gohr { 186589c60cSAndreas Gohr if(!is_string($text)) return false; #FIXME original treats between -128 and 255 inclusive as ASCII chars 196589c60cSAndreas Gohr if(trim($text) === '') return true; 206589c60cSAndreas Gohr return false; 216589c60cSAndreas Gohr } 226589c60cSAndreas Gohr} 236589c60cSAndreas Gohr 246589c60cSAndreas Gohrif(!function_exists('ctype_digit')) { 256589c60cSAndreas Gohr /** 266589c60cSAndreas Gohr * Check for numeric character(s) 276589c60cSAndreas Gohr * 286589c60cSAndreas Gohr * @see ctype_digit 296589c60cSAndreas Gohr * @param string $text 306589c60cSAndreas Gohr * @return bool 316589c60cSAndreas Gohr */ 32*d868eb89SAndreas Gohr function ctype_digit($text) 33*d868eb89SAndreas Gohr { 346589c60cSAndreas Gohr if(!is_string($text)) return false; #FIXME original treats between -128 and 255 inclusive as ASCII chars 356589c60cSAndreas Gohr if(preg_match('/^\d+$/', $text)) return true; 366589c60cSAndreas Gohr return false; 376589c60cSAndreas Gohr } 386589c60cSAndreas Gohr} 3992b9f196SAndreas Gohr 4092b9f196SAndreas Gohrif(!function_exists('gzopen') && function_exists('gzopen64')) { 4192b9f196SAndreas Gohr /** 4292b9f196SAndreas Gohr * work around for PHP compiled against certain zlib versions #865 4392b9f196SAndreas Gohr * 4492b9f196SAndreas Gohr * @link http://stackoverflow.com/questions/23417519/php-zlib-gzopen-not-exists 4592b9f196SAndreas Gohr * 4692b9f196SAndreas Gohr * @param string $filename 4792b9f196SAndreas Gohr * @param string $mode 4892b9f196SAndreas Gohr * @param int $use_include_path 4992b9f196SAndreas Gohr * @return mixed 5092b9f196SAndreas Gohr */ 51*d868eb89SAndreas Gohr function gzopen($filename, $mode, $use_include_path = 0) 52*d868eb89SAndreas Gohr { 5392b9f196SAndreas Gohr return gzopen64($filename, $mode, $use_include_path); 548457f8ceSAndreas Gohr } 558457f8ceSAndreas Gohr} 568457f8ceSAndreas Gohr 578457f8ceSAndreas Gohrif(!function_exists('gzseek') && function_exists('gzseek64')) { 588457f8ceSAndreas Gohr /** 598457f8ceSAndreas Gohr * work around for PHP compiled against certain zlib versions #865 608457f8ceSAndreas Gohr * 618457f8ceSAndreas Gohr * @link http://stackoverflow.com/questions/23417519/php-zlib-gzopen-not-exists 628457f8ceSAndreas Gohr * 638457f8ceSAndreas Gohr * @param resource $zp 648457f8ceSAndreas Gohr * @param int $offset 658457f8ceSAndreas Gohr * @param int $whence 668457f8ceSAndreas Gohr * @return int 678457f8ceSAndreas Gohr */ 68*d868eb89SAndreas Gohr function gzseek($zp, $offset, $whence = SEEK_SET) 69*d868eb89SAndreas Gohr { 708457f8ceSAndreas Gohr return gzseek64($zp, $offset, $whence); 718457f8ceSAndreas Gohr } 728457f8ceSAndreas Gohr} 738457f8ceSAndreas Gohr 748457f8ceSAndreas Gohrif(!function_exists('gztell') && function_exists('gztell64')) { 758457f8ceSAndreas Gohr /** 768457f8ceSAndreas Gohr * work around for PHP compiled against certain zlib versions #865 778457f8ceSAndreas Gohr * 788457f8ceSAndreas Gohr * @link http://stackoverflow.com/questions/23417519/php-zlib-gzopen-not-exists 798457f8ceSAndreas Gohr * 808457f8ceSAndreas Gohr * @param resource $zp 818457f8ceSAndreas Gohr * @return int 828457f8ceSAndreas Gohr */ 83*d868eb89SAndreas Gohr function gztell($zp) 84*d868eb89SAndreas Gohr { 858457f8ceSAndreas Gohr return gztell64($zp); 8692b9f196SAndreas Gohr } 8792b9f196SAndreas Gohr} 883f6872b1SMyron Turner 89