X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=359a7ba2f0333e4f34dcb7ede125a7288e049986;hb=65b541413f2ecc8d16050a8ed57bdf22e0814b89;hp=eb009477cf40834fc059dca1f1e160d88b5f193e;hpb=8ec833f8087b0bba2f167471c430543c271602dc;p=friendica.git diff --git a/include/bbcode.php b/include/bbcode.php index eb009477cf..359a7ba2f0 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,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), "