• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.2 Transferring 300 censored words from vB to Xenforo. Is there a quick way?

Rigel Kentaurus

Well-known member
#2
Can't be done with queries because the information is serialized. However, I did a small script for you.

Save this as "updateCensor.php" on your XenForo installation, then open http://yoursite.com/updateCensor.php

Also, change the word list (from Ugly to Fantastic in the example) to the list that you want to use

Code:
<?php

$censor = <<<HERE

Ugly
Terrible
Words
Nasty
Fantasstic

HERE;


####################################################################################################
# Do not change anything below this
####################################################################################################

$words = trim($censor);
$words = preg_split("#[\r\n]+#", $words);
sort($words);
$data = array();
foreach ($words as $w)
{
    $data['exact'][$w] = strlen($w);
}


$startTime = microtime(true);
$fileDir = dirname(__FILE__);

require($fileDir . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
XenForo_Application::initialize($fileDir . '/library', $fileDir);
XenForo_Application::set('page_start_time', $startTime);

$db = XenForo_Application::getDb();
$db->query("UPDATE xf_option SET option_value = ? WHERE option_id='censorWords'", serialize($data));
print "Done";
 
Last edited:

Stuart Wright

Well-known member
#3
Thanks so much!
The vast majority of our censor words are parts of domains (recently relating to kitchens) so I would rather have the exact tickbox unticked for all the censored words and then go through and tick it for the few where I want an exact match. I assume that $data['exact'] sets the exact option. Can I change this to something else to achieve what I want?
 

Mike

XenForo developer
Staff member
#6
You may be better off using the "spam phrases" option for them, and you can force the posts into moderation or just reject them.
 

Stuart Wright

Well-known member
#7
You may be better off using the "spam phrases" option for them, and you can force the posts into moderation or just reject them.
Didn't even know that existed. You're right. Thanks, Mike. Excellent.
Just need a built-in multiple account detector now.
 
Last edited:

RoldanLT

Well-known member
#8
Can't be done with queries because the information is serialized. However, I did a small script for you.

Save this as "updateCensor.php" on your XenForo installation, then open http://yoursite.com/updateCensor.php

Also, change the word list (from Ugly to Fantastic in the example) to the list that you want to use

Code:
<?php

$censor = <<<HERE

Ugly
Terrible
Words
Nasty
Fantasstic

HERE;


####################################################################################################
# Do not change anything below this
####################################################################################################

$words = trim($censor);
$words = preg_split("#[\r\n]+#", $words);
sort($words);
$data = array();
foreach ($words as $w)
{
    $data['exact'][$w] = strlen($w);
}


$startTime = microtime(true);
$fileDir = dirname(__FILE__);

require($fileDir . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
XenForo_Application::initialize($fileDir . '/library', $fileDir);
XenForo_Application::set('page_start_time', $startTime);

$db = XenForo_Application::getDb();
$db->query("UPDATE xf_option SET option_value = ? WHERE option_id='censorWords'", serialize($data));
print "Done";
Could you please change the script to cater spam phrases ?
Thanks !