diff --git a/include/bbcode.php b/include/bbcode.php
index 23949d24be..4c2d6e547c 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -6,73 +6,84 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
$Text = preg_replace_callback("/\[attachment(.*?)\](.*?)\[\/attachment\]/ism",
function ($match) use ($plaintext){
- $attributes = $match[1];
+ $attributes = $match[1];
- $type = "";
- preg_match("/type='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
- $type = $matches[1];
+ $type = "";
+ preg_match("/type='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $type = $matches[1];
- preg_match('/type="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
- $type = $matches[1];
+ preg_match('/type="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $type = $matches[1];
- if ($type == "")
- return($match[0]);
+ if ($type == "")
+ return($match[0]);
- if (!in_array($type, array("link", "audio", "video")))
- return($match[0]);
+ if (!in_array($type, array("link", "audio", "video")))
+ return($match[0]);
- $url = "";
- preg_match("/url='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
- $url = $matches[1];
+ $url = "";
+ preg_match("/url='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $url = $matches[1];
- preg_match('/url="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
- $url = $matches[1];
+ preg_match('/url="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $url = $matches[1];
- $title = "";
- preg_match("/title='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
- $title = $matches[1];
+ $title = "";
+ preg_match("/title='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $title = $matches[1];
- preg_match('/title="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
- $title = $matches[1];
+ preg_match('/title="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $title = $matches[1];
- $image = "";
- preg_match("/image='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
- $image = $matches[1];
+ $image = "";
+ preg_match("/image='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $image = $matches[1];
- preg_match('/image="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
- $image = $matches[1];
+ preg_match('/image="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $image = $matches[1];
+
+ $preview = "";
+ preg_match("/preview='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $preview = $matches[1];
+
+ preg_match('/preview="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $preview = $matches[1];
if ($plaintext)
$text = sprintf('%s', $url, $title);
else {
- $text = sprintf('', $type);
+ $text = sprintf('', $type);
- $bookmark = array(sprintf('[bookmark=%s]%s[/bookmark]', $url, $title), $title, $url);
+ $bookmark = array(sprintf('[bookmark=%s]%s[/bookmark]', $url, $title), $title, $url);
if ($tryoembed)
- $oembed = tryoembed($bookmark);
+ $oembed = tryoembed($bookmark);
else
$oembed = $bookmark[0];
- if (($image != "") AND !strstr(strtolower($oembed), "', $image, $title); // To-Do: Anführungszeichen in "alt"
+ if (($image != "") AND !strstr(strtolower($oembed), "', $image, $title); // To-Do: Anführungszeichen in "alt"
+ elseif (($preview != "") AND !strstr(strtolower($oembed), "', $preview, $title); // To-Do: Anführungszeichen in "alt"
- $text .= $oembed;
+ $text .= $oembed;
- $text .= sprintf('%s
', trim($match[2]));
+ $text .= sprintf('%s
', trim($match[2]));
}
- return($text);
+ return($text);
},$Text);
- return($Text);
+ return($Text);
}
function bb_rearrange_link($shared) {
@@ -104,37 +115,43 @@ function bb_rearrange_link($shared) {
return($newshare);
}
-function bb_remove_share_information($Text, $plaintext = false) {
- if ($plaintext)
- $Text = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism","[bookmark=$1]$1[/bookmark]", $Text);
-
- $Text = preg_replace_callback("((.*?)\[class=(.*?)\](.*?)\[\/class\])ism","bb_cleanup_share",$Text);
- return($Text);
+function bb_remove_share_information($Text, $plaintext = false, $nolink = false) {
+ $Text = preg_replace_callback("((.*?)\[class=(.*?)\](.*?)\[\/class\])ism",
+ function ($match) use ($plaintext, $nolink){
+ return(bb_cleanup_share($match, $plaintext, $nolink));
+ },$Text);
+ return($Text);
}
-function bb_cleanup_share($shared) {
+function bb_cleanup_share($shared, $plaintext, $nolink) {
if (!in_array($shared[2], array("type-link", "type-video")))
- return($shared[0]);
+ return($shared[0]);
- if (!preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$shared[3], $bookmark))
- return($shared[0]);
+ if ($plaintext)
+ $shared[3] = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism","[bookmark=$1]$1[/bookmark]", $shared[3]);
- $title = "";
- $link = "";
+ if (!preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$shared[3], $bookmark))
+ return($shared[0]);
- if (isset($bookmark[2][0]))
- $title = $bookmark[2][0];
+ if ($nolink)
+ return(trim($shared[1]));
- if (isset($bookmark[1][0]))
- $link = $bookmark[1][0];
+ $title = "";
+ $link = "";
- if (strpos($shared[1],$title) !== false)
- $title = "";
+ if (isset($bookmark[2][0]))
+ $title = $bookmark[2][0];
+
+ if (isset($bookmark[1][0]))
+ $link = $bookmark[1][0];
+
+ if (strpos($shared[1],$title) !== false)
+ $title = "";
// if (strpos($shared[1],$link) !== false)
// $link = "";
- $text = trim($shared[1]);
+ $text = trim($shared[1]);
if (($text == "") AND ($title != "") AND ($link == ""))
$text .= "\n\n".trim($title);
@@ -144,7 +161,7 @@ function bb_cleanup_share($shared) {
elseif (($link != ""))
$text .= "\n".trim($link);
- return(trim($text));
+ return(trim($text));
}
@@ -274,7 +291,7 @@ function get_bb_tag_pos($s, $name, $occurance = 1) {
return false;
$res = array( 'start' => array('open' => $start_open, 'close' => $start_close),
- 'end' => array('open' => $end_open, 'close' => $end_open + strlen('[/' . $name . ']')) );
+ 'end' => array('open' => $end_open, 'close' => $end_open + strlen('[/' . $name . ']')) );
if( $start_equal !== false)
$res['start']['equal'] = $start_equal + 1;
@@ -364,45 +381,46 @@ function bb_replace_images($body, $images) {
return $newbody;
}}
+/*
function bb_ShareAttributes($match) {
- $attributes = $match[1];
+ $attributes = $match[1];
- $author = "";
- preg_match("/author='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
- $author = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
+ $author = "";
+ preg_match("/author='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $author = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
- preg_match('/author="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
- $author = $matches[1];
+ preg_match('/author="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $author = $matches[1];
- $link = "";
- preg_match("/link='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
- $link = $matches[1];
+ $link = "";
+ preg_match("/link='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $link = $matches[1];
- preg_match('/link="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
- $link = $matches[1];
+ preg_match('/link="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $link = $matches[1];
- $avatar = "";
- preg_match("/avatar='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
- $avatar = $matches[1];
+ $avatar = "";
+ preg_match("/avatar='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $avatar = $matches[1];
- preg_match('/avatar="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
- $avatar = $matches[1];
+ preg_match('/avatar="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $avatar = $matches[1];
- $profile = "";
- preg_match("/profile='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
- $profile = $matches[1];
+ $profile = "";
+ preg_match("/profile='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $profile = $matches[1];
- preg_match('/profile="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
- $profile = $matches[1];
+ preg_match('/profile="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $profile = $matches[1];
$posted = "";
@@ -422,57 +440,57 @@ function bb_ShareAttributes($match) {
}
$headline = '
'.trim($match[3])."
'.trim($share[3])."
'.trim($share[3])."
'.trim($share[3]).""; + break; + } + return($text); } function GetProfileUsername($profile, $username) { @@ -687,6 +823,13 @@ function bb_RemovePictureLinks($match) { return($text); } +function bb_expand_links($match) { + if (stristr($match[2], $match[3]) OR ($match[2] == $match[3])) + return ($match[1]."[url]".$match[2]."[/url]"); + else + return ($match[1].$match[3]." [url]".$match[2]."[/url]"); +} + function bb_CleanPictureLinksSub($match) { $text = Cache::get($match[1]); @@ -836,8 +979,9 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal $Text = preg_replace("/#\[url\=[$URLSearchString]*\]\^\[\/url\]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/i", "[bookmark=$1]$2[/bookmark]", $Text); - if ($simplehtml == 2) { - $Text = preg_replace("/[^#@]\[url\=([^\]]*)\](.*?)\[\/url\]/ism",' $2 [url]$1[/url]',$Text); + if (in_array($simplehtml, array(2, 6))) { + $Text = preg_replace_callback("/([^#@])\[url\=([^\]]*)\](.*?)\[\/url\]/ism","bb_expand_links",$Text); + //$Text = preg_replace("/[^#@]\[url\=([^\]]*)\](.*?)\[\/url\]/ism",' $2 [url]$1[/url]',$Text); $Text = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",' $2 [url]$1[/url]',$Text); } @@ -901,7 +1045,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal $Text = preg_replace("(\[color=(.*?)\](.*?)\[\/color\])ism","$2",$Text); // Check for sized text - // [size=50] --> font-size: 50px (with the unit). + // [size=50] --> font-size: 50px (with the unit). $Text = preg_replace("(\[size=(\d*?)\](.*?)\[\/size\])ism","$2",$Text); $Text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])ism","$2",$Text); @@ -917,7 +1061,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal // Check for CSS classes $Text = preg_replace_callback("(\[class=(.*?)\](.*?)\[\/class\])ism","bb_cleanclass",$Text); - // handle nested lists + // handle nested lists $endlessloop = 0; while ((((strpos($Text, "[/list]") !== false) && (strpos($Text, "[list") !== false)) || @@ -978,8 +1122,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal $endlessloop = 0; while ((strpos($Text, "[/spoiler]")!== false) and (strpos($Text, "[spoiler=") !== false) and (++$endlessloop < 20)) $Text = preg_replace("/\[spoiler=[\"\']*(.*?)[\"\']*\](.*?)\[\/spoiler\]/ism", - "
$2", - $Text); + "
$2", + $Text); // Declare the format for [quote] layout $QuoteLayout = '
$1'; @@ -998,8 +1142,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal $endlessloop = 0; while ((strpos($Text, "[/quote]")!== false) and (strpos($Text, "[quote=") !== false) and (++$endlessloop < 20)) $Text = preg_replace("/\[quote=[\"\']*(.*?)[\"\']*\](.*?)\[\/quote\]/ism", - "
$2", - $Text); + "
$2", + $Text); // [img=widthxheight]image source[/img] //$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '', $Text); @@ -1012,6 +1156,11 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '', $Text); // Shared content + $Text = preg_replace_callback("/(.*?)\[share(.*?)\](.*?)\[\/share\]/ism", + function ($match) use ($simplehtml){ + return(bb_ShareAttributes($match, $simplehtml)); + },$Text); +/* if (!$simplehtml) $Text = preg_replace_callback("/\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributes",$Text); elseif ($simplehtml == 1) @@ -1022,6 +1171,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal $Text = preg_replace_callback("/(.*?)\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributesDiaspora",$Text); elseif ($simplehtml == 4) $Text = preg_replace_callback("/(.*?)\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributesForExport",$Text); +*/ $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'