Skip to:
Content
Pages
Categories
Search
Top
Bottom

Combatting Spammers (sploggers) – Geoip PHP mod..

  • Avatar of Lawrence
    Lawrence
    Participant

    @grimbog

    Hey guys,

    Just thought I’d share my own little script that I’ve embedded in to wp-config.php. True I should ideally place this in to a plugin, but this is just a quick example which others may find useful.

    I’ve noticed that pretty much all of the ‘sploggers’ originate from China. Whilst I’m sure that there are many innocent visitors over there, I felt that my own needs for Buddypress did not extend to that country, so using Maxminds GeoIp mod, you can simply ban the entire country.

    http://geolite.maxmind.com/download/geoip/api/php/

    Save geoip.inc and place it somewhere on your server. Then get the ip lookup table here:

    http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz and place it in your home/username/ directory (underneath public_html)

    You can probably set up a cron job to download the lookup table each month. As its updated monthly.

    All I did was place the following in wp-config.php after /* That’s all, stop editing! Happy blogging. */.

    ### GEOIP BAN CHINA
    include('path/to/geoip.inc');
    $gi = geoip_open("path/to/GeoIP.dat",GEOIP_STANDARD);

    $ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
    $country = geoip_country_code_by_addr($gi, $ip);

    geoip_close($gi);

    if ($country == 'CN') {
    die('Service Unavailable');
    }
    ### END GEOIP

    So there you go – it simply reads in the visitors ip, then compares it to the lookup table – if the ip originates from China, then simply kill the connection. As I say, its very harsh, but personally my own project doesn’t cover that area, and so far I haven’t had any problems.

    What I’m going to potentially look at, is to see if I can flag users from China… so enable them to sign up and log in, but they must ‘earn’ reputation before they can start a blog. This will cut away most of the splogger issue as spammers don’t tend to hang around. :)

Viewing 1 replies (of 1 total)
  • Avatar of bpisimone
    bpisimone
    Participant

    @bpisimone

    Good thought about the reputation. YOu might be able to combine it with the achievments plugin! In any case let us know if you attempt anything like that.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.