- // New code
-
- // Looking for the first image
- $image = '';
- if(preg_match("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/is",$b['body'],$matches))
- $image = $matches[3];
-
- if ($image == '')
- if(preg_match("/\[img\](.*?)\[\/img\]/is",$b['body'],$matches))
- $image = $matches[1];
-
- // When saved into the database the content is sent through htmlspecialchars
- // That means that we have to decode all image-urls
- $image = htmlspecialchars_decode($image);
-
- // Checking for a bookmark element
- $body = $b['body'];
- if (strpos($body, "[bookmark") !== false) {
- // splitting the text in two parts:
- // before and after the bookmark
- $pos = strpos($body, "[bookmark");
- $body1 = substr($body, 0, $pos);
- $body2 = substr($body, $pos);
-
- // Removing the bookmark and all quotes after the bookmark
- // they are mostly only the content after the bookmark.
- $body2 = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",'',$body2);
- $body2 = preg_replace("/\[quote\=([^\]]*)\](.*?)\[\/quote\]/ism",'',$body2);
- $body2 = preg_replace("/\[quote\](.*?)\[\/quote\]/ism",'',$body2);
-
- $body = $body1.$body2;
- }
-
- // Convert recycle signs
- $body = str_replace("\t", " ", $body);
- // recycle 1
- $recycle = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8');
- $body = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', "\n\t$2:\t", $body);
- // recycle 2 (Test)
- $recycle = html_entity_decode("◌ ", ENT_QUOTES, 'UTF-8');
- $body = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', "\n\t$2:\t", $body);
-
- // share element
- $body = preg_replace_callback("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]/ism","fbpost_ShareAttributes", $body);
-
- $bodyparts = explode("\t", $body);
- // Doesn't help with multiple repeats - the problem has to be solved later
- if (sizeof($bodyparts) == 3) {
- $html = bbcode($bodyparts[2], false, false);
- $test = trim(html2plain($html, 0, true));
-
- if (trim($bodyparts[0]) == "")
- $body = trim($bodyparts[2]);
- else if (trim($test) == "")
- $body = trim($bodyparts[0]);
- else
- $body = trim($bodyparts[0])."\n\n".trim($bodyparts[1])."[quote]".trim($bodyparts[2])."[/quote]";
- } else
- $body = str_replace("\t", "", $body);