Changeset 4989 for trunk/bp-core/bp-core-wpabstraction.php
- Timestamp:
- 08/16/2011 11:33:09 AM (15 years ago)
- File:
-
- 1 edited
-
trunk/bp-core/bp-core-wpabstraction.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-wpabstraction.php
r4820 r4989 27 27 } 28 28 } 29 29 30 30 if ( !function_exists( 'update_blog_option' ) ) { 31 31 function update_blog_option( $blog_id, $option_name, $value ) { … … 74 74 return "{$prefix}spam = 0 AND {$prefix}deleted = 0 AND {$prefix}user_status = 0"; 75 75 } 76 77 /** 78 * Multibyte encoding fallback functions 79 * 80 * The PHP multibyte encoding extension is not enabled by default. In cases where it is not enabled, 81 * these functions provide a fallback. 82 * 83 * Borrowed from MediaWiki, under the GPLv2. Thanks! 84 */ 85 if ( !function_exists( 'mb_strlen' ) ) { 86 /** 87 * Fallback implementation of mb_strlen, hardcoded to UTF-8. 88 * @param string $str 89 * @param string $enc optional encoding; ignored 90 * @return int 91 */ 92 function mb_strlen( $str, $enc = '' ) { 93 $counts = count_chars( $str ); 94 $total = 0; 95 96 // Count ASCII bytes 97 for( $i = 0; $i < 0x80; $i++ ) { 98 $total += $counts[$i]; 99 } 100 101 // Count multibyte sequence heads 102 for( $i = 0xc0; $i < 0xff; $i++ ) { 103 $total += $counts[$i]; 104 } 105 return $total; 106 } 107 } 108 109 if ( !function_exists( 'mb_strpos' ) ) { 110 /** 111 * Fallback implementation of mb_strpos, hardcoded to UTF-8. 112 * @param $haystack String 113 * @param $needle String 114 * @param $offset String: optional start position 115 * @param $encoding String: optional encoding; ignored 116 * @return int 117 */ 118 function mb_strpos( $haystack, $needle, $offset = 0, $encoding = '' ) { 119 $needle = preg_quote( $needle, '/' ); 120 121 $ar = array(); 122 preg_match( '/' . $needle . '/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset ); 123 124 if( isset( $ar[0][1] ) ) { 125 return $ar[0][1]; 126 } else { 127 return false; 128 } 129 } 130 } 131 132 if ( !function_exists( 'mb_strrpos' ) ) { 133 /** 134 * Fallback implementation of mb_strrpos, hardcoded to UTF-8. 135 * @param $haystack String 136 * @param $needle String 137 * @param $offset String: optional start position 138 * @param $encoding String: optional encoding; ignored 139 * @return int 140 */ 141 function mb_strrpos( $haystack, $needle, $offset = 0, $encoding = '' ) { 142 $needle = preg_quote( $needle, '/' ); 143 144 $ar = array(); 145 preg_match_all( '/' . $needle . '/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset ); 146 147 if( isset( $ar[0] ) && count( $ar[0] ) > 0 && 148 isset( $ar[0][count( $ar[0] ) - 1][1] ) ) { 149 return $ar[0][count( $ar[0] ) - 1][1]; 150 } else { 151 return false; 152 } 153 } 154 } 155 76 156 ?>
Note: See TracChangeset
for help on using the changeset viewer.