]> i-scream Git - www.i-scream.org.git/blob - cgi-bin/download.cgi
So we can keep track of build downloads
[www.i-scream.org.git] / cgi-bin / download.cgi
1 #!/usr/bin/perl -w
2
3 #--------------------------------------------------------------
4 # download.cgi
5
6 # A Perl CGI script that requests a user's email address
7 # before they may download a build from the i-scream web site.
8 # It is not essential for them to enter their email address.
9 #
10 # Copyright Paul Mutton, 2001.
11 #--------------------------------------------------------------
12
13 use strict;
14 use CGI;
15
16 $| = 1;
17
18
19 #--------------------------------------------------------------
20 # Essential Settings
21 #--------------------------------------------------------------
22 my $build_dir = "/builds";
23 my $log_file = "download_log";
24 #--------------------------------------------------------------
25
26
27 my $query = new CGI;
28
29 my ($file_name) = ($query->param('file_name') =~ /^\s*(.*)\s*$/);
30 my ($your_name) = ($query->param('your_name') =~ /^\s*(.*)\s*$/);
31 my ($email_address) = ($query->param('email_address') =~ /^\s*(.*)\s*$/);
32 my ($country) = ($query->param('country') =~ /^\s*(.*)\s*$/);
33 my ($submit) = ($query->param('submit') =~ /^\s*(.*)\s*$/);
34 my ($date) = scalar localtime time;
35
36 $your_name =~ s/\|//g;
37 $email_address =~ s/\|//g;
38 $country =~ s/\|//g;
39
40 if (!defined($file_name) || $file_name eq "") {
41     print "Content-type: text/html\n\n";
42     print "You must specify a filename for use with the i-scream downloader.";
43     exit;
44 }
45
46 if (defined($submit) && $submit eq "Download") {
47     open(LOGFILE, ">>$log_file");
48     print LOGFILE "$date|$file_name|$your_name|$email_address|$country\n";
49     close(LOGFILE);
50     print "Location: $build_dir/$file_name\n\n";
51 }
52 else {
53     print "Content-type: text/html\n\n";
54    
55     print <<EOT;
56         <html>
57         <basefont face="arial,sans-serif" size="2">
58         <body bgcolor="white" text="#000066">
59         <table align="center" width="600">
60          <tr>
61           <td>
62            <center><img src="/i-scream.gif" width="502" height="37" border="0"></center>
63            <center><h3>i-scream builds</h3></center>
64            <font size="2">
65             At the current moment, all i-scream builds may be downloaded <b>free
66             of charge</b>.  If you wish to be alerted infrequently about important issues
67             regarding the i-scream montoring system, then we would recommend that
68             you provide your contact details below.  All fields are optional.
69            </font>
70           </td>
71          </tr>
72         </table>
73         
74         <p>&nbsp;</p>
75         
76         <form action="download.cgi" method="POST">
77          <table border="0" align="center">
78           <tr>
79            <td>Filename:</td>
80            <td><b>$file_name</b><input type="hidden" name="file_name" value="$file_name"></td>
81           </tr>
82           <tr>
83            <td>Your name:</td>
84            <td><input type="text" name="your_name" value=""></td>
85           </tr>
86           <tr>
87            <td>Email address:</td>
88            <td><input type="text" name="email_address" value=""></td>
89           </tr>
90           <tr>
91            <td>Country:</td>
92            <td><input type="text" name="country" value=""></td>
93           </tr>
94           <tr>
95            <td>&nbsp;</td>
96            <td><input type="submit" name="submit" value="Download"></td>
97           </tr>
98          </table>
99         </form>
100         
101         </body>
102         </html>
103 EOT
104
105 }
106
107
108 exit;