55) ? substr($url, 0 , 39).'...'.substr($url, -10) : $url) : stripslashes($link); if ($bbcode){ if ($full_url == $link) return '[url]'.$link.'[/url]'; else return '[url='.$full_url.']'.$link.'[/url]'; } else return ''.$link.''; } function handle_img_tag($url, $is_signature = false, $alt = null) { if ($alt == null) $alt = $url; $img_tag = ''; return $img_tag; } function do_bbcode($text){ $pattern = $replace = $patterns_and_callbacks = array(); $text=nl2br($text); if (strpos($text, '[quote') !== false){ $text = preg_replace_callback('#\[quote=("|"|\'|)(.*?)\\1\]#', function($matches) { return "
"; }, $text); $text = preg_replace('#\[quote\]\s*#', '
', $text); $text = preg_replace('#\s*\[\/quote\]#', '
', $text); } $patterns_and_callbacks['#\[img\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#'] = function($matches){ return handle_img_tag($matches[1].$matches[3], false); }; $patterns_and_callbacks['#\[img=([^\[]*?)\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#'] = function($matches){ return handle_img_tag($matches[2].$matches[4], false, $matches[1]); }; $pattern[] = '#\[b\](.*?)\[/b\]#ms'; $pattern[] = '#\[i\](.*?)\[/i\]#ms'; $pattern[] = '#\[u\](.*?)\[/u\]#ms'; $pattern[] = '#\[code\](.*?)\[/code\]#ms'; $pattern[] = '#\[colou?r=([a-zA-Z]{3,20}|\#[0-9a-fA-F]{6}|\#[0-9a-fA-F]{3})](.*?)\[/colou?r\]#ms'; $pattern[] = '#\[h\](.*?)\[/h\]#ms'; $replace[] = '$1'; $replace[] = '$1'; $replace[] = '$1'; $replace[] = '
$1'; $replace[] = '$2'; $replace[] = '$1
'; $patterns_and_callbacks['#\[url\]([^\[]*?)\[/url\]#'] = function($matches){ return handle_url_tag($matches[1]); }; $patterns_and_callbacks['#\[url=([^\[]+?)\](.*?)\[/url\]#'] = function($matches){ return handle_url_tag($matches[1], $matches[2]); }; $pattern[] = '#\[email\]([^\[]*?)\[/email\]#'; $pattern[] = '#\[email=([^\[]+?)\](.*?)\[/email\]#'; $replace[] = '$1'; $replace[] = '$2'; $pattern[] = '#\[red\](.*?)\[/red\]#ms'; $pattern[] = '#\[li\](.*?)\[/li\]#ms'; $replace[] = '$1'; $replace[] = '
$1 '; $text = preg_replace($pattern, $replace, $text); if (function_exists("preg_replace_callback_array")) { // Cette fonction n'arrive qu'en PHP7 $text = preg_replace_callback_array($patterns_and_callbacks, $text); } else { foreach ($patterns_and_callbacks as $pat => $callback) { $text = preg_replace_callback($pat, $callback, $text); } } return $text; } ?>