[llvm-commits] CVS: llvm-www/releases/quickreg.cgi

John Criswell criswell at cs.uiuc.edu
Thu Dec 18 15:52:01 PST 2003


Changes in directory llvm-www/releases:

quickreg.cgi added (r1.1)

---
Log message:

Script used to do quick registration.



---
Diffs of the changes:  (+130 -0)

Index: llvm-www/releases/quickreg.cgi
diff -c /dev/null llvm-www/releases/quickreg.cgi:1.1
*** /dev/null	Thu Dec 18 15:51:43 2003
--- llvm-www/releases/quickreg.cgi	Thu Dec 18 15:51:33 2003
***************
*** 0 ****
--- 1,130 ----
+ #!/usr/dcs/software/supported/bin/python
+ 
+ import cgi
+ import urllib
+ import smtplib
+ import os
+ import fcntl
+ import sys
+ import pickle
+ 
+ # List of email addresses that want to know when people download
+ notifylist=['vadve at cs.uiuc.edu', 'criswell at uiuc.edu', 'sabre at nondot.org']
+ 
+ # Full pathname of the logfile
+ logfilename='/var/tmp/LLVMDownloads'
+ 
+ #
+ # Function: checkEmail()
+ #
+ # Description:
+ #	This function searches through the database to see if the email address
+ # has already been registered.
+ #pickle.dump ((email, firstname, lastname, organization, title), logfile) 
+ #
+ def checkEmail (email):
+ 
+ 	#
+ 	# Assume we haven't found a matching entry.
+ 	#
+ 	foundentry = ('','','','','')
+ 	try:
+ 		#
+ 		# Open the logfile read only.
+ 		#
+ 		logfile = file (logfilename, 'r')
+ 
+ 		found = 0
+ 		while (found == 0):
+ 			entry = pickle.load (logfile)
+ 			if (entry[0] == email):
+ 				foundentry = entry
+ 				break
+ 	except:
+ 		pass
+ 
+ 	try:
+ 		logfile.close ()
+ 	except:
+ 		pass
+ 
+ 	return foundentry
+ 
+ #
+ # 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', '')
+ 	title        = form.getfirst ('title','')
+ 	organization = form.getfirst ('organization', '')
+ 
+ 	#
+ 	# Verify the email address first.
+ 	#
+ 	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'
+ 
+ 	#
+ 	# Determine if the email address has been used in a previous
+ 	# registration.
+ 	#
+ 	entry = checkEmail (email)
+ 	if (entry[0] != ''):
+ 		return 'registered'
+ 	return 'unregistered'
+ 
+ #
+ # Parse the CGI input
+ #
+ form = cgi.FieldStorage ()
+ 
+ #
+ # Verify that everything in the form is correct.
+ #
+ error = ValidateForm (form)
+ if (error == 'registered'):
+ 	print ('Location: /releases/download.html')
+ 	print ('')
+ 	sys.exit (0)
+ 
+ #
+ # Send the user to the download page.
+ #
+ print ('Content-type: text/html')
+ print ('')
+ 
+ print ('<center><h1>Sorry; not registered</center></h1>')
+ print ('<p>')
+ print ('We are sorry, but we cannot find your email address in our database.')
+ print ('Please use the normal registration system.')
+ print ('</p>')
+ 
+ sys.exit (0)
+ 





More information about the llvm-commits mailing list