PHP userland backwards compatibility layer that emulates PHP 5.5+ core functions.

⌈⌋ branch:  upgrade.php


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:8c7499012759ad73a4b09168e154e33dba5de56a
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
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
..
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
..
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
..
89
90
91
92
93
94
95


96
97
98
99
100
101
102
...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
...
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
...
212
213
214
215
216
217
218

219
220

221
222
223
224
225
226
227
...
247
248
249
250
251
252
253

254
255
256
257
258
259
260
261

262
263
264
265
266
267
268

PHP downwards compatibility functions

Because web hosters often run outdated PHP interpreter versions,
there are regularily functions missing, what prevents certains
scripts from running (if those were written with later interpeter
versions in mind). Sourceforge.net makes a good example. The
library presented here emulates some of those functions, if it
detects that they are 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 from now on.

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 also simply stubs
without function body or real logic; merely to provide the standard
function name (some of them simply issue a warning, that replaces
the E_FATAL for the undefined function name). 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
................................................................................
      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.2.0/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
................................................................................
      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).



core

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
................................................................................

  <?example
     if (PHP_VERSION < "4.3.0") { require(".../upgrade.php"); }
  ?>

Currently following functions can be emulated:
 gzdecode


 stripos
 strripos
 str_ireplace
 get_headers
 headers_list
 fprintf
 vfprintf
................................................................................
 substr_compare
 spl_classes
 class_parents
 session_commit
 dns_check_record
 dns_get_mx
 setrawcookie
 file_get_contents
 file_put_contents
 fnmatch
 glob
 array_key_exists
 array_intersect_assoc
 array_diff_assoc
 html_entity_decode
 str_word_count
................................................................................
 str_rot13
 array_change_key_case
 array_fill
 array_chunk
 md5_file
 is_a
 fmod






 diskfreespace
 disktotalspace
 vprintf
 vsprintf










 array_udiff_uassoc
 array_uintersect_uassoc
 array_udiff_assoc
 array_uintersect_assoc
 array_udiff
 array_uintersect

 array_diff_uassoc
 array_intersect_uassoc
 mime_content_type
























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.



















ext/

The ext/ subdirectory in here provides a few more or less useful
PHP-ext-module emulation functions.

 "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/math41" defines a few rarely used mathematical functions that

  were introduced by PHP 4.1 - and because we have that as minimum
  requirement anyhow, these functions didn't go into the core script.




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
................................................................................
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:



................................................................................
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




|
|
|
|
|






|













|
|
|
|
|
|
|







 







|







 







|
|







 







>
>







 







|
|







 







>
>
>
>
>
>




>
>
>
>
>
>
>
>
>
>

<

|

|
>
|


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>











>
>


>
>
>
>
>
>
>
>
>
>
>
>
>
>




|



>



>



>



>




<
>
|
|
>
>
>







 







>


>







 







>








>







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
..
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
..
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
..
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
...
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
...
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
...
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
...
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336

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
................................................................................
      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
................................................................................
      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
................................................................................

  <?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
................................................................................
 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_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
................................................................................
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:



................................................................................
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.

cannot compute difference between binary files

Changes to dtools/ckavail.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
<?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";
}


















?>






>


|



>


<
|
|


|
|


>
>
|
>

<
>



|
|



|



>
>
>
>
>






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

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
8
9
10
11
12
13
14
15
16
17
18
19
..
29
30
31
32
33
34
35




36
37
38
39
40
41
42
..
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
#!/usr/local/bin/php -qC
<?php
/*
   Adds hints about emulation functions to your local PHP documentation.
*/

#-- help
if ($_SERVER["argc"] != 3) {

   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-
................................................................................
#-- 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");
   }
   
................................................................................
         "data"=>"PGh0bWw+PGhlYWQ+PHRpdGxlPmd6ZGVjb2RlPC90aXRsZT48L2hlYWQ+Cjxib2R5Pgo8ZGl2IGFsaWduPSJjZW50ZXIiPnVwZ3JhZGUucGhwIGRvYzwvZGl2Pgo8dGFibGUgYm9yZGVyPSIwIiB3aWR0aD0iMTAwJSIgY2VsbHBhZGRpbmc9IjAiIGN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GEpPGJyPgombmJzcDsgJm5ic3A7ICZuYnNwOyAgOiBnemluZmxhdGUoc3Vic3RyKCRnemRhdGEsIDEwLCAtOCkpOzxicj4KPGJyPgo8L2NvZGU+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) {
   if (!is_array($list)) {
      $list = array($list);
   }
   foreach ($list as $fn) {

      $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);
   }
}

?>







|



|







 







>
>
>
>







 







|
>







|







 







>











1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
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
#!/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-
................................................................................
#-- 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");
   }
   
................................................................................
         "data"=>"PGh0bWw+PGhlYWQ+PHRpdGxlPmd6ZGVjb2RlPC90aXRsZT48L2hlYWQ+Cjxib2R5Pgo8ZGl2IGFsaWduPSJjZW50ZXIiPnVwZ3JhZGUucGhwIGRvYzwvZGl2Pgo8dGFibGUgYm9yZGVyPSIwIiB3aWR0aD0iMTAwJSIgY2VsbHBhZGRpbmc9IjAiIGNlbGxzcGFjaW5nPSIwIj48dHI+CiAgPHRkIGFsaWduPSJsZWZ0Ij48YSBocmVmPSJmdW5jdGlvbi5nemRlZmxhdGUuaHRtbCI+YmFjazwvYT48L3RkPgogIDx0ZCBhbGlnbj0icmlnaHQiPjxhIGhyZWY9ImZ1bmN0a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CUiIGNlbGxwYWRkaW5nPSIwIiBjZWxsc3BhY2luZz0iMCI+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
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
   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) {







|
|







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
...
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
<?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) {

................................................................................

#-- 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_BMP", 6);  // post-4.3 only ...



   define("IMAGETYPE_JP2", 10);




   define("IMAGETYPE_WBMP", 15);
   define("IMAGETYPE_XBM", 16);






   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",















      );
      if (isset($mime[$id])) {
         $m = $mime[$id];
         strpos($m, "/") || ($m = "image/$m");
      }
      else {
         $m = "image/unknown";
      }
      return($m);
   }
}
























#-- we need this then, too
if (!function_exists("exif_imagetype")) {
   function exif_imagetype($fn) {
      $magic = array(
         "\211PNG" => IMAGETYPE_PNG,
         "JFIF" => IMAGETYPE_JPEG,
         "GIF8" => IMAGETYPE_GIF,

         "FWS" => IMAGETYPE_SWF,











      );
      if ($f = fopen($fn, "rb")) {
         $bin = fread($f, 32);
         fclose($f);
         foreach ($magic as $scn=>$id) {
            if (strpos($bin, $scn) !== false) {

               return $id;
            }
         }
      }
   }
}

?>







>







 







>
|
>
>
>

>
>
>
>


>
>
>
>
>
>










>
>
>
>
>
>
>
>
>
>
>
>
>
>
>











>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






|
|
>

>
>
>
>
>
>
>
>
>
>
>


|


<
>








1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
...
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
<?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) {

................................................................................

#-- 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
3
4
5
6
7
8
9
10
11
12
13
..
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
...
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
...
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
...
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
<?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
................................................................................
   $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
# 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))) {
................................................................................
   }
}




#---------------------------------------------------------------- 4.0.5 ---
# localeconv - unimpl.
# call_user_method_array
# chroot
# 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) {
................................................................................
#-- checks variable to be of a simple type
if (!function_exists("is_scalar")) {
   function is_scalar($var) {
      return( !is_array($var) && !is_object($var) );
   }
}












































































#---------------------------------------------------------------- 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);
................................................................................
            $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
















?>


|
|
|
|







 







<
<







 







<
<

<







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

<
<
<







 







>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

<
<
<
<



>
>
>
>
>
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


<







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>










<





>
>
>
>
|
>
>
|
>
>
>
>
>
>
>

1
2
3
4
5
6
7
8
9
10
11
12
13
..
22
23
24
25
26
27
28


29
30
31
32
33
34
35
...
110
111
112
113
114
115
116


117

118
119
120
121
122
123
124
...
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
...
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
<?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
................................................................................
   $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))) {
................................................................................
   }
}




#---------------------------------------------------------------- 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) {
................................................................................
#-- 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);
................................................................................
            $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
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
...
116
117
118
119
120
121
122




















123
124
125
126
127
128
129
...
131
132
133
134
135
136
137





138
139
140
141
142
143
144
...
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
...
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
<?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 so get 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)
   - 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*userssfnet>
*/





#------------------------------------------------------------------ CVS ---
// most of this appeared in 5.0
// ...




#------------------------------------------------------------- optional ---
// following functions aren't present everywhere (regardless of version)
// ... (should probably go into ext/ then?)




#------------------------------------------------------------------ 6.0 ---
// following functions were never implemented in PHP


................................................................................
      else {
         return($data);
      }
   }
}
























#------------------------------------------------------------------ 5.0 ---
# set_exception_handler - unimpl.
# restore_exception_handler - unimpl.
# debug_print_backtrace - unimpl.
# class_implements - unimplementable
................................................................................
# 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);
   }
................................................................................
      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)) {
................................................................................
      }
   }
}


#-- 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
}








|





<
<
|
|
|


<
>











<
<




<
<
<
<
<
<
<







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>







 







|







 







|







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
...
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
...
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
...
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
...
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
<?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*userssfnet>
*/





#------------------------------------------------------------------ CVS ---
// most of this appeared in 5.0
// ...











#------------------------------------------------------------------ 6.0 ---
// following functions were never implemented in PHP


................................................................................
      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(
        "&#"=>"&#", "&"=>"&amp;", "'"=>"&apos;",
        "<"=>"&lt;", ">"=>"&gt;", "\""=>"&quot;", 
      ));
   }
}



#------------------------------------------------------------------ 5.0 ---
# set_exception_handler - unimpl.
# restore_exception_handler - unimpl.
# debug_print_backtrace - unimpl.
# class_implements - unimplementable
................................................................................
# 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);
   }
................................................................................
      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)) {
................................................................................
      }
   }
}


#-- 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
}