예제 #1
0
def is_friend(friend1, friend2):
	"""检查两个用户是否是好友关系"""
	tmp = friend1
	if friend1 > friend2:
		tmp = friend1
		friend1 = friend2
		friend2 = tmp
	return database.is_exist("""select * from friends where (friend1 = '%s' and friend2 = '%s') """ % (friend1, friend2))
예제 #2
0
def save(u_name, r_name, sex, birth_year, birth_month, birth_day, 
	school_type, school_name, school_grade):
	"""保存用户的基本信息"""
	if database.is_exist('select * from baseInfo where uName = "%s" ' % u_name):
		database.query("""update baseInfo set realName = '%s', sex = '%s', birthYear = %d, birthMonth = %d,
			birthDay = %d, school_type='%c', school_name = '%s', school_grade = %d where uName = '%s'""" %
			(r_name, sex, birth_year, birth_month, birth_day, school_type, school_name, school_grade, u_name))
	else:
		database.query("""insert into baseInfo values('%s', '%s', '%c', %d, %d, %d, '%s', '%s', %d) """ % 
		(u_name, r_name, sex, birth_year, birth_month, birth_day, school_type, school_name, school_grade))
예제 #3
0
파일: says.py 프로젝트: a314702203/Mosquito
def is_author(sayId, u_name):
	"""验证u_name是否是sayId说说的作者"""
	return database.is_exist("select sayId from say where sayId = %d and author = '%s'" % (sayId, u_name))
예제 #4
0
def is_valid_user(uname, pwd):
	pwd = md5.md5(pwd)
	sql = 'select * from user where uname = "%s" and pwd = "%s"' % (uname, pwd)
	return database.is_exist(sql)
예제 #5
0
파일: user.py 프로젝트: a314702203/Mosquito
def is_valid(u_name, u_pwd):
	"""通过用户名和密码来认证用户的合法性"""
	pwd = code.code_undecode(u_pwd)
	if database.is_exist("select * from user where uName='%s' and uPwd='%s'" % (u_name, pwd)):
		return True
	return False
예제 #6
0
파일: user.py 프로젝트: a314702203/Mosquito
def u_email_logined(u_email):
	"""用户e-mail是否已经被注册了"""
	if database.is_exist("select * from user where uEmail = '%s'" % u_email):
		return True
	return False
예제 #7
0
파일: user.py 프로젝트: a314702203/Mosquito
def u_name_logined(u_name):
	"""用户名是否已经被注册了"""
	b = database.is_exist("select * from user where uName = '%s'" % u_name)
	if b:
		return True
	return False
예제 #8
0
def is_not_confirm(friendFrom, friendTo):
	"""相应的表项存在但未确认"""
	return database.is_exist("select * from addFriend where friendFrom = '%s' and friendTo = '%s' and state = '0'" 
		% (friendFrom, friendTo))
예제 #9
0
def is_exist(friendFrom, friendTo):
	"""相应的表项是否已经存在"""
	return database.is_exist("select * from addFriend where friendFrom = '%s' and friendTo = '%s'" 
		% (friendFrom, friendTo))