Example #1
0
def save_info(user, args):
	c = data.SQLconn()
	conn = MySQLdb.connect(host=c["host"], user=c["user"], passwd=c["passwd"], charset=c["charset"], db=c["db"])
	cursor = conn.cursor(cursorclass = MySQLdb.cursors.DictCursor)
	cursor.execute("update ACCOUNT SET \
					account_username='******', \
					account_sex = '%s',\
					account_phone='%s', \
					account_email='%s', \
					account_address = '%s'\
					WHERE account_id = %s\
					;"% (args.username, args.account_sex,args.phone,\
					args.email,str(args.account_address).encode('utf-8'), args.id))
	conn.commit()
	if args.get('oldpasswd'):
		if args.get('newpassword1') == args.get('newpassword2'):
			passwd = data.checkin(user)
			newpassword1 = data.md5(args.get('newpassword1'))
			oldpasswd = data.md5(args.get('oldpasswd'))
			if oldpasswd == passwd[0]['account_password']:
				cursor.execute("update ACCOUNT SET \
						account_password = '******'\
						WHERE account_id = '%s'"\
						%(newpassword1, args.get('id')))
				conn.commit()
			else:
				return False
		else:
			return False
	conn.close()
	return True
Example #2
0
def account_save(account_name, account_sex, account_username, account_work, account_position, account_phone,account_address,account_email,account_department, account_power):
	#存储账号信息
	#设置默认密码user:123456, admin: admin
	if account_name == 'user':
		account_password = data.md5('123456')
	elif account_name == 'admin':
		account_password = data.md5('admin')
	c = data.SQLconn()
	conn = MySQLdb.connect(host=c["host"], user=c["user"], passwd=c["passwd"], charset=c["charset"], db=c["db"])
	cursor = conn.cursor(cursorclass = MySQLdb.cursors.DictCursor)
	cursor.execute("insert into account \
		(account_password, account_name, account_sex, account_username, account_work, account_position, account_phone,account_address,account_email,account_department, account_power)\
		value ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');\
		"%(account_password, account_name.encode('utf-8'), account_sex.encode('utf-8'), account_username.encode('utf-8'), account_work.encode('utf-8'), account_position.encode('utf-8'), account_phone.encode('utf-8'),account_address.encode('utf-8'),account_email.encode('utf-8'),account_department.encode('utf-8'),account_power))
	conn.commit()
	conn.close()
Example #3
0
File: index.py Project: lhang/TDOA
	def POST(self):
		user = web.input().user
		#md5加密存储密码
		passwd = data.md5(web.input().passwd)
		ident = data.checkin(user)
		checkcode = web.input().checkcode
		try:
			if checkcode != session.checkcode:
				session.login = 0
				return render_template(type=0,template_name='login.html',error="验证码错误")

			elif len(ident)==0 :
				session.login = 0
				return render_template(type=0,template_name='login.html',error="用户名不存在")
			elif passwd == ident[0]['account_password']:
				session.login = 1
				session.user = user
				session.type = ident[0]['account_name']
				return json.dumps({"statusCode":"200", "message":"登录成功", "callbackType":"closeCurrent"})
			else:
				session.login = 0
				return render_template(type=0,template_name='login.html',error="密码错误")
		except:
			session.login = 0
			return render_template(type=0,template_name='login.html',error="系统错误")
Example #4
0
File: index.py Project: lhang/TDOA
	def POST(self):
		user = web.input().user
		#md5加密存储密码
		passwd = data.md5(web.input().passwd)
		ident = data.checkin(user)
		checkcode = web.input().checkcode

		try:
			if checkcode != session.checkcode:
				session.login = 0
				return render_template(type=0,template_name='login.html',error="验证码错误")
			elif len(ident)==0 :
				session.login = 0
				return render_template(type=0,template_name='login.html',error="用户名不存在")
			elif passwd == ident[0]['account_password']:
				session.login = 1
				session.user = user
				session.type = ident[0]['account_name']
				return render_template(type=session.type,template_name='index.html',user=session.user)
			else:
				session.login = 0
				return render_template(type=0,template_name='login.html',error="密码错误")
		except Exception, e:
			print 'login error', e
			session.login = 0
			return render_template(type=0,template_name='login.html',error="系统错误")
Example #5
0
def account_save(account_name, account_sex, account_username, account_work, account_position, account_phone,account_address,account_email,account_department, account_power):
	#存储账号信息
	#设置默认密码user:123456, admin: admin
	if account_name == 'user':
		account_password = data.md5('123456')
	elif account_name == 'admin':
		account_password = data.md5('admin')
	c = data.SQLconn()
	conn = MySQLdb.connect(host=c["host"], user=c["user"], passwd=c["passwd"], charset=c["charset"], db=c["db"])
	cursor = conn.cursor(cursorclass = MySQLdb.cursors.DictCursor)
	cursor.execute("insert into ACCOUNT \
		(account_password, account_name, account_sex, account_username, account_work, account_position, account_phone,account_address,account_email,account_department, account_power)\
		value ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');\
		"%(account_password, account_name.encode('utf-8'), account_sex.encode('utf-8'), account_username.encode('utf-8'), account_work.encode('utf-8'), account_position.encode('utf-8'), account_phone.encode('utf-8'),account_address.encode('utf-8'),account_email.encode('utf-8'),account_department.encode('utf-8'),account_power))
	conn.commit()
	conn.close()
Example #6
0
File: index.py Project: haohy/TDOA
	def POST(self):
		user = web.input().user
		#md5加密存储密码
		passwd = data.md5(web.input().passwd)
		ident = data.checkin(user)
		checkcode = web.input().checkcode
		try:
			if checkcode != session.checkcode:
				session.login = 0
				return render_template(type=0,template_name='login.html',error="验证码错误")

			elif len(ident)==0 :
				session.login = 0
				return render_template(type=0,template_name='login.html',error="用户名不存在")
			elif passwd == ident[0]['account_password']:
				session.login = 1
				session.user = user
				session.type = ident[0]['account_name']
				return json.dumps({"statusCode":"200", "message":"登录成功", "callbackType":"closeCurrent"})
			else:
				session.login = 0
				return render_template(type=0,template_name='login.html',error="密码错误")
		except:
			session.login = 0
			return render_template(type=0,template_name='login.html',error="系统错误")
Example #7
0
File: index.py Project: haohy/TDOA
	def POST(self):
		user = web.input().user
		#md5加密存储密码
		passwd = data.md5(web.input().passwd)
		ident = data.checkin(user)
		checkcode = web.input().checkcode

		try:
			if checkcode != session.checkcode:
				session.login = 0
				return render_template(type=0,template_name='login.html',error="验证码错误")
			elif len(ident)==0 :
				session.login = 0
				return render_template(type=0,template_name='login.html',error="用户名不存在")
			elif passwd == ident[0]['account_password']:
				session.login = 1
				session.user = user
				session.type = ident[0]['account_name']
				return render_template(type=session.type,template_name='index.html',user=session.user)
			else:
				session.login = 0
				return render_template(type=0,template_name='login.html',error="密码错误")
		except Exception, e:
			print 'login error', e
			session.login = 0
			return render_template(type=0,template_name='login.html',error="系统错误")