]> git.mxchange.org Git - friendica.git/blobdiff - include/bbcode.php
pagination: fix template
[friendica.git] / include / bbcode.php
index a587d8c38075e5f6da2dfc066801492d8f6f8eaa..eaf412c35394bfae5e09ba4de1e603b6fc1d426e 100644 (file)
@@ -407,6 +407,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
        $Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '<a href="$1" target="external-link">$2</a>', $Text);
        //$Text = preg_replace("/\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[\/url\]/ism", '<a href="$1" target="_blank">$2</a>', $Text);
 
+       // Red compatibility, though the link can't be authenticated on Friendica
+       $Text = preg_replace("/\[zrl\=([$URLSearchString]*)\](.*?)\[\/zrl\]/ism", '<a href="$1" target="external-link">$2</a>', $Text);
+
+
        // we may need to restrict this further if it picks up too many strays
        // link acct:user@host to a webfinger profile redirector
 
@@ -539,10 +543,12 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
        // [img=widthxheight]image source[/img]
        //$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="height: $2px; width: $1px;" >', $Text);
        $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="width: $1px;" >', $Text);
+       $Text = preg_replace("/\[zmg\=([0-9]*)x([0-9]*)\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$3" style="width: $1px;" >', $Text);
 
        // Images
        // [img]pathtoimage[/img]
        $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . t('Image/photo') . '" />', $Text);
+       $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '<img src="$1" alt="' . t('Image/photo') . '" />', $Text);
 
        // Shared content
        if (!$simplehtml)
@@ -642,8 +648,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
        $Text = preg_replace('/\&quot\;/','"',$Text);
 
        // fix any escaped ampersands that may have been converted into links
-       $Text = preg_replace("/\<(.*?)(src|href)=(.*?)\&amp\;(.*?)\>/ism",'<$1$2=$3&$4>',$Text);
-       $Text = preg_replace("/\<(.*?)(src|href)=\"[^hfm](.*?)\>/ism",'<$1$2="">',$Text);
+       $Text = preg_replace("/\<([^>]*?)(src|href)=(.*?)\&amp\;(.*?)\>/ism",'<$1$2=$3&$4>',$Text);
+       $Text = preg_replace("/\<([^>]*?)(src|href)=\"(?!http|ftp|mailto|cid)(.*?)\>/ism",'<$1$2="">',$Text);
 
        if($saved_image)
                $Text = bb_replace_images($Text, $saved_image);
@@ -652,26 +658,31 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
        // Only do it when it has to be done - for performance reasons
        // Update: Now it is done every time - since bad structured html can break a whole page
        //if (!$tryoembed) {
-               $doc = new DOMDocument();
-               $doc->preserveWhiteSpace = false;
+//             $doc = new DOMDocument();
+//             $doc->preserveWhiteSpace = false;
 
-               $Text = mb_convert_encoding($Text, 'HTML-ENTITIES', "UTF-8");
+//             $Text = mb_convert_encoding($Text, 'HTML-ENTITIES', "UTF-8");
 
-               $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">';
-               @$doc->loadHTML($doctype."<html><body>".$Text."</body></html>");
+//             $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">';
+//             @$doc->loadHTML($doctype."<html><body>".$Text."</body></html>");
 
-               $Text = $doc->saveHTML();
-               $Text = str_replace(array("<html><body>", "</body></html>", $doctype), array("", "", ""), $Text);
+//             $Text = $doc->saveHTML();
+//             $Text = str_replace(array("<html><body>", "</body></html>", $doctype), array("", "", ""), $Text);
 
-               $Text = str_replace('<br></li>','</li>', $Text);
+//             $Text = str_replace('<br></li>','</li>', $Text);
 
-               $Text = mb_convert_encoding($Text, "UTF-8", 'HTML-ENTITIES');
+//             $Text = mb_convert_encoding($Text, "UTF-8", 'HTML-ENTITIES');
        //}
 
+       // Remove all hashtag addresses
+       if (!$tryoembed AND get_config("system", "remove_hashtags_on_export")) {
+               $pattern = '/#<a.*?href="(.*?)".*?>(.*?)<\/a>/is';
+               $Text = preg_replace($pattern, '#$2', $Text);
+       }
+
        call_hooks('bbcode',$Text);
 
        $a->save_timestamp($stamp1, "parser");
 
        return $Text;
 }
-