forked from github/server
Umstellung des Anmeldesystems
This commit is contained in:
parent
a5e7481273
commit
c3cb5ba1cc
|
@ -15,6 +15,7 @@ HTMLTemplate = "eressea.html"
|
||||||
DefaultTitle = "Eressea Anmeldung"
|
DefaultTitle = "Eressea Anmeldung"
|
||||||
dbname = "eressea"
|
dbname = "eressea"
|
||||||
db=None
|
db=None
|
||||||
|
tutorial_id=1 # the tuorial game has id 1
|
||||||
|
|
||||||
# define a new function called Display
|
# define a new function called Display
|
||||||
# it takes one parameter - a string to Display
|
# it takes one parameter - a string to Display
|
||||||
|
@ -54,6 +55,9 @@ def genpasswd():
|
||||||
return newpasswd
|
return newpasswd
|
||||||
|
|
||||||
|
|
||||||
|
Display("Derzeit ist wegen einer technischen Umstellung keine Anmeldung möglich")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
Form = cgi.FieldStorage()
|
Form = cgi.FieldStorage()
|
||||||
|
|
||||||
custid=GetKey(Form, "custid")
|
custid=GetKey(Form, "custid")
|
||||||
|
@ -67,13 +71,21 @@ if (password==None) or (custid==None):
|
||||||
else:
|
else:
|
||||||
db=MySQLdb.connect(db=dbname)
|
db=MySQLdb.connect(db=dbname)
|
||||||
cursor=db.cursor()
|
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:
|
if exist==0:
|
||||||
Display('<p>Kundennummer oder Schlüssel falsch. Bitte beachte, dass Du beim Schlüssel auf Groß- und Kleinschreibung achten mußt.')
|
Display('<p>Kundennummer oder Schlüssel falsch. Bitte beachte, dass Du beim Schlüssel auf Groß- und Kleinschreibung achten mußt.')
|
||||||
else:
|
else:
|
||||||
|
status, sid, gid = cursor.fetchone()
|
||||||
if os.environ.has_key('REMOTE_ADDR'):
|
if os.environ.has_key('REMOTE_ADDR'):
|
||||||
ip=os.environ['REMOTE_ADDR']
|
ip=os.environ['REMOTE_ADDR']
|
||||||
cursor.execute("REPLACE userips (ip, user) VALUES ('"+ip+"', "+str(int(custid))+")")
|
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("<p>Deine Anmeldung wurde bestätigt.");
|
Display("<p>Deine Anmeldung wurde bestätigt.");
|
||||||
db.close()
|
db.close()
|
||||||
|
|
|
@ -22,6 +22,8 @@ From = "accounts@eressea-pbem.de"
|
||||||
locale="de"
|
locale="de"
|
||||||
smtpserver = 'localhost'
|
smtpserver = 'localhost'
|
||||||
db=None
|
db=None
|
||||||
|
game_id=0 # Eressea Main game
|
||||||
|
tutorial_id=None #
|
||||||
|
|
||||||
# define a new function called Display
|
# define a new function called Display
|
||||||
# it takes one parameter - a string to Display
|
# it takes one parameter - a string to Display
|
||||||
|
@ -45,8 +47,11 @@ def Display(Content, Title=DefaultTitle):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def Send(email, custid, firstname, password, position):
|
def Send(email, custid, sid, firstname, password, game):
|
||||||
TemplateHandle = open(MailTemplate+"."+locale, "r") # open in read only mode
|
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
|
# read the entire file as a string
|
||||||
TemplateInput = TemplateHandle.read()
|
TemplateInput = TemplateHandle.read()
|
||||||
TemplateHandle.close() # close the file
|
TemplateHandle.close() # close the file
|
||||||
|
@ -54,16 +59,16 @@ def Send(email, custid, firstname, password, position):
|
||||||
SubResult = re.subn("<FIRSTNAME>", firstname, TemplateInput)
|
SubResult = re.subn("<FIRSTNAME>", firstname, TemplateInput)
|
||||||
SubResult = re.subn("<PASSWORD>", password, SubResult[0])
|
SubResult = re.subn("<PASSWORD>", password, SubResult[0])
|
||||||
SubResult = re.subn("<POSITION>", str(int(position)), SubResult[0])
|
SubResult = re.subn("<POSITION>", str(int(position)), SubResult[0])
|
||||||
|
SubResult = re.subn("<GAME>", name, SubResult[0])
|
||||||
SubResult = re.subn("<CUSTID>", str(int(custid)), SubResult[0])
|
SubResult = re.subn("<CUSTID>", str(int(custid)), SubResult[0])
|
||||||
subject={"de":"Eressea Anmeldung","en":"Eressea Registration"}
|
subject={"de":"Anmeldung","en":"Registration"}
|
||||||
Msg="From: "+From+"\nTo: "+email+"\nSubject: "+subject[locale]+"\n\n"
|
Msg="From: "+From+"\nTo: "+email+"\nSubject: "+name+" "+subject[locale]+"\n\n"
|
||||||
Msg=Msg+SubResult[0]
|
Msg=Msg+SubResult[0]
|
||||||
server=smtplib.SMTP(smtpserver)
|
server=smtplib.SMTP(smtpserver)
|
||||||
server.sendmail(From, email, Msg)
|
server.sendmail(From, email, Msg)
|
||||||
server.close()
|
server.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def GetKey(Form, key):
|
def GetKey(Form, key):
|
||||||
if Form.has_key(key):
|
if Form.has_key(key):
|
||||||
value=Form[key].value
|
value=Form[key].value
|
||||||
|
@ -85,6 +90,8 @@ def genpasswd():
|
||||||
newpasswd = newpasswd + choice(chars)
|
newpasswd = newpasswd + choice(chars)
|
||||||
return newpasswd
|
return newpasswd
|
||||||
|
|
||||||
|
Display("Derzeit ist wegen einer technischen Umstellung keine Anmeldung möglich")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
Form = cgi.FieldStorage()
|
Form = cgi.FieldStorage()
|
||||||
|
|
||||||
|
@ -114,7 +121,8 @@ elif ValidEmail(email)==0:
|
||||||
else:
|
else:
|
||||||
db=MySQLdb.connect(db=dbname)
|
db=MySQLdb.connect(db=dbname)
|
||||||
cursor=db.cursor()
|
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:
|
if exist:
|
||||||
text={"de":"Du stehst bereits auf der Warteliste","en":"You are already on the waiting list"}
|
text={"de":"Du stehst bereits auf der Warteliste","en":"You are already on the waiting list"}
|
||||||
Display('<p>'+text[locale])
|
Display('<p>'+text[locale])
|
||||||
|
@ -128,9 +136,8 @@ else:
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
# create a new user record
|
# create a new user record
|
||||||
password=genpasswd()
|
fields = "firstname, lastname, locale, email, address, city"
|
||||||
fields = "firstname, lastname, locale, email, address, city, status, password"
|
values = "'"+firstname+"', '"+lastname+"', '"+locale+"', '"+email+"', '"+address+"', '"+city+"'"
|
||||||
values = "'"+firstname+"', '"+lastname+"', '"+locale+"', '"+email+"', '"+address+"', '"+city+"', 'WAITING', '"+password+"'"
|
|
||||||
if phone!=None:
|
if phone!=None:
|
||||||
fields=fields+", phone"
|
fields=fields+", phone"
|
||||||
values=values+", '"+phone+"'"
|
values=values+", '"+phone+"'"
|
||||||
|
@ -149,7 +156,24 @@ else:
|
||||||
values=values+", 1"
|
values=values+", 1"
|
||||||
else:
|
else:
|
||||||
values=values+", 0"
|
values=values+", 0"
|
||||||
cursor.execute("insert into users ("+fields+") VALUES ("+values+")")
|
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('<em>Dein Account ist gesperrt.</em><br>Bitte wende Dich an <a href="mailto:accounts@eressea-pbem.de">accounts@eressea-pbem.de</a> 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")
|
cursor.execute("SELECT LAST_INSERT_ID() from dual")
|
||||||
custid=cursor.fetchone()[0]
|
custid=cursor.fetchone()[0]
|
||||||
|
|
||||||
|
@ -161,18 +185,22 @@ else:
|
||||||
cursor.execute("REPLACE userips (ip, user) VALUES ('"+ip+"', "+str(int(custid))+")")
|
cursor.execute("REPLACE userips (ip, user) VALUES ('"+ip+"', "+str(int(custid))+")")
|
||||||
|
|
||||||
# add a subscription record
|
# add a subscription record
|
||||||
values="'PENDING', '"+genpasswd()+"'"
|
password = genpasswd()
|
||||||
|
values="'WAITING', '"+password+"'"
|
||||||
fields="status, password"
|
fields="status, password"
|
||||||
|
game = game_id
|
||||||
|
if tutorial_id!=None and status!='ACTIVE':
|
||||||
|
game=tutorial_id
|
||||||
if bonus!=None:
|
if bonus!=None:
|
||||||
fields=fields+", bonus"
|
fields=fields+", bonus"
|
||||||
if bonus=='yes':
|
if bonus=='yes':
|
||||||
values=values+", 1"
|
values=values+", 1"
|
||||||
else:
|
else:
|
||||||
values=values+", 0"
|
values=values+", 0"
|
||||||
cursor.execute("insert into subscriptions (user, race, game, "+fields+") VALUES ("+str(int(custid))+", '"+race+"', 0, "+values+")")
|
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")
|
||||||
cursor.execute("select count(*) from users where status='WAITING' or status='CONFIRMED'")
|
sid = cursor.fetchone()[0]
|
||||||
Send(email, custid, firstname, password, 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"}
|
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("<p>"+text[locale]+".")
|
Display("<p>"+text[locale]+".")
|
||||||
db.close()
|
db.close()
|
||||||
|
|
|
@ -2,19 +2,34 @@
|
||||||
|
|
||||||
import MySQLdb
|
import MySQLdb
|
||||||
import sys
|
import sys
|
||||||
|
import string
|
||||||
|
from whrandom import choice
|
||||||
|
|
||||||
dbname=sys.argv[1]
|
dbname=sys.argv[1]
|
||||||
maxnum=int(sys.argv[2])
|
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)
|
db=MySQLdb.connect(db=dbname)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
|
c = db.cursor()
|
||||||
num=cursor.execute(query)
|
num=cursor.execute(query)
|
||||||
if num>maxnum:
|
if num>maxnum:
|
||||||
num=maxnum
|
num=maxnum
|
||||||
while num:
|
while num:
|
||||||
num=num-1
|
num=num-1
|
||||||
email, password, race, locale, bonus = cursor.fetchone()
|
email, sid, password, race, locale, bonus = cursor.fetchone()
|
||||||
if bonus==None:
|
if bonus==None:
|
||||||
bonus=0
|
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
|
print email+" "+race+" "+locale+" "+str(int(bonus))+" "+password
|
||||||
|
|
|
@ -27,7 +27,6 @@ def pay(db, userid, email, cash, date, reason='PAYMENT'):
|
||||||
balance=cursor.fetchone()[0]
|
balance=cursor.fetchone()[0]
|
||||||
if balance==None:
|
if balance==None:
|
||||||
balance=0.0
|
balance=0.0
|
||||||
|
|
||||||
Msg = ("From: Vinyambar Buchhaltung <"+From+">\nTo: "+email+"\nSubject: Vinyambar Zahlungseingang.\n\n"+
|
Msg = ("From: Vinyambar Buchhaltung <"+From+">\nTo: "+email+"\nSubject: Vinyambar Zahlungseingang.\n\n"+
|
||||||
"Kundennummer: "+str(userid)+"\n"+
|
"Kundennummer: "+str(userid)+"\n"+
|
||||||
"Eingangsdatum: "+date+"\n"+
|
"Eingangsdatum: "+date+"\n"+
|
||||||
|
@ -146,7 +145,7 @@ def manual(dbname):
|
||||||
if len(sys.argv)>5:
|
if len(sys.argv)>5:
|
||||||
reason=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'
|
print 'New balance is '+str(balance+cash)+' EUR'
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
Hallo <FIRSTNAME>,
|
Hallo <FIRSTNAME>,
|
||||||
|
|
||||||
Du stehst mit deiner Anmeldung bei Eressea auf der Warteliste für neue Parteien
|
Du stehst mit deiner Anmeldung bei <GAME> auf der Warteliste für neue Parteien
|
||||||
derzeit an Position <POSITION>. Um Deine Anmeldung zu bestätigen, gehe bitte
|
derzeit an Position <POSITION>. Um Deine Anmeldung zu bestätigen, gehe bitte
|
||||||
auf die folgende Webseite, und gib dort zur Bestätigung deine Kundennummer
|
auf die folgende Webseite, und gib dort zur Bestätigung deine Kundennummer
|
||||||
und den Bestätigungsschlüssel ein.
|
und den Bestätigungsschlüssel ein.
|
||||||
|
|
||||||
http://eressea-pbem.de/de/confirm.html
|
http://eressea-pbem.de/confirm.html
|
||||||
Kundennummer: <CUSTID>
|
Kundennummer: <CUSTID>
|
||||||
Schlüssel: <PASSWORD>
|
Schlüssel: <PASSWORD>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Hello <FIRSTNAME>,
|
Hello <FIRSTNAME>,
|
||||||
|
|
||||||
You are now entered into the waiting list of Eressea, at position <POSITION>.
|
You are now entered into the waiting list of <GAME>, at position <POSITION>.
|
||||||
To confirm your subscription, please go to the following URL and enter your
|
To confirm your subscription, please go to the following URL and enter your
|
||||||
Customer-ID and confirmation key.
|
Customer-ID and confirmation key.
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
Hallo <FIRSTNAME>,
|
||||||
|
|
||||||
|
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: <CUSTID>
|
||||||
|
Schlüssel: <PASSWORD>
|
||||||
|
|
||||||
|
Das Eressea-Team
|
|
@ -0,0 +1,19 @@
|
||||||
|
Hello <FIRSTNAME>,
|
||||||
|
|
||||||
|
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: <CUSTID>
|
||||||
|
Key: <PASSWORD>
|
||||||
|
|
||||||
|
The Eressea Team
|
Loading…
Reference in New Issue