X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=ed23253648e615e5613893409d24a4865582891a;hb=014fc5dccbf24a6473e0e2e9bdca810103d8b202;hp=8102fc3f71e5de0ef5251b034305cddb04ee4f04;hpb=c076c5601628cf87735b8ae0b9f17fe58eb0041d;p=friendica.git diff --git a/include/bbcode.php b/include/bbcode.php index 8102fc3f71..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 @@ -14,228 +32,99 @@ 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]; - - $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 ($simplehtml == 7) - $text = sprintf('%s', - $url, $title, $title); - 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), "