def banned_player_map(request): from common.utils.geoip import GeoLocation from common.cache.file import FileCache local = FileCache("ban-%s" % request.server, getattr(settings, 'WORLDMAP_CACHE_EXPIRE', 1440)) countries = local.load() if not countries: countries = {} geo = GeoLocation() for penalty in Penalty.objects.db_manager(request.server).active(): country_name = geo.get_country(penalty.client.ip) if countries.has_key(country_name): count = countries.get(country_name) + 1 else: count = 1 countries[country_name]=count if len(countries) > 0: local.save(countries) return {'list': countries}
def player_map(request): from common.utils.geoip import GeoLocation from common.cache.file import FileCache local = FileCache("pl-%s" % request.server, getattr(settings, 'WORLDMAP_CACHE_EXPIRE', 1440)) countries = local.load() if not countries: countries = {} geo = GeoLocation() for client in Client.objects.using(request.server).filter(id__gt=1): country_name = geo.get_country(client.ip) if country_name != '': #country_code = geo.get_country_code(client.ip) if countries.has_key(country_name): countries[country_name]['count'] += 1 #countries[country_name]['clients'].append(client) else: countries[country_name] = {'count': 1 } #, 'clients': [client]} if len(countries) > 0: local.save(countries) return {'list': countries}