Correction d'erreurs liées à l'utilisation de mysql

This commit is contained in:
guimoz 2017-01-31 17:40:16 +01:00
parent 81f7838d17
commit 583475d1b6
2 changed files with 10 additions and 12 deletions

View file

@ -73,7 +73,7 @@ def get_player(player_id):
cur = con.cursor()
cur.execute("""select id,firstname,name,ban_end from players
where id=%i"""% [player_id])
where id=%i"""% player_id)
row = cur.fetchone()
con.close()
@ -88,12 +88,11 @@ def get_player_from_ip(ip):
machines.id,machines.ip,players.ban_end
from players
inner join machines on players.id=machines.player_id
where machines.ip=%s"""% [ip])
where machines.ip=\"%s\""""% ip)
row = cur.fetchone()
con.close()
print("last good line")
user = None
if row is not None:
user = {'id': row[0], 'firstname': row[1], 'name': row[2], \
@ -125,7 +124,7 @@ def is_banned(user_id):
con = connect_sql()
cur = con.cursor()
cur.execute("""select ban_end from players where id=%i"""% [user_id])
cur.execute("""select ban_end from players where id=%i"""% user_id)
ban_end = cur.fetchone()[0]
con.close()
@ -153,7 +152,7 @@ def get_players_not_banned():
cur = con.cursor()
cur.execute("""select id,firstname,name from players
where %f > ban_end """% [time()])
where %f > ban_end """% time())
rows = cur.fetchall()
con.close()
@ -201,7 +200,7 @@ def ban(player_id, target_id, success):
cur = con.cursor()
cur.execute("""select id,ban_end from players
where id=%i"""% [banned_player['id']])
where id=%i"""% banned_player['id'])
con.commit()
con.close()
@ -310,7 +309,7 @@ def banned_ip():
cur.execute("""select machines.ip from players
inner join machines on players.id=machines.player_id
where players.ban_end>%f"""% [time()])
where players.ban_end>%f"""% time())
rows = cur.fetchall()
con.close()
@ -322,9 +321,8 @@ def banned_ip():
def home():
player = get_player_from_ip(get_ip())
if DEBUG:
print(STATE)
if DEBUG:
print(player, 'arrived')
print(player, 'arrived and the site is',STATE)
bans = sorted(get_bans(player['id']), \
key=lambda ban: ban['time'], \
reverse=True)
@ -394,7 +392,7 @@ def play():
elif "up" in STATE:
# Traitement de la requête de bannissement
if request.method == 'POST':
target_id = request.form['target_id']
target_id = int(request.form['target_id'])
if target_id != 'none':
if is_banned(target_id):
flash(u'Utilisateur déjà tranché, il faut en choisir un autre.')

2
state
View file

@ -1 +1 @@
up
down