'https://youtube.com',
'youtu.be' => 'https://youtu.be',
'vimeo' => 'https://vimeo.com',
'soundcloud' => 'https://soundcloud.com'
);
foreach($s as $k => $v) {
if(strpos($m['host'],$k) !== false) {
logger('found: ' . $k);
$realurl = $v;
break;
}
}
if($realurl) {
$arr['url'] = $realurl . (($m['path']) ? '/' . $m['path'] : '') . (($m['query']) ? '?' . $m['query'] : '') . (($m['fragment']) ? '#' . $m['fragment'] : '');
$arr['action'] = 'allow';
logger('allowed');
}
}
function std_embeds_html2bb_video(&$x) {
$s = $x['string'];
$s = preg_replace('##ism',
'[embed]https://www.youtube.com/watch?v=$2[/embed]', $s);
$s = preg_replace('##ism',
'[embed]https://www.youtube.com/watch?v=$2[/embed]', $s);
$s = preg_replace('##ism',
'[embed]https://player.vimeo.com/video/$2[/embed]', $s);
$x['string'] = $s;
}
function std_embeds_bb_translate_video(&$x) {
$s = $x['string'];
$matches = null;
$r = preg_match_all("/\[video\](.*?)\[\/video\]/ism",$s,$matches,PREG_SET_ORDER);
if($r) {
foreach($matches as $mtch) {
if((stristr($mtch[1],'youtube')) || (stristr($mtch[1],'youtu.be')))
$s = str_replace($mtch[0],'[embed]' . $mtch[1] . '[/embed]',$s);
elseif(stristr($mtch[1],'vimeo'))
$s = str_replace($mtch[0],'[embed]' . $mtch[1] . '[/embed]',$s);
}
}
$x['string'] = $s;
}