# AD.MS2 - Banner Ad System # # This program is called from each html page where you want a banner to # appear: # # # # where LOGIN is actually your Islandnet login name. This entire tag will # be replaced with an image tag and a line of text. This program keeps # track of the last ad displayed, and cycles through all available ads in # sequence. Ads that have expired or exceeded the maximum number of # displays or click-thrus are ignored. # Set this to the maximum number of ad slots you wish to maintain. Don't # make this too high or it slows things down. maxads = 20 if laf = open( "ms2/lastad", "r+" ) n = 0 ad = num( read( laf ) ) rewind( laf ) else laf = open( "ms2/lastad", "w" ) ad = 0 endif while lockf( laf ) == 0 and n < 200 n = n + 1 endwhile done = 0 marker = ad while not done ad = ad + 1 if ad > maxads ad = 1 endif fn = "ms2/ads/" + str( ad ) + ".cfg" if input = open( fn ) line = read( input ) expiry = first( line ) + " 00:00:01" maxdisplays = num( nth( line, 2 ) ) maxclicks = num( nth( line, 3 ) ) if expiry > time() fn = "ms2/ads/" + str( ad ) + ".stat" if in2 = open( fn ) displayed = num( read( in2 ) ) clicked = num( read( in2 ) ) close( in2 ) else displayed = 0; clicked = 0 endif if (maxdisplays == 0 and maxclicks == 0) or \ (displayed <= maxdisplays and clicked <= maxclicks) text = read( input ) image = read( input ) width = read( input ) height = read( input ) done = 1 endif endif close( input ) endif endwhile write( laf, ad, "\n" ) close( laf ) print( "
" ) print( "
", text, "
\n" ) fn = "ms2/ads/" + str( ad ) + ".stat" if input = open( fn, "r+" ) displayed = num( read( input ) ) clicked = num( read( input ) ) rewind( input ) else input = open( fn, "w" ) displayed = 0 clicked = 0 endif n = 0 while lockf( input ) == 0 and n < 200 n = n + 1 endwhile displayed = displayed + 1 write( input, displayed, "\n" ) write( input, clicked, "\n" ) close( input )