From 5c7700b4a2d09d6a0766c86dd0fe82140618d1cb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 2 Jan 2002 16:39:19 +0000 Subject: [PATCH] cgi script kann jetzt speichern --- scripts/cgi-bin/info.py | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/scripts/cgi-bin/info.py b/scripts/cgi-bin/info.py index 110bffc24..5ce1376d6 100755 --- a/scripts/cgi-bin/info.py +++ b/scripts/cgi-bin/info.py @@ -7,6 +7,7 @@ import re import smtplib # specify the filename of the template file +scripturl="http://eressea.upb.de/~enno/cgi-bin/info.cgi" TemplateFile = "vinyambar.html" DefaultTitle = "Vinyambar Datenbank" dbname = "vinyambar" @@ -21,8 +22,8 @@ def Display(Content, Title=DefaultTitle): TemplateInput = TemplateHandle.read() TemplateHandle.close() # close the file - for key in Form.keys(): - Content=Content+"
"+key+"="+Form[key] + 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 @@ -52,7 +53,7 @@ def ShowInfo(custid, Password): results = cursor.execute(query); if results > 0: - output = "
Letzte Aktualisierung: "+str(lastdate)[0:10]+"
\n" + output = "
Letzte Aktualisierung: "+str(lastdate)[0:10]+"
\n" while results>0: results = results - 1 row = cursor.fetchone() @@ -107,13 +108,28 @@ def ShowInfo(custid, Password): output=output+line output=output+"
" - output=output+"
" + output=output+'
' + output=output+'' + output=output+'' output=output+"
" else: output = "Die Kundennummer oder das angegebene Passwort sind nicht korrekt." - + db.close() Display(output, "Kundendaten #"+str(custid)) +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+"'" + db = MySQLdb.connect(db=dbname) + cursor=db.cursor() + cursor.execute('UPDATE users SET '+values+' where id='+str(custid)) + db.close() + ShowInfo(custid, Password) +# Display("Noch nicht implementiert", "Daten speichern für Kunde #"+str(custid)) + def SendPass(custid): try: db = MySQLdb.connect(db=dbname) @@ -127,15 +143,13 @@ def SendPass(custid): server=smtplib.SMTP(smtpserver) server.sendmail(From, email, Msg) server.close() + db.close() Display('
Das Passwort wurde verschickt
', 'Kundendaten #'+str(custid)) except: Display('
Beim Versenden des Passwortes ist ein Fehler aufgetreten
', 'Kundendaten #'+str(custid)) Form = cgi.FieldStorage() -if Form.has_key("user"): - custid = int(Form["user"].value) - if Form.has_key("user"): custid = int(Form["user"].value) else: @@ -146,7 +160,9 @@ if Form.has_key("pass"): else: Password="" -if Password!="": - ShowInfo(custid, Password) -else: +if Password=="": SendPass(custid) +elif Form.has_key("save"): + Save(custid, Password) +else: + ShowInfo(custid, Password)