Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ####### index.py #########
- import cgi, cgitb
- cgitb.enable()
- import template
- print template.start
- print template.header
- print "Welcome to the IRC Quote DB"
- print template.footer
- ###### submit.py #######
- import cgi, cgitb
- cgitb.enable()
- import template
- formcontent = cgi.FieldStorage()
- if "content" not in formcontent:
- content = """\
- <form method="post" action="submit.py">
- <textarea rows="20" cols="80" name="content">
- </textarea>
- <input type="submit" value="Submit!">
- </form>"""
- if "content" in formcontent:
- import MySQLdb as sql
- db = sql.connect(host='localhost', user=template.user, passwd=template.pasw, db=template.database)
- cursor = db.cursor()
- cursor.execute("INSERT INTO quotes (content, score, moderated) VALUES(%s, %s, %s)", (formcontent['content'].value, 0, 0))
- content = """ Thank you, your quote has been added!"""
- db.close()
- print template.start
- print template.header
- print content
- print template.footer
- ###### template.py ######
- user = "quotes"
- pasw = "--------"
- database = "quotes"
- table = "quotes"
- start = "Content-Type: text/html\n\n"
- header = """\
- <html>
- <head>
- <title> IRC Quotes DB </title>
- </head>
- <body>
- <a href="./index.py"> Home </a> /
- <a href="./submit.py"> Submit </a> /
- <a href="./quotes.py?grab=mostrecent"> Most Recent </a> /
- <a href="./quotes.py?grab=top100"> Top 100 </a> /
- <br />"""
- footer = """\
- <br />
- </body>
- </html>"""
Advertisement
Add Comment
Please, Sign In to add comment