diff --git a/admin_page_server.py b/admin_page_server.py index 6ab53db..414d158 100644 --- a/admin_page_server.py +++ b/admin_page_server.py @@ -81,8 +81,8 @@ class AdminPage(resource.Resource): '' '
' '' - 'Blacklist ' - 'Whitelist ' + 'All Users | ' + 'Active Bans ' '
' ) return s @@ -114,56 +114,47 @@ class AdminPage(resource.Resource): request.write(error_message) return is_auth - def update_whitelist(self, request): + def update_banlist(self, request): address = request.getClientIP() dbconn = sqlite3.connect('gpcm.db') - userid = request.args['userid'][0].strip() gameid = request.args['gameid'][0].upper().strip() - macadr = request.args['macadr'][0].strip() - actiontype = request.args['actiontype'][0] - if not userid.isdigit() or not gameid.isalnum() or not macadr.isalnum(): + ipaddr = request.args['ipaddr'][0].strip() + actiontype = request.args['action'][0] + if not gameid.isalnum(): request.setResponseCode(500) - logger.log(logging.INFO,address+" Bad data "+userid+" "+gameid+" "+macadr) + logger.log(logging.INFO,address+" Bad data "+gameid+" "+ipaddr) return "Bad data" - if actiontype == 'add': - dbconn.cursor().execute('insert into whitelist values(?,?,?)',(userid,gameid,macadr)) - responsedata = "Added macadr=%s for gameid=%s, userid=%s" % (macadr,gameid,userid) + if actiontype == 'ban': + dbconn.cursor().execute('insert into banned values(?,?)',(gameid[:-1],ipaddr)) + responsedata = "Added gameid=%s, ipaddr=%s" % (gameid[:-1],ipaddr) else: - dbconn.cursor().execute('delete from whitelist where userid=? and gameid=? and macadr=?',(userid,gameid,macadr)) - responsedata = "Removed macadr=%s for gameid=%s, userid=%s" % (macadr,gameid,userid) + dbconn.cursor().execute('delete from banned where gameid=? and ipaddr=?',(gameid[:-1],ipaddr)) + responsedata = "Removed gameid=%s, ipaddr=%s" % (gameid[:-1],ipaddr) dbconn.commit() dbconn.close() logger.log(logging.INFO,address+" "+responsedata) request.setHeader("Content-Type", "text/html; charset=utf-8") - request.setHeader("Location", "/whitelist") + request.setHeader("Location", "/banhammer") request.setResponseCode(303) return responsedata - def render_whitelist(self, request): + def render_banlist(self, request): address = request.getClientIP() dbconn = sqlite3.connect('gpcm.db') - logger.log(logging.INFO,address+" Viewed whitelist") + logger.log(logging.INFO,address+" Viewed banlist") responsedata = ("" '[CLICK HERE TO LOG OUT]' - "\r\n" "| userid | gameid | macadr | |
| "+userid+" | "+gameid+" | "+macadr+" | " - "
| ingamesn or devname | gameid | " "Enabled | newest dwc_pid | " - "gsbrcd | userid | IP | gsbrcd | userid | ipAddr | \r\n") for row in dbconn.cursor().execute(sqlstatement): dwc_pid = str(row[0]) enabled = str(row[1]) @@ -204,7 +198,7 @@ class AdminPage(resource.Resource): is_console = int(str(row[4])) userid = str(row[5]) gsbrcd = str(nasdata['gsbrcd']) - ipaddr = str (nasdata['ipaddr']) + ipaddr = str(nasdata['ipaddr']) ingamesn = '' if 'ingamesn' in nasdata: ingamesn = str(nasdata['ingamesn']) @@ -226,20 +220,18 @@ class AdminPage(resource.Resource): responsedata += ""+gsbrcd+" | " responsedata += ""+userid+" | " responsedata += ""+ipaddr+" | " - if enabled == "1": - responsedata += (" | ")
- else:
- responsedata += (" | ")
+ else:
+ responsedata += (" | ")
responsedata += " |