# STATS.MS2 - Banner Ad System
#
# This program is used to view the current status of all your banner ads.
# Each banner ad is displayed along with the current display count, click
# count, etc. If an ad has expired or exceeded the maximum number of
# displays or clicks, it is still shown in the list but its slot number
# will be red, indicating that it is currently being ignored by AD.MS2.
#
# At the top of the display will be an input field where you can type the
# number of an ad slot, then press EDIT or DELETE. Pressing EDIT will
# invoke EDIT.MS2 to create a new ad or edit an existing one. Pressing
# DELETE will invoke EDIT.MS@ to delete the specified ad.
# Set this to the maximum number of ad slots you wish to support. Don't
# set this too high or it will slow down.
maxads = 20
# Change the following value to a suitable login name and password pair.
# You will have to enter these values in order to access this program.
# Note that the login and password must be separated with a full colon.
LOGPASS = "admin:dump/truck"
# Check to see if the user has entered a valid login and password. If not,
# prompt them and exit.
if decode() != LOGPASS
getauth( "Banner Stats" )
print( "Sorry." )
exit
endif
# Display each ad...
print( "
\n" )
print( "Banner Ad Stats
\n" )
print( "\n" )
print( "
\n" )
ad = 1
while ad <= maxads
fn = "ms2/ads/" + str( ad )
if input = open( fn + ".cfg" )
line = read( input )
expiry = first( line ) + " 00:00:01"
maxdisplays = num( nth( line, 2 ) )
maxclicks = num( nth( line, 3 ) )
text = read( input )
image = read( input )
width = read( input )
height = read( input )
url = read( input )
contact = read( input )
email = read( input )
close( input )
if input = open( fn + ".stat" )
displayed = num( read( input ) )
clicked = num( read( input ) )
close( input )
else
displayed = 0
clicked = 0
endif
days = timesub( expiry, time() ) // 86400
if days < 1 or (maxclicks > 0 and clicks >= maxclicks) or
(maxdisplays > 0 and displayed >= maxdisplays)
print( "#", ad, "" )
else
print( "#", ad, "" )
endif
print( " " )
print( "Displayed: " )
if maxdisplays > 0 and displayed >= maxdisplays
print( "", displayed, "/", maxdisplays, "" )
else
print( displayed )
endif
print( " " )
print( "Clicked: " )
if maxclicks > 0 and clicked >= maxclicks
print( "", clicked, "/", maxclicks, "" )
else
print( clicked )
endif
print( " " )
print( "Size: ", filesize( "ms2/ads/" + str( ad ) + ".gif" ), " " )
print( "Expires: ", first( expiry ), " " )
if days < 1
print( "Expired ", abs( days ), " days ago!" )
elif days < 7
print( "Expires in ", days, " days!" )
elif days < 14
print( "Expires in ", days, " days." )
else
print( "Expires in ", days, " days." )
endif
print( "
\n" )
print( "Contact: ", contact, " " )
print( "Email: ", email, "
" )
print( "URL: ", url, "
\n" )
print( "" )
print( "
", text, "
\n" )
print( "
\n" )
endif
ad = ad + 1
endwhile