]> i-scream Git - www.i-scream.org.git/commitdiff
So we can keep track of build downloads
authorPaul Mutton <pjm2@i-scream.org>
Sat, 31 Mar 2001 10:53:58 +0000 (10:53 +0000)
committerPaul Mutton <pjm2@i-scream.org>
Sat, 31 Mar 2001 10:53:58 +0000 (10:53 +0000)
cgi-bin/download.cgi [new file with mode: 0755]

diff --git a/cgi-bin/download.cgi b/cgi-bin/download.cgi
new file mode 100755 (executable)
index 0000000..d555c7f
--- /dev/null
@@ -0,0 +1,108 @@
+#!/usr/bin/perl -w
+
+#--------------------------------------------------------------
+# 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.
+#
+# Copyright Paul Mutton, 2001.
+#--------------------------------------------------------------
+
+use strict;
+use CGI;
+
+$| = 1;
+
+
+#--------------------------------------------------------------
+# Essential Settings
+#--------------------------------------------------------------
+my $build_dir = "/builds";
+my $log_file = "download_log";
+#--------------------------------------------------------------
+
+
+my $query = new CGI;
+
+my ($file_name) = ($query->param('file_name') =~ /^\s*(.*)\s*$/);
+my ($your_name) = ($query->param('your_name') =~ /^\s*(.*)\s*$/);
+my ($email_address) = ($query->param('email_address') =~ /^\s*(.*)\s*$/);
+my ($country) = ($query->param('country') =~ /^\s*(.*)\s*$/);
+my ($submit) = ($query->param('submit') =~ /^\s*(.*)\s*$/);
+my ($date) = scalar localtime time;
+
+$your_name =~ s/\|//g;
+$email_address =~ s/\|//g;
+$country =~ s/\|//g;
+
+if (!defined($file_name) || $file_name eq "") {
+    print "Content-type: text/html\n\n";
+    print "You must specify a filename for use with the i-scream downloader.";
+    exit;
+}
+
+if (defined($submit) && $submit eq "Download") {
+    open(LOGFILE, ">>$log_file");
+    print LOGFILE "$date|$file_name|$your_name|$email_address|$country\n";
+    close(LOGFILE);
+    print "Location: $build_dir/$file_name\n\n";
+}
+else {
+    print "Content-type: text/html\n\n";
+   
+    print <<EOT;
+        <html>
+        <basefont face="arial,sans-serif" size="2">
+        <body bgcolor="white" text="#000066">
+        <table align="center" width="600">
+         <tr>
+          <td>
+           <center><img src="/i-scream.gif" width="502" height="37" border="0"></center>
+           <center><h3>i-scream builds</h3></center>
+           <font size="2">
+            At the current moment, all i-scream builds may be downloaded <b>free
+            of charge</b>.  If you wish to be alerted infrequently about important issues
+            regarding the i-scream montoring system, then we would recommend that
+            you provide your contact details below.  All fields are optional.
+           </font>
+          </td>
+         </tr>
+        </table>
+        
+        <p>&nbsp;</p>
+        
+        <form action="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>
+          </tr>
+          <tr>
+           <td>Your name:</td>
+           <td><input type="text" name="your_name" value=""></td>
+          </tr>
+          <tr>
+           <td>Email address:</td>
+           <td><input type="text" name="email_address" value=""></td>
+          </tr>
+          <tr>
+           <td>Country:</td>
+           <td><input type="text" name="country" value=""></td>
+          </tr>
+          <tr>
+           <td>&nbsp;</td>
+           <td><input type="submit" name="submit" value="Download"></td>
+          </tr>
+         </table>
+        </form>
+        
+        </body>
+        </html>
+EOT
+
+}
+
+
+exit;
\ No newline at end of file