.BANCHO. Set country to unknown for users with hidden country flag

This commit is contained in:
Nyo 2016-05-01 20:39:01 +02:00
parent 49b36e6acb
commit 82c9d2209b
2 changed files with 24 additions and 4 deletions

View File

@ -124,6 +124,12 @@ def handle(flaskRequest):
# Get location and country from ip.zxq.co or database # Get location and country from ip.zxq.co or database
if generalFunctions.stringToBool(glob.conf.config["server"]["localizeusers"]): if generalFunctions.stringToBool(glob.conf.config["server"]["localizeusers"]):
# 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 # Get location and country from IP
location = locationHelper.getLocation(requestIP) location = locationHelper.getLocation(requestIP)
countryLetters = locationHelper.getCountry(requestIP) countryLetters = locationHelper.getCountry(requestIP)
@ -132,6 +138,7 @@ def handle(flaskRequest):
# Set location to 0,0 and get country from db # Set location to 0,0 and get country from db
print("[!] Location skipped") print("[!] Location skipped")
location = [0,0] location = [0,0]
countryLetters = "XX"
country = countryHelper.getCountryID(userHelper.getCountry(userID)) country = countryHelper.getCountryID(userHelper.getCountry(userID))
# Set location and country # Set location and country

View File

@ -1,5 +1,6 @@
import passwordHelper import passwordHelper
import gameModes import gameModes
import generalFunctions
import glob import glob
def getID(username): def getID(username):
@ -284,3 +285,15 @@ def setCountry(userID, country):
country -- country letters country -- country letters
""" """
glob.db.execute("UPDATE users_stats SET country = ? WHERE id = ?", [country, userID]) 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)