diff --git a/roulette.py b/roulette.py index 1103f49..6bd61b1 100644 --- a/roulette.py +++ b/roulette.py @@ -6,7 +6,7 @@ from flask import Flask, request, g, redirect, url_for, \ from functools import wraps from contextlib import closing import sqlite3 -import MySQLdb as mdb +import MySQLdb from time import time, localtime, strftime import locale import random @@ -70,7 +70,7 @@ def get_ip(): def get_player(player_id): con = connect_sql() - cur = db.cursor() + cur = con.cursor() cur.execute("""select id,firstname,name,ban_end from players where id=(?)""", [player_id]) @@ -82,7 +82,7 @@ def get_player(player_id): def get_player_from_ip(ip): con = connect_sql() - cur = db.cursor() + cur = con.cursor() cur.execute("""select players.id,players.firstname,players.name, machines.id,machines.ip,players.ban_end @@ -103,7 +103,7 @@ def get_player_from_ip(ip): def get_player_from_full_name(firstname, name): con = connect_sql() - cur = db.cursor() + cur = con.cursor() cur.execute("""select players.id,players.firstname,players.name, machines.id,machines.ip,players.ban_end @@ -123,7 +123,7 @@ def get_player_from_full_name(firstname, name): def is_banned(user_id): con = connect_sql() - cur = db.cursor() + cur = con.cursor() cur.execute("""select ban_end from players where id=(?)""", [user_id]) @@ -150,7 +150,7 @@ def playable_required(f): def get_players_not_banned(): con = connect_sql() - cur = db.cursor() + cur = con.cursor() cur.execute("""select id,firstname,name from players where (?) > ban_end """, [time()]) @@ -198,7 +198,7 @@ def ban(player_id, target_id, success): banned_player = success and target or player con = connect_sql() - cur = db.cursor() + cur = con.cursor() cur.execute("""select id,ban_end from players where id=(?)""", [banned_player['id']]) @@ -206,7 +206,7 @@ def ban(player_id, target_id, success): con.commit() con.close() con = connect_sql() - cur = db.cursor() + cur = con.cursor() ban_end = cur.fetchone()[0] ban_end = time() + BAN_DURATION @@ -218,7 +218,7 @@ def ban(player_id, target_id, success): con.commit() con.close() con = connect_sql() - cur = db.cursor() + cur = con.cursor() cur.execute("""insert into bans (player_id,target_id,success,time) values (?,?,?,?)""", [player['id'], target['id'], \ success and 1 or 0, time()]) @@ -228,7 +228,7 @@ def ban(player_id, target_id, success): def unban(player_id): con = connect_sql() - cur = db.cursor() + cur = con.cursor() cur.execute("""update players set ban_end=(?) where id=(?)""", [time() - BAN_DURATION, player_id]) @@ -238,7 +238,7 @@ def unban(player_id): def get_bans(player_id): con = connect_sql() - cur = db.cursor() + cur = con.cursor() # Bannissements concernant le joueur : cur.execute("""select player_id,target_id,success,time from bans @@ -273,7 +273,7 @@ def banned(): def statistiques(): #Calcul des statistiques con = connect_sql() - cur = db.cursor() + cur = con.cursor() cur.execute("""select firstname,name,ban_end from players""") @@ -308,7 +308,7 @@ def banned_ip(): abort(403) con = connect_sql() - cur = db.cursor() + cur = con.cursor() cur.execute("""select machines.ip from players inner join machines on players.id=machines.player_id