Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-11-2005, 03:16 PM
TosaInu's Avatar
TosaInu TosaInu is offline
 
Join Date: Jul 2004
Posts: 256
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default bbcodeparse.php

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
The author who made the table hack isn't going to port it (afaik), it's a code that can have some options and is frequently used. It adds new code only and I wonder whether it would just work in some new file?

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>&nbsp;</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;
	}
}
Reply With Quote
  #2  
Old 09-15-2005, 07:29 PM
TosaInu's Avatar
TosaInu TosaInu is offline
 
Join Date: Jul 2004
Posts: 256
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Any ideas about this HTML stripper and table tag for 3.5?
Reply With Quote
  #3  
Old 09-16-2005, 04:32 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes: I can say that it can be quite easily done with Plugins in vBulletin 3.5
Reply With Quote
  #4  
Old 09-17-2005, 05:29 PM
TosaInu's Avatar
TosaInu TosaInu is offline
 
Join Date: Jul 2004
Posts: 256
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by KirbyDE
Yes: I can say that it can be quite easily done with Plugins in vBulletin 3.5
That's good news.
Reply With Quote
  #5  
Old 10-03-2005, 10:20 AM
TosaInu's Avatar
TosaInu TosaInu is offline
 
Join Date: Jul 2004
Posts: 256
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
$bbcode = strip_tags(unhtmlspecialchars($bbcode));
Our board is a grab together of several older boards and it contains quite some HTML. I've been busy with a text stripper from vb.com to edit it out (should make this always on processing step obsolete and would reduce database size a little bit, but it didn't work out that great). The database is way too big to edit it out by hand, and a script would even timeout because of the PHP/Apache settings. There was a rebuild thread tool in another board we used and thus I wonder whether it's possible to have a html stripper thead tool: get rid of old html in the database and avoid timeouts while doing so because of huge queries, because you only order one thread at a time to be cleaned.
Reply With Quote
  #6  
Old 10-27-2005, 09:00 PM
silurius silurius is offline
 
Join Date: Oct 2004
Posts: 404
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've added this code, but I'm not seeing the table in my posts. Can someone help me out with this?
Reply With Quote
  #7  
Old 11-08-2005, 12:29 AM
Detomah's Avatar
Detomah Detomah is offline
 
Join Date: Sep 2003
Location: South Shields UK
Posts: 217
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Andreas
Yes: I can say that it can be quite easily done with Plugins in vBulletin 3.5
Could you possibly help me with this an explain the easy way you mention that this could be done with plugins please, as i've not got a clue how to include that table code as a plugin and get it to actually work?
Reply With Quote
  #8  
Old 04-08-2006, 05:29 PM
MaLTRaiN MaLTRaiN is offline
 
Join Date: Feb 2005
Posts: 87
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Someone here?
I need this too...
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:41 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03966 seconds
  • Memory Usage 2,239KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete