diff --git a/Flask/app.py b/Flask/app.py index 4bc0f97..1f0d31d 100644 --- a/Flask/app.py +++ b/Flask/app.py @@ -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) \ No newline at end of file diff --git a/Flask/static/css/flask.css b/Flask/static/css/flask.css index 0e493f4..563e3ff 100644 --- a/Flask/static/css/flask.css +++ b/Flask/static/css/flask.css @@ -137,6 +137,7 @@ input[type=password] { button:hover{ border: 2px solid white; + cursor: pointer; } input:hover{ border: 2px solid white; @@ -215,9 +216,10 @@ input[type=checkbox]{ height: 0; width: 0; visibility: hidden; - } +} label { + padding: 8px; margin: auto; cursor: pointer; text-indent: -9999px; @@ -274,3 +276,26 @@ select { select:hover { border: 2px solid white; } + + +input[type="time"] { + width: 70%; + padding: 8px 12px; + margin: 8px 0; + background-color: #212121; + border: 2px solid grey; + border-radius: 4px; + outline: none; + color: white; + text-align: center; +} + +input[type="time"]::-webkit-calendar-picker-indicator { + filter: invert(1); + opacity: 0.7; + cursor: pointer; +} + +input[type="time"]::-webkit-calendar-picker-indicator:hover { + opacity: 1; +} diff --git a/Flask/templates/change_password.html b/Flask/templates/change_password.html index 9a39f38..30fae99 100644 --- a/Flask/templates/change_password.html +++ b/Flask/templates/change_password.html @@ -9,7 +9,7 @@ - + diff --git a/Flask/templates/accounts.html b/Flask/templates/config.html similarity index 98% rename from Flask/templates/accounts.html rename to Flask/templates/config.html index 771b2c9..73e3578 100644 --- a/Flask/templates/accounts.html +++ b/Flask/templates/config.html @@ -8,7 +8,7 @@ - + @@ -40,7 +40,7 @@ {%if not current_user.is_authenticated %} {% else %} -
+ diff --git a/Flask/templates/database.html b/Flask/templates/database.html index 44e4dc2..ea57933 100644 --- a/Flask/templates/database.html +++ b/Flask/templates/database.html @@ -9,7 +9,7 @@ diff --git a/Flask/templates/dev.html b/Flask/templates/dev.html index 9368389..e31478b 100644 --- a/Flask/templates/dev.html +++ b/Flask/templates/dev.html @@ -10,7 +10,7 @@ diff --git a/Flask/templates/discord.html b/Flask/templates/discord.html index e270708..a1b1cfb 100644 --- a/Flask/templates/discord.html +++ b/Flask/templates/discord.html @@ -9,7 +9,7 @@ @@ -73,12 +73,17 @@ + +
- +
- +
- +
Failure Link
+ - - + + +
+ +
-