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(" '+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. "+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
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("