2ch Proxy Blocker on PHP

What this document?

This document describes how to implement proxy blocker via 2ch vandal denying service by using PHP.

Why this document?

Before I build up this website, I was an administrator of a certain game fan website.
However, I couldn't administrate it because of my administrative ability. By its lack, of cource, vandalisms were occured.
In order to stop them, I implemented this mod.

Advantages of using this mod

  • A lot of proxy servers in the blacklist.
  • The blacklist is administrated properly.
  • The largest BBS in Japan uses this service.

Disadvantages of using this mod

  • Sometimes it denies non-proxy host.
  • It is not a completed way to deny vandals.

Implementation code

The implementation code is here:

  1. <?php
  2. function isPxy($addr){
  3. $bbq_deny=implode('.',array_reverse(explode('.', $user->ip)));
  4. $bbq_return=gethostbyname("$bbq_deny.niku.2ch.net");
  5. $bbx_return=gethostbyname("$bbq_deny.bbx.2ch.net");
  6. $return_datas=array("127.0.0.2","127.0.0.3","127.0.0.4");
  7. return (gethostbyaddr($user->ip) ===$user->ip||array_search($bbq_return,$return_datas)!==FALSE||array_search($bbx_return,$return_datas)!==FALSE);
  8. }
  9. ?>

How to use it

When you use that code, you can write like the following:

  1. <?php
  2. //implemantation code
  3. function isPxy($addr){
  4. $bbq_deny=implode('.',array_reverse(explode('.', $user->ip)));
  5. $bbq_return=gethostbyname("$bbq_deny.niku.2ch.net");
  6. $bbx_return=gethostbyname("$bbq_deny.bbx.2ch.net");
  7. $return_datas=array("127.0.0.2","127.0.0.3","127.0.0.4");
  8. return (gethostbyaddr($user->ip) ===$user->ip||array_search($bbq_return,$return_datas)!==FALSE||array_search($bbx_return,$return_datas)!==FALSE);
  9. }
  10. //check proxy.There is an IPaddress in $ipaddress
  11. if(isPxy($ipaddress)){
  12. //Write code when $ipaddress is proxy
  13. }else{
  14. //write elese.
  15. }
  16. ?>