diff --git a/register_page.py b/register_page.py index d9226df..3af20d6 100644 --- a/register_page.py +++ b/register_page.py @@ -19,6 +19,7 @@ from twisted.web import server, resource from twisted.internet import reactor from twisted.internet.error import ReactorAlreadyRunning +import re import base64 import codecs import sqlite3 @@ -38,7 +39,7 @@ class RegPage(resource.Resource): def get_header(self, title = None): if not title: - title = 'Register a Console .:. BeanJrFi' + title = 'Register a Console' s = ( '' '
' @@ -46,7 +47,7 @@ class RegPage(resource.Resource): '' '' '' - 'Register a console for BeanJrFi' + 'Register a console' '
' ) return s @@ -63,12 +64,14 @@ class RegPage(resource.Resource): dbconn = sqlite3.connect('gpcm.db') macadr = request.args['macadr'][0].strip() actiontype = request.args['action'][0] - if not macadr.isalnum(): + macadr = macadr.lower() + if not re.match("[0-9a-f]{2}([-:])[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$", macadr): request.setResponseCode(500) - return "Bad data" + return "The MAC you entered was invalid. Please click the back button and try again!" + macadr = macadr.replace(":","").replace("-","") if actiontype == 'add': dbconn.cursor().execute('insert into pending values(?)',(macadr,)) - responsedata = "Added %s to pending list. Your application may take anywhere from 24 to 48 hours." % (macadr) + responsedata = "Added %s to pending list. Please close this window now. It's also not a bad idea to check back on the status of your activation by attempting to connect your console to the server." % (macadr) dbconn.commit() dbconn.close() request.setHeader("Content-Type", "text/html; charset=utf-8") @@ -86,7 +89,7 @@ class RegPage(resource.Resource): dbconn = sqlite3.connect('gpcm.db') responsedata = ("" "\r\n" "