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

John Criswell criswell at cs.uiuc.edu
Tue Dec 16 15:07:13 PST 2003


Changes in directory llvm-www/releases:

testregister.cgi added (r1.1)
testregister.html added (r1.1)

---
Log message:

Test files for testing new functionality without breaking the old.



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

Index: llvm-www/releases/testregister.cgi
diff -c /dev/null llvm-www/releases/testregister.cgi:1.1
*** /dev/null	Tue Dec 16 15:07:02 2003
--- llvm-www/releases/testregister.cgi	Tue Dec 16 15:06:52 2003
***************
*** 0 ****
--- 1,191 ----
+ #!/usr/dcs/software/supported/bin/python
+ 
+ import cgi
+ import urllib
+ import smtplib
+ import os
+ import sys
+ import Cookie
+ 
+ # 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']
+ 
+ #
+ # 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       = email
+ 	pw2       = email
+ 	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', '')
+ 	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'
+ 
+ 	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)
+ 
+ #
+ # Create a cookie so that the user does not need to register again.
+ #
+ usercookie = Cookie.SimpleCookie()
+ usercookie['LLVM Download'] = 'Yes'
+ usercookie.output()
+ 
+ #
+ # Send the user to the download page.
+ #
+ print ('Location: /releases/download.html')
+ print ('')
+ 
+ sys.exit (0)
+ 


Index: llvm-www/releases/testregister.html
diff -c /dev/null llvm-www/releases/testregister.html:1.1
*** /dev/null	Tue Dec 16 15:07:02 2003
--- llvm-www/releases/testregister.html	Tue Dec 16 15:06:52 2003
***************
*** 0 ****
--- 1,85 ----
+ <html>
+ <head>
+   <title>LLVM Registration Page</title>
+   <link rel="stylesheet" type="text/css" href="../llvm.css">
+ </head>
+ <body>
+ 
+ <div class="rel_title">
+   LLVM Registration Page
+ </div>
+ 
+ <div class="rel_container">
+ 
+ <div class="rel_intro">
+ Welcome to the LLVM registration page!
+ <br><br>
+ We'd like to collect some information about people and organizations who are
+ interested in LLVM.  Please complete the following form below to download a copy
+ of the LLVM software.
+ </div>
+ 
+ <table class="rel_section">
+ <tr><td>Information</td></tr>
+ </table>
+ 
+ <div class="rel_boxtext">
+ 
+ <form action="testregister.cgi" method="POST">
+ 
+ <table align="center" border="0" cellpadding="3">
+ <tr>
+   <td><b>First Name</b> (required):</td>
+   <td><input type="text" size="40" name="firstname"></td>
+ </tr>
+ <tr>
+   <td><b>Last Name</b> (required):</td>
+   <td><input type="text" size="40" name="lastname"></td>
+ </tr>
+ <tr>
+   <td><b>Email Address</b> (required):</td>
+   <td><input type="text" size="40" name="email"></td>
+ </tr>
+ <tr>
+   <td><b>Organizational Affiliation:</b></td>
+   <td><input type="text" size="40" name="organization"></td>
+ </tr>
+ <tr>
+   <td><b>Position/Title:</b></td>
+   <td><input type="text" size="40" name="title"></td>
+ </tr>
+ </table>
+ 
+ <p>
+ The LLVM Announcements List is a low volume mailing list that provides LLVM
+ users with important information on new LLVM releases.  If you would like to
+ subscribe to this list, please select "yes" and respond to the confirmation
+ email that you will receive (<b>your email address will be your password</b>):
+ </p>
+ 
+ Subscribe to 
+ <a href="http://mail.cs.uiuc.edu/mailman/listinfo/llvm-announce">LLVM
+ Announcements List</a> (default is <em>yes</em>):
+ <br>
+ <input type="radio" name="announce" value="yes" checked> Yes<br>
+ <input type="radio" name="announce"value="no"> No<br>
+ 
+ <p>
+ We would be interested to know how you plan to use LLVM.
+ <br>
+ This information is strictly optional and will be kept completely confidential:<br>
+ <textarea rows="10" cols="60" name="plans"></textarea>
+ </p>
+ 
+ Finally, click "Download" to go to the download page:<br>
+ <input type="submit" value="Download">
+ <input type="reset"  value="Clear Form">
+ 
+ </form>
+ 
+ </div>
+ 
+ </div>
+ 
+ </body>
+ </html>





More information about the llvm-commits mailing list