Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -72,6 +72,54 @@ |
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
| 76 | + |
| 77 | +if( !function_exists( 'mb_strpos' ) ) { |
| 78 | + /** |
| 79 | + * Fallback implementation of mb_strpos, hardcoded to UTF-8. |
| 80 | + * @param string $haystack |
| 81 | + * @param string $needle |
| 82 | + * @param string $offset optional start position |
| 83 | + * @param string $encoding optional encoding; ignored |
| 84 | + * @return int |
| 85 | + */ |
| 86 | + function mb_strpos( $haystack, $needle, $offset = 0, $encoding="" ) { |
| 87 | + $needle = preg_quote( $needle, '/' ); |
| 88 | + |
| 89 | + $ar = array(); |
| 90 | + preg_match( '/'.$needle.'/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset ); |
| 91 | + |
| 92 | + if( isset( $ar[0][1] ) ) { |
| 93 | + return $ar[0][1]; |
| 94 | + } else { |
| 95 | + return false; |
| 96 | + } |
| 97 | + } |
| 98 | +} |
| 99 | + |
| 100 | +if( !function_exists( 'mb_strrpos' ) ) { |
| 101 | + /** |
| 102 | + * Fallback implementation of mb_strrpos, hardcoded to UTF-8. |
| 103 | + * @param string $haystack |
| 104 | + * @param string $needle |
| 105 | + * @param string $offset optional start position |
| 106 | + * @param string $encoding optional encoding; ignored |
| 107 | + * @return int |
| 108 | + */ |
| 109 | + function mb_strrpos( $haystack, $needle, $offset = 0, $encoding = "" ) { |
| 110 | + $needle = preg_quote( $needle, '/' ); |
| 111 | + |
| 112 | + $ar = array(); |
| 113 | + preg_match_all( '/'.$needle.'/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset ); |
| 114 | + |
| 115 | + if( isset( $ar[0] ) && count( $ar[0] ) > 0 && |
| 116 | + isset( $ar[0][count($ar[0])-1][1] ) ) { |
| 117 | + return $ar[0][count($ar[0])-1][1]; |
| 118 | + } else { |
| 119 | + return false; |
| 120 | + } |
| 121 | + } |
| 122 | +} |
| 123 | + |
76 | 124 | if ( !function_exists( 'array_diff_key' ) ) { |
77 | 125 | /** |
78 | 126 | * Exists in PHP 5.1.0+ |