diff --git a/AstraOS/Frontend/HTML/age_verification.html b/AstraOS/Frontend/HTML/age_verification.html new file mode 100644 index 0000000..b590d02 --- /dev/null +++ b/AstraOS/Frontend/HTML/age_verification.html @@ -0,0 +1,119 @@ +{% extends "sidebar.html" %} + +{% block title %}AstraOS — Altersüberprüfung{% endblock %} + +{% block content %} +
+

Altersüberprüfung

+
+ + +{% with messages = get_flashed_messages(with_categories=true) %} + {% if messages %} + {% for category, message in messages %} +
+ {{ message }} +
+ {% endfor %} + {% endif %} +{% endwith %} + +
+ +
+

Neue Überprüfung

+
+ +
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + {% if result %} +
+

Ergebnis

+

Die Person ist {{ result.age }} Jahre alt.

+ {% if result.age < 13 %} +

Diese Person muss für {{ result.ban_duration_days }} Tage gesperrt werden.

+
+ +
+ + +
+
+ {% else %} +

Keine Sperre erforderlich.

+ {% endif %} +
+ {% endif %} +
+ + +
+

Benutzer suchen

+
+ + +
+ + +
+
+ + +{% endblock %} + diff --git a/AstraOS/Frontend/HTML/sidebar.html b/AstraOS/Frontend/HTML/sidebar.html index 3d7e486..58b6f5a 100644 --- a/AstraOS/Frontend/HTML/sidebar.html +++ b/AstraOS/Frontend/HTML/sidebar.html @@ -247,7 +247,13 @@ {% endif %} 🌐 Moonlab-Intranet - 🎂 Altersüberprüfung + {% if 'view_age_verification' in session.get('permissions', []) %} + + 🎂 Altersüberprüfung + + {% endif %} 🎉 Events diff --git a/AstraOS/Frontend/HTML/view_user_age_details.html b/AstraOS/Frontend/HTML/view_user_age_details.html new file mode 100644 index 0000000..4909205 --- /dev/null +++ b/AstraOS/Frontend/HTML/view_user_age_details.html @@ -0,0 +1,74 @@ +{% extends "sidebar.html" %} + +{% block title %}AstraOS — Benutzerdetails{% endblock %} + +{% block content %} +
+

Benutzerdetails

+ + ← Zurück + +
+ +
+
+
+

Ingame Name

+

{{ user.ingame_name }}

+
+
+

SteamID

+

{{ user.steam_id }}

+
+
+

Geburtsdatum

+

{{ user.birthdate }}

+
+
+

Alter bei Überprüfung

+

{{ user.age }} Jahre

+
+
+

Überprüft von

+

{{ user.checked_by }} am {{ user.timestamp.strftime('%d.%m.%Y um %H:%M') }}

+
+
+ + {% if result %} +
+

Aktion erforderlich

+

Diese Person muss für {{ result.ban_duration_days }} Tage gesperrt werden.

+
+ +
+ + +
+
+
+ {% elif user.age >= 13 %} +
+

Keine Sperre erforderlich.

+
+ {% endif %} +
+ + +{% endblock %} + diff --git a/AstraOS/astra_os.py b/AstraOS/astra_os.py index a5b9b5b..d608e77 100644 --- a/AstraOS/astra_os.py +++ b/AstraOS/astra_os.py @@ -61,6 +61,7 @@ try: dashboard_collection = db["dashboard_stats"] discord_bots_collection = db["discord_bots_data"] ip_analyzer_results_collection = db["ip_analyzer_results"] + age_verification_collection = db["age_verification"] print("INFO: MongoDB-Verbindung erfolgreich hergestellt.") AVAILABLE_PERMISSIONS = [ "view_dashboard", @@ -72,7 +73,8 @@ try: "maintenance_management", "bypass_maintenance", "manage_discord_bots", - "view_ip_analyzer" + "view_ip_analyzer", + "view_age_verification" ] if roles_collection.count_documents({}) == 0: print("WARNUNG: Keine Rollen in der Datenbank gefunden. Erstelle Standard-Rollen...") @@ -691,6 +693,83 @@ def delete_role(role_id): roles_collection.delete_one({'_id': ObjectId(role_id)}) flash("Rolle wurde gelöscht.", "success") return redirect(url_for('role_management')) +@app.route('/age_verification', methods=['GET', 'POST']) +@login_required +@permission_required('view_age_verification') +def age_verification(): + result = None + search_query = request.args.get('search', '') + + if request.method == 'POST': + birthdate_str = request.form.get('birthdate') + steam_id = request.form.get('steam_id') + ingame_name = request.form.get('ingame_name') + + if birthdate_str and steam_id and ingame_name: + birthdate_dt = datetime.strptime(birthdate_str, '%Y-%m-%d') + today = datetime.today() + age = today.year - birthdate_dt.year - ((today.month, today.day) < (birthdate_dt.month, birthdate_dt.day)) + + user_data = { + 'birthdate': birthdate_str, + 'steam_id': steam_id, + 'ingame_name': ingame_name, + 'age': age, + 'checked_by': session.get('username'), + 'timestamp': datetime.utcnow() + } + age_verification_collection.insert_one(user_data) + + result = {'age': age, 'steam_id': steam_id} + if age < 13: + thirteenth_birthday = birthdate_dt.replace(year=birthdate_dt.year + 13) + ban_duration_days = (thirteenth_birthday - today).days + 1 + result['ban_duration_days'] = ban_duration_days + result['ban_command'] = f"oban {steam_id} {ban_duration_days}d" + + flash("Altersüberprüfung erfolgreich durchgeführt und gespeichert.", "success") + + if search_query: + users = list(age_verification_collection.find({ + "$or": [ + {"ingame_name": {"$regex": search_query, "$options": "i"}}, + {"steam_id": {"$regex": search_query, "$options": "i"}} + ] + }).sort("timestamp", -1)) + else: + users = list(age_verification_collection.find().sort("timestamp", -1).limit(10)) + + return render_template('age_verification.html', + active_page='age_verification', + result=result, + users=users, + search_query=search_query) + +@app.route('/age_verification/') +@login_required +@permission_required('view_age_verification') +def view_user_age_details(user_id): + user = age_verification_collection.find_one({'_id': ObjectId(user_id)}) + if not user: + flash("Benutzer nicht gefunden.", "danger") + return redirect(url_for('age_verification')) + + result = None + if user.get('age') < 13: + today = datetime.today() + birthdate_dt = datetime.strptime(user['birthdate'], '%Y-%m-%d') + thirteenth_birthday = birthdate_dt.replace(year=birthdate_dt.year + 13) + ban_duration_days = (thirteenth_birthday - today).days + 1 + if ban_duration_days > 0: + result = { + 'ban_duration_days': ban_duration_days, + 'ban_command': f"oban {user['steam_id']} {ban_duration_days}d" + } + + return render_template('view_user_age_details.html', + active_page='age_verification', + user=user, + result=result) @app.route('/ip_analyzer', methods=['GET', 'POST']) @login_required @permission_required('view_ip_analyzer') diff --git a/Outdated Website/website.py b/Outdated Website/website.py index 839a2f5..b25d5a8 100644 --- a/Outdated Website/website.py +++ b/Outdated Website/website.py @@ -885,59 +885,6 @@ def start_bots_on_server_start(): start_bots_on_server_start() -@app.route("/verify_age", methods=["GET", "POST"]) -@csrf.exempt -def verify_age(): - if "username" not in session: - return redirect(url_for("login")) - - age = None - birthdate_dt = None - today = datetime.today() - if request.method == "POST": - birthdate = request.form["birthdate"] - steam_id = request.form["steam_id"] - ingame_name = request.form["ingame_name"] - - birthdate_dt = datetime.strptime(birthdate, "%Y-%m-%d") - age = today.year - birthdate_dt.year - ((today.month, today.day) < (birthdate_dt.month, birthdate_dt.day)) - - user_ages_collection.insert_one({ - "username": session["username"], - "birthdate": birthdate, - "age": age, - "steam_id": steam_id, - "ingame_name": ingame_name, - "timestamp": datetime.now() - }) - - search_query = request.args.get('search') - if search_query: - users = user_ages_collection.find({ - "$or": [ - {"ingame_name": {"$regex": search_query, "$options": "i"}}, - {"steam_id": {"$regex": search_query, "$options": "i"}} - ] - }) - else: - users = user_ages_collection.find().limit(10) - - return render_template("verify_age.html", age=age, birthdate_dt=birthdate_dt, today=today, users=users) - - -@app.route("/verify_age/", methods=["GET"]) -def view_user_age(user_id): - if "username" not in session: - return redirect(url_for("login")) - - user = user_ages_collection.find_one({"_id": ObjectId(user_id)}) - if user: - user['_id'] = str(user['_id']) - return render_template("view_user_age.html", user=user) - else: - return "Benutzer nicht gefunden", 404 - - @app.route('/logout') def logout(): add_log(f"{session['username']} hat sich ausgeloggt")