Ejemplo n.º 1
0
class LoginHandler(webapp.RequestHandler):
    def get(self):
        doRender(self, 'loginscreen.htm')

    def post(self):
        self.session = Session()
        un = self.request.get('username')
        pw = self.request.get('password')

        self.session.delete_item('username')
        self.session.delete_item('userkey')

        if pw == '' or un == '':
            doRender(self, 'loginscreen.html',
                     {'error': 'Please specify Username and Password'})
            return

        que = db.Query(User)
        que = que.filter('username ='******'password ='******'userkey'] = user.key()
            self.session['username'] = un
            doRender(self, 'main.html',
                     {})  # if ok, go to main.html (logged in)
        else:
            doRender(self, 'loginscreen.html',
                     {'error': 'Username or Password wrong'})
Ejemplo n.º 2
0
class LoginHandler(webapp.RequestHandler):
    def get(self):
        self.session = Session()
        doRender(self, 'loginscreen.html')

    def post(self):
        self.session = Session()
        acct = self.request.get('account')
        pw = self.request.get('password')
        #logging.info('Checking account='+acct+' pw='+pw)
        
        self.session.delete_item('username')
        self.session.delete_item('userkey')
        
        if pw == '' or acct == '':
            doRender(self, 'loginscreen.html', {'error' : 'Please specify Acct and PW'} )
            return
        
        # Check to see if our data is correct
        que = db.Query(User)
        que = que.filter('account =',acct)
        que = que.filter('password = '******'userkey'] = user.key()
            self.session['username'] = acct
            doRender(self,'index.html',{ } )
        else:
            doRender(self,'loginscreen.html',{'error' : 'Incorrect password'} )
Ejemplo n.º 3
0
class LogoutHandler(webapp.RequestHandler):
    def get(self):
        self.session = Session()
        un = self.session.get('username')
        self.session.delete_item('username')
        self.session.delete_item('userkey')
        doRender(self, 'index.html', {'msg': un + ' logout successful.'})
Ejemplo n.º 4
0
class LoginHandler(webapp2.RequestHandler):

  def get(self):
    doRender(self, 'login.html')
    
  def post(self):
    self.session = Session()
    acct = self.request.get('account')
    pw = self.request.get('password')
    logging.info('Checking account='+acct+' pw='+pw)

    # Make sure no other user is login
    self.session.delete_item('username')
    self.session.delete_item('userkey')    
    
    # Still no sender or transporter
    self.session['senderflag'] = False
    self.session['transporterflag'] = False
    
    # Check if there is a registered user
    que = db.Query(User)
    que = que.filter('account =',acct)
    que = que.filter('password = '******'userkey'] = user.key()
      self.session['username'] = acct
      doRender(self,'StartPage.html',{ } )

    else:
      doRender(self,'login.html', {'error' : 'Please fill in the correct details!'})
Ejemplo n.º 5
0
class LogoutHandler(webapp.RequestHandler):
    def get(self):
        self.session = Session()
        un = self.session.get('username')
        self.session.delete_item('username')
        self.session.delete_item('userkey')
        doRender(self, 'index.html', {'msg' : un + ' logout successful.'} ) 
Ejemplo n.º 6
0
class LoginHandler(webapp.RequestHandler):
    def get(self):
        doRender(self, "loginscreen.htm")

    def post(self):
        self.session = Session()
        acct = self.request.get("account")
        pw = self.request.get("password")
        logging.info("Checking account=" + acct + " pw=" + pw)

        self.session.delete_item("username")
        self.session.delete_item("userkey")

        if pw == "" or acct == "":
            doRender(self, "loginscreen.htm", {"error": "Please specify Account and Password"})
            return

        que = db.Query(User)
        que = que.filter("account =", acct)
        que = que.filter("password = "******"userkey"] = user.key()
            self.session["username"] = acct
            doRender(self, "index.htm", {})
        else:
            doRender(self, "loginscreen.htm", {"error": "Incorrect password"})
Ejemplo n.º 7
0
class TransHandler(webapp.RequestHandler):
    def post(self):
        self.session = Session()
        mode = self.session.get("mode")
        msg = self.session.get("msg")

        txtinput = self.request.get('method')

        if (txtinput == 't'):
            txtinput = "You have chosen Transposition cipher. Your mode is " + mode + " and your message is " + msg + ". Please enter a key(1<= key <= length of your message) (ex: tkey-3)"
        elif (txtinput == 'key'):
            key = int(self.request.get("keystr"))
            maxlen = len(msg)
            trans = transposition.TranspositionCipherTool(mode, msg, maxlen)
            keynum = trans.display()
            if (key >= 1 and key <= int(maxlen)):
                trans.storekey(key)
                translated = trans.getTranslatedMessage()
                txtinput = "Your translated message is " + translated
            else:
                self.session.delete_item("msg")
                txtinput = "Your key is not valid. Please re-enter a new message( ex: tmsg-{'This is message'})"
        elif (txtinput == 'tmsg'):
            msg = self.request.get("keystr")
            self.session['msg'] = msg
            txtinput = "Please enter a key(1<= key <= length of your message) (ex: tkey-3)"

        array = {'text': txtinput}

        # Output the JSON
        self.response.headers['Content-Type'] = 'application/json'
        self.response.out.write(json.dumps(array))
Ejemplo n.º 8
0
class LogoutHandler(webapp.RequestHandler):

	def get(self):
		self.session = Session()
		self.session.delete_item('username')
		self.session.delete_item('user_key')
		doRender(self, 'index.htm')
Ejemplo n.º 9
0
class LogoutHandler(webapp.RequestHandler):

  def get(self):
    self.session = Session()
    self.session.delete_item('username')
    self.session.delete_item('userkey')
    doRender(self, 'index.htm')
Ejemplo n.º 10
0
class LogOutHandler(webapp.RequestHandler):

    def get(self):
        
        self.session = Session()
        self.session.delete_item('user')
        self.redirect('main.html')
Ejemplo n.º 11
0
class GameloadHandler(webapp.RequestHandler):
    def get(self):
        self.session = Session()
        start_msg = ""
        gid = self.request.get("gid")

        self.session['game_id'] = gid
        #get current level for game id
        result_game = (db.GqlQuery("SELECT * FROM GameDB WHERE game_id = :1",
                                   gid)).get()
        glevel = result_game.current_level
        if (glevel):
            start_msg = "START THE GAME"
        #level=self.request.get("level")
        if (self.session.get('level')):
            self.session.delete_item('level')
        self.session['level'] = glevel

        temp = os.path.join(os.path.dirname(__file__),
                            'templates/gameload.html')
        self.response.headers['Content-Type'] = 'text/html'
        self.response.out.write(
            str(
                template.render(temp, {
                    "start_msg": start_msg,
                    "level": glevel
                })))
Ejemplo n.º 12
0
class LoginHandler(webapp.RequestHandler):

  def get(self):
    doRender(self, 'loginscreen.htm')

  def post(self):
    self.session = Session()
    acct = self.request.get('account')
    pw = self.request.get('password')
    logging.info('Checking account='+acct+' pw='+pw)

    self.session.delete_item('username')

    if pw == '' or acct == '':
      doRender(
          self,
          'loginscreen.htm',
          {'error' : 'Please specify Account and Password'} )
      return

    que = db.Query(User)
    que = que.filter('account =',acct)
    que = que.filter('password = '******'username'] = acct
      doRender(self,'index.htm',{ } )
    else:
      doRender(
          self,
          'loginscreen.htm',
          {'error' : 'Incorrect password'} )
Ejemplo n.º 13
0
class logout(webapp.RequestHandler):
    def get(self):
        self.session = Session()
        self.session.delete_item('username')
        render(self,"logout.html")
        
    def post(self):
        render()
Ejemplo n.º 14
0
class LogoutHandler(webapp.RequestHandler):
    def get(self):
        self.session = Session()
        if 'username' in self.session:
            del self.session['username']
        self.session.delete_item('username')
        self.session.delete_item('userkey')
        doRender(self, '/index.html')
class LogoutHandler(webapp.RequestHandler):
    def get(self):
        self.session=Session()
        self.session.delete_item('username')
        self.session.delete_item('ft_client')
        path=self.request.path
        temp=os.path.join(os.path.dirname(__file__),'templates/index.html')
        html=template.render(temp,{'path':path})
        self.response.out.write(html)
Ejemplo n.º 16
0
class ExitHandler(webapp.RequestHandler):
    def get(self):
        self.session = Session()
        self.session.delete_item('username')
        self.session.delete_item('role')
        self.session.delete_item('tid')
        self.session.delete_item('level')
        self.session.delete_item('game_id')

        msg = "Thank you for playing. Bye!"

        temp = os.path.join(os.path.dirname(__file__), 'templates/logout.html')

        self.response.headers['Content-Type'] = 'text/html'
        self.response.out.write(str(template.render(temp, {"logoutmsg": msg})))
Ejemplo n.º 17
0
class ExitHandler(webapp.RequestHandler):
    def get(self):
	self.session=Session()
	self.session.delete_item('username')
	self.session.delete_item('role')
	self.session.delete_item('tid')
	self.session.delete_item('level')
	self.session.delete_item('game_id')
	
	msg="Thank you for playing. Bye!"
	
	temp = os.path.join(os.path.dirname(__file__), 'templates/logout.html')
	
      	self.response.headers['Content-Type'] = 'text/html'
        self.response.out.write(str(template.render(temp,{"logoutmsg":msg})))
Ejemplo n.º 18
0
class CipherInterfaceHandler(webapp.RequestHandler):
    def get(self):
	temp=os.path.join(os.path.dirname(__file__), 'templates/sample.html')
	self.response.headers['Content-Type'] = 'text/html'
	self.response.out.write(str(template.render(temp,{})))
	
    def post(self):
        # Our POST Input
	self.session=Session()
        txtinput = self.request.get('txtValue')
	txtinput=txtinput.lower()
	mode=self.request.get('mode')
	
	if (txtinput =='show files' or txtinput == 'sf'):
	    txtinput="Show Files: Ciphers.py Subsitution.py transposition.py vigenere.py Affine.py ciphers.py"
        elif (txtinput == "help" or txtinput =='h'):
	    txtinput="Would you like to go to the tutorial for the Caesar cipher(chelp or ch), Substitution cipher(shelp or sh), Transposition cipher(thelp or th), Vigenere cipher(vhelp or vh), or Affine cipher(ahelp or ah)? You can also type toolbox(toolbox or tb) to use the ciphers."
	elif(txtinput == "chelp" or txtinput=="ch"):
		txtinput="The Caesar cipher works by substituting letters for different letters a certain number away from the original letter. For example, the letter 'A' with a key of 2 would become 'C' because C is 2 letters away from 'A'. The word 'CAT' would be encoded to say 'ECV'. To figure out the key to decode a message, you can keep trying numbers between 1 and 26 until one decodes the message into something that makes sense."
	elif(txtinput == "shelp" or txtinput=="sh"):
		txtinput="The substitution cipher has a key of 26 letters, each one in the alphabet, all reordered, and matches the old letters of the alphabet to the new ones. So if the letter 'A' maps to 'V' because it is the first letter of the key, 'B' maps to 'Q' because 'Q' is the second letter in the key. If 'T' maps to 'P', the code word for 'TAB' would be 'PVQ'."
	elif(txtinput == "thelp" or txtinput=="th"):
		txtinput="The transposition cipher works by mapping different letters to columns in a table, and then putting the rows of the table together to make the ciphertext. For example, to encode the sentence 'The apple is red.' with a key of 3, the cipher will make a table with 3 columns. Because there are 17 characters in this sentence, we take 17/3 which gives 5 with a remainder of 2. This means we need 6 rows and one space will not be used since there are 17 characters and 18 table entries. The cipher will put one letter in each column of the table so that they read [T,h,e; ,a,p;p,l,e; ,i,s; ,r,e;d,.,X] (commas separate columns, semicolumns separate rows) The resulting ciphertext will go down each column one at a time putting together the characters, giving the ciphertext 'T p  dhalir.epese'"
	elif(txtinput == "vhelp" or txtinput=="vh"):
		txtinput="The Vigenere cipher works almost like the Caesar cipher, except for every letter, the number of letters it shifts is different. The alphabet index of each letter in the key tells how many letters to shift each letter of plaintext. To encode the sentence 'The sky is blue' with the key 'cat', the index of each letter in the key 'cat' is the shift number. The first letter of the message 'T' will shift 3 letters since the first letter of the key is 'c', and its index is 3. So, the first letter of the ciphertext will be 'W'. The next letter will shift 1 because the index of a is one, so 'h' will become 'i'. The index of 't' is 20, so 'e' will shift 20 to become 'y'. When the letters in the key run out, it just starts over, so the next letter of the message 's' will shift 3 to 'v' because the next shift will be the letter 'c' again."
	elif(txtinput == "ahelp" or txtinput=="ah"):
		txtinput="The affine cipher has a few more steps than the other ciphers. First, it maps each letter of the plaintext to its alphabetic index starting at 0. The word 'SLEUTH' would map to the numbers 18, 11, 4, 20, 19, 7. Let's say we want to include special characters in our encoded alphabet, which will now have a length of 96 instead of 26. We then need to select two numbers for the key, and the first number has to be coprime with 96, meaning it does not share any factors with 96. Since 96's prime factors are 2 and 3, the first part of the key can be any number not divisible by 2 or 3. Our numbers a and b will be used in the equation ax+b, where x is the letter index and the result of which needs to be bigger than 96 for reasons we'll explain in a minute. We'll choose a to be 31 and b to be 57. When we use each letter's index as x in the equation, we get 615, 398, 181, 677, 646, 274. To map these numbers to our alphabet of symbols and letters, we need them to be mod 96. This means we want to divide them by 96 and use the remainder as the new number. After doing that, our new numbers are 39, 14, 85, 5, 70, 82. To get our key, we can multiply a by 96 and add b, which gives us 3033. Mapping the new numbers to their indexes in our alphabet gives us the ciphertext '&lTcEQ'."
	elif(txtinput == "tb" or txtinput=='toolbox'):
	    txtinput="You have selected toolbox. Please select a mode(e for Encryption, d for Decryption) and type a message( ex: d-Hello )?"
	elif(mode=='e' or mode=='d'):
	    self.session.delete_item('mode')
	    self.session['mode']=mode
	    msg=self.request.get('msg')
	    self.session.delete_item('msg')
	    self.session['msg']=msg
	    if (mode =='e'):
		mo="Encryption"
	    else:
		mo="Decryption"
	    txtinput="You have chosen " + mo +" and your message is " + msg + ". Please select which cipher you would like to use - Caesar cipher(c), Substitution cipher(s), Transposition cipher(t), Vigenere cipher(v), or Affine cipher(a). Please type \"use-cipher method\"(ex - use-s)"
	else:
	    txtinput="Error, invalid command! Please type again."
	array = {'text': txtinput}	    
        
       
        # Output the JSON
        self.response.headers['Content-Type'] = 'application/json'
        self.response.out.write(json.dumps(array))
class AuthenticationPage(webapp.RequestHandler):

    def get(self):
        logging.info("reached login page")
        path=self.request.path
        temp=os.path.join(os.path.dirname(__file__),'templates/login.html')
        html=template.render(temp,{})
        self.response.out.write(html)

    def post(self):
        import sys, getpass
        self.session=Session()
        username = self.request.get('username')
        password = self.request.get('password')
        self.session.delete_item('username')

        if username=='' or password=='':
            temp=os.path.join(os.path.dirname(__file__),'templates/login.html')
            html=template.render(temp,{'error':'Invalid Login'})
            self.response.out.write(html)
        else:
            token = ClientLogin().authorize(username, password)
            if token is not None:
                self.session['username']=username
                ft_client = ftclient.ClientLoginFTClient(token)
                self.session['ft_client']=ft_client
                results = ft_client.query(SQL().showTables())
                temp=os.path.join(os.path.dirname(__file__),'templates/index.html')
                html=template.render(temp,{'username':username})
                self.redirect("/house")
            else:
                logging.info("unable to login")
                temp=os.path.join(os.path.dirname(__file__),'templates/login.html')
                html=template.render(temp,{'error':'Invalid Login'})
                self.response.out.write(html)







        #show tables


        '''temp=os.path.join(os.path.dirname(__file__),'templates/index.html')
Ejemplo n.º 20
0
class CapitalHandler(webapp.RequestHandler):
    def get(self):
        self.session = Session()
        self.session.delete_item('username')
        doRender(self, 'index.html')

    def post(self):
        self.session = Session()
        guess_capital = str(self.request.get('capital'))
        for country in country_data:
            if country['name'] == self.session['country']:
                self.session['capital'] = country['capital']
        true_capital = self.session['capital']
        if guess_capital != true_capital:
            doRender(self, 'country.html', {'error': 'Guess again...'})
        else:
            doRender(self, 'capital.html', {'capital': true_capital})
Ejemplo n.º 21
0
class CipherInterfaceHandler(webapp.RequestHandler):
    def get(self):
        temp = os.path.join(os.path.dirname(__file__), 'templates/sample.html')
        self.response.headers['Content-Type'] = 'text/html'
        self.response.out.write(str(template.render(temp, {})))

    def post(self):
        # Our POST Input
        self.session = Session()
        txtinput = self.request.get('txtValue')
        mode = self.request.get('mode')

        if (txtinput == 'show files'):
            txtinput = "Show Files: Ciphers.py Subsitution.py"
        elif (txtinput == "help" or txtinput == 'h'):
            txtinput = "Would you like to go to the tutorial for the Caesar cipher(chelp), Substitution cipher(shelp), Transposition cipher(thelp), Vigenere cipher(vhelp), or Affine cipher(ahelp)? You can also type toolbox(tb) to use the ciphers."
        elif (txtinput == "chelp"):
            txtinput = "The Caesar cipher works by substituting letters for different letters a certain number away from the original letter. For example, the letter 'A' with a key of 2 would become 'C' because C is 2 letters away from 'A'. The word 'CAT' would be encoded to say 'ECV'. To figure out the key to decode a message, you can keep trying numbers between 1 and 26 until one decodes the message into something that makes sense."
        elif (txtinput == "shelp"):
            txtinput = "The substitution cipher has a key of 26 letters, each one in the alphabet, all reordered, and matches the old letters of the alphabet to the new ones. So if the letter 'A' maps to 'V' because it is the first letter of the key, 'B' maps to 'Q' because 'Q' is the second letter in the key. If 'T' maps to 'P', the code word for 'TAB' would be 'PVQ'."
        elif (txtinput == "thelp"):
            txtinput = "The transposition cipher works by mapping different letters to columns in a table, and then putting the rows of the table together to make the ciphertext. For example, to encode the sentence 'The apple is red.' with a key of 3, the cipher will make a table with 3 columns. Because there are 17 characters in this sentence, we take 17/3 which gives 5 with a remainder of 2. This means we need 6 rows and one space will not be used since there are 17 characters and 18 table entries. The cipher will put one letter in each column of the table so that they read [T,h,e; ,a,p;p,l,e; ,i,s; ,r,e;d,.,X] (commas separate columns, semicolumns separate rows) The resulting ciphertext will go down each column one at a time putting together the characters, giving the ciphertext 'T p  dhalir.epese'"
        elif (txtinput == "vhelp"):
            txtinput = "The Vigenere cipher works almost like the Caesar cipher, except for every letter, the number of letters it shifts is different. The alphabet index of each letter in the key tells how many letters to shift each letter of plaintext. To encode the sentence 'The sky is blue' with the key 'cat', the index of each letter in the key 'cat' is the shift number. The first letter of the message 'T' will shift 3 letters since the first letter of the key is 'c', and its index is 3. So, the first letter of the ciphertext will be 'W'. The next letter will shift 1 because the index of a is one, so 'h' will become 'i'. The index of 't' is 20, so 'e' will shift 20 to become 'y'. When the letters in the key run out, it just starts over, so the next letter of the message 's' will shift 3 to 'v' because the next shift will be the letter 'c' again."
        elif (txtinput == "ahelp"):
            txtinput = "The affine cipher has a few more steps than the other ciphers. First, it maps each letter of the plaintext to its alphabetic index starting at 0. The word 'SLEUTH' would map to the numbers 18, 11, 4, 20, 19, 7. Let's say we want to include special characters in our encoded alphabet, which will now have a length of 96 instead of 26. We then need to select two numbers for the key, and the first number has to be coprime with 96, meaning it does not share any factors with 96. Since 96's prime factors are 2 and 3, the first part of the key can be any number not divisible by 2 or 3. Our numbers a and b will be used in the equation ax+b, where x is the letter index and the result of which needs to be bigger than 96 for reasons we'll explain in a minute. We'll choose a to be 31 and b to be 57. When we use each letter's index as x in the equation, we get 615, 398, 181, 677, 646, 274. To map these numbers to our alphabet of symbols and letters, we need them to be mod 96. This means we want to divide them by 96 and use the remainder as the new number. After doing that, our new numbers are 39, 14, 85, 5, 70, 82. To get our key, we can multiply a by 96 and add b, which gives us 3033. Mapping the new numbers to their indexes in our alphabet gives us the ciphertext '&lTcEQ'."
        elif (txtinput == "tb"):
            txtinput = "You have selected toolbox. Please select a mode(e for Encryption, d for Decryption) and type a message( ex: d-Hello )?"
        elif (mode == 'e' or mode == 'd'):
            self.session.delete_item('mode')
            self.session['mode'] = mode
            msg = self.request.get('msg')
            self.session.delete_item('msg')
            self.session['msg'] = msg
            if (mode == 'e'):
                mo = "Encryption"
            else:
                mo = "Decryption"
            txtinput = "You have chosen " + mo + " and your message is " + msg + ". Please select which cipher you would like to use - Caesar cipher(c), Substitution cipher(s), Transposition cipher(t), Vigenere cipher(v), or Affine cipher(a). Please type \"use-cipher method\"(ex - use-s)"

        array = {'text': txtinput}

        # Output the JSON
        self.response.headers['Content-Type'] = 'application/json'
        self.response.out.write(json.dumps(array))
Ejemplo n.º 22
0
class CapitalHandler(webapp.RequestHandler):

	def get(self): 
		self.session = Session()
		self.session.delete_item('username')
		doRender(self,'index.html')

	def post(self):
		self.session = Session()
		guess_capital = str(self.request.get('capital'))
		for country in country_data:
			if country['name']==self.session['country']:
				self.session['capital'] = country['capital']
		true_capital = self.session['capital']
		if guess_capital != true_capital:
			doRender(self, 'country.html', {'error': 'Guess again...'})
		else:
			doRender(self,'capital.html', {'capital': true_capital})
class LoginHandler(webapp.RequestHandler):
    def get(self):
        logging.info('Login Page Rendered')

        #Environment (testing or production)
        ereturn = functions.productionEnvironment()
        if ereturn == '0': environment = "Dev Environment"
        if ereturn == '1': environment = "Prod Environment"
        logging.info('ereturn: ' + ereturn)

        doRender(self, 'loginscreen.htm', {'environment': environment})

    def post(self):
        logging.info('Login Attempt')
        self.session = Session()
        acct = self.request.get('account')
        pw = self.request.get('password')
        #logging.info('Checking account='+acct+' pw='+pw)

        self.session.delete_item('username')

        if pw == '' or acct == '':
            doRender(self, 'loginscreen.htm',
                     {'error': 'Please specify Email and Password'})
            return

        logging.info('password: '******'':  #Salts Password for db check
            pw = functions.getSaltedHash(pw)

        logging.info('password: '******'account =', acct)
        que = que.filter('password = '******'username'] = acct
            doRender(self, 'index.htm', {})
        else:
            doRender(self, 'loginscreen.htm', {'error': 'Incorrect password'})
Ejemplo n.º 24
0
class TransHandler(webapp.RequestHandler):
    def post(self):
	self.session=Session()
	mode = self.session.get("mode")
	msg=self.session.get("msg")
	
        txtinput = self.request.get('method')
	
	if (txtinput=='t'):
	    txtinput="You have chosen Transposition cipher. Your mode is " + mode +" and your message is " + msg +". Please enter a key(1<= key <= length of your message) (ex: tkey-3)" 
	elif (txtinput == 'key'):
	    key=int(self.request.get("keystr"))
	    maxlen=len(msg)
	    trans = transposition.TranspositionCipherTool(mode,msg,maxlen)
	    keynum=trans.display()
	    if(key >= 1 and key <= int(maxlen)):
		trans.storekey(key)
		translated=trans.getTranslatedMessage()
		txtinput="Your translated message is " + translated
	    else:
		self.session.delete_item("msg")
		txtinput="Your key is not valid. Please re-enter a new message( ex: tmsg-{'This is message'})"
	elif (txtinput=='tmsg'):
	    msg=self.request.get("keystr")
	    self.session['msg']=msg
	    txtinput="Please enter a key(1<= key <= length of your message) (ex: tkey-3)"
	else:
	    txtinput="Error, invalid command! Please type again. Please select which cipher you would like to use - Caesar cipher(c), Substitution cipher(s), Transposition cipher(t), Vigenere cipher(v), or Affine cipher(a). Please type \"use-cipher method\"(ex - use-s)"
	    
	    
	    
	   
	    
		
	    
	    
	array = {'text': txtinput}	    
        
       
        # Output the JSON
        self.response.headers['Content-Type'] = 'application/json'
        self.response.out.write(json.dumps(array))
Ejemplo n.º 25
0
class MainHandler(webapp.RequestHandler):

	def get(self):
	
		path = (self.request.path).replace('/', '')
		datastore = DataStoreInterface()
		
		if (path <> '') and (path <> 'main.html'):
			if (datastore.companyProfileExists(path) == 1):				
				path = 'profiles.html?company='+path
				self.redirect(path)
			else:
				self.response.out.write('404: File not Found')
		else:
			render.doRender(self,'main.html', {})
	
	def post(self):
		
		self.session = Session()
		datastore = DataStoreInterface()
		
		email = self.request.get('txtEmail').strip()
		password = self.request.get('txtPassword')
		
		self.session.delete_item('user')
		
		#Check for any fields left empty
		if email == '' or password == '':
			render.doRender(self, 'main.html', {'error' : 'Please fill in all the details'})
			return
		
		username = datastore.loginUser(email, password)
		
		if datastore.isUser(email)== 1:
			if datastore.checkPass(email, password)==1:	
				self.session['user'] = username			
				self.redirect('controlpanel.html')
			else:
				render.doRender(self, 'main.html', {'error' : 'Wrong password'})
		else:
			render.doRender(self, 'main.html', {'error' : 'Email Address does not exist'})
Ejemplo n.º 26
0
class LoginHandler( webapp.RequestHandler ):
    def get( self ):
        doRender( self, 'login/loginscreen.htm' )

    def post( self ):
        self.session = Session()
        acct = self.request.get( 'account' ).lower()
        pw = self.request.get( 'password' ).lower()
        logging.info( 'checking account=' + acct + ' pw=' + pw )

        self.session.delete_item( 'username' )

        if pw == '' or acct == '':
            doRender( self, 'login/loginscreen.htm', {'error':'Please specify acct and pw'} )
            return
        user = User.all().filter( 'email =', db.Email( acct ) ).filter( 'password ='******'login/loginscreen.htm',
                     {'error' : 'Incorrect password'} )
        else:
            self.session['username'] = acct
            doRender( self, 'index.htm', {} )
Ejemplo n.º 27
0
class GameloadHandler(webapp.RequestHandler):
    
    def get(self):
	self.session=Session()
	start_msg=""	
	gid=self.request.get("gid")
	
	self.session['game_id']=gid
	#get current level for game id
	result_game=(db.GqlQuery("SELECT * FROM GameDB WHERE game_id = :1", gid)).get()
    	glevel=result_game.current_level
	if (glevel):
	    start_msg="START THE GAME"
	#level=self.request.get("level")
	if (self.session.get('level')):
	    self.session.delete_item('level')
	self.session['level']=glevel

	
	temp = os.path.join(os.path.dirname(__file__), 'templates/gameload.html')
	self.response.headers['Content-Type'] = 'text/html'
	self.response.out.write(str(template.render(temp,{"start_msg":start_msg,"level":glevel})))
Ejemplo n.º 28
0
class LoginHandler(webapp2.RequestHandler):
    def get(self):
        doRender(self, 'loginscreen.htm')

    def post(self):
        self.session = Session()
        acct = self.request.get('account')
        pw = self.request.get('password')
        logging.info('Checking account=' + acct + 'pw=' + pw)
        que = db.Query(User).filter('acct =', acct).filter('pw =', pw)
        results = que.fetch(limit=1)
        self.session.delete_item('username')
        if pw == '' or acct == '':
            doRender(self, 'loginscreen.htm', {'error': 'Specify Acct and PW'})
        elif len(results) > 0:
            user = results[0]
            self.session['username'] = acct
            self.session['userkey'] = user.key()
            doRender(self, 'loggedin.htm',
                     {'username': self.session['username']})
        else:
            doRender(self, 'loginscreen.htm',
                     {'error': 'Incorrect login data'})
Ejemplo n.º 29
0
class AdminHandler(webapp.RequestHandler):
	def get(self):
		self.session = Session()
		if not 'admin_key' in self.session:
			doRender(self,'admin_index.htm',{})
		else:
			admin_name=self.session['admin_name']
			#logging.info('I am logging in!!!'+admin_name)
			doRender(self,'admin_index.htm',{'admin_name':admin_name})
		#newadmin = Admin_User(admin_account='admin_xum', admin_password='******');
		#newadmin.put();
			
	def post(self):
		self.session = Session()
		acct = self.request.get('admin_account')
		pw = self.request.get('admin_password')
		logging.info('Checking admin account='+acct+' pw='+pw)
		self.session.delete_item('admin_key')
		self.session.delete_item('admin_name')
		
		if pw == '' or acct == '':
			doRender(self,'admin_index.htm',{'error' : 'Please specify email and password'} )
			return
			
		# Check to see if our data is correct
		que = db.Query(Admin_User)
		que = que.filter('admin_account =',acct)
		que = que.filter('admin_password = '******'admin_name'] = acct
			self.session['admin_key'] = user.key()
			doRender(self,'admin_index.htm',{'admin_name':acct} )
		else:
			doRender(self,'admin_index.htm',{'error' : 'Incorrect password'} )
class LoginHandler(webapp.RequestHandler):
    def get(self):
        doRender(self, 'loginscreen.htm')

    def post(self):
        self.session = Session()
        name = self.request.get('name')
        emailaddress = self.request.get('emailaddress')
        password = self.request.get('password')
        logging.info('Checking emailaddress=' + emailaddress + ' password='******'username')
        self.session.delete_item('userkey')

        if name == '' or password == '' or emailaddress == '':
            doRender(self, 'loginscreen.htm',
                     {'error': 'Please fill all the Fields'})
            return

        que = db.Query(User)
        que = que.filter('name = ', name)
        que = que.filter('emailaddress =', emailaddress)
        que = que.filter('password = '******'userkey'] = user.key()
            self.session['username'] = name
            doRender(self, 'profile.htm', {})

        else:
            doRender(self, 'loginscreen.htm',
                     {'error': 'All Details Need to Match!! '})
            return
Ejemplo n.º 31
0
class LoginHandler(webapp.RequestHandler):

  def get(self):
    doRender(self, 'loginscreen.htm')

  def post(self):
    self.session = Session()
    acct = self.request.get('account')
    pw = self.request.get('password')
    logging.info('Checking account='+acct+' pw='+pw)

    self.session.delete_item('username')

    if pw == '' or acct == '':
      doRender(
          self,
          'loginscreen.htm',
          {'error' : 'Please specify Account and Password'} )
    elif pw == 'secret':
      self.session['username'] = acct
      doRender(self,'index.htm',{ } )
    else:
      doRender(self,'loginscreen.htm',
            {'error' : 'Incorrect password'} )
Ejemplo n.º 32
0
class LoginHandler(webapp.RequestHandler):
    def get(self):
        doRender(self, 'loginscreen.htm')
    
    def post(self):
        self.session = Session()
        un = self.request.get('username')
        pw = self.request.get('password')

        self.session.delete_item('username')
        self.session.delete_item('userkey')

        if pw == '' or un == '':
            doRender(
                    self,
                    'loginscreen.html',
                    {'error': 'Please specify Username and Password'} )
            return

        que = db.Query(User)
        que = que.filter('username ='******'password ='******'userkey'] = user.key()
            self.session['username'] = un
            doRender(self,'main.html', {} ) # if ok, go to main.html (logged in)
        else:
            doRender(
                    self,
                    'loginscreen.html',
                    {'error' : 'Username or Password wrong' } )
Ejemplo n.º 33
0
class login(webapp.RequestHandler):
    def get(self):
        render(self, "login.html")
        
    def post(self):
        data = {}
        em = self.request.get('em')
        pw = self.request.get('pw')
    
        self.session = Session()
        #destroy former session data
        self.session.delete_item('username')
       
        
        if em =="" and pw == "":
            data['noCredos']  = True
            #self.session = Session()
            #data['user'] =  self.session.get('username', None)
            data['error_msg'] = "pls fill in your email and password"
            render(self,"login.html",data) 
        
        else:
            que = db.Query(Poller)
            que.filter('email', em)
            que.filter('password', pw)
        
            results = que.fetch(limit=1)
        
            if len(results) > 0:
                self.session['username'] = em #set session
                data['user'] = em
                render(self,"create_question.html",data)
            else:
                data['usernotfound'] = True
                data['error_msg'] = "incorrect password or email; pls try again"
                render(self,"login.html",data)
Ejemplo n.º 34
0
class LoginHandler(BaseHandler):
    def get(self):
        form = LoginForm()
        self.doRender('loginscreen.html', {'form': form})
    
    def post(self):
        self.session = Session()

        form = LoginForm(self.request.POST)
        if form.validate():
            self.session.delete_item('username')
            self.session.delete_item('userkey')
            self.session.delete_item('admin')
            
            un = form.username.data 
            pw = form.password.data 
            m = hashlib.sha224(pw)
            que = db.Query(User).filter('username ='******'password ='******'password ='******'userkey'] = user.key()
                self.session['username'] = un
                self.session['admin'] = user.admin
                self.redirect('/main') 
                #self.doRender('main.html', {} ) # if ok, go to main.html (logged in)
            else:
                self.doRender(
                        'loginscreen.html',
                        {'error': 'Username or Password wrong', \
                         'form': form} )
        else: # if form.validate() Fails.
            self.doRender('loginscreen.html', {'form': form} )
Ejemplo n.º 35
0
class LoginHandler(webapp.RequestHandler):
  '''
  类作用:用户登录页面的响应
  '''  
  def get(self):
    '''
    当用户登录聊天频道首页的时候调用 
    '''
    
    #如果url包含了login 则标识客户端的ajax请求 仅仅传送部分html网页即可
    if self.request.url.find('login') != -1: 
    #见register.html 中已经注册,点此<a href="#" onclick="$('#chat_main').load('/chat/login');return false;">返回</a>
      doRender(self,'login.html')
    #表示用户来到了聊天室主界面 url为/chat
    else:
      doRender(self,'chat.html',{'error' : None})
            
  def post(self):
    '''
    用户提交登录表单时候调用
    '''
    
    #登录的时候会发送cookie !!!出于安全考虑 用户在和服务器通信的时候通过cookie来认证登录的用户!!!
    self.session = Session()       
    acct = cgi.escape(self.request.get('account')) #!!!安全考虑!!!
    pw = self.request.get('password')
    ######################logging.info('Checking account='+acct.encode('utf-8')+' pw='+pw.encode('utf-8'))

    #为什么要删除???因为浏览器会一直发送cookie 只要他曾经来登录过 或者注册过 
    #这样做方便后面更新memcache里面的数据
    self.session.delete_item('username')
    self.session.delete_item('userkey') 
    #delete_item见下源码
    #    def delete_item(self, keyname):
    #        if keyname in self.session:
    #            del self.session[keyname] 
    #            self._update_cache() #更新memcache
    #用户名或密码为空时候提示 已经在客户端js里面进行了判断 所以理论上不会出现这种情况
    if pw == '' or acct == '':
      doRender( self, 'login.html', {'error' : '系统提示:用户名或密码不能够为空!'})
      return
    
    #核对用户名和密码
    que = db.Query(User)
    que = que.filter('account =',acct)
    que = que.filter('password = '******'userkey'] = user.key() #注意:这里是一个引用地址 而不是用户的密码!!!
      self.session['username'] = acct
      
      #当用户一旦登录成功了以后更新用户的在线状态 
      #############其实在线状态在OpenedSocketHandler里面更新最好
      #user.is_online = True
      #user.put()
      que = db.Query(ChatMessage).order('created_time');
      chat_list = que.fetch(limit=100)              
      ##############聊天记录应该看多少才合适呢???我是不是应该在后面加入一些命令???例如私人会话 或者是查看聊天记录的命令???
      if(len(chat_list)>0):
        doRender(self,'chatroom.html',{'username':self.session['username'],'chat_list': chat_list})                                             
      else:
        doRender(self,'chatroom.html',{'username':self.session['username'],'chat_list': None})
        #self.response.out.write("<p>无聊天记录</p>") 
    #密码错误
    else:
      doRender( self, 'login.html', {'error' : '系统提示:用户名或密码错误!'})
Ejemplo n.º 36
0
class GameHandler(webapp.RequestHandler):
    def get(self):
        self.session = Session()

        self.session['userCheck'] = 0
        userid = self.session.get("id")
        username = self.session.get("username")
        level = self.request.get("level")
        if (self.session.get('level')):
            self.session.delete_item('level')
        self.session['level'] = level
        final = self.request.get("c")
        errormsg = ""

        result_student = (db.GqlQuery(
            "SELECT * FROM StudentDB WHERE student_id = :1", userid)).get()

        if (level == '1'):
            self.session.delete_item('userCheck')
            self.session['userCheck'] = 1
            temp = os.path.join(os.path.dirname(__file__),
                                'templates/game1.html')

            current_level = int(level)
            #create a new gamedb for the user
            if (self.session.get('game_id')):
                gameid = self.session.get('gid')
            else:
                gameid = userid + "_" + str(randint(1, 99999))
                self.session['game_id'] = gameid

            newDB = GameDB(student_id=userid,
                           game_id=gameid,
                           current_level=current_level)
            newDB.put()

            #update StudentDB with the new gameid
            result_student.game_id = gameid
            result_student.attempt = 0
            result_student.level_1 = False
            result_student.level_2 = False
            result_student.level_3 = False
            result_student.level_4 = False
            result_student.level_5 = False
            result_student.put()

        elif (level == '2'):
            self.session.delete_item('userCheck')
            self.session['userCheck'] = 2
            temp = os.path.join(os.path.dirname(__file__),
                                'templates/game2.html')
            current_level = int(level)
            gameid = self.session.get("game_id")
            result_game = (db.GqlQuery(
                "SELECT * FROM GameDB WHERE game_id = :1", gameid)).get()

            #update game DB with current level
            result_game.current_level = current_level
            result_game.put()

            #update student DB with current level
            result_student.attempt = current_level
            result_student.put()

        elif (level == '3'):
            self.session.delete_item('userCheck')
            self.session['userCheck'] = 3
            temp = os.path.join(os.path.dirname(__file__),
                                'templates/game3.html')
            current_level = int(level)

            gameid = self.session.get("game_id")
            result_game = (db.GqlQuery(
                "SELECT * FROM GameDB WHERE game_id = :1", gameid)).get()
            result_game.current_level = current_level
            result_game.put()

            #update student DB with current level
            result_student.attempt = current_level
            result_student.put()
        elif (level == '4'):
            self.session.delete_item('userCheck')
            self.session['userCheck'] = 4
            temp = os.path.join(os.path.dirname(__file__),
                                'templates/game4.html')
            current_level = int(level)

            gameid = self.session.get("game_id")
            result_game = (db.GqlQuery(
                "SELECT * FROM GameDB WHERE game_id = :1", gameid)).get()

            result_game.current_level = current_level
            result_game.put()

            #update student DB with current level
            result_student.attempt = current_level
            result_student.put()
        elif (level == '5'):
            self.session.delete_item('userCheck')
            self.session['userCheck'] = 5
            temp = os.path.join(os.path.dirname(__file__),
                                'templates/game5.html')
            current_level = int(level)

            gameid = self.session.get("game_id")
            result_game = (db.GqlQuery(
                "SELECT * FROM GameDB WHERE game_id = :1", gameid)).get()

            result_game.current_level = current_level
            result_game.put()

            #update student DB with current level
            result_student.attempt = current_level
            result_student.put()
        elif (level == '0'):
            self.session['userCheck'] = 0
            temp = os.path.join(os.path.dirname(__file__),
                                'templates/game0.html')

            gameid = self.session.get("game_id")
            result_game = (db.GqlQuery(
                "SELECT * FROM GameDB WHERE game_id = :1", gameid)).get()

            result_game.completion = True
            result_game.put()

        elif (final == "1"):
            temp = os.path.join(os.path.dirname(__file__),
                                'templates/gameterm.html')

        self.response.headers['Content-Type'] = 'text/html'
        self.response.out.write(
            str(
                template.render(
                    temp, {
                        "username": username,
                        "level": level + " / 5",
                        "error_msg": errormsg
                    })))

    def post(self):
        self.session = Session()
        userid = self.session.get("id")
        username = self.session.get("username")
        level = self.session.get("level")
        operation = self.request.get("op")
        decoded = self.request.get("decodedmsg")
        error_msg = ""
        msg = ""
        solved = None
        flag = True

        result = (db.GqlQuery("SELECT * FROM StudentDB WHERE student_id = :1",
                              userid)).get()

        decoded = decoded.upper()
        if (operation == '11'):

            temp = os.path.join(os.path.dirname(__file__),
                                'templates/game1.html')
            if (decoded == 'GO TO LIBRARY'):
                result.level_1 = True
                msg = "CONTINUE"
                solved = 1
                flag = False
            #start session for putting the level into the db
        elif (operation == '12'):

            temp = os.path.join(os.path.dirname(__file__),
                                'templates/game2.html')
            if (decoded == 'GET MYSTERY OF TIME AND GO TO AIRPORT'):
                result.level_2 = True
                flag = False
                solved = 1
                msg = "CONTINUE"

        elif (operation == '13'):

            temp = os.path.join(os.path.dirname(__file__),
                                'templates/game3.html')
            if (decoded == 'HE HAS BROWN HAIR, RED SCARF, YELLOW SHOES'):
                result.level_3 = True
                flag = False
                solved = 1
                msg = "CONTINUE"

        elif (operation == '14'):

            temp = os.path.join(os.path.dirname(__file__),
                                'templates/game4.html')
            if (decoded == 'I LOVE YELLOW AND SKY IS PURPLE'):
                result.level_4 = True
                flag = False
                solved = 1
                msg = "CONTINUE"

        elif (operation == '15'):

            temp = os.path.join(os.path.dirname(__file__),
                                'templates/game5.html')
            if (decoded == 'GO TO GRANDMA HOUSE CODE IS 42'):
                result.level_5 = True
                flag = False
                solved = 1
                msg = "CONTINUE"
        elif (operation == '0'):

            temp = os.path.join(os.path.dirname(__file__),
                                'templates/game0.html')
            if (decoded == '42'):

                flag = False
                solved = 1
                msg = "CONTINUE"

        if (flag):
            error_msg = "I'm sorry. Your decode seems incorrect. Please try again."

        result.put()
        self.response.headers['Content-Type'] = 'text/html'
        self.response.out.write(
            str(
                template.render(
                    temp, {
                        "username": username,
                        'error_msg': error_msg,
                        'msg': msg,
                        "level": level + " / 5",
                        "solved": solved
                    })))
Ejemplo n.º 37
0
class AdminLogoutHandler(webapp.RequestHandler):
	def get(self):
		self.session = Session()
		self.session.delete_item('admin_name')
		self.session.delete_item('admin_key')
		doRender(self, 'admin_index.htm')
Ejemplo n.º 38
0
class LogoutHandler(webapp2.RequestHandler):

  def get(self):
    self.session = Session()
    self.session.delete_item('username')
    self.session.delete_item('userkey')
    self.session.delete_item('sender_key')
    self.session.delete_item('transporter_key')
    self.session.delete_item('senderflag')
    self.session.delete_item('transporterflag')
    self.session.delete_item('matchingkey')
    doRender(self, 'login.html')
Ejemplo n.º 39
0
class LogoutHandler(webapp.RequestHandler):
    def get(self):
        self.session = Session()
        self.session.delete_item("username")
        self.session.delete_item("userkey")
        doRender(self, "index.htm")
Ejemplo n.º 40
0
class GameHandler(webapp.RequestHandler):
    
    
    def get(self):
	self.session=Session()

	self.session['userCheck']=0
	userid=self.session.get("id")
	username=self.session.get("username")
	level=self.request.get("level")
	if (self.session.get('level')):
	    self.session.delete_item('level')
	self.session['level']=level
	final=self.request.get("c")
	errormsg=""
    	
	
	result_student=(db.GqlQuery("SELECT * FROM StudentDB WHERE student_id = :1", userid)).get()
	
	if (level=='1'):
	    self.session.delete_item('userCheck')
	    self.session['userCheck']=1
	    temp = os.path.join(os.path.dirname(__file__), 'templates/game1.html')
	    
	    current_level=int(level)
	    #create a new gamedb for the user
	    if (self.session.get('game_id')):
		gameid=self.session.get('gid')
	    else:	
		gameid=userid + "_" + str(randint(1,99999))
		self.session['game_id']=gameid
		
	    newDB = GameDB(student_id=userid, game_id=gameid,current_level=current_level)
	    newDB.put()
	    
	    #update StudentDB with the new gameid
	    result_student.game_id=gameid
	    result_student.attempt=0
	    result_student.level_1=False
	    result_student.level_2=False
	    result_student.level_3=False
	    result_student.level_4=False
	    result_student.level_5=False
	    result_student.put()
	    
	    
	elif (level=='2'):
	    self.session.delete_item('userCheck')
	    self.session['userCheck']=2
	    temp = os.path.join(os.path.dirname(__file__), 'templates/game2.html')
	    current_level=int(level)
	    gameid=self.session.get("game_id")
	    result_game=(db.GqlQuery("SELECT * FROM GameDB WHERE game_id = :1", gameid)).get()
	    
	    #update game DB with current level
	    result_game.current_level=current_level
	    result_game.put()
	    
	    #update student DB with current level
	    result_student.attempt=current_level
	    result_student.put()
	    
	elif (level=='3'):
	    self.session.delete_item('userCheck')
	    self.session['userCheck']=3
	    temp = os.path.join(os.path.dirname(__file__), 'templates/game3.html')
	    current_level=int(level)
	    
	    gameid=self.session.get("game_id")
	    result_game=(db.GqlQuery("SELECT * FROM GameDB WHERE game_id = :1", gameid)).get()
	    result_game.current_level=current_level
	    result_game.put()
	    
	    #update student DB with current level
	    result_student.attempt=current_level
	    result_student.put()	
	elif (level=='4'):
	    self.session.delete_item('userCheck')
	    self.session['userCheck']=4
	    temp = os.path.join(os.path.dirname(__file__), 'templates/game4.html')
	    current_level=int(level)
	    
	    gameid=self.session.get("game_id")
	    result_game=(db.GqlQuery("SELECT * FROM GameDB WHERE game_id = :1", gameid)).get()
	    
	    result_game.current_level=current_level
	    result_game.put()
	    
	    #update student DB with current level
	    result_student.attempt=current_level
	    result_student.put()	
	elif (level=='5'):
	    self.session.delete_item('userCheck')
	    self.session['userCheck']=5
	    temp = os.path.join(os.path.dirname(__file__), 'templates/game5.html')
	    current_level=int(level)
	    
	    gameid=self.session.get("game_id")
	    result_game=(db.GqlQuery("SELECT * FROM GameDB WHERE game_id = :1", gameid)).get()
	    
	    result_game.current_level=current_level
	    result_game.put()
	    
	    #update student DB with current level
	    result_student.attempt=current_level
	    result_student.put()	
	elif (level=='0'):
	    self.session['userCheck']=0
	    temp = os.path.join(os.path.dirname(__file__), 'templates/game0.html')
	    
	    gameid=self.session.get("game_id")
	    result_game=(db.GqlQuery("SELECT * FROM GameDB WHERE game_id = :1", gameid)).get()
	    
	    result_game.completion=True
	    result_game.put()
	    
	elif (final=="1"):
	    temp = os.path.join(os.path.dirname(__file__), 'templates/gameterm.html')
	    
	self.response.headers['Content-Type'] = 'text/html'
	self.response.out.write(str(template.render(temp,{"username":username, "level":level+" / 5", "error_msg":errormsg})))
    
    def post(self):
	self.session=Session()
	userid=self.session.get("id")
	username=self.session.get("username")
	level=self.session.get("level")
	operation=self.request.get("op")
	decoded=self.request.get("decodedmsg")
	error_msg=""
	msg=""
	solved=None
	flag=True
	
	result=(db.GqlQuery("SELECT * FROM StudentDB WHERE student_id = :1", userid)).get()
	
	decoded=decoded.upper()
	if (operation=='11'):
	    
	    temp = os.path.join(os.path.dirname(__file__), 'templates/game1.html')
	    if(decoded=='GO TO LIBRARY'):	
		result.level_1=True
		msg="CONTINUE"
		solved=1
		flag=False
	    #start session for putting the level into the db
	elif (operation=='12'):
	
	    temp = os.path.join(os.path.dirname(__file__), 'templates/game2.html')
	    if(decoded=='GET MYSTERY OF TIME AND GO TO AIRPORT'):
		result.level_2=True
		flag=False
		solved=1
		msg="CONTINUE"	
	    
	elif (operation=='13'):
	    
	    temp = os.path.join(os.path.dirname(__file__), 'templates/game3.html')
	    if(decoded=='HE HAS BROWN HAIR, RED SCARF, YELLOW SHOES'):
		result.level_3=True
		flag=False
		solved=1
		msg="CONTINUE"	
	    
	elif (operation=='14'):
	    
	    temp = os.path.join(os.path.dirname(__file__), 'templates/game4.html')
	    if(decoded=='I LOVE YELLOW AND SKY IS PURPLE'):
		result.level_4=True
		flag=False
		solved=1
		msg="CONTINUE"
		
	elif (operation=='15'):
	    
	    temp = os.path.join(os.path.dirname(__file__), 'templates/game5.html')
	    if(decoded=='GO TO GRANDMA HOUSE CODE IS 42'):
		result.level_5=True
		flag=False
		solved=1
		msg="CONTINUE"	
	elif (operation=='0'):
	    
	    
	    temp = os.path.join(os.path.dirname(__file__), 'templates/game0.html')
	    if(decoded=='42'):
		
		flag=False
		solved=1
		msg="CONTINUE"
	
	
	if(flag):
	    error_msg="I'm sorry. Your decode seems incorrect. Please try again."
	    
	result.put()
	self.response.headers['Content-Type'] = 'text/html'
	self.response.out.write(str(template.render(temp,{"username":username, 'error_msg': error_msg, 'msg':msg, "level":level+" / 5", "solved":solved})))
Ejemplo n.º 41
0
class RegisterHandler(webapp.RequestHandler):

  def get(self):
  
    render.doRender(self, 'register.html', {})

  def post(self):
  
    if (self.request.get('txtInviteCode') == 'SYNAPSE'):
        self.session = Session()
        datastore = DataStoreInterface()
    
        #collection of text box contents
        firstName = self.request.get('txtFirstName')
        lastName = self.request.get('txtLastName')
        company = self.request.get('txtCompany')
        email = self.request.get('txtEmail')
        password = self.request.get('txtPass1')
        repassword = self.request.get('txtPass2')
    
        #create session variable 
        self.session.delete_item('user')
        
        #create emailPOrcessor object
        emailObj = EmailProcessor()
                
        #check email address validity
        if emailObj.isValidEmail(email) == 0:
            render.doRender(self, 'register.html', {'error' : 'Invalid email address. Please input a valid email address.'})
            return
    
        #Ensure that the passwords match
        if password <> repassword:
            render.doRender(self, 'register.html', {'error' : 'Password did not match'})
            return
    
        #Check for any fields left empty
        if firstName == '' or lastName == '' or  company == '' or email == '' or password == '' or repassword == '':
            render.doRender(self, 'register.html', {'error' : 'Please fill in all the details'})
            return
    
        #See if the user already exists in the database
        if datastore.userExists(email) == 1:
            render.doRender(self, 'register.html', {'error' : 'The account associated with the email already exists'})
            return
    
        #check if company exists
        #IF it doesn't THEN add user as administrator and create company ELSE add user as editor
        if datastore.companyExists(company) == 0:
            if datastore.addUser([email, password, firstName, lastName, company, 'Administrator']) == 0:
                self.doRender(self, 'register.html', {'error' : 'Database could not add User: Adding a new user requires 6 attributes to be specified.'})
                return
                
            profileName = company.replace(' ', '').lower()
            if datastore.addCompany([company, profileName, email]) == 0:
                self.doRender(self, 'register.html', {'error' : 'Database could not add Company:  Adding a new company requires 3 attributes to be specified.'})
                return
        else:
            if datastore.addUser([email, password, firstName, lastName, company, 'Editor']) == 0:
                self.doRender(self, 'register.html', {'error' : 'Database could not add User: Adding a new user requires 6 attributes to be specified.'})
                return
    
        #create session variable based on email and company name
        username = company + " - " + email
        self.session['user'] = username
        self.redirect('controlpanel.html')
    else:
        render.doRender(self, 'register.html', {'error' : 'Sorry at this time SynapSync is open only to a limited number of users. Please check back at another time. <br><br>Thanks,<br> The SynapSync Team'})