[llvm-commits] CVS: llvm-www/releases/register.py index.html

John Criswell criswell at cs.uiuc.edu
Thu Oct 16 11:38:02 PDT 2003


Changes in directory llvm-www/releases:

register.py added (r1.1)
index.html updated: 1.2 -> 1.3

---
Log message:

Adding in the registration CGI script for testing.



---
Diffs of the changes:  (+212 -3)

Index: llvm-www/releases/register.py
diff -c /dev/null llvm-www/releases/register.py:1.1
*** /dev/null	Thu Oct 16 11:37:18 2003
--- llvm-www/releases/register.py	Thu Oct 16 11:37:08 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.2 llvm-www/releases/index.html:1.3
--- llvm-www/releases/index.html:1.2	Wed Oct 15 15:01:27 2003
+++ llvm-www/releases/index.html	Thu Oct 16 11:37:08 2003
@@ -13,10 +13,24 @@
 
 <hr>
 
+<b>
+NOTE: This registration page is currently up for testing.  If you want to
+download LLVM, you will have to re-register once we finish the 1.0 Release.
+<p>
+If you want to know when the 1.0 Release of LLVM will be ready, you can
+subscribe to our LLVM Announcements mailing list at
+<a href="http://mail.cs.uiuc.edu/mailman/listinfo/llvm-announce">
+http://mail.cs.uiuc.edu/mailman/listinfo/llvm-announce
+</a>.
+We will send mail to the list once the 1.0 Release is finished.
+</b>
+<hr>
+
 Welcome to the LLVM registration page!  Please complete the following form
 below to download a copy of the LLVM software.
+<p>
 
-<FORM ACTION="/cgi-bin/download.py" METHOD="POST">
+<FORM ACTION="/register.py" METHOD="POST">
 First Name (required):<br>
 <INPUT TYPE="text" SIZE=40 NAME="firstname"><br>
 <p>
@@ -50,10 +64,8 @@
 <TEXTAREA ROWS=10 COLS=80 NAME="plans"></TEXTAREA><br>
 <p>
 
-<!-- COMMENTED OUT
 <INPUT TYPE="submit" VALUE="Download">
 <INPUT TYPE="reset"  VALUE="Clear Form">
--->
 
 </FORM>
 





More information about the llvm-commits mailing list