Word censoring/replacement with phpBB

Discussion about the Google Search Engine. SEO, PageRank, AdSense, AdWords, Use and other Services.

Moderator: Moderators

Word censoring/replacement with phpBB

Postby euroman » Tue Oct 31, 2006 11:57 pm

Would it be possible to make a small mod so its only guests that get effected by word censoring ?

The reason:

Sometimes Adsense gets beserk with certain topics. Fx. we had a user calling himself Tomcat and suddenly we get a lot of animal related ads. I had to rename him to tomc_at to get the ads back to normal.

It would be nice if it only was guests that gets effected and not the regular members when using word censoring to stear Adsense in the right direction.
euroman
PR0
PR0
 
Posts: 81
Joined: Sat Oct 21, 2006 10:18 pm

Advertisement

Postby dcz » Wed Nov 01, 2006 11:51 am

Actually, it's not a bad idea.

And I think it's easy to do :

Open :

Code: Select all
Includes/functions.php



Find :

Code: Select all
function obtain_word_list(&$orig_word, &$replacement_word)
{
   global $db;

   //
   // Define censored word matches
   //
   $sql = "SELECT word, replacement
      FROM  " . WORDS_TABLE;
   //Begin sql cache
   //if( !($result = $db->sql_query($sql)) )
   if( !($result = $db->sql_query($sql, false, true)) )
   //End sql cache
   {
      message_die(GENERAL_ERROR, 'Could not get censored words from database', '', __LINE__, __FILE__, $sql);
   }

   if ( $row = $db->sql_fetchrow($result) )
   {
      do
      {
         $orig_word[] = '#\b(' . str_replace('\*', '\w*?', preg_quote($row['word'], '#')) . ')\b#i';
         $replacement_word[] = $row['replacement'];
      }
      while ( $row = $db->sql_fetchrow($result) );
   }

   return true;
}


Replace with :


Code: Select all
function obtain_word_list(&$orig_word, &$replacement_word)
{
   global $db, $userdata;
   // www.phpBB-SEO.com SEO TOOLKIT BEGIN
   // Only return the censoring to guests users
   if( $userdata['session_logged_in'] ) {
      //
      // Define censored word matches
      //
      $sql = "SELECT word, replacement
         FROM  " . WORDS_TABLE;
      //Begin sql cache
      //if( !($result = $db->sql_query($sql)) )
      if( !($result = $db->sql_query($sql, false, true)) )
      //End sql cache
      {
         message_die(GENERAL_ERROR, 'Could not get censored words from database', '', __LINE__, __FILE__, $sql);
      }

      if ( $row = $db->sql_fetchrow($result) )
      {
         do
         {
            $orig_word[] = '#\b(' . str_replace('\*', '\w*?', preg_quote($row['word'], '#')) . ')\b#i';
            $replacement_word[] = $row['replacement'];
         }
         while ( $row = $db->sql_fetchrow($result) );
      }
   } else {
      $orig_word = $replacement_word = array();
   }
   // www.phpBB-SEO.com SEO TOOLKIT END

   return true;
}


But, this means there won't be any censoring for logged users. And, if for example a word is censored in a topic title, it will thus be replaced in URL for guests, and AdSense will see the logged in version of it if the page is loaded by a logged in user.
This mean the zero duplicate would be necessary to avoid duplicate content, even if the problem should not occur that often.

Another way to turn around this would be to set up your AdSense account to filter such bad adds.

Though, this make me think that we could use a separate censoring word list for anything injected in URLs, but this would mean many more changes.

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21429
Joined: Fri Apr 28, 2006 9:03 pm

Postby euroman » Wed Nov 01, 2006 12:22 pm

Thats cool :D

I am using simple rewrite with no words in urls - so that means I can use your suggestet mod as is with no problems - right ?

The ultimate solution I think would be that the censoring was only active for one (or a couple?) IP namely Mediapartners-Google/2.1. That way only the adsense bot would se the censoring and not even other guests or the google "content bot" (ie the search results in google wouldnt be affected). Dont know if thats easy or difficult to implement ?

Also if it was only Adsense bot who could see censured words you could actully use censoring as a tool - say replacing common words with special searchwords you want to affect the ads.
euroman
PR0
PR0
 
Posts: 81
Joined: Sat Oct 21, 2006 10:18 pm

Postby dcz » Wed Nov 01, 2006 5:19 pm

Exactly, this is safe to use up to the phpBB SEO mixed mod rewrite, as we should not use tricky keywords in our forums and categories URLs.

Then, censoring based on IP and / OR User Agent recognition would mean cloaking, eg showing different content to bots than to human.
And this is not a good thing to do as it's on of the number one way to get blacklisted by Google.

Have you had a look to your AdSense filters ?
And, at least for User names, the regular user name censoring would be enough to prevent bad user name registration.

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21429
Joined: Fri Apr 28, 2006 9:03 pm

Postby euroman » Wed Nov 01, 2006 5:47 pm

OK you are right.

I just tried the MOD but nothing happens at all. The censored words are still censored both for the logged in users and for the guests ??
euroman
PR0
PR0
 
Posts: 81
Joined: Sat Oct 21, 2006 10:18 pm

Postby dcz » Wed Nov 01, 2006 5:55 pm

Are you sure it's not due to your browser's cache ?
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21429
Joined: Fri Apr 28, 2006 9:03 pm

Postby euroman » Wed Nov 01, 2006 6:08 pm

Yes even if I close all windows first - then reopen the window- press refresh - log on with a different user. No change - word censoring still in effect. Also tried to add a new censored word - still censoring.

I have just copied the code as is - I have not removed any // or so.


This is from includes/functions.php I just downloaded from my site:
Code: Select all
//
// Obtain list of naughty words and build preg style replacement arrays for use by the
// calling script, note that the vars are passed as references this just makes it easier
// to return both sets of arrays
//
function obtain_word_list(&$orig_word, &$replacement_word)
{
global $db, $userdata;
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
// Only return the censoring to guests users
if( $userdata['session_logged_in'] ) {
//
// Define censored word matches
//
$sql = "SELECT word, replacement
FROM " . WORDS_TABLE;
//Begin sql cache
//if( !($result = $db->sql_query($sql)) )
if( !($result = $db->sql_query($sql, false, true)) )
//End sql cache
{
message_die(GENERAL_ERROR, 'Could not get censored words from database', '', __LINE__, __FILE__, $sql);
}

if ( $row = $db->sql_fetchrow($result) )
{
do
{
$orig_word[] = '#\b(' . str_replace('\*', '\w*?', preg_quote($row['word'], '#')) . ')\b#i';
$replacement_word[] = $row['replacement'];
}
while ( $row = $db->sql_fetchrow($result) );
}
} else {
$orig_word = $replacement_word = array();
}
// www.phpBB-SEO.com SEO TOOLKIT END

return true;
}

//
// This is general replacement for die(), allows templated
// output in users (
euroman
PR0
PR0
 
Posts: 81
Joined: Sat Oct 21, 2006 10:18 pm

Postby dcz » Wed Nov 01, 2006 6:20 pm

Oh sorry you want to only censor for guests lol, not to users only, so find :

Code: Select all
if( $userdata['session_logged_in'] ) {


Replace with :
Code: Select all
if( !$userdata['session_logged_in'] ) {


++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21429
Joined: Fri Apr 28, 2006 9:03 pm

Postby euroman » Wed Nov 01, 2006 6:26 pm

Works now - Thanks :)
euroman
PR0
PR0
 
Posts: 81
Joined: Sat Oct 21, 2006 10:18 pm

Postby guyer » Fri Nov 07, 2008 8:27 am

I made a small modification to the "if" statement above and this patch works wonderfully!

but I have a different problem now: "approved" users can post without being censored, but "unapproved" posters can't see certain words in posts by the "approved" users because of the word censor.

Is there a way to limit the censor (phpbb2) to post making only, but to leaving viewing of posts alone?
guyer
 
Posts: 3
Joined: Fri Oct 17, 2008 10:00 am

Postby dcz » Sun Nov 09, 2008 10:19 am

Well this should not be hard to implement, but this mean that all the post posted before the new way of censoring would not be censored at all, since phpBB2 is keeping the full content of posts in db.

The easiest way would probably be to set up a group for approved user who can post without censoring and then add a condition before censoring in viewtopic.php, if the user who posted the post is part of the group, then bypass else censor ;)
This imply that you'd have to check group for all user who'd have posted in each thread's page, but this can be done with one query if you tweak the display loop a bit.

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21429
Joined: Fri Apr 28, 2006 9:03 pm


Return to Google Forum

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 3 guests