adsense script to preven click bombing

Discussion in 'AdSense' started by dabeast, Jun 11, 2011.

  1. #1
    ok i googled a bit for this.and found one.but my prob is i dont understand javascript so plz help me with this script...


    <div id="banners" onclick="trackclick();">

    <script language="JavaScript">

    if ( clickCount > 2 ){
    document.write('
    <a href="your clickbank link or anything else">
    <img src="anything replacing adsense ad">
    </a>
    ');
    }else{
    document.write('
    adsense code goes here
    ');
    }

    </script>
    </div>


    now javascript handler for this

    <script language="JavaScript">

    var clickCount = readCookie();
    if ( clickCount == null ){
    clickCount = 0;
    }

    function trackclick() {
    clickCount = parseInt(clickCount)+1;
    setCookie( clickCount, 2 );
    return true;
    }

    function setCookie( cookieValue, nDays) {
    var today = new Date();
    var expire = new Date();
    if (nDays==null || nDays==0) nDays=1;
    expire.setTime(today.getTime() + 3600000*24*nDays);
    document.cookie = "clicktrack="+escape(cookieValue)
    + ";expires="+expire.toGMTString();
    }

    function readCookie() {
    var nameEQ = "clicktrack=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
    var c = ca;
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0){
    return c.substring(nameEQ.length,c.length);
    }
    }
    return null;
    }

    </script>

    now i really dont understand this ndays concept..when will the cookies actually expire.i mean what time frame ? 24 hours or what ? plz help me guys...i need to ensure this thing before using the script....:rolleyes:
     
    dabeast, Jun 11, 2011 IP
  2. Project Mobius

    Project Mobius Peon

    Messages:
    10,524
    Likes Received:
    170
    Best Answers:
    0
    Trophy Points:
    0
    #2
    then learn about how a cookie works
     
    Project Mobius, Jun 12, 2011 IP