public function VideoParser($sText) {
/**
* youtube.com
*/
$sText = preg_replace('/<video>(?:http(?:s|):|)(?:\/\/|)(?:www\.|)youtube\.com\/watch\?v=([a-zA-Z0-9_\-]+)(&.+)?<\/video>/Ui', '<iframe width="560" height="315" src="http://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>', $sText);
/**
/**
* youtu.be
*/
$sText = preg_replace('/<video>http:\/\/(?:www\.|)youtu.be\/([a-zA-Z0-9_\-]+)(&.+)?<\/video>/Ui', '<iframe width="560" height="315" src="http://www.youtube.com/embed/$1?rel=0" frameborder="0" allowfullscreen></iframe>', $sText);
/**
* twitch
*/
$sText = preg_replace('/<video>(?:http(?:s|):|)(?:\/\/|)(?:www\.|)twitch.tv\/([a-zA-Z0-9_\-]+)(&.+)?<\/video>/Ui', '<iframe src="https://player.twitch.tv/?channel=$1" frameborder="0" scrolling="no" height="315" width="560" class="youtube"></iframe>', $sText);
/**
* twitch
*/
$sText = preg_replace('/<video>(?:http(?:s|):|)(?:\/\/|)(?:www\.|)twitch.tv\/([a-zA-Z0-9_\-]+)(&.+)?\/v\/([A-Z]{1}|[0-9]{8}).*<\/video>/Ui', '<iframe src="https://player.twitch.tv/?video=v$3" frameborder="0" scrolling="no" height="315" width="560" class="youtube"></iframe>', $sText);
/**
* twitch chat
*/
$sText = preg_replace('/<video>(?:http(?:s|):|)(?:\/\/|)(?:www\.|)twitch.tv\/([a-zA-Z0-9_\-]+)(&.+)?\/chat<\/video>/Ui', '<div align="center"><iframe src="https://www.twitch.tv/$1/chat?popout=" frameborder="0" scrolling="no" height="500" width="650"></iframe></div>', $sText);
/**
* vimeo.com
*/
$sText = preg_replace('/<video>http:\/\/(?:www\.|)vimeo\.com\/(\d+).*<\/video>/i', '<iframe src="http://player.vimeo.com/video/$1" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>', $sText);
/**
* rutube.ru
*/
$sText = preg_replace('/<video>http:\/\/(?:www\.|)rutube\.ru\/tracks\/(\d+)\.html.*<\/video>/Ui', '<OBJECT width="470" height="353"><PARAM name="movie" value="http://video.rutube.ru/$1"></PARAM><PARAM name="wmode" value="window"></PARAM><PARAM name="allowFullScreen" value="true"></PARAM><EMBED src="http://video.rutube.ru/$1" type="application/x-shockwave-flash" wmode="window" width="470" height="353" allowFullScreen="true" ></EMBED></OBJECT>', $sText);
/**
* video.yandex.ru
*/
$sText = preg_replace('/<video>http:\/\/video\.yandex\.ru\/users\/([a-zA-Z0-9_\-]+)\/view\/(\d+).*<\/video>/i', '<object width="467" height="345"><param name="video" value="http://video.yandex.ru/users/$1/view/$2/get-object-by-url/redirect"></param><param name="allowFullScreen" value="true"></param><param name="scale" value="noscale"></param><embed src="http://video.yandex.ru/users/$1/view/$2/get-object-by-url/redirect" type="application/x-shockwave-flash" width="467" height="345" allowFullScreen="true" scale="noscale" ></embed></object>', $sText);
/**
* vk.com
*/
$regExp = '/<video>(?:http(?:s|):|)(?:\/\/|)(?:www\.|)vk\.com\/video((?:-|)[\d]+)_((?:-|)[\d]+)(?:\?[\s\S]+|)<\/video>/i';
if(preg_match($regExp, $sText)) {
preg_match_all($regExp, $sText, $sTextMatches);
for($i=0;$i<count($sTextMatches[1]);$i++){
$html = file_get_contents('http://vk.com/video'.$sTextMatches[1][$i].'_'.$sTextMatches[2][$i]);
preg_match('/\\\"hash2\\\":\\\"([a-f0-9]+)\\\"/Ui', $html, $matches);
$sText = preg_replace('/(?:http(?:s|):|)(?:\/\/|)(?:www\.|)vk\.com\/video'.$sTextMatches[1][$i].'_'.$sTextMatches[2][$i].'(?:\?[\s\S]+|)/Ui', '<iframe src="http://vk.com/video_ext.php?oid='.$sTextMatches[1][$i].'&id='.$sTextMatches[2][$i].'&hash='.$matches[1].'" width="560" height="315" frameborder="0"></iframe>', $sText);
}
}
return $sText;
}