' . 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]); } function bb_attachment($Text, $simplehtml = false, $tryoembed = true) { $data = get_attachment_data($Text); if (!$data) return $Text; if (isset($data["title"])) { $data["title"] = strip_tags($data["title"]); $data["title"] = str_replace(array("http://", "https://"), "", $data["title"]); } if (((strpos($data["text"], "[img=") !== false) OR (strpos($data["text"], "[img]") !== false)) AND ($data["image"] != "")) { $data["preview"] = $data["image"]; $data["image"] = ""; } if ($simplehtml == 7) { $title2 = $data["title"]; $test1 = trim(html_entity_decode($data["text"],ENT_QUOTES,'UTF-8')); $test2 = trim(html_entity_decode($data["title"],ENT_QUOTES,'UTF-8')); // 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"]); $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 (strstr(strtolower($oembed), "', $Text); else $Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/ism", '$1', $Text); // Youtube extensions if ($tryoembed) { $Text = preg_replace_callback("/\[youtube\](https?:\/\/www.youtube.com\/watch\?v\=.*?)\[\/youtube\]/ism", 'tryoembed', $Text); $Text = preg_replace_callback("/\[youtube\](www.youtube.com\/watch\?v\=.*?)\[\/youtube\]/ism", 'tryoembed', $Text); $Text = preg_replace_callback("/\[youtube\](https?:\/\/youtu.be\/.*?)\[\/youtube\]/ism",'tryoembed',$Text); } $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text); $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/embed\/(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text); $Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text); if ($tryoembed) $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '', $Text); else $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", 'https://www.youtube.com/watch?v=$1', $Text); if ($tryoembed) { $Text = preg_replace_callback("/\[vimeo\](https?:\/\/player.vimeo.com\/video\/[0-9]+).*?\[\/vimeo\]/ism",'tryoembed',$Text); $Text = preg_replace_callback("/\[vimeo\](https?:\/\/vimeo.com\/[0-9]+).*?\[\/vimeo\]/ism",'tryoembed',$Text); } $Text = preg_replace("/\[vimeo\]https?:\/\/player.vimeo.com\/video\/([0-9]+)(.*?)\[\/vimeo\]/ism",'[vimeo]$1[/vimeo]',$Text); $Text = preg_replace("/\[vimeo\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/vimeo\]/ism",'[vimeo]$1[/vimeo]',$Text); if ($tryoembed) $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '', $Text); else $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", 'https://vimeo.com/$1', $Text); // $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", '', $Text); // oembed tag $Text = oembed_bbcode2html($Text); // Avoid triple linefeeds through oembed $Text = str_replace("


", "

", $Text); // If we found an event earlier, strip out all the event code and replace with a reformatted version. // Replace the event-start section with the entire formatted event. The other bbcode is stripped. // Summary (e.g. title) is required, earlier revisions only required description (in addition to // start which is always required). Allow desc with a missing summary for compatibility. if((x($ev,'desc') || x($ev,'summary')) && x($ev,'start')) { $sub = format_event_html($ev, $simplehtml); $Text = preg_replace("/\[event\-summary\](.*?)\[\/event\-summary\]/ism",'',$Text); $Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/ism",'',$Text); $Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/ism",$sub,$Text); $Text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/ism",'',$Text); $Text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/ism",'',$Text); $Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/ism",'',$Text); } //replace oneliner with $Text = preg_replace_callback("|(?!]*>)([^<]*)(?!]*>)|ism", 'bb_onelinecode_cb', $Text); // Unhide all [noparse] contained bbtags unspacefying them // and triming the [noparse] tag. $Text = preg_replace_callback("/\[noparse\](.*?)\[\/noparse\]/ism", 'bb_unspacefy_and_trim',$Text); $Text = preg_replace_callback("/\[nobb\](.*?)\[\/nobb\]/ism", 'bb_unspacefy_and_trim',$Text); $Text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", 'bb_unspacefy_and_trim',$Text); $Text = preg_replace('/\[\&\;([#a-z0-9]+)\;\]/','&$1;',$Text); $Text = preg_replace('/\&\#039\;/','\'',$Text); $Text = preg_replace('/\"\;/','"',$Text); // fix any escaped ampersands that may have been converted into links $Text = preg_replace("/\<([^>]*?)(src|href)=(.*?)\&\;(.*?)\>/ism",'<$1$2=$3&$4>',$Text); $Text = preg_replace("/\<([^>]*?)(src|href)=\"(?!http|ftp|mailto|gopher|cid)(.*?)\>/ism",'<$1$2="">',$Text); if($saved_image) $Text = bb_replace_images($Text, $saved_image); // Clean up the HTML by loading and saving the HTML with the DOM. // Bad structured html can break a whole page. // For performance reasons do it only with ativated item cache or at export. if (!$tryoembed OR (get_itemcachepath() != "")) { $doc = new DOMDocument(); $doc->preserveWhiteSpace = false; $Text = mb_convert_encoding($Text, 'HTML-ENTITIES', "UTF-8"); $doctype = ''; $encoding = ''; @$doc->loadHTML($encoding.$doctype."".$Text.""); $doc->encoding = 'UTF-8'; $Text = $doc->saveHTML(); $Text = str_replace(array("", "", $doctype, $encoding), array("", "", "", ""), $Text); $Text = str_replace('
','', $Text); //$Text = mb_convert_encoding($Text, "UTF-8", 'HTML-ENTITIES'); } // Clean up some useless linebreaks in lists //$Text = str_replace('

','', $Text); //$Text = str_replace('
','', $Text); //$Text = str_replace('
  • ','
  • ', $Text); // $Text = str_replace('