1+ <?php
2+
3+ /*
4+ * Patch for apache_request_headers()
5+ * If Apache web server is missing then making
6+ */
7+ if ( !function_exists ('apache_request_headers ' ) ){
8+ function apache_request_headers (){
9+
10+ $ headers = array ();
11+ foreach ($ _SERVER as $ key => $ val ){
12+ if (preg_match ('/\AHTTP_/ ' , $ key )){
13+ $ server_key = preg_replace ('/\AHTTP_/ ' , '' , $ key );
14+ $ key_parts = explode ('_ ' , $ server_key );
15+ if (count ($ key_parts ) > 0 and strlen ($ server_key ) > 2 ){
16+ foreach ($ key_parts as $ part_index => $ part ){
17+ $ key_parts [$ part_index ] = function_exists ('mb_strtolower ' ) ? mb_strtolower ($ part ) : strtolower ($ part );
18+ $ key_parts [$ part_index ][0 ] = strtoupper ($ key_parts [$ part_index ][0 ]);
19+ }
20+ $ server_key = implode ('- ' , $ key_parts );
21+ }
22+ $ headers [$ server_key ] = $ val ;
23+ }
24+ }
25+ return $ headers ;
26+ }
27+ }
28+
29+ /*
30+ * Patch for locale_get_display_region()
31+ * For old PHP versions
32+ */
33+ if ( !function_exists ('locale_get_display_region ' ) ){
34+ function locale_get_display_region ($ locale , $ in_locale = 'EN ' ){
35+
36+ return 'Unkonwn ' . ($ locale ? ': ' . $ locale : '' );
37+ }
38+ }
39+
40+ /*
41+ * Patch for utf8_decode()
42+ * If PHP complied without XML support
43+ * From getID3() by James Heinrich <info@getid3.org> under GNU GPL
44+ */
45+ if (!function_exists ('utf8_decode ' )){
46+ function utf8_decode ($ string ){
47+
48+ $ newcharstring = '' ;
49+ $ offset = 0 ;
50+ $ stringlength = strlen ($ string );
51+ while ($ offset < $ stringlength ) {
52+ if ((ord ($ string {$ offset }) | 0x07 ) == 0xF7 ) {
53+ $ charval = ((ord ($ string {($ offset + 0 )}) & 0x07 ) << 18 ) &
54+ ((ord ($ string {($ offset + 1 )}) & 0x3F ) << 12 ) &
55+ ((ord ($ string {($ offset + 2 )}) & 0x3F ) << 6 ) &
56+ (ord ($ string {($ offset + 3 )}) & 0x3F );
57+ $ offset += 4 ;
58+ } elseif ((ord ($ string {$ offset }) | 0x0F ) == 0xEF ) {
59+ $ charval = ((ord ($ string {($ offset + 0 )}) & 0x0F ) << 12 ) &
60+ ((ord ($ string {($ offset + 1 )}) & 0x3F ) << 6 ) &
61+ (ord ($ string {($ offset + 2 )}) & 0x3F );
62+ $ offset += 3 ;
63+ } elseif ((ord ($ string {$ offset }) | 0x1F ) == 0xDF ) {
64+ $ charval = ((ord ($ string {($ offset + 0 )}) & 0x1F ) << 6 ) &
65+ (ord ($ string {($ offset + 1 )}) & 0x3F );
66+ $ offset += 2 ;
67+ } elseif ((ord ($ string {$ offset }) | 0x7F ) == 0x7F ) {
68+ $ charval = ord ($ string {$ offset });
69+ $ offset += 1 ;
70+ } else {
71+ $ charval = false ;
72+ $ offset += 1 ;
73+ }
74+ if ($ charval !== false ) {
75+ $ newcharstring .= (($ charval < 256 ) ? chr ($ charval ) : '? ' );
76+ }
77+ }
78+ return $ newcharstring ;
79+ }
80+ }
0 commit comments