Ejemplo n.º 1
0
    def post(self):
		input_name = self.request.get('username')
		input_name = cgi.escape(input_name)
		validname = validate_name(input_name)

		input_pass = self.request.get('password')
		input_pass2 = self.request.get('verify')
		input_pass = cgi.escape(input_pass)
		input_pass2 = cgi.escape(input_pass2)
		validpass = validate_pass(input_pass)
		validmatch = validate_match(input_pass,input_pass2)

		input_em = self.request.get('email')
		input_em = cgi.escape(input_em)
		validem = validate_email(input_em)

		UNchek = db.GqlQuery("SELECT * FROM UNPW WHERE UN = :user", user = input_name)
		
		if  UNchek.get():
			warn1 = HTMLError("Username is taken.")
			self.write_form(input_name,input_em,warn1)
		elif not validem:
			warn4 = HTMLError("Not a Valid Email.")
			self.write_form(input_name,input_em,'','','',warn4)
		elif (not validname):
			warn1 = HTMLError("Not a Valid Username.")
			self.write_form(input_name,input_em,warn1)
		elif validname and (not validpass):
			warn2 = HTMLError("Not a Valid Password.")
			self.write_form(input_name,input_em,'',warn2)
			#self.response.out.write("No good bro")
		elif validname and (not validmatch):
			warn3 = HTMLError("Passwords do not match.")
			self.write_form(input_name,input_em,'','',warn3)
		elif (validname and validpass and validmatch):
			PWH = make_pw_hash(input_name, input_pass)
			dashInit=json.dumps([['save','0px','0px']])
			newu = UNPW(UN=input_name,PW=PWH,EM=input_em,CSET='d3set10',STATUS='',DASH=dashInit)
			newu.put()
			pn=str(newu.key().id())
			self.secureCookie('UNH',pn)
			#pnsec = make_secure_val(pn)
			#self.response.headers.add_header('Set-Cookie', 'UNH=%s' %pnsec)
			self.redirect('/')
Ejemplo n.º 2
0
	def post(self):
		
		input_name = self.request.get('name')
		name = cgi.escape(input_name)

		input_em = self.request.get('email')
		em = cgi.escape(input_em)
		
		input_comm = self.request.get('comm')
		comm = cgi.escape(input_comm)

		if not len(str(comm)) > 3:
			w1="Please leave a message </br>"
			self.write_contact(name,em,'',w1,'')
			return

		if not validate_email(em):
			w2="Valid email required </br>"
			self.write_contact(name,'',comm,'',w2)
			return

		[loggedIn,admin,UN] = self.checkCookies()
		newComm = COMMENTS(UN=name,EM=em,COMM=comm)
		newComm.put()

		message = mail.EmailMessage(sender="*****@*****.**",
                            subject="Contact from P3")
		message.to = '*****@*****.**'
		message.body=(name+' has conacted your from PLOT3.com \n' +
					'Email: ' + em + '\n' +
					'Logged in as: ' + UN + '\n' +
					'Message: \n ' + comm )
		message.send()

		recvd = 'Thank you for your Feedback!'
		
		self.render('contact.html',UN=UN,loggedIn=loggedIn,recvd=recvd)