| 1 |
djmaze |
1.1 |
<?php |
| 2 |
djmaze |
1.1 |
/********************************************* |
| 3 |
djmaze |
9.12 |
CPG Dragonfly™ CMS |
| 4 |
djmaze |
1.1 |
******************************************** |
| 5 |
nanocaio |
9.38 |
Copyright © 2004 - 2007 by CPG-Nuke Dev Team |
| 6 |
djmaze |
9.27 |
http://dragonflycms.org |
| 7 |
djmaze |
1.1 |
  |
| 8 |
djmaze |
8.41 |
Dragonfly is released under the terms and conditions |
| 9 |
djmaze |
8.13 |
of the GNU GPL version 2 or any later version |
| 10 |
djmaze |
1.1 |
  |
| 11 |
djmaze |
9.13 |
$Source: /cvs/html/includes/nbbcode.php,v $ |
| 12 |
djmaze |
10.0 |
$Revision: 9.60 $ |
| 13 |
djmaze |
10.0 |
$Author: nanocaiordo $ |
| 14 |
djmaze |
10.0 |
$Date: 2010/07/08 10:46:56 $ |
| 15 |
djmaze |
8.41 |
**********************************************/ |
| 16 |
trevor |
8.22 |
if (!defined('CPG_NUKE')) { exit; } |
| 17 |
djmaze |
1.1 |
  |
| 18 |
akamu |
9.22 |
  |
| 19 |
akamu |
9.22 |
global $db, $prefix, $smilies_path, $bbbttns_path, $BASEHREF, $CPG_SESS, $bb_codes, $smilies_close, $bbcode_common; |
| 20 |
akamu |
9.22 |
  |
| 21 |
djmaze |
9.32 |
$smilies_path = file_exists("themes/$CPG_SESS[theme]/images/smiles/icon_smile.gif") ? "themes/$CPG_SESS[theme]/images/smiles/" : 'images/smiles/'; |
| 22 |
djmaze |
9.31 |
$bbbttns_path = file_exists("themes/$CPG_SESS[theme]/images/bbcode/b.gif") ? "themes/$CPG_SESS[theme]/images/bbcode/" : 'themes/default/images/bbcode/'; |
| 23 |
djmaze |
1.1 |
  |
| 24 |
djmaze |
8.10 |
get_lang('bbcode'); |
| 25 |
djmaze |
1.16 |
  |
| 26 |
nanocaio |
9.53 |
$bb_codes['quote'] = '<div class="genmed"><b>'.$bbcode_common['quote'][0].':</b></div> |
| 27 |
estlane |
9.56 |
<div class="quote">'; |
| 28 |
nanocaio |
9.53 |
$bb_codes['quote_name'] = '<div class="genmed"><b>\\1 '.$bbcode_common['Wrote'].':</b></div> |
| 29 |
estlane |
9.56 |
<div class="quote">'; |
| 30 |
nanocaio |
9.53 |
$bb_codes['quote_close'] = '</div>'; |
| 31 |
nanocaio |
9.53 |
$bb_codes['code_start'] = '<div class="genmed"><b>'.$bbcode_common['code'][0].':</b></div> |
| 32 |
estlane |
9.56 |
<div class="code"><code>'; |
| 33 |
nanocaio |
9.53 |
$bb_codes['code_end'] = '</code></div>'; |
| 34 |
phoenix |
9.47 |
$bb_codes['php_start'] = '<table border="0" style="margin:auto;" width="90%" cellpadding="3" cellspacing="1"><tr> |
| 35 |
estlane |
9.56 |
<td><span class="genmed"><b>PHP:</b></span></td> |
| 36 |
djmaze |
9.12 |
</tr><tr> |
| 37 |
estlane |
9.56 |
<td class="code">'; |
| 38 |
djmaze |
8.31 |
$bb_codes['php_end'] = '</td></tr></table>'; |
| 39 |
djmaze |
8.31 |
$bb_codes['win_start'] = '<html> |
| 40 |
djmaze |
8.31 |
<head> |
| 41 |
djmaze |
8.31 |
<title>Smiley Selection</title> |
| 42 |
djmaze |
8.31 |
<base href="'.$BASEHREF.'" /> |
| 43 |
djmaze |
8.31 |
<link rel="stylesheet" href="themes/'.$CPG_SESS['theme'].'/style/style.css" type="text/css" /> |
| 44 |
djmaze |
8.31 |
</head> |
| 45 |
djmaze |
8.31 |
<body> |
| 46 |
phoenix |
9.40 |
<script type="text/javascript"> |
| 47 |
djmaze |
8.31 |
<!-- |
| 48 |
djmaze |
8.31 |
function emoticon(form, field, text) { |
| 49 |
estlane |
9.56 |
text = \' \' + text + \' \'; |
| 50 |
estlane |
9.56 |
if (opener.document.forms[form].elements[field].createTextRange && opener.document.forms[form].elements[field].caretPos) { |
| 51 |
estlane |
9.56 |
var caretPos = opener.document.forms[form].elements[field].caretPos; |
| 52 |
estlane |
9.56 |
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == \' \' ? text + \' \' : text; |
| 53 |
estlane |
9.56 |
opener.document.forms[form].elements[field].focus(); |
| 54 |
estlane |
9.56 |
} else { |
| 55 |
estlane |
9.56 |
opener.document.forms[form].elements[field].value += text; |
| 56 |
estlane |
9.56 |
opener.document.forms[form].elements[field].focus(); |
| 57 |
estlane |
9.56 |
} |
| 58 |
djmaze |
8.31 |
} |
| 59 |
djmaze |
8.31 |
//--> |
| 60 |
djmaze |
8.31 |
</script>'; |
| 61 |
djmaze |
9.12 |
$bb_codes['win_end'] = '<br /> |
| 62 |
phoenix |
9.47 |
<div style="text-align:center;"><a href="javascript:window.close();" class="genmed">'.$smilies_close.'</a></div> |
| 63 |
djmaze |
8.31 |
</body></html>'; |
| 64 |
djmaze |
8.31 |
if (file_exists('themes/'.$CPG_SESS['theme'].'/bbcode.inc')) { |
| 65 |
estlane |
9.56 |
include('themes/'.$CPG_SESS['theme'].'/bbcode.inc'); |
| 66 |
djmaze |
8.27 |
} |
| 67 |
djmaze |
8.27 |
  |
| 68 |
djmaze |
1.1 |
function get_code_lang($var, $array) { |
| 69 |
estlane |
9.56 |
return (isset($array[$var])) ? $array[$var] : $var; |
| 70 |
djmaze |
1.1 |
} |
| 71 |
djmaze |
1.1 |
  |
| 72 |
djmaze |
1.1 |
function smilies_table($mode, $field='message', $form='post') |
| 73 |
djmaze |
1.1 |
{ |
| 74 |
estlane |
9.56 |
global $bb_codes, $db, $prefix, $smilies_path, $MAIN_CFG, $CPG_SESS; |
| 75 |
estlane |
9.56 |
global $smilies_more, $smilies_desc; |
| 76 |
estlane |
9.56 |
$url = $MAIN_CFG['server']['path'].URL::index("smilies&field=$field&form=$form"); |
| 77 |
estlane |
9.56 |
  |
| 78 |
estlane |
9.56 |
$inline_cols = 4; |
| 79 |
estlane |
9.56 |
$inline_rows = 5; |
| 80 |
estlane |
9.56 |
$window_cols = 8; |
| 81 |
estlane |
9.56 |
  |
| 82 |
estlane |
9.56 |
$content = ''; |
| 83 |
estlane |
9.56 |
if ($mode == 'window') { |
| 84 |
estlane |
9.56 |
$content = $bb_codes['win_start']; |
| 85 |
estlane |
9.56 |
} else if (!defined('BBCODE_JS_ACTIVE')) { |
| 86 |
estlane |
9.56 |
$content .= '<script src="includes/javascript/bbcode.js" type="text/javascript"></script>'; |
| 87 |
estlane |
9.56 |
define('BBCODE_JS_ACTIVE', 1); |
| 88 |
estlane |
9.56 |
} |
| 89 |
estlane |
9.56 |
if ($mode == 'onerow') { |
| 90 |
estlane |
9.56 |
$content .= ' |
| 91 |
djmaze |
8.20 |
<table width="450" border="0" cellspacing="0" cellpadding="0" class="forumline">'; |
| 92 |
estlane |
9.56 |
} else { |
| 93 |
estlane |
9.56 |
$content .= ' |
| 94 |
djmaze |
8.20 |
<table width="100" border="0" cellspacing="0" cellpadding="5" class="forumline">'; |
| 95 |
estlane |
9.56 |
} |
| 96 |
estlane |
9.56 |
$smilies = get_smilies(); |
| 97 |
estlane |
9.56 |
if (is_array($smilies)) { |
| 98 |
estlane |
9.56 |
$num_smilies = 0; |
| 99 |
estlane |
9.56 |
$rowset = array(); |
| 100 |
estlane |
9.56 |
#while ($row = $db->sql_fetchrow($result)) { |
| 101 |
estlane |
9.56 |
for ($i=0; $i<count($smilies); ++$i) { |
| 102 |
estlane |
9.56 |
if (empty($rowset[$smilies[$i]['smile_url']])) { |
| 103 |
estlane |
9.56 |
$rowset[$smilies[$i]['smile_url']]['code'] = str_replace("'", "\\'", str_replace('\\', '\\\\', $smilies[$i]['code'])); |
| 104 |
djmaze |
9.20 |
# process the smiley description |
| 105 |
estlane |
9.56 |
$rowset[$smilies[$i]['smile_url']]['emoticon'] = get_code_lang($smilies[$i]['emoticon'],$smilies_desc); |
| 106 |
estlane |
9.56 |
$num_smilies++; |
| 107 |
estlane |
9.56 |
} |
| 108 |
estlane |
9.56 |
} |
| 109 |
estlane |
9.56 |
if ($num_smilies) { |
| 110 |
estlane |
9.56 |
$smilies_count = ($mode == 'inline') ? min(19, $num_smilies) : $num_smilies; |
| 111 |
estlane |
9.56 |
$smilies_split_row = ($mode == 'inline') ? $inline_cols - 1 : $window_cols - 1; |
| 112 |
estlane |
9.56 |
  |
| 113 |
estlane |
9.56 |
$s_colspan = $row = $col = 0; |
| 114 |
estlane |
9.56 |
  |
| 115 |
estlane |
9.56 |
while (list($smile_url, $data) = each($rowset)) { |
| 116 |
estlane |
9.56 |
if (!$col) { |
| 117 |
estlane |
9.56 |
$content .= '<tr align="center" valign="middle">'; |
| 118 |
estlane |
9.56 |
} |
| 119 |
estlane |
9.56 |
$content .= "<td><a href=\"javascript:emoticon('".$form."', '".$field."', '".$data['code']."')\"><img src=\"" . $smilies_path . $smile_url . "\" style=\"border:0;\" alt=\"".$data['emoticon']."\" title=\"".$data['emoticon']."\" /></a></td>"; |
| 120 |
estlane |
9.56 |
$s_colspan = max($s_colspan, $col + 1); |
| 121 |
estlane |
9.56 |
  |
| 122 |
estlane |
9.56 |
if ($mode == 'onerow') { |
| 123 |
estlane |
9.56 |
if ($col >= 15) { |
| 124 |
estlane |
9.56 |
if ($num_smilies > 15) { |
| 125 |
estlane |
9.56 |
$content .= "<td colspan=\"$s_colspan\" class=\"nav\"><a href=\"$url\" onclick=\"window.open('$url', '_smilies', 'height=200,resizable=yes,scrollbars=yes,width=230');return false;\" target=\"_smilies\" class=\"nav\">$smilies_more</a></td>"; |
| 126 |
estlane |
9.56 |
} |
| 127 |
estlane |
9.56 |
break; |
| 128 |
estlane |
9.56 |
} |
| 129 |
estlane |
9.56 |
$col++; |
| 130 |
estlane |
9.56 |
} |
| 131 |
estlane |
9.56 |
else if ($col == $smilies_split_row) { |
| 132 |
estlane |
9.56 |
$content .= '</tr>'; |
| 133 |
estlane |
9.56 |
$col = 0; |
| 134 |
estlane |
9.56 |
if ($mode == 'inline' && $row == $inline_rows - 1) { |
| 135 |
estlane |
9.56 |
break; |
| 136 |
estlane |
9.56 |
} |
| 137 |
estlane |
9.56 |
$row++; |
| 138 |
estlane |
9.56 |
} |
| 139 |
estlane |
9.56 |
else { $col++; } |
| 140 |
estlane |
9.56 |
} |
| 141 |
estlane |
9.56 |
if ($col > 0) { $content .= '</tr>'; } |
| 142 |
estlane |
9.56 |
  |
| 143 |
estlane |
9.56 |
if ($mode == 'inline' && $num_smilies > $inline_rows * $inline_cols) { |
| 144 |
estlane |
9.56 |
$content .= "<tr align=\"center\"> |
| 145 |
estlane |
9.56 |
<td colspan=\"$s_colspan\" class=\"nav\"><a href=\"$url\" onclick=\"window.open('$url', '_smilies', 'height=200,resizable=yes,scrollbars=yes,width=230');return false;\" target=\"_smilies\" class=\"nav\">$smilies_more</a></td> |
| 146 |
estlane |
9.56 |
</tr>"; |
| 147 |
estlane |
9.56 |
} |
| 148 |
estlane |
9.56 |
} |
| 149 |
estlane |
9.56 |
} |
| 150 |
estlane |
9.56 |
$content .= "\n</table>\n"; |
| 151 |
estlane |
9.56 |
if ($mode == 'window') { $content .= $bb_codes['win_end']; } |
| 152 |
estlane |
9.56 |
return $content; |
| 153 |
djmaze |
1.1 |
} |
| 154 |
djmaze |
1.1 |
  |
| 155 |
djmaze |
1.1 |
function bbcode_table($field='message', $form='post', $allowed=0) |
| 156 |
djmaze |
1.1 |
{ |
| 157 |
estlane |
9.56 |
global $bbbttns_path, $color_desc, $font_desc, $textcolor1, $bbcode_common; |
| 158 |
estlane |
9.56 |
$content = ''; |
| 159 |
estlane |
9.56 |
if (!defined('BBCODE_JS_ACTIVE')) { |
| 160 |
estlane |
9.56 |
$content .= ' <script type="text/javascript"> |
| 161 |
estlane |
9.56 |
var b_help = "'. $bbcode_common['bold'][0].' '.$bbcode_common['bold'][1].'"; |
| 162 |
estlane |
9.56 |
var i_help = "'. $bbcode_common['italic'][0].' '.$bbcode_common['italic'][1].'"; |
| 163 |
estlane |
9.56 |
var u_help = "'. $bbcode_common['underline'][0].' '.$bbcode_common['underline'][1].'"; |
| 164 |
estlane |
9.56 |
var quote_help = "'. $bbcode_common['quote'][0].' '.$bbcode_common['quote'][1].'"; |
| 165 |
estlane |
9.56 |
var code_help = "'. $bbcode_common['code'][0].' '.$bbcode_common['code'][1].'"; |
| 166 |
estlane |
9.56 |
var php_help = "'. $bbcode_common['php'][0].' '.$bbcode_common['php'][1].'"; |
| 167 |
estlane |
9.56 |
var img_help = "'. $bbcode_common['img'][0].' '.$bbcode_common['img'][1].'"; |
| 168 |
estlane |
9.56 |
var fc_help = "'. $bbcode_common['fc'][0].' '.$bbcode_common['fc'][1].'"; |
| 169 |
estlane |
9.56 |
var fs_help = "'. $bbcode_common['fs'][0].' '.$bbcode_common['fs'][1].'"; |
| 170 |
estlane |
9.56 |
var ft_help = "'. $bbcode_common['ft'][0].' '.$bbcode_common['ft'][1].'"; |
| 171 |
estlane |
9.56 |
var rtl_help = "'. $bbcode_common['rtl'][0].' '.$bbcode_common['rtl'][1].'"; |
| 172 |
estlane |
9.56 |
var ltr_help = "'. $bbcode_common['ltr'][0].' '.$bbcode_common['ltr'][1].'"; |
| 173 |
estlane |
9.56 |
var mail_help = "'. $bbcode_common['mail'][0].' '.$bbcode_common['mail'][1].'"; |
| 174 |
estlane |
9.56 |
var url_help= "'. $bbcode_common['url'][0].' '.$bbcode_common['url'][1].'"; |
| 175 |
estlane |
9.56 |
var right_help= "'. $bbcode_common['right'][0].' '.$bbcode_common['right'][1].'"; |
| 176 |
estlane |
9.56 |
var left_help= "'. $bbcode_common['left'][0].' '.$bbcode_common['left'][1].'"; |
| 177 |
estlane |
9.56 |
var center_help= "'. $bbcode_common['center'][0].' '.$bbcode_common['center'][1].'"; |
| 178 |
estlane |
9.56 |
var justify_help= "'. $bbcode_common['justify'][0].' '.$bbcode_common['justify'][1].'"; |
| 179 |
estlane |
9.56 |
var marqr_help= "'. $bbcode_common['marqr'][0].' '.$bbcode_common['marqr'][1].'"; |
| 180 |
estlane |
9.56 |
var marql_help= "'. $bbcode_common['marql'][0].' '.$bbcode_common['marql'][1].'"; |
| 181 |
estlane |
9.56 |
var marqu_help= "'. $bbcode_common['marqu'][0].' '.$bbcode_common['marqu'][1].'"; |
| 182 |
estlane |
9.56 |
var marqd_help= "'. $bbcode_common['marqd'][0].' '.$bbcode_common['marqd'][1].'"; |
| 183 |
estlane |
9.56 |
var hr_help= "'. $bbcode_common['hr'][0].' '.$bbcode_common['hr'][1].'"; |
| 184 |
estlane |
9.56 |
var video_help="'. $bbcode_common['video'][0].' '.$bbcode_common['video'][1].'"; |
| 185 |
estlane |
9.56 |
var flash_help="'. $bbcode_common['flash'][0].' '.$bbcode_common['flash'][1].'";</script> |
| 186 |
estlane |
9.56 |
<script src="includes/javascript/bbcode.js" type="text/javascript"></script>'; |
| 187 |
estlane |
9.56 |
define('BBCODE_JS_ACTIVE', 1); |
| 188 |
estlane |
9.56 |
} |
| 189 |
estlane |
9.56 |
$content .= '<table cellpadding="0" cellspacing="0"> |
| 190 |
djmaze |
9.12 |
<tr> |
| 191 |
estlane |
9.56 |
<td> |
| 192 |
estlane |
9.56 |
<img alt="'.$bbcode_common['bold'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'b\')" onclick="BBCcode(\''.$form.'\',\''.$field.'\',this,\'b\')" src="'.$bbbttns_path.'b.gif" /> |
| 193 |
estlane |
9.56 |
<img alt="'.$bbcode_common['italic'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'i\')" onclick="BBCcode(\''.$form.'\',\''.$field.'\',this,\'i\')" src="'.$bbbttns_path.'i.gif" /> |
| 194 |
estlane |
9.56 |
<img alt="'.$bbcode_common['underline'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'u\')" onclick="BBCcode(\''.$form.'\',\''.$field.'\',this,\'u\')" src="'.$bbbttns_path.'u.gif" /> |
| 195 |
djmaze |
1.1 |
|
| 196 |
estlane |
9.56 |
<img alt="'.$bbcode_common['ltr'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'ltr\')" onclick="BBCdir(\''.$form.'\',\''.$field.'\',\'ltr\')" src="'.$bbbttns_path.'ltr.gif" /> |
| 197 |
estlane |
9.56 |
<img alt="'.$bbcode_common['rtl'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'rtl\')" onclick="BBCdir(\''.$form.'\',\''.$field.'\',\'rtl\')" src="'.$bbbttns_path.'rtl.gif" /> |
| 198 |
djmaze |
1.1 |
|
| 199 |
estlane |
9.56 |
<img alt="'.$bbcode_common['url'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'url\')" onclick="BBCurl(\''.$form.'\',\''.$field.'\')" src="'.$bbbttns_path.'url.gif" /> |
| 200 |
estlane |
9.56 |
<img alt="'.$bbcode_common['mail'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'mail\')" onclick="BBCwmi(\''.$form.'\',\''.$field.'\',\'email\')" src="'.$bbbttns_path.'email.gif" />'; |
| 201 |
estlane |
9.56 |
if ($allowed) { |
| 202 |
estlane |
9.56 |
$content .= ' |
| 203 |
djmaze |
1.1 |
|
| 204 |
estlane |
9.56 |
<img alt="'.$bbcode_common['justify'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'justify\')" onclick="BBCode(\''.$form.'\',\''.$field.'\',\'align\',this,\'justify\')" src="'.$bbbttns_path.'align_justify.gif" /> |
| 205 |
estlane |
9.56 |
<img alt="'.$bbcode_common['left'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'left\')" onclick="BBCode(\''.$form.'\',\''.$field.'\',\'align\',this,\'left\')" src="'.$bbbttns_path.'align_left.gif" /> |
| 206 |
estlane |
9.56 |
<img alt="'.$bbcode_common['center'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'center\')" onclick="BBCode(\''.$form.'\',\''.$field.'\',\'align\',this,\'center\')" src="'.$bbbttns_path.'align_center.gif" /> |
| 207 |
estlane |
9.56 |
<img alt="'.$bbcode_common['right'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'right\')" onclick="BBCode(\''.$form.'\',\''.$field.'\',\'align\',this,\'right\')" src="'.$bbbttns_path.'align_right.gif" />'; |
| 208 |
estlane |
9.56 |
} |
| 209 |
estlane |
9.56 |
$content .= ' |
| 210 |
djmaze |
1.1 |
|
| 211 |
estlane |
9.56 |
<select onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'fc\')" onchange="BBCfc(\''.$form.'\',\''.$field.'\',this)" title="'.$color_desc['color'].'"> |
| 212 |
estlane |
9.56 |
<option class="genmed" value="'.$textcolor1.'" style="color: black; background-color: rgb(250, 250, 250);">'.$color_desc['Default'].'</option> |
| 213 |
estlane |
9.56 |
<option class="genmed" value="maroon" style="color: maroon; background-color: rgb(250, 250, 250);">'.$color_desc['Dark Red'].'</option> |
| 214 |
estlane |
9.56 |
<option class="genmed" value="red" style="color: red; background-color: rgb(250, 250, 250);">'.$color_desc['Red'].'</option> |
| 215 |
estlane |
9.56 |
<option class="genmed" value="orange" style="color: orange; background-color: rgb(250, 250, 250);">'.$color_desc['Orange'].'</option> |
| 216 |
estlane |
9.56 |
<option class="genmed" value="brown" style="color: brown; background-color: rgb(250, 250, 250);">'.$color_desc['Brown'].'</option> |
| 217 |
estlane |
9.56 |
<option class="genmed" value="yellow" style="color: yellow; background-color: rgb(250, 250, 250);">'.$color_desc['Yellow'].'</option> |
| 218 |
estlane |
9.56 |
<option class="genmed" value="green" style="color: green; background-color: rgb(250, 250, 250);">'.$color_desc['Green'].'</option> |
| 219 |
estlane |
9.56 |
<option class="genmed" value="olive" style="color: olive; background-color: rgb(250, 250, 250);">'.$color_desc['Olive'].'</option> |
| 220 |
estlane |
9.56 |
<option class="genmed" value="cyan" style="color: cyan; background-color: rgb(250, 250, 250);">'.$color_desc['Cyan'].'</option> |
| 221 |
estlane |
9.56 |
<option class="genmed" value="blue" style="color: blue; background-color: rgb(250, 250, 250);">'.$color_desc['Blue'].'</option> |
| 222 |
estlane |
9.56 |
<option class="genmed" value="darkblue" style="color: darkblue; background-color: rgb(250, 250, 250);">'.$color_desc['Dark Blue'].'</option> |
| 223 |
estlane |
9.56 |
<option class="genmed" value="indigo" style="color: indigo; background-color: rgb(250, 250, 250);">'.$color_desc['Indigo'].'</option> |
| 224 |
estlane |
9.56 |
<option class="genmed" value="violet" style="color: violet; background-color: rgb(250, 250, 250);">'.$color_desc['Violet'].'</option> |
| 225 |
estlane |
9.56 |
<option class="genmed" value="white" style="color: white; background-color: rgb(250, 250, 250);">'.$color_desc['White'].'</option> |
| 226 |
estlane |
9.56 |
<option class="genmed" value="black" style="color: black; background-color: rgb(250, 250, 250);">'.$color_desc['Black'].'</option> |
| 227 |
estlane |
9.56 |
</select>'; |
| 228 |
estlane |
9.56 |
if ($allowed) { |
| 229 |
estlane |
9.56 |
$content .= ' |
| 230 |
estlane |
9.56 |
</td> |
| 231 |
djmaze |
9.12 |
</tr><tr> |
| 232 |
estlane |
9.56 |
<td> |
| 233 |
estlane |
9.56 |
<img alt="'.$bbcode_common['img'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'img\')" onclick="BBCwmi(\''.$form.'\',\''.$field.'\',\'img\')" src="'.$bbbttns_path.'img.gif" /> |
| 234 |
estlane |
9.56 |
<img alt="'.$bbcode_common['flash'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'flash\')" onclick="BBCmm(\''.$form.'\',\''.$field.'\',\'flash\')" src="'.$bbbttns_path.'flash.gif" /> |
| 235 |
estlane |
9.56 |
<img alt="'.$bbcode_common['video'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'video\')" onclick="BBCmm(\''.$form.'\',\''.$field.'\',\'video\')" src="'.$bbbttns_path.'video.gif" /> |
| 236 |
djmaze |
8.2 |
|
| 237 |
estlane |
9.56 |
<img alt="'.$bbcode_common['quote'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'quote\')" onclick="BBCcode(\''.$form.'\',\''.$field.'\',this,\'quote\')" src="'.$bbbttns_path.'quote.gif" /> |
| 238 |
estlane |
9.56 |
<img alt="'.$bbcode_common['code'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'code\')" onclick="BBCcode(\''.$form.'\',\''.$field.'\',this,\'code\')" src="'.$bbbttns_path.'code.gif" /> |
| 239 |
estlane |
9.56 |
<img alt="'.$bbcode_common['php'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'php\')" onclick="BBCcode(\''.$form.'\',\''.$field.'\',this,\'php\')" src="'.$bbbttns_path.'php.gif" /> |
| 240 |
djmaze |
1.1 |
|
| 241 |
estlane |
9.56 |
<img alt="'.$bbcode_common['hr'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'hr\')" onclick="BBChr(\''.$form.'\',\''.$field.'\')" src="'.$bbbttns_path.'hr.gif" /> |
| 242 |
djmaze |
1.1 |
|
| 243 |
estlane |
9.56 |
<img alt="'.$bbcode_common['marqd'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'marqd\')" onclick="BBCode(\''.$form.'\',\''.$field.'\',\'marq\',this,\'down\')" src="'.$bbbttns_path.'marq_down.gif" /> |
| 244 |
estlane |
9.56 |
<img alt="'.$bbcode_common['marqu'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'marqu\')" onclick="BBCode(\''.$form.'\',\''.$field.'\',\'marq\',this,\'up\')" src="'.$bbbttns_path.'marq_up.gif" /> |
| 245 |
estlane |
9.56 |
<img alt="'.$bbcode_common['marql'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'marql\')" onclick="BBCode(\''.$form.'\',\''.$field.'\',\'marq\',this,\'left\')" src="'.$bbbttns_path.'marq_left.gif" /> |
| 246 |
estlane |
9.56 |
<img alt="'.$bbcode_common['marqr'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'marqr\')" onclick="BBCode(\''.$form.'\',\''.$field.'\',\'marq\',this,\'right\')" src="'.$bbbttns_path.'marq_right.gif" /> |
| 247 |
djmaze |
1.1 |
|
| 248 |
estlane |
9.56 |
<select onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'fs\')" onchange="BBCfs(\''.$form.'\',\''.$field.'\',this)" title="'.$font_desc['size'].'"> |
| 249 |
estlane |
9.56 |
<option value="7" class="genmed">'.$font_desc['Tiny'].'</option> |
| 250 |
estlane |
9.56 |
<option value="9" class="genmed">'.$font_desc['Small'].'</option> |
| 251 |
estlane |
9.56 |
<option value="12" class="genmed" selected="selected">'.$font_desc['Normal'].'</option> |
| 252 |
estlane |
9.56 |
<option value="18" class="genmed">'.$font_desc['Large'].'</option> |
| 253 |
estlane |
9.56 |
<option value="24" class="genmed">'.$font_desc['Huge'].'</option> |
| 254 |
estlane |
9.56 |
</select>'; |
| 255 |
estlane |
9.56 |
} |
| 256 |
estlane |
9.56 |
$content .= ' |
| 257 |
estlane |
9.56 |
</td> |
| 258 |
djmaze |
9.12 |
</tr><tr> |
| 259 |
estlane |
9.56 |
<td> |
| 260 |
estlane |
9.56 |
<input type="text" name="help'.$field.'" size="66" maxlength="100" value="'.$bbcode_common['Tip'].'" class="helpline" /> |
| 261 |
estlane |
9.56 |
</td> |
| 262 |
djmaze |
1.1 |
</tr> |
| 263 |
djmaze |
1.1 |
</table>'; |
| 264 |
djmaze |
1.1 |
  |
| 265 |
estlane |
9.56 |
return $content; |
| 266 |
djmaze |
1.1 |
} |
| 267 |
djmaze |
1.1 |
  |
| 268 |
djmaze |
9.28 |
function get_smilies() { |
| 269 |
estlane |
9.56 |
global $db, $prefix; |
| 270 |
estlane |
9.56 |
$smilies = Cache::array_load('smilies','bb', false); |
| 271 |
estlane |
9.56 |
if (!$smilies) { |
| 272 |
estlane |
9.56 |
$smilies = $db->sql_ufetchrowset('SELECT * FROM '.$prefix.'_bbsmilies', SQL_ASSOC); |
| 273 |
estlane |
9.56 |
if (count($smilies)) { |
| 274 |
estlane |
9.56 |
usort($smilies, 'sort_smiley'); |
| 275 |
estlane |
9.56 |
Cache::array_save('smilies','bb', $smilies); |
| 276 |
estlane |
9.56 |
} |
| 277 |
estlane |
9.56 |
} |
| 278 |
estlane |
9.56 |
return $smilies; |
| 279 |
djmaze |
9.28 |
} |
| 280 |
djmaze |
9.20 |
# smilies_pass( |
| 281 |
djmaze |
1.1 |
function set_smilies($message, $url='') { |
| 282 |
estlane |
9.56 |
static $orig, $repl; |
| 283 |
estlane |
9.56 |
if (!isset($orig)) { |
| 284 |
estlane |
9.56 |
global $smilies_path, $smilies_desc; |
| 285 |
estlane |
9.56 |
$orig = $repl = array(); |
| 286 |
estlane |
9.56 |
$smilies = get_smilies(); |
| 287 |
estlane |
9.56 |
if ($url != '' && substr($url, -1) != '/') { $url .= '/'; } |
| 288 |
estlane |
9.56 |
for ($i = 0; $i < count($smilies); $i++) { |
| 289 |
estlane |
9.56 |
$smilies[$i]['code'] = str_replace('#', '\#', preg_quote($smilies[$i]['code'])); |
| 290 |
estlane |
9.56 |
$orig[] = "#([\s])".$smilies[$i]['code']."([\s<])#si"; |
| 291 |
estlane |
9.56 |
$repl[] = '\\1<img class="bbsmilies" src="' . $url . $smilies_path . $smilies[$i]['smile_url'] . '" alt="'.get_code_lang($smilies[$i]['emoticon'],$smilies_desc).'" title="'.get_code_lang($smilies[$i]['emoticon'],$smilies_desc).'" />\\2'; |
| 292 |
estlane |
9.56 |
} |
| 293 |
estlane |
9.56 |
} |
| 294 |
estlane |
9.56 |
if (count($orig)) { |
| 295 |
estlane |
9.56 |
$message = preg_replace($orig, $repl, " $message "); |
| 296 |
estlane |
9.56 |
$message = substr($message, 1, -1); |
| 297 |
estlane |
9.56 |
} |
| 298 |
estlane |
9.56 |
return $message; |
| 299 |
djmaze |
1.1 |
} |
| 300 |
djmaze |
1.1 |
  |
| 301 |
djmaze |
1.1 |
function sort_smiley($a, $b) |
| 302 |
djmaze |
1.1 |
{ |
| 303 |
estlane |
9.56 |
if ($a['pos'] == $b['code']) { return 0; } |
| 304 |
estlane |
9.56 |
return ($a['pos'] < $b['pos']) ? -1 : 1; |
| 305 |
estlane |
9.56 |
// if (strlen($a['code']) == strlen($b['code'])) { return 0; } |
| 306 |
estlane |
9.56 |
// return (strlen($a['code']) > strlen($b['code'])) ? -1 : 1; |
| 307 |
djmaze |
9.3 |
} |
| 308 |
djmaze |
9.3 |
  |
| 309 |
djmaze |
9.20 |
# bbencode_first_pass() prepare bbcode for db insert |
| 310 |
djmaze |
9.3 |
function encode_bbcode($text) |
| 311 |
djmaze |
9.3 |
{ |
| 312 |
estlane |
9.56 |
return BBCode::encode($text); |
| 313 |
djmaze |
1.1 |
} |
| 314 |
djmaze |
9.1 |
function decode_bb_all($text, $allowed=0, $allow_html=false, $url='') { |
| 315 |
estlane |
9.56 |
return set_smilies(decode_bbcode($text, $allowed, $allow_html), $url); |
| 316 |
djmaze |
9.1 |
} |
| 317 |
djmaze |
9.30 |
function decode_bbcode($text, $allowed=0, $allow_html=false) |
| 318 |
djmaze |
9.15 |
{ |
| 319 |
estlane |
9.56 |
return BBCode::decode($text, $allowed, $allow_html); |
| 320 |
djmaze |
9.15 |
} |
| 321 |
djmaze |
9.15 |
  |
| 322 |
djmaze |
1.22 |
function shrink_url($url) { |
| 323 |
estlane |
9.56 |
$url = preg_replace("#(^[\w]+?://)#", '', $url); |
| 324 |
estlane |
9.56 |
return (strlen($url) > 35) ? substr($url,0,22).'...'.substr($url,-10) : $url; |
| 325 |
djmaze |
1.22 |
} |
| 326 |
djmaze |
1.1 |
  |
| 327 |
djmaze |
1.1 |
function make_clickable($text) |
| 328 |
djmaze |
1.1 |
{ |
| 329 |
estlane |
9.56 |
$ret = ' ' . $text; |
| 330 |
estlane |
9.56 |
$ret = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t<]*)#ise", "'\\1<a href=\"\\2\" rel=\"nofollow\" title=\"\\2\" target=\"_blank\">'.shrink_url('\\2').'</a>'", $ret); |
| 331 |
estlane |
9.56 |
$ret = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r<]*)#ise", "'\\1<a href=\"http://\\2\" rel=\"nofollow\" target=\"_blank\" title=\"\\2\">'.shrink_url('\\2').'</a>'", $ret); |
| 332 |
estlane |
9.56 |
$ret = preg_replace("#(^|[\n ])([a-z0-9&\-_\.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1 \\2 @ \\3", $ret); |
| 333 |
estlane |
9.56 |
$ret = substr($ret, 1); |
| 334 |
estlane |
9.56 |
return($ret); |
| 335 |
djmaze |
1.1 |
} |
| 336 |
djmaze |
1.1 |
  |
| 337 |
djmaze |
9.20 |
# prepare_message( |
| 338 |
djmaze |
1.1 |
function message_prepare($message, $html_on, $bbcode_on) |
| 339 |
djmaze |
1.1 |
{ |
| 340 |
estlane |
9.56 |
# |
| 341 |
estlane |
9.56 |
# Clean up the message |
| 342 |
estlane |
9.56 |
# |
| 343 |
estlane |
9.56 |
$message = trim($message); |
| 344 |
nanocaio |
9.60 |
/*if ($html_on) { |
| 345 |
nanocaio |
9.60 |
$allowed_html_tags = split(',', 'b,i,u,pre'); |
| 346 |
estlane |
9.56 |
$end_html = 0; |
| 347 |
estlane |
9.56 |
$start_html = 1; |
| 348 |
estlane |
9.56 |
$tmp_message = ''; |
| 349 |
estlane |
9.56 |
$message = ' ' . $message . ' '; |
| 350 |
estlane |
9.56 |
while ($start_html = strpos($message, '<', $start_html)) { |
| 351 |
estlane |
9.56 |
$tmp_message .= BBCode::encode_html(substr($message, $end_html + 1, ($start_html - $end_html - 1))); |
| 352 |
estlane |
9.56 |
if ($end_html = strpos($message, '>', $start_html)) { |
| 353 |
estlane |
9.56 |
$length = $end_html - $start_html + 1; |
| 354 |
estlane |
9.56 |
$hold_string = substr($message, $start_html, $length); |
| 355 |
estlane |
9.56 |
if (($unclosed_open = strrpos(' ' . $hold_string, '<')) != 1) { |
| 356 |
estlane |
9.56 |
$tmp_message .= BBCode::encode_html(substr($hold_string, 0, $unclosed_open - 1)); |
| 357 |
estlane |
9.56 |
$hold_string = substr($hold_string, $unclosed_open - 1); |
| 358 |
estlane |
9.56 |
} |
| 359 |
estlane |
9.56 |
$tagallowed = false; |
| 360 |
estlane |
9.56 |
for ($i = 0; $i < sizeof($allowed_html_tags); $i++) { |
| 361 |
estlane |
9.56 |
$match_tag = trim($allowed_html_tags[$i]); |
| 362 |
estlane |
9.56 |
if (preg_match('#^<\/?' . $match_tag . '[> ]#i', $hold_string)) { |
| 363 |
estlane |
9.56 |
$tagallowed = (preg_match('#^<\/?' . $match_tag . ' .*?(style[ ]*?=|on[\w]+[ ]*?=)#i', $hold_string)) ? false : true; |
| 364 |
estlane |
9.56 |
} |
| 365 |
estlane |
9.56 |
} |
| 366 |
estlane |
9.56 |
$tmp_message .= ($length && !$tagallowed) ? BBCode::encode_html($hold_string) : $hold_string; |
| 367 |
estlane |
9.56 |
$start_html += $length; |
| 368 |
estlane |
9.56 |
} else { |
| 369 |
estlane |
9.56 |
$tmp_message .= BBCode::encode_html(substr($message, $start_html)); |
| 370 |
estlane |
9.56 |
$start_html = strlen($message); |
| 371 |
estlane |
9.56 |
$end_html = $start_html; |
| 372 |
estlane |
9.56 |
} |
| 373 |
estlane |
9.56 |
} |
| 374 |
estlane |
9.56 |
if ($end_html != strlen($message) && $tmp_message != '') { |
| 375 |
estlane |
9.56 |
$tmp_message .= BBCode::encode_html(substr($message, $end_html + 1)); |
| 376 |
estlane |
9.56 |
} |
| 377 |
estlane |
9.56 |
$message = ($tmp_message != '') ? trim($tmp_message) : trim($message); |
| 378 |
nanocaio |
9.60 |
} else {*/ |
| 379 |
estlane |
9.56 |
$message = BBCode::encode_html($message); |
| 380 |
nanocaio |
9.60 |
/*}*/ |
| 381 |
estlane |
9.56 |
if ($bbcode_on) { |
| 382 |
estlane |
9.56 |
$message = BBCode::encode($message); |
| 383 |
estlane |
9.56 |
} |
| 384 |
estlane |
9.56 |
return $message; |
| 385 |
djmaze |
8.31 |
} |
| 386 |
djmaze |
9.3 |
  |
| 387 |
nanocaio |
9.49 |
abstract class BBCode { |
| 388 |
djmaze |
9.3 |
  |
| 389 |
estlane |
9.56 |
public static function encode_html($text) { |
| 390 |
estlane |
9.56 |
return (false !== strpos($text, '<')) ? htmlprepare($text, false, ENT_NOQUOTES) : $text; |
| 391 |
estlane |
9.56 |
} |
| 392 |
estlane |
9.56 |
  |
| 393 |
estlane |
9.56 |
public static function encode($text) |
| 394 |
estlane |
9.56 |
{ |
| 395 |
estlane |
9.56 |
# Split all bbcodes. |
| 396 |
estlane |
9.56 |
$text_parts = BBCode::split_bbcodes($text); |
| 397 |
estlane |
9.56 |
# Merge all bbcodes and do special actions depending on the type of code. |
| 398 |
estlane |
9.56 |
$text = ''; |
| 399 |
estlane |
9.56 |
while ($part = array_shift($text_parts)) { |
| 400 |
estlane |
9.56 |
if (isset($part['code'])) { |
| 401 |
estlane |
9.56 |
if ($part['code'] == 'list' && $part['text'][5] == '=' && substr($part['text'], -3) != ':o]') { |
| 402 |
estlane |
9.56 |
# [list=x] for ordered lists. |
| 403 |
estlane |
9.56 |
$part['text'] = substr($part['text'], 0, -1).':o]'; |
| 404 |
estlane |
9.56 |
} |
| 405 |
estlane |
9.56 |
if ($part['code'] != 'code' && $part['code'] != 'php' && $part['subc']) { |
| 406 |
estlane |
9.56 |
$part['text'] = '['.encode_bbcode(substr($part['text'], 1, -1)).']'; |
| 407 |
estlane |
9.56 |
} |
| 408 |
estlane |
9.56 |
} |
| 409 |
estlane |
9.56 |
$text .= $part['text']; |
| 410 |
estlane |
9.56 |
} |
| 411 |
estlane |
9.56 |
return trim($text); |
| 412 |
estlane |
9.56 |
} |
| 413 |
estlane |
9.56 |
  |
| 414 |
estlane |
9.56 |
public static function decode($text, $allowed=0, $allow_html=false) |
| 415 |
estlane |
9.56 |
{ |
| 416 |
estlane |
9.56 |
global $bb_codes; |
| 417 |
estlane |
9.56 |
# First: If there isn't a "[" and a "]" in the message, don't bother. |
| 418 |
estlane |
9.56 |
if (!(strpos($text, '[') !== false && strpos($text, ']'))) { |
| 419 |
estlane |
9.56 |
return ($allow_html ? (false !== strpos($text, '<') ? $text : nl2br($text)) : nl2br(strip_tags($text))); |
| 420 |
estlane |
9.56 |
} |
| 421 |
estlane |
9.56 |
  |
| 422 |
estlane |
9.56 |
// strip the obsolete bbcode_uid |
| 423 |
estlane |
9.56 |
$text = preg_replace("/:(([a-z0-9]+:)?)[a-z0-9]{10}(=|\])/si", '\\3', $text); |
| 424 |
estlane |
9.56 |
  |
| 425 |
estlane |
9.56 |
# pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0). |
| 426 |
estlane |
9.56 |
$text = BBCode::split_on_bbcodes($text, $allowed, $allow_html); |
| 427 |
estlane |
9.56 |
  |
| 428 |
estlane |
9.56 |
# Patterns and replacements for URL, email tags etc. |
| 429 |
estlane |
9.56 |
$patterns = $replacements = array(); |
| 430 |
estlane |
9.56 |
  |
| 431 |
estlane |
9.56 |
# replace single & to & |
| 432 |
estlane |
9.56 |
$text = preg_replace('/&(?![a-z]{2,6};|#[0-9]{1,4};)/is', '&', $text); |
| 433 |
estlane |
9.56 |
  |
| 434 |
estlane |
9.56 |
# colours |
| 435 |
estlane |
9.56 |
$patterns[] = '#\[color=(\#[0-9A-F]{6}|[a-z]+)\](.*?)\[/color\]#si'; |
| 436 |
estlane |
9.56 |
$replacements[] = '<span style="color: \\1">\\2</span>'; |
| 437 |
estlane |
9.56 |
  |
| 438 |
estlane |
9.56 |
# size |
| 439 |
estlane |
9.56 |
$patterns[] = '#\[size=([1-2]?[0-9])\](.*?)\[/size\]#si'; |
| 440 |
estlane |
9.56 |
$replacements[] = '<span style="font-size: \\1px; line-height: normal">\\2</span>'; |
| 441 |
estlane |
9.56 |
  |
| 442 |
estlane |
9.56 |
# [b] and [/b] for bolding text. |
| 443 |
estlane |
9.56 |
$patterns[] = '#\[b\](.*?)\[/b\]#si'; |
| 444 |
estlane |
9.56 |
$replacements[] = '<span style="font-weight: bold">\\1</span>'; |
| 445 |
estlane |
9.56 |
  |
| 446 |
estlane |
9.56 |
# [u] and [/u] for underlining text. |
| 447 |
estlane |
9.56 |
$patterns[] = '#\[u\](.*?)\[/u\]#si'; |
| 448 |
estlane |
9.56 |
$replacements[] = '<span style="text-decoration: underline">\\1</span>'; |
| 449 |
estlane |
9.56 |
  |
| 450 |
estlane |
9.56 |
# [i] and [/i] for italicizing text. |
| 451 |
estlane |
9.56 |
$patterns[] = '#\[i\](.*?)\[/i\]#si'; |
| 452 |
estlane |
9.56 |
$replacements[] = '<span style="font-style: italic">\\1</span>'; |
| 453 |
estlane |
9.56 |
  |
| 454 |
estlane |
9.56 |
# align |
| 455 |
estlane |
9.56 |
$patterns[] = '#\[align=(left|right|center|justify)\](.*?)\[/align\]#si'; |
| 456 |
estlane |
9.56 |
$replacements[] = '<div style="text-align:\\1">\\2</div>'; |
| 457 |
estlane |
9.56 |
  |
| 458 |
estlane |
9.56 |
# [google]search string[/google] |
| 459 |
estlane |
9.56 |
$patterns[] = "#\[search=google\](.*?)\[/search\]#ise"; |
| 460 |
estlane |
9.56 |
$replacements[] = "'<form action=\"http://google.com/search\" method=\"get\"><input type=\"text\" name=\"q\" value=\"'.trim('\\1').'\" /><input type=\"submit\" value=\"Search Google\" /></form>'"; |
| 461 |
estlane |
9.56 |
$patterns[] = "#\[search\](.*?)\[/search\]#ise"; |
| 462 |
estlane |
9.56 |
$replacements[] = "'<form action=\"search.html\" method=\"post\"><input type=\"text\" name=\"search\" value=\"'.trim('\\1').'\" /><input type=\"submit\" value=\"Search\" /></form>'"; |
| 463 |
estlane |
9.56 |
// $replacements[] = "'<a href=\"http://google.com/search?q='.urlencode(trim('\\1')).'\" target=\"_blank\" class=\"postlink\" rel=\"nofollow\">\\1</a>'"; |
| 464 |
estlane |
9.56 |
  |
| 465 |
estlane |
9.56 |
# [url] local |
| 466 |
estlane |
9.56 |
$patterns[] = "#\[url\]([\w]+(\.html|\.php|/)[^ \[\"\n\r\t<]*?)\[/url\]#ise"; |
| 467 |
estlane |
9.56 |
$replacements[] = "'<a href=\"\\1\" title=\"\\1\" class=\"postlink\">'.shrink_url('\\1').'</a>'"; |
| 468 |
estlane |
9.56 |
$patterns[] = "#\[url=([\w]+(\.html|\.php|/)[^ \[\"\n\r\t<]*?)\](.*?)\[/url\]#is"; |
| 469 |
estlane |
9.56 |
$replacements[] = "<a href=\"\\1\" title=\"\\1\" class=\"postlink\">\\3</a>"; |
| 470 |
estlane |
9.56 |
  |
| 471 |
estlane |
9.56 |
# [url]xxxx://www.cpgnuke.com[/url] |
| 472 |
estlane |
9.59 |
$patterns[] = "#\[url\]([\w]+?://[^ \[\"\n\r\t<]*?)\[/url\]#ise"; |
| 473 |
estlane |
9.56 |
$replacements[] = "'<a href=\"\\1\" target=\"_blank\" title=\"\\1\" class=\"postlink\" rel=\"nofollow\">'.shrink_url('\\1').'</a>'"; |
| 474 |
estlane |
9.56 |
# [url]www.cpgnuke.com[/url] (no xxxx:// prefix). |
| 475 |
estlane |
9.59 |
$patterns[] = "#\[url\]((www|ftp)\.[^ \[\"\n\r\t<]*?)\[/url\]#ise"; |
| 476 |
estlane |
9.56 |
$replacements[] = "'<a href=\"http://\\1\" target=\"_blank\" title=\"\\1\" class=\"postlink\" rel=\"nofollow\">'.shrink_url('\\1').'</a>'"; |
| 477 |
estlane |
9.56 |
# [url=www.cpgnuke.com]cpgnuke[/url] (no xxxx:// prefix). |
| 478 |
estlane |
9.56 |
$patterns[] = "#\[url=((www|ftp)\.[^ \"\n\r\t<]*?)\](.*?)\[/url\]#is"; |
| 479 |
estlane |
9.56 |
$replacements[] = "<a href=\"http://\\1\" target=\"_blank\" title=\"\\1\" class=\"postlink\" rel=\"nofollow\">\\3</a>"; |
| 480 |
estlane |
9.56 |
# [url=xxxx://www.cpgnuke.com]cpgnuke[/url] |
| 481 |
estlane |
9.59 |
$patterns[] = "#\[url=([\w]+://[^ (\"\n\r\t<]*?)\](.*?)\[/url\]#is"; |
| 482 |
estlane |
9.56 |
$replacements[] = "<a href=\"\\1\" target=\"_blank\" title=\"\\1\" class=\"postlink\" rel=\"nofollow\">\\2</a>"; |
| 483 |
estlane |
9.56 |
  |
| 484 |
estlane |
9.56 |
# [email]user@domain.tld[/email] code.. |
| 485 |
estlane |
9.56 |
$patterns[] = "#\[email\]([a-z0-9&\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/email\]#si"; |
| 486 |
estlane |
9.56 |
$replacements[] = "<a href=\"mailto:\\1\">\\1</a>"; |
| 487 |
estlane |
9.56 |
  |
| 488 |
estlane |
9.56 |
if ($allowed) { |
| 489 |
estlane |
9.56 |
# [hr] |
| 490 |
estlane |
9.56 |
$patterns[] = "#\[hr\]#si"; |
| 491 |
estlane |
9.56 |
$replacements[] = '<hr />'; |
| 492 |
estlane |
9.56 |
  |
| 493 |
estlane |
9.56 |
# marquee |
| 494 |
estlane |
9.56 |
$patterns[] = "#\[marq=(left|right|up|down)\](.*?)\[/marq\]#si"; |
| 495 |
estlane |
9.56 |
$replacements[] = '<marquee direction="\\1" scrolldelay="60" scrollamount="1" onmouseover="this.stop()" onmouseout="this.start()">\\2</marquee>'; |
| 496 |
estlane |
9.56 |
  |
| 497 |
estlane |
9.56 |
# [img]image_url_here[/img] code.. |
| 498 |
estlane |
9.56 |
$patterns[] = "#\[img\](.*)\[/img\]#sie"; |
| 499 |
estlane |
9.56 |
$replacements[] = "'[img]'.urldecode(urldecode('\\1')).'[/img]'"; |
| 500 |
estlane |
9.56 |
$patterns[] = "#\[img\]([\w]+(://|\.|/)[^ \?=&(\"\n\r\t<\\\]*?)\[/img\]#si"; |
| 501 |
estlane |
9.56 |
$replacements[] = "<img src=\"\\1\" alt=\"\" />"; |
| 502 |
estlane |
9.56 |
  |
| 503 |
estlane |
9.56 |
# [flash width= height= loop= ] and [/flash] code.. |
| 504 |
estlane |
9.56 |
$patterns[] = "#\[flash width=([0-6]?[0-9]?[0-9]) height=([0-4]?[0-9]?[0-9])\]((ht|f)tp://)([^ \?&=\"\n\r\t<]*?(\.(swf|fla)))\[/flash\]#si"; |
| 505 |
estlane |
9.56 |
$replacements[] = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="\\1" height="\\2"> |
| 506 |
estlane |
9.56 |
<param name="movie" value="\\3\\5" /> |
| 507 |
estlane |
9.56 |
<param name="quality" value="high" /> |
| 508 |
estlane |
9.56 |
<param name="scale" value="noborder" /> |
| 509 |
estlane |
9.56 |
<param name="wmode" value="transparent" /> |
| 510 |
estlane |
9.56 |
<param name="bgcolor" value="#000000" /> |
| 511 |
djmaze |
9.15 |
<embed src="\\3\\5" quality="high" scale="noborder" wmode="transparent" bgcolor="#000000" width="\\1" height="\\2" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"> |
| 512 |
djmaze |
9.15 |
</embed></object>'; |
| 513 |
djmaze |
9.15 |
  |
| 514 |
estlane |
9.56 |
# [video width= height= loop= ] and [/video] code.. |
| 515 |
estlane |
9.56 |
$patterns[] = "#\[video width=([0-6]?[0-9]?[0-9]) height=([0-4]?[0-9]?[0-9])\]([\w]+?://[^ \?&=\"\n\r\t<]*?(\.(avi|mpg|mpeg|wmv)))\[/video\]#si"; |
| 516 |
estlane |
9.56 |
$replacements[] = '<embed src="\\3" width=\\1 height=\\2></embed>'; |
| 517 |
estlane |
9.56 |
} |
| 518 |
estlane |
9.56 |
  |
| 519 |
estlane |
9.56 |
$text = preg_replace($patterns, $replacements, $text); |
| 520 |
estlane |
9.56 |
  |
| 521 |
estlane |
9.56 |
# Fix linebreaks on important items |
| 522 |
estlane |
9.56 |
$text = preg_replace('#<br>#si', '<br />', $text); |
| 523 |
estlane |
9.56 |
$text = preg_replace('#<ul><br \/>#si', '<ul>', $text); |
| 524 |
estlane |
9.56 |
$text = preg_replace('#<\/ul><br \/>#si', '</ul>', $text); |
| 525 |
estlane |
9.56 |
$text = preg_replace('#<\/ol><br \/>#si', '</ol>', $text); |
| 526 |
estlane |
9.56 |
$text = preg_replace('#<\/table><br \>#si', '</table>', $text); |
| 527 |
estlane |
9.56 |
$text = preg_replace('#<\/div><br \/>#si', '</div>', $text); |
| 528 |
estlane |
9.56 |
$text = preg_replace('#<br \/><table#si', '<table', $text); |
| 529 |
estlane |
9.56 |
  |
| 530 |
estlane |
9.56 |
# Remove our padding from the string.. |
| 531 |
estlane |
9.56 |
return trim($text); |
| 532 |
estlane |
9.56 |
} |
| 533 |
estlane |
9.56 |
  |
| 534 |
estlane |
9.56 |
protected static function split_bbcodes($text) |
| 535 |
estlane |
9.56 |
{ |
| 536 |
estlane |
9.56 |
$curr_pos = 0; |
| 537 |
estlane |
9.56 |
$str_len = strlen($text); |
| 538 |
estlane |
9.56 |
$text_parts = array(); |
| 539 |
estlane |
9.56 |
while ($curr_pos < $str_len) { |
| 540 |
estlane |
9.56 |
# Find bbcode start tag, if not found end the loop. |
| 541 |
estlane |
9.56 |
$curr_pos = strpos($text, '[', $curr_pos); |
| 542 |
estlane |
9.56 |
if ($curr_pos === false) { break; } |
| 543 |
estlane |
9.56 |
$end = strpos($text, ']', $curr_pos); |
| 544 |
estlane |
9.56 |
if ($end === false) { break; } |
| 545 |
estlane |
9.56 |
  |
| 546 |
estlane |
9.56 |
$code_start = substr($text, $curr_pos, $end-$curr_pos+1); |
| 547 |
estlane |
9.56 |
$code = strtolower(preg_replace('/\[([a-z]+).*]/i', '\\1', $code_start)); |
| 548 |
estlane |
9.56 |
$code_len = strlen($code); |
| 549 |
estlane |
9.56 |
  |
| 550 |
estlane |
9.56 |
$end_pos = empty($code) ? false : $end; |
| 551 |
estlane |
9.56 |
$depth = 0; |
| 552 |
estlane |
9.56 |
$sub = false; |
| 553 |
estlane |
9.56 |
while ($end_pos) { |
| 554 |
estlane |
9.56 |
# Find bbcode end tag, if not found end the loop. |
| 555 |
estlane |
9.56 |
$end_pos = strpos($text, '[', $end_pos); |
| 556 |
estlane |
9.56 |
if ($end_pos === false) { break; } |
| 557 |
estlane |
9.56 |
$end = strpos($text, ']', $end_pos); |
| 558 |
estlane |
9.56 |
if ($end === false) { break; } |
| 559 |
estlane |
9.56 |
$code_end = strtolower(substr($text, $end_pos, $code_len+2)); |
| 560 |
estlane |
9.56 |
if ($code_end == "[/$code") { |
| 561 |
estlane |
9.56 |
if ($depth > 0) { |
| 562 |
estlane |
9.56 |
$depth--; |
| 563 |
estlane |
9.56 |
$end_pos++; |
| 564 |
estlane |
9.56 |
$sub = true; |
| 565 |
estlane |
9.56 |
} else { |
| 566 |
estlane |
9.56 |
if ($curr_pos > 0) { |
| 567 |
estlane |
9.56 |
$text_parts[] = array('text' => substr($text, 0, $curr_pos), 'code' => false, 'subc' => false); |
| 568 |
estlane |
9.56 |
} |
| 569 |
estlane |
9.56 |
$text_parts[] = array( |
| 570 |
estlane |
9.56 |
'text' => substr($text, $curr_pos, $end-$curr_pos+1), |
| 571 |
estlane |
9.56 |
'code' => $code, |
| 572 |
estlane |
9.56 |
'subc' => $sub); |
| 573 |
estlane |
9.56 |
$text = substr($text, $end+1); |
| 574 |
estlane |
9.56 |
$str_len = strlen($text); |
| 575 |
estlane |
9.56 |
$curr_pos = 0; |
| 576 |
estlane |
9.56 |
break; |
| 577 |
estlane |
9.56 |
} |
| 578 |
estlane |
9.56 |
} else { |
| 579 |
estlane |
9.56 |
if (substr($code_end, 0, -1) == "[$code") { $depth++; } |
| 580 |
estlane |
9.56 |
$end_pos++; |
| 581 |
estlane |
9.56 |
} |
| 582 |
estlane |
9.56 |
} |
| 583 |
estlane |
9.56 |
$curr_pos++; |
| 584 |
estlane |
9.56 |
} |
| 585 |
estlane |
9.56 |
if ($str_len > 0) { $text_parts[] = array('text' => $text, 'code' => false, 'subc' => false); } |
| 586 |
estlane |
9.56 |
return $text_parts; |
| 587 |
estlane |
9.56 |
} |
| 588 |
estlane |
9.56 |
  |
| 589 |
estlane |
9.56 |
# split the bbcodes and use nl2br on everything except [php] |
| 590 |
estlane |
9.56 |
protected static function split_on_bbcodes($text, $allowed=0, $allow_html=false) |
| 591 |
estlane |
9.56 |
{ |
| 592 |
estlane |
9.56 |
global $bb_codes; |
| 593 |
estlane |
9.56 |
# Split all bbcodes. |
| 594 |
estlane |
9.56 |
$text_parts = BBCode::split_bbcodes($text); |
| 595 |
estlane |
9.56 |
# Merge all bbcodes and do special actions depending on the type of code. |
| 596 |
estlane |
9.56 |
$text = ''; |
| 597 |
estlane |
9.56 |
while ($part = array_shift($text_parts)) { |
| 598 |
estlane |
9.56 |
if ($part['code'] == 'php') { |
| 599 |
estlane |
9.56 |
# [PHP] |
| 600 |
estlane |
9.56 |
$text .= ($allowed) ? BBCode::decode_php($part['text']) : nl2br(htmlspecialchars($part['text'])); |
| 601 |
estlane |
9.56 |
} elseif ($part['code'] == 'code') { |
| 602 |
estlane |
9.56 |
# [CODE] |
| 603 |
estlane |
9.56 |
if (!$allowed && false !== strpos($part['text'], '<')) { |
| 604 |
estlane |
9.56 |
$part['text'] = nl2br(htmlspecialchars($part['text'])); |
| 605 |
estlane |
9.56 |
} |
| 606 |
estlane |
9.56 |
$text .= $allowed ? BBCode::decode_code($part['text']) : $part['text']; |
| 607 |
estlane |
9.56 |
} elseif ($part['code'] == 'quote') { |
| 608 |
estlane |
9.56 |
# [QUOTE] and [QUOTE=""] |
| 609 |
estlane |
9.56 |
if ($part['text'][6] == ']') { |
| 610 |
estlane |
9.56 |
$text .= $bb_codes['quote'].BBCode::split_on_bbcodes(substr($part['text'], 7, -8), $allowed, $allow_html).$bb_codes['quote_close']; |
| 611 |
estlane |
9.56 |
} else { |
| 612 |
estlane |
9.56 |
$part['text'] = preg_replace('/\[quote=["]*(.*?)["]*\]/si', $bb_codes['quote_name'], BBCode::split_on_bbcodes(substr($part['text'], 0, -8), $allowed, $allow_html), 1); |
| 613 |
estlane |
9.56 |
$text .= $part['text'].$bb_codes['quote_close']; |
| 614 |
estlane |
9.56 |
} |
| 615 |
estlane |
9.56 |
} elseif ($part['subc']) { |
| 616 |
estlane |
9.56 |
$tmptext = '['.BBCode::split_on_bbcodes(substr($part['text'], 1, -1)).']'; |
| 617 |
estlane |
9.56 |
$text .= ($part['code'] == 'list') ? BBCode::decode_list($tmptext) : $tmptext; |
| 618 |
estlane |
9.56 |
unset($tmptext); |
| 619 |
estlane |
9.56 |
} else { |
| 620 |
estlane |
9.56 |
if ($allow_html) { |
| 621 |
estlane |
9.56 |
$tmptext = (false === strpos($part['text'], '<') ? nl2br($part['text']) : $part['text']); |
| 622 |
estlane |
9.56 |
} else { |
| 623 |
estlane |
9.56 |
$tmptext = nl2br(BBCode::encode_html($part['text'])); |
| 624 |
estlane |
9.56 |
} |
| 625 |
estlane |
9.56 |
$text .= ($part['code'] == 'list') ? BBCode::decode_list($tmptext) : $tmptext; |
| 626 |
estlane |
9.56 |
unset($tmptext); |
| 627 |
estlane |
9.56 |
} |
| 628 |
estlane |
9.56 |
} |
| 629 |
estlane |
9.56 |
return $text; |
| 630 |
estlane |
9.56 |
} |
| 631 |
estlane |
9.56 |
  |
| 632 |
estlane |
9.56 |
protected static function decode_code($text) |
| 633 |
estlane |
9.56 |
{ |
| 634 |
estlane |
9.56 |
global $bb_codes; |
| 635 |
estlane |
9.56 |
$text = substr($text, 6, -7); |
| 636 |
estlane |
9.56 |
$code_entities_match = array('#<#', '#>#', '#"#', '#:#', '#\[#', '#\]#', '#\(#', '#\)#', '#\{#', '#\}#'); |
| 637 |
estlane |
9.56 |
$code_entities_replace = array('<', '>', '"', ':', '[', ']', '(', ')', '{', '}'); |
| 638 |
estlane |
9.56 |
$text = preg_replace($code_entities_match, $code_entities_replace, $text); |
| 639 |
estlane |
9.56 |
return $bb_codes['code_start']."<pre>$text</pre>".$bb_codes['code_end']; |
| 640 |
estlane |
9.56 |
} |
| 641 |
estlane |
9.56 |
  |
| 642 |
estlane |
9.56 |
protected static function decode_php($text) |
| 643 |
estlane |
9.56 |
{ |
| 644 |
estlane |
9.56 |
global $bb_codes; |
| 645 |
estlane |
9.56 |
$text = str_replace("\r\n", "\n", substr($text, 5, -6)); # Windows |
| 646 |
estlane |
9.56 |
$text = str_replace("\r", "\n", $text); # Mac |
| 647 |
estlane |
9.56 |
$text = str_replace("\t", '/*t*/', $text); # Temporary tab fix |
| 648 |
estlane |
9.56 |
$text = htmlunprepare($text, true); |
| 649 |
estlane |
9.56 |
$added = FALSE; |
| 650 |
estlane |
9.56 |
if (preg_match('/^<\?.*/', $text) <= 0) { |
| 651 |
estlane |
9.56 |
$text = "<?php\n$text"; |
| 652 |
estlane |
9.56 |
$added = TRUE; |
| 653 |
estlane |
9.56 |
} |
| 654 |
estlane |
9.56 |
$text = highlight_string($text, TRUE); |
| 655 |
estlane |
9.56 |
if ($added == TRUE) { |
| 656 |
estlane |
9.56 |
$text = preg_replace('/^(.*)\n.*php<br \/><\/span>/i', "\\1\n", $text, 1); |
| 657 |
estlane |
9.56 |
$text = preg_replace('/^(.*)\n(.*)>.*php<br \/>/i', "\\1\n\\2>", $text, 1); |
| 658 |
estlane |
9.56 |
} |
| 659 |
estlane |
9.56 |
$text = str_replace('[', '[', $text); |
| 660 |
estlane |
9.56 |
$text = str_replace("\n", '', $text); |
| 661 |
estlane |
9.56 |
$text = str_replace(' ', ' ', $text); |
| 662 |
estlane |
9.56 |
$text = str_replace('/*t*/', "\t", $text); |
| 663 |
estlane |
9.56 |
$text = preg_replace('#<span style="color: \#[A-F0-9]{6}">([\t]+)</span>#', '\\1', $text); |
| 664 |
estlane |
9.56 |
return $bb_codes['php_start']."<pre>$text</pre>".$bb_codes['php_end']; |
| 665 |
estlane |
9.56 |
} |
| 666 |
estlane |
9.56 |
  |
| 667 |
estlane |
9.56 |
protected static function decode_list($text) |
| 668 |
estlane |
9.56 |
{ |
| 669 |
estlane |
9.56 |
// &(?![a-z]{2,6};|#[0-9]{1,4};) |
| 670 |
estlane |
9.56 |
$items = explode('[*]', $text); |
| 671 |
estlane |
9.56 |
$text = array_shift($items).'<li>'; |
| 672 |
estlane |
9.56 |
$text .= implode('</li><li>', $items); |
| 673 |
estlane |
9.56 |
if (count($items) > 1) $text = str_replace('[/list', '</li>[/list', $text); |
| 674 |
estlane |
9.56 |
$text = preg_replace("#<br />[\r\n]+</li>#", "</li>\n", $text); |
| 675 |
estlane |
9.56 |
unset($items); |
| 676 |
estlane |
9.56 |
# [list] and [list=x] for (un)ordered lists. |
| 677 |
estlane |
9.56 |
# unordered lists |
| 678 |
estlane |
9.56 |
$text = preg_replace('#\[list\]#i', '<ul>', $text); |
| 679 |
estlane |
9.56 |
$text = preg_replace('#\[/list:u\]#i', '</ul>', $text); |
| 680 |
estlane |
9.56 |
$text = preg_replace('#\[/list\]#i', '</ul>', $text); |
| 681 |
estlane |
9.56 |
# Ordered lists |
| 682 |
estlane |
9.56 |
$text = preg_replace('#\[list=([ai1])\]#i', '<ol type="\\1">', $text); |
| 683 |
estlane |
9.56 |
$text = preg_replace('#\[/list:o\]#i', '</ol>', $text); |
| 684 |
estlane |
9.56 |
  |
| 685 |
estlane |
9.56 |
$text = preg_replace('#(<[ou]l.*?>)<br />#s', '\\1', $text); |
| 686 |
estlane |
9.56 |
return $text; |
| 687 |
estlane |
9.56 |
} |
| 688 |
djmaze |
9.20 |
  |
| 689 |
estlane |
9.59 |
} |