def run(): while True: print(""" *********************************** 欢迎来到新闻浏览器 1.查看新闻 2.登录 3.注册 4.退出 *********************************** """) choice=input("请输入你的选择:").strip() if choice == "1": user.show_news() elif choice == "2": jieguo,username=common.logginger() if jieguo == 1: admin.main(username) logger1.info("%s登陆成功"%username) elif jieguo == 0: user.main(username) common.logger2.info("%s登陆成功"%username) elif choice == "3": dic_user = DB_handler.get_user_read() common.zhuce(dic_user) elif choice == "4": exit(0) else: print("您输入的不正确,请重新输入!!!")
def logginger(): global logging_user, username dic_user = DB_handler.get_user_read() while True: user_name = input("请输入你的姓名: ").strip() if user_name not in dic_user: print(""" 该用户不存在!!! 1.注册 2.重新输入 3.退出 """) choice = input("请选择: ") if choice == "1": jieguo = zhuce(dic_user) if jieguo == True: return elif choice == "2": continue elif choice == "3": return else: print("你输入的不正确!!!") else: if dic_user[user_name]["lock"] == False: count = 0 if time.time() - dic_user[user_name]["logger_time"] >= 300: while count <= 2: pwd = input("请输入您的密码:").strip() pwd1 = hashlib_pwd(pwd) if pwd1 == dic_user[user_name]["pwd"]: print("登陆成功") dic_user[user_name]["logger_time"] = 0 DB_handler.get_user_write(dic_user) logging_user = True username = user_name return dic_user[user_name]["type"], user_name else: print("密码不正确,请重新输入") count += 1 else: print("您输入次数过多,账户已被锁定300秒") dic_user[user_name]["logger_time"] = time.time() DB_handler.get_user_write(dic_user) else: print("账户之前被锁定时间未超过300秒") continue else: print("您的账户已被管理员锁定,请联系管理员") continue