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