Tutorial: Blocking your IP from seeing Adsense

Discussion in 'AdSense' started by Scriptona, Sep 5, 2006.

  1. #1
    Hello guys,

    many of us are afraid of being Banned of adsense for accidently clicking on our own ads

    i was reading this topic

    http://forums.digitalpoint.com/showthread.php?t=67344
    
    * had to put it in code tag cuz i'm not allowed to post live links yet
    
    Code (markup):



    and i thought that i might make something to block my IP from seeing Adsense on my own sites so i gurantee i won't EVER click on my own ads by mistake


    it's just a small code and easy to add

    let's start


    1- If you have static IP

    <?
    $currentip = $_SERVER['REMOTE_ADDR'];
    
    $myip = "127.0.0.1"; // replace 127.0.0.1 with your own IP
    
    if($currentip == $myip)
    
    {
    
    // shows nothing if it's you seeing the site
    
    }
    
    else
    {
    
    ?>
    
    <!--
    
    remove the <!-- and  put adsense code here 
    
    -->
    
    <?
    }
    ?>
    PHP:

    2- If you have dynamic IP

    well, that is hard to do but the only way i found was to block all IPS from your ISP and you might want to think about this one before doing it cuz it will make you lose all clicks that might be generated from all people that are having same ISP like yours

    <?
    
    $blockedAddr = "123.123.";  //ips starting with 123.123 will not see adsense
    
          //you can also do "123.123.123..*" to block anything that is 123.123.123.x from seeing adsense
    
          if (ereg($blockedAddr, $_SERVER['REMOTE_ADDR'])) 
    	  
    {
    
    // shows nothing if the ip viewing the site is in the ip range that is defined before in $blockedAddr 
    
    }
    
    else
    
    {
    
    ?>
    
    <!--
    
    remove the <!-- and  put adsense code here 
    
    -->
    
    <?
    }
    ?>
    PHP:

    Notes:

    1- Using this code is safe and has nothing to do with Adsense TOS cuz the adsense code itself isn't modified.
    2- i'm php newbie so i'm sorry if there is anyting wrong ( although both codes are tested by mr and working !!!).
    3- if anyone has better idea for code #2 please don't hesitate to share with us
     
    Scriptona, Sep 5, 2006 IP
  2. matthewk

    matthewk Guest

    Messages:
    265
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    good stuff, clean and simple. i have had similar scripts implemented on my sites since i started. i wrote the scripts myself, but they are basically the same. good post :)
     
    matthewk, Sep 5, 2006 IP
  3. P8ntballer

    P8ntballer Peon

    Messages:
    115
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    There is alot easier ways actully

    Copied from here.
     
    P8ntballer, Sep 5, 2006 IP
  4. error10

    error10 Peon

    Messages:
    73
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yep, that's my script. Surprisingly it's been almost bug-free. And it's kept me out of a lot of trouble. :)
     
    error10, Sep 5, 2006 IP
  5. bizhobby

    bizhobby Peon

    Messages:
    692
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I still like the server side solution better. Someone here was banned for checking his AdSense stats from work, and someone from his work has clicked on his ads. So that's not something you can prevent with a FireFox extension.

    There's also asrep.com which is just a more detailed adsense report. but the full version also has things like "don't display ads to the same IP if they already clicked x times in the same day"
     
    bizhobby, Sep 5, 2006 IP
  6. Scriptona

    Scriptona Notable Member

    Messages:
    4,957
    Likes Received:
    265
    Best Answers:
    0
    Trophy Points:
    280
    #6
    thanks for your support guys, i hope that helped

    personally i implemended it on one of my sites which has adsense enabled and it is fine for me
     
    Scriptona, Sep 5, 2006 IP
  7. Scriptona

    Scriptona Notable Member

    Messages:
    4,957
    Likes Received:
    265
    Best Answers:
    0
    Trophy Points:
    280
    #7
    Any other ideas for the same purpose on dynamic ips ?
     
    Scriptona, Sep 9, 2006 IP
  8. MarkusE

    MarkusE Guest

    Messages:
    111
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #8
    I just use Adlogger. Simple and easy.
     
    MarkusE, Sep 11, 2006 IP
  9. digiseek

    digiseek Peon

    Messages:
    283
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Best would be to add a entry in the host file for google. That way even if your IP changes you are safe.
     
    digiseek, Sep 11, 2006 IP
  10. Scriptona

    Scriptona Notable Member

    Messages:
    4,957
    Likes Received:
    265
    Best Answers:
    0
    Trophy Points:
    280
    #10
    sorry, i didn't get that
     
    Scriptona, Sep 11, 2006 IP
  11. Icheb

    Icheb Peon

    Messages:
    1,092
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Use strpos() instead of eregi().
     
    Icheb, Sep 11, 2006 IP
  12. easterwolf

    easterwolf Well-Known Member

    Messages:
    608
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    108
    #12
    If Google really didn't want the possibility of fraudulent clicks as far as a publisher clicking his/her own ads, they would have implemented a tool so that you could not count your IP such as almost all site counters can do. It is so easy, why isn't it being done right from the AdSense user panel!?
     
    easterwolf, Sep 11, 2006 IP
  13. Scriptona

    Scriptona Notable Member

    Messages:
    4,957
    Likes Received:
    265
    Best Answers:
    0
    Trophy Points:
    280
    #13
    actually Adsense once sent me an e-mail to fill a feedback form and in the comments field i asked for something like what you have just said

    a few days after, they replied saying that my suggestion regarding this will be forwarded to the adsense techs and might be applied if possible


    let's just pray :D
     
    Scriptona, Sep 11, 2006 IP