Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
Register FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-06-2011, 11:44 AM
Scathefire Scathefire is offline
 
Join Date: Oct 2006
Posts: 19
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Strip bbcode from posts with mysql query

Hello,

I am wanting to remove formatting from post text such as font, size, and color.

sample text

I need to preserve things such as bold/italic/underline. So the above text would turn out like:

sample text


Is there a database query I could run on the posts table that would accomplish this? Can someone provide an example?
Reply With Quote
  #2  
Old 07-06-2011, 01:18 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't know if there's an easy way to do it using a query, but you can use a small php script. Borrowing a nice script that Adrian posted in this thread https://vborg.vbsupport.ru/showthread.php?t=266166 , you could do something like this:

PHP Code:
<?php

error_reporting(E_ALL ^ E_NOTICE ^ 8192);

require('./global.php');

$result = $vbulletin->db->query_read("SELECT postid, pagetext FROM " . TABLE_PREFIX . "post");

while ($post = $vbulletin->db->fetch_array($result)) {    
$new = preg_replace("#\[/?(color|size|font)(=\s*\"?.*?\"?\s*)?]#i", '', $post['pagetext']);
   if ($new != $post['pagetext'])
   {
       $vbulletin->db->query_write(fetch_query_sql(
           array('pagetext' => $new),
           'post',
           'WHERE postid = ' . $post['postid']
       ));
   }
}  

die('Done');
(I tried this out, but you'd probably want to back up the db before running this, just in case).
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 03:10 PM.


Powered by vBulletin® Version 3.9.0
Copyright ©2000 - 2017, vBulletin Solutions Inc.