1 <?php
2 function ubb($string) {
3 $searcharray['bbcode_regexp'] = array(
4 "/\s*\[quote\][\n\r]*(.+?)[\n\r]*\[\/quote\]\s*/is",
5 "/(\[box=(#[0-9A-F]{6}|[a-z]+)\])[\n\r]*(.+?)[\n\r]*(\[\/box\])/is",
6 "/\[url\]\s*(www.|https?:\/\/|ftp:\/\/|gopher:\/\/|news:\/\/|telnet:\/\/|rtsp:\/\/|mms:\/\/){1}([^\[\"']+?)\s*\[\/url\]/ie",
7 "/\[url=www.([^\[\"']+?)\](.+?)\[\/url\]/is",
8 "/\[url=(https?|ftp|gopher|news|telnet|rtsp|mms){1}:\/\/([^\[\"']+?)\](.+?)\[\/url\]/is",
9 "/\[email\]\s*([A-Za-z0-9\-_.]+)@([A-Za-z0-9\-_]+[.][A-Za-z0-9\-_.]+)\s*\[\/email\]/i",
10 "/\[email=([A-Za-z0-9\-_.]+)@([A-Za-z0-9\-_]+[.][A-Za-z0-9\-_.]+)\](.+?)\[\/email\]/is",
11 "/\[color=([^\[]+?)\]/i",
12 "/\[size=([^\[]+?)\]/i",
13 "/\[font=([^\[]+?)\]/i",
14 "/\[align=([^\[]+?)\]/i",
15 "/\[center\]/i",
16 "/\[swf\]\s*([^\[]+?)\s*\[\/swf\]/ies",
17 "/\[img\]\s*([^\[]+?)\s*\[\/img\]/ies",
18 "/\[img=(\d{1,3})[x|\,](\d{1,3})\]\s*([^\[]+?)\s*\[\/img\]/ies"
19 );
20 $replacearray['bbcode_regexp'] = array(
21 "<br><br><center><table border=\"0\" width=\"90%\" cellspacing=\"0\" cellpadding=\"0\"><tr><td> Quote:</td></tr><tr><td><table border=\"0\" width=\"100%\" cellspacing=\"1\" cellpadding=\"10\" bgcolor=\"".BORDERCOLOR."\"><tr><td width=\"100%\" bgcolor=\"".ALTBG2."\" style=\"word-break:break-all\">\\1</td></tr></table></td></tr></table></center><br>",
22 "<blockquote style=\"background-color: \\2 ;\"><span class=\"bold\">$title</span>\\3</blockquote>",
23 "cuturl('\\1\\2')",
24 "<a href=\"http://www.\\1\" target=\"_blank\">\\2</a>",
25 "<a href=\"\\1://\\2\" target=\"_blank\">\\3</a>",
26 "<a href=\"mailto:\\1@\\2\">\\1@\\2</a>",
27 "<a href=\"mailto:\\1@\\2\">\\3</a>",
28 "<font color=\"\\1\">",
29 "<font size=\"\\1\">",
30 "<font face=\"\\1\">",
31 "<p align=\"\\1\">",
32 "<p align=\"center\">",
33 "bbcodeurl('\\1', ' <img src=\"images/attachicons/flash.gif\" align=\"absmiddle\"> <a href=\"%s\" target=\"_blank\">Flash: %s</a> ')",
34 "bbcodeurl('\\1', '<img src=\"%s\" border=\"0\" onload=\"if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt=\'Click here to open new window\';}\" onmouseover=\"if(this.resized) this.style.cursor=\'hand\';\" onclick=\"if(this.resized) {window.open(\'%s\');}\">')",
35 "bbcodeurl('\\3', '<img width=\"\\1\" height=\"\\2\" src=\"%s\" border=\"0\">')"
36 );
37
38 $searcharray['bbcode_str'] = array(
39 '[/color]', '[/size]', '[/font]', '[/align]', '[b]', '[/b]',
40 '[i]', '[/i]', '[u]', '[/u]', '[list]', '[list=1]', '[list=a]',
41 '[list=A]', '[*]', '[/list]','[/center]'
42 );
43
44 $replacearray['bbcode_str'] = array(
45 '</font>', '</font>', '</font>', '</p>', '<b>', '</b>', '<i>',
46 '</i>', '<u>', '</u>', '<ul>', '<ol type=1>', '<ol type=a>',
47 '<ol type=A>', '<li>', '</ul></ol>','</p>'
48 );
49 $string = str_replace($searcharray['bbcode_str'], $replacearray['bbcode_str'], preg_replace($searcharray['bbcode_regexp'], $replacearray['bbcode_regexp'], $string));
50
51 return $string;
52 }
53
54 function bbcodeurl($url, $tags) {
55 if(!preg_match("/<.+?>/s",$url)) {
56 if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'ftp://', 'rtsp:/', 'mms://'))) {
57 $url = 'http://'.$url;
58 }
59 return str_replace('submit', '', sprintf($tags, $url, $url));
60 } else {
61 return ' '.$url;
62 }
63 }
64
65 function cuturl($url) {
66 $length = 65;
67 $urllink = "<a href=\"".(substr(strtolower($url), 0, 4) == 'www.' ? "http://$url" : $url).'" target="_blank">';
68 if(strlen($url) > $length) {
69 $url = substr($url, 0, intval($length * 0.5)).' '.substr($url, - intval($length * 0.3));
70 }
71 $urllink .= $url.'</a>';
72 return $urllink;
73 }
74
75 ?>
76
2 function ubb($string) {
3 $searcharray['bbcode_regexp'] = array(
4 "/\s*\[quote\][\n\r]*(.+?)[\n\r]*\[\/quote\]\s*/is",
5 "/(\[box=(#[0-9A-F]{6}|[a-z]+)\])[\n\r]*(.+?)[\n\r]*(\[\/box\])/is",
6 "/\[url\]\s*(www.|https?:\/\/|ftp:\/\/|gopher:\/\/|news:\/\/|telnet:\/\/|rtsp:\/\/|mms:\/\/){1}([^\[\"']+?)\s*\[\/url\]/ie",
7 "/\[url=www.([^\[\"']+?)\](.+?)\[\/url\]/is",
8 "/\[url=(https?|ftp|gopher|news|telnet|rtsp|mms){1}:\/\/([^\[\"']+?)\](.+?)\[\/url\]/is",
9 "/\[email\]\s*([A-Za-z0-9\-_.]+)@([A-Za-z0-9\-_]+[.][A-Za-z0-9\-_.]+)\s*\[\/email\]/i",
10 "/\[email=([A-Za-z0-9\-_.]+)@([A-Za-z0-9\-_]+[.][A-Za-z0-9\-_.]+)\](.+?)\[\/email\]/is",
11 "/\[color=([^\[]+?)\]/i",
12 "/\[size=([^\[]+?)\]/i",
13 "/\[font=([^\[]+?)\]/i",
14 "/\[align=([^\[]+?)\]/i",
15 "/\[center\]/i",
16 "/\[swf\]\s*([^\[]+?)\s*\[\/swf\]/ies",
17 "/\[img\]\s*([^\[]+?)\s*\[\/img\]/ies",
18 "/\[img=(\d{1,3})[x|\,](\d{1,3})\]\s*([^\[]+?)\s*\[\/img\]/ies"
19 );
20 $replacearray['bbcode_regexp'] = array(
21 "<br><br><center><table border=\"0\" width=\"90%\" cellspacing=\"0\" cellpadding=\"0\"><tr><td> Quote:</td></tr><tr><td><table border=\"0\" width=\"100%\" cellspacing=\"1\" cellpadding=\"10\" bgcolor=\"".BORDERCOLOR."\"><tr><td width=\"100%\" bgcolor=\"".ALTBG2."\" style=\"word-break:break-all\">\\1</td></tr></table></td></tr></table></center><br>",
22 "<blockquote style=\"background-color: \\2 ;\"><span class=\"bold\">$title</span>\\3</blockquote>",
23 "cuturl('\\1\\2')",
24 "<a href=\"http://www.\\1\" target=\"_blank\">\\2</a>",
25 "<a href=\"\\1://\\2\" target=\"_blank\">\\3</a>",
26 "<a href=\"mailto:\\1@\\2\">\\1@\\2</a>",
27 "<a href=\"mailto:\\1@\\2\">\\3</a>",
28 "<font color=\"\\1\">",
29 "<font size=\"\\1\">",
30 "<font face=\"\\1\">",
31 "<p align=\"\\1\">",
32 "<p align=\"center\">",
33 "bbcodeurl('\\1', ' <img src=\"images/attachicons/flash.gif\" align=\"absmiddle\"> <a href=\"%s\" target=\"_blank\">Flash: %s</a> ')",
34 "bbcodeurl('\\1', '<img src=\"%s\" border=\"0\" onload=\"if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt=\'Click here to open new window\';}\" onmouseover=\"if(this.resized) this.style.cursor=\'hand\';\" onclick=\"if(this.resized) {window.open(\'%s\');}\">')",
35 "bbcodeurl('\\3', '<img width=\"\\1\" height=\"\\2\" src=\"%s\" border=\"0\">')"
36 );
37
38 $searcharray['bbcode_str'] = array(
39 '[/color]', '[/size]', '[/font]', '[/align]', '[b]', '[/b]',
40 '[i]', '[/i]', '[u]', '[/u]', '[list]', '[list=1]', '[list=a]',
41 '[list=A]', '[*]', '[/list]','[/center]'
42 );
43
44 $replacearray['bbcode_str'] = array(
45 '</font>', '</font>', '</font>', '</p>', '<b>', '</b>', '<i>',
46 '</i>', '<u>', '</u>', '<ul>', '<ol type=1>', '<ol type=a>',
47 '<ol type=A>', '<li>', '</ul></ol>','</p>'
48 );
49 $string = str_replace($searcharray['bbcode_str'], $replacearray['bbcode_str'], preg_replace($searcharray['bbcode_regexp'], $replacearray['bbcode_regexp'], $string));
50
51 return $string;
52 }
53
54 function bbcodeurl($url, $tags) {
55 if(!preg_match("/<.+?>/s",$url)) {
56 if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'ftp://', 'rtsp:/', 'mms://'))) {
57 $url = 'http://'.$url;
58 }
59 return str_replace('submit', '', sprintf($tags, $url, $url));
60 } else {
61 return ' '.$url;
62 }
63 }
64
65 function cuturl($url) {
66 $length = 65;
67 $urllink = "<a href=\"".(substr(strtolower($url), 0, 4) == 'www.' ? "http://$url" : $url).'" target="_blank">';
68 if(strlen($url) > $length) {
69 $url = substr($url, 0, intval($length * 0.5)).' '.substr($url, - intval($length * 0.3));
70 }
71 $urllink .= $url.'</a>';
72 return $urllink;
73 }
74
75 ?>
76