# EDIT.MS2 - Banner Ad System # # This program is used to create, edit, or delete banner ads entries. # 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 Ad Editor" ) print( "Sorry." ) exit endif # Grab the number of the ad we are going to edit/delete. ad = num( form( "ad" ) ) mkdir( "ms2/ads" ) # If the value of the submit button = "Delete", then the user wants to # delete the banner. Do it and redirect them back to STATS.MS2. if form( "submit" ) == "Delete" delete( "ms2/ads/" + str( ad ) + ".cfg" ) delete( "ms2/ads/" + str( ad ) + ".stat" ) redirect( "/cgi-bin/ms2/" + varget( "arg", 1 ) + "/stats" ) exit endif # If the form variable "expiry" exists, then this must be a SAVE operation. # Grab the rest of the form variables and write them to the .CFG file, then # redirect the user to STATS.MS2 if expiry = form( "expiry" ) maxdisplays = num( form( "maxdisplays" ) ) maxclicks = num( form( "maxclicks" ) ) text = form( "text" ) image = form( "image" ) width = num( form( "width" ) ) height = num( form( "height" ) ) url = form( "url" ) contact = form( "contact" ) email = form( "email" ) if output = open( "ms2/ads/" + str( ad ) + ".cfg", "w" ) write( output, expiry, " ", maxdisplays, " ", maxclicks, "\n" ) write( output, text, "\n" ) write( output, image, "\n" ) write( output, width, "\n" ) write( output, height, "\n" ) write( output, url, "\n" ) write( output, contact, "\n" ) write( output, email, "\n" ) close( output ) redirect( "/cgi-bin/ms2/" + varget( "arg", 1 ) + "/stats" ) exit endif endif # If we are here then it wasn't a delete or a save, so we generate a form # so the user can edit the values. This isn't pretty, it's up to you to # spiff it up if you want. # First read in the current contents of the .CFG file... fn = "ms2/ads/" + str( ad ) if input = open( fn + ".cfg" ) line = read( input ) expiry = first( line ) 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 ) endif # Output the form... print( "\n" ) print( "

Editing Banner #", ad, "

\n" ) print( "
\n" ) print( "
\n" )
print( "
\n" ); print( "\n" ) print( "Expiry Date (YYYY-MM-DD): \n" ) print( "Max Displays: " ) print( "Max Clicks: \n" ) print( "Text: \n" ) print( "Image: \n" ) print( "Image Width: " ) print( "Image Height: \n" ) print( "URL: \n" ) print( "Contact: \n" ) print( "Email: \n\n" ) print( " " ) print( "
" ) print( "
\n" ) print( "
\n" )