Check-in [d2cf77a801]
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | upgradephp-8 |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
d2cf77a80120a1179d7b089077bfb615 |
User & Date: | mario 2010-06-22 16:46:01 |
Context
2010-06-22
| ||
16:46 | upgradephp-9 check-in: 09785ab723 user: mario tags: trunk | |
16:46 | upgradephp-8 check-in: d2cf77a801 user: mario tags: trunk | |
16:25 | upgradephp-7 check-in: e22a019d41 user: mario tags: trunk | |
Changes
Changes to README.
︙ | ︙ | |||
205 206 207 208 209 210 211 | dtools/ ¯¯¯¯¯¯¯ Please run the "updoc" script once to update your PHP manual, if you are planning to use the upgrade.php script. Create a symlink from your | | | | > > > > > > > | | | | | > > | 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 | dtools/ ¯¯¯¯¯¯¯ Please run the "updoc" script once to update your PHP manual, if you are planning to use the upgrade.php script. Create a symlink from your 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: tests/ ¯¯¯¯¯¯ Contains stupidly short scripts, that have been used to compare behaviour of the original functions to that of the emulated ones. Use the "tests/_runparts" shell script (Linux) to get all tests run automatically. You must specify the names of two different PHP interpreter versions, whose output for each test will be shown side by side. If you don't have two, then simply give the name of your only PHP (-cgi) interpreter twice or simply use "false" or "cat" as the second argument. contrib/ ¯¯¯¯¯¯¯¯ Holds a few library scripts, which are believed to be of higher quality than any of the PEAR counterparts. Probably inappropriate to place it in this tarball, but they usefully take advantage of the 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 snippets distributed in this directory. License ¯¯¯¯¯¯¯ Everything in here is Public Domain. There are no restrictions on how or where you could use it. You may redistribute it under any license as you wish, and you don't need to tell anyone where you got it from. It has absolutely no impact on the rest of YOUR project; you are free to include it as if you had written it yourself. Author ¯¯¯¯¯¯ The current maintainer can be contacted under <milky*users·sf·net> Please drop me a line, if you found something important missing, or a really frustrating bug, and if you have feature wishes, or if you can name one of the functions that the php developers were too lazy to implement. |
Changes to contrib/http.php.
︙ | ︙ | |||
39 40 41 42 43 44 45 | var $url = ""; var $params = array(); // URL/form post vars, or single request body str var $headers = array(); var $cookies = array(); var $type = "url"; // content-type, abbrv. for x-www-form-... var $enc = false; // "gzip" or "deflate" var $error="", $io_err=0, $io_err_s=""; | | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | var $url = ""; var $params = array(); // URL/form post vars, or single request body str var $headers = array(); var $cookies = array(); var $type = "url"; // content-type, abbrv. for x-www-form-... var $enc = false; // "gzip" or "deflate" var $error="", $io_err=0, $io_err_s=""; var $active_client = 1; // enables redirect-following var $redirects = 3; var $proxy = false; // set to "http://host:NN/" var $timeout = 15; #-- constructor function http_request($method="GET", $url, $params=NULL) { |
︙ | ︙ |
Deleted dtools/VERDATA.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to dtools/ckavail.php.
1 2 3 4 5 6 7 | <?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). */ | | > | | > > | > > > > > > | 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 | <?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 if ($f = @fopen("ckavail.last", "r")) { $oldl = unserialize(fread($f, 1<<20)); fclose($f); } #-- current func list $curl = array(); $curl = get_defined_functions(); $curl["constants"] = get_defined_constants(); #-- save this one if ($f = fopen("ckavail.last", "w")) { fwrite($f, serialize($curl)); fclose($f); } #-- comparison of current / last run echo "old(".count($oldl["internal"])."), new(".count($curl["internal"]).")\n"; if ($oldl) { #-- funcs $new = array_diff($curl["internal"], $oldl["internal"]); echo "New functions added in PHP ". PHP_VERSION ." interpreter:\n"; print_r($new); #-- constants $new = array_diff(array_keys($curl["constants"]), array_keys($oldl["constants"])); echo "\nNewly added constants:\n"; print_r($new); } else { echo "Now start this script a 2nd time with the newer interpreter version.\n"; } ?> |
Deleted dtools/doctest.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted dtools/list.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to dtools/updoc.
︙ | ︙ | |||
72 73 74 75 76 77 78 | } } echo "$chng documentation files updated.\n"; } #-- add some special files | > > > > > > > > > > | | | | | | | | | | > | 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 | } } echo "$chng documentation files updated.\n"; } #-- add some special files $add_files = array( array( "func"=>"gzdecode", "data"=>"PGh0bWw+PGhlYWQ+PHRpdGxlPmd6ZGVjb2RlPC90aXRsZT48L2hlYWQ+Cjxib2R5Pgo8ZGl2IGFsaWduPSJjZW50ZXIiPnVwZ3JhZGUucGhwIGRvYzwvZGl2Pgo8dGFibGUgYm9yZGVyPSIwIiB3aWR0aD0iMTAwJSIgY2VsbHBhZGRpbmc9IjAiIGNlbGxzcGFjaW5nPSIwIj48dHI+CiAgPHRkIGFsaWduPSJsZWZ0Ij48YSBocmVmPSJmdW5jdGlvbi5nemRlZmxhdGUuaHRtbCI+YmFjazwvYT48L3RkPgogIDx0ZCBhbGlnbj0icmlnaHQiPjxhIGhyZWY9ImZ1bmN0aW9uLmd6ZW5jb2RlLmh0bWwiPm5leHQ8L2E+PC90ZD4KPC90cj48L3RhYmxlPgo8aHIgYWxpZ249IkxFRlQiIHdpZHRoPSIxMDAlIj4KCjxoMT5nemRlY29kZTwvaDE+Cgo8cD4oUEhQIDYsIEVNVSk8L3A+CgpnemRlY29kZSZuYnNwOy0tJm5ic3A7RGVjb2RlcyBhIGd6aXAgY29tcHJlc3NlZCBzdHJpbmc8L2Rpdj4KCjxoMj5EZXNjcmlwdGlvbjwvaDI+CgpzdHJpbmcgPGIgY2xhc3M9Im1ldGhvZG5hbWUiPmd6ZGVjb2RlPC9iPiAoIHN0cmluZyBkYXRhIFssIGludCBtYXhsZW5dKTxicj4KPGJyPgo8cD5UaGlzIGZ1bmN0aW9uIGRlY29kZXMgYSBzdHJpbmcgY29tcHJlc3NlZCBieSB0aGUgCjxhIGhyZWY9ImZpbGU6Ly8vdXNyL3NoYXJlL21hbi9tYW4xL2d6aXAuMS5neiI+Z3ppcCgxKTwvYT4gdXRpbGl0eSBvcgp0aGUgPGEgY2xhc3M9ImZ1bmN0aW9uIiBocmVmPSJmdW5jdGlvbi5nemVuY29kZS5odG1sIj5nemVuY29kZSgpPC9hPgpmdW5jdGlvbi4gVGhlIG9wdGlvbmFsIHBhcmFtZXRlciAnbWF4bGVuJyBsaW1pdHMgdGhlIGxlbmd0aCBvZiB0aGUgcmV0dXJuZWQKc3RyaW5nIC0gaWYgdGhlIGluZmxhdGlvbiBwcm9jZXNzIHJldHVybmVkIGEgYmlnZ2VyIHJlc3VsdCBpdCB3b3VsZCBiZSBkcm9wcGVkLgo8L3A+Cgo8cD5UaGUgZ3ppcCBmb3JtYXQgaW50ZXJuYWxseSB1c2VzIHRoZSBkZWZsYXRlIGFsZ29yaXRobSwgYW5kIGFkZHMgYSBmZXcKY2hlY2tzdW1zIGFuZCBvcHRpb25hbCBtZXRhIGRhdGEgZmllbGRzLiBJdCBpcyByZWd1bGFyaWx5IHVzZWQgYXMKY29udGVudC1jb2RpbmcgaW4gSFRUUCByZXF1ZXN0cyBhbmQgcmVzcG9uc2VzLiBTZWUKPGEgaHJlZj0iaHR0cDovL3d3dy5mYXFzLm9yZy9yZmNzL3JmYzE5NTIiPlJGQzE5NTI8L2E+IGZvciB0aGUgZm9ybWF0CmRlc2NyaXB0aW9uLjwvcD4KCjxwPgpTZWUgYWxzbyA8YSBocmVmPSJmdW5jdGlvbi5nemVuY29kZS5odG1sIj48YiBjbGFzcz0iZnVuY3Rpb24iPmd6ZW5jb2RlKCk8L2I+PC9hPgphbmQgPGEgaHJlZj0iZnVuY3Rpb24uZ3ppbmZsYXRlLmh0bWwiPjxiIGNsYXNzPSJmdW5jdGlvbiI+Z3ppbmZsYXRlKCk8L2I+PC9hPi4KPC9wPgoKPHA+Rm9yIGNvbXBhdGliaWxpdHkgd2l0aCBvbGRlciBQSFAgdmVyc2lvbnMgKGFuZCBmb3IgcGVvcGxlIHRoYXQgYXJlCnVud2lsbGluZyB0byBsb2FkICd1cGdyYWRlLnBocCcpLCB5b3UgY2FuIHVzZSBmb2xsb3dpbmcgKHVuY2xlYW4pCndvcmthcm91bmQgZm9yIGRlY29tcHJlc3NpbmcgZ3ppcGVkIGRhdGE6PGJyPgo8YnI+CjxiPkV4YW1wbGUgMTwvYj46PGJyPgo8YnI+Cjxjb2RlPgombmJzcDsgICRnemRhdGEgPSBnemVuY29kZSgiSSdtIGdldHRpbmcgY29tcHJlc3NlZC4uLiIpOzxicj4KPGJyPgombmJzcDsgICRzdHIgPSBmdW5jdGlvbl9leGlzdHMoImd6ZGVjb2RlIik8YnI+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")) { 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) { |
︙ | ︙ |
Changes to ext/array.php.
1 2 | <?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 | <?php /* Extended PHP array functions - _diff and _intersect() for associative arrays and/or with callback functions (for keys and/or values). These are too rarely used and exotic to be part of the core "upgrade.php" script. NOTHING IN HERE WAS SERIOUSLY TESTED. Please grab the definitions from "PEAR::PHP_Compat" if you want reliable and tested versions. */ #-- diff associative arrays with two user callbacks # (if this looks complicated to you, don't even try to look at the manual) if (!function_exists("array_udiff_uassoc")) { function array_udiff_uassoc() { $in = func_get_args(); $key_cb = array_pop($in); $val_cb = array_pop($in); $arr1 = array_shift($in); $r = array(); foreach ($arr1 as $i=>$v) { #-- in each array, compare against each key/value pair foreach (array_keys($in) as $c) { foreach ($in[$c] as $i2=>$v2) { $key_cmp = call_user_func_array($key_cb, array($i, $i2)); if ($key_cmp == 0) { #-- ok, in this case we must compare the data as well $val_cmp = call_user_func_array($val_cb, array($v, $v2)); if ($val_cmp == 0) { continue 3; } } } } #-- this combination isn't really found anywhere else $r[$i] = $v; } return($r); } } #-- same, but that keys now are compared normally (without callback) if (!function_exists("array_udiff_assoc")) { function array_udiff_assoc() { $in = func_get_args(); $val_cb = array_pop($in); $arr1 = array_shift($in); $r = array(); #-- compare against each key/value pair in other arrays foreach ($arr1 as $i=>$v) { foreach (array_keys($in) as $c) { if (isset($in[$c][$i])) { #-- now compare data by callback $cmp = call_user_func_array($val_cb, array($v, $in[$c][$i])); if ($cmp == 0) { continue 2; } } } #-- everything exists only in array1 $r[$i] = $v; } return($r); } } #-- .... if (!function_exists("array_diff_uassoc")) { function array_diff_uassoc() { $in = func_get_args(); $key_cb = array_pop($in); $arr1 = array_shift($in); $num = count($in); $r = array(); foreach ($arr1 as $i=>$v) { #-- in other arrays? for ($c=0; $c<$num; $c++) { foreach ($in[$c] as $i2=>$v2) { if ($v == $v2) { $cmp = call_user_func_array($key_cb, array($i, $i2)); if ($cmp == 0) { continue 3; } } } } #-- exists only in array1 $r[$i] = $v; } return($r); } } #-- diff array, keys ignored, callback for comparing values if (!function_exists("array_udiff")) { function array_udiff() { $in = func_get_args(); $val_cb = array_pop($in); $arr1 = array_shift($in); $num = count($in); $r = array(); foreach ($arr1 as $i=>$v) { #-- check other arrays for ($c=0; $c<$num; $c++) { foreach ($in[$c] as $v2) { $cmp = call_user_func_array($val_cb, array($v, $v2)); if ($cmp == 0) { continue 3; } } } #-- exists only in array1 $r[$i] = $v; } return($r); } } #-- same for intersections if (!function_exists("array_uintersect_uassoc")) { function array_uintersect_uassoc() { $in = func_get_args(); $key_cb = array_pop($in); $val_cb = array_pop($in); $all = array(); $conc = count($in); foreach ($in[0] as $i=>$v) { #-- must exist in each array (at least once, callbacks may match fuzzy) for ($c=1; $c<$conc; $c++) { $ok = false; foreach ($in[$c] as $i2=>$v2) { $key_cmp = call_user_func_array($key_cb, array($i, $i2)); $val_cmp = call_user_func_array($val_cb, array($v, $v2)); if (($key_cmp == 0) && ($val_cmp == 0)) { $ok = true; break; } } if (!$ok) { continue 2; } } #-- exists in all arrays $all[$i] = $v; } return($all); } } #-- intersection again if (!function_exists("array_uintersect_assoc")) { function array_uintersect_assoc() { $in = func_get_args(); $val_cb = array_pop($in); |
︙ | ︙ | |||
119 120 121 122 123 124 125 | } return($all); } } | < < < < < < < < < < < < < < < < < < < < < < < < | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | } return($all); } } #-- array intersection, no keys compared, but callback for values if (!function_exists("array_uintersect")) { function array_uintersect() { $rest = func_get_args(); $val_cb = array_pop($rest); |
︙ | ︙ | |||
172 173 174 175 176 177 178 | } } return($all); } } | < < < < < < < < < < < < < < < < < < < < < < < < | 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | } } return($all); } } #-- diff array, keys ignored, callback for comparing values if (!function_exists("array_intersect_uassoc")) { function array_intersect_uassoc() { $args = func_get_args(); $key_cb = array_pop($args); |
︙ | ︙ |
Added ext/ctype.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 | <?php /* These functions emulate the "character type" extension, which is present in PHP first since version 4.3 per default. In this variant only ASCII and Latin-1 characters are being handled. The first part is eventually faster. */ #-- regex variants if (!function_exists("ctype_alnum")) { function ctype_alnum($text) { return preg_match("/^[A-Za-z\d\300-\377]+$/", $text); } function ctype_alpha($text) { return preg_match("/^[a-zA-Z\300-\377]+$/", $text); } function ctype_digit($text) { return preg_match("/^\d+$/", $text); } function ctype_xdigit($text) { return preg_match("/^[a-fA-F0-9]+$/", $text); } function ctype_cntrl($text) { return preg_match("/^[\000-\037]+$/", $text); } function ctype_space($text) { return preg_match("/^\s+$/", $text); } function ctype_upper($text) { return preg_match("/^[A-Z\300-\337]+$/", $text); } function ctype_lower($text) { return preg_match("/^[a-z\340-\377]+$/", $text); } function ctype_graph($text) { return preg_match("/^[\041-\176\241-\377]+$/", $text); } function ctype_punct($text) { return preg_match("/^[^0-9A-Za-z\000-\040\177-\240\300-\377]+$/", $text); } function ctype_print($text) { return ctype_punct($text) && ctype_graph($text); } } #-- simple char-by-char comparisions if (!function_exists("ctype_alnum")) { #-- true if string is made of letters and digits only function ctype_alnum($text) { $r = true; for ($i=0; $i<strlen($text); $i++) { $c = ord($text{$i}); $r = $r and ( ($c>=65) && ($c<=90) // A-Z or ($c>=97) && ($c<=122) // a-z or ($c>=48) && ($c<=59) // 0-9 or ($c>=192) // Latin-1 letters ); } return($r); } #-- only letters in given string function ctype_alpha($text) { $r = true; for ($i=0; $i<strlen($text); $i++) { $c = ord($text{$i}); $r = $r and ( ($c>=65) && ($c<=90) // A-Z or ($c>=97) && ($c<=122) // a-z or ($c>=192) // Latin-1 letters ); } return($r); } #-- only numbers in string function ctype_digit($text) { $r = true; for ($i=0; $i<strlen($text); $i++) { $c = ord($text{$i}); $r = $r and ($c>=48) && ($c<=59); // 0-9 } return($r); } #-- hexadecimal numbers only function ctype_xdigit($text) { $r = true; for ($i=0; $i<strlen($text); $i++) { $c = ord($text{$i}); $r = $r and ( ($c>=48) && ($c<=59) // 0-9 or ($c>=65) && ($c<=70) // A-F or ($c>=97) && ($c<=102) // a-f ); } return($r); } #-- hexadecimal numbers only function ctype_cntrl($text) { $r = true; for ($i=0; $i<strlen($text); $i++) { $c = ord($text{$i}); $r = $r and ($c < 32); } return($r); } #-- hexadecimal numbers only function ctype_space($text) { $r = true; for ($i=0; $i<strlen($text); $i++) { $c = $text{$i}; $r = $r and ( ($c == " ") or ($c == "\240") or ($c == "\n") or ($c == "\r") or ($c == "\t") or ($c == "\f") ); } return($r); } #-- all-uppercase function ctype_upper($text) { $r = true; for ($i=0; $i<strlen($text); $i++) { $c = ord($text{$i}); $r = $r and ( ($c>=65) && ($c<=90) // A-Z or ($c>=192) && ($c<=223) // Latin-1 letters ); } return($r); } #-- all-lowercase function ctype_lower($text) { $r = true; for ($i=0; $i<strlen($text); $i++) { $c = ord($text{$i}); $r = $r and ( ($c>=97) && ($c<=122) // a-z or ($c>=224) && ($c<=255) // Latin-1 letters ); } return($r); } #-- everything except spaces that produces a valid printable output # (this probably excludes contral chars as well) function ctype_graph($text) { $r = true; for ($i=0; $i<strlen($text); $i++) { $c = ord($text{$i}); $r = $r and ($c>=33) and ($c!=160) and (($c<=126) or ($c>=161)); } return($r); } #-- everything printable, but no spaces+letters+digits function ctype_punct($text) { $r = true; for ($i=0; $i<strlen($text); $i++) { $c = ord($text{$i}); $r = $r and ( ($c>=33) && ($c<=47) // !../ or ($c>=58) && ($c<=64) // :..@ or ($c>=91) && ($c<=96) // [..` or ($c>=123) && ($c<=126) // {..~ or ($c>=161) && ($c<=191) // Latin-1 everything else ); } return($r); } // - no idea what this means exactly // // function ctype_print($text) { // } } ?> |
Added ext/fakezlib.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 | <?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 any 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) { $mode = preg_replace('/[^carwb+]/', '', $mode); return(fopen($fp, $mode)); } function gzread($fp, $len) { return(fread($fp, $len)); } function gzwrite($fp, $string) { return(fwrite($fp, $string)); } function gzputs($fp, $string) { return(fputs($fp, $string)); } function gzclose($fp) { return(fclose($fp)); } function gzeof($fp) { return(feof($fp)); } function gzseek($fp, $offs) { return(fseek($fp, $offs, SEEK_SET)); } function gzrewind($fp) { return(frewind($fp)); } function gztell($fp) { return(ftell($fp)); } function gzpassthru($fp) { while (!gzeof($fp)) { print(gzred($fp, 1<<20)); } gzclose($fp); } function readgzfile($fn) { if ($fp = gzopen($fn, "rb")) { gzpassthru($fp); } } function gzfile($fn) { return(file($fn)); } function gzgetc($fp) { return(fgetc($fp)); } function gzgets($fp, $len) { return(fgets($fp, $len)); } function gzgetss($fp, $len, $allowedtags="") { return(fgetss($fp, $len, $allowedtags)); } } #-- fake compression methods if (!function_exists("gzdeflate")) { // only returns uncompressed deflate streams function gzdeflate($data, $level=0) { $gz = ""; $end = strlen($data); $p = 0; do { $c = $end - $pos; if ($c >= 65536) { $c = 0xFFFF; $end = 0x00; } else { $end = 0x01; } $gz .= pack("Cvv", ($end << 7) + (00 << 5), // LAST=0/1, BTYPE=00 $c, // LEN $c ^ 0xFFFF // NLEN ); $gz .= substr($data, $p, $c); $p += $c; } while ($p < $end); return($gz); } // only can strip deflate headers, cannot decompress function gzinflate($data, $length=NULL) { $end = strlen($data); $gz = ""; if (isset($length) && (($max*0.99) > $length)) { trigger_error("gzinflate(): gave up, decompressed string is likely longer than requested", E_USER_ERROR); return; } $out = ""; $p = 0; do { $head = ord($data[$p]); $last = ($head >> 7); if (($head & 0x60) != 00) { trigger_error("gzinflate(): cannot decode compressed stream", E_USER_ERROR); return; } $head = unpack("v1LEN/v1NLEN", substr($data, $p+1, 4)); $c = $head["LEN"]; if (($c ^ 0xFFFF) != $head["NLEN"]) { trigger_error("gzinflate(): data error in stream", E_USER_ERROR); return; } $p += 5; $out .= substr($data, $p, $c); $p += $c; } while (($p < $end) && !$last); return($out); } // function gzcompress() { // } // function gzuncompress() { // } // without real compression support again function gzencode($data, $level=0) { $isize = strlen($data); $crc32 = crc32($data); $gz = ""; { $gz .= pack("nCCVCC", $_ID = 0x1f8b, $_CM = 0x08, // deflate fmt $_FLG = 0x00, // nothing extra $_MTIME = time(), $_XFL = 0x00, // no bonus flags $_OS = 255 // "unknown" ); $gz .= gzdeflate($data); $gz .= pack("VV", $crc32, $isize); } return($gz); } } ?> |
Deleted ext/math41.php.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to ext/mime.php.
︙ | ︙ | |||
17 18 19 20 21 22 23 | #-- fallback $type = false; #-- read in first 3K of given file if (is_dir($fn)) { return("httpd/unix-directory"); } | | > > > | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #-- fallback $type = false; #-- read in first 3K of given file if (is_dir($fn)) { return("httpd/unix-directory"); } elseif (is_resource($fn) || ($fn = @fopen($fn, "rb"))) { $bin = fread($fn, $maxlen=3072); fclose($fn); } elseif (!file_exists($fn)) { return false; } else { return("application/octet-stream"); // give up } #-- use PECL::fileinfo when available if (function_exists("finfo_buffer")) { |
︙ | ︙ | |||
53 54 55 56 57 58 59 | fclose($f); $fd = str_replace(" ", "\t", $fd); #-- look at each entry foreach (explode("\n", $fd) as $line) { #-- skip empty lines | | | | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | fclose($f); $fd = str_replace(" ", "\t", $fd); #-- look at each entry foreach (explode("\n", $fd) as $line) { #-- skip empty lines if (!strlen($line) or ($line[0] == "#") or ($line[0] == "\n")) { continue; } #-- break into four fields at tabs $l = preg_split("/\t+/", $line); @list($pos, $typestr, $magic, $ct) = $l; #print_r($l); #-- ignore >continuing lines if ($pos[0] == ">") { continue; } #-- real mime type string? |
︙ | ︙ | |||
108 109 110 111 112 113 114 | if ((ord($magic[0]) < 48) or (ord($magic[0]) > 57)) { #echo "\nmagicnumspec=$line\n"; #var_dump($l); continue; #-- skip specials like >, x, <, ^, & } #-- convert string representation into int | | | 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | if ((ord($magic[0]) < 48) or (ord($magic[0]) > 57)) { #echo "\nmagicnumspec=$line\n"; #var_dump($l); continue; #-- skip specials like >, x, <, ^, & } #-- convert string representation into int if ((strlen($magic) >= 4) && ($magic[1] == "x")) { $magic = hexdec(substr($magic, 2)); } elseif ($magic[0]) { $magic = octdec($magic); } else { $magic = (int) $magic; |
︙ | ︙ |
Changes to ext/old.php.
1 2 3 4 5 6 7 8 9 10 11 12 | <?php /* This script will eventually collect PHP functions for versions before 4.1, but as the 4.0.x versions can't be made compatible with newer versions anyhow (new superglobals are missing) this part is currently empty. Have a look at PEAR::PHP_Compat for emulation of some of these (it's not complete in this regard, too). */ #---------------------------------------------------------------- 4.0.6 --- | > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > | | > > > > > > > > > | > > > > > > > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | <?php /* This script will eventually collect PHP functions for versions before 4.1, but as the 4.0.x versions can't be made compatible with newer versions anyhow (new superglobals are missing) this part is currently empty. 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 # you still had to put "global $_REQUEST,$_GET,..." into any function that # used them - so this workaround is not all too useful anyhow, you should # not accept PHP versions prior 4.0.7 for your scripts in any case! if (!isset($GLOBALS["_REQUEST"])) { $GLOBALS["_GET"] = & $HTTP_GET_VARS; $GLOBALS["_POST"] = & $HTTP_POST_VARS; $GLOBALS["_SERVER"] = & $HTTP_SERVER_VARS; $GLOBALS["_ENV"] = & $HTTP_ENV_VARS; $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 --- # fopenstream # is_callable # key_exists #-- 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))) { unset($array[$key]); } } return($array); } } #-- uses callback function to change array values, multiple input arrays if (!function_exists("array_map")) { function array_map() { $arrays = get_func_args(); $callback = shift($arrays); $r = &$arrays[0]; foreach ($r as $key=>$val) { $val = call_user_func_array($callback, $arrays); $r[$key] = $val; } return($r); } } #---------------------------------------------------------------- 4.0.5 --- # localeconv - unimpl. # call_user_method_array # chroot # is_scalar # strcoll #-- 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) { if ($strict&&($v===$value) || !$strict&&($v==$value)) { return($key); } } return(NULL); // PHP prior 4.2 also did so } } #-- recursively collapse array into one value (via user callback) if (!function_exists("array_reduce")) { function array_reduce($array, $callback, $value=NULL) { foreach ($array as $v) { if (is_array($v)) { $v = array_reduce($v, $callback); } else { $v = call_user_func_array($callback, array($value, $v)); } $value = $v; } return($value); } } #---------------------------------------------------------------- 4.0.4 --- # call_user_func_array # constant # is_null #-- 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; } } #---------------------------------------------------------------- 4.0.3 --- # is_uplo # move_uploaded_file # escapeshellarg # pathinfo # register_tick_function # unregister_tick_function #---------------------------------------------------------------- 4.0.2 --- # ob_get_length # php_uname if (!function_exists("strncasecmp")) { function strncasecmp($str1, $str2, $len=0) { if ($len > 0) { $str1 = substr($str1, 0, $len); $str2 = substr($str2, 0, $len); } return strcasecmp($str1, $str2); } } if (!function_exists("wordwrap")) { function wordwrap($text, $width=75, $break="\n", $hardcut=0) { $out = ""; foreach (explode("\n", $text) as $line) { if ($out) { $out .= "\n"; } while (strlen($line)) { if ($hardcut) { $l = $width; } else { $l = strrpos(substr($text, 0, $width), " "); if ($l && ($l < strlen($line))) { $l = strlen($line); } if ($l === false) { $l = $width; } } $out .= substr($line, 0, $l); $out .= "\n"; $line = substr(0, $l); } } return($out); } } #---------------------------------------------------------------- 4.0.1 --- # levensth # fflush() - unimplementable # array_unique # array_diff # array_intersect # array_merge_recursive # crc32 # fscanf # php_sapi_name # sscanf # str_pad # set_file_buffer # spliti ?> |
Changes to ext/spl.php.
1 2 3 4 5 6 7 8 9 10 | <?php /* Emulates a bit of PHP5 convinience for PHP4 interpreter versions. Of course no Interfaces are there, but most stuff can be done with plain class definitions anyhow. There is a collection of spl class defines in the PHP source distributions ext/spl/internal/ dir to eventually get used together with this part (not included here because of its PHP license). THIS IS NOT TESTED FOR CORRECTNESS, because very few people have any | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <?php /* Emulates a bit of PHP5 convinience for PHP4 interpreter versions. Of course no Interfaces are there, but most stuff can be done with plain class definitions anyhow. There is a collection of spl class defines in the PHP source distributions ext/spl/internal/ dir to eventually get used together with this part (not included here because of its PHP license). THIS IS NOT TESTED FOR CORRECTNESS, because very few people have any interest in using this anyhow (so me). Moreover this part is ALMOST ABANDONED as I have more important projects to waste time on. */ #-- be funny class WikiWord { } #-- general class here |
︙ | ︙ |
Changes to tests/_runparts.
1 2 3 4 5 6 | #!/bin/bash #-- params if [ -z "$1" ] then echo "syntax: _runparts [php412] [php501] | more" | | | > > | | | 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 | #!/bin/bash #-- params if [ -z "$1" ] then echo "syntax: _runparts [php412] [php501] | more" echo "Runs all PHP scripts in the tests/ directory with two interpreter versions" echo "side by side, for comparison. If you don't have two of them installed, you" echo "could simply specify 'cat' or 'false' as the second argument." else #-- go cd `dirname $0` OLD=$1 NEW=$2 [ -z "$NEW" ] && NEW="cat" for SCRIPT in * do $OLD $SCRIPT | tr -d "\r" | fmt -w 36 -s > /tmp/1 $NEW $SCRIPT | tr -d "\r" | fmt -w 36 -s > /tmp/2 echo "-----------------------------------------------------------------" echo "[32m$SCRIPT[37m" echo "-----------------------------------------------------------------" pr -m --columns=2 -t /tmp/1 /tmp/2 echo "--" done fi |
Added tests/array_udiff_uassoc.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | <?php include("../ext/array.php"); #-- from manual -- class cr { var $priv_member; function cr($val) { $this->priv_member = $val; } } function comp_func_cr($a, $b) { if ($a->priv_member === $b->priv_member) return 0; return ($a->priv_member > $b->priv_member)? 1:-1; } function comp_func_key($a, $b) { if ($a === $b) return 0; return ($a > $b)? 1:-1; } $a = array( "0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15), ); $b = array( "0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1=> new cr(4), 2 => new cr(-15), ); $result = array_udiff_uassoc($a, $b, "comp_func_cr", "comp_func_key"); $expected = array ( '0.1' => new cr(9), '0.5' => new cr(12), 0 => new cr(23), ); print_r($result); if ($result == $expected) { echo "\n--> works correctly\n"; } ?> |
Changes to tests/class_parents.
1 2 3 4 | <?php include("../upgrade.php"); | < > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <?php include("../upgrade.php"); class a {} class x extends a {} class y extends x {} class z extends a {} class eve extends y {} $y = new y; $r = class_parents($y); print_r($r); ?> |
Changes to upgrade.php.
︙ | ︙ | |||
12 13 14 15 16 17 18 | - many things are still missing, and external add-ons are provided to mimic certain other PHP core extension modules - a few very extravagant functions (array_u?diff*_u*assoc?) have been separated out into ext/ - the extended OO-capabilities and language syntax extensions of PHP5 and ZE2 cannot seriously be emulated here, this script only takes care of procedural interfaces | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | - many things are still missing, and external add-ons are provided to mimic certain other PHP core extension modules - a few very extravagant functions (array_u?diff*_u*assoc?) have been separated out into ext/ - the extended OO-capabilities and language syntax extensions of PHP5 and ZE2 cannot seriously be emulated here, this script only takes care of procedural interfaces - this script itself has PHP 4.1 as minimum version requirement (mostly) - 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> |
︙ | ︙ | |||
41 42 43 44 45 46 47 | // following functions aren't present everywhere (regardless of version) // ... (should probably go into ext/ then?) #------------------------------------------------------------------ 6.0 --- | | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | // following functions aren't present everywhere (regardless of version) // ... (should probably go into ext/ then?) #------------------------------------------------------------------ 6.0 --- // following functions were never implemented in PHP #-- inflates a string enriched with gzip headers # (this is the logical counterpart to gzencode(), but don't tell anyone!) if (!function_exists("gzdecode")) { function gzdecode($data, $maxlen=NULL) { |
︙ | ︙ | |||
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" | | | | | 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | 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: text/html, application/xml;q=0.8, text/xml;q=0.75, application/xhtml+xml, text/plain;q=0.5, */*;q=0.01\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])) { |
︙ | ︙ | |||
449 450 451 452 453 454 455 456 457 458 459 460 461 462 | } } #-- calls PHP interpreter itself (really only works with 4.3 onwards) 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; } | > > > | 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | } } #-- calls PHP interpreter itself (really only works with 4.3 onwards) if (!function_exists("php_strip_whitespace")) { function php_strip_whitespace($fn) { // alternatives would be using te tokenizer or // some regexs to strip unwanted content parts // (PEAR::PHP_Compat blindly calls the tokenizer) $fn = escapeshellcmd($fn); $text = `php -wqCf '$fn'`; if (!$text) { $text = implode("", file($fn)); } return $text; } |
︙ | ︙ | |||
551 552 553 554 555 556 557 | #-- do return(strncmp($haystack, $needle, $len)); } } | | > | 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | #-- do return(strncmp($haystack, $needle, $len)); } } #-- stub, returns empty list as usual; # you must load "ext/spl.php" beforehand to get this if (!function_exists("spl_classes")) { function spl_classes() { trigger_error("spl_classes(): not built into this PHP version"); return (array)NULL; } } |
︙ | ︙ | |||
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 | } } #-- more new constants for 5.0 if (!defined("E_STRICT")) { define("E_STRICT", 2048|E_NOTICE); // _STRICT is a special case of _DEBUG } #------------------------------------------------------------------ 4.3 --- # money_format - unimpl? # sha1, sha1_file - too much code to pack it into here; and this # has already been implemented elsewhere, btw | > > > < | > > > > > > > > > > > | | | 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 | } } #-- more new constants for 5.0 if (!defined("E_STRICT")) { define("E_STRICT", 2048|E_NOTICE); // _STRICT is a special case of _DEBUG # PHP_CONFIG_FILE_SCAN_DIR # COUNT_NORMAL seems unused # COUNT_RECURSIVE } #------------------------------------------------------------------ 4.3 --- # money_format - unimpl? # sha1, sha1_file - too much code to pack it into here; and this # has already been implemented elsewhere, btw #-- simplified file read-at-once function 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); # max 2MB fclose($f); return($content); } } } #-- shell-like filename matching if (!function_exists("fnmatch")) { define("FNM_PATHNAME", 1<<0); // no wildcard ever matches a "/" define("FNM_NOESCAPE", 1<<1); // backslash can't escape meta chars define("FNM_PERIOD", 1<<2); // leading dot must be given explicit define("FNM_LEADING_DIR", 1<<3); // not in PHP define("FNM_CASEFOLD", 0x50); // match case-insensitive define("FNM_EXTMATCH", 1<<5); // not in PHP 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)); } } |
︙ | ︙ | |||
906 907 908 909 910 911 912 913 914 915 916 917 918 919 | } } #-- constants for 4.3 if (!defined("PATH_SEPARATOR")) { define("PATH_SEPARATOR", ((DIRECTORY_SEPARATOR=='\\') ?';' :':')); } #------------------------------------------------------------------ 4.2 --- # almost complete!? | > > > > > > > | 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 | } } #-- constants for 4.3 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/"))); } #------------------------------------------------------------------ 4.2 --- # almost complete!? |
︙ | ︙ | |||
1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 | else { print($output); } } } #------------------------------------------------------------------ 4.1 --- # nl_langinfo - unimpl? # getmygid | > > > > > > > > | 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 | else { print($output); } } } #-- strcmp() variant that respects locale setting, # existed since PHP 4.0.5, but under Win32 first since 4.3.2 if (!function_exists("strcoll")) { function strcoll($str1, $str2) { return strcmp($str1, $str2); } } #------------------------------------------------------------------ 4.1 --- # nl_langinfo - unimpl? # getmygid |
︙ | ︙ | |||
1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 | } } } // done } } #-- pre-4.1 -- end // no need to implement anything below that, because such old versions // will be incompatbile anyhow (- none of the newer superglobals known), // but see also "ext/old" ?> | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 | } } } // done } } // a few mathematical functions follow // (wether we should really emulate them is a different question) #-- me has no idea what this function means if (!function_exists("hypot")) { function hypot($num1, $num2) { return sqrt($num1*$num1 + $num2*$num2); // as per PHP manual ;) } } #-- more accurate logarithm func, but we cannot simulate it # (too much work, too slow in PHP) if (!function_exists("log1p")) { function log1p($x) { return( log(1+$x) ); } #-- same story for: function expm1($x) { return( exp($x)-1 ); } } #-- as per PHP manual 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) ); // ok, that one makes sense again :) } } #-- these look a bit more complicated 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 ); } } #-- other stuff /* removed funcs?? [18] => leak */ #-- pre-4.1 -- end // no need to implement anything below that, because such old versions // will be incompatbile anyhow (- none of the newer superglobals known), // but see also "ext/old" ?> |