# CLICK.MS2 - Banner Ad System # # This program is called whenever someone clicks on a banner ad. It updates # the .STAT file for the ad and redirects the user to the URL associated # with it. You do not need to reference this program directly anywhere, # that is taken care of in AD.MS2 ad = varget( "arg", 3 ) fn = "ms2/ads/" + ad + ".cfg" if input = open( fn ) line = read( input ) expiry = first( line ) + " 00:00:01" maxdisplays = num( nth( line, 2 ) ) maxclicks = num( nth( line, 2 ) ) text = read( input ) image = read( input ) width = read( input ) height = read( input ) url = read( input ) close( fn ) if expiry > time() redirect( url ) fn = "ms2/ads/" + ad + ".stat" displayed = 0 clicked = 0 if input = open( fn, "r+" ) displayed = num( read( input ) ) clicked = num( read( input ) ) rewind( input ) else input = open( fn, "w" ) endif n = 0 while lockf( input ) == 0 and n < 200 n = n + 1 endwhile clicked = clicked + 1 write( input, displayed, "\n" ) write( input, clicked, "\n" ) close( input ) endif endif