Prune Users

Automatically delete user accounts based on their last activity
User avatar
kasimi
mChat developer
Posts: 917
Joined: 06 Oct 2016, 09:56
Location: Germany
Contact:

Re: Prune Users

#21

Post by kasimi » 27 Aug 2018, 08:12

I see where your problem is. To only prune users who have been active at least once, try this:
  • Open ext/kasimi/pruneusers/cron/prune_users.php
  • Find, around line 124:

    Code: Select all

    AND u.user_lastvisit < ' . (int) $lifetime;
    
  • On a new line above, add:

    Code: Select all

    AND u.user_lastvisit > 0
    

User avatar
jan_2017
Distinguished Donor
Posts: 131
Joined: 13 May 2017, 18:07

Re: Prune Users

#22

Post by jan_2017 » 27 Aug 2018, 08:15

Okay :D

I will test it , very thanks!

Bye Jan :wave:

User avatar
jan_2017
Distinguished Donor
Posts: 131
Joined: 13 May 2017, 18:07

Re: Prune Users

#23

Post by jan_2017 » 22 Sep 2018, 12:45

I have found an error in acp error log:
Ein allgemeiner Fehler ist aufgetreten: General Error
» SQL ERROR [ mysqli ]

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND u.user_lastvisit < 1514029275' at line 6 [1064]

SQL

SELECT u.user_id, u.username
FROM phpbb_users u
WHERE u.user_type = 0
AND u.user_id <> 1
AND u.user_lastvisit > 0;
AND u.user_lastvisit < 1514029275

BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

FILE: [ROOT]/phpbb/db/driver/driver.php
LINE: 999
CALL: trigger_error()

FILE: [ROOT]/phpbb/db/driver/mysqli.php
LINE: 193
CALL: phpbb\db\driver\driver->sql_error()

FILE: [ROOT]/phpbb/db/driver/factory.php
LINE: 329
CALL: phpbb\db\driver\mysqli->sql_query()

FILE: [ROOT]/ext/kasimi/pruneusers/cron/prune_users.php
LINE: 126
CALL: phpbb\db\driver\factory->sql_query()

FILE: [ROOT]/ext/kasimi/pruneusers/cron/prune_users.php
LINE: 76
CALL: kasimi\pruneusers\cron\prune_users->get_expired_users()

FILE: (not given by php)
LINE: (not given by php)
CALL: kasimi\pruneusers\cron\prune_users->run()

FILE: [ROOT]/phpbb/cron/task/wrapper.php
LINE: 104
CALL: call_user_func_array()

FILE: [ROOT]/cron.php
LINE: 78
CALL: phpbb\cron\task\wrapper->__call()

User avatar
kasimi
mChat developer
Posts: 917
Joined: 06 Oct 2016, 09:56
Location: Germany
Contact:

Re: Prune Users

#24

Post by kasimi » 22 Sep 2018, 12:58

You added a semicolon that doesn't belong there:

Code: Select all

AND u.user_lastvisit > 0;
Remove it and you should be good to go. :+1:

User avatar
jan_2017
Distinguished Donor
Posts: 131
Joined: 13 May 2017, 18:07

Re: Prune Users

#25

Post by jan_2017 » 22 Sep 2018, 13:07

small mistake big effect

thanks , i have fixed it

Painkiller88
Donor
Posts: 23
Joined: 01 Jan 2019, 12:41

Re: Prune Users

#26

Post by Painkiller88 » 21 Feb 2019, 21:14

I'm not sure if u are still working on this ext, but it would be great, as we all love your mChat, to make it possible like for mchat rooms, to enter a user ID that posts into the chat that the user has to make at least 1 post or his account will be pruned after the set time.

Maybe let the admin set the exact text to be posted into the chat.

I saw this already at terry2's board, but as it is ur extension i better ask u if you can do this :)

thanks :)

User avatar
kasimi
mChat developer
Posts: 917
Joined: 06 Oct 2016, 09:56
Location: Germany
Contact:

Re: Prune Users

#27

Post by kasimi » 09 Mar 2019, 21:45

I probably won't add that feature to this extension, but editing the code so that these users are deleted too should be easy:
  • Open ext/kasimi/pruneusers/cron/prune_users.php
  • Find the SQL query on lines 120-124:

    Code: Select all

    $sql = 'SELECT u.user_id, u.username
        FROM ' . USERS_TABLE . ' u
        WHERE u.user_type = ' . USER_NORMAL . '
            AND u.user_id <> ' . ANONYMOUS . '
            AND u.user_lastvisit < ' . (int) $lifetime;
    
  • Replace with:

    Code: Select all

    global $table_prefix;
    $sql = 'SELECT u.user_id, u.username
        FROM ' . USERS_TABLE . ' u
        LEFT JOIN (
                SELECT mt.user_id, MAX(mt.message_time) AS latest_message_time
                FROM ' . $table_prefix . 'mchat mt
                GROUP BY mt.user_id
            ) AS m
            ON u.user_id = m.user_id
        WHERE u.user_type = ' . USER_NORMAL . '
            AND u.user_id <> ' . ANONYMOUS . '
            AND (u.user_lastvisit < ' . (int) $lifetime . ' OR m.latest_message_time < ' . (int) $lifetime . ')';
    

clight77
Donor
Posts: 20
Joined: 01 May 2017, 01:06

Re: Prune Users

#28

Post by clight77 » 20 Apr 2019, 15:17

Hi any chance members with 0 post count could be added for pruning also?

Thanks

User avatar
kasimi
mChat developer
Posts: 917
Joined: 06 Oct 2016, 09:56
Location: Germany
Contact:

Re: Prune Users

#29

Post by kasimi » 22 Apr 2019, 18:07

Sure:
  • Open ext/kasimi/pruneusers/cron/prune_users.php
  • In the SQL query on lines 120-124, find:

    Code: Select all

    AND u.user_id <> ' . ANONYMOUS . '
  • On a new line below, add:

    Code: Select all

    AND user_posts = 0

clight77
Donor
Posts: 20
Joined: 01 May 2017, 01:06

Re: Prune Users

#30

Post by clight77 » 23 Apr 2019, 13:30

Hey thanks for the response :)

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests