This commit is contained in:
piair
2023-06-18 17:40:59 +02:00
parent b201c68aa9
commit 08b593eeb9
11 changed files with 146 additions and 100 deletions

View File

@ -137,7 +137,7 @@ def main():
def discord_get():
with open("./user_data/discord.json", "r") as inFile:
data = json.load(inFile)
return(render_template("discord.html", data=data, len=len(data)))
return(render_template("discord.html", data=data, len=maxi(data)))
@app.route("/discord/", methods=["post"])
@ -145,26 +145,28 @@ def discord_post():
with open("./user_data/discord.json", "r") as inFile:
data = json.load(inFile)
action = request.form
config = action["select"]
successL = action["successL"]
try :
a = action["successT"]
successT = "True"
except:
successT = "False"
try :
a = action["errorsT"]
errorsT = "True"
except:
errorsT = "False"
errorsL = action["errorsL"]
name = action["name"] if action["name"] else f"unnamed{action['select']}"
data[config] = {"errorsL" : errorsL, "errorsT": errorsT, "successT": successT, "successL": successL, "name": name}
if action['DISCORD'] == "delete" :
data.pop(action["select"], None)
else :
config = action["select"]
successL = action["successL"]
try :
a = action["successT"]
successT = "True"
except:
successT = "False"
try :
a = action["errorsT"]
errorsT = "True"
except:
errorsT = "False"
errorsL = action["errorsL"]
name = action["name"] if action["name"] else f"unnamed{action['select']}"
data[config] = {"errorsL" : errorsL, "errorsT": errorsT, "successT": successT, "successL": successL, "name": name}
with open("./user_data/discord.json", "w") as outFile:
json.dump(data, outFile)
return(render_template("discord.html", data=data, len=len(data)))
return(render_template("discord.html", data=data, len=maxi(data)))
@app.route("/dev/")
@ -193,6 +195,7 @@ def settings_get():
settings = json.load(inFile)
return(render_template("settings.html", data=settings))
@app.route("/settings/", methods=["post"])
def settings_post():
settings = {}
@ -207,7 +210,7 @@ def settings_post():
def proxy_get():
with open("./user_data/proxy.json", "r") as inFile:
j = json.load(inFile)
return(render_template("proxy.html", data=j, len=len(j)))
return(render_template("proxy.html", data=j, len=maxi(j)))
@app.route("/proxy/", methods=["post"])
@ -215,29 +218,52 @@ def proxy_post():
with open("./user_data/proxy.json", "r") as inFile:
data = json.load(inFile)
action = request.form
try :
config = action["select"]
address = action["address"]
port = action["port"]
name = action["name"] if action["name"] else f"@unnamed{action['select']}"
data[config] = {"address" : address, "port": port, "name": name}
except :
print("error : probably bad config")
print(action)
if action['PROXY'] == "delete" :
print(action)
data.pop(action["select"], None)
else :
try :
config = action["select"]
address = action["address"]
port = action["port"]
name = action["name"] if action["name"] else f"@unnamed{action['select']}"
data[config] = {"address" : address, "port": port, "name": name}
except :
print("error : probably bad config")
with open("./user_data/proxy.json", "w") as outFile:
json.dump(data, outFile)
return(render_template("proxy.html", data=data, len=len(data)))
return(render_template("proxy.html", data=data, len=maxi(data)))
@app.route("/override/")
def override_get():
return(render_template("override.html"))
with open("./user_data/configs.json", "r") as inFile:
configs = json.load(inFile)
return(render_template("override.html", data=configs))
@app.route("/override/", methods=["post"])
def override():
subprocess.run(["python3", "./V6.py", "-v", "2345"])
return(render_template("override.html"))
with open("./user_data/configs.json", "r") as inFile:
configs = json.load(inFile)
data = dict(request.form)
for i in configs:
try :
data[f'switch{i}']
except :
data[f'switch{i}'] = "off"
for i in configs:
configs[i]["time"] = data[f"time{i}"]
configs[i]["enabled"] = data[f"switch{i}"] == "on"
with open("./user_data/configs.json", "w") as inFile:
json.dump(configs, inFile)
return(render_template("override.html", data=configs))
@app.route("/database/")
@ -270,19 +296,19 @@ def database_post():
return(render_template("database.html", data = data))
@app.route("/accounts/")
def accounts_get():
@app.route("/config/")
def config_get():
with open("./user_data/proxy.json", "r") as inFile:
proxys = json.load(inFile)
with open("./user_data/discord.json", "r") as inFile:
discords = json.load(inFile)
with open("./user_data/configs.json", "r") as inFile:
configs = json.load(inFile)
return(render_template("accounts.html", data=configs, discords=discords, proxys=proxys, configs=configs, len=len(configs)))
return(render_template("config.html", data=configs, discords=discords, proxys=proxys, configs=configs, len=maxi(configs)))
@app.route("/accounts/", methods=["POST"])
def accounts_post():
@app.route("/config/", methods=["POST"])
def config_post():
action = request.form
with open("./user_data/proxy.json", "r") as inFile:
proxys = json.load(inFile)
@ -303,49 +329,22 @@ def accounts_post():
"name" : action["name"] if action["name"] != "" else f"unnamed{action['config']}",
"proxy": action["proxy"],
"discord": action["discord"],
"accounts": comptes
"time":"",
"enabled":"False",
"config": comptes
}
with open("./user_data/configs.json", "w") as outFile:
json.dump(configs, outFile)
return(render_template("accounts.html", data=configs, discords=discords, proxys=proxys, configs=configs, len=len(configs)))
return(render_template("config.html", data=configs, discords=discords, proxys=proxys, configs=configs, len=maxi(configs)))
def read_config_txt(ligne):
f = open("./user_data/config.cfg", "r")
txt = f.readlines()
f.close()
if txt.count(txt) >1:
raise NameError("Fail")
for i in range(len(txt)) :
name = txt[i].split(" = ")[0]
if name == ligne:
ret = txt[i].split(" = ")[1]
f = open("./user_data/config.cfg", "w")
for i in txt :
f.write(i)
f.close()
return(ret.replace("\n", ""))
def edit_config_txt(ligne, contenu):
f = open("./user_data/config.cfg", "r")
txt = f.readlines()
f.close()
if txt.count(txt) >1:
raise NameError("Fail")
for i in range(len(txt)) :
name = txt[i].split(" = ")[0]
if name == ligne:
txt[i] = name + " = " + str(contenu) + "\n"
f = open("./user_data/config.cfg", "w")
for i in txt :
f.write(i)
f.close()
def maxi(dict):
m = 0
for i in dict :
if int(i) >= m:
m = int(i)
return(m+1)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=3456, debug=True)