Compare commits

..

No commits in common. "37e8f6f61bf1818cdcac7527d940564bce7007b8" and "449d2da41052b225a6f3886b4c797bdc725fb8d6" have entirely different histories.

5 changed files with 43 additions and 62 deletions

View File

@ -1,2 +0,0 @@
**/.venv
user_data/*

6
.gitignore vendored
View File

@ -3,16 +3,18 @@ geckodriver.log
.vscode/
.idea
venv
**/.venv
/Git
page.html
screenshot.png
login.csv
data
**/__pycache__
user_data/*
install.sh
nohup.out
points.csv
file.png
user_data/configs.json
*.ts
LICENSE
README.md
README.md

View File

@ -13,27 +13,11 @@ import re
from requests import get
import redis
APP_ROOT = os.getenv("APP_ROOT")
if APP_ROOT is None:
APP_ROOT = "/app/MsRewards-Reborn/"
NO_SUBPROCESS = os.getenv("NO_SUBPROCESS")
if NO_SUBPROCESS is not None:
def fake_popen(*args, **kwargs):
print("Calling subprocess.Popen with", args, kwargs)
subprocess.Popen = fake_popen
print("Faking subprocess calls")
# redis part for live update
pool = redis.ConnectionPool(host='localhost', port=6379, db=0)
r = redis.Redis(connection_pool=pool)
def get_path(path):
return os.path.join(APP_ROOT, path)
def generate_output():
pubsub = r.pubsub()
pubsub.subscribe('console')
@ -48,7 +32,7 @@ def generate_output():
# the end
global password
with open(get_path("user_data/flask.json"), "r") as inFile:
with open("/app/MsRewards-Reborn/user_data/flask.json", "r") as inFile:
data = json.load(inFile)
password = data["password"]
@ -56,7 +40,7 @@ secret = data["secret"]
if secret == "":
import secrets
secret = secrets.token_hex()
with open(get_path("user_data/flask.json"), "w") as inFile:
with open("/app/MsRewards-Reborn/user_data/flask.json", "w") as inFile:
data = {
"password": password,
"secret": secret
@ -86,14 +70,14 @@ scheduler.add_job( # on relance le job
def start_ms(i):
print("\033[32m" + f"Starting config {i}" + "\033[0m")
log = open(get_path(f"Flask/static/logs/{i}.txt"), 'a') # so that data written to it will be appended
subprocess.Popen([f"python3 -u {get_path('V6.py')} -c {i}"], stdout=log, stderr=log, shell=True)
log = open(f"/app/MsRewards-Reborn/Flask/static/logs/{i}.txt", 'a') # so that data written to it will be appended
subprocess.Popen([f"python3 -u /app/MsRewards-Reborn/V6.py -c {i}"], stdout=log, stderr=log, shell=True)
log.close()
TriggerDict = {}
def update_jobs():
with open(get_path("user_data/configs.json"), "r") as inFile:
with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
configs = json.load(inFile)
for i in configs:
try :
@ -136,7 +120,7 @@ app = Flask(__name__)
@app.context_processor
def inject_default_variables():
with open(get_path("version"), "r") as f:
with open("/app/MsRewards-Reborn/version", "r") as f:
version = f.readline().replace("\n", '')
return dict(version=version)
"""
@ -191,7 +175,7 @@ def change_password():
if request.method == 'POST':
password = request.form["password"]
subprocess.Popen(["grafana-cli", "admin", "reset-admin-password", password])
with open(get_path("user_data/flask.json"), "w") as inFile:
with open("/app/MsRewards-Reborn/user_data/flask.json", "w") as inFile:
data = {
"password": password,
"secret": secret
@ -217,21 +201,21 @@ def load_user(userid):
@app.route("/")
def main():
with open(get_path("user_data/configs.json"), "r") as inFile:
with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
configs = json.load(inFile)
return(render_template("schedule.html", data=configs))
@app.route("/discord/")
def discord_get():
with open(get_path("user_data/discord.json"), "r") as inFile:
with open("/app/MsRewards-Reborn/user_data/discord.json", "r") as inFile:
data = json.load(inFile)
return(render_template("discord.html", data=data, len=maxi(data)))
@app.route("/discord/", methods=["post"])
def discord_post():
with open(get_path("user_data/discord.json"), "r") as inFile:
with open("/app/MsRewards-Reborn/user_data/discord.json", "r") as inFile:
data = json.load(inFile)
action = request.form
if action['DISCORD'] == "delete" :
@ -253,7 +237,7 @@ def discord_post():
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(get_path("user_data/discord.json"), "w") as outFile:
with open("/app/MsRewards-Reborn/user_data/discord.json", "w") as outFile:
json.dump(data, outFile)
return(render_template("discord.html", data=data, len=maxi(data)))
@ -265,7 +249,7 @@ def dev2():
@app.route("/settings/")
def settings_get():
with open(get_path("user_data/settings.json"), "r") as inFile:
with open("/app/MsRewards-Reborn/user_data/settings.json", "r") as inFile:
settings = json.load(inFile)
return(render_template("settings.html", data=settings))
@ -275,21 +259,21 @@ def settings_post():
settings = {}
action = request.form
settings['avatarlink'] = action["avatarlink"]
with open(get_path("user_data/settings.json"), "w") as inFile:
with open("/app/MsRewards-Reborn/user_data/settings.json", "w") as inFile:
json.dump(settings, inFile)
return(render_template("settings.html", data=settings))
@app.route("/proxy/")
def proxy_get():
with open(get_path("user_data/proxy.json"), "r") as inFile:
with open("/app/MsRewards-Reborn/user_data/proxy.json", "r") as inFile:
j = json.load(inFile)
return(render_template("proxy.html", data=j, len=maxi(j)))
@app.route("/proxy/", methods=["post"])
def proxy_post():
with open(get_path("user_data/proxy.json"), "r") as inFile:
with open("/app/MsRewards-Reborn/user_data/proxy.json", "r") as inFile:
data = json.load(inFile)
action = request.form
print(action)
@ -306,21 +290,21 @@ def proxy_post():
except :
print("error : probably bad config")
with open(get_path("user_data/proxy.json"), "w") as outFile:
with open("/app/MsRewards-Reborn/user_data/proxy.json", "w") as outFile:
json.dump(data, outFile)
return(render_template("proxy.html", data=data, len=maxi(data)))
@app.route("/schedule/")
def schedule_get():
with open(get_path("user_data/configs.json"), "r") as inFile:
with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
configs = json.load(inFile)
return(render_template("schedule.html", data=configs))
@app.route("/schedule/", methods=["post"])
def schedule_post():
with open(get_path("user_data/configs.json"), "r") as inFile:
with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
configs = json.load(inFile)
data = dict(request.form)
@ -334,7 +318,7 @@ def schedule_post():
configs[i]["time"] = data[f"time{i}"]
configs[i]["enabled"] = data[f"switch{i}"] == "on"
with open(get_path("user_data/configs.json"), "w") as inFile:
with open("/app/MsRewards-Reborn/user_data/configs.json", "w") as inFile:
json.dump(configs, inFile)
update_jobs()
return(render_template("schedule.html", data=configs))
@ -342,11 +326,11 @@ def schedule_post():
@app.route("/config/")
def config_get():
with open(get_path("user_data/proxy.json"), "r") as inFile:
with open("/app/MsRewards-Reborn/user_data/proxy.json", "r") as inFile:
proxys = json.load(inFile)
with open(get_path("user_data/discord.json"), "r") as inFile:
with open("/app/MsRewards-Reborn/user_data/discord.json", "r") as inFile:
discords = json.load(inFile)
with open(get_path("user_data/configs.json"), "r") as inFile:
with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
configs = json.load(inFile)
return(render_template("config.html", data=configs, discords=discords, proxys=proxys, configs=configs, len=maxi(configs)))
@ -354,11 +338,11 @@ def config_get():
@app.route("/config/", methods=["POST"])
def config_post():
action = request.form
with open(get_path("user_data/proxy.json"), "r") as inFile:
with open("/app/MsRewards-Reborn/user_data/proxy.json", "r") as inFile:
proxys = json.load(inFile)
with open(get_path("user_data/discord.json"), "r") as inFile:
with open("/app/MsRewards-Reborn/user_data/discord.json", "r") as inFile:
discords = json.load(inFile)
with open(get_path("user_data/configs.json"), "r") as inFile:
with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
configs = json.load(inFile)
if action["data"] == "delete":
@ -381,18 +365,18 @@ def config_post():
"enabled":"False",
"accounts": comptes
}
with open(get_path("user_data/configs.json"), "w") as outFile:
with open("/app/MsRewards-Reborn/user_data/configs.json", "w") as outFile:
json.dump(configs, outFile)
return(render_template("config.html", data=configs, discords=discords, proxys=proxys, configs=configs, len=maxi(configs)))
@app.route("/logs/", methods=["GET", "POST"])
def logs():
with open(get_path("user_data/configs.json"), "r") as inFile:
with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
configs = json.load(inFile)
files = [(configs[i]["name"], i) for i in configs]
config_files = [i[1] for i in files]
for f in os.listdir(get_path("Flask/static/logs")):
for f in os.listdir("/app/MsRewards-Reborn/Flask/static/logs"):
fid = ".".join(f.split(".")[:-1]) # filename without .txt
if f != ".gitignore" and fid not in config_files:
files.append((f, fid))
@ -411,21 +395,21 @@ def stats():
@app.route("/override/", methods=["POST"])
def override_post():
json = request.form.to_dict(flat=False)
log = open(get_path("Flask/static/logs/custom.txt"), 'w') # so that data written to it will be appended
subprocess.Popen([f"python3 -u {get_path('V6.py')} -c {json['config'][0]} --json \"{json}\""], stdout=log, stderr=log, shell=True)
log = open(f"/app/MsRewards-Reborn/Flask/static/logs/custom.txt", 'w') # so that data written to it will be appended
subprocess.Popen([f"python3 -u /app/MsRewards-Reborn/V6.py -c {json['config'][0]} --json \"{json}\""], stdout=log, stderr=log, shell=True)
log.close()
return(render_template("vnc_post.html"))
@app.route("/override/", methods=["GET"])
def override_get():
with open(get_path("user_data/configs.json"), "r") as inFile:
with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
configs = json.load(inFile)
return(render_template("vnc_get.html", configs=configs))
@app.route('/download/<path:filename>', methods=['GET', 'POST'])
@login_required
def download(filename):
return send_from_directory(directory=get_path("user_data/"), path=filename, as_attachment=True)
return send_from_directory(directory='/app/MsRewards-Reborn/user_data/', path=filename, as_attachment=True)
def allowed_file(filename):
@ -446,8 +430,8 @@ def upload_file():
elif file and allowed_file(file.filename):
filename = secure_filename(file.filename)
print(os.path.join(get_path("user_data/"), filename))
file.save(os.path.join(get_path("user_data/"), filename))
print(os.path.join('/app/MsRewards-Reborn/user_data/', filename))
file.save(os.path.join('/app/MsRewards-Reborn/user_data/', filename))
i += 1
print(i)
@ -465,7 +449,4 @@ def maxi(dict):
update_jobs()
subprocess.Popen(["bash", get_path("config/request.sh")])
if __name__ == "__main__":
app.run()
subprocess.Popen(["bash",'/app/MsRewards-Reborn/config/request.sh'])

View File

@ -46,7 +46,7 @@ server {
proxy_pass "http://127.0.0.1:6666";
chunked_transfer_encoding off;
proxy_buffering off;
add_header X-Accel-Buffering no;
set_header X-Accel-Buffering no;
}
}

View File

@ -11,11 +11,11 @@ class Driver:
self.mobile_driver = mobile_driver
def switch_to_driver(self, driver: str):
match driver.lower():
case "pc":
match driver:
case "pc" | "PC" | "Pc":
self.driver = self.pc_driver
case "mobile":
case "mobile" | "Mobile":
self.driver = self.mobile_driver
case _: