function post_html_clean($str) { global $phpbb_root_path, $phpbb_home, $mobiquo_config; $search = array("/<a .*?href=\"(.*?)\".*?>(.*?)<\\/a>/si", "/<img .*?src=\"(.*?)\".*?\\/?>/sei", "/<br\\s*\\/?>|<\\/cite>/si", "/<object .*?data=\"(http:\\/\\/www\\.youtube\\.com\\/.*?)\" .*?>.*?<\\/object>/si", "/<object .*?data=\"(http:\\/\\/video\\.google\\.com\\/.*?)\" .*?>.*?<\\/object>/si"); $replace = array('[url=$1]$2[/url]', "'[img]'.url_encode('\$1').'[/img]'", "\n", '[url=$1]YouTube Video[/url]', '[url=$1]Google Video[/url]'); $str = preg_replace('/\\n|\\r/si', '', $str); // remove smile $str = preg_replace('/<img [^>]*?src=\\"[^"]*?images\\/smilies\\/[^"]*?\\"[^>]*?alt=\\"([^"]*?)\\"[^>]*?\\/?>/', '$1', $str); $str = preg_replace('/<img [^>]*?alt=\\"([^"]*?)\\"[^>]*?src=\\"[^"]*?images\\/smilies\\/[^"]*?\\"[^>]*?\\/?>/', '$1', $str); $str = preg_replace('/<null.*?\\/>/', '', $str); $str = preg_replace($search, $replace, $str); $str = strip_tags($str); $str = html_entity_decode($str, ENT_QUOTES, 'UTF-8'); // change relative path to absolute URL $str = preg_replace('/\\[img\\]\\.\\.\\/(.*?)\\[\\/img\\]/si', "[img]{$phpbb_home}/\$1[/img]", $str); $str = preg_replace('#\\[img\\]' . addslashes($phpbb_root_path) . '(.*?)\\[/img\\]#si', "[img]{$phpbb_home}\$1[/img]", $str); // remove link on img $str = preg_replace('/\\[url=[^\\]]*?\\]\\s*(\\[img\\].*?\\[\\/img\\])\\s*\\[\\/url\\]/si', '$1', $str); // cut quote content to 100 charactors if ($mobiquo_config['shorten_quote']) { $str = cut_quote($str, 100); } return parse_bbcode($str); }
function post_html_clean($str) { global $phpbb_root_path, $phpbb_home, $mobiquo_config, $config; $search = array("/<strong>(.*?)<\\/strong>/si", "/<em>(.*?)<\\/em>/si", "/<img .*?src=\"(.*?)\".*?\\/?>/si", "/<a .*?href=\"(.*?)\"(.*?)?>(.*?)<\\/a>/sei", "/<br\\s*\\/?>|<\\/cite>|<\\/dt>|<\\/dd>/si", "/<object .*?data=\"(http:\\/\\/www\\.youtube\\.com\\/.*?)\" .*?>.*?<\\/object>/si", "/<object .*?data=\"(http:\\/\\/video\\.google\\.com\\/.*?)\" .*?>.*?<\\/object>/si", "/<iframe .*?src=\"(http.*?)\" .*?>.*?<\\/iframe>/si", "/<script( [^>]*)?>([^<]*?)<\\/script>/si", "/<param name=\"movie\" value=\"(.*?)\" \\/>/si"); $replace = array('[b]$1[/b]', '[i]$1[/i]', '[img]$1[/img]', "'[url='.url_encode('\$1').']\$3[/url]'", "\n", '[url=$1]YouTube Video[/url]', '[url=$1]Google Video[/url]', '[url=$1]$1[/url]', '', '[url=$1]Flash Video[/url]'); $str = preg_replace('/\\n|\\r/si', '', $str); $str = preg_replace('/>\\s+</si', '><', $str); // remove smile $str = preg_replace('/<img [^>]*?src=\\"[^"]*?images\\/smilies\\/[^"]*?\\"[^>]*?alt=\\"([^"]*?)\\"[^>]*?\\/?>/', '$1', $str); $str = preg_replace('/<img [^>]*?alt=\\"([^"]*?)\\"[^>]*?src=\\"[^"]*?images\\/smilies\\/[^"]*?\\"[^>]*?\\/?>/', '$1', $str); $str = preg_replace('/<null.*?\\/>/', '', $str); $str = preg_replace($search, $replace, $str); $str = strip_tags($str); $str = html_entity_decode($str, ENT_QUOTES, 'UTF-8'); // remove attach icon image $str = preg_replace('/\\[img\\][^\\[\\]]+icon_topic_attach\\.gif\\[\\/img\\]/si', '', $str); // change relative path to absolute URL and encode url $str = preg_replace('/\\[img\\](.*?)\\[\\/img\\]/sei', "'[img]'.url_encode('\$1').'[/img]'", $str); $str = preg_replace('/\\[\\/img\\]\\s*/si', "[/img]\n", $str); $str = preg_replace('/\\[\\/img\\]\\s+\\[img\\]/si', '[/img][img]', $str); // remove link on img //$str = preg_replace('/\[url=[^\]]*?\]\s*(\[img\].*?\[\/img\])\s*\[\/url\]/si', '$1', $str); // change url to image resource to img bbcode $str = preg_replace('/\\[url\\](http[^\\[\\]]+\\.(jpg|png|bmp|gif))\\[\\/url\\]/si', '[img]$1[/img]', $str); $str = preg_replace('/\\[url=(http[^\\]]+\\.(jpg|png|bmp|gif))\\]([^\\[\\]]+)\\[\\/url\\]/si', '[img]$1[/img]', $str); // cut quote content to 100 charactors if (isset($mobiquo_config['shorten_quote']) && $mobiquo_config['shorten_quote']) { $str = cut_quote($str, 100); } return parse_bbcode($str); }