]> git.mxchange.org Git - friendica.git/blobdiff - include/bbcode.php
set writable flag on dfrn_poll
[friendica.git] / include / bbcode.php
index 4caf187666852b26739f815366e86453b2cc89ce..6fadbaf7eb4d81536c4a8cecb917c36d45e76eb7 100644 (file)
@@ -3,7 +3,7 @@ require_once("include/oembed.php");
        // BBcode 2 HTML was written by WAY2WEB.net
        // extended to work with Mistpark/Friendika - Mike Macgirvin
 
-function bbcode($Text) {
+function bbcode($Text,$preserve_nl = false) {
 
        // Replace any html brackets with HTML Entities to prevent executing HTML or script
        // Don't use strip_tags here because it breaks [url] search by replacing & with amp
@@ -12,7 +12,10 @@ function bbcode($Text) {
        $Text = str_replace(">", ">", $Text);
 
        // Convert new line chars to html <br /> tags
+
        $Text = nl2br($Text);
+       if($preserve_nl)
+               $Text = str_replace(array("\n","\r"), array('',''),$Text);
 
        // Set up the parameters for a URL search string
        $URLSearchString = "^\[\]";
@@ -22,7 +25,7 @@ function bbcode($Text) {
        // Perform URL Search
 
 
-       $Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%\$\!\+]+)/", ' <a href="$2" target="external-link">$2</a>', $Text);
+       $Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%\$\!\+\,]+)/", ' <a href="$2" target="external-link">$2</a>', $Text);
 
        $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '<a href="$1" target="external-link">$1</a>', $Text);
        $Text = preg_replace("(\[url\=([$URLSearchString]*)\](.+?)\[/url\])", '<a href="$1" target="external-link">$2</a>', $Text);