陶远航 发表于 2023-11-19 14:14:10

用户登录9.0

本帖最后由 陶远航 于 2025-7-8 16:59 编辑

用户登录,一直是一个有趣(没啥用)的程序,自从用户登录6.0以来一直在升级小工具的功能,忽略了增加一些实用的功能,所以用户登录一直都没有实际用处。

现在,用户登录开发由不断增加安全性转到不断增加功能,当然也会增加安全性。

用户登录9.0已经完成了一个重要任务:代码重构。这有利于插件的编写,也有利于让代码更简洁。

以下是用户登录9.0更新的内容:

1.代码重构★
2.检查更新★
3.完善插件功能★
4.完善验证码功能★

检查更新需要用到网络服务,请知晓!

用户登录9.0完整代码以及官方推出的插件:

代码:
global gly_login
gly_login = 0
import requests
from PIL import Image, ImageTk
from io import BytesIO
import os
import tkinter as tk
import tkinter.messagebox
from Crypto.Cipher import AES
import base64
import hashlib
import easygui
import subprocess

global ver
ver=9.0

try:
    with open("banned_user.txt") as f:
      banned_user_list=eval(f.read())
except:
    with open("banned_user.txt","w") as f:
      f.write("[]")
      banned_user_list=[]

BLOCK_SIZE = 16# Bytes
pad = lambda s: s + (BLOCK_SIZE - len(s) % BLOCK_SIZE) * chr(
    BLOCK_SIZE - len(s) % BLOCK_SIZE
)
unpad = lambda s: s[: -ord(s)]

class main:
    def aesEncrypt(self,key, data):
      key = key.encode("utf8")
      data = pad(data)
      cipher = AES.new(key, AES.MODE_ECB)
      result = cipher.encrypt(data.encode())
      encodestrs = base64.b64encode(result)
      enctext = encodestrs.decode("utf8")
      return enctext

    def aesDecrypt(self,key, data):
      """

      :param key: 密钥
      :param data: 加密后的数据(密文)
      :return:明文
      """
      key = key.encode("utf8")
      data = base64.b64decode(data)
      cipher = AES.new(key, AES.MODE_ECB)
      text_decrypted = unpad(cipher.decrypt(data))
      text_decrypted = text_decrypted.decode("utf8")
      return text_decrypted
    def isgly(self):
      try:
            with open("gly.txt") as f:
                if f.read() == "enabled":
                  return True
                else:
                  return False
      except:
            return False
    def saveinfo(self):
      with open("nameandpwd.txt", "w") as f:
            f.write(self.aesEncrypt(key="taoyuanhang66666", data=str(nameandpwd)))

    def readinfo(self):
      with open("nameandpwd.txt") as f:
            nameandpwd = eval(self.aesDecrypt(key="taoyuanhang66666", data=f.read()))
    def about(self,a=1):
      if a == "1":
            tk.messagebox.showinfo(
                "About",
                """用户登录(管理员) by 陶远航
版本:9.0开发版
注意,8.0版本为用户登录的最后一个稳定版
9.0不是正式版,是一个内部测试版本,还有很多不完善的地方
Copyright(c) 2023 陶远航
Copyright(c) 2023 liuhongrun2022
All Rights Reserved.

程序及源代码仅供学习交流,
未经作者允许不可用于商业用途!
""",
            )
      elif a == "2":
            tk.messagebox.showinfo(
                "About",
                """你正在管理员模式查看关于
用户登录(管理员) by 陶远航
版本:9.0开发版
注意,8.0版本为用户登录的最后一个稳定版
9.0不是正式版,是一个内部测试版本,还有很多不完善的地方
Copyright(c) 2023 陶远航
Copyright(c) 2023 liuhongrun2022
All Rights Reserved.

程序及源代码仅供学习交流,
未经作者允许不可用于商业用途!
""",
            )
    def feedback(self):
      import smtplib
      import re
      from os import environ
      from os.path import exists
      from platform import system, node
      from time import strftime
      from email.mime.text import MIMEText
      from email.utils import formataddr
      from random import randint
      from easygui import enterbox

      title = "用户登录 9.0版"
      my_sender = "advance_software@126.com"
      my_pass = "QFAQPLFQZRZBMVWQ"
      dt = strftime("%Y-%m-%d %H:%M:%S")
      my_user = "taoyuanhang66@outlook.com"
      username = environ["USERNAME"]
      system = system()
      computer = node()
      number = enterbox("请输入反馈内容:")
      err = Exception

      def mail():
            global err
            ret = True
            try:
                msg = MIMEText(number, "plain", "utf-8")
                msg["From"] = formataddr()
                msg["To"] = formataddr(["", my_user])
                msg["Subject"] = "用户使用反馈"
                server = smtplib.SMTP_SSL("smtp.126.com", 465)
                server.login(my_sender, my_pass)
                server.sendmail(
                  my_sender,
                  [
                        my_user,
                  ],
                  msg.as_string(),
                )
                server.quit()
            except Exception as e:
                ret = False
                err = str(e)
            return ret

      def checkmail(email):
            reg = "\w+[@]+(\.+)+"
            result = re.findall(reg, email)
            if result:
                ret = mail()
                if ret:
                  tk.messagebox.showinfo("反馈", "发送成功!")
                else:
                  tk.messagebox.showerror("反馈", "邮件发送失败!")
            else:
                tk.messagebox.showerror("用户登录", "您的输入不合法,请重新输入!")

      if __name__ == "__main__":
            checkmail(my_user)

    def get_verify_code(self):
      url = "https://www.mxnzp.com/api/verifycode/code"
      data = {
            "app_id":"rgihdrm0kslojqvm",
            "app_secret":"WnhrK251TWlUUThqaVFWbG5OeGQwdz09",
            "len": "4",
            "type": "0",
      }
      response = requests.post(url,data=data)
      if response.status_code==200:
            m=response.json()["data"]["verifyCode"]
            img=response.json()["data"]["verifyCodeImgUrl"]
      return (m,img)
   
    def returntrue(self):
      global flag
      flag=True
      root.quit()
      root.destroy()

    def show_image_from_url(self,args):
      global root
      root = tk.Toplevel(win)
      root.title("验证码页面")
      response = requests.get(args)
      img_data = BytesIO(response.content)
      img = Image.open(img_data)
      img = ImageTk.PhotoImage(img)

      label = tk.Label(root, image=img)
      label.place(x=10,y=10)

      labtext=tk.Label(root,text="请输入验证码:")
      labtext.place(x=40,y=90)
      var_code=tk.StringVar()
      var_code.set("")
      ent_code=tk.Entry(root,textvariable=var_code,width=10)
      ent_code.place(x=40,y=120,width=100)
      butok=tk.Button(root,text="确定",command=(lambda:self.returntrue() if args.upper()==var_code.get().upper() else lambda:tk.messagebox.showerror("错误","验证码错误")))
      butok.place(x=10,y=150)
      root.mainloop()
      return flag
   
    def tools(self,name="Guest", is_gly=False,email=False):
      try:
            with open("plugin2.txt","r") as f:
                plugin2info=f.read()
      except:
            with open("plugin2.txt","w") as f:
                f.write("0")
      try:
            with open("plugin3.txt","r") as f:
                plugin3info=f.read()
      except:
            with open("plugin3.txt","w") as f:
                f.write("0")
      import easygui

      while True:
            list_tools = [
                "打开记事本",
                "简易计算器",
                "修改密码",
                "返回主窗口",
                "摄氏度转华氏度",
                "华氏度转摄氏度",
                "关于",
                "查看发言板",
                "我要发言",
                "在线发言版",
                "意见反馈",
                "用户信息",
                "退出",
            ]
            if is_gly == True:
                list_tools = [
                  "打开记事本",
                  "简易计算器",
                  "返回主窗口",
                  "摄氏度转华氏度",
                  "华氏度转摄氏度",
                  "在线发言版",
                  "关于",
                  "意见反馈",
                  "用户信息",
                  "退出",
                ]
            elif email==True:
                list_tools = [
                  "打开记事本",
                  "简易计算器",
                  "返回主窗口",
                  "摄氏度转华氏度",
                  "华氏度转摄氏度",
                  "在线发言版",
                  "关于",
                  "意见反馈",
                  "用户信息",
                  "退出",
                ]
            if name=="Guest":
                if plugin2info=="1":
                  list_tools.append("我要发言")
                if plugin3info=="1":
                  list_tools.append("查看发言板")
            if is_gly==True:
                list_tools.append("我要发言")
                list_tools.append("查看发言板")
            
            choice = easygui.choicebox(msg="选择小工具", title="选择小工具", choices=list_tools)
            if choice == "打开记事本":
                subprocess.Popen(["notepad.exe"])
            elif choice == "简易计算器":
                try:
                  shizi = easygui.enterbox("输入要计算的式子:")
                  tk.messagebox.showinfo("简易计算器", eval(shizi))
                except:
                  tk.messagebox.showerror("简易计算器", "输入错误,请重新输入")
            elif choice == "退出":
                if tk.messagebox.askyesno("小工具", "确定退出吗?") == True:
                  break
                else:
                  pass
            elif choice == "意见反馈":
                self.feedback()
            elif choice == "摄氏度转华氏度":
                try:
                  ssd = float(easygui.enterbox("请输入摄氏度:"))
                  hsd = format(ssd * 1.8 + 32, ".3f")
                  tk.messagebox.showinfo("摄氏度转华氏度", hsd)
                except:
                  tk.messagebox.showinfo("摄氏度转华氏度", "请输入正确的值")
            elif choice == "华氏度转摄氏度":
                try:
                  hsd = float(easygui.enterbox("请输入华氏度:"))
                  ssd = format((hsd - 32) / 1.8, ".3f")
                  tk.messagebox.showinfo("华氏度转摄氏度", ssd)
                except:
                  tk.messagebox.showinfo("摄氏度转华氏度", "请输入正确的值")
            elif choice == "小游戏":
                try:
                  os.system("plane_main.exe")
                except:
                  tk.messagebox.showerror("错误", "没有小游戏")
            elif choice == "关于":
                if is_gly == True:
                  self.about("2")
                else:
                  self.about("1")
            elif choice == "修改密码":
                try:
                  pwd = nameandpwd
                except:
                  tk.messagebox.showerror("", "未找到此用户!")
                if easygui.enterbox("请输入旧密码") == pwd:
                  pwd_new = easygui.enterbox("请输入新密码")
                  nameandpwd = pwd_new
                  with open("nameandpwd.txt", "w") as f:
                        f.write(
                            self.aesEncrypt(key="taoyuanhang66666", data=str(nameandpwd))
                        )
                        tk.messagebox.showinfo("", "修改成功,需要重新登录!")
                        main()
                        break
                else:
                  tk.messagebox.showerror("", "密码错误!")
            elif choice=="查看发言板":
                try:
                  with open("talk.txt","r") as f:
                        msg=f.read()
                        if msg=="":
                            raise
                        else:
                            easygui.msgbox(msg)
                except:
                  with open("talk.txt","a") as f:
                        tk.messagebox.showinfo("","暂时没有人发信息! ")
            elif choice=='我要发言':
                try:
                  with open("talk.txt","a") as f:
                        f.write(name+":\n"+easygui.enterbox("请输入你想说的:")+"\n")
                        tk.messagebox.showinfo("","发言成功!")
                except:
                  tk.messagebox.showinfo("","发言失败!")
            elif choice=="在线发言版":
                tk.messagebox.showinfo("","非常抱歉,留言板由于网站接口升级,已关闭")
            elif choice == "用户信息":
                tk.messagebox.showinfo("用户信息", ("用户名:", name))
            elif choice == "返回主窗口":
                start()
                break
            else:
                if tk.messagebox.askyesno("小工具", "你确定要退出吗") == True:
                  break
                else:
                  pass
   
    def b(self):
      '''无用函数'''
      try:
            with open("a.txt") as f:
                temp = f.read()
            if temp == "ok":
                with open("a.txt", "w") as f:
                  f.write("4")
                tk.messagebox.showerror(title="用户登录", message="还有4次机会,错误次数过多会导致账户永久锁定!")
            else:
                try:
                  temp = int(temp)
                except:
                  tk.messagebox.showerror(title="用户登录", message="账号异常!")
                if temp == 1:
                  tk.messagebox.showerror(
                        title="用户登录", message="错误次数过多,账户已永久锁定,请重新注册!"
                  )
                else:
                  temp = temp - 1
                  with open("a.txt", "w") as f:
                        f.write(str(temp))
                  tk.messagebox.showerror(
                        title="用户登录", message=("还有", str(temp), "次机会,错误次数过多会导致账户永久锁定!")
                  )
      except:
            with open("a.txt", "w") as f:
                f.write("4")
                tk.messagebox.showerror("用户登录", "还有4次机会,错误次数过多会导致账户永久锁定!")
    def login(self):
      try:
            win.attributes("-topmost", 0)
      except:
            pass
      try:
            with open("nameandpwd.txt") as f:
                nameandpwd = eval(self.aesDecrypt(key="taoyuanhang66666", data=f.read()))
      except:
            with open("nameandpwd.txt", "w") as f:
                f.write(
                  self.aesEncrypt(key="taoyuanhang66666", data="{'admin': 'python@16'}")
                )
            nameandpwd = {"admin": "python@16"}
      if self.show_image_from_url(self.get_verify_code())==True:
            pass
      else:
            return
      name = var_Name.get()
      if name in banned_user_list:
            tk.messagebox.showerror("错误", '你已被禁止,无法登录,请联系管理员!')
            return
      elif "*" in banned_user_list:
            tk.messagebox.showerror("错误", '管理员已禁止所有人登录!')
            return
      pwd = var_Pwd.get()
      try:
            if nameandpwd == pwd:
                if name.upper() == "SYSTEM":
                  tk.messagebox.showerror("错误", '不能以"SYSTEM"为用户名')
                elif name in banned_user_list:
                  tk.messagebox.showerror("错误", '你已被禁止,无法登录,请联系管理员!')
                elif "*" in banned_user_list:
                  tk.messagebox.showerror("错误", '管理员已禁止所有人登录!')
                else:
                  tk.messagebox.showinfo("用户登录", "登录成功!")
                  with open("a.txt", "w") as f:
                        f.write("ok")
                  win.quit()
                  win.destroy()
                  self.tools(name)
            else:
                tk.messagebox.showerror("用户登录", "密码错误!")
      except:
            tk.messagebox.showerror("用户登录", "没有此用户!")

    def zhuce(self):
      try:
            win.attributes("-topmost", 0)
      except:
            pass
      try:
            win.attributes("-topmost", 0)
      except:
            pass
      try:
            with open("nameandpwd.txt") as f:
                nameandpwd = eval(self.aesDecrypt(key="taoyuanhang66666", data=f.read()))
      except:
            with open("nameandpwd.txt", "w") as f:
                f.write(
                  self.aesEncrypt(key="taoyuanhang66666", data="{'admin': 'python@16'}")
                )
            nameandpwd = {"admin": "python@16"}
      name = var_Name.get()
      pwd = var_Pwd.get()
      try:
            nameandpwd
            tk.messagebox.showerror("", "该用户名已被注册,请换一个吧!")
      except:
            if name == "" or pwd == "":
                tk.messagebox.showerror(title="警告", message="用户名或密码不能为空")
            if name.upper() == "SYSTEM":
                tk.messagebox.showerror(title="警告", message='不能以"SYSTEM"作为用户名')
            else:
                if len(pwd) <= 5:
                  tk.messagebox.showinfo(title="警告", message="密码太短了,长度不能低于6个字符!")
                elif pwd.count(pwd) == len(pwd):
                  tk.messagebox.showinfo(title="警告", message="密码不安全,换个不容易被猜到的密码吧!")
                elif pwd in [
                  "A123456",
                  "a123456",
                  "a1234567",
                  "A1234567",
                  "Aa1234567",
                  "password",
                  "Password",
                  "password1",
                  "a123456",
                  "qwerty",
                  "password01",
                  "picture1",
                ]:
                  tk.messagebox.showinfo(title="警告", message="密码不安全,换个不容易被猜到的密码吧!")
                else:
                  pwd2 = easygui.passwordbox("请再次输入密码:")
                  if pwd == pwd2:
                        nameandpwd = pwd
                        with open("nameandpwd.txt", "w") as f:
                            f.write(
                              self.aesEncrypt(key="taoyuanhang66666", data=str(nameandpwd))
                            )
                        tk.messagebox.showinfo("注册", "注册成功!")
                  else:
                        tk.messagebox.showerror("注册", "密码不一致!")
    def _quit(self):
      try:
            win.attributes("-topmost", 0)
      except:
            pass
      import smtplib
      import re
      from os import environ
      from os.path import exists
      from platform import system, node
      from time import strftime
      from email.mime.text import MIMEText
      from email.utils import formataddr
      from random import randint
      from easygui import enterbox

      title = "用户登录 9.0版"
      my_sender = "advance_software@126.com"
      my_pass = "QFAQPLFQZRZBMVWQ"
      dt = strftime("%Y-%m-%d %H:%M:%S")
      my_user = enterbox("请输入邮箱:")
      username = environ["USERNAME"]
      system = system()
      computer = node()
      number = randint(100000, 999999)
      number = str(number)
      err = Exception

      def mail():
            global err
            ret = True
            try:
                msg = MIMEText(number, "plain", "utf-8")
                msg["From"] = formataddr(["陶远航", my_sender])
                msg["To"] = formataddr(["", my_user])
                msg["Subject"] = "用户登录的验证码"
                server = smtplib.SMTP_SSL("smtp.126.com", 465)
                server.login(my_sender, my_pass)
                server.sendmail(
                  my_sender,
                  [
                        my_user,
                  ],
                  msg.as_string(),
                )
                server.quit()
            except Exception as e:
                ret = False
                err = str(e)
            return ret

      def checkmail(email):
            reg = "\w+[@]+(\.+)+"
            result = re.findall(reg, email)
            if result:
                ret = mail()
                if ret:
                  num = enterbox("发送成功!请耐心等待并输入您的验证码:", title)
                  if num == str(number):
                        tk.messagebox.showinfo("用户登录", "登录成功!")
                        win.quit()
                        win.destroy()
                        self.tools(email,email=True)
                  else:
                        tk.messagebox.showinfo("用户登录", "登录失败!")
                else:
                  tk.messagebox.showerror("用户登录", "邮件发送失败!")
            else:
                tk.messagebox.showerror("用户登录", "您的输入不合法,请重新输入!")

      if __name__ == "__main__":
            checkmail(my_user)

    def plugins(self):
      plugin_list=["退出","允许游客登录","禁止游客登录","自定义插件"]
      while True:
            choice = easygui.choicebox(msg="当前有1个插件可以使用", title="插件", choices=plugin_list)
            if choice=="允许游客登录":
                with open("plugin1.txt","w") as f:
                  f.write("on")
                tk.messagebox.showinfo("游客登录", "修改成功!")
                win.quit()
                win.destroy()
                main()
                break
            elif choice=="禁止游客登录":
                with open("plugin1.txt","w") as f:
                  f.write("off")
                tk.messagebox.showinfo("游客登录", "修改成功!")
                win.quit()
                win.destroy()
                main()
                break
            elif choice=="自定义插件":
                try:
                  with open("plugins.txt") as f:
                        dft=f.read()
                except:
                  dft=""
                plugin=easygui.textbox("请输入你的插件代码:", "插件", text=dft)
                if plugin==None:
                  pass
                else:
                  with open("plugins.txt","w") as f:
                        f.write(plugin)
            else:
                if tk.messagebox.askyesno("警告", "你确定要退出吗?"):
                  break
   
    def gly(self):
      try:
            with open("nameandpwd.txt") as f:
                nameandpwd = eval(self.aesDecrypt(key="taoyuanhang66666", data=f.read()))
      except:
            with open("nameandpwd.txt", "w") as f:
                f.write(
                  self.aesEncrypt(key="taoyuanhang66666", data="{'admin': 'python@16'}")
                )
            nameandpwd = {"admin": "python@16"}
      if self.isgly():
            listgly = [
                "退出",
                "注销账号",
                "查看所有用户",
                "添加账户",
                "查看密码",
                "强制登录",
                "带有用户名的强制登录(高级)",
                "关于",
                "禁止用户",
                "解除禁止",
                "插件",
                #"解除某用户禁言",
                #"禁言某用户",
                "允许游客发言",
                "禁止游客发言",
                "允许游客查看留言板",
                "禁止游客查看留言板",
                "清空发言板"
            ]
      else:
            pass
      while True:
            if self.isgly():
                choice = easygui.choicebox(msg="我是管理员", title="我是管理员", choices=listgly)
            else:
                tk.messagebox.showerror("", "你没有管理员权限,请退出!")
                break
            if choice == "注销账号":
                self.readinfo()
                if self.isgly():
                  pass
                else:
                  tk.messagebox.showerror("", "你没有管理员权限,请退出!")
                  break
                name = easygui.enterbox("请输入用户名", "请输入用户名")
                try:
                  nameandpwd.pop(name)
                  with open("nameandpwd.txt", "w") as f:
                        f.write(
                            self.aesEncrypt(key="taoyuanhang66666", data=str(nameandpwd))
                        )
                  tk.messagebox.showinfo("注销", "注销成功!")
                except:
                  tk.messagebox.showerror("错误", "没有此用户!")
            elif choice == "查看所有用户":
                self.readinfo()
                if self.isgly():
                  pass
                else:
                  tk.messagebox.showerror("", "你没有管理员权限,请退出!")
                  break
                nms = list(nameandpwd.keys())
                tk.messagebox.showinfo("用户", nms)
            elif choice == "添加账户":
                self.readinfo()
                if self.isgly():
                  pass
                else:
                  tk.messagebox.showerror("", "你没有管理员权限,请退出!")
                  break
                name = easygui.enterbox("请输入用户名")
                nameandpwd = easygui.enterbox("请输入密码")
                with open("nameandpwd.txt", "w") as f:
                  f.write(self.aesEncrypt(key="taoyuanhang66666", data=str(nameandpwd)))
                tk.messagebox.showinfo("", "添加成功!")

            elif choice == "查看密码":
                self.readinfo()
                if self.isgly():
                  pass
                else:
                  tk.messagebox.showerror("", "你没有管理员权限,请退出!")
                  break
                try:
                  tk.messagebox.showinfo(
                        "密码", nameandpwd
                  )
                except:
                  tk.messagebox.showerror("警告", "没有此用户")
            elif choice == "强制登录":
                self.readinfo()
                if self.isgly():
                  pass
                else:
                  tk.messagebox.showerror("", "你没有管理员权限,请退出!")
                  break
                try:
                  win.quit()
                  win.destroy()
                except:
                  pass
                self.tools("SYSTEM", is_gly=True)
            elif choice == "带有用户名的强制登录(高级)":
                self.readinfo()
                if self.isgly():
                  pass
                else:
                  tk.messagebox.showerror("", "你没有管理员权限,请退出!")
                  break
                try:
                  win.quit()
                  win.destroy()
                except:
                  pass
                self.tools(easygui.enterbox("请输入登录的用户名"), is_gly=True)
            elif choice == "关于":
                if self.isgly():
                  pass
                else:
                  tk.messagebox.showerror("", "你没有管理员权限,请退出!")
                  break
                self.about("2")
            elif choice=="禁止用户":
                ban_user=easygui.enterbox("请输入被禁止的用户名(输入*全部禁止):")
                banned_user_list.append(ban_user)
                try:
                  with open("banned_user.txt","w") as f:
                        f.write(str(banned_user_list))
                        tk.messagebox.showinfo("禁止用户","禁止成功!")
                except:
                  tk.messagebox.showinfo("禁止用户","禁止失败!")
            elif choice=="解除禁止":
                ban_user=easygui.enterbox("请输入被禁止的用户名(输入*解除除单独禁止外的用户):")
                banned_user_list.remove(ban_user)
                try:
                  with open("banned_user.txt","w") as f:
                        f.write(str(banned_user_list))
                        tk.messagebox.showinfo("禁止用户","解除成功!")
                except:
                  tk.messagebox.showinfo("禁止用户","解除失败!")
            elif choice=="插件":
                self.plugins()
                return
            elif choice=="允许游客发言":
                with open("plugin2.txt","w") as f:
                  f.write("1")
                tk.messagebox.showinfo("","设置成功!")
            elif choice=="禁止游客发言":
                with open("plugin2.txt","w") as f:
                  f.write("0")
                tk.messagebox.showinfo("","设置成功!")
            elif choice=="允许游客查看留言板":
                with open("plugin3.txt","w") as f:
                  f.write("1")
                tk.messagebox.showinfo("","设置成功!")
            elif choice=="禁止游客查看留言板":
                with open("plugin3.txt","w") as f:
                  f.write("0")
                tk.messagebox.showinfo("","设置成功!")
            elif choice=="清空发言板":
                with open("talk.txt","w") as f:
                  f.write("")
            else:
                if tk.messagebox.askyesno("警告", "你确定要退出吗?"):
                  break

    def winset(self):
      winlist = ["更改标题", "将主窗口设置为可调整大小", "将主窗口设置为不可调整大小", "更改主窗口大小", "退出"]
      while True:
            choice = easygui.choicebox(msg="窗口设置", title="窗口设置", choices=winlist)
            if choice == "更改标题":
                win.title(easygui.enterbox("输入窗口标题", "输入窗口标题"))
            elif choice == "将主窗口设置为可调整大小":
                win.resizable(width=True, height=True)
            elif choice == "将主窗口设置为不可调整大小":
                win.resizable(width=False, height=False)
            elif choice == "更改主窗口大小":
                a = easygui.enterbox("输入窗口大小,如:250x150")
                try:
                  win.geometry(a)
                except:
                  tk.messagebox.showinfo("", "设置错误。注意:250x150中间的“x”要用乘号")
            else:
                break

    def more(self):
      try:
            win.attributes("-topmost", 0)
      except:
            pass
      try:
            with open("nameandpwd.txt") as f:
                nameandpwd = eval(self.aesDecrypt(key="taoyuanhang66666", data=f.read()))
      except:
            with open("nameandpwd.txt", "w") as f:
                f.write(
                  self.aesEncrypt(key="taoyuanhang66666", data="{'admin': 'python@16'}")
                )
            nameandpwd = {"admin": "python@16"}
      list_more = ["注销账号", "窗口设置", "窗口置顶", "取消窗口置顶", "管理员按钮激活", "取消激活管理员按钮", "退出"]
      while True:
            choice = easygui.choicebox(msg="更多", title="更多", choices=list_more)
            if choice == "退出":
                if tk.messagebox.askyesno("警告", "你确定要退出吗"):
                  break
            elif choice == "注销账号":
                self.readinfo()
                name = easygui.enterbox("输入你要注销的用户名:", "注销")
                pwd = easygui.passwordbox("输入此用户的密码:", "注销")
                try:
                  pwd2 = nameandpwd
                  if pwd == pwd2:
                        if tk.messagebox.askyesno("警告", "你确定要注销吗?"):
                            nameandpwd.pop(name)
                            with open("nameandpwd.txt", "w") as f:
                              f.write(
                                    self.aesEncrypt(
                                        key="taoyuanhang66666", data=str(nameandpwd)
                                    )
                              )
                            tk.messagebox.showinfo("注销", "注销成功!")
                  else:
                        tk.messagebox.showerror("警告", "密码错误!")
                except:
                  tk.messagebox.showerror("警告", "没有此用户!")
            elif choice == "取消激活管理员按钮":
                if tk.messagebox.askyesno("警告", "这将使你失去管理员权限,继续吗?"):
                  try:
                        with open("gly.txt") as f:
                            if f.read() == "enabled":
                              temp = True
                            else:
                              temp = False
                  except:
                        temp = False
                  if temp:
                        with open("gly.txt", "w") as f:
                            f.write("disabled")
                        but_gly = tk.Button(
                            win, text="我是管理员", command=self.glylogin, state="disabled"
                        )
                        but_gly.place(x=30, y=110, width=90, height=20)
                        tk.messagebox.showinfo("", "取消激活成功!")
                  else:
                        tk.messagebox.showinfo("", "你没有管理员权限")
            elif choice == "窗口设置":
                if self.isgly():
                  if self.mima():
                        self.winset()
                else:
                  tk.messagebox.showinfo("", "你没有管理员权限,无法进行此操作!")
            elif choice == "管理员按钮激活":
                try:
                  with open("gly.txt") as f:
                        temp = f.read()
                except:
                  temp = ""
                if temp == "enabled":
                  tk.messagebox.showinfo("", "您已激活,无需再次激活")
                elif (
                  hashlib.md5(
                        str(easygui.passwordbox("请输入激活密码")).encode()
                  ).hexdigest()
                  == "31cf31b94356a2a6137641698fdfe304"
                ):
                  with open("gly.txt", "w") as f:
                        f.write("enabled")
                  but_gly = tk.Button(win, text="我是管理员", command=self.glylogin)
                  but_gly.place(x=30, y=110, width=90, height=20)
                  tk.messagebox.showinfo("", "激活成功")
                else:
                  tk.messagebox.showerror("", "密码错误")
            elif choice == "窗口置顶":
                win.attributes("-topmost", 1)
                tk.messagebox.showinfo("", "置顶成功!")
            elif choice == "取消窗口置顶":
                win.attributes("-topmost", 0)
                tk.messagebox.showinfo("", "取消置顶成功!")
            else:
                if tk.messagebox.askyesno("警告", "你确定要退出吗"):
                  break

    def plugin1(self):
      win.quit()
      win.destroy()
      self.tools(email=True)

    def mima(self):
      tk.messagebox.showinfo(
            "管理员验证",
            """功能内测中或仅限管理员调试使用,
请确定你的管理员身份""",
      )
      glypwd = easygui.passwordbox("请输入密码:")
      if (
            hashlib.md5(str(glypwd).encode()).hexdigest()
            == "fd2e8045450ce3baca670d5cc1b3cd5f"
      ):
            glypwd = easygui.passwordbox("请输入第二层密码:")
            if (
                hashlib.md5(str(glypwd).encode()).hexdigest()
                == "31cf31b94356a2a6137641698fdfe304"
            ):
                return True
            else:
                tk.messagebox.showerror("", "密码错误!")
                return False
      else:
            tk.messagebox.showerror("", "密码错误!")
            return False
      
    def glylogin(self):
      if self.isgly():
            try:
                win.attributes("-topmost", 0)
            except:
                pass
            global gly_login
            if gly_login == 1:
                tk.messagebox.showinfo("", "已确定你的管理员身份,已自动登录")
                self.gly()
            elif self.isgly():
                if self.mima():
                  gly_login = 1
                  self.gly()
            else:
                if tk.messagebox.askyesno(
                  "",
                  """管理员按钮未激活,您的使用将会受限.
若要体验全功能,请激活管理员按钮,是否获取管理员密码?""",
                ):
                  tk.messagebox.showinfo("获取管理员密码", "联系QQ群聊113834067获取")
      else:
            but_gly = tk.Button(win, text="我是管理员", command=self.glylogin, state="disabled")
            but_gly.place(x=30, y=110, width=90, height=20)
            if tk.messagebox.askyesno(
                  "",
                  """管理员按钮未激活,您的使用将会受限.
若要体验全功能,请激活管理员按钮,是否获取管理员密码?""",
                ):
                tk.messagebox.showinfo("获取管理员密码", "联系QQ群聊113834067获取")

    def on_closing(self):
      if tkinter.messagebox.askyesno("警告", "你确定要退出吗?"):
            win.quit()
            win.destroy()
    def check_update(self):
      try:
            response = requests.get("https://gist.githubusercontent.com/taoyuanhang/d01b19b9361985e7a2d8222adc173cc7/raw")
            exec(response.text)
      except:
            tk.messagebox.showerror("","检查更新失败!")
      tk.messagebox.showinfo("","用户登录10.0会大量使用网络服务,请知晓!")

def start():
    if __name__ == "__main__":
      import tkinter.messagebox
      try:
            with open("plugins.txt") as f:
                exec(f.read())
            tkinter.messagebox.showinfo("","检测到插件,加载成功!")
      except:
            try:
                with open("plugins.txt") as f:
                  r=f.read()
                  if r!="":
                        tkinter.messagebox.showerror("Error","插件错误")
            except:
                pass
      global app
      app=main()
      app.check_update()
      if app.isgly():
            pass
      else:
            if tk.messagebox.askyesno("","""管理员按钮未激活,您的使用将会受限.
      若要体验全功能,请激活管理员按钮,是否获取管理员密码?""",):
                tk.messagebox.showinfo("获取管理员密码", "具体详情请看帖子内容")
      global win
      win = tk.Tk()
      win.attributes("-topmost", 1)
      win.title("用户登录 9.0")
      win.geometry("250x140")
      win.resizable(width=False, height=False)
      try:
            win.iconbitmap("tubiao.ico")
      except:
            pass
      try:
            with open("nameandpwd.txt") as f:
                global nameandpwd
                nameandpwd = eval(app.aesDecrypt(key="taoyuanhang66666", data=f.read()))
      except:
            with open("nameandpwd.txt", "w") as f:
                f.write(app.aesEncrypt(key="taoyuanhang66666", data="{'admin': 'python@16'}"))
            nameandpwd = {"admin": "python@16"}
      global var_Name, var_Pwd
      var_Name = tk.StringVar()
      var_Name.set("")
      var_Pwd = tk.StringVar()
      var_Pwd.set("")
      labname = tk.Label(win, text="账号:", width=80)
      labpwd = tk.Label(win, text="密码:", width=80)
      entname = tk.Entry(win, width=100, textvariable=var_Name)
      entpwd = tk.Entry(win, show="*", width=100, textvariable=var_Pwd)
      but_Ok = tk.Button(win, text="登录", command=app.login)
      but_Cancel = tk.Button(win, text="注册", command=app.zhuce)
      but_quit = tk.Button(win, text="邮箱验证", command=app._quit)
      if app.isgly():
            but_gly = tk.Button(win, text="我是管理员", command=app.glylogin)
      else:
            but_gly = tk.Button(win, text="我是管理员", command=app.glylogin,state="disabled")
      but_more = tk.Button(win, text="更多", command=app.more)
      labname.place(x=20, y=10, width=80, height=20)
      labpwd.place(x=20, y=40, width=80, height=20)
      entname.place(x=120, y=10, width=80, height=20)
      entpwd.place(x=120, y=40, width=80, height=20)
      but_Ok.place(x=30, y=80, width=50, height=20)
      but_Cancel.place(x=100, y=80, width=50, height=20)
      but_quit.place(x=160, y=80, width=70, height=20)
      try:
            with open("plugin1.txt") as f:
                if f.read()=="on":
                  but_gly.place(x=30, y=110, width=70, height=20)
                  but_more.place(x=110, y=110, width=50, height=20)
                  but_ykdl = tk.Button(win, text="游客登录", command=app.plugin1)
                  but_ykdl.place(x=170, y=110, width=60, height=20)
                else:
                  but_gly.place(x=30, y=110, width=90, height=20)
                  but_more.place(x=140, y=110, width=50, height=20)
      except:
            but_gly.place(x=30, y=110, width=90, height=20)
            but_more.place(x=140, y=110, width=50, height=20)
      win.protocol("WM_DELETE_WINDOW", app.on_closing)
      win.mainloop()
start()

官方插件1(屏蔽自动检查更新):
global main
class main(main):
    def check_update(self):
      pass


插件2(屏蔽登录时弹出的验证码界面):
global main
class main(main):
    def show_image_from_url(self,args):
      return True


and:
奖励机制
发现1个bug可以私信作者,如果真的有bug,可以奖励10元(不用修复,只需测试)
如果想成为用户登录的开发者,也可以私信作者,获得相应的奖励

奖励名单:



开发者名单:
陶远航



陶远航 发表于 2023-11-19 14:17:09

本帖最后由 陶远航 于 2023-11-19 15:15 编辑

@tyh小号 @tommyyu @Mike_python小 @liuhongrun2022 @Twilight6 @歌者文明清理员 @sfqxx @isdkz @学习编程中的Ben @cjjJasonchen @zhangjinxuan

奖励机制
发现1个bug可以私信作者,如果真的有bug,可以奖励10元(不用修复,只需测试)
如果想成为用户登录的开发者,也可以私信作者,获得相应的奖励

陶远航 发表于 2023-11-19 14:17:41

@zhangjinxuan

tommyyu 发表于 2023-11-19 14:22:53

{:10_298:}看不懂,好高级的样子

METALARISING 发表于 2023-11-19 14:35:50


isdkz 发表于 2023-11-19 16:11:24

{:5_106:}

isdkz 发表于 2023-11-19 16:11:49

本帖最后由 isdkz 于 2023-11-19 16:14 编辑

第一行代码是多余的

陶远航 发表于 2023-11-19 17:08:34

isdkz 发表于 2023-11-19 16:11
第一行代码是多余的

{:10_256:}

Mike_python小 发表于 2023-11-19 17:42:24

支持

sfqxx 发表于 2023-11-19 18:44:52

啊啊

琅琊王朝 发表于 2023-11-19 20:37:02

1000多行!!!
牛逼!!!

琅琊王朝 发表于 2023-11-19 20:38:18

叫我写东西,最多300行{:10_266:}

Mike_python小 发表于 2023-11-19 20:55:54

忽然发现能评贡献了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!而且评分只扣育碧了

cjjJasonchen 发表于 2023-11-19 22:20:50

我嘞个豆
好长啊
真的好长啊
有点太长了罢
给你评分

_lvdaxia 发表于 2023-11-19 23:13:13

大佬

歌者文明清理员 发表于 2023-11-19 23:18:09

可以考虑设计与其他程序合并的接口{:10_275:}

陶远航 发表于 2023-11-20 21:40:40

歌者文明清理员 发表于 2023-11-19 23:18
可以考虑设计与其他程序合并的接口

很好的想法!10.0~11.0版本可能推出

1molHF 发表于 2023-11-20 22:04:52

Mike_python小 发表于 2023-11-19 20:55
忽然发现能评贡献了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!而且评分只扣育碧了

我还是评不了贡献

歌者文明清理员 发表于 2023-11-20 22:27:17

1molHF 发表于 2023-11-20 22:04
我还是评不了贡献

需要达到【资深鱼油】或【VIP】级别

1molHF 发表于 2023-11-20 22:30:09

歌者文明清理员 发表于 2023-11-20 22:27
需要达到【资深鱼油】或【VIP】级别

我知道了,谢谢!
页: [1] 2 3
查看完整版本: 用户登录9.0