X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=ed23253648e615e5613893409d24a4865582891a;hb=014fc5dccbf24a6473e0e2e9bdca810103d8b202;hp=b47a514320d638e3a5a649fdd74ad4d49b2e3580;hpb=6258a21434a83d840b1af5962219a2924d40ba42;p=friendica.git diff --git a/include/bbcode.php b/include/bbcode.php index b47a514320..ed23253648 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -2,7 +2,25 @@ 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) + return ($matches[0]); + + $matches[3] = proxy_url($matches[3]); + return "[img=".$matches[1]."x".$matches[2]."]".$matches[3]."[/img]"; +} + +function bb_PictureCache($matches) { + if (strpos($matches[1], "data:image/") === 0) + return ($matches[0]); + + $matches[1] = proxy_url($matches[1]); + return "[img]".$matches[1]."[/img]"; +} function bb_map_coords($match) { // the extra space in the following line is intentional @@ -13,226 +31,100 @@ function bb_map_location($match) { return str_replace($match[0],'
' . generate_named_map($match[1]) . '
', $match[0]); } -function bb_attachment($Text, $plaintext = false, $tryoembed = true) { - $Text = preg_replace_callback("/(.*?)\[attachment(.*?)\](.*?)\[\/attachment\]/ism", - function ($match) use ($plaintext, $tryoembed){ - - $attributes = $match[2]; - - $type = ""; - preg_match("/type='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") - $type = strtolower($matches[1]); - - 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 ($plaintext) - $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]; +function bb_attachment($Text, $simplehtml = false, $tryoembed = true) { - if (strstr(strtolower($oembed), "