The Arcive of vBulletin Modifications Site. |
|
|
#1
|
||||
|
||||
|
Hello,
We have two hacks/tweaks in that file, one is a table hack (using custom BB code in ACP results in dangerous code) and a line that strips html (imported code left from ancient boards like UBB). This was the code that stripped HTML Code:
inlucudes/functions_bbcodeparse.php
1. find
// ###################### Start bbcodeparse2 #######################
function parse_bbcode2($bbcode, $dohtml, $dobbimagecode, $dosmilies, $dobbcode, $iswysiwyg = 0, $donl2br = 1)
{
// parses text for vB code, smilies and censoring
global $DB_site, $vboptions, $bbuserinfo, $templatecache, $smiliecache;
global $html_allowed;
add
//strip html M:\vbul-hacks\striphtml\vBulletin_org Forum - Removing HTML Code From Posts.htm
$bbcode = strip_tags(unhtmlspecialchars($bbcode));
//End Hack
Code:
BB code tables by JohnWoo :)
It still needs optimization, but should work fine already :)
How it works :
1) starting code is [table] or [table 1 2 3] where
1 2 3 any numbers separated by space
first - border
second - cellpadding
third - cellspacing
- ending tag is always [/table]
- table lines separated by line break
- each line can have 7 styles. To specify a style add in the beginning number and ^ symbol without spaces
example:
2^
you may skip 7^ - it is default (alt1) style
- ceils in line separated by |
- there is no need to add | before first and after last ceil
- each ceil can have each own align. Use align mark as a first symbol of ceil without spaces
blank (default) - left
= - center
~ - right
- you can use any other BB code inside ceils :)
- if number of ceils different in lines, last ceil of shorter lines will get colspan= with needed number
so table in post may look like
[table 1 3 0]
1|2|test 16798789789797979799879797979|4|5|6|7
1^~right with colspan
2^333|=center with colspan
3^1|2|left with colspan
4^1|~center without colspan|3|4|5|6|7
5^1|blablabla|3|4|5
6^1|2|3|4|5|6|7
[/table]
code changes
includes/functions_bbcodeparse.php
1. find
// do new lines
$wysiwygtype = null;
before it add
$bbcode = preg_replace("~(\[table.+\[/table\])~iUse", "fetch_html_table('\\1')", $bbcode);
2. in the end of file add 2 functions.
function get_table_class($id) {
$id = intval($id);
if ($id == 1) {
return " class=\"alt2\"";
} elseif ($id == 2) {
return " class =\"tcat\"";
} elseif ($id == 3) {
return " class=\"tfoot\"";
} elseif ($id == 4) {
return " class=\"highlight\"";
} elseif ($id == 5) {
return " class=\"alt3\"";
} elseif ($id == 6) {
return " class=\"smallfont\"";
} else {
return " class =\"alt1\"";
}
}
function fetch_html_table ($tblcode) {
if (preg_match("~\[table( (\d)+ (\d)+ (\d)+|)\](.+)\[/table\]~isU", $tblcode, $rows)) {
$params = "";
if (strlen($rows[2]) > 0) {
$params .= " border=\"".intval($rows[2])."\"";
}
if (strlen($rows[3]) > 0) {
$params .= " cellpadding=\"".intval($rows[3])."\"";
}
if (strlen($rows[4]) > 0) {
$params .= " cellspacing=\"".intval($rows[4])."\"";
}
$bb_table = array();
$tbl_k=0;
$tbl_max = 0;
$tbl_all = split("\n",trim($rows[5]));
if (is_array($tbl_all)) {
foreach ($tbl_all as $tbl_i => $tbl_string) {
$bb_table[$tbl_k] = array();
preg_match("~((\d)\^|)(.+)~", trim($tbl_string), $tbl_new);
$bb_table[$tbl_k]["class"] = get_table_class(intval($tbl_new[2]));
$tbl_c = split("\|", $tbl_new[3]);
$tbl_l = 0;
if (is_array($tbl_c)) {
foreach ($tbl_c as $tbl_ii => $tbl_ss) {
$bb_table[$tbl_k][$tbl_l] = array();
$bb_table[$tbl_k][$tbl_l]["align"] = "";
preg_match("#(=|~|)(.+)#", $tbl_ss, $tbl_ceil);
if ($tbl_ceil[1] == "=") {
$bb_table[$tbl_k][$tbl_l]["align"] = " align=\"center\"";
} elseif ($tbl_ceil[1] == "~") {
$bb_table[$tbl_k][$tbl_l]["align"] = " align=\"right\"";
}
$bb_table[$tbl_k][$tbl_l]["text"] = trim($tbl_ceil[2]);
$tbl_l++;
unset($tbl_ceil);
}
}
if ($tbl_max < $tbl_l) {
$tbl_max = $tbl_l;
}
$tbl_k++;
}
}
$html_table = "<table".$params.">";
foreach ($bb_table as $id => $this_row) {
$html_table .="<tr>";
$k = count($this_row)-2;
for ($i=0;$i < $k;$i++) {
if (array_key_exists($i, $bb_table[$id]) && strlen($bb_table[$id][$i]["text"]) > 0) {
$html_table .="<td".$bb_table[$id]["class"].$bb_table[$id][$i]["align"].">".$bb_table[$id][$i]["text"]."</td>";
} else {
$html_table .="<td> </td>";
}
}
if ($k+1 < $tbl_max) {
$html_table .="<td".$bb_table[$id]["class"].$bb_table[$id][$k]["align"]." colspan=\"".($tbl_max-$k)."\">".$bb_table[$id][$k]["text"]."</td>";
} else {
$html_table .="<td".$bb_table[$id]["class"].$bb_table[$id][$k]["align"].">".$bb_table[$id][$k]["text"]."</td>";
}
$html_table .="</tr>";
}
$html_table .= "</table>";
return $html_table;
} else {
return $tblcode;
}
}
|
|
#2
|
||||
|
||||
|
Any ideas about this HTML stripper and table tag for 3.5?
|
|
#3
|
||||
|
||||
|
Yes: I can say that it can be quite easily done with Plugins in vBulletin 3.5
|
|
#4
|
||||
|
||||
|
Quote:
|
|
#5
|
||||
|
||||
|
Code:
$bbcode = strip_tags(unhtmlspecialchars($bbcode)); |
|
#6
|
|||
|
|||
|
I've added this code, but I'm not seeing the table in my posts. Can someone help me out with this?
|
|
#7
|
||||
|
||||
|
Quote:
|
|
#8
|
|||
|
|||
|
Someone here?
I need this too... |
![]() |
|
|
| X vBulletin 3.8.12 by vBS Debug Information | |
|---|---|
|
|
More Information |
|
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|