Check-in [8c74990127]
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | upgradephp-11 |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
8c7499012759ad73a4b09168e154e33d |
User & Date: | mario 2010-06-22 16:46:34 |
Context
2010-06-22
| ||
16:59 | upgradephp-12 check-in: bcf7d8cbab user: mario tags: trunk | |
16:46 | upgradephp-11 check-in: 8c74990127 user: mario tags: trunk | |
16:46 | upgradephp-9 check-in: 09785ab723 user: mario tags: trunk | |
Changes
Changes to README.
1 2 3 4 | PHP downwards compatibility functions ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ Because web hosters often run outdated PHP interpreter versions, | | | | | | | | | | < | | | > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | PHP downwards compatibility functions ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ Because web hosters often run outdated PHP interpreter versions, there are regularily functions missing. This can prevent certain scripts from running, if those were written with later interpeter versions in mind. Sourceforge.net makes a good example. The include script presented here emulates most such functions, if it detects that something is missing. You can therefore now reliably use a few of the advanced (later introduced) PHP core functions, by simply loading this script. This effectively frees you from wasting time with backwards compatibility problems and even avoiding certain useful additions from newer PHP versions. This script takes care of all function_exists() checks on your behalf then. Of course, some later introduced PHP extensions cannot be emulated. For example you still had to avoid some of the added optional function arguments, because this script cannot override and extend any native function implementations. Language syntax and behaviour changes of PHP5 also cannot be emulated in older versions, like it is impossible to make any PHP 4.0.x version compatible to 4.1.x and later (all superglobals like $_REQUEST, are only provided since then). That is, you still have a "minimum required PHP version" if you use this emulation. But with it you now have the choice to use 4.3 and 5.0 functions while producing "PHP 4.1+ COMPATIBLE" scripts. Some of the functions that get defined here, are just simple stubs; sometimes only there to prevent E_FATAL errors. The emulated functions sometimes run slower than the native variant would, but it generally shouldn't be slower than any workaround you used for the [advanced but not widely available] functions until now. PEAR::PHP_Compat ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ Only after finishing release 5 of this library I found out, that such a thing already exists. You can find the PEAR package named "PHP_Compat" (written by Aidan Lister) on http://pear.php.net/, and give that a try also. Because it exists much longer, it should be free of bugs meanwhile. It btw, provides more functions than "upgrade.php" in some areas (4.0.x emulations for example), and it is more accurate in simulating PHPs warning messages, and comes under the PHP license. You could get something similar to this "upgrade.php" script by simply unpacking the PHP_Compat tarball and running: cat .../PHP_Compat-1.3.1/Compat/*/*.php > phpcompat.php This then was as easy to use (simply one include script) like the "upgrade.php" library as described here (and you could even load both). You may want to rip out the many overly redundant license comments using `php -w` if you generate such an include script from PHP_Compat. But don't forget to mention that it comes under the PHP license, if you then package this with any application or |
︙ | ︙ | |||
70 71 72 73 74 75 76 | used to produce "upgrade.php", but I'll happily take ideas from there, and especially the function-introduction/version data from it and PEAR::PHP_CompatInfo will help finishing this library (apparantly contains more accurate hints than the PHP manual). | | | > > | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | used to produce "upgrade.php", but I'll happily take ideas from there, and especially the function-introduction/version data from it and PEAR::PHP_CompatInfo will help finishing this library (apparantly contains more accurate hints than the PHP manual). Basics ¯¯¯¯¯¯ Simply include("upgrade.php"); in any of your scripts, if you want to use some of the newer PHP4.3 or PHP5 functions like stripos() or so. The functions get declared on demand then, but only on outdated PHP interpreter versions. On up-to-date servers speed won't suffer, because the native functions are already there. You could additionally check the PHP_VERSION (by using the function version_compare() for example), and only include the emulation wrapper if you depend on features from a certain PHP interpreter release: <?example if (PHP_VERSION < "4.3.0") { require(".../upgrade.php"); } ?> Currently following functions can be emulated: · gzdecode · ob_get_headers · xmlentities · stripos · strripos · str_ireplace · get_headers · headers_list · fprintf · vfprintf |
︙ | ︙ | |||
118 119 120 121 122 123 124 | · substr_compare · spl_classes · class_parents · session_commit · dns_check_record · dns_get_mx · setrawcookie | < > > > > > > > > > > > > > > > > > | > | | | < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > | | > > | > | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | · substr_compare · spl_classes · class_parents · session_commit · dns_check_record · dns_get_mx · setrawcookie · file_put_contents · file_get_contents · fnmatch · glob · array_key_exists · array_intersect_assoc · array_diff_assoc · html_entity_decode · str_word_count · str_shuffle · get_include_path · set_include_path · restore_include_path · str_rot13 · array_change_key_case · array_fill · array_chunk · md5_file · is_a · fmod · floatval · is_infinite · is_nan · is_finite · var_export · strcoll · diskfreespace · disktotalspace · vprintf · vsprintf · import_request_variables · hypot · log1p · expm1 · sinh · cosh · tanh · asinh · acosh · atanh · array_udiff_uassoc · array_udiff_assoc · array_diff_uassoc · array_udiff · array_uintersect_uassoc · array_uintersect_assoc · array_uintersect · array_intersect_uassoc · mime_content_type · image_type_to_mime_type · image_type_to_extension · exif_imagetype · array_filter · array_map · is_callable · array_search · array_reduce · is_scalar · localeconv · call_user_func_array · call_user_method_array · array_sum · constant · is_null · pathinfo · escapeshellarg · is_uploaded_file · move_uploaded_file · strncasecmp · wordwrap · php_uname · php_sapi_name On a side note: You don't have to include() this func emulation script yourself. Leave this to your users if they use an older PHP version; a note often suffices. It however may be senseful to ship this together with your scripts - that's also why it was released as Public Domain. It is safe to extract a few function bodies/definitions out of the script to make a shorter version (load only the needed functions); but you should keep the "if (function_exists(...))" wrapper code always. (PHP_Compat makes a better source, if you really need only a few emulated functions.) Omissions ¯¯¯¯¯¯¯¯¯ A few PHP features are specifically NOT implemented, and so still had to be taken care of in your scripts: · predefined STDIN, STDOUT and STDERR constants · UPLOAD_ERR_* constants (introduced with 4.2, officially 4.3) · ob_* (eventually possible) · clone (PHP5 language feature, but workaround exists in PHP_Compat) · ini_get_all (ingenious trick in PHP_Compat) It may be possible that a script in ext/ later adds support. Often PHP_Compat already provides loadable definitions of above features. ext/ ¯¯¯¯ The ext/ subdirectory in here provides a few more or less useful emulations for various PHP extensions or function groups. · "ext/array" provides a few exotic array diff functions (for associative arrays and for using multiple callback functions) · "ext/ftp" emulates the ftp extension using only the bare socket and networking functions (should work anywhere), even has some features not found in the original · "ext/mime" simulates the mime_content_type() function, either by accessing PECL::fileinfo or reading and evaluating the magic.mime database itself (likely slower and a bit unclean of course) · "ext/dba" allows you to use scripts written for the dba module, if your interpreter only has dbm_*() functions; but only provides the minimum functionality · "ext/spl" tries to mimic the "Standard PHP Library" which suddenly only is going to be made "standard" for PHP5 and above. Load this emulation with version 4 only. NOT READY (difficult to rewrite for the old PHP4 OO capabilities). Happily not in use too widely yet. · "ext/gettext" simulates most of what gettext/libintl provides, and seems to read .mo data files correctly - plural support is however weak. There is also support for .po files, but since the libintl and original gettext functions don't normally read this, that's a useless feature (just for fun). You save 2K by ripping it out. A few snippets in there provide experimental features that aren't found in any current PHP version. · "ext/phprequest" enables your PHP interpreter to receive HTTP requests with "application/vnd.php.serialized" encoding (even compressed) instead of the older "multipart/form-data" and the |
︙ | ︙ | |||
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | installed multi-file PHP manual to ease using this and the "doctests" utility: · The "dtools/updoc" commandline script updates your local PHP documentation to carry hints about emulated functions. It'll simply add a small "EMU" on top of the supported functions` description pages (in the line typically listing the PHP versions). · "ckavail.php" was used to check for added functions between different PHP interpreter versions, purely a development script. · "dtools/doctests" greps your local PHP manual for function use examples, and executes them with the given PHP interpreter and the "upgrade.php" script loaded of course. This way you get live tests, but also see: | > > | 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | installed multi-file PHP manual to ease using this and the "doctests" utility: · The "dtools/updoc" commandline script updates your local PHP documentation to carry hints about emulated functions. It'll simply add a small "EMU" on top of the supported functions` description pages (in the line typically listing the PHP versions). · "ckavail.php" was used to check for added functions between different PHP interpreter versions, purely a development script. · "dtools/doctests" greps your local PHP manual for function use examples, and executes them with the given PHP interpreter and the "upgrade.php" script loaded of course. This way you get live tests, but also see: |
︙ | ︙ | |||
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | upgrade.php provided gzdecode(). (PEARs HTTP and XML-RPC classes don't even know about content-coding, btw). · "contrib/http" can be used to contact Web form scripts, or PHP code utilizing "ext/phprequest" more efficiently. It especially supports content-coding as per RFC2616 (HTTP standard) for saving a lot of bandwidth and getting answers faster. · "contrib/xmlrpc" likewise can compress output and is used to access XML-RPC and IETF XML+RPC Web services. It takes advantage of supported XML and EPI-XML-RPC extensions, but runs gracefully (not 100% exact XML parser) without. It was also made to provide downwards compatibility. Currently you shouldn't run it against old and not-HTTP standards-compliant servers and clients (=avoid compression unless you use it also as server or client at the other side). · "contrib/hiddenerrors" shows a nice way to hide all disturbing error messages from users, but keeping them available for development. It is especially useful, when premature _NOTICEs or _WARNINGs could garbage (XML or binary) output or if this could prevent sending any further/required HTTP headers(). Please also have a peek into the README files accompaning the script | > > | 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | upgrade.php provided gzdecode(). (PEARs HTTP and XML-RPC classes don't even know about content-coding, btw). · "contrib/http" can be used to contact Web form scripts, or PHP code utilizing "ext/phprequest" more efficiently. It especially supports content-coding as per RFC2616 (HTTP standard) for saving a lot of bandwidth and getting answers faster. · "contrib/xmlrpc" likewise can compress output and is used to access XML-RPC and IETF XML+RPC Web services. It takes advantage of supported XML and EPI-XML-RPC extensions, but runs gracefully (not 100% exact XML parser) without. It was also made to provide downwards compatibility. Currently you shouldn't run it against old and not-HTTP standards-compliant servers and clients (=avoid compression unless you use it also as server or client at the other side). · "contrib/hiddenerrors" shows a nice way to hide all disturbing error messages from users, but keeping them available for development. It is especially useful, when premature _NOTICEs or _WARNINGs could garbage (XML or binary) output or if this could prevent sending any further/required HTTP headers(). Please also have a peek into the README files accompaning the script |
︙ | ︙ |
Added contrib/upgrade.php.shortened.
> | 1 | <?php if(!function_exists("gzdecode")){function gzdecode($data,$maxlen=NULL){$len=strlen($data);if($len<20){return;}$head=substr($data,0,10);$head=unpack("n1id/C1cm/C1flg/V1mtime/C1xfl/C1os",$head);list($ID,$CM,$FLG,$MTIME,$XFL,$OS)=array_values($head);$FTEXT=1<<0;$FHCRC=1<<1;$FEXTRA=1<<2;$FNAME=1<<3;$FCOMMENT=1<<4;$head=unpack("V1crc/V1isize",substr($data,$len-8,8));list($CRC32,$ISIZE)=array_values($head);if($ID!=0x1f8b){trigger_error("gzdecode: not in gzip format",E_USER_WARNING);return;}if($CM!=8){trigger_error("gzdecode: cannot decode anything but deflated streams",E_USER_WARNING);return;}$s=10;if($FLG&$FEXTRA){$s+=$XFL;}if($FLG&$FNAME){$s=strpos($data,"\000",$s)+1;}if($FLG&$FCOMMENT){$s=strpos($data,"\000",$s)+1;}if($FLG&$FHCRC){$s+=2;}$data=substr($data,$s,$len-$s);if($maxlen){$data=gzinflate($data,$maxlen);return($data);}else{$data=gzinflate($data);}$chk=crc32($data);if($CRC32!=$chk){trigger_error("gzdecode: checksum failed(real$chk!=comp$CRC32)",E_USER_WARNING);}elseif($ISIZE!=strlen($data)){trigger_error("gzdecode: stream size mismatch",E_USER_WARNING);}else{return($data);}}}if(!function_exists("ob_get_headers")){function ob_get_headers(){return(array)NULL;}}if(!function_exists("xmlentities")){function xmlentities($str){return strtr($str,array("&#"=>"&#","&"=>"&","'"=>"'","<"=>"<",">"=>">","\""=>""",));}}if(!defined("PHP_EOL")){define("PHP_EOL",((DIRECTORY_SEPARATOR=="\\")?"\015\012":(strncmp(PHP_OS,"D",1)?"\012":"\015")));}if(!function_exists("stripos")){function stripos($haystack,$needle,$offset=NULL){return strpos(strtolower($haystack),strtolower($needle),$offset);}}if(!function_exists("strripos")){function strripos($haystack,$needle,$offset=NULL){if(isset($offset)){$haystack=strtolower($haystack);$needle=strtolower($needle);if($offset<0){$offset=strlen($haystack)+$offset;}do{$l=$new;$new=strpos($haystack,$needle,$l);}while(($new!==false)&&($new<$offset));return($l);}else{return strrpos(strtolower($haystack),strtolower($needle));}}}if(!function_exists("str_ireplace")){function str_ireplace($search,$replace,$subject,$count=NULL){if(is_array($search)){$replace=array_values($replace);foreach(array_values($search)as$i=>$srch){$subject=str_ireplace($srch,$replace[$i],$subject);}}else{$search="\007". preg_quote($search)."\007i";$replace=strtr($replace,array('$'=>'\\$',"\\"=>"\\\\"));$subject=preg_replace($search,$replace,$subject);}return($subject);}}if(!function_exists("get_headers")){function get_headers($url,$parse=0){$c=parse_url($url);extract($c);if(!isset($port)){$port=80;}if($f=fsockopen($host,$port,$errno,$errstr,$timeout=5)){fwrite($f,"HEAD$path HTTP/1.1\015\012"."Host:$host\015\012"."Connection: close\015\012"."Accept:*/*\015\012"."User-Agent:".trim(ini_get("user_agent"))."\015\012"."\015\012");socket_set_blocking($f,true);$ls=array();while(!feof($f)){$line=trim(fgets($f,1<<16));if(!strlen($line)){break;}elseif($parse){if($l=strpos($line,":")){$name=substr($line,0,$l);$value=trim(substr($line,$l+1));if(isset($ls[$name])){$ls[$name].=",$value";}else{$ls[$name]=$value;}}else{$ls[]=$line;}}else{$ls[]=$line;}}fclose($f);return($ls);}else{return(false);}}}if(!function_exists("headers_list")){function headers_list(){trigger_error("headers_list(): not supported by this PHP version",E_USER_WARNING);return(array)NULL;}}if(!function_exists("fprintf")){function fprintf(){$args=func_get_args();$stream=array_shift($args);return fwrite($stream,call_user_func_array("sprintf",$args));}}if(!function_exists("vfprintf")){function vfprintf($stream,$format,$args=NULL){return fwrite($stream,vsprintf($format,$args));}}if(!function_exists("str_split")){function str_split($str,$chunk=1){$r=array();if($chunk<1){$r[]=$str;}else{$len=strlen($str);for($n=0;$n<$len;$n+=$chunk){$r[]=substr($str,$n,$chunk);}}return($r);}}if(!function_exists("http_build_query")){function http_build_query($data,$prefix="",$fpfix="",$l=0){$s="";foreach($data as$in=>$val){$s_in=$in;if($fpfix){$s_in=$l ?"$fpfix"."[$s_in]":"$fpfix$s_in";}elseif(is_int($s_in)&&$prefix){$s_in="$prefix$s_in";}if(is_array($val)){$s .=http_build_query($val,"",$s_in,$l+1);}else{$s .="&$s_in=". urlencode($val);}}if(!$fpfix){$s=substr($s,1);}return($s);}}if(!function_exists("convert_uuencode")){function convert_uuencode($data){$out="";$line="";$len=strlen($data);for($n=0;$n<$len;){$x=(ord($data[$n++])<<16)+(ord($data[$n++])<<8)+(ord($data[$n++])<<0);$line .=chr(32+(($x>>18)&0x3f)). chr(32+(($x>>12)&0x3f)). chr(32+(($x>>6)&0x3f)). chr(32+(($x>>0)&0x3f));if(($n % 45)==0){$out .=chr(32+45)."$line\n";$line="";}}if($trail=($len % 45)){$out .=chr(32+$trail)."$line\n";}$out=strtr("$out \n","","`");return($out);}}if(!function_exists("convert_uudecode")){function convert_uudecode($data){$out="";$data=strtr($data,"`","");foreach(explode("\n",ltrim($data))as$line){if(!strlen($line)){break;}unset($num);$num=ord($line{0})-32;if(($num<=0)||($num>62)){break;}$line=substr($line,1);$add="";for($n=0;strlen($add)<$num;){$x=((ord($line[$n++])-32)<<18)+((ord($line[$n++])-32)<<12)+((ord($line[$n++])-32)<<6)+((ord($line[$n++])-32)<<0);$add .=chr(($x>>16)&0xff). chr(($x>>8)&0xff). chr(($x>>0)&0xff);}$out .=substr($add,0,$num);$line="";}return($out);}}if(!function_exists("scandir")){function scandir($dirname,$desc=0){if(strpos($dirname,"file://")===0){$dirname=substr($dirname,7);if(strpos($dirname,"localh")===0){$dirname=substr($dirname,strpos($dirname,"/"));}}if($dh=opendir($dirname)){$ls=array();while($fn=readdir($dh)){$ls[]=$fn;}closedir($dh);if($desc){rsort($ls);}else{sort($ls);}return$ls;}else{return false;}}}if(!function_exists("idate")){function idate($formatchar,$timestamp=NULL){if(strlen($formatchar)!=1){return false;}if(!isset($timestamp)){$timestamp=time();}return((int)(date($formatchar,$timestamp)));}}if(!function_exists("time_nanosleep")){function time_nanosleep($sec,$nano){sleep($sec);usleep($nano);}}if(!function_exists("strpbrk")){function strpbrk($haystack,$char_list){$cn=strlen($char_list);$min=strlen($haystack);for($n=0;$n<$cn;$n++){$l=strpos($haystack,$char_list{$n});if(($l!==false)&&($l<$min)){$min=$l;}}return($min ? substr($haystack,$min):$haystack);}}if(!function_exists("php_real_logo_guid")){function php_real_logo_guid(){return php_logo_guid();}function php_egg_logo_guid(){return zend_logo_guid();}}if(!function_exists("php_strip_whitespace")){function php_strip_whitespace($fn){$fn=escapeshellcmd($fn);$text=`php-wqCf '$fn'`;if(!$text){$text=implode("",file($fn));}return$text;}}if(!function_exists("php_check_syntax")){function php_check_syntax($fn){$args=func_get_args();if(count($args)>1){$result=&$args[1];}$fn=escapeshellcmd($fn);$result=system("php-lqCf '$fn'",$err);return($err==0);}}if(!function_exists("get_declared_interfaces")){function get_declared_interfaces(){trigger_error("get_declared_interfaces(): Current script won't run reliably with PHP4.",E_USER_WARNING);return((array)NULL);}}if(!function_exists("array_combine")){function array_combine($keys,$values){$keys=array_values($keys);$values=array_values($values);$r=array();foreach($values as$i=>$val){if($key=$keys[$i]){$r[$key]=$val;}else{$r[]=$val;}}return($r);}}if(!function_exists("array_walk_recursive")){function array_walk_recursive(&$input,$callback,$userdata=NULL){foreach($input as$i=>$value){if(is_array($value)){array_walk_recursive($input[$i],$callback,@$userdata);}else{call_user_func_array($callback,array(&$input[$i],&$i,@$userdata));}}return NULL;}}if(!function_exists("substr_compare")){function substr_compare($haystack,$needle,$offset=0,$len=0,$ci=0){if($len<=0){$len=strlen($needle);if(!$len){return(0);}}if($len+$offset>=strlen($haystack)){trigger_error("substr_compare: given length exceeds main_str",E_USER_WARNING);return(false);}if($offset){$haystack=substr($haystack,$offset,$len);}if($ci){$haystack=strtolower($haystack);$needle=strtolower($needle);}return(strncmp($haystack,$needle,$len));}}if(!function_exists("spl_classes")){function spl_classes(){trigger_error("spl_classes(): not built into this PHP version");return(array)NULL;}}if(!function_exists("class_parents")){function class_parents($obj){$all=get_declared_classes();$r=array();foreach($all as$potential_parent){if(is_subclass_of($obj,$potential_parent)){$r[$potential_parent]=$potential_parent;}}return($r);}}if(!function_exists("session_commit")&&function_exists("session_write_close")){function session_commit(){session_write_close();}}if(!function_exists("dns_check_record")){function dns_check_record($host,$type=NULL){return checkdnsrr($host,$type);}}if(!function_exists("dns_get_mx")){function dns_get_mx($host,$mx){$args=func_get_args();if($args[2]){$w=&$args[2];}return getmxrr($host,$mx,$w);}}if(!function_exists("setrawcookie")){function setrawcookie($name,$value=NULL,$expire=NULL,$path=NULL,$domain=NULL,$secure=0){if(isset($value)&&strpbrk($value,",;\r\t\n\f\014\013")){trigger_error("setrawcookie: value may not contain any of ',;\r\n' and some other control chars;thrown away",E_USER_WARNING);}else{$h="Set-Cookie:$name=$value".($expire ?";expires=". gmstrftime("%a,%d-%b-%y %H:%M:%S %Z",$expire):"").($path ?";path=$path":"").($domain ?";domain=$domain":"").($secure ?";secure":"");header($h);}}}if(!function_exists("file_put_contents")){define("FILE_USE_INCLUDE_PATH",1);define("FILE_IGNORE_NEW_LINES",2);define("FILE_SKIP_EMPTY_LINES",4);define("FILE_APPEND",8);define("FILE_NO_DEFAULT_CONTEXT",16);function file_put_contents($filename,$data,$flags=0,$resource=NULL){if($f=fopen($filename,($flags&FILE_APPEND?"a":"w")."b",$flags&FILE_USE_INCLUDE_PATH)){fwrite($f,$data);fclose($f);return(TRUE);}}}if(!defined("E_STRICT")){define("E_STRICT",2048);}if(!function_exists("file_get_contents")){function file_get_contents($filename,$use_include_path=1){if($f=fopen($filename,"rb",$use_include_path)){$content=fread($f,1<<21);fclose($f);return($content);}}}if(!function_exists("fnmatch")){define("FNM_PATHNAME",1<<0);define("FNM_NOESCAPE",1<<1);define("FNM_PERIOD",1<<2);define("FNM_LEADING_DIR",1<<3);define("FNM_CASEFOLD",0x50);define("FNM_EXTMATCH",1<<5);function fnmatch($pattern,$str,$flags=0x0000){static$cmp=array();$rxci=($flags&FNM_CASEFOLD ?'i' :'');$rx=@$cmp["$pattern$flags"];if(($str[0]==".")&&($flags&FNM_PERIOD)){if($pattern[0]!="."){return(false);}}if(!$rx){if(count($cmp)>=10){$cmp=array();}$rx=preg_quote($pattern);$wild=(($flags&FNM_PATHNAME)?"[^/]":".");$rx=strtr($rx,array("\\*"=>"$wild*?","\\?"=>"$wild","\\["=>"[","\\]"=>"]",));$rx="\007^$rx$\007$rxci";$cmp["$pattern$flags"]=$rx;}return(preg_match($rx,$str));}}if(!function_exists("glob")){define("GLOB_MARK",1<<0);define("GLOB_NOSORT",1<<1);define("GLOB_NOCHECK",1<<2);define("GLOB_NOESCAPE",1<<3);define("GLOB_BRACE",1<<4);define("GLOB_ONLYDIR",1<<5);define("GLOB_NOCASE",1<<6);define("GLOB_DOTS",1<<7);function glob($pattern,$flags=0x0000){$ls=array();$rxci=($flags&GLOB_NOCASE)?"i":"";if($pattern){$parts2=explode("/",$pattern);$pat=preg_quote($pattern);$pat=strtr($pat,array("\\*"=>".*?","\\?"=>".?"));if($flags ^ GLOB_NOESCAPE){}if($flags ^ GLOB_BRACE){$pat=preg_replace("/\{(.+?)\}/e",'strtr("[$1]",",","")',$pat);}$parts=explode("/",$pat);$lasti=count($parts)-1;$dn="";foreach($parts as$i=>$p){if(!strpos($p,"*?")&&(strpos($p,".?")===false)){$dn .=$parts2[$i].($i!=$lasti ?"/":"");continue;}if($dh=opendir($dn ?$dn:'.')){$with_dot=($p[1]==".")||($flags&GLOB_DOTS);while($fn=readdir($dh)){if(preg_match("\007^$p$\007$rxci",$fn)){if(($fn[0]==".")&&!$with_dot){continue;}if($i==$lasti){if(is_dir("$dn$fn")){if($flags&GLOB_ONLYDIR){continue;}if($flags&GLOB_MARK){$fn .="/";}}$ls[]="$dn$fn";}elseif(is_dir("$dn$fn")){$remaind=implode("/",array_slice($parts2,$i+1));$ls=array_merge($ls,glob("$dn$fn/$remaind",$flags));}}}closedir($dh);break;}else{return($ls);}}}if(!$ls&&($flags&GLOB_NOCHECK)){$ls[]=$pattern;}if($flags ^ GLOB_NOSORT){sort($ls);}return($ls);}}if(!function_exists("array_key_exists")){function array_key_exists($key,$search){return isset($search[$key]);}}if(!function_exists("array_intersect_assoc")){function array_intersect_assoc(){$whatsleftover=array();$in=func_get_args();$cmax=count($in);foreach($in[0]as$i=>$v){for($c=1;$c<$cmax;$c++){if(@$in[$c][$i]!==$v){continue 2;}}$whatsleftover[$i]=$v;}return$whatsleftover;}}if(!function_exists("array_diff_assoc")){function array_diff_assoc(){$diff=array();$in=func_get_args();foreach($in[0]as$i=>$v){for($c=1;$c<count($in);$c++){if(isset($in[$c][$i])&&($in[$c][$i]==$v)){continue 2;}}$diff[$i]=$v;}return$diff;}}if(!function_exists("html_entity_decode")){function html_entity_decode($string,$quote_style=ENT_COMPAT,$charset="ISO-8859-1"){$y=array_flip(get_html_translation_table(HTML_ENTITIES,$quote_style));return strtr($string,$y);}}if(!function_exists("str_word_count")){function str_word_count($string,$format=0){preg_match_all('/([\w](?:[-\'\w]?[\w]+)*)/',$string,$uu);if(!$format){return(count($uu[1]));}elseif($format==1){return($uu[1]);}else{$r=array();$l=0;foreach($uu[1]as$word){$l=strpos($string,$word,$l);$r[$l]=$word;$l+=strlen($word);}return($r);}}}if(!function_exists("str_shuffle")){function str_shuffle($str){$r="";while(strlen($str)){$n=strlen($str)-1;if($n){$n=rand(0,$n);}$r .=$str[$n];$str=substr($str,0,$n). substr($str,$n+1);}return($r);}}if(!function_exists("get_include_path")){function get_include_path(){return(get_cfg_var("include_path"));}function set_include_path($new){return ini_set("include_path",$new);}function restore_include_path(){ini_restore("include_path");}}if(!defined("PATH_SEPARATOR")){define("PATH_SEPARATOR",((DIRECTORY_SEPARATOR=='\\')?';' :':'));define("PHP_SHLIB_SUFFIX",((DIRECTORY_SEPARATOR=='\\')?'dll' :'so'));}if(!defined("PHP_SAPI")){define("PHP_SAPI",php_sapi_name());}if(!defined("PHP_PREFIX")&&isset($_ENV["_"])){define("PHP_PREFIX",substr($_ENV["_"],strpos($_ENV["_"],"/bin/")));}if(!function_exists("str_rot13")){function str_rot13($str){static$from="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";static$to="NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm";return strtr($str,$from,$to);}}if(!function_exists("array_change_key_case")){define("CASE_LOWER",0);define("CASE_UPPER",1);function array_change_key_case($array,$case=CASE_LOWER){foreach($array as$i=>$v){unset($array[$i]);if(is_string($i)){$i=($case==CASE_LOWER)? strtolower($i): strtoupper($i);}$array[$i]=$v;}return($array);}}if(!function_exists("array_fill")){function array_fill($start_index,$num,$value){$r=array();for($i=$start_index,$end=$num+$i;$i<$end;$i++){$r[$i]=$value;}return($r);}}if(!function_exists("array_chunk")){function array_chunk($input,$size,$preserve_keys=false){$r=array();$n=-1;foreach($input as$i=>$v){if(($n<0)||(count($r[$n])==$size)){$n++;$r[$n]=array();}if($preserve_keys){$r[$n][$i]=$v;}else{$r[$n][]=$v;}}return($r);}}if(!function_exists("md5_file")){function md5_file($filename,$raw_output=false){if($f=fopen($filename,"rb")){$data=fread($f,1<<22);fclose($f);$r=md5($data);$data=NULL;if($raw_output){$r=pack("H*",$r);}return$r;}}}if(!function_exists("is_a")){function is_a($obj,$classname){return((strtolower(get_class($obj))==strtolower($classname))or is_subclass_of($obj,$classname));}}if(!function_exists("fmod")){function fmod($x,$y){$r=$x/$y;$r-=(int)$r;$r*=$y;return($r);}}if(!function_exists("floatval")){function floatval($str){$str=ltrim($str);return(float)$str;}}if(!function_exists("is_infinite")){define("NAN","NAN");define("INF","INF");function is_infinite($f){$s=(string)$f;return(($s=="INF")||($s=="-INF"));}function is_nan($f){$s=(string)$f;return($s=="NAN");}function is_finite($f){$s=(string)$f;return(!strpos($s,"N"));}}if(!function_exists("var_export")){function var_export($var,$return=false,$indent="",$output=""){if(is_object($var)){$output="class". get_class($var)."{\n";foreach(((array)$var)as$id=>$var){$output .="var \$$id=". var_export($var,true).";\n";}$output .="}";}elseif(is_array($var)){foreach($var as$id=>$next){if($output)$output .=",\n";else$output="array(\n";$output .=$indent . ' ' .(is_numeric($id)?$id : '"'.addslashes($id).'"'). '=>' . var_export($next,true,"$indent");}if(empty($output))$output="array(";$output .="\n{$indent})";}elseif(is_numeric($var)){$output="$var";}elseif(is_bool($var)){$output=$var ?"true":"false";}else{$output="'". preg_replace("/([\\\\\'])/",'\\\\$1',$var)."'";}if($return){return($output);}else{print($output);}}}if(!function_exists("strcoll")){function strcoll($str1,$str2){return strcmp($str1,$str2);}}if(!function_exists("diskfreespace")){function diskfreespace(){return disk_free_sapce();}function disktotalspace(){return disk_total_sapce();}}if(!function_exists("vprintf")){function vprintf($format,$args=NULL){call_user_func_array("fprintf",get_func_args());}}if(!function_exists("vsprintf")){function vsprintf($format,$args=NULL){$args=array_merge(array($format),array_values((array)$args));return call_user_func_array("sprintf",$args);}}if(!function_exists("import_request_variables")){function import_request_variables($types="GPC",$pfix=""){if(!isset($_REQUEST)){$_GET=&$HTTP_GET_VARS;$_POST=&$HTTP_POST_VARS;$_COOKIE=&$HTTP_COOKIE_VARS;}$alias=array("G"=>"_GET","P"=>"_POST","C"=>"_COOKIE",);for($i=0;$i<strlen($types);$i++){if($FROM=$alias[strtoupper($c)]){foreach($$FROM as$key=>$val){if(!isset($GLOBALS[$pfix.$key])){$GLOBALS[$pfix.$key]=$val;}}}}}}if(!function_exists("hypot")){function hypot($num1,$num2){return sqrt($num1*$num1+$num2*$num2);}}if(!function_exists("log1p")){function log1p($x){return(log(1+$x));}function expm1($x){return(exp($x)-1);}}if(!function_exists("sinh")){function sinh($f){return((exp($f)-exp(-$f))/2);}function cosh($f){return((exp($f)+exp(-$f))/2);}function tanh($f){return(sinh($f)/cosh($f));}}if(!function_exists("asinh")){function asinh($x){return(log($x+sqrt($x*$x+1)));}function acosh($x){return(log($x+sqrt($x*$x-1)));}function atanh($x){return(log1p(2*$x/(1-$x))/2);}}?> |
Changes to dtools/ckavail.php.
1 2 3 4 5 6 7 8 | <?php /* Run this first with an older PHP interpreter, and then with a newer version. This way you get a list (once) of added functions (the func list is stored in a temporary file). */ #-- load previous list | > | > < | | | | > > | > | | | | > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | <?php /* Run this first with an older PHP interpreter, and then with a newer version. This way you get a list (once) of added functions (the func list is stored in a temporary file). */ $DATA_FILE = "/tmp/ckavail.lst"; #-- load previous list if ($f = @fopen($DATA_FILE, "rb")) { $oldl = unserialize(fread($f, 1<<20)); fclose($f); } //echo "OLD=";print_r($oldl); #-- current func list $newl = get_defined_stuff(); //echo "NEW=";print_r($newl); #-- save this one if ($f = fopen($DATA_FILE, "wb")) { fwrite($f, serialize($newl)); fclose($f); } else { echo "ERROR(could not save current list)\n"; } #-- comparison of current / last run echo "old(".count($oldl["functions"])."), new(".count($newl["functions"]).")\n"; if ($oldl) { #-- funcs $new = array_diff($newl["functions"], $oldl["functions"]); echo "New functions added between PHP $oldl[version] and current $newl[version] interpreter:\n"; print_r($new); #-- constants $new = array_diff(array_keys($newl["constants"]), array_keys($oldl["constants"])); echo "\nNewly added constants:\n"; print_r($new); #-- classes $new = array_diff($newl["classes"], $oldl["classes"]); echo "\nAnd classes:\n"; print_r($new); } else { echo "Now start this script a 2nd time with the newer interpreter version.\n"; } function get_defined_stuff() { $rl = array(); $f = get_defined_functions(); while ($f["internal"]) { $f = $f["internal"]; } $rl["functions"] = $f; $c = get_defined_constants(); $rl["constants"] = $c; $c = get_declared_classes(); $rl["classes"] = $c; $rl["version"] = PHP_VERSION; return($rl); } ?> |
Changes to dtools/updoc.
1 2 3 4 5 6 7 | #!/usr/local/bin/php -qC <?php /* Adds hints about emulation functions to your local PHP documentation. */ #-- help | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #!/usr/local/bin/php -qC <?php /* Adds hints about emulation functions to your local PHP documentation. */ #-- help if ($_SERVER["argc"] < 2) { echo<<<END Usage: updoc [.../upgrade.php] /path/to/your/php-doc/directory/ This script will update your PHP documentation, if you have the (DocBook-converted) multi-html-files version installed. The first parameter must be the filepath to the 'upgrade.php' script, so the names of the emulated functions are known. You will afterwards find the abbreviation "EMU" in the required- |
︙ | ︙ | |||
29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #-- run else { error_reporting(0); #-- params $emu = $_SERVER["argv"][1]; $dir = $_SERVER["argv"][2]; if (!is_dir($dir)) { die("The given 'PHP doc directory' of \"$dir\" isn't!\n"); } if (!file_exists($emu)) { die("Couldn't find 'upgrade.php' script under the given name \"$emu\".\n"); } | > > > > | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #-- run else { error_reporting(0); #-- params $emu = $_SERVER["argv"][1]; $dir = $_SERVER["argv"][2]; if (!$dir) { $dir = $emu; $emu = dirname(__FILE__)."/../upgrade.php"; } if (!is_dir($dir)) { die("The given 'PHP doc directory' of \"$dir\" isn't!\n"); } if (!file_exists($emu)) { die("Couldn't find 'upgrade.php' script under the given name \"$emu\".\n"); } |
︙ | ︙ | |||
82 83 84 85 86 87 88 | "data"=>"PGh0bWw+PGhlYWQ+PHRpdGxlPmd6ZGVjb2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IGdldHRpbmcgY29tcHJlc3NlZC4uLiIpOzxicj4KPGJyPgombmJzcDsgICRzdHIgPSBmdW5jdGlvbl9leGlzdHMoImd6ZGVjb2RlIik8YnI+CiZuYnNwOyAmbmJzcDsgJm5ic3A7ICA/IGd6ZGVjb2RlKCRnemRhdGEpPGJyPgombmJzcDsgJm5ic3A7ICZuYnNwOyAgOiBnemluZmxhdGUoc3Vic3RyKCRnemRhdGEsIDEwLCAtOCkpOzxicj4KPGJyPgo8L2NvZGU+CjwvcD4KCjxocj4KPHRhYmxlIGJvcmRlcj0iMCIgd2lkdGg9IjEwMCUiIGNlbGxwYWRkaW5nPSIwIiBjZWxsc3BhY2luZz0iMCI+PHRyPgogIDx0ZCB3aWR0aD0iMzMlIiBhbGlnbj0ibGVmdCI+PGEgaHJlZj0iZnVuY3Rpb24uZ3pkZWZsYXRlLmh0bWwiPmJhY2s8L2E+PGJyPmd6ZGVmbGF0ZTwvdGQ+CiAgPHRkIHdpZHRoPSIzMyUiIGFsaWduPSJjZW50ZXIiPjxhIGhyZWY9InJlZi56bGliLmh0bWwiPnVwPC9hPjxicj56bGliIG92ZXJ2aWV3PC90ZD4KICA8dGQgd2lkdGg9IjMzJSIgYWxpZ249InJpZ2h0Ij48YSBocmVmPSJmdW5jdGlvbi5nemVuY29kZS5odG1sIj5uZXh0PC9hPjxicj5nemVuY29kZTwvdGQ+CjwvdHI+PC90YWJsZT4KCjwvYm9keT4KPC9odG1sPgo=", "sect"=>"zlib", "after"=>"gzencode", "desc"=>"Decode a gzip compressed string", ), ); foreach ($add_files as $data) { extract($data); | | > | > | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | "data"=>"PGh0bWw+PGhlYWQ+PHRpdGxlPmd6ZGVjb2RlPC90aXRsZT48L2hlYWQ+Cjxib2R5Pgo8ZGl2IGFsaWduPSJjZW50ZXIiPnVwZ3JhZGUucGh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leGlzdHMoImd6ZGVjb2RlIik8YnI+CiZuYnNwOyAmbmJzcDsgJm5ic3A7ICA/IGd6ZGVjb2RlKCRnemRhdGEpPGJyPgombmJzcDsgJm5ic3A7ICZuYnNwOyAgOiBnemluZmxhdGUoc3Vic3RyKCRnemRhdGEsIDEwLCAtOCkpOzxicj4KPGJyPgo8L2NvZGU+CjwvcD4KCjxocj4KPHRhYmxlIGJvcmRlcj0iMCIgd2lkdGg9IjEwMCUiIGNlbGxwYWRkaW5nPSIwIiBjZWxsc3BhY2luZz0iMCI+PHRyPgogIDx0ZCB3aWR0aD0iMzMlIiBhbGlnbj0ibGVmdCI+PGEgaHJlZj0iZnVuY3Rpb24uZ3pkZWZsYXRlLmh0bWwiPmJhY2s8L2E+PGJyPmd6ZGVmbGF0ZTwvdGQ+CiAgPHRkIHdpZHRoPSIzMyUiIGFsaWduPSJjZW50ZXIiPjxhIGhyZWY9InJlZi56bGliLmh0bWwiPnVwPC9hPjxicj56bGliIG92ZXJ2aWV3PC90ZD4KICA8dGQgd2lkdGg9IjMzJSIgYWxpZ249InJpZ2h0Ij48YSBocmVmPSJmdW5jdGlvbi5nemVuY29kZS5odG1sIj5uZXh0PC9hPjxicj5nemVuY29kZTwvdGQ+CjwvdHI+PC90YWJsZT4KCjwvYm9keT4KPC9odG1sPgo=", "sect"=>"zlib", "after"=>"gzencode", "desc"=>"Decode a gzip compressed string", ), ); foreach ($add_files as $data) { extract($data); if (!file_exists($fn = "$dir/function.$func.html") ||1) { echo "adding \"$fn\"\n"; $f = fopen($fn, "w"); fwrite($f, base64_decode($data)); fclose($f); #-- update function list page $fn = array("$dir/ref.$sect.html", "$dir/index.functions.html"); update_files($fn, "/(<a\s+href=\"function.$after)/ims", "<a href=\"function.$func.html\">$func</a> -- $desc.</dt>\n<dt> $1" ); } } } #-- inject something into a file function update_files($list, $regex, $replace) { if (!is_array($list)) { $list = array($list); } foreach ($list as $fn) { echo "+$fn\n"; $f = fopen($fn, "r"); $html = fread($f, 1<<20); fclose($f); $html = preg_replace($regex, $replace, $html); $f = fopen($fn, "w"); fwrite($f, $html); fclose($f); } } ?> |
Added ext/base64.php.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | <?php /* This script implements the base64-encoding functions and base32 and base16 as described in RFC3548. */ if (!function_exists("base16_encode")) { #-- URL and filename safe variants of base64-encoding function base64_encode_safe($str) { return strtr(base64_encode($str), "+/", "-_"); } function base64_decode_safe($b64) { return base64_decode(strtr($str, "-_", "+/")); } #-- base16 function base16_encode($str) { return chunk_split(bin2hex($str)); } function base16_decode($b16) { $b16 = preg_replace("/\s+/", '', $b16); $b16 = pack("H*", $b16); return($b16[0]); } #-- base32 function base32_encode() { # strtoupper() # "A-Z,0-7,=" } } ?> |
Changes to ext/fakezlib.php.
1 2 3 4 5 6 7 | <?php /* This script simulates the gz*() functions, without actually providing compression functionality. The generated data streams will be correct, but reading compressed files isn't possible. Not very useful; should only be used if there is no other way. But if | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <?php /* This script simulates the gz*() functions, without actually providing compression functionality. The generated data streams will be correct, but reading compressed files isn't possible. Not very useful; should only be used if there is no other way. But if your provider seriously doesn't have PHP with builtin zlib support, you were better off simply switching to someone else! */ #-- fake zlib if (!function_exists("gzopen")) { function gzopen($fp, $mode) { |
︙ | ︙ |
Added ext/gettext.php.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | <?php /* Simulates gettext functionality. Understands .mo and .po files. Lookup of plural forms mostly work (but not fully compliant, no support for Plural-Forms: header). Categories/codesets are ignored. Besides using setlocale() you should change the $_ENV["LANG"] var to the desired language manually. Additionally all your scripts could contain following (may also work with standard gettext): $_ENV["LANGUAGE"] = $_SERVER["HTTP_ACCEPT_LANGUAGE"]; What's often more user-friendly than hardwired server-side values. */ #-- define if not there if (!function_exists("gettext")) { #-- all-in-one combined implementation # (in PHP only the first parameter is used) function gettext($msg, $msg2=NULL, $domain=NULL, $category=NULL, $plural=NULL, $config=NULL) { global $_GETTEXT; #-- params if (!isset($domain)) { $domain = $_GETTEXT["%domain"]; } elseif (empty($_GETTEXT[$domain])) { bindtextdomain($domain); // load from system dirs } #-- config if (isset($config)) { return false; } #-- plural array position (English) if (!isset($plural) || ($plural == 1)) { $pli = 0; } else { if (isset($msg2)) { $msg = $msg2; } $pli = 1; } // $pli = ($plural==1) ?0 :1; #-- look up if ($trans = $_GETTEXT[$domain][$msg]) { if (is_array($trans)) { if (!isset($trans[$pli])) { $pli = 0; } $trans = $trans[$pli]; } if (strlen($trans)) { $msg = $trans; } } #-- give out whatever we have return($msg); } #-- wrappers function ngettext($msg1, $msg2, $plural) { return gettext($msg1, $msg2, NULL, NULL, $plural); } function dngettext($domain, $msg1, $msg2, $plural) { return gettext($msg1, $msg2, $domain, NULL, $plural); } function dcngettext($domain, $msg1, $msg2, $plural, $category) { return gettext($msg1, $msg2, $domain, $category, $plural); } function dcgettext($domain, $msg, $category) { return gettext($msg, NULL, $domain, $category); } function dgettext($domain, $msg) { return gettext($msg, NULL, $domain); } #-- settings function textdomain($default="NULL") { global $_GETTEXT; $prev = $_GETTEXT["%domain"]; if (isset($default)) { $_GETTEXT["%domain"] = $default; } return $prev; } #-- loads data files function bindtextdomain($domain, $directory="/usr/share/locale:/usr/local/share/locale:./locale") { global $_GETTEXT; if (isset($_GETTEXT["domain"]) && (count($_GETTEXT["domain"]) > 3)) { return; // don't load twice } $_GETTEXT[$domain]["%dir"] = $directory; $_GETTEXT["%locale"] = setlocale(LC_CTYPE, 0); #-- language directories $langs = "$_ENV[LANGUAGE],$_ENV[LC_ALL],$_ENV[LC_MESSAGE],$_ENV[LANG]," . "{$_GETTEXT['%locale']},$_SERVER[HTTP_ACCEPT_LANGUAGE],C,en"; foreach (explode(",",$langs) as $d) { $d = trim($d); // $dir2[] = $d; $d = strtok($d, "@.-+=%:; "); if (strlen($d)) { $dir2[] = $d; } if (strpos($d, "_")) { $dir2[] = strtok($d, "_"); } } #-- repeat foreach (explode(":", $directory) as $directory) foreach ($dir2 as $lang) { $base_fn = "$directory/$lang/LC_MESSAGES/$domain"; #-- binary format if (file_exists($f = "$base_fn.mo") && ($f = fopen($f, "rb"))) { $data = fread($f, 1<<20); fclose($f); #-- check file magic if ($data) { extract(unpack("L1magic/L1version/L1count/L1o_msg/L1o_trn", substr($data, 0, 20))); if ((dechex($magic) == "950412de") && ($version == 0)) { for ($n=0; $n<$count; $n++) { #-- id $r = unpack("L1len/L1offs", substr($data, $o_msg + $n * 8, 8)); $msgid = substr($data, $r["offs"], $r["len"]); unset($msgid_plural); if (strpos($msgid, "\000")) { list($msgid, $msgid_plural) = explode("\000", $msgid); } #-- translation $r = unpack("L1len/L1offs", substr($data, $o_trn + $n * 8, 8)); $msgstr = substr($data, $r["offs"], $r["len"]); if (strpos($msgstr, "\000")) { $msgstr = explode("\000", $msgstr); } #-- add $_GETTEXT[$domain][$msgid] = $msgstr; if (isset($msgid_plural)) { $_GETTEXT[$domain][$msgid_plural] = &$_GETTEXT[$domain][$msgid]; } } } } break; } #-- read from text file (not fully correct, and redundant because # the original gettext/libintl doesn't support this at all) elseif (file_exists($f = "$base_fn.po") && ($f = fopen($f, "r"))) { do { $line = trim(fgets($f)); if (isset($msgid) && isset($msgstr) && (empty($line) || ($line[0]=="m"))) { foreach ($msgstr as $v) { $_GETTEXT[$domain][$msgid[0]] = $v; } if ($msgid[1]) { $_GETTEXT[$domain][$msgid[1]] = &$_GETTEXT[$domain][$msgid[0]]; } unset($msgid); unset($msgstr); } $space = strpos($line, " "); if ($line[0] == "#") { continue; } elseif (strncmp($line, "msgid", 5)==0) { $msgid[] = trim(substr($line, $space+1), '"'); } elseif (strncmp($line, "msgstr", 6)==0) { $msgstr[] = trim(substr($line, $space+1), '"'); } elseif ($line[0] == '"') { $line = trim($line, '"'); if (isset($msggstr)) { $msgstr[count($msgstr)] .= $line; } else { $msgid[count($msgid)] .= $line; } } } while (!feof($f)); if ($msgid && $msgstr) { $_GETTEXT[$domain][$msgid[0]] = $msgstr[0]; } fclose($f); break; } }//foreach #-- set as default textdomain if (empty($_GETTEXT["%domain"]) && (count($_GETTEXT[$domain]) > 1)) { $_GETTEXT["%domain"] = $domain; } return($domain); } #-- ignored setting (no idea what it really should do) function bind_textdomain_codeset($domain, $codeset) { global $_GETTEXT; $_GETTEXT[$domain]["%codeset"] = $codeset; return($domain); } } #-- define separately if (!function_exists("_")) { function _($str) { return gettext($str); } } ?> |
Changes to ext/mime.php.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <?php /* Simulates the mime_magic extension. Was originally implemented for [http://nanoweb.si.kz/], but that mime magic data reading was reinjected for this version (more unclean, though). You still need to get the "mime_magic" file to use this, please see file(1) for more informations. */ #-- mime-magic, type will be detected by analyzing the content if (!function_exists("mime_content_type")) { function mime_content_type($fn) { | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <?php /* Simulates the mime_magic extension. Was originally implemented for [http://nanoweb.si.kz/], but that mime magic data reading was reinjected for this version (more unclean, though). You still need to get the "mime_magic" file to use this, please see file(1) for more informations. Also simulates the image type/mime/ext functions. */ #-- mime-magic, type will be detected by analyzing the content if (!function_exists("mime_content_type")) { function mime_content_type($fn) { |
︙ | ︙ | |||
239 240 241 242 243 244 245 | #-- gives Media Type for the index numbers getimagesize() returned if (!function_exists("image_type_to_mime_type")) { define("IMAGETYPE_GIF", 1); define("IMAGETYPE_JPEG", 2); define("IMAGETYPE_PNG", 3); define("IMAGETYPE_SWF", 4); | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > > > > > > | | | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | #-- gives Media Type for the index numbers getimagesize() returned if (!function_exists("image_type_to_mime_type")) { define("IMAGETYPE_GIF", 1); define("IMAGETYPE_JPEG", 2); define("IMAGETYPE_PNG", 3); define("IMAGETYPE_SWF", 4); define("IMAGETYPE_PSD", 5); // post-4.3 from here ... define("IMAGETYPE_BMP", 6); define("IMAGETYPE_TIFF_II", 7); define("IMAGETYPE_TIFF_MM", 8); define("IMAGETYPE_JPC", 9); define("IMAGETYPE_JP2", 10); define("IMAGETYPE_JPX", 11); define("IMAGETYPE_JB2", 12); define("IMAGETYPE_SWC", 13); define("IMAGETYPE_IFF", 14); define("IMAGETYPE_WBMP", 15); define("IMAGETYPE_XBM", 16); define("IMAGETYPE_MNG", 77); define("IMAGETYPE_XPM", 88); define("IMAGETYPE_ZIF", 90); define("IMAGETYPE_PBM", 80); define("IMAGETYPE_PGM", 81); define("IMAGETYPE_PPM", 82); function image_type_to_mime_type($id) { static $mime = array( IMAGETYPE_GIF => "gif", IMAGETYPE_JPEG => "jpeg", IMAGETYPE_PNG => "png", IMAGETYPE_SWF => "application/x-shockwave-flash", IMAGETYPE_BMP => "bmp", IMAGETYPE_JP2 => "jp2", IMAGETYPE_WBMP => "vnd.wap.wbmp", IMAGETYPE_XBM => "xbm", IMAGETYPE_PSD => "x-photoshop", IMAGETYPE_TIFF_II => "tiff", IMAGETYPE_TIFF_MM => "tiff", IMAGETYPE_JPC => "application/octet-stream", IMAGETYPE_JP2 => "jp2", // IMAGETYPE_JPX => "", // IMAGETYPE_JB2 => "", IMAGETYPE_SWC => "application/x-shockwave-flash", IMAGETYPE_IFF => "iff", IMAGETYPE_XPM => "x-xpm", IMAGETYPE_ZIF => "unknown", IMAGETYPE_MNG => "video/mng", IMAGETYPE_PBM => "x-portable-bitmap", IMAGETYPE_PGM => "x-portable-greymap", IMAGETYPE_PPM => "x-portable-pixmap", ); if (isset($mime[$id])) { $m = $mime[$id]; strpos($m, "/") || ($m = "image/$m"); } else { $m = "image/unknown"; } return($m); } } #-- still in CVS if (!function_exists("image_type_to_extension")) { function image_type_to_extension($id, $dot=true) { static $ext = array( 0=>false, 1=>"gif", 2=>"jpeg", 3=>"png", "swf", "psd", "bmp", "tiff", "tiff", "jpc", "jp2", "jpx", "jb2", "swc", "wbmp", "xbm", 77=>"mng", 88=>"xpm", 90=>"zif", 80=>"pbm", 81=>"pgm", 82=>"ppm", ); $m = $ext[$id]; if ($m && $dot) { $m = ".$m"; } return($m); } } #-- we need this then, too if (!function_exists("exif_imagetype")) { function exif_imagetype($fn) { $magic = array( "\211PNG" => IMAGETYPE_PNG, "\377\330" => IMAGETYPE_JPEG, "GIF89a" => IMAGETYPE_GIF, "GIF94z" => IMAGETYPE_ZIF, "FWS" => IMAGETYPE_SWF, "II" => IMAGETYPE_TIFF_II, "MM" => IMAGETYPE_TIFF_MM, "/* XPM" => IMAGETYPE_XPM, "BM" => IMAGETYPE_BMP, // also for OS/2 "\212MNG" => IMAGETYPE_MNG, "P1" => IMAGETYPE_PBM, "P4" => IMAGETYPE_PBM, "P2" => IMAGETYPE_PGM, "P5" => IMAGETYPE_PGM, "P3" => IMAGETYPE_PPM, "P6" => IMAGETYPE_PPM, ); if ($f = fopen($fn, "rb")) { $bin = fread($f, 8); fclose($f); foreach ($magic as $scn=>$id) { if (!strncmp($bin, $scn, strlen($scn))) { return $id; } } } } } ?> |
Changes to ext/old.php.
1 2 | <?php /* | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | <?php /* Here we collect PHP functions for versions before 4.1 - it should be noted that 4.0.x versions can't be made compatible with newer versions anyhow, because the newer superglobals ($_GET, $_REQUEST) are missing. Most of this is untested. Have a look at PEAR::PHP_Compat for emulation of some of these (it's not complete in this regard, too). */ #---------------------------------------------------------------- 4.0.7 --- #-- simulate superglobals |
︙ | ︙ | |||
22 23 24 25 26 27 28 | $GLOBALS["_COOKIE"] = & $HTTP_COOKIE_VARS; $GLOBALS["_FILES"] = & $HTTP_POST_FILES; $GLOBALS["_REQUEST"] = array_merge($HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS); } #---------------------------------------------------------------- 4.0.6 --- | < < | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | $GLOBALS["_COOKIE"] = & $HTTP_COOKIE_VARS; $GLOBALS["_FILES"] = & $HTTP_POST_FILES; $GLOBALS["_REQUEST"] = array_merge($HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS); } #---------------------------------------------------------------- 4.0.6 --- #-- uses callback function to remove entries from array if (!function_exists("array_filter")) { function array_filter($array, $callback="is_int") { foreach ($array as $key=>$val) { if (!call_user_func_array($callback, array($val))) { |
︙ | ︙ | |||
112 113 114 115 116 117 118 | } } #---------------------------------------------------------------- 4.0.5 --- | < < < | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | } } #---------------------------------------------------------------- 4.0.5 --- # chroot #-- return index of value in array if (!function_exists("array_search")) { function array_search($value, $array, $strict=false) { $strict = $strict ? true : false; foreach ($array as $key=>$v) { |
︙ | ︙ | |||
156 157 158 159 160 161 162 | #-- checks variable to be of a simple type if (!function_exists("is_scalar")) { function is_scalar($var) { return( !is_array($var) && !is_object($var) ); } } | > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | > > > > > > | > > > > > | > > | > > > | | | > > > > > > > > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > < | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | #-- checks variable to be of a simple type if (!function_exists("is_scalar")) { function is_scalar($var) { return( !is_array($var) && !is_object($var) ); } } #-- only static value (mix of C/English/European/US) if (!function_exists("localeconv")) { function localeconv() { return array ( 'decimal_point' => '.', 'thousands_sep' => '', 'int_curr_symbol' => 'EUR ', // more international than USD 'currency_symbol' => '¤', // unnamed/trans currency symbol 'mon_decimal_point' => '.', 'mon_thousands_sep' => ',', 'positive_sign' => '', 'negative_sign' => '-', 'int_frac_digits' => 2, 'frac_digits' => 2, 'p_cs_precedes' => 1, 'p_sep_by_space' => 0, 'n_cs_precedes' => 1, 'n_sep_by_space' => 0, 'p_sign_posn' => 1, 'n_sign_posn' => 1, 'grouping' => array (0=>3, 1=>3,), 'mon_grouping' => array(0=>3, 1=>3,), ); } } #-- function by name if (!function_exists("call_user_func_array")) { function call_user_func_array($callback, $param_array=array()) { if ($param_array) { $param_array = array_values($param_array); $params = "'" . implode("','", $param_array) . "'"; } if (is_array($callback)) { $obj = &$callback[0]; $method = $callback[1]; if (!method_exists($obj, $method)) { trigger_error("call_user_method_array: method '$method' does not exist", E_ERROR); } elseif (is_object($obj)) { eval("return \$obj->$method($params);"); } else { eval("return $obj::$method($params);"); } } elseif (!function_exists("$callback")) { trigger_error("call_user_func_array: function '$method' does not exist", E_ERROR); } else { switch (count($param_array)) { case 0: return $callback(); case 1: return $callback($param_array[0]); case 2: return $callback($param_array[0], $param_array[1]); case 3: return $callback($param_array[0], $param_array[1], $param_array[2]); case 4: return $callback($param_array[0], $param_array[1], $param_array[2], $param_array[3]); default: eval("return $callback($params);"); } } } function call_user_method_array($method, &$obj, $param_array=array()) { call_user_func_array(array(&$obj, $method), $param_array); } } #---------------------------------------------------------------- 4.0.4 --- #-- adds all values of given array into total sum if (!function_exists("array_sum")) { function array_sum($array) { $sum = 0; foreach ($array as $val) { $sum += $val; } return $sum; } } #-- value of constant (if their name was returned as string from somewhere) if (!function_exists("constant")) { function constant($name) { if (defined($name)) { eval("return $name"); } else { return NULL; } } } #-- more a language construct if (!function_exists("is_null")) { function is_null($var) { return($var === NULL); } } #---------------------------------------------------------------- 4.0.3 --- # register_tick_function # unregister_tick_function if (!function_exists("pathinfo")) { function pathinfo($fn) { preg_match("#^(?:(.+)/)?([^/]+?(?:\.([^/\.]+))?)$#", $fn, $uu); return array( "dirname" => $uu[1], "basename" => $uu[2], "extension" => $uu[3], ); } } if (!function_exists("escapeshellarg")) { function escapeshellarg($arg) { $arg = str_replace("'", "'\\''", $arg); return "'$arg'"; } } if (!function_exists("is_uploaded_file")) { function is_uploaded_file($fn) { ( $dir = get_cfg_var("upload_tmp_dir") ) or ( $dir = dirname(tempnam("", "")) ); return( realpath($dir) == realpath(dirname($fn)) ); } } if (!function_exists("move_uploaded_file")) { function move_uploaded_file($fn, $dest) { if (is_uploaded_file($fn)) { return copy($fn, $dest) && unlink($fn); } } } #---------------------------------------------------------------- 4.0.2 --- # ob_get_length if (!function_exists("strncasecmp")) { function strncasecmp($str1, $str2, $len=0) { if ($len > 0) { $str1 = substr($str1, 0, $len); |
︙ | ︙ | |||
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | $line = substr(0, $l); } } return($out); } } #---------------------------------------------------------------- 4.0.1 --- # levensth # fflush() - unimplementable # array_unique # array_diff # array_intersect # array_merge_recursive # crc32 # fscanf | > > > > > > > > > > > > > > > < > > > > | > > | > > > > > > > | 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | $line = substr(0, $l); } } return($out); } } if (!function_exists("php_uname")) { function php_uname($mode="a") { switch ($mode) { case "s": $p = "--kernel-name"; break; case "n": $p = "--node-name"; break; case "r": $p = "--release"; break; case "v": $p = "--kernel-version"; break; case "m": $p = "--machine"; break; default: $p = "--all"; break; } return `uname $p`; } } #---------------------------------------------------------------- 4.0.1 --- # levensth # fflush() - unimplementable # array_unique # array_diff # array_intersect # array_merge_recursive # crc32 # fscanf # sscanf # str_pad # set_file_buffer # spliti if (!function_exists("php_sapi_name")) { function php_sapi_name() { if (isset($_ENV["CGI_INTERFACE"])) { return "cgi"; } elseif (strpos($_ENV["SERVER_SOFTWARE"], "Apache") !== false) { return "apache"; } // ... else { return "cgi"; // the silly "cli" variation didn't exist before 4.2 } } } ?> |
Added ext/openssl.php.
> > > > > | 1 2 3 4 5 | <?php /* Ok, that's a joke. */ ?> |
Changes to upgrade.php.
1 2 3 4 5 | <?php /* This include() script adds missing PHP functions to earlier interpreter versions, so you can make downwards compatible scripts without having to stick to the least common denominator. It only defines the ones that | | < < | | | | < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | <?php /* This include() script adds missing PHP functions to earlier interpreter versions, so you can make downwards compatible scripts without having to stick to the least common denominator. It only defines the ones that are really missing; native functions will be used where available. - many of the emulation functions are one-liners - a few features have been added that never made it into one of the official versions (CVS code and the ever-absent "gzdecode" and "file_put_contents" for example) - a few very extravagant functions (array_u?diff*_u*assoc?) and other extensions have been separated out into ext/ - the advanced OO-capabilities and language syntax extensions of PHP5 and ZE2 cannot seriously be emulated here, this script only takes care of procedural interfaces - with only this part loaded, you get "PHP 4.1 COMPATIBILITY" - this is PuplicDomain (no copyright, no license, no warranty) so you can melt it into anything, regardless of your preferred license (you may strip this paragraph and turn it all into GPL, BSD, GNU LGPL, Artistic, MPL, PHP license, M$ EULA, or whatever you like best) Get update notes via "http://freshmeat.net/projects/upgradephp" or google for it. Any contribution is appreciated. <milky*users·sf·net> */ #------------------------------------------------------------------ CVS --- // most of this appeared in 5.0 // ... #------------------------------------------------------------------ 6.0 --- // following functions were never implemented in PHP |
︙ | ︙ | |||
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | else { return($data); } } } #------------------------------------------------------------------ 5.0 --- # set_exception_handler - unimpl. # restore_exception_handler - unimpl. # debug_print_backtrace - unimpl. # class_implements - unimplementable # proc_terminate - unimpl? # proc_get_status - unimpl. # -- # proc_nice # dns_get_record # date_sunrise - undoc. # date_sunset - undoc. #-- ci string search functions if (!function_exists("stripos")) { #-- find position of first occourence of a case-insensitive string function stripos($haystack, $needle, $offset=NULL) { return strpos(strtolower($haystack), strtolower($needle), $offset); } | > > > > > > > > > > > > > > > > > > > > > > > > > | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | else { return($data); } } } #-- output buffering functions swallow up any http header() if (!function_exists("ob_get_headers")) { function ob_get_headers() { return (array)NULL; } } #-- uh, ooops, now hopefully this doesn't screw scripts which # already implemented this themselves # (this implementation doesn't fix bogus numeric entities) if (!function_exists("xmlentities")) { function xmlentities($str) { return strtr($str, array( "&#"=>"&#", "&"=>"&", "'"=>"'", "<"=>"<", ">"=>">", "\""=>""", )); } } #------------------------------------------------------------------ 5.0 --- # set_exception_handler - unimpl. # restore_exception_handler - unimpl. # debug_print_backtrace - unimpl. # class_implements - unimplementable # proc_terminate - unimpl? # proc_get_status - unimpl. # -- # proc_nice # dns_get_record # date_sunrise - undoc. # date_sunset - undoc. #-- end of line if (!defined("PHP_EOL")) { define("PHP_EOL", ( (DIRECTORY_SEPARATOR == "\\") ?"\015\012" :(strncmp(PHP_OS,"D",1)?"\012":"\015") ) ); #" } #-- ci string search functions if (!function_exists("stripos")) { #-- find position of first occourence of a case-insensitive string function stripos($haystack, $needle, $offset=NULL) { return strpos(strtolower($haystack), strtolower($needle), $offset); } |
︙ | ︙ | |||
195 196 197 198 199 200 201 | if (!isset($port)) { $port = 80; } if ($f = fsockopen($host, $port, $errno, $errstr, $timeout=5)) { fwrite($f, "HEAD $path HTTP/1.1\015\012" . "Host: $host\015\012" . "Connection: close\015\012" | | | 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | if (!isset($port)) { $port = 80; } if ($f = fsockopen($host, $port, $errno, $errstr, $timeout=5)) { fwrite($f, "HEAD $path HTTP/1.1\015\012" . "Host: $host\015\012" . "Connection: close\015\012" . "Accept: */*\015\012" . "User-Agent: ".trim(ini_get("user_agent"))."\015\012" . "\015\012"); socket_set_blocking($f, true); $ls = array(); while (!feof($f)) { $line = trim(fgets($f, 1<<16)); if (!strlen($line)) { |
︙ | ︙ | |||
642 643 644 645 646 647 648 | } } } #-- more new constants for 5.0 if (!defined("E_STRICT")) { | | | 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 | } } } #-- more new constants for 5.0 if (!defined("E_STRICT")) { define("E_STRICT", 2048); // _STRICT is a special case of _NOTICE (_DEBUG) # PHP_CONFIG_FILE_SCAN_DIR # COUNT_NORMAL seems unused # COUNT_RECURSIVE } |
︙ | ︙ |