X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=ed23253648e615e5613893409d24a4865582891a;hb=014fc5dccbf24a6473e0e2e9bdca810103d8b202;hp=9a3563527ae4bc9eb8d11143391bf5497358e859;hpb=b7a50a24c74184e1d068b457bf1099ea9c2ed405;p=friendica.git diff --git a/include/bbcode.php b/include/bbcode.php index 9a3563527a..ed23253648 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -1,218 +1,130 @@ %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 (($image != "") AND !strstr(strtolower($oembed), "
', $url, $image, $title); - elseif (($preview != "") AND !strstr(strtolower($oembed), "
', $url, $preview, $title); - - $text .= $oembed; - - $text .= sprintf('
%s
', trim($match[3])); - } - - return($match[1].$text); - },$Text); - - return($Text); + $matches[3] = proxy_url($matches[3]); + return "[img=".$matches[1]."x".$matches[2]."]".$matches[3]."[/img]"; } -function bb_rearrange_share($shared) { - if (!in_array(strtolower($shared[2]), array("type-link", "type-audio", "type-video"))) - return($shared[0]); +function bb_PictureCache($matches) { + if (strpos($matches[1], "data:image/") === 0) + return ($matches[0]); - if (!preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$shared[3], $bookmark)) - return($shared[0]); + $matches[1] = proxy_url($matches[1]); + return "[img]".$matches[1]."[/img]"; +} - $type = substr(trim(strtolower($shared[2])), 5); +function bb_map_coords($match) { + // the extra space in the following line is intentional + return str_replace($match[0],'
' . generate_map(str_replace('/',' ',$match[1])) . '
', $match[0]); +} +function bb_map_location($match) { + // the extra space in the following line is intentional + return str_replace($match[0],'
' . generate_named_map($match[1]) . '
', $match[0]); +} - $title = ""; - $url = ""; - $preview = ""; - $description = ""; +function bb_attachment($Text, $simplehtml = false, $tryoembed = true) { - if (isset($bookmark[2][0])) - $title = $bookmark[2][0]; + $data = get_attachment_data($Text); + if (!$data) + return $Text; - if (isset($bookmark[1][0])) - $url = $bookmark[1][0]; + if (isset($data["title"])) { + $data["title"] = strip_tags($data["title"]); + $data["title"] = str_replace(array("http://", "https://"), "", $data["title"]); + } - $cleanedshare = trim($shared[3]); - $cleanedshare = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $cleanedshare); - preg_match("/\[img\](.*?)\[\/img\]/ism", $cleanedshare, $matches); + if (((strpos($data["text"], "[img=") !== false) OR (strpos($data["text"], "[img]") !== false)) AND ($data["image"] != "")) { + $data["preview"] = $data["image"]; + $data["image"] = ""; + } - if ($matches) - $preview = trim($matches[1]); + if ($simplehtml == 7) { + $title2 = $data["title"]; - preg_match("/\[quote\](.*?)\[\/quote\]/ism", $cleanedshare, $matches); - if ($matches) - $description = trim($matches[1]); + $test1 = trim(html_entity_decode($data["text"],ENT_QUOTES,'UTF-8')); + $test2 = trim(html_entity_decode($data["title"],ENT_QUOTES,'UTF-8')); - $url = str_replace(array("[", "]"), array("[", "]"), htmlentities($url, ENT_QUOTES, 'UTF-8', false)); - $title = str_replace(array("[", "]"), array("[", "]"), htmlentities($title, ENT_QUOTES, 'UTF-8', false)); - $preview = str_replace(array("[", "]"), array("[", "]"), htmlentities($preview, ENT_QUOTES, 'UTF-8', false)); + // If the link description is similar to the text above then don't add the link description + if (($data["title"] != "") AND ((strpos($test1,$test2) !== false) OR + (similar_text($test1,$test2) / strlen($data["title"])) > 0.9)) + $title2 = $data["url"]; + $text = sprintf('%s
', + $data["url"], $data["title"], $title2); + } elseif (($simplehtml != 4) AND ($simplehtml != 0)) + $text = sprintf('%s
', $data["url"], $data["title"]); + else { + $text = sprintf('', $data["type"]); - $Text = trim($shared[1])."\n[attachment type='".$type."'"; + $bookmark = array(sprintf('[bookmark=%s]%s[/bookmark]', $data["url"], $data["title"]), $data["url"], $data["title"]); + if ($tryoembed) + $oembed = tryoembed($bookmark); + else + $oembed = $bookmark[0]; - if ($url != "") - $Text .= " url='".$url."'"; - if ($title != "") - $Text .= " title='".$title."'"; - if ($preview != "") { - require_once("include/Photo.php"); - $picturedata = get_photo_info($preview); + if (strstr(strtolower($oembed), "