X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=c22813922bee6fcc8965802ed26e5bfb07e11ac1;hb=b9da831138667700d465f15ad50df650ab4da427;hp=b68a7c5b188ec74c7e181fd9056a2f8e76084fe5;hpb=03000beac6a70b6f5bb1e6852a2aad4eb6f52787;p=friendica.git diff --git a/include/bbcode.php b/include/bbcode.php index b68a7c5b18..c22813922b 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -3,6 +3,8 @@ require_once("include/oembed.php"); require_once('include/event.php'); require_once('include/map.php'); require_once('mod/proxy.php'); +require_once('include/Contact.php'); +require_once('include/plaintext.php'); function bb_PictureCacheExt($matches) { if (strpos($matches[3], "data:image/") === 0) @@ -30,237 +32,100 @@ function bb_map_location($match) { } function bb_attachment($Text, $simplehtml = false, $tryoembed = true) { - $Text = preg_replace_callback("/(.*?)\[attachment(.*?)\](.*?)\[\/attachment\]/ism", - function ($match) use ($simplehtml, $tryoembed){ - $attributes = $match[2]; + $data = get_attachment_data($Text); - $type = ""; - preg_match("/type='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") - $type = strtolower($matches[1]); + if (!$data) + return $Text; - preg_match('/type="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $type = strtolower($matches[1]); - - if ($type == "") - return($match[0]); - - if (!in_array($type, array("link", "audio", "video"))) - return($match[0]); - - $url = ""; - preg_match("/url='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") - $url = $matches[1]; - - preg_match('/url="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $url = $matches[1]; - - $title = ""; - preg_match("/title='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") - $title = $matches[1]; - - preg_match('/title="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $title = $matches[1]; - - //$title = htmlentities($title, ENT_QUOTES, 'UTF-8', false); - $title = bbcode(html_entity_decode($title, ENT_QUOTES, 'UTF-8'), false, false, true); - $title = str_replace(array("[", "]"), array("[", "]"), $title); - - $image = ""; - if ($type != "video") { - preg_match("/image='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") - $image = $matches[1]; - - preg_match('/image="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $image = $matches[1]; - } - - $preview = ""; - if ($type != "video") { - preg_match("/preview='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") - $preview = $matches[1]; - - preg_match('/preview="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $preview = $matches[1]; - } - - if (((strpos($match[1], "[img=") !== false) OR (strpos($match[1], "[img]") !== false)) AND ($image != "")) { - $preview = $image; - $image = ""; - } - - if ($simplehtml == 7) { - $title2 = $title; - - $test1 = trim(html_entity_decode($match[1],ENT_QUOTES,'UTF-8')); - $test2 = trim(html_entity_decode($title,ENT_QUOTES,'UTF-8')); - - // If the link description is similar to the text above then don't add the link description - if (($title != "") AND ((strpos($test1,$test2) !== false) OR - (similar_text($test1,$test2) / strlen($title)) > 0.9)) - $title2 = $url; - $text = sprintf('%s
', - $url, $title, $title2); - } elseif (($simplehtml != 4) AND ($simplehtml != 0)) - $text = sprintf('%s
', $url, $title); - else { - $text = sprintf('', $type); - - $bookmark = array(sprintf('[bookmark=%s]%s[/bookmark]', $url, $title), $url, $title); - if ($tryoembed) - $oembed = tryoembed($bookmark); - else - $oembed = $bookmark[0]; - - if (strstr(strtolower($oembed), "