X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=70cd22d5f9c0eaa960c3aad0ac18a8f8e8f7a8e6;hb=714eb1a296b2529a1d1b410c0225fc1c6a3e48d0;hp=8545b2ff8253c9b29c9b71d87b8003a383623e3b;hpb=430be22bb9fb25e1d8d6f4e50f69cde1ff36204a;p=friendica.git diff --git a/include/bbcode.php b/include/bbcode.php index 8545b2ff82..70cd22d5f9 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -4,6 +4,7 @@ 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) @@ -31,238 +32,95 @@ 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), "