zmiany
This commit is contained in:
parent
d977ced0f5
commit
8989f2abf0
13
app.py
13
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)
|
||||
|
@ -2,25 +2,30 @@
|
||||
<?php
|
||||
|
||||
if ($argc < 3) {
|
||||
echo "❌ Użycie: php delete_user.php UID /sciezka/do/drupala\n";
|
||||
echo "❌ Użycie: php delete_user.php UID /ścieżka/do/drupala\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$uid = (int) $argv[1];
|
||||
$drupal_path = $argv[2];
|
||||
|
||||
// Bootstrap Drupala
|
||||
// Ustaw sztuczne IP dla CLI
|
||||
if (php_sapi_name() == 'cli') {
|
||||
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||
}
|
||||
|
||||
define('DRUPAL_ROOT', $drupal_path);
|
||||
chdir(DRUPAL_ROOT);
|
||||
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
|
||||
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
|
||||
|
||||
// Załaduj użytkownika
|
||||
$account = user_load(array('uid' => $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";
|
||||
|
Loading…
x
Reference in New Issue
Block a user