1. 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?

Discussion in 'Installation, Upgrade, and Import Support' started by Stuart Wright, Sep 11, 2013.

  1. Stuart Wright

    Stuart Wright Well-Known Member

    Most are domains which we banned to stop spammers.
    It would take ages to add all 300.
    Can I just write an SQL query to do it?
    Thanks
     
  2. Rigel Kentaurus

    Rigel Kentaurus Well-Known Member

    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: Sep 11, 2013
  3. Stuart Wright

    Stuart Wright Well-Known Member

    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?
     
  4. Rigel Kentaurus

    Rigel Kentaurus Well-Known Member

    change 'exact' to 'any'
     
  5. Stuart Wright

    Stuart Wright Well-Known Member

    Worked perfectly, many thanks. The kitchen and indian yoga spammers will continue to be thwarted.
     
    DRE, Rigel Kentaurus and BamaStangGuy like this.
  6. Mike

    Mike XenForo Developer Staff Member

    You may be better off using the "spam phrases" option for them, and you can force the posts into moderation or just reject them.
     
  7. Stuart Wright

    Stuart Wright Well-Known Member

    Didn't even know that existed. You're right. Thanks, Mike. Excellent.
    Just need a built-in multiple account detector now.
     
    Last edited: Sep 11, 2013
  8. RoldanLT

    RoldanLT Well-Known Member

    Could you please change the script to cater spam phrases ?
    Thanks !
     
  9. Brandon Sheley

    Brandon Sheley Well-Known Member

  10. Stuart Wright

    Stuart Wright Well-Known Member

    You don't need it. The spam phrases are stored in a text box. Just get your existing spam phrases and arrange them into a list. I used search and replace in word.
     
    RoldanLT likes this.

Share This Page