[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 // Last sync [WP11537] 3 4 /** 5 * BackPress implementation for PHP functions missing from older PHP versions. 6 * 7 * @package PHP 8 * @access private 9 */ 10 11 if ( !function_exists( 'http_build_query' ) ) { 12 // Added in PHP 5.0.0 13 function http_build_query( $data, $prefix = null, $sep = null ) 14 { 15 return _http_build_query( $data, $prefix, $sep ); 16 } 17 } 18 19 if ( !function_exists( '_http_build_query' ) ) { 20 // from php.net (modified by Mark Jaquith to behave like the native PHP5 function) 21 function _http_build_query($data, $prefix = null, $sep = null, $key = '', $urlencode = true) 22 { 23 $ret = array(); 24 25 foreach ( (array) $data as $k => $v ) { 26 if ( $urlencode) { 27 $k = urlencode( $k ); 28 } 29 if ( is_int( $k ) && $prefix != null ) { 30 $k = $prefix.$k; 31 } 32 if ( !empty( $key ) ) { 33 $k = $key . '%5B' . $k . '%5D'; 34 } 35 if ( $v === NULL ) { 36 continue; 37 } elseif ( $v === FALSE ) { 38 $v = '0'; 39 } 40 41 if ( is_array( $v ) || is_object( $v ) ) { 42 array_push( $ret, _http_build_query( $v, '', $sep, $k, $urlencode ) ); 43 } elseif ( $urlencode ) { 44 array_push( $ret, $k . '=' . urlencode( $v ) ); 45 } else { 46 array_push( $ret, $k . '=' . $v ); 47 } 48 } 49 50 if ( NULL === $sep ) { 51 $sep = ini_get( 'arg_separator.output' ); 52 } 53 54 return implode( $sep, $ret ); 55 } 56 } 57 58 if ( !function_exists( '_' ) ) { 59 // Alias of gettext() - requires l10n functions 60 function _( $string ) 61 { 62 return $string; 63 } 64 } 65 66 if ( !function_exists( 'stripos' ) ) { 67 // Added in PHP 5.0.0 68 function stripos( $haystack, $needle, $offset = 0 ) 69 { 70 return strpos( strtolower( $haystack ), strtolower( $needle ), $offset ); 71 } 72 } 73 74 if ( !function_exists( 'hash_hmac' ) ) { 75 // Added in PHP 5.1.2 76 function hash_hmac( $algo, $data, $key, $raw_output = false ) 77 { 78 $packs = array( 'md5' => 'H32', 'sha1' => 'H40' ); 79 80 if ( !isset( $packs[$algo] ) ) { 81 return false; 82 } 83 84 $pack = $packs[$algo]; 85 86 if ( strlen( $key ) > 64 ) { 87 $key = pack( $pack, $algo( $key ) ); 88 } elseif ( strlen($key) < 64 ) { 89 $key = str_pad( $key, 64, chr( 0 ) ); 90 } 91 92 $ipad = ( substr( $key, 0, 64 ) ^ str_repeat( chr( 0x36 ), 64 ) ); 93 $opad = ( substr( $key, 0, 64 ) ^ str_repeat( chr( 0x5C ), 64 ) ); 94 95 return $algo( $opad . pack( $pack, $algo ( $ipad . $data ) ) ); 96 } 97 } 98 99 if ( !function_exists( 'mb_substr' ) ) { 100 // Requires multi-byte support in PHP 101 function mb_substr( $str, $start, $length = null, $encoding = null ) 102 { 103 return _mb_substr( $str, $start, $length, $encoding ); 104 } 105 } 106 107 if ( !function_exists( '_mb_substr' ) ) { 108 function _mb_substr( $str, $start, $length = null, $encoding = null ) 109 { 110 // the solution below, works only for utf-8, so in case of a different 111 // charset, just use built-in substr 112 $charset = backpress_get_option( 'charset' ); 113 if ( !in_array( $charset, array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) { 114 return is_null( $length )? substr( $str, $start ) : substr( $str, $start, $length); 115 } 116 // use the regex unicode support to separate the UTF-8 characters into an array 117 preg_match_all( '/./us', $str, $match ); 118 $chars = is_null( $length )? array_slice( $match[0], $start ) : array_slice( $match[0], $start, $length ); 119 return implode( '', $chars ); 120 } 121 } 122 123 if ( !function_exists( 'htmlspecialchars_decode' ) ) { 124 // Added in PHP 5.1.0 125 // Error checks from PEAR::PHP_Compat 126 function htmlspecialchars_decode( $str, $quote_style = ENT_COMPAT ) 127 { 128 if ( !is_scalar( $string ) ) { 129 trigger_error( 'htmlspecialchars_decode() expects parameter 1 to be string, ' . gettype( $string ) . ' given', E_USER_WARNING ); 130 return; 131 } 132 133 if ( !is_int( $quote_style ) && $quote_style !== null ) { 134 trigger_error( 'htmlspecialchars_decode() expects parameter 2 to be integer, ' . gettype( $quote_style ) . ' given', E_USER_WARNING ); 135 return; 136 } 137 138 return wp_specialchars_decode( $str, $quote_style ); 139 } 140 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Dec 22 01:00:54 2024 | Cross-referenced by PHPXref 0.7.1 |