.BANCHO. Set country to unknown for users with hidden country flag
This commit is contained in:
parent
49b36e6acb
commit
82c9d2209b
|
@ -124,14 +124,21 @@ 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"]):
|
||||||
# Get location and country from IP
|
# Make sure this user has not disabled his country flag
|
||||||
location = locationHelper.getLocation(requestIP)
|
if userHelper.getShowCountry(userID) == False:
|
||||||
countryLetters = locationHelper.getCountry(requestIP)
|
location = [0,0]
|
||||||
country = countryHelper.getCountryID(countryLetters)
|
countryLetters = "XX"
|
||||||
|
country = 0
|
||||||
|
else:
|
||||||
|
# Get location and country from IP
|
||||||
|
location = locationHelper.getLocation(requestIP)
|
||||||
|
countryLetters = locationHelper.getCountry(requestIP)
|
||||||
|
country = countryHelper.getCountryID(countryLetters)
|
||||||
else:
|
else:
|
||||||
# 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
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user