From 918c90584dafea391343b85483576ceb70446f25 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 19 Mar 2002 22:33:45 +0000 Subject: [PATCH] registration in english (partially) --- scripts/cgi-bin/eressea-confirm.py | 4 ++ scripts/cgi-bin/eressea-register.py | 39 ++++++++++++++++--- .../{register.mail => register.mail.de} | 0 scripts/cgi-bin/register.mail.en | 20 ++++++++++ 4 files changed, 57 insertions(+), 6 deletions(-) rename scripts/cgi-bin/{register.mail => register.mail.de} (100%) create mode 100644 scripts/cgi-bin/register.mail.en diff --git a/scripts/cgi-bin/eressea-confirm.py b/scripts/cgi-bin/eressea-confirm.py index 8f55c133c..1fd80a123 100755 --- a/scripts/cgi-bin/eressea-confirm.py +++ b/scripts/cgi-bin/eressea-confirm.py @@ -3,6 +3,7 @@ import sys import MySQLdb import cgi +import os import re # specify the filename of the template file @@ -67,6 +68,9 @@ else: if exist==0: Display('

Kundennummer oder Schlüssel falsch. Bitte beachte, dass Du beim Schlüssel auf Groß- und Kleinschreibung achten mußt.') else: + 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) 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 a599c8bec..bc3860352 100755 --- a/scripts/cgi-bin/eressea-register.py +++ b/scripts/cgi-bin/eressea-register.py @@ -2,6 +2,7 @@ import sys import MySQLdb +import os import cgi import re import string @@ -15,6 +16,7 @@ MailTemplate="register.mail" DefaultTitle = "Eressea Anmeldung" dbname = "eressea" From = "accounts@eressea-pbem.de" +locale="de" smtpserver = 'localhost' db=None @@ -41,7 +43,7 @@ def Display(Content, Title=DefaultTitle): def Send(email, custid, firstname, password, position): - TemplateHandle = open(MailTemplate, "r") # open in read only mode + TemplateHandle = open(MailTemplate+"."+locale, "r") # open in read only mode # read the entire file as a string TemplateInput = TemplateHandle.read() TemplateHandle.close() # close the file @@ -51,7 +53,7 @@ def Send(email, custid, firstname, password, position): SubResult = re.subn("", str(int(position)), SubResult[0]) SubResult = re.subn("", str(int(custid)), SubResult[0]) - Msg="From: "+From+"\nTo: "+email+"\nSubject: Vinambar Passwort\n\n" + Msg="From: "+From+"\nTo: "+email+"\nSubject: Eressea Anmeldung\n\n" Msg=Msg+SubResult[0] server=smtplib.SMTP(smtpserver) server.sendmail(From, email, Msg) @@ -66,6 +68,12 @@ def GetKey(Form, key): return value return None +def ValidEmail(email): + if string.find(email, "@")==-1: + return 0 + elif string.find(email, " ")!=-1: + return 0 + return 1 def genpasswd(): newpasswd="" @@ -86,11 +94,18 @@ city=GetKey(Form, "city") country=GetKey(Form, "country") phone=GetKey(Form, "phone") race=GetKey(Form, "race") +locale=GetKey(Form, "locale") -if (lastname==None) or (race==None) or (firstname==None) or (address==None) or (city==None): +referrer=GetKey(Form, "referrer") +firsttime=GetKey(Form, "firsttime") + +if (locale==None) or (lastname==None) or (race==None) or (firstname==None) or (address==None) or (city==None): output="

Um Dich zu Eressea anzumelden musst Du das Formular vollständig ausfüllen.\n " for key in Form.keys(): - output=output+"
"+str(key)+"="+str(Form[key]) + output=output+"
"+key+": "+Form[key].value+"\n" + Display(output) +elif ValidEmail(email)==0: + output="

Um Dich zu Eressea anzumelden musst Du eine gültige Email-Adresse angeben.\n " Display(output) else: db=MySQLdb.connect(db=dbname) @@ -100,8 +115,8 @@ else: Display('

Du stehst bereits auf der Warteliste') else: password=genpasswd() - fields = "firstname, lastname, email, address, city, status, password" - values = "'"+firstname+"', '"+lastname+"', '"+email+"', '"+address+"', '"+city+"', 'WAITING', '"+password+"'" + fields = "firstname, lastname, locale, email, address, city, status, password" + values = "'"+firstname+"', '"+lastname+"', '"+locale+"', '"+email+"', '"+address+"', '"+city+"', 'WAITING', '"+password+"'" if phone!=None: fields=fields+", phone" values=values+", '"+phone+"'" @@ -111,9 +126,21 @@ else: if country!=None: fields=fields+", country" values=values+", "+country+"" + if referrer!=None: + fields=fields+", referrer" + values=values+", '"+referrer+"'" + if firsttime!=None: + fields=fields+", firsttime" + if firsttime=='yes': + 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] + 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("insert into subscriptions (user, race, game, status) VALUES ("+str(int(custid))+", '"+race+"', 0, 'PENDING')") cursor.execute("select count(*) from users") Send(email, custid, firstname, password, cursor.fetchone()[0]) diff --git a/scripts/cgi-bin/register.mail b/scripts/cgi-bin/register.mail.de similarity index 100% rename from scripts/cgi-bin/register.mail rename to scripts/cgi-bin/register.mail.de diff --git a/scripts/cgi-bin/register.mail.en b/scripts/cgi-bin/register.mail.en new file mode 100644 index 000000000..77e6a0b82 --- /dev/null +++ b/scripts/cgi-bin/register.mail.en @@ -0,0 +1,20 @@ +Hello , + +You are now entered into the waiting list of Eressea, at position . +To confirm your subscription, please go to the following URL and enter your +Customer-ID and confirmation key. + + http://eressea-pbem.de/en/confirm.html + Customer ID: + Key: + +To make sure that only those players interested in playing remain on the +list, you need to repeat this procedure once every week. We will send you this +reminder by mail, in which you'll also see your updated position on the +waiting list. + +If you do not enter the key before sunday morning 9:00 CET, your +registration will be considered cancelled, and you will receive no further +email from us. + +The Eressea Team