X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=81536d37200fdd5083a38685c306282856f8d0cb;hb=ddf3589fc5effa9fb28947e200bfe0a310cef88c;hp=6c5a400ddc307a069ac67a56a57f09c0fc668017;hpb=e839e3e1ec4b4a56ecf9886d8e29e07d6e5a798c;p=friendica.git diff --git a/include/bbcode.php b/include/bbcode.php index 6c5a400ddc..81536d3720 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -2,7 +2,23 @@ require_once("include/oembed.php"); require_once('include/event.php'); require_once('include/map.php'); +require_once('mod/proxy.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 @@ -101,9 +117,9 @@ function bb_attachment($Text, $simplehtml = false, $tryoembed = true) { $text = $oembed; else { if (($image != "") AND !strstr(strtolower($oembed), "
', $url, $image, $title); + $text .= sprintf('
', $url, proxy_url($image), $title); elseif (($preview != "") AND !strstr(strtolower($oembed), "
', $url, $preview, $title); + $text .= sprintf('
', $url, proxy_url($preview), $title); $text .= $oembed; @@ -268,6 +284,13 @@ function stripcode_br_cb($s) { return '[code]' . str_replace('
', '', $s[1]) . '[/code]'; } +function bb_onelinecode_cb($match) { + if (strpos($match[1],"
")===false){ + return "".$match[1].""; + } + return "".$match[1].""; +} + function tryoembed($match){ //$url = ((count($match)==2)?$match[1]:$match[2]); $url = $match[1]; @@ -448,7 +471,7 @@ function bb_replace_images($body, $images) { // We're depending on the property of 'foreach' (specified on the PHP website) that // it loops over the array starting from the first element and going sequentially // to the last element - $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '' . t('Image/photo') . '', $newbody); + $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '' . t('Image/photo') . '', $newbody); $cnt++; } @@ -578,7 +601,7 @@ function bb_ShareAttributes($share, $simplehtml) { default: $headline = trim($share[1]).'
'; if ($avatar != "") - $headline .= ''; + $headline .= ''; $headline .= sprintf(t('%s wrote the following post'.$reldate.':'), $profile, $author, $link); $headline .= "
"; @@ -887,8 +910,12 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal $MAILSearchString = $URLSearchString; // Remove all hashtag addresses - if ((!$tryoembed OR $simplehtml) AND ($simplehtml != 7)) + if ((!$tryoembed OR $simplehtml) AND !in_array($simplehtml, array(3, 7))) $Text = preg_replace("/([#@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $Text); + elseif ($simplehtml == 3) + $Text = preg_replace("/([@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", + '$1$3', + $Text); elseif ($simplehtml == 7) $Text = preg_replace("/([@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', @@ -1091,13 +1118,17 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal "
" . $t_wrote . "
$2
", $Text); + // [img=widthxheight]image source[/img] - //$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '', $Text); + $Text = preg_replace_callback("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", 'bb_PictureCacheExt', $Text); + $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '', $Text); $Text = preg_replace("/\[zmg\=([0-9]*)x([0-9]*)\](.*?)\[\/zmg\]/ism", '', $Text); // Images // [img]pathtoimage[/img] + $Text = preg_replace_callback("/\[img\](.*?)\[\/img\]/ism", 'bb_PictureCache', $Text); + $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); @@ -1175,11 +1206,11 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal // 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 + // 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); + $sub = format_event_html($ev, $simplehtml); $Text = preg_replace("/\[event\-summary\](.*?)\[\/event\-summary\]/ism",'',$Text); $Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/ism",'',$Text); @@ -1189,6 +1220,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal $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. @@ -1203,7 +1238,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal // 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|cid)(.*?)\>/ism",'<$1$2="">',$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);