ASP/.NET Web Hosting
* 3 Months FREE *
CLICK HERE!
 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
155 active users
3136 visitors today
4700 pages today
how is this done?
ASP.NET Showcase
ASP.NET Graph and Chart Component with FREE developer version

ASP.NET Shopping Cart and E-commerce Control with FREE trial download

ASP.NET Web Hosting with free month and setup

$15 Domain Name Registration from .DNR.
As seen on these sites
Special thanks go to the sites that support me by publishing my articles.
See more

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

ASP.NET Blog
ASPRSS
ShawThing

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

Selling products online - read how James does it now



New Proposal Kit Professional 5.1
Brand yourself as a top professional: create quotes and amazing proposals and get many legal documents free!

The latter saved me 3 times the purchase price on the first day I owned it!


Qualify for Free Trade Magazines

Free subscriptions to industry leading publications for those who qualify!