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)

View File

@ -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;
}

View File

@ -9,7 +9,7 @@
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/accounts';">accounts</button>
<button class="unselected" onclick="location.href = '/config';">config</button>
</td>
</tr>
<tr>

View File

@ -8,7 +8,7 @@
</tr>
<tr>
<td>
<button class="selected" onclick="location.href = '/accounts';">accounts</button>
<button class="selected" onclick="location.href = '/config';">config</button>
</td>
</tr>
<tr>
@ -40,7 +40,7 @@
{%if not current_user.is_authenticated %}
<button class="unselected" onclick="location.href = '/login';">login</button>
{% else %}
<form method="post" action="/accounts/">
<form method="post" action="/config/">
<table>

View File

@ -9,7 +9,7 @@
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/accounts';">accounts</button>
<button class="unselected" onclick="location.href = '/config';">config</button>
</td>
</tr>
<tr>

View File

@ -10,7 +10,7 @@
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = 'accounts';">accounts</button>
<button class="unselected" onclick="location.href = 'config';">config</button>
</td>
</tr>
<tr>

View File

@ -9,7 +9,7 @@
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/accounts';">accounts</button>
<button class="unselected" onclick="location.href = '/config';">config</button>
</td>
</tr>
<tr>
@ -73,12 +73,17 @@
<td class="comlumn-name">Failure Link</td>
<td><input type="text" id="errorsL" name="errorsL" value=""></td>
</tr>
</table>
<table>
<tr>
<td></td>
<td><input type="submit" name="DISCORD" id="submit" value="Create !" class="button"/></td>
<td class="comlumn-name"></td>
<td style="width:60%;"><input type="submit" name="DISCORD" id="submit" value="Create !" class="button" style="width:90%;"/></td>
<td style="padding-right: 20px;">
<input type="submit" name="DISCORD" id="submit" value="delete" class="button"/>
</td>
</tr>
</table>
</form>
<script>
function changecat(value) {

View File

@ -9,7 +9,7 @@
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/accounts';">accounts</button>
<button class="unselected" onclick="location.href = '/config';">config</button>
</td>
</tr>
<tr>

View File

@ -9,7 +9,7 @@
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/accounts';">accounts</button>
<button class="unselected" onclick="location.href = '/config';">config</button>
</td>
</tr>
<tr>
@ -39,14 +39,30 @@
{%if not current_user.is_authenticated %}
<button class="unselected" onclick="location.href = '/login';">login</button>
{% else %}
{% else %}
<h1>Not Implemented, watch terminal</h1>
<form method="post" action="/override/">
<input type="submit" name="data" value="Run bot" class="button"/>
<table>
{% for i in data %}
<tr>
<td>{{data[i]['name']}}</td>
<td>
<input type="time" id="{{i}}" name="time{{i}}" value="{{data[i]['time']}}">
</td>
<td>
<input type="checkbox" id="switch{{i}}" name="switch{{i}}" {{ "checked" if data[i]['enabled'] == True else "" }}/>
<label for="switch{{i}}">
Toggle
</label>
</td>
</tr>
{% endfor %}
</table>
<input type="submit" name="data" value="Update" class="button"/>
</form>
{% endif %}

View File

@ -9,7 +9,7 @@
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/accounts';">accounts</button>
<button class="unselected" onclick="location.href = '/config';">config</button>
</td>
</tr>
<tr>
@ -68,13 +68,14 @@
<td class="comlumn-name">port : </td>
<td><input type="text" name="port" value="" id="port"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="data" id="submit" value="Create" class="button"/></td>
</tr>
</table>
</table>
<table>
<tr>
<td class="comlumn-name"></td>
<td style="width:60%;"><input type="submit" name="PROXY" id="submit" value="Create !" class="button" style="width:90%;"/></td>
<td style="padding-right: 20px;"><input type="submit" name="PROXY" id="submit" value="delete" class="button"/></td>
</tr>
</table>
</form>

View File

@ -9,7 +9,7 @@
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/accounts';">accounts</button>
<button class="unselected" onclick="location.href = '/config';">config</button>
</td>
</tr>
<tr>