#!/usr/bin/python import sys import MySQLdb import cgi import re import smtplib # specify the filename of the template file TemplateFile = "vinyambar.html" DefaultTitle = "Vinyambar Datenbank" dbname = "vinyambar" From = "accounts@vinyambar.de" 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 # 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] def ShowInfo(custid, Password): db = MySQLdb.connect(db=dbname) cursor = db.cursor() cursor.execute("select max(date), max(id) from transactions") lastdate, id = cursor.fetchone() query=("select info, firstname, lastname, email, address, city, country, phone, sum(t.balance), status "+ "from users u, transactions t "+ "where u.id=t.user and u.id="+str(custid)+" and u.password='"+Password+"' "+ "GROUP BY u.id") #print query results = cursor.execute(query); if results > 0: output = "