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... |