示例#1
0
def userLogin(phone, password):
    db.execute('select * from users where `phone`=%s', (phone,))
    result = db.fetchone()
    if result:
        if checkPwd(password, result[3]):
            return result
    return None
示例#2
0
def checkPhone(phone):
    db.execute('select * from users where `phone`=%s',(phone,))
    result = db.fetchone()
    dictReturn=dict()
    uniqueness=(result==None)
    phoneLength=((len(phone)==11)and phone[0]=='1')
    return {
        'phoneLength':phoneLength,
        'uniqueness':uniqueness}
示例#3
0
def userLogin(username, password):
    db.execute('SELECT * FROM users_info WHERE `username`=%s ', (username, ))
    result = db.fetchone()
    #先根据用户名选取该行
    if result:
        if checkPwd(password, result[2]):
            #检验密码
            return result
    return None
示例#4
0
def checkPhone(phone):
    db.execute('select * from b_screen where `phone`=%s', (phone, ))
    result = db.fetchone()
    uniqueness = (result == None)
    phoneLength = ((len(phone) == 11) and phone[0] == '1')
    if (uniqueness and phoneLength):
        return True
    else:
        return False
示例#5
0
文件: database.py 项目: Tobin717/BBT
def userLogin(username, password):
    db.execute('select * from user_name where `user_name`=%s', (username, ))
    result = db.fetchone()
    # result若存在, 在本例中是一个list, [1, "abc", ".....加密密码....."]
    if result:
        if checkPwd(password, result[2]):
            return result
    # 密码错误或用户名不存在
    return None
def loginin(data):
    username = data['username']
    password = encrypt(data['password'])
    db.execute('select * from users where `username`=%s', (username, ))
    result = db.fetchone()
    if (result) and checkPwd(password, result[2]):
        session['user_id'] = result[0]
        return {"errcode": 200, "errmsg": "登录成功"}
    else:
        return {"errcode": 400, "errmsg": "登录失败"}
示例#7
0
def BulletProcess(phone, content):
    db.execute('select * from b_screen where `phone`=%s', (phone, ))
    result = db.fetchone()
    userid = result[0]
    time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    db.execute(
        'insert into c_bullet (`time`, `content`,`userid`) values (%s, %s, %s)',
        (time, content, userid))
    ContentProcessed = automaton(content)
    return ContentProcessed
def checkPhone(phone):
    db.execute('select * from spring where `phone`=%s', (phone, ))
    result = db.fetchone()
    dictReturn = dict()
    uniqueness = (result == None)
    phoneLength = ((len(phone) == 11) and phone[0] == '1')
    if (phoneLength and uniqueness):
        dictReturn = {'phoneLength': True, 'uniqueness': True}
    elif ((phoneLength == True) and (uniqueness == False)):
        dictReturn = {'phoneLength': True, 'uniqueness': False}
    elif ((phoneLength == False) and (uniqueness == True)):
        dictReturn = {'phoneLength': False, 'uniqueness': True}
    else:
        dictReturn = {'phoneLength': False, 'uniqueness': False}
    return dictReturn
示例#9
0
def getUser(anId):
    db.execute('select * from users where `id`= %s',(anId,))
    finalGot=db.fetchone()
    return finalGot[1]
示例#10
0
def num_images():
    db = get_db(False)
    db.execute('select count(*) from instaclone_images')
    total_count = db.fetchone()[0]
    return total_count
示例#11
0
def findUser(phone):
    db.execute('select * from b_screen where `phone`=%s', (phone, ))
    result = db.fetchone()
    return result