Skip to:

Combatting Spammers (sploggers) – Geoip PHP mod..

  • Lawrence


    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.

    Save and place it somewhere on your server. Then get the ip lookup table here: 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. */.

    $gi = geoip_open("path/to/GeoIP.dat",GEOIP_STANDARD);

    $country = geoip_country_code_by_addr($gi, $ip);


    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)

  • 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)
  • The topic ‘Combatting Spammers (sploggers) – Geoip PHP mod..’ is closed to new replies.
Skip to toolbar