Wife/Girlfriend/Sister?
Pepper Spray &
Stun Gun Specials!
KEEP THEM SAFE.
 CoverYourASP --> Managing banner ad clickthroughs --> Part 3

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
89 active users
542 visitors today
711 pages today
(only part of today)
Tools I use

CoverYourASP
Copyright © 1999-2010 James Shaw.
All rights reserved.

ASP.NET Blog
RSS submissions
E-commerce

Now open source with SourceForge!

Application ( 'ClickFromIP' )

Having created a new Application variable called 'ClickFromIP' that is initialized each day, now I just have to make some use of this to store the IP addresses of people who click my ads:

// ignore any IP addresses that have been used today
var sIP ='>' + Request.ServerVariables ( 'REMOTE_ADDR' );
var sClickIPs = Application ( 'ClickFromIP' );
var bIgnoreClick = false;

// test if IP has clicked before
if ( -1 != sClickIPs.indexOf ( sIP ) )
{
   // they've clicked before, so ignore them
   bIgnoreClick = true;
}
else
{
   // this IP hasn't clicked before, so add to list
   Application.Lock ( );
   Application ( 'ClickFromIP' ) = Application ( 'ClickFromIP' ) + sIP;
   Application.Unlock ( );
}

First I get the IP address from the ServerVariables collection. Then I get the current ClickFromIP variable, and test if the current IP appears in the string using the String.indexOf method.

If it does, then I ignore the clickthrough (I still allow the clickthrough, just don't charge the client for it)

If it hasn't been used before I concatenate the IP to the string. This is why I prefixed it with a > character (on the first line) so that each IP address will be separated by this character in the string.

Next, Ignoring user agents...

Featured sponsor
My favorite resources

Tiki Statues - Tiki Masks - Tiki Totems



I share my content

Supporting ASPRSS

Do you need a quick and easy way to link to my articles? All the information you need is published with ASPRSS...


See my source code
wherever you see this icon...

You can also download the entire site source code for FREE!