%s', $url, $title);
else {
$text = sprintf('', $type);
$bookmark = array(sprintf('[bookmark=%s]%s[/bookmark]', $url, $title), $title, $url);
if ($tryoembed)
$oembed = tryoembed($bookmark);
else
$oembed = $bookmark[0];
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 .= sprintf('%s
', trim($match[2]));
}
return($text);
},$Text);
return($Text);
}
function bb_rearrange_link($shared) {
if ($shared[1] != "type-link")
return($shared[0]);
$newshare = trim($shared[2]);
$newshare = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $newshare);
if (!strpos($shared[0], "[bookmark"))
$newshare = preg_replace("/\[url\=(.*?)\](.*?)\[\/url\]/ism", '[bookmark=$1]$2[/bookmark]', $newshare, 1);
preg_match("/\[img\](.*?)\[\/img\]/ism", $newshare, $matches);
if ($matches) {
$newshare = str_replace($matches[0], '', $newshare);
$newshare = "[img]".$matches[1]."[/img]\n".$newshare;
}
$search = array("\n\n", "\n ", " \n");
$replace = array("\n", "\n", "\n");
do {
$oldtext = $newshare;
$newshare = str_replace($search, $replace, $newshare);
} while ($oldtext != $newshare);
$newshare = "[class=type-link]".$newshare."[/class]";
return($newshare);
}
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, $plaintext, $nolink) {
if (!in_array($shared[2], array("type-link", "type-video")))
return($shared[0]);
if ($plaintext)
$shared[3] = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism","[bookmark=$1]$1[/bookmark]", $shared[3]);
if (!preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$shared[3], $bookmark))
return($shared[0]);
if ($nolink)
return(trim($shared[1]));
$title = "";
$link = "";
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]);
if (($text == "") AND ($title != "") AND ($link == ""))
$text .= "\n\n".trim($title);
if (($link != "") AND ($title != ""))
$text .= "\n[url=".trim($link)."]".trim($title)."[/url]";
elseif (($link != ""))
$text .= "\n".trim($link);
return(trim($text));
}
function bb_cleanstyle($st) {
return "".$st[2]."";
}
function bb_cleanclass($st) {
return "".$st[2]."";
}
function cleancss($input) {
$cleaned = "";
$input = strtolower($input);
for ($i = 0; $i < strlen($input); $i++) {
$char = substr($input, $i, 1);
if (($char >= "a") and ($char <= "z"))
$cleaned .= $char;
if (!(strpos(" #;:0123456789-_", $char) === false))
$cleaned .= $char;
}
return($cleaned);
}
function stripcode_br_cb($s) {
return '[code]' . str_replace('
', '', $s[1]) . '[/code]';
}
function tryoembed($match){
$url = ((count($match)==2)?$match[1]:$match[2]);
// Always embed the SSL version
$url = str_replace(array("http://www.youtube.com/", "http://player.vimeo.com/"),
array("https://www.youtube.com/", "https://player.vimeo.com/"), $url);
//logger("tryoembed: $url");
$o = oembed_fetch_url($url);
//echo "
"; var_dump($match, $url, $o); killme(); if ($o->type=="error") return $match[0]; $html = oembed_format_object($o); return $html; //oembed_iframe($html,$o->width,$o->height); } // [noparse][i]italic[/i][/noparse] turns into // [noparse][ i ]italic[ /i ][/noparse], // to hide them from parser. function bb_spacefy($st) { $whole_match = $st[0]; $captured = $st[1]; $spacefied = preg_replace("/\[(.*?)\]/", "[ $1 ]", $captured); $new_str = str_replace($captured, $spacefied, $whole_match); return $new_str; } // The previously spacefied [noparse][ i ]italic[ /i ][/noparse], // now turns back and the [noparse] tags are trimed // returning [i]italic[/i] function bb_unspacefy_and_trim($st) { $whole_match = $st[0]; $captured = $st[1]; $unspacefied = preg_replace("/\[ (.*?)\ ]/", "[$1]", $captured); return $unspacefied; } function bb_find_open_close($s, $open, $close, $occurance = 1) { if($occurance < 1) $occurance = 1; $start_pos = -1; for($i = 1; $i <= $occurance; $i++) { if( $start_pos !== false) $start_pos = strpos($s, $open, $start_pos + 1); } if( $start_pos === false) return false; $end_pos = strpos($s, $close, $start_pos); if( $end_pos === false) return false; $res = array( 'start' => $start_pos, 'end' => $end_pos ); return $res; } function get_bb_tag_pos($s, $name, $occurance = 1) { if($occurance < 1) $occurance = 1; $start_open = -1; for($i = 1; $i <= $occurance; $i++) { if( $start_open !== false) $start_open = strpos($s, '[' . $name, $start_open + 1); // allow [name= type tags } if( $start_open === false) return false; $start_equal = strpos($s, '=', $start_open); $start_close = strpos($s, ']', $start_open); if( $start_close === false) return false; $start_close++; $end_open = strpos($s, '[/' . $name . ']', $start_close); if( $end_open === false) return false; $res = array( 'start' => array('open' => $start_open, 'close' => $start_close), 'end' => array('open' => $end_open, 'close' => $end_open + strlen('[/' . $name . ']')) ); if( $start_equal !== false) $res['start']['equal'] = $start_equal + 1; return $res; } function bb_tag_preg_replace($pattern, $replace, $name, $s) { $string = $s; $occurance = 1; $pos = get_bb_tag_pos($string, $name, $occurance); while($pos !== false && $occurance < 1000) { $start = substr($string, 0, $pos['start']['open']); $subject = substr($string, $pos['start']['open'], $pos['end']['close'] - $pos['start']['open']); $end = substr($string, $pos['end']['close']); if($end === false) $end = ''; $subject = preg_replace($pattern, $replace, $subject); $string = $start . $subject . $end; $occurance++; $pos = get_bb_tag_pos($string, $name, $occurance); } return $string; } if(! function_exists('bb_extract_images')) { function bb_extract_images($body) { $saved_image = array(); $orig_body = $body; $new_body = ''; $cnt = 0; $img_start = strpos($orig_body, '[img'); $img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false); $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false); while(($img_st_close !== false) && ($img_end !== false)) { $img_st_close++; // make it point to AFTER the closing bracket $img_end += $img_start; if(! strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) { // This is an embedded image $saved_image[$cnt] = substr($orig_body, $img_start + $img_st_close, $img_end - ($img_start + $img_st_close)); $new_body = $new_body . substr($orig_body, 0, $img_start) . '[$#saved_image' . $cnt . '#$]'; $cnt++; } else $new_body = $new_body . substr($orig_body, 0, $img_end + strlen('[/img]')); $orig_body = substr($orig_body, $img_end + strlen('[/img]')); if($orig_body === false) // in case the body ends on a closing image tag $orig_body = ''; $img_start = strpos($orig_body, '[img'); $img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false); $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false); } $new_body = $new_body . $orig_body; return array('body' => $new_body, 'images' => $saved_image); }} if(! function_exists('bb_replace_images')) { function bb_replace_images($body, $images) { $newbody = $body; $cnt = 0; foreach($images as $image) { // 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 . '#$]', '', $newbody); $cnt++; } return $newbody; }} /* function bb_ShareAttributes($match) { $attributes = $match[1]; $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]; $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]; $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]; $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]; $posted = ""; $itemcache = get_config("system","itemcache"); // relative dates only make sense when they aren't cached if ($itemcache == "") { preg_match("/posted='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") $posted = $matches[1]; preg_match('/posted="(.*?)"/ism', $attributes, $matches); if ($matches[1] != "") $posted = $matches[1]; $reldate = (($posted) ? " " . relative_date($posted) : ''); } $headline = '