The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
PHP Help, Stripping HTML tags and updating MySQL.
Hi all
I am looking for a bit of help in PHP. For my forums DB, I want to programatically update every posts content with the same content minus all the HTML tags. Basically a small PHP app to connect to Mysql, open the post table, extract the pagetext value, strip all HTML tags from it write it back to that record loop to the next record. Due to my distinct lack of PHP knowledge I am struggling with the looping bit and retrieve/modify/update bit, so I appreciate some kind soul showing me the right direction. Thanks in advance Cheers Bruce |
#2
|
|||
|
|||
When the posts are brought out of the database they are script of all the html tags, etc if you have html turn off and bbcode code is added.
|
#3
|
||||
|
||||
Quote:
Cheers Bruce |
#4
|
|||
|
|||
The 'post' table only stores the post with BBCode, unless you had HTML enabled on your board or something?
|
#5
|
||||
|
||||
Quote:
So, I need to remove all BBcode tags and restore the text to the Verdana, size 2 set. Any pointers to how I would do that - sites, texts, books, anything? Cheers Bruce |
#6
|
||||
|
||||
You'll need some regex replacements. (I hate regex, as it's really confusing, but I'm giving it a shot .)
PHP Code:
|
#7
|
||||
|
||||
Thank you Sir.
Armed with that I went searching on Google and found this: Code:
function stripBBCode($text_to_search) { $pattern = '|[[\/\!]*?[^\[\]]*?]|si'; $replace = ''; return preg_replace($pattern, $replace, $text_to_search); } [ QUOTE ] [ /QUOTE ] [ QUOTE= [ B ] [ I ] [ U ] or any of the other basic ones? (spaces included on purpose so the forum doesn't try and use them) I did find this function as well: Code:
function stripBBCode($stringInput) { if (strpos($stringInput, '[') !== false) { $validBBCodeArray = array( 'b', 'i', 'u', 'url', 'quote', ); $validBBCode = join('|', $validBBCodeArray); $stringOutput = preg_replace( '@\[(?:\/{0,1}?)(?:' . $validBBCode . ')(?:\s{0,1}?)(?:\/{0,1}?)\]@', '', $stringInput ); } else { $stringOutput = $stringInput; } return $stringOutput; } All the help so far is being appreciated I assure you. Now for that last little step Cheers Bruce |
#8
|
||||
|
||||
Try this (it will strip all font and size tags, but nothing else):
PHP Code:
|
#9
|
||||
|
||||
Thanks Hanson
I tried that but it strips everything *but* the font & size tags I have tried nutting this one out myself but am still lost. Cheers Bruce |
#10
|
|||
|
|||
where do i put this code i would like to get rid of html used on my forum to as when i first opened many post's were made using html and i would prefer it to be bb code where do i put the code ?
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|