#!/usr/bin/env python
import smtplib
import MySQLdb
import cgi
import re
# specify the filename of the template file
scripturl='http://eressea.upb.de/~enno/cgi-bin/standin.py'
TemplateFile = "vinyambar.html"
DefaultTitle = "Vinyambar Parteibörse"
dbname = "vinyambar"
From = "accounts@vinyambar.de"
Errors = ""
db = MySQLdb.connect(db=dbname)
smtpserver='localhost'
# define a new function called Display
# it takes one parameter - a string to Display
def Display(Content, Title=DefaultTitle):
TemplateHandle = open(TemplateFile, "r") # open in read only mode
# read the entire file as a string
TemplateInput = TemplateHandle.read()
TemplateHandle.close() # close the file
# for key in Form.keys():
# Content=Content+"
"+str(key)+"="+str(Form[key])
# this defines an exception string in case our
# template file is messed up
BadTemplateException = "There was a problem with the HTML template."
SubResult = re.subn("", Title, TemplateInput)
SubResult = re.subn("", Content, SubResult[0])
if SubResult[1] == 0:
raise BadTemplateException
print "Content-Type: text/html\n\n"
print SubResult[0]
return
def ShowPage():
cursor=db.cursor()
maxturn = {}
games = cursor.execute("SELECT max(lastturn), game from subscriptions GROUP by game")
while games>0:
games=games-1
lastturn, game = cursor.fetchone()
maxturn[game] = lastturn
output='
Um eine der folgenden Parteien zu übernehmen, musst du zuerst ein Spielerkonto anlegen. Wenn Du eines hast, markiere die Partei, die Du übernehmen willst, und trage Kundennummer und Kundenpasswort ein.' query = "SELECT g.id, g.name, s.faction, s.lastturn, s.id, s.race, s.info from games g, subscriptions s where s.game=g.id and s.status='CANCELLED'" results = cursor.execute(query) output=output+'