Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Mods & Themes (http://www.bvlist.com/forumdisplay.php?f=93)
-   -   [PMBT 2.x]automated User purging (http://www.bvlist.com/showthread.php?t=2551)

joeroberts 3rd May 2009 14:30

[PMBT 2.x]automated User purging
 
This is a update to the release By Revan for PMBT 1.X
This well delete inactive users from your site in 2 stages

First stage it well check users to see who has not been in for a set
period of time it well mark there account warned for inactivity and send them a E-mail notice telling them that they have not been active and that they have a set amount of time in which to return to the site in order not to be removed.

Second it well check to see who has been set inactive read the date set as inactive if the user has not returned in such time it well remove the account from both forum and tracker.

I had to do a lot of clean up on this as when I first tested Revans
release it would always send out a notice to new user on sign up confirmation which was not very good.
then I noticed that the notices where empty of the e-mail body so I had to fix this to
I also noted that the query's used to mark accounts as active and inactive would be ran for every user wich would cause a very high load on the data base so I had to move them in the code so
that it would only run one time for every page load.

I am going to make a admin page to allow you to set your warning dates and delete dates and so that you can turn it on and off with out
going threw data base.

so here it is let me know what you think

first is the sql you well need
this one is the configs of your prune system set it to what you want
Code:

CREATE TABLE IF NOT EXISTS `torrent_userautodel` (
  `inactwarning_time` int(10) NOT NULL default '0',
  `autodel_users_time` int(10) NOT NULL default '0',
  `autodel_users` enum('true','false') NOT NULL default 'true'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `torrent_userautodel` (`inactwarning_time`, `autodel_users_time`, `autodel_users`) VALUES
(30, 10, 'false');
ALTER TABLE `torrent_users` ADD `inactwarning` TINYINT( 1 ) NOT NULL DEFAULT '0';
ALTER TABLE `torrent_users` ADD `inactive_warn_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00';

Now open include/config.php
then below this

Code:

if (!$row = $db->sql_fetchrow($configquery)) die("phpMyBitTorrent not correctly installed! Ensure you have run setup.php or config_default.sql!!");
add:

Code:

$sql = "SELECT * FROM ".$db_prefix."_userautodel LIMIT 1;";

$userautodel = $db->sql_query($sql,BEGIN_TRANSACTION);

if (!$userautodel) die("Configuration not found! Make sure you have installed phpMyBitTorrent correctly.");
if (!$row3 = $db->sql_fetchrow($userautodel)) die("phpMyBitTorrent not correctly installed! Ensure you have run setup.php or config_default.sql!!");

and below

Code:

$version = $row["version"];
add

Code:

$inactwarning_time = $row3["inactwarning_time"]*86400;
$autodel_users_time = $row3["autodel_users_time"]*86400;
$autodel_users = ($row3["autodel_users"] == "true") ? true : false;

Now here is the Cleanup.php parts you need
first find
Code:

        $db->sql_query("UPDATE ".$db_prefix."_torrents SET visible = 'no' WHERE type != 'link' AND tot_peer <= '".$down_limit."' AND UNIX_TIMESTAMP(last_action) < UNIX_TIMESTAMP(NOW()) - ".intval($dead_torrent_interval)." AND evidence != 1 AND (TRACKER IS NULL OR ".intval($autoscrape).");");
        $db->sql_query("UPDATE ".$db_prefix."_torrents SET visible = 'yes' WHERE tot_peer > '".$down_limit."';");

And add after
[code]#prune users
if ($autodel_users)
{
$userwarninactivesub = Array();
$userwarninactivesub[english] = "".$sitename." Warning";
$userwarninactivesub[german] = "".$sitename." Achtung";
$userwarninactivesub[spanish] = "Advertencia ".$sitename."";
$userwarninactivesub[brazilian] = "".$sitename." adverte";
$userwarninactivesub[portuguese] = "".$sitename." adverte";

$userwarninactivetext = Array();

$warntexten1 = "Hi,
we would like to warn you that you have not been active on **siteurl** for more than **inactwarning_time** days,
if you do not want to have your account deleted please login to it.
";
if ($autodel_users_time != 0)
{
$warntexten2 = "You have **autodel_users_time** days to log in from now.
Otherwise we will delete your account permanently.";
}
else $warntexten2 = "";
$warntexten3 = "
Thanks **sitename** Admin
**siteurl**";
$userwarninactivetext[english] = "".$warntexten1.$warntexten2.$warntexten3."";


$warntextger1 = "Wir m


All times are GMT +2. The time now is 23:55.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.