--- flashvideo.module 2009-05-02 04:28:01.000000000 +0200 +++ flashvideo.module 2009-05-31 18:42:56.000000000 +0200 @@ -1926,7 +1926,6 @@ function flashvideo_does_video_exist($no */ function flashvideo_get_video($node, $params = array(), $file_only = FALSE) { $video = flashvideo_get_video_object($node, $params); - // If a video file is defined, return the video object. if (isset($video['file'])) { return ($file_only ? $video['file'] : flashvideo_play($video)); @@ -2147,14 +2146,14 @@ function flashvideo_get_video_object($no function _flashvideo_parse_params($body, &$pos, $max_params = 10) { // If we are able to find the end tag delimiter denoted by "]" - if (($endpos = strpos($body, ']', $pos)) !== FALSE) { + if (($endpos = mb_strpos($body, ']', $pos)) !== FALSE) { // Set up an array of characters to take out from the parameter string. $bad_chars = array("

", "

", "
", "
", "\n", "\r", "\t", " "); // Get our parameter string. $param_string = drupal_substr($body, $pos, ($endpos - $pos)); - + // Replace all bad characters with null chars. $param_string = str_replace($bad_chars, '', $param_string); @@ -2229,7 +2228,7 @@ function _flashvideo_replace_tags(&$node $body = (isset($node->teaser) && $node->body == '') ? $node->teaser : $node->body; // Search for tags - for ($pos = 0; (($pos = $startpos = strpos($body, $tag, $pos)) !== FALSE); $pos++) { + for ($pos = 0; (($pos = $startpos = mb_strpos($body, $tag, $pos)) !== FALSE); $pos++) { // We need to check to see if this tag has "!" in front of it, if it does, then we will ignore this tag. if (drupal_substr($body, $pos - 1, 1) == '!') { @@ -2247,14 +2246,14 @@ function _flashvideo_replace_tags(&$node // Initialize our parameters array. $params = array(); - // Parse all the parameters. + // Parse all the parameters. $params = _flashvideo_parse_params($body, $pos); - + // Set the object based on the parameters given. $object = ($tag == '[thumbnail') ? flashvideo_get_thumbnail($node, $params) : flashvideo_get_video($node, $params); // Replace this tag with the real object code. - $body = substr_replace($body, $object, $startpos, ($pos - $startpos)); // Replace this tag. + $body = mb_substr_replace($body, $object, $startpos, ($pos - $startpos)); // Replace this tag. } // If the position exceeds the body length, then break out of the loop. @@ -2269,6 +2268,48 @@ function _flashvideo_replace_tags(&$node $node->body = $body; } +function mb_substr_replace($string, $replacement, $start, $length = null, $encoding = null) { + if (extension_loaded('mbstring') === true) + { + $string_length = (is_null($encoding) === true) ? mb_strlen($string) : mb_strlen($string, $encoding); + + if ($start < 0) + { + $start = max(0, $string_length + $start); + } + + else if ($start > $string_length) + { + $start = $string_length; + } + + if ($length < 0) + { + $length = max(0, $string_length - $start + $length); + } + + else if ((is_null($length) === true) || ($length > $string_length)) + { + $length = $string_length; + } + + if (($start + $length) > $string_length) + { + $length = $string_length - $start; + } + + if (is_null($encoding) === true) + { + return mb_substr($string, 0, $start) . $replacement . mb_substr($string, $start + $length, $string_length - $start - $length); + } + + return mb_substr($string, 0, $start, $encoding) . $replacement . mb_substr($string, $start + $length, $string_length - $start - $length, $encoding); + } + + return (is_null($length) === true) ? substr_replace($string, $replacement, $start) : substr_replace($string, $replacement, $start, $length); +} + + /** * Implementation of hook_nodeapi(). */ @@ -2519,4 +2560,4 @@ function _flashvideo_load($node) { $files[$file->fid] = $file; } return $files; -} \ No newline at end of file +}