def main(): # Handles header, reads from petition files, and invokes get_details() or # starts the authentication proccess according to the 'send' value # passed by CGI. print """Content-Type: text/html\n\n <head> <style type="text/css"> table {font-size:8pt;font-family: sans-serif;} </style> <title>Petitioner 1.1 | [email protected]</title> </head>""" form = cgi.FieldStorage() data = petitioner.data(form) file_number = form.getfirst("petition", "empty") addresses_path = "./address_files/" + str(file_number) addresses = open(addresses_path).read().split() text_path = "./text_files/" + str(file_number) text = str(open(text_path).read()) if form.getfirst("send", "empty") != "true": get_details(file_number, addresses, text, data) else: from_name = form.getfirst("from_name", "Anonymous") from_address = form.getfirst("from_address", "No email address.") code = authenticate(file_number, from_name, from_address) email(from_address, code)
def main(): # Handles headers. Primarily an HTML wrapper for petitioner.data() function, # then ask for confirmation and invoke get_link.py # Needs eye-candy. print """Content-Type: text/html\n\n <head> <style type="text/css"> table {font-size:8pt; font-family: sans-serif;} </style> <title>Petitioner 1.1 | [email protected]</title> </head>""" form = cgi.FieldStorage() print "<body>" print "<table width=100%>" print "</tr><tr><td width=50% height=310px>" print "(Currently we don't have email addresses for all MPs.)" print "<div id='members' style='position:relative;width:100%;height:100%; \ overflow:auto;'><table border=1>" for line in petitioner.data(form): print "<tr>" for value in line: print "<td>" print value print "</td>" print "</tr>" print "</table></div></td><td><b>" print cgi.escape(form.getfirst("subject", "No subject")) print "</b><br><br><textarea rows='20' cols='65'>" print cgi.escape(form.getfirst("text", "Message was empty!")) print "</textarea>" print "</td></tr></table>" print "<p><center>" print "<a href='" print petitioner.parse_url(petitioner.columns(form), form) print "'>Confirm and get link.</a>" print "</center>" print "</body>"
def main(): # Handles header print """Content-Type: text/html\n\n <head> <style type="text/css"> table {font-size:8pt; font-family: sans-serif;} </style> <title>Petitioner 1.1 | [email protected]</title> </head>""" # Reads from files and prepares 'data' form = cgi.FieldStorage() text = cgi.escape(form.getfirst("text", "false")) subject = cgi.escape(form.getfirst("subject", "false")) # Update running count of petitions. # This will be used for file names in text_files, address_files and # count_files count_file = open("count.txt", "r") count = str(int(count_file.read())+1) count_file.close() count_file = open("count.txt", "w") count_file.write(count) count_file.close() # Creates text_file with name in the form 000001. # Writes the petition text to the newly created file. file_name = "./text_files/" + count.zfill(6) text_file = open(file_name, "w") text_file.write(text) text_file.close() # Creates subject_file with name in the form 000001. # Writes the petition subject to the newly created file. file_name = "./subject_files/" + count.zfill(6) subject_file = open(file_name, "w") subject_file.write(subject) subject_file.close() # Creates address_files with name in the form 000001. # Writes the list of addressees, one address per lines, the newly created file. file_name = "./address_files/" + count.zfill(6) address_file = open(file_name, "w") for member in petitioner.data(form): string = member[-1] + "\n" address_file.write(string) address_file.close() # Creates count_file with name in the form 000001. # Keeps a count of how many times each petition has been sent. file_name = "./count_files/" + count.zfill(6) petition_count = open(file_name, "w") petition_count.write("0") petition_count.close() link = "http://www.petitionaustralia.com/cgi-bin/authenticate.py?" link += "petition=" + count.zfill(6) print "<center>" print "<h2>You are all done!</h2>" print "<p>To allow others to input their details and send this email" print "petition, just give them this link:<br><br><span id='copytext'" print "style='height:150;width:162;background-color:pink'>" print link print "</span><br>" print "<a href='" print link print "'>Follow link.</a></p></center>"