--- web/cgi-bin/download.cgi 2001/03/31 10:53:58 1.1 +++ web/cgi-bin/download.cgi 2001/05/05 18:03:38 1.6 @@ -1,11 +1,11 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl #-------------------------------------------------------------- # download.cgi # -# A Perl CGI script that requests a user's email address -# before they may download a build from the i-scream web site. -# It is not essential for them to enter their email address. +# A Perl CGI script that requests some details from the user +# before they download a build from the i-scream web site. +# To assist the paranoid, all fields are optional. # # Copyright Paul Mutton, 2001. #-------------------------------------------------------------- @@ -19,12 +19,15 @@ $| = 1; #-------------------------------------------------------------- # Essential Settings #-------------------------------------------------------------- -my $build_dir = "/builds"; -my $log_file = "download_log"; +my ($build_dir) = "/builds"; +my ($log_file) = "download_log"; +my ($left) = "../left.inc" ; +my ($title) = "../title.inc"; +my ($bottom) = "../bottom.inc"; #-------------------------------------------------------------- -my $query = new CGI; +my ($query) = new CGI; my ($file_name) = ($query->param('file_name') =~ /^\s*(.*)\s*$/); my ($your_name) = ($query->param('your_name') =~ /^\s*(.*)\s*$/); @@ -45,21 +48,52 @@ if (!defined($file_name) || $file_name eq "") { if (defined($submit) && $submit eq "Download") { open(LOGFILE, ">>$log_file"); - print LOGFILE "$date|$file_name|$your_name|$email_address|$country\n"; + print LOGFILE "$date|$ENV{'REMOTE_ADDR'}|$file_name|$your_name|$email_address|$country\n"; close(LOGFILE); - print "Location: $build_dir/$file_name\n\n"; + print $query->redirect("$build_dir/$file_name"); } else { print "Content-type: text/html\n\n"; - - print <<EOT; + + print <<"END"; + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> + + <!-- + download.cgi + Created by pjm2 31/03/2001 + Last modified 31/03/2001 + --> + <html> - <basefont face="arial,sans-serif" size="2"> - <body bgcolor="white" text="#000066"> - <table align="center" width="600"> + + <head> + <title>i-scream downloads</title> + <meta name="description" content="The i-scream Project is a central monitoring system for Unix, Linux and NT servers."> + <meta name="keywords" content="i-scream, project, central monitoring system, unix, linux, nt, server, alert"> + <meta name="generator" content="notepad on acid, aye."> + </head> + + <body bgcolor="#ffffff" link="#0000ff" alink="#3333cc" vlink="#3333cc" text="#000066"> + + <table border="0" cellpadding="2" cellspacing="2"> <tr> + <td valign="top"> +END + + &print_html($left); + + print <<"END"; + </td> + <td valign="top"> +END + + &print_html($title); + + print <<EOT; + <table align="center" width="500"> + <tr> <td> - <center><img src="/i-scream.gif" width="502" height="37" border="0"></center> + <font face="arial,sans-serif"> <center><h3>i-scream builds</h3></center> <font size="2"> At the current moment, all i-scream builds may be downloaded <b>free @@ -67,28 +101,29 @@ else { regarding the i-scream montoring system, then we would recommend that you provide your contact details below. All fields are optional. </font> + </font> </td> </tr> </table> <p> </p> - <form action="download.cgi" method="POST"> + <form action="/cgi-bin/download.cgi" method="POST"> <table border="0" align="center"> <tr> - <td>Filename:</td> - <td><b>$file_name</b><input type="hidden" name="file_name" value="$file_name"></td> + <td><font face="arial,sans-serif">Filename:</font></td> + <td><font face="arial,sans-serif"><b>$file_name</b></font><input type="hidden" name="file_name" value="$file_name"></td> </tr> <tr> - <td>Your name:</td> + <td><font face="arial,sans-serif">Your name:</font></td> <td><input type="text" name="your_name" value=""></td> </tr> <tr> - <td>Email address:</td> + <td><font face="arial,sans-serif">Email address:</font></td> <td><input type="text" name="email_address" value=""></td> </tr> <tr> - <td>Country:</td> + <td><font face="arial,sans-serif">Country:</font></td> <td><input type="text" name="country" value=""></td> </tr> <tr> @@ -102,7 +137,22 @@ else { </html> EOT -} + &print_html($bottom); + print <<"END"; -exit; \ No newline at end of file + </td> + </tr> + </table> +END + +} + +exit; + + +# Print a file without escaping HTML: - +sub print_html ($) { + my ($filename) = @_; + print `cat $filename`; +}