From 9296d178b3696a0cf408d006b7fb9832a3344dcb Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 30 Dec 2010 18:32:49 -0800 Subject: [PATCH] html5 video/audio support - still needs multiple source selection, and check that it isn't blocked by html purifier --- include/bbcode.php | 7 ++++ include/html2bbcode.php | 92 +++++++++++++++++++++++------------------ 2 files changed, 58 insertions(+), 41 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index 7e901bd412..646401ddb5 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -77,6 +77,13 @@ function bbcode($Text) { // Images // [img]pathtoimage[/img] $Text = preg_replace("/\[img\](.+?)\[\/img\]/", '', $Text); + + // html5 video and audio + + $Text = preg_replace("/\[video\](.+?)\[\/video\]/", '', $Text); + + $Text = preg_replace("/\[audio\](.+?)\[\/audio\]/", '', $Text); + // [img=widthxheight]image source[/img] $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.+?)\[\/img\]/", '', $Text); diff --git a/include/html2bbcode.php b/include/html2bbcode.php index 1f3d63a0da..b993292300 100644 --- a/include/html2bbcode.php +++ b/include/html2bbcode.php @@ -1,52 +1,62 @@ (.*?)\<\/b\>/is', - '/\(.*?)\<\/i\>/is', - '/\(.*?)\<\/u\>/is', - '/\(.*?)\<\/ul\>/is', - '/\(.*?)\<\/li\>/is', - '/\/is', - '/\(.*?)\<\/div\>/is', - '/\/is', - '/\(.*?)\<\/strong\>/is', - '/\(.*?)\<\/a\>/is', - '/\(.*?)\<\/code\>/is', - '/\(.*?)\<\/span\>/is', - '/\(.*?)\<\/blockquote\>/is', + $htmltags = array( + '/\n/is', + '/\(.*?)\<\/b\>/is', + '/\(.*?)\<\/i\>/is', + '/\(.*?)\<\/u\>/is', + '/\(.*?)\<\/ul\>/is', + '/\(.*?)\<\/li\>/is', + '/\/is', + '/\(.*?)\<\/div\>/is', + '/\/is', + '/\(.*?)\<\/strong\>/is', + '/\(.*?)\<\/a\>/is', + '/\(.*?)\<\/code\>/is', + '/\(.*?)\<\/span\>/is', + '/\(.*?)\<\/blockquote\>/is', + '/\(.*?)/is', + '/\(.*?)/is', - ); + ); -// Replace with -$bbtags = array( - '', - '[b]$1[/b]', - '[i]$1[/i]', - '[u]$1[/u]', - '[list]$1[/list]', - '[*]$1', - '[img]$2[/img]', - '$2', - "\n", - '[b]$1[/b]', - '[url=$1]$3[/url]', - '[code]$1[/code]', - '[color="$1"]$2[/color]', - '[quote]$1[/quote]', - ); + // Replace with -// Replace $htmltags in $text with $bbtags -$text = preg_replace ($htmltags, $bbtags, $s); + $bbtags = array( + '', + '[b]$1[/b]', + '[i]$1[/i]', + '[u]$1[/u]', + '[list]$1[/list]', + '[*]$1', + '[img]$2[/img]', + '$2', + "\n", + '[b]$1[/b]', + '[url=$1]$3[/url]', + '[code]$1[/code]', + '[color="$1"]$2[/color]', + '[quote]$1[/quote]', + '[video]$1[/video]', + '[audio]$1[/audio]', + ); -call_hooks('html2bbcode', $text); + // Replace $htmltags in $text with $bbtags + $text = preg_replace ($htmltags, $bbtags, $s); + + call_hooks('html2bbcode', $text); + + // Strip all other HTML tags + $text = strip_tags($text); + return $text; +} -// Strip all other HTML tags -$text = strip_tags($text); -return $text; -} \ No newline at end of file