From 8989f2abf0fde6f1eecba5891ff4011025c22fc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Gruszczy=C5=84ski?= Date: Fri, 16 May 2025 12:53:14 +0200 Subject: [PATCH] zmiany --- app.py | 13 ++++++------- delete_user.php | 23 ++++++++++++++--------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/app.py b/app.py index b58907c..532e375 100644 --- a/app.py +++ b/app.py @@ -40,9 +40,12 @@ def get_users(db_config): connection = mysql.connector.connect(**db_config) cursor = connection.cursor(dictionary=True) query = """ - SELECT u.uid, u.name, u.mail, u.access, u.created, p.points, COUNT(n.nid) AS post_count + SELECT u.uid, u.name, u.mail, u.access, u.created, p.points, + COUNT(DISTINCT n.nid) AS post_count, + COUNT(DISTINCT c.cid) AS comment_count FROM users u LEFT JOIN node n ON u.uid = n.uid + LEFT JOIN comments c ON u.uid = c.uid LEFT JOIN userpoints p ON u.uid = p.uid WHERE u.uid > 0 GROUP BY u.uid @@ -229,14 +232,10 @@ def main(): skipped_veterans = 0 for user in tqdm(users, desc="Analiza"): - if (user.get('points') or 0) > 0: - skipped_with_points += 1 - continue - if (user.get('post_count') or 0) > 0: - # Pomijamy użytkownika, który dodał treści + if (user.get('post_count') or 0) > 0 or (user.get('comment_count') or 0) > 0: continue - + # Pomijanie aktywnych "weteranów" created_year = datetime.datetime.fromtimestamp(user['created']).year if user.get('created') else None recent_login_threshold = now_ts - (args.recent_login_days * 86400) diff --git a/delete_user.php b/delete_user.php index 09d1132..3c642b2 100644 --- a/delete_user.php +++ b/delete_user.php @@ -2,25 +2,30 @@ $uid)); - -if ($account) { - user_delete(array('uid' => $uid)); - echo "✅ Użytkownik $uid został usunięty.\n"; -} else { +// Sprawdź czy użytkownik istnieje +$account = db_fetch_object(db_query("SELECT uid, name, status FROM {users} WHERE uid = %d", $uid)); +if (!$account) { echo "⚠️ Użytkownik $uid nie istnieje.\n"; + exit(0); } + +// Ustaw status = 0 (soft delete) +db_query("UPDATE {users} SET status = 0 WHERE uid = %d", $uid); +echo "✅ Użytkownik $uid został zdezaktywowany (soft delete).\n";