[llvm-commits] CVS: llvm-www/releases/register.cgi index.html register.py
John Criswell
criswell at cs.uiuc.edu
Thu Oct 16 11:42:01 PDT 2003
Changes in directory llvm-www/releases:
register.cgi added (r1.1)
index.html updated: 1.4 -> 1.5
register.py (r1.1) removed
---
Log message:
Renamed the script from register.py to register.cgi.
This should hopefully make the script executable within the web directory.
---
Diffs of the changes: (+198 -1)
Index: llvm-www/releases/register.cgi
diff -c /dev/null llvm-www/releases/register.cgi:1.1
*** /dev/null Thu Oct 16 11:41:14 2003
--- llvm-www/releases/register.cgi Thu Oct 16 11:41:04 2003
***************
*** 0 ****
--- 1,197 ----
+ #!/usr/dcs/software/supported/bin/python
+
+ import cgi
+ import urllib
+ import smtplib
+ import os
+ import sys
+
+ # List of email addresses that want to know when people download
+ notifylist=['criswell at uiuc.edu', 'jcriswel at bigw.org']
+
+ #
+ # Function: Subscribe()
+ #
+ # Description:
+ # This function subscribes the specified user to the LLVM announce mailing
+ # list.
+ #
+ def Subscribe (form):
+ # Name of the LLVM subscription CGI script
+ scriptURL='http://mail.cs.uiuc.edu/mailman/subscribe/llvm-announce'
+
+ #
+ # Extract from the form any information that we need
+ #
+ email = form.getfirst ('email', '')
+ pw1 = form.getfirst ('pw1', '')
+ pw2 = form.getfirst ('pw2', '')
+ announce = form.getfirst ('announce','yes')
+
+ #
+ # Exit now if we do not need to subscribe.
+ #
+ if (announce != 'yes'):
+ return
+
+ #
+ # Create a POST request with all of the information that the CGI
+ # script will require.
+ #
+ options = {'email': email, 'pw': pw1, 'pw-conf': pw2, 'digest': '0'}
+
+ #
+ # Convert the POST options into a string that we can send to the
+ # subscription CGI script.
+ #
+ postdata = urllib.urlencode (options)
+
+ #
+ # Subscribe the user.
+ #
+ urllib.urlopen (scriptURL, postdata)
+
+ return
+
+ #
+ # Function: ValidateForm ()
+ #
+ # Description:
+ # Make sure that the input to the CGI script is valid.
+ #
+ def ValidateForm (form):
+ #
+ # Verify if the required fields have been supplied.
+ #
+ firstname = form.getfirst ('firstname', '')
+ lastname = form.getfirst ('lastname', '')
+ email = form.getfirst ('email', '')
+ pw1 = form.getfirst ('pw1', '')
+ pw2 = form.getfirst ('pw2', '')
+ announce = form.getfirst ('announce','yes')
+
+ #
+ # Verify that the name and email fields have been filled in.
+ #
+ if (firstname == ''):
+ return 'First name is empty.'
+
+ if (lastname == ''):
+ return 'Last name is empty.'
+
+ if (email == ''):
+ return 'Email address is empty.'
+
+ #
+ # Verify that the email address has an at sign and some periods.
+ #
+ length = len (email) - 1
+ while (length != 0):
+ if (email[length] == '@'):
+ break
+ length=length - 1
+ else:
+ return 'Email address has no at sign'
+
+ length = len (email) - 1
+ while (length != 0):
+ if (email[length] == '.'):
+ break
+ length=length - 1
+ else:
+ return 'Email address has no periods'
+
+ #
+ # Verify that a non-empty password has been selected.
+ #
+ if ((announce == 'yes') and ((pw1 == '') or (pw2 == ''))):
+ return 'Password for mailing address is empty.'
+
+ #
+ # Verify that the passwords are equal.
+ #
+ if (pw1 != pw2):
+ return 'Confirmation password does not match original password.'
+
+ return ''
+
+ #
+ # Function: LogForm ()
+ #
+ # Description:
+ # Append a log record to the logfile that another users has registered to
+ # download LLVM.
+ #
+ def LogForm (form):
+ #
+ # Extract the information from the form that we want.
+ #
+ firstname = form.getfirst ('firstname', '')
+ lastname = form.getfirst ('lastname', '')
+ title = form.getfirst ('title','')
+ organization = form.getfirst ('organization', '')
+ email = form.getfirst ('email','')
+ plans = form.getfirst ('plans','')
+ if (plans == ''):
+ plans = 'No plans.'
+
+ #
+ # Construct an email message describing the user who is downloading
+ # LLVM.
+ #
+ msg = 'Subject: [LLVM DOWNLOAD]\r\n\r\n'
+ msg = msg + 'Name: ' + firstname + ' ' + lastname + '\n'
+ msg = msg + 'Email: ' + email + '\n'
+ msg = msg + 'Title: ' + title + '\n'
+ msg = msg + 'Organization: ' + organization + '\n'
+ msg = msg + 'Plans with LLVM:\n' + plans + '\n'
+
+ #
+ # Send email to notify that someone has downloaded LLVM yet again!
+ #
+ mailer = smtplib.SMTP ('localhost')
+ for receiver in notifylist:
+ header = 'From: ' + email + '\r\nTo: ' + receiver + '\r\n'
+ try:
+ mailer.sendmail (email, receiver, msg)
+ except:
+ pass
+ mailer.quit ()
+ return
+
+ #
+ # Parse the CGI input
+ #
+ form = cgi.FieldStorage ()
+
+ #
+ # Verify that everything in the form is correct.
+ #
+ error = ValidateForm (form)
+ if (error != ''):
+ print ('Content-type: text/html')
+ print ('Status: 400 Bad Request')
+ print ('')
+ print ('<h2>')
+ print ('Error in form:' + error)
+ print ('</h2>')
+ sys.exit (0)
+
+ #
+ # Log the information provided by the form.
+ #
+ LogForm (form)
+
+ #
+ # Subscribe the user the LLVM Announcements list (if they so desire)
+ #
+ Subscribe (form)
+
+ #
+ # Everything so far has worked. Send the user to the download page.
+ #
+ print ('Location: /download.html')
+ print ('')
+
+ sys.exit (0)
+
Index: llvm-www/releases/index.html
diff -u llvm-www/releases/index.html:1.4 llvm-www/releases/index.html:1.5
--- llvm-www/releases/index.html:1.4 Thu Oct 16 11:38:22 2003
+++ llvm-www/releases/index.html Thu Oct 16 11:41:04 2003
@@ -30,7 +30,7 @@
below to download a copy of the LLVM software.
<p>
-<FORM ACTION="/releases/register.py" METHOD="POST">
+<FORM ACTION="/releases/register.cgi" METHOD="POST">
First Name (required):<br>
<INPUT TYPE="text" SIZE=40 NAME="firstname"><br>
<p>
More information about the llvm-commits
mailing list