scriptänderungen

This commit is contained in:
Enno Rehling 2002-03-02 03:59:40 +00:00
parent 54b84bf78d
commit 4b1bc8f73d
2 changed files with 64 additions and 31 deletions

View File

@ -54,6 +54,16 @@ matchemail=re.compile(
re.IGNORECASE | re.DOTALL | re.VERBOSE)
email=None
matchuserid=re.compile(
r""".*userid:\s*([^\n\r]*)\s*""",
re.IGNORECASE | re.DOTALL | re.VERBOSE)
userid=None
matchpassword=re.compile(
r""".*passwort:\s*([^\n\r]*)\s*""",
re.IGNORECASE | re.DOTALL | re.VERBOSE)
password=None
matchaddress=re.compile(
r""".*adresse:\s*([^\n\r]*)\s*""",
re.IGNORECASE | re.DOTALL | re.VERBOSE)
@ -90,7 +100,7 @@ matchstandin=re.compile(
standin=0
matchwaiting=re.compile(
r""".*Warteliste: on\s(on)\s*""",
r""".*Warteliste:\s(on)\s*""",
re.IGNORECASE | re.DOTALL | re.VERBOSE)
waiting=0
@ -117,6 +127,15 @@ for line in sys.stdin.readlines():
email=match.group(1)
continue
match=matchuserid.match(line)
if (match!=None):
userid=match.group(1)
continue
match=matchpassword.match(line)
if (match!=None):
password=match.group(1)
continue
match=matchfirstname.match(line)
if (match!=None):
firstname=match.group(1)
@ -149,46 +168,60 @@ for line in sys.stdin.readlines():
oldrace=validrace(oldrace)
newrace=validrace(newrace)
if (email==None):
okay=0
if (password!=None) & (userid!=None):
query="select id from users where password='" + password + "' and id="+str(userid)
cursor=db.cursor()
num=cursor.execute(query)
if num==1:
okay=1
else:
if email==None:
email="enno@eressea.upb.de"
error(email, "Das Passwort für Kundennummer "+str(userid)+" war nicht korrekt.")
else:
if email==None:
error("enno@eressea.upb.de",
"Es wurde keine Emailadresse angegeben: "+firstname+" "+lastname)
elif (oldrace==None) & (newrace==None) & (standin==0) & (waiting==0):
elif (oldrace==None) & (newrace==None) & (standin==0) & (waiting==0):
error(email, "Es wurde kein Spiel ausgewählt.")
elif (firstname==None):
elif (firstname==None):
error(email, "Es wurde kein Vorname angegeben")
elif (lastname==None):
elif (lastname==None):
error(email, "Es wurde kein Nachname angegeben")
elif (address==None):
elif (address==None):
error(email, "Es wurde keine Adresse angegeben")
elif (city==None):
elif (city==None):
error(email, "Es wurde kein Wohnort angegeben")
elif (country==None):
elif (country==None):
error(email, "Es wurde kein Land angegeben")
else:
else:
if (phone==None):
phone = "NULL"
okay=1
cursor=db.cursor()
cursor.execute("INSERT INTO users (firstname, lastname, email, address, city, phone, country, password) "+
"VALUES ('"+firstname+"', '"+lastname+"', '"+email+"', '"+address+"', '"+city+"', '"+phone+"', "+country+", '"+genpasswd()+"')")
cursor.execute("SELECT LAST_INSERT_ID() from dual")
lastid=str(int(cursor.fetchone()[0]))
userid=str(int(cursor.fetchone()[0]))
if okay:
if (oldrace!=None):
error(email, "Derzeit wird kein Spiel nach alten Regeln angeboten")
# cursor.execute("INSERT INTO subscriptions (user, race, game) "+
# "VALUES ("+lastid+", '"+oldrace+"', 1)")
# "VALUES ("+str(userid)+", '"+oldrace+"', 1)")
if (newrace!=None):
error(email, "Derzeit wird kein Spiel nach neuen Regeln angeboten")
# cursor.execute("INSERT INTO subscriptions (user, race, game, status) "+
# "VALUES ("+lastid+", '"+newrace+"', 2, 'WAITING')")
# "VALUES ("+str(userid)+", '"+newrace+"', 2, 'WAITING')")
if waiting:
cursor.execute("INSERT INTO subscriptions (user, game, status) "+
"VALUES ("+lastid+", 3, 'WAITING')")
"VALUES ("+str(userid)+", 3, 'WAITING')")
if standin:
cursor.execute("INSERT INTO subscriptions (user, game, status) "+
"VALUES ("+lastid+", 4, 'WAITING')")
"VALUES ("+str(userid)+", 4, 'WAITING')")
errors.close()
unlock(sys.argv[1]+".err")

View File

@ -5,9 +5,9 @@ select u.id ID, left(concat(firstname,' ',lastname, ' <',email,'>'),43) Name, su
GROUP BY u.id
HAVING SUM(t.balance)<2.5;
select count(users.status) Anzahl, users.status Status, games.name Spiel
select count(users.status) Anzahl, subscriptions.status Status, games.name Spiel
from users, games, subscriptions
where games.id = subscriptions.game
and users.id = subscriptions.user
group by games.name, users.status
group by games.name, subscriptions.status
order by subscriptions.game;