Placing ads on the fluxBB or punBB forum

As a rule, forums do not bring much income, unless there is a lot of traffic on them, because visitors are regulars who ignore ads. If your forum is large enough, you can place ads in the template, subject to certain precautions that we will see later.

Insert AdSense code

The idea comes from the punBB forum.

Create a PHP file with Adsense code inside .

  1. The name may be ads.php.
  2. This file must be placed in the include/user directory.

The code can be created using the echo operator:

echo '<script type="text/javascript">...Adsense content...</script>";

Now go to the include/template directory and edit the main.tpl.
Add this line (you can try different places):

<pun_include "ads.php">

To block forbidden words

Program rules prohibit the use of Adsense on a page that displays words associated with, for example, "p_rn_graphy" or "casin_s",. However, it is not always easy to manage post content on the forum, as it is not immediately readable once posted.
Therefore, ads could appear on pages where spammers entered these prohibited terms.

But we can easily prevent spammers from using certain words with punBB.

First, we define a list of prohibited words and place them in an array:

$words = array(
"first word",
"second word",
"etc." );

Then we create code that blocks these words:

foreach($words as $word)
{
if($stristr($message, $word) !== false))
$errors[] = 'Words forbidden in the post. Access denied';
} 

You can also display the message in English, as most spam in this language:

"Words forbidden in the post. Access denied."

This code should be inserted into the post.php file, after the code that parses the content in these lines:

if ($pun_config['p_message_bbcode'] == '1' && strpos($message, '[') !== false && strpos($message, ']') !== false)
{
require PUN_ROOT.'include/parser.php';
$message = preparse_bbcode($message, $errors);
}

and before sending the message to the database in a block that begins with:

require PUN_ROOT.'include/search_idx.php';

You can allow an administrator to override the lock by inserting a code in the following condition:

if (!$is_admmod)

This works on punBB.
For other CMS, such as phpBB, SMF, and IPB, the code inserted is similar, but the variable names change.

More information