forked from github/server
canceling
This commit is contained in:
parent
666fb81e14
commit
0d7e25dc4e
1 changed files with 89 additions and 75 deletions
|
@ -7,7 +7,7 @@ import re
|
|||
import smtplib
|
||||
|
||||
# specify the filename of the template file
|
||||
scripturl="http://eressea.upb.de/~enno/cgi-bin/info.cgi"
|
||||
scripturl="http://eressea.upb.de/~enno/cgi-bin/info.py"
|
||||
TemplateFile = "vinyambar.html"
|
||||
DefaultTitle = "Vinyambar Datenbank"
|
||||
dbname = "vinyambar"
|
||||
|
@ -23,7 +23,7 @@ def Display(Content, Title=DefaultTitle):
|
|||
TemplateHandle.close() # close the file
|
||||
|
||||
# for key in Form.keys():
|
||||
# Content=Content+"<br>"+str(key)+"="+str(Form[key])
|
||||
# Content=Content+"<br>"+str(key)+"="+str(Form[key])
|
||||
|
||||
# this defines an exception string in case our
|
||||
# template file is messed up
|
||||
|
@ -32,7 +32,7 @@ def Display(Content, Title=DefaultTitle):
|
|||
SubResult = re.subn("<!-- INSERT TITLE HERE -->", Title, TemplateInput)
|
||||
SubResult = re.subn("<!-- INSERT CONTENT HERE -->", Content, SubResult[0])
|
||||
if SubResult[1] == 0:
|
||||
raise BadTemplateException
|
||||
raise BadTemplateException
|
||||
|
||||
print "Content-Type: text/html\n\n"
|
||||
print SubResult[0]
|
||||
|
@ -53,67 +53,68 @@ def ShowInfo(custid, Password):
|
|||
results = cursor.execute(query);
|
||||
if results > 0:
|
||||
|
||||
output = "<div align=center>Letzte Aktualisierung: "+str(lastdate)[0:10]+"</div><form action=\""+scripturl+"\" method=post><div align=left><table width=80% border>\n"
|
||||
while results>0:
|
||||
results = results - 1
|
||||
row = cursor.fetchone()
|
||||
line = "<tr>"
|
||||
line = line + "<tr><th height=30>Vorname</th><td><input size=40 name=firstname value=\""+row[1]+"\"></td></tr>\n"
|
||||
line = line + "<tr><th height=30>Nachname</th><td><input size=40 name=lastname value=\""+row[2]+"\"></td></tr>\n"
|
||||
line = line + "<tr><th height=30>EMail Adresse</th><td><input size=40 name=email value=\""+row[3]+"\"></td></tr>\n"
|
||||
line = line + "<tr><th height=30>Adresse</th><td><input size=40 name=address value=\""+row[4]+"\"></td></tr>\n"
|
||||
line = line + "<tr><th height=30>Wohnort</th><td><input size=40 name=city value=\""+row[5]+"\"></td></tr>\n"
|
||||
line = line + "<tr><th height=30>Telefon</th><td><input size=40 name=phone value=\""+row[7]+"\"></td></tr>\n"
|
||||
line = line + "<tr><th height=30>Kontostand</th><td>"+str(row[8])+" EUR</td></tr>\n"
|
||||
line = line + "<tr><th height=30>Status</th><td>"+row[9]+"</td></tr>\n"
|
||||
output = output + line;
|
||||
output = "<div align=center>Letzte Aktualisierung: "+str(lastdate)[0:10]+"</div><form action=\""+scripturl+"\" method=post><div align=left><table width=80% border>\n"
|
||||
while results>0:
|
||||
results = results - 1
|
||||
row = cursor.fetchone()
|
||||
line = "<tr>"
|
||||
line = line + "<tr><th height=30>Vorname</th><td><input size=40 name=firstname value=\""+row[1]+"\"></td></tr>\n"
|
||||
line = line + "<tr><th height=30>Nachname</th><td><input size=40 name=lastname value=\""+row[2]+"\"></td></tr>\n"
|
||||
line = line + "<tr><th height=30>EMail Adresse</th><td><input size=40 name=email value=\""+row[3]+"\"></td></tr>\n"
|
||||
line = line + "<tr><th height=30>Adresse</th><td><input size=40 name=address value=\""+row[4]+"\"></td></tr>\n"
|
||||
line = line + "<tr><th height=30>Wohnort</th><td><input size=40 name=city value=\""+row[5]+"\"></td></tr>\n"
|
||||
line = line + "<tr><th height=30>Telefon</th><td><input size=40 name=phone value=\""+row[7]+"\"></td></tr>\n"
|
||||
line = line + "<tr><th height=30>Kontostand</th><td>"+str(row[8])+" EUR</td></tr>\n"
|
||||
line = line + "<tr><th height=30>Status</th><td>"+row[9]+"</td></tr>\n"
|
||||
output = output + line;
|
||||
|
||||
output=output+"</table></div>"
|
||||
output=output+"</table></div>"
|
||||
|
||||
query = ("select games.name, races.name, s.status, s.faction "+
|
||||
"from races, games, subscriptions s "+
|
||||
"where s.race=races.race and s.game=games.id "+
|
||||
"and s.user="+str(custid)+" ");
|
||||
query = ("select games.name, races.name, s.status, s.faction "+
|
||||
"from races, games, subscriptions s "+
|
||||
"where s.race=races.race and s.game=games.id "+
|
||||
"and s.user="+str(custid)+" ");
|
||||
|
||||
results = cursor.execute(query);
|
||||
results = cursor.execute(query);
|
||||
|
||||
output=output+"<h3>Anmeldungen</h3>\n<div align=left><table width=80% border>\n"
|
||||
output=output+"<tr><th>Spiel</th><th>Rasse</th><th>Status</th><th>Partei</th></tr>\n"
|
||||
while results>0:
|
||||
results = results - 1
|
||||
row = cursor.fetchone()
|
||||
line = "<tr>"
|
||||
line = line + "<td align=left>"+row[0]+"</td>\n"
|
||||
line = line + "<td align=left>"+row[1]+"</td>\n"
|
||||
line = line + "<td align=left>"+row[2]+"</td>\n"
|
||||
line = line + "<td align=left>"+row[3]+"</td>\n"
|
||||
line = line + "</tr>\n"
|
||||
output=output+line
|
||||
output=output+"<h3>Anmeldungen</h3>\n<div align=left><table width=80% border>\n"
|
||||
output=output+"<tr><th>Spiel</th><th>Rasse</th><th>Status</th><th>Partei</th><th>Abmelden</th></tr>\n"
|
||||
while results>0:
|
||||
results = results - 1
|
||||
row = cursor.fetchone()
|
||||
line = "<tr>"
|
||||
line = line + '<td align="left">'+row[0]+'</td>\n'
|
||||
line = line + '<td align="left">'+row[1]+'</td>\n'
|
||||
line = line + '<td align="left">'+row[2]+'</td>\n'
|
||||
line = line + '<td align="left">'+row[3]+'</td>\n'
|
||||
line = line + '<td align="left"><input type="checkbox" name="cancel" value="cancel_' + row[3] + '"></td>\n'
|
||||
line = line + '</tr>\n'
|
||||
output=output+line
|
||||
|
||||
output=output+"</table></div>"
|
||||
query="select date, balance, text from transactions, descriptions where descriptions.handle=transactions.description and user="+str(custid)
|
||||
output=output+"</table></div>"
|
||||
query="select date, balance, text from transactions, descriptions where descriptions.handle=transactions.description and user="+str(custid)
|
||||
|
||||
results = cursor.execute(query);
|
||||
results = cursor.execute(query);
|
||||
|
||||
output=output+"<h3>Transaktionen</h3>\n<div align=left><table width=80% border>\n"
|
||||
output=output+"<tr><th>Datum</th><th>Betrag</th><th>Verwendung</th></tr>\n"
|
||||
while results>0:
|
||||
results = results - 1
|
||||
row = cursor.fetchone()
|
||||
line = "<tr>"
|
||||
line = line + "<td align=left>"+str(row[0])[0:10]+"</td>\n"
|
||||
line = line + "<td align=right>"+str(row[1])+" EUR</td>\n"
|
||||
line = line + "<td align=left>"+row[2]+"</td>\n"
|
||||
line = line + "</tr>\n"
|
||||
output=output+line
|
||||
output=output+"<h3>Transaktionen</h3>\n<div align=left><table width=80% border>\n"
|
||||
output=output+"<tr><th>Datum</th><th>Betrag</th><th>Verwendung</th></tr>\n"
|
||||
while results>0:
|
||||
results = results - 1
|
||||
row = cursor.fetchone()
|
||||
line = "<tr>"
|
||||
line = line + "<td align=left>"+str(row[0])[0:10]+"</td>\n"
|
||||
line = line + "<td align=right>"+str(row[1])+" EUR</td>\n"
|
||||
line = line + "<td align=left>"+row[2]+"</td>\n"
|
||||
line = line + "</tr>\n"
|
||||
output=output+line
|
||||
|
||||
output=output+"</table></div>"
|
||||
output=output+'<div align=left><input name="save" type="submit" value="Speichern"></div>'
|
||||
output=output+'<input type="hidden" name="user" value="'+str(custid)+'"></div>'
|
||||
output=output+'<input type="hidden" name="pass" value="'+Password+'"></div>'
|
||||
output=output+"</form>"
|
||||
output=output+"</table></div>"
|
||||
output=output+'<div align=left><input name="save" type="submit" value="Speichern"></div>'
|
||||
output=output+'<input type="hidden" name="user" value="'+str(custid)+'"></div>'
|
||||
output=output+'<input type="hidden" name="pass" value="'+Password+'"></div>'
|
||||
output=output+"</form>"
|
||||
else:
|
||||
output = "Die Kundennummer oder das angegebene Passwort sind nicht korrekt."
|
||||
output = "Die Kundennummer oder das angegebene Passwort sind nicht korrekt."
|
||||
db.close()
|
||||
Display(output, "Kundendaten #"+str(custid))
|
||||
|
||||
|
@ -121,34 +122,47 @@ def Save(custid, Password):
|
|||
validkeys=['email','address','lastname','firstname','city','password','phone']
|
||||
values='id='+str(custid)
|
||||
for key in Form.keys():
|
||||
if key in validkeys:
|
||||
values=values+", "+key+"='"+Form[key].value+"'"
|
||||
if key in validkeys:
|
||||
values=values+", "+key+"='"+Form[key].value+"'"
|
||||
db = MySQLdb.connect(db=dbname)
|
||||
cursor=db.cursor()
|
||||
cursor.execute('UPDATE users SET '+values+' where id='+str(custid))
|
||||
|
||||
nfactions = cursor.execute("select game, id, faction from subscriptions where status='ACTIVE' and user="+str(custid))
|
||||
while nfactions > 0:
|
||||
game, sid, faction = cursor.fetchone()
|
||||
if Form.has_key("cancel_"+faction):
|
||||
update = db.cursor("UPDATE subscriptions set status='CANCELLED' where id="+str(sid))
|
||||
server=smtplib.SMTP(smtpserver)
|
||||
Msg="From: accounts@vinyambar.de\nTo: admin@vinyambar.de\nSubject: Vinambar Abmeldung\n\n"
|
||||
Msg=Msg+"Die Partei: "+faction+" hat sich aus Spiel Nr. "+game+" abgemeldet\n"
|
||||
server.sendmail("accounts@vinyambar.de", "admin@vinyambar.de", Msg)
|
||||
server.close()
|
||||
nfactions = nfactions - 1
|
||||
|
||||
db.close()
|
||||
ShowInfo(custid, Password)
|
||||
# Display("Noch nicht implementiert", "Daten speichern für Kunde #"+str(custid))
|
||||
|
||||
def SendPass(email):
|
||||
try:
|
||||
db = MySQLdb.connect(db=dbname)
|
||||
cursor=db.cursor()
|
||||
# print custid
|
||||
cursor.execute("select id, email, password from users where email='"+email+"'")
|
||||
custid, email, password = cursor.fetchone()
|
||||
Msg="From: "+From+"\nTo: "+email+"\nSubject: Vinambar Passwort\n\n"
|
||||
Msg=Msg+"Deine Kundennummer ist: "+str(int(custid))+"\n"
|
||||
Msg=Msg+"Dein Vinyambar-Passwort lautet: "+password+"\n"
|
||||
Msg=Msg+"\nDiese Mail wurde an Dich versandt, weil Du (oder jemand anders) \n"
|
||||
Msg=Msg+"es im Formular auf http://www.vinyambar.de/accounts.shtml angefordert hat.\n"
|
||||
server=smtplib.SMTP(smtpserver)
|
||||
server.sendmail(From, email, Msg)
|
||||
server.close()
|
||||
db.close()
|
||||
Display('<div align="center">Das Passwort wurde verschickt</div>', 'Kundendaten #'+str(custid))
|
||||
db = MySQLdb.connect(db=dbname)
|
||||
cursor=db.cursor()
|
||||
# print custid
|
||||
cursor.execute("select id, email, password from users where email='"+email+"'")
|
||||
custid, email, password = cursor.fetchone()
|
||||
Msg="From: "+From+"\nTo: "+email+"\nSubject: Vinambar Passwort\n\n"
|
||||
Msg=Msg+"Deine Kundennummer ist: "+str(int(custid))+"\n"
|
||||
Msg=Msg+"Dein Vinyambar-Passwort lautet: "+password+"\n"
|
||||
Msg=Msg+"\nDiese Mail wurde an Dich versandt, weil Du (oder jemand anders) \n"
|
||||
Msg=Msg+"es im Formular auf http://www.vinyambar.de/accounts.shtml angefordert hat.\n"
|
||||
server=smtplib.SMTP(smtpserver)
|
||||
server.sendmail(From, email, Msg)
|
||||
server.close()
|
||||
db.close()
|
||||
Display('<div align="center">Das Passwort wurde verschickt</div>', 'Kundendaten #'+str(custid))
|
||||
except:
|
||||
Display('<div align="center">Beim Versenden des Passwortes ist ein Fehler aufgetreten.<br>Eventuell ist die email-Adresse unbekannt</div>', 'Kundendaten für '+email)
|
||||
Display('<div align="center">Beim Versenden des Passwortes ist ein Fehler aufgetreten.<br>Eventuell ist die email-Adresse unbekannt</div>', 'Kundendaten für '+email)
|
||||
|
||||
Form = cgi.FieldStorage()
|
||||
|
||||
|
@ -164,9 +178,9 @@ else:
|
|||
|
||||
if Form.has_key("sendpass"):
|
||||
if Form.has_key("email"):
|
||||
Email = Form["email"].value
|
||||
Email = Form["email"].value
|
||||
else:
|
||||
Email=""
|
||||
Email=""
|
||||
SendPass(Email)
|
||||
elif Form.has_key("save"):
|
||||
Save(custid, Password)
|
||||
|
|
Loading…
Reference in a new issue