276

(4 replies, posted in PunBB 1.2 discussion)

At the end of the installation, you will be displayed a page with some code you're supposed to copy/paste into a new config.php file.

Administration -> user groups.

Edit those groups you'd like smile

kev1952 wrote:

Okay - I checked and it is MySQL Lite. Here is the line you asked for:

$db_type = 'sqlite';

Well, if you're using MySQL, it should say:

$db_type = 'mysql';

It does not affect posts in any way.

By the way, I've currently re-written the protection a little smile

The next version will probably be posted later this week.

Done:
- Admin plugin to select which scripts to protect/not protect. As simple as clicking a checkbox for the scripts you want to protect smile
- Permanently block IP's after X number of hits.

Partially done:
- Admin plugin to manage each blocked IP

Connorhd wrote:

but surely thats a big performance hit, checking every IP, and even checking it on every view of post.php is bad imo, it should only be checked when a registration or post is attempted. but thats just my opinion tongue

Each IP is only checked once, each hour. Other than that, it's only a single query, selecting a single row, on each page view. I don't think anyone would notice any performance hit. Of course, when checking against the remote server, there will be a slight delay, but as mentioned, it only happens for each user once in 60 minutes smile

But each to his/her own I guess... Just add the spam_protect(); function to the part of post.php/register.php that gets executed on a form submit.. Not that hard really wink

Connorhd wrote:

Maybe this should have instructions to be run specifically when a user registers or a post is posted?

That's quite simple... Just add spam_protect(); to the register.php, post.php & perhaps edit.php files, instead of common.php smile

That being said, the reason I would recommend people to add it to their common.php, is to prevent SPAM bots from harvesting e-mails in topics etc..

I'm currently working on the next version of this, that will add the possibility of permanently blocking users after X failed attempts + a admin plugin (maybe wink).

Tobi wrote:

Well, I don't see anything. Which can be a good or a bad sign... smile
At least there is no error appearing so I figure it works OK.

Hehe, I'd say that's a good sign wink As for testing, try adding spam_protect('127.0.0.2'); instead of spam_protect();.

If that displays an error message, then everything works just as it should smile

283

(2 replies, posted in Programming)

Unfortunately, no, there's no good way of doing that.. When selecting fonts, I'd suggest you to take a look over @ the VisiBone Font Survey Results. It helps a lot smile

Tobi wrote:

Now, that is one useful mod!

Thanks, I will definitely give it  a try.

Let me know if you have any questions/problems. I've tested it on both Windows & Linux, and didn't encounter any problems yet...but you never know wink

##
##
##        Mod title:  Spam Protection MOD
##
##      Mod version:  1.1
##   Works on PunBB:  1.2, 1.2.8
##     Release date:  2005-10-03
##           Author:  Öyvind A. Sörensen (codexp@tasarinan.com)
##
##      Description:  Add SPAM (trough spamhaus.org) protection to your
##                    forum! Block those f**kers from your site completely! ;)
##                    Now with admin plugins to configure several new
##                    options, like permanent blocking, which files to protect,
##                    "trusted" users, check frequency + more!
##
##   Affected files:  include/functions.php
##                    include/common.php
##
##       Affects DB:  Yes (adds a new table) + 2 new values to your
##                    config table
##
##            Notes:  This MOD will add spam protection to your forum.
##                    It will check the visitors IP against the SBL/XBL
##                    records at http://www.spamhaus.org
##                    The script will also block the use of most open
##                    proxies.
##                    If a record is returned, it will block the visitor
##                    from the scripts you specify. The results for that
##                    IP will be stored in the database for 1 hour (by default)
##                    before it's checked again. The reason for this is that
##                    the list is only updated once each hours, and also
##                    to prevent unnecessary slowdown to your forum.
##
##       DISCLAIMER:  Please note that "mods" are not officially supported by
##                    PunBB. Installation of this modification is done at your
##                    own risk. Backup your forum database and any and all
##                    applicable files before proceeding.
##
##


#
#---------[ 1. UPLOAD ]-------------------------------------------------------
#

install_mod.php to /
AP_SPAM_Protect_Scripts.php /plugins/
AP_SPAM_Protect_Settings.php /plugins/


#
#---------[ 2. RUN ]----------------------------------------------------------
#

install_mod.php

(Choose UPGRADE if you've installed v1.0 of this mod)


#
#---------[ 3. DELETE ]-------------------------------------------------------
#

install_mod.php


#
#---------[ 4. OPEN ]---------------------------------------------------------
#

include/functions.php


#
#---------[ 5. FIND (line: 25) ]---------------------------------------------
#

//
// Cookie stuff!
//


#
#---------[ 6. BEFORE, ADD ]-------------------------------------------------
#

//
// Spam & anonymizer protection (mod by codexp@tasarinan.com)
// SPM_start
function spam_protect($installed = TRUE, $ip = FALSE)
{
  global $db, $pun_config, $pun_user;

  // If we have defined that the script is not installed, quit here. 
  // Usage to disable: spam_protect(FALSE);
  if($installed === FALSE) return;
  
  // If script is not protected, or the config variables doesn't exist, end check here
  if (!in_array(basename($_SERVER['PHP_SELF']), explode(',', $pun_config['mod_spam_protect'])) || !array_key_exists('mod_spam_settings', $pun_config) || !array_key_exists('mod_spam_protect', $pun_config)):
            return;
    endif;

  // Get the config string, and generate an array from it..
    $config = explode(',', $pun_config['mod_spam_settings']);

    // Make the config array keys a little more readable for Homo sapiens ;)
    $config = array('server'         => $config[0],
                                    'expire'        => intval($config[1]),
                                    'max'                => intval($config[2]),
                                    'trust'            => intval($config[3]),
                                    'chk_admin'    => intval($config[4]),
                                    'chk_mods'    => intval($config[5])
                                    );

    // If we don't want to check admins/mods, or have enable the 'trusted' feature, end here.
    switch(TRUE):
        case($pun_user['g_id'] == PUN_ADMIN && $config['chk_admin'] === 0):
        case($pun_user['g_id'] == PUN_MOD && $config['chk_mods'] === 0):
        case($pun_user['num_posts'] >= $config['trust'] && $config['trust'] !== 0):
                return;
        default:
                break;
    endswitch;

    // If no 'test ip' defined, get the IP address...PunBB style ;)
  if($ip === FALSE):
            $ip = get_remote_address();
    endif;

  // Get the current users IP information from the DB, if any exists
  $result = $db->query('SELECT ip, time, blocked, total FROM '.$db->prefix.'spam_protect WHERE ip=\''.$ip.'\' LIMIT 1') or error('Unable to get spam protection', __FILE__, __LINE__, $db->error());
  $cur_status = $db->fetch_assoc($result);

  // Language definitions
  $eMessage = array('temp'    =>    '<strong>ERROR:</strong> Your IP address «'.$ip.'» is currently blocked by due to one, or more, of the following reasons:</p><div id="posterror"><ul><li><strong>Spam</strong></li><li><strong>Open proxy</strong></li><li><strong>Worms/viruses</strong></li><li><strong>Other form of trojan-horse exploits</strong></li></ul></div>',
                                        'perm'    =>    '<strong>FATAL ERROR:</strong> Your IP address «'.$ip.'» <span class="bbu">have been permanently blocked</span> by due to '.$config['max'].' verified hits against the Spamhaus RBL/XBL lists, which protects against the following:</p>'."\n\t\t".'<div id="posterror">'."\n\t\t\t".'<ul>'."\n\t\t\t\t".'<li><strong>Spam</strong></li>'."\n\t\t\t\t".'<li><strong>Open proxies</strong></li>'."\n\t\t\t\t".'<li><strong>Worms/viruses</strong></li><li>'."\n\t\t\t\t".'<strong>Other form of trojan-horse exploits</strong></li>'."\n\t\t\t".'</ul>'."\n\t\t".'</div>',
                                        'more'    =>    ''."\n\t\t".'<p>Please visit <a href="http://www.spamhaus.org/query/bl?ip='.$ip.'" onclick="window.open(this.href); return false;">The Spamhaus Project</a> for more details …'
                                        );

  // If the user have been blocked X number of times, quit with a message right away
  if($cur_status['total'] >= $config['max'] && $config['max'] != 0):
            message($eMessage['perm'].$eMessage['more'], true);

    // If the IP is blocked, and no new check is scheduled, end with a message here
  elseif($cur_status['blocked'] == 1 && time()-$cur_status['time'] < $config['expire']):
        message($eMessage['temp'].$eMessage['more'], true);

    // If we haven't checked the current IP before, or a new check is scheduled, continue...
  elseif(time()-$cur_status['time'] > $config['expire'] || !isset($cur_status['ip'])):
        $rev = array_reverse(explode('.', $ip));
        $lookup = implode('.', $rev) . '.' . $config['server'];
        $isbanned = '0';

    // Not really needed, but we want to make sure the total gets updated
    if(!isset($cur_status['total'])):
                $cur_status['total'] = '0';
        endif;

        // Check if the users IP is listed in the SBL database
    if ($lookup != gethostbyname($lookup)):
                $isbanned = '1'; // Users IP was listed!
                $cur_status['total']++; // Increase the total number hits
    endif;

    // Update the current status
    if(isset($cur_status['ip']) && isset($cur_status['blocked'])):
          $db->query('UPDATE '.$db->prefix.'spam_protect SET ip=\''.$ip.'\', time=\''.time().'\', blocked=\''.$isbanned.'\', total=\''.$cur_status['total'].'\' WHERE ip=\''.$ip.'\'') or error('Unable to update spam protection', __FILE__, __LINE__, $db->error());
        endif;

    // Create a new entry, seeing as the IP did not previously exist
    if(!isset($cur_status['ip'])):
          $result = $db->query('INSERT INTO '.$db->prefix.'spam_protect (ip, time, blocked, total) VALUES (\''.$ip.'\', \''.time().'\', \''.$isbanned.'\', \''.$cur_status['total'].'\')') or error('Unable to insert new spam protection', __FILE__, __LINE__, $db->error());
        endif;

    // The IP have been blocked, so let's display an error message
    if($isbanned == 1):
                message($eMessage['temp'].$eMessage['more'], true);
        endif;

  endif;
} 
// SPM_end


#
#---------[ 7. OPEN ]-------------
#

include/common.php


#
#---------[ 8. FIND (line: 136) ]---------------------------------------------
#

// Check if current user is banned
check_bans();


#
#---------[ 9. AFTER, ADD ]-----------------------------------------------
#

// SPM_start
if(function_exists(spam_protect)):
    spam_protect();
endif;
// SPM_end


#
#---------[ 10. SAVE/UPLOAD ]-------------------------------------------------
#


#
#---------[ NOTES ]---------------------------------------------
#

To configure: Go into your administration panel & select the new plugins.

UPDATED (oct. 3rd, 05): Now with 2 admin plugins to easy the configuration.
New in this release:

- Option to select protected scripts through the plugins (Just check the boxes and you're done!)
- Block users permatentely after X number of hits,
- Configure server to check against (advanced users only)
- Checking interval
- Trust users after X number of posts (e.g. disable checking after they've posted 10 posts (default))
- Admins & mods are not checked by default (possible to enable in admin plugin)
- Function in settings plugin to verify the SPAM Protection code in functions.php & common.php!
++

Enjoy! smile

[Download link]

Hope this is something people will find useful smile Been working on it a couple of days, and it seems to work *very* well so far big_smile Don't know if my description tells you all that you might want to know, so if you have any questions, just ask!

If you want an alternative method of testing (other than the ones described in the last 'note', head over to http://www.aliveproxy.com/products/aliv … roxy-list/ and choose yourself an open, public proxy. Why? Well, because those should also be blocked wink

Enjoy!

EDIT: For a demo, visit this demo/dev site through one of the proxys listed on the site posted above. Alternatively, if you're using Ad-Muncher, enable IP scrable on the tools page of the configuration.

286

(5 replies, posted in PunBB 1.2 troubleshooting)

Just include it into your 'config.php' file.

287

(2 replies, posted in PunBB 1.2 show off)

coolhd wrote:

I will try my best to understand with my poor English.

Don't worry, your English is infinitely better than my Chinese wink

288

(2 replies, posted in Programming)

Use an array & a foreach loop.

E.g.

$adress = array('some@adress.com', 'another@adress.com', 'yetanother@adress.com');

foreach ($adress as $sendto) {
  YOUR MAIL CODE HERE. EACH ADRESS IS STORED INTO THE '$sendto' VARIABLE.
}

That would be a simple way of doing it, but it all depens on how you want the script to work, where you're getting the data from etc..

Well, what you could do is add the following above the current IF statement:

    if (strpos($_SERVER['PHP_SELF'], '.php') === FALSE)
        $_SERVER['PHP_SELF'] = str_replace('php', '.php', $_SERVER['PHP_SELF']);

This isn't a solution though, but rather just a 'dirty' workaround. Your server *should* output script.php.. Sounds like some form of mod_rewrite or something...

290

(67 replies, posted in News)

yelowpunk wrote:

I'm currently still running 1.25. How would I go about updating to 1.2.8?

I installed a lot of mods to my 1.2.5 installation, so just reintsalling a fresh copy and pointing it to the database is not an option.

thanks,

-Tim

I would suggest you to use the .patch (available on the downloads page), or alternatively, the hdiff. If you're on Windows, and don't have access to a *nix machine, just grab a copy of Cygwin.

291

(124 replies, posted in News)

Just sent a little donation... Nice that the first donation from my newly created paypal account, will go to Rickard & PunBB smile

292

(124 replies, posted in News)

Rickard wrote:

Come on people! $10? $5? $2? $1? No contribution is too small.

I haven't been able to check my Paypal account today, but I'm keeping my fingers crossed.

I'll donate some $ today, but I need to sign up for a Paypal account first... smile

Mediator wrote:

Changes:

Fixed typo in readme
Fixed logs not working on anything less than php5 (I hope)

Thanks, it works great now! smile

294

(67 replies, posted in News)

m4dm4n wrote:

Slight prob with editing profiles... The page where you put the admin notes, when you click submit, it goes to a page saying "Bad request. The link you followed is incorrect or outdated."... Any other page of the profile (personal, messaging, personality, etc) works, but not Essentials.

Can confirm the same problem here as well.

You could always just strip out the javascript form validation completely though... But I do see the point. Usng Opera myself as well so... wink

Don't know what you're testing right now, but the menu doesn't show up here...at all, no matter the browser.

EDIT: Nevermind, I see it now. I works just fine in the profile here...

297

(6 replies, posted in Feature requests)

I kinda agree with this... It would make the posts much more readable, without images smile

It's easy enough to "fix", but I think it would be better with this as the default setting...

For those who wants this, just:

Open include/parser.php

Find, around line 402:

        $text = preg_replace("#(?<=.\W|\W.|^\W)".preg_quote($smiley_text[$i], '#')."(?=.\W|\W.|\W$)#m", '$1<img src="img/smilies/'.$smiley_img[$i].'" alt="'.substr($smiley_img[$i], 0, strrpos($smiley_img[$i], '.')).'" />$2', $text);

Replace with:

        $text = preg_replace("#(?<=.\W|\W.|^\W)".preg_quote($smiley_text[$i], '#')."(?=.\W|\W.|\W$)#m", '$1<img src="img/smilies/'.$smiley_img[$i].'" alt="'.$smiley_text[$i].'" />$2', $text);

298

(7 replies, posted in Programming)

Ludo wrote:

I'm fetching from different rss feeds which cause problems :

http://www.presence-pc.com/rss.xml

http://www.ratiatum.com/rss/news.rss

http://www.pcinpact.com/include/news.xml

But one feed ( http://permanent.nouvelobs.com/rss_permanent.xml ) I'm using has no problem with my parser.

Ludo,

Some of those feeds are already correctly formatted, so I guess that could be part of your problem...

299

(1 replies, posted in PunBB 1.2 discussion)

By reading the description in the already exisiting extern.php:

extern.php?action=new&show=<number of topics...>&fid=<...from forum with this ID>

Endre wrote:

I have a problem getting output from extern.php when including it in the main.tpl.
There is no output whatsoever.
I tried a simple

<?php include('http://www.site.com/forum/extern.php?action=stats'); ?>

but that didn't work.
So I read a little in this forum, and decided to try the pun_include, and I put this code in main.tpl:

<pun_include "http://www.site.no/forum/extern.php?action=stats">

But that didn't work either. What am I doing wrong?

I read through a bunch of other threads regarding extern.php, but couldnt find the answer hmm

There are a few problems doing this that way..

1. Included files by using <pun_include> is that those files should always be located in ./include/user/
2. Passing GET values to an URL doesn't always work.. What you've done here will work, but any additional parameters may cause you some headaches.

What you could do, is just create a new .php files in the include/user folder, that in turn includes the extern.php file.