From c3cb5ba1ccdb1d283e7a989327e031f125e0f8a8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 18 Apr 2002 00:49:22 +0000 Subject: [PATCH] Umstellung des Anmeldesystems --- scripts/cgi-bin/eressea-confirm.py | 16 ++++- scripts/cgi-bin/eressea-register.py | 62 ++++++++++++++----- scripts/register/getfactions.py | 19 +++++- scripts/register/payment.py | 3 +- ...ister.mail.de => register.mail.eressea.de} | 4 +- ...ister.mail.en => register.mail.eressea.en} | 2 +- scripts/templates/register.mail.tutorial.de | 21 +++++++ scripts/templates/register.mail.tutorial.en | 19 ++++++ 8 files changed, 120 insertions(+), 26 deletions(-) rename scripts/templates/{register.mail.de => register.mail.eressea.de} (85%) rename scripts/templates/{register.mail.en => register.mail.eressea.en} (88%) create mode 100644 scripts/templates/register.mail.tutorial.de create mode 100644 scripts/templates/register.mail.tutorial.en diff --git a/scripts/cgi-bin/eressea-confirm.py b/scripts/cgi-bin/eressea-confirm.py index 9b78e62ce..e4053bb5f 100755 --- a/scripts/cgi-bin/eressea-confirm.py +++ b/scripts/cgi-bin/eressea-confirm.py @@ -15,6 +15,7 @@ HTMLTemplate = "eressea.html" DefaultTitle = "Eressea Anmeldung" dbname = "eressea" db=None +tutorial_id=1 # the tuorial game has id 1 # define a new function called Display # it takes one parameter - a string to Display @@ -54,6 +55,9 @@ def genpasswd(): return newpasswd +Display("Derzeit ist wegen einer technischen Umstellung keine Anmeldung möglich") +sys.exit(0) + Form = cgi.FieldStorage() custid=GetKey(Form, "custid") @@ -67,13 +71,21 @@ if (password==None) or (custid==None): else: db=MySQLdb.connect(db=dbname) cursor=db.cursor() - exist=cursor.execute("select id from users where id="+custid+" and status in('WAITING','CONFIRMED') and password='"+password+"'") + exist=cursor.execute("select u.status, s.id, s.game from users u, subscriptions s where u.id="+custid+" and s.status in ('WAITING', 'CONFIRMED') and s.password='"+password+"'") if exist==0: Display('

Kundennummer oder Schlüssel falsch. Bitte beachte, dass Du beim Schlüssel auf Groß- und Kleinschreibung achten mußt.') else: + status, sid, gid = cursor.fetchone() if os.environ.has_key('REMOTE_ADDR'): ip=os.environ['REMOTE_ADDR'] cursor.execute("REPLACE userips (ip, user) VALUES ('"+ip+"', "+str(int(custid))+")") - cursor.execute("update users set status='CONFIRMED' where password='"+password+"' and id="+custid) + if status=='NEW' or status=='TUTORIAL': + if tutorial_id!=None and gid==tutorial_id: + # user confirms his tutorial participation + cursor.execute("update users set status='TUTORIAL' where id="+custid) + else: + cursor.execute("update users set status='ACTIVE' where id="+custid) + cursor.execute("update subscriptions set status='CONFIRMED' where id="+str(sid)) + Display("

Deine Anmeldung wurde bestätigt."); db.close() diff --git a/scripts/cgi-bin/eressea-register.py b/scripts/cgi-bin/eressea-register.py index 25898825d..6e18dc305 100755 --- a/scripts/cgi-bin/eressea-register.py +++ b/scripts/cgi-bin/eressea-register.py @@ -22,6 +22,8 @@ From = "accounts@eressea-pbem.de" locale="de" smtpserver = 'localhost' db=None +game_id=0 # Eressea Main game +tutorial_id=None # # define a new function called Display # it takes one parameter - a string to Display @@ -45,8 +47,11 @@ def Display(Content, Title=DefaultTitle): return -def Send(email, custid, firstname, password, position): - TemplateHandle = open(MailTemplate+"."+locale, "r") # open in read only mode +def Send(email, custid, sid, firstname, password, game): + cursor=db.cursor() + cursor.execute("select count(*), g.name from games g, subscriptions s where g.id="+str(game)+" AND (s.status='WAITING' or s.status='CONFIRMED') AND g.id=s.game GROUP BY g.id") + position, name = cursor.fetchone() + TemplateHandle = open(MailTemplate+"."+string.lower(name)+"."+locale, "r") # open in read only mode # read the entire file as a string TemplateInput = TemplateHandle.read() TemplateHandle.close() # close the file @@ -54,16 +59,16 @@ def Send(email, custid, firstname, password, position): SubResult = re.subn("", firstname, TemplateInput) SubResult = re.subn("", password, SubResult[0]) SubResult = re.subn("", str(int(position)), SubResult[0]) + SubResult = re.subn("", name, SubResult[0]) SubResult = re.subn("", str(int(custid)), SubResult[0]) - subject={"de":"Eressea Anmeldung","en":"Eressea Registration"} - Msg="From: "+From+"\nTo: "+email+"\nSubject: "+subject[locale]+"\n\n" + subject={"de":"Anmeldung","en":"Registration"} + Msg="From: "+From+"\nTo: "+email+"\nSubject: "+name+" "+subject[locale]+"\n\n" Msg=Msg+SubResult[0] server=smtplib.SMTP(smtpserver) server.sendmail(From, email, Msg) server.close() return - def GetKey(Form, key): if Form.has_key(key): value=Form[key].value @@ -85,6 +90,8 @@ def genpasswd(): newpasswd = newpasswd + choice(chars) return newpasswd +Display("Derzeit ist wegen einer technischen Umstellung keine Anmeldung möglich") +sys.exit(0) Form = cgi.FieldStorage() @@ -114,7 +121,8 @@ elif ValidEmail(email)==0: else: db=MySQLdb.connect(db=dbname) cursor=db.cursor() - exist=cursor.execute("select id from users where email='"+email+"' and (status='WAITING' or status='CONFIRMED')") + # check if he is already entered in the main game: + exist=cursor.execute("select u.id from users u, subscriptions s where s.user=u.id AND s.game="+str(game_id)+" AND u.email='"+email+"' and (s.status='WAITING' or s.status='CONFIRMED')") if exist: text={"de":"Du stehst bereits auf der Warteliste","en":"You are already on the waiting list"} Display('

'+text[locale]) @@ -128,9 +136,8 @@ else: sys.exit(0) # create a new user record - password=genpasswd() - fields = "firstname, lastname, locale, email, address, city, status, password" - values = "'"+firstname+"', '"+lastname+"', '"+locale+"', '"+email+"', '"+address+"', '"+city+"', 'WAITING', '"+password+"'" + fields = "firstname, lastname, locale, email, address, city" + values = "'"+firstname+"', '"+lastname+"', '"+locale+"', '"+email+"', '"+address+"', '"+city+"'" if phone!=None: fields=fields+", phone" values=values+", '"+phone+"'" @@ -149,9 +156,26 @@ else: values=values+", 1" else: values=values+", 0" - cursor.execute("insert into users ("+fields+") VALUES ("+values+")") - cursor.execute("SELECT LAST_INSERT_ID() from dual") - custid=cursor.fetchone()[0] + exist=cursor.execute("select password, status, id from users where email='"+email+"'") + custid=0 + status='NEW' + if exist: + # user exists, update his data + password, status, custid=cursor.fetchone() + if status=='BANNED': + Display('Dein Account ist gesperrt.
Bitte wende Dich an accounts@eressea-pbem.de falls Du Fragen zu dieser Meldung hast.') + sys.exit(0) + fields=fields+", id, status" + values=values+", "+str(custid)+", '"+status+"'" + command="REPLACE" + cursor.execute("REPLACE into users ("+fields+") VALUES ("+values+")") + else: + password = genpasswd() + fields=fields+", password, status" + values=values+", '"+password+"', 'NEW'" + cursor.execute("INSERT into users ("+fields+") VALUES ("+values+")") + cursor.execute("SELECT LAST_INSERT_ID() from dual") + custid=cursor.fetchone()[0] # track IP addresses ip=None @@ -161,18 +185,22 @@ else: cursor.execute("REPLACE userips (ip, user) VALUES ('"+ip+"', "+str(int(custid))+")") # add a subscription record - values="'PENDING', '"+genpasswd()+"'" + password = genpasswd() + values="'WAITING', '"+password+"'" fields="status, password" + game = game_id + if tutorial_id!=None and status!='ACTIVE': + game=tutorial_id if bonus!=None: fields=fields+", bonus" if bonus=='yes': values=values+", 1" else: values=values+", 0" - cursor.execute("insert into subscriptions (user, race, game, "+fields+") VALUES ("+str(int(custid))+", '"+race+"', 0, "+values+")") - - cursor.execute("select count(*) from users where status='WAITING' or status='CONFIRMED'") - Send(email, custid, firstname, password, cursor.fetchone()[0]) + cursor.execute("insert into subscriptions (user, race, game, "+fields+") VALUES ("+str(int(custid))+", '"+race+"', "+str(game)+", "+values+")") + cursor.execute("SELECT LAST_INSERT_ID() from dual") + sid = cursor.fetchone()[0] + Send(email, custid, sid, firstname, password, game) text={"de":"Deine Anmeldung wurde bearbeitet. Eine EMail mit Hinweisen ist unterwegs zu Dir", "en":"Your application was processed. An email containing further instructions is being sent to you"} Display("

"+text[locale]+".") db.close() diff --git a/scripts/register/getfactions.py b/scripts/register/getfactions.py index de84928ee..67cfb28aa 100755 --- a/scripts/register/getfactions.py +++ b/scripts/register/getfactions.py @@ -2,19 +2,34 @@ import MySQLdb import sys +import string +from whrandom import choice dbname=sys.argv[1] maxnum=int(sys.argv[2]) +game_id=0 # eressea is game 0, tutorial is 1 -query = "select distinct u.email, s.password, r.name, u.locale, s.bonus from users u, races r, subscriptions s left join userips i on u.id=i.user left join bannedips b on i.ip=b.ip where s.user=u.id and b.ip is NULL and u.status='CONFIRMED' and r.race=s.race and r.locale='de' order by u.id" +def genpasswd(): + newpasswd="" + chars = string.letters + string.digits + for i in range(8): + newpasswd = newpasswd + choice(chars) + return newpasswd + +query = "select distinct u.email, s.id, s.password, r.name, u.locale, s.bonus from users u, races r, subscriptions s left join userips i on u.id=i.user left join bannedips b on i.ip=b.ip where s.user=u.id and b.ip is NULL and u.status='CONFIRMED' and r.race=s.race and s.game="+str(game_id)+" and r.locale='de' order by u.id" db=MySQLdb.connect(db=dbname) cursor = db.cursor() +c = db.cursor() num=cursor.execute(query) if num>maxnum: num=maxnum while num: num=num-1 - email, password, race, locale, bonus = cursor.fetchone() + email, sid, password, race, locale, bonus = cursor.fetchone() if bonus==None: bonus=0 + if password==None: + password=genpasswd() + c.execute("UPDATE subscriptions set password='"+password+"' where id="+str(int(sid))) + print email+" "+race+" "+locale+" "+str(int(bonus))+" "+password diff --git a/scripts/register/payment.py b/scripts/register/payment.py index 591d1d2b7..771b2a875 100755 --- a/scripts/register/payment.py +++ b/scripts/register/payment.py @@ -27,7 +27,6 @@ def pay(db, userid, email, cash, date, reason='PAYMENT'): balance=cursor.fetchone()[0] if balance==None: balance=0.0 - Msg = ("From: Vinyambar Buchhaltung <"+From+">\nTo: "+email+"\nSubject: Vinyambar Zahlungseingang.\n\n"+ "Kundennummer: "+str(userid)+"\n"+ "Eingangsdatum: "+date+"\n"+ @@ -146,7 +145,7 @@ def manual(dbname): if len(sys.argv)>5: reason=sys.argv[5] - pay(db, int(userid), email, balance, date, reason) + pay(db, int(userid), email, cash, date, reason) print 'New balance is '+str(balance+cash)+' EUR' return diff --git a/scripts/templates/register.mail.de b/scripts/templates/register.mail.eressea.de similarity index 85% rename from scripts/templates/register.mail.de rename to scripts/templates/register.mail.eressea.de index 875431e59..ec0866fb7 100644 --- a/scripts/templates/register.mail.de +++ b/scripts/templates/register.mail.eressea.de @@ -1,11 +1,11 @@ Hallo , -Du stehst mit deiner Anmeldung bei Eressea auf der Warteliste für neue Parteien +Du stehst mit deiner Anmeldung bei auf der Warteliste für neue Parteien derzeit an Position . Um Deine Anmeldung zu bestätigen, gehe bitte auf die folgende Webseite, und gib dort zur Bestätigung deine Kundennummer und den Bestätigungsschlüssel ein. - http://eressea-pbem.de/de/confirm.html + http://eressea-pbem.de/confirm.html Kundennummer: Schlüssel: diff --git a/scripts/templates/register.mail.en b/scripts/templates/register.mail.eressea.en similarity index 88% rename from scripts/templates/register.mail.en rename to scripts/templates/register.mail.eressea.en index 77e6a0b82..41759f740 100644 --- a/scripts/templates/register.mail.en +++ b/scripts/templates/register.mail.eressea.en @@ -1,6 +1,6 @@ Hello , -You are now entered into the waiting list of Eressea, at position . +You are now entered into the waiting list of , at position . To confirm your subscription, please go to the following URL and enter your Customer-ID and confirmation key. diff --git a/scripts/templates/register.mail.tutorial.de b/scripts/templates/register.mail.tutorial.de new file mode 100644 index 000000000..a81f63b99 --- /dev/null +++ b/scripts/templates/register.mail.tutorial.de @@ -0,0 +1,21 @@ +Hallo , + +Als bisher nicht registrierter Eressea-Spieler haben wir Dich zu einer 5 +Runden dauernden Schnupperpartie eingetragen. Dieses Tutorial gibt Dir die +Chance, deine Anfangsstrategie auszuprobieren und festzustellen, ob Du die +Regeln auch wirklich verstanden hast. + +Nachdem Du 5 Runden im Tutorial gespielt hast, werden wir deinen Account für +das richtige Eressea-Spiel freischalten. Das hat für alle Beteiligten auch +den Vorteil, das nur solche Spieler teilnehmen, die über Grundkenntnisse der +Regeln verfügen, und wissen, worum es bei Eressea geht. + +Um Deine Anmeldung zu bestätigen, gehe bitte auf die folgende Webseite, und +gib dort zur Bestätigung deine Kundennummer und den Bestätigungsschlüssel +ein. + + http://eressea-pbem.de/confirm.html + Kundennummer: + Schlüssel: + +Das Eressea-Team diff --git a/scripts/templates/register.mail.tutorial.en b/scripts/templates/register.mail.tutorial.en new file mode 100644 index 000000000..4e6f84b98 --- /dev/null +++ b/scripts/templates/register.mail.tutorial.en @@ -0,0 +1,19 @@ +Hello , + +as a new player, you have been entered into the Eressea tutorial game. By +letting you play the tutorial first, we're giving you the chance to test +your knowledge of the rules and exxperiment for a few turns befor the actual +game starts - consider this a way to test your initial strategy. Better to +make mistakes now than later, right? + +Once you finish 5 turns in this game (which will have a turn every 2 days), +your Account will be upgraded, allowing you to subscribe to Eressea. + +To confirm this subscription, please go to the following URL and enter your +new Customer-ID and confirmation key. + + http://eressea-pbem.de/en/confirm.html + Customer ID: + Key: + +The Eressea Team