From 583475d1b68a374dc32fecfd263b8e8df61ee415 Mon Sep 17 00:00:00 2001 From: guimoz Date: Tue, 31 Jan 2017 17:40:16 +0100 Subject: [PATCH] =?UTF-8?q?Correction=20d'erreurs=20li=C3=A9es=20=C3=A0=20?= =?UTF-8?q?l'utilisation=20de=20mysql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roulette.py | 20 +++++++++----------- state | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/roulette.py b/roulette.py index 90a4b25..280397e 100644 --- a/roulette.py +++ b/roulette.py @@ -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.') diff --git a/state b/state index e31ee94..eb0e904 100644 --- a/state +++ b/state @@ -1 +1 @@ -up +down