From 82c9d2209b948edc587b09ace82ef4441820d4ab Mon Sep 17 00:00:00 2001 From: Nyo Date: Sun, 1 May 2016 20:39:01 +0200 Subject: [PATCH] .BANCHO. Set country to unknown for users with hidden country flag --- loginEvent.py | 15 +++++++++++---- userHelper.py | 13 +++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/loginEvent.py b/loginEvent.py index 101252b..33110df 100644 --- a/loginEvent.py +++ b/loginEvent.py @@ -124,14 +124,21 @@ def handle(flaskRequest): # Get location and country from ip.zxq.co or database if generalFunctions.stringToBool(glob.conf.config["server"]["localizeusers"]): - # Get location and country from IP - location = locationHelper.getLocation(requestIP) - countryLetters = locationHelper.getCountry(requestIP) - country = countryHelper.getCountryID(countryLetters) + # Make sure this user has not disabled his country flag + if userHelper.getShowCountry(userID) == False: + location = [0,0] + countryLetters = "XX" + country = 0 + else: + # Get location and country from IP + location = locationHelper.getLocation(requestIP) + countryLetters = locationHelper.getCountry(requestIP) + country = countryHelper.getCountryID(countryLetters) else: # Set location to 0,0 and get country from db print("[!] Location skipped") location = [0,0] + countryLetters = "XX" country = countryHelper.getCountryID(userHelper.getCountry(userID)) # Set location and country diff --git a/userHelper.py b/userHelper.py index 6a4a756..23bf85a 100644 --- a/userHelper.py +++ b/userHelper.py @@ -1,5 +1,6 @@ import passwordHelper import gameModes +import generalFunctions import glob def getID(username): @@ -284,3 +285,15 @@ def setCountry(userID, country): country -- country letters """ glob.db.execute("UPDATE users_stats SET country = ? WHERE id = ?", [country, userID]) + +def getShowCountry(userID): + """ + Get userID's show country status + + userID -- userID + return -- True if country is shown, False if it's hidden + """ + country = glob.db.fetch("SELECT show_country FROM users_stats WHERE id = ?", [userID]) + if country == None: + return False + return generalFunctions.stringToBool(country)