Members   Search      Help    Register    Login    Home
Home » Discussion Forums » M0dZ & HaCkZ » Auto deleting users
Auto deleting users [message #1353] Mon, 17 September 2007 19:19 Go to next message
Revan is currently offline Revan  Czech Republic
Messages: 125
Registered: April 2007
Super-Seeder
This script sends a warning to users who haven't been online for more than 30 days and will delete users that haven't been online for more than 40 days. It has some flaws, but it works.

Open the cleanup.php in include folder and find:
function cleanup() {
        global $db, $db_prefix, $btuser, $autoscrape, $dead_torrent_interval, $announce_interval;

        $db->sql_query("DELETE FROM ".$db_prefix."_download WHERE date < SUBDATE(SYSDATE(), INTERVAL 7 DAY);");
        $db->sql_query("DELETE FROM ".$db_prefix."_users WHERE active = 0 AND UNIX_TIMESTAMP(regdate) < UNIX_TIMESTAMP(NOW()) - 432000;");
and insert after that:
$userwarninactivesub = Array();
$userwarninactivesub[english] = "".$sitename." Warning";
$userwarninactivesub[german] = "".$sitename." Achtung";
$userwarninactivesub[spanish] = "Advertencia".$sitename."";
$userwarninactivesub[brazilian] = "".$sitename." adverte";


$userwarninactivetext = Array();

$userwarninactivetext[english] = "Hi,
we would like to warn you that you have not been active on **siteurl** for more than 30 days,
if you do not want to have your account deleted please login to it. You have 10 days to log in from now. 
Otherwise we will delete your account permanently.
Thanks **sitename** Admin
**siteurl**";

$userwarninactivetext[german] = "Wir möchten darauf hinweisen , dass du auf **siteurl** seit mehr als 30 Tagen nicht mehr aktiv warst, 
wenn Du nicht willst, dass dein Account gelöscht wird, logge dich bitte ein. 
Du hast ab jetzt 10 Tage Zeit um dich auf **sitename** einzuloggen.
Ansonsten werden wir deinen Account permanent löschen.
Danke**sitename**Admin.
**siteurl**";

$userwarninactivetext[spanish] = "Hola, 
Queriamos decirte que no visitaste nuestra pagina **siteurl** por mas de 30 dias.
Si no quieres que tu Cuenta sea borrada, por favor logueate. Tienes 10 dias para loguearte nuevamente apartir de hoy.
De otra manera borraremos tu cuenta de forma permanente.
Gracias. Los **sitename** administradores
**siteurl**";


$userwarninactivetext[brazilian] = "Oi,
Nós gostaríamos de avisa-lo que voce nao tem estado ativo no **siteurl** por mais de 30 dias.
Se voce nao quer ter sua conta excluída, por favor conecte-se. Voce tem 10 dias a partir de hoje para fazer isso.
Caso contrário nós iremos apagar sua conta permanentemente.
Obrigado **sitename** Administrador
**siteurl**";

$admin_email ="YOUR ADMIN MAIL";
$sitename= "YOUR SITE NAME";
$siteurl= "YOUR SITE URL";

$res1 = "SELECT id, email, inactwarning, lastlogin, language FROM ".$db_prefix."_users;";
$res2 = $db->sql_query($res1);
while ($get_info = $db->sql_fetchrow($res2))
{
if ($get_info[inactwarning] == 0 AND $get_info[lastlogin] != 0 AND $get_info[lastlogin] < date('Y-m-d H:i:s', time() - 2592000)) 
{
$db->sql_query("UPDATE ".$db_prefix."_users SET inactwarning = 1 WHERE ((UNIX_TIMESTAMP(lastlogin) < UNIX_TIMESTAMP(NOW()) - 2592000) AND (UNIX_TIMESTAMP(lastlogin) <> 0));");
$replace_markers = Array("**sitename**","**siteurl**");
$replace_data = Array ($sitename,$siteurl);
if ($get_info[language] == "") $get_info[language] = "english";
$warn_mail = New eMail;
$warn_mail->sender = $admin_email;
$warn_mail->subject = $userwarninactivesub[$get_info[language]];
$warn_mail->body = str_replace($replace_markers,$replace_data,$userwarninactivetext[$get_info[language]]);
$warn_mail->Add($get_info[email]);
$warn_mail->Send();
}
if ($get_info[inactwarning] == 1 AND $get_info[lastlogin] != 0 AND $get_info[lastlogin] > date('Y-m-d H:i:s', time() - 2592000))
{
$db->sql_query("UPDATE ".$db_prefix."_users SET inactwarning = 0 WHERE (inactwarning = 1) AND (UNIX_TIMESTAMP(lastlogin) > UNIX_TIMESTAMP(NOW()) - 2592000);");
}
if ($get_info[inactwarning] == 1 AND $get_info[lastlogin] != 0 AND $get_info[lastlogin] < date('Y-m-d H:i:s', time() - 3456000))
{
$db->sql_query("DELETE FROM ".$db_prefix."_users WHERE (inactwarning = 1) AND (UNIX_TIMESTAMP(lastlogin) < UNIX_TIMESTAMP(NOW()) - 3456000);");
}
}

after that you'll need to go to database and add to your users table column 'inactwarning'

This could probably need some more work on it, but I just thought I'd post it anyway..

[Updated on: Thu, 06 December 2007 17:17]

Report message to a moderator

Re: Auto deleting users [message #1781 is a reply to message #1353] Thu, 14 February 2008 12:45 Go to previous messageGo to next message
joeroberts is currently offline joeroberts  United States
Messages: 1971
Registered: June 2006
Location: U.S.A
Releaser
Da HacKer
you missed some changes in user info such as pms sent torrents posted (owner change) off the top of my head


http://a.imageshack.us/img831/5562/mybikes.png
Re: Auto deleting users [message #1782 is a reply to message #1353] Thu, 14 February 2008 14:02 Go to previous messageGo to next message
Revan is currently offline Revan  Czech Republic
Messages: 125
Registered: April 2007
Super-Seeder
good point joe! i'll try to fix it soon Smile
Re: Auto deleting users [message #1819 is a reply to message #1353] Fri, 29 February 2008 21:11 Go to previous messageGo to next message
Revan is currently offline Revan  Czech Republic
Messages: 125
Registered: April 2007
Super-Seeder
been little busy right now Sad
but here's first update:
instead of:
if ($get_info[inactwarning] == 1 AND $get_info[lastlogin] != 0 AND $get_info[lastlogin] < date('Y-m-d H:i:s', time() - 3456000))
{
$db->sql_query("DELETE FROM ".$db_prefix."_users WHERE (inactwarning = 1) AND (UNIX_TIMESTAMP(lastlogin) < UNIX_TIMESTAMP(NOW()) - 3456000);");
}


put:
if ($get_info[inactwarning] == 1 AND $get_info[lastlogin] != 0 AND $get_info[lastlogin] < date('Y-m-d H:i:s', time() - 3456000))
{
$sql = "SELECT id FROM ".$db_prefix."_users WHERE (inactwarning = 1) AND (UNIX_TIMESTAMP(lastlogin) < UNIX_TIMESTAMP(NOW()) - 3456000);";
$res = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($res))
  {
  $op = "delete";
  $id = $row[id];
  include("user.php");
  }
}


i'll try to add few settings to this soon... sorry it takes so long Sad
Re: Auto deleting users [message #1820 is a reply to message #1819] Sat, 01 March 2008 06:39 Go to previous messageGo to next message
joeroberts is currently offline joeroberts  United States
Messages: 1971
Registered: June 2006
Location: U.S.A
Releaser
Da HacKer
you can not include user.php
if (!eregi("user.php",$_SERVER["PHP_SELF"])) die ("You cannot include this file");


http://a.imageshack.us/img831/5562/mybikes.png
Re: Auto deleting users [message #1821 is a reply to message #1353] Sat, 01 March 2008 15:58 Go to previous messageGo to next message
Revan is currently offline Revan  Czech Republic
Messages: 125
Registered: April 2007
Super-Seeder
ooops, you're right i messed that up...
what would you suggest?
straight copy of delete function from user.php or editing this in user.php
if (!eregi("user.php",$_SERVER["PHP_SELF"])) die ("You cannot include this file");

to something like:
if (!eregi("user.php",$_SERVER["PHP_SELF"]) and !eregi("functions.php",$_SERVER["PHP_SELF"])) die ("You cannot include this file");
Re: Auto deleting users [message #1822 is a reply to message #1821] Sat, 01 March 2008 16:24 Go to previous messageGo to next message
joeroberts is currently offline joeroberts  United States
Messages: 1971
Registered: June 2006
Location: U.S.A
Releaser
Da HacKer
use the code from there are create a new function

<?php
function removedinactive($uid){
                        
$sql = "SELECT username FROM ".$db_prefix."_users WHERE id = '".$uid."';";
                        
$res = $db->sql_query($sql);
                        list (
$username) = $db->sql_fetchrow($res);
                        
$db->sql_freeresult($res);
                        if (empty(
$username)) return;



                        
$sql = "SELECT avatar FROM ".$db_prefix."_users WHERE id = '".$id."';";
                        
$res = $db->sql_query($sql);
                        list (
$avatar) = $db->sql_fetchrow($res);
                        
$db->sql_freeresult($sql);
                        if (
eregi("^user/",$avatar)) @unlink($avatar);

                        
                        
$sql = Array();
                        
$sql[] = "DELETE FROM ".$db_prefix."_download_completed WHERE user = '".$uid."';";
                        
$sql[] = "DELETE FROM ".$db_prefix."_privacy_backup WHERE master = '".$uid."' OR slave = '".$uid."';";
                        
$sql[] = "DELETE FROM ".$db_prefix."_privacy_file WHERE master = '".$uid."' OR slave = '".$uid."';";
                        
$sql[] = "DELETE FROM ".$db_prefix."_privacy_global WHERE master = '".$uid."' OR slave = '".$uid."';";
                        
$sql[] = "DELETE FROM ".$db_prefix."_comments_notify WHERE user = '".$uid."';";
                        
$sql[] = "DELETE FROM ".$db_prefix."_seeder_notify WHERE user = '".$uid."';";
                        
$sql[] = "DELETE FROM ".$db_prefix."_online_users WHERE id = '".$uid."';";
                        
$sql[] = "UPDATE ".$db_prefix."_torrents SET owner = '0', ownertype = '2' WHERE owner = '".$uid."';";
                        
$sql[] = "UPDATE ".$db_prefix."_peers SET uid = '0' WHERE uid = '".$uid."';";
                        
$sql[] = "DELETE FROM ".$db_prefix."_private_messages_blacklist WHERE master = '".$uid."' OR slave = '".$uid."';";
                        
$sql[] = "DELETE FROM ".$db_prefix."_private_messages_bookmarks WHERE master = '".$uid."' OR slave = '".$uid."';";
                        
$sql[] = "DELETE FROM ".$db_prefix."_private_messages WHERE recipient = '".$uid."';";
                        
$sql[] = "DELETE FROM ".$db_prefix."_users WHERE id = '".$uid."';";

                        foreach (
$sql as $query) {
                                
$db->sql_query($query) or btsqlerror($sql);
                        }
}
?>

or somthing like that


http://a.imageshack.us/img831/5562/mybikes.png

[Updated on: Sat, 01 March 2008 16:25]

Report message to a moderator

Re: Auto deleting users [message #1823 is a reply to message #1353] Sat, 01 March 2008 19:26 Go to previous messageGo to next message
Revan is currently offline Revan  Czech Republic
Messages: 125
Registered: April 2007
Super-Seeder
ok will do...
i'll try it both ways probably and post here result later Smile
Re: Auto deleting users [message #1838 is a reply to message #1823] Mon, 10 March 2008 01:33 Go to previous messageGo to next message
DrAgon  United States
Messages: 192
Registered: August 2007
Super-Seeder
Bug hunter
Great work, Guys.

What's the result on this?

Thanks
Re: Auto deleting users [message #1850 is a reply to message #1353] Fri, 14 March 2008 20:28 Go to previous messageGo to next message
Revan is currently offline Revan  Czech Republic
Messages: 125
Registered: April 2007
Super-Seeder
didn't have too much time to work on this - sorry...
anyway here's what i did so far:

sql that needs to be run:
ALTER TABLE `torrent_config` ADD `autodel_users` ENUM( 'true', 'false' ) NOT NULL DEFAULT 'false',
ADD `inactwarning_time` INT( 10 ) NOT NULL DEFAULT '0',
ADD `autodel_users_time` INT( 10 ) NOT NULL DEFAULT '0';
ALTER TABLE `torrent_users` ADD `inactwarning` TINYINT( 1 ) NOT NULL DEFAULT '0';


then in include/config.php
find: $version = $row["version"];
and add after:
$autodel_users = ($row["autodel_users"] == "true") ? true : false;
$inactwarning_time = $row["inactwarning_time"];
$autodel_users_time = $row["autodel_users_time"];


then open include/cleanup.php
find:
function cleanup() {
        global $db, $db_prefix, $btuser, $autoscrape, $dead_torrent_interval, $announce_interval;

        $db->sql_query("DELETE FROM ".$db_prefix."_download WHERE date < SUBDATE(SYSDATE(), INTERVAL 7 DAY);");
        $db->sql_query("DELETE FROM ".$db_prefix."_users WHERE active = 0 AND UNIX_TIMESTAMP(regdate) < UNIX_TIMESTAMP(NOW()) - 432000;");

and add after:
if ($autodel_users == true)	
{
$userwarninactivesub = Array();
$userwarninactivesub[english] = "".$sitename." Warning";
$userwarninactivesub[german] = "".$sitename." Achtung";
$userwarninactivesub[spanish] = "Advertencia".$sitename."";
$userwarninactivesub[brazilian] = "".$sitename." adverte";
$userwarninactivesub[portuguese] = "".$sitename." adverte";

$userwarninactivetext = Array();

$userwarninactivetext[english] = "".$warntexten1.$warntexten2.$warntexten3."";
$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[german] = "".$warntextger1.$warntextger2.$warntextger3."";
$warntextger1 = "Wir möchten darauf hinweisen , dass du auf **siteurl** seit mehr als **inactwarning_time** Tagen nicht mehr aktiv warst, 
wenn Du nicht willst, dass dein Account gelöscht wird, logge dich bitte ein. 
";
if ($autodel_users_time != 0)
{
$warntextger2 = "Du hast ab jetzt **autodel_users_time** Tage Zeit um dich auf **sitename** einzuloggen.
Ansonsten werden wir deinen Account permanent löschen.";
}
else $warntextger2 = "";
$warntextger3 = "
Danke**sitename**Admin.
**siteurl**";

$userwarninactivetext[spanish] = "".$warntextspa1.$warntextspa2.$warntextspa3."";
$warntextspa1 = "Hola, 
Queriamos decirte que no visitaste nuestra pagina **siteurl** por mas de **inactwarning_time** dias.
Si no quieres que tu Cuenta sea borrada, por favor logueate. 
";
if ($autodel_users_time != 0)
{
$warntextspa2 = "Tienes **autodel_users_time** dias para loguearte nuevamente apartir de hoy.
De otra manera borraremos tu cuenta de forma permanente.";
}
else $warntextspa2 = "";
$warntextspa3 = "
Gracias. Los **sitename** administradores
**siteurl**";


$userwarninactivetext[brazilian] = "".$warntextbra1.$warntextbra2.$warntextbra3."";
$warntextbra1 = "Oi,
Nós gostaríamos de avisa-lo que voce nao tem estado ativo no **siteurl** por mais de **inactwarning_time** dias.
Se voce nao quer ter sua conta excluída, por favor conecte-se. 
";
if ($autodel_users_time != 0)
{
$warntextbra2 = "Voce tem **autodel_users_time** dias a partir de hoje para fazer isso.
Caso contrário nós iremos apagar sua conta permanentemente.";
}
else $warntextbra2 = "";
$warntextbra3 = "
Obrigado **sitename** Administrador
**siteurl**";

$userwarninactivetext[portuguese] = "".$warntextpor1.$warntextpor2.$warntextpor3."";
$warntextpor1 = "Oi,
Nós gostaríamos de avisa-lo que voce nao tem estado ativo no **siteurl** por mais de **inactwarning_time** dias.
Se voce nao quer ter sua conta excluída, por favor conecte-se. 
";
if ($autodel_users_time != 0)
{
$warntextpor2 = "Voce tem **autodel_users_time** dias a partir de hoje para fazer isso.
Caso contrário nós iremos apagar sua conta permanentemente.";
}
else $warntextpor2 = "";
$warntextpor3 = "
Obrigado **sitename** Administrador
**siteurl**";

$admin_email ="YOUR ADMIN MAIL";
$sitename= "YOUR SITE NAME";
$siteurl= "YOUR SITE URL";

$res1 = "SELECT id, email, inactwarning, lastlogin, language, ban FROM ".$db_prefix."_users;";
$res2 = $db->sql_query($res1);
while ($get_info = $db->sql_fetchrow($res2))
{
if ($get_info[inactwarning] == 0 AND $get_info[lastlogin] != 0 AND $get_info[ban] != 1 AND $get_info[lastlogin] < date('Y-m-d H:i:s', time() - 2592000)) 
{
$db->sql_query("UPDATE ".$db_prefix."_users SET inactwarning = 1 WHERE ((UNIX_TIMESTAMP(lastlogin) < UNIX_TIMESTAMP(NOW()) - ".$inactwarning_time.") AND (UNIX_TIMESTAMP(lastlogin) <> 0));");
$replace_markers = Array("**sitename**","**siteurl**,**inactwarning_time**,**autodel_users_time**");
$replace_data = Array ($sitename,$siteurl,$inactwarning_time,$autodel_users_time);
if ($get_info[language] == "") $get_info[language] = "english";
$warn_mail = New eMail;
$warn_mail->sender = $admin_email;
$warn_mail->subject = $userwarninactivesub[$get_info[language]];
$warn_mail->body = str_replace($replace_markers,$replace_data,$userwarninactivetext[$get_info[language]]);
$warn_mail->Add($get_info[email]);
$warn_mail->Send();
}
if ($get_info[inactwarning] == 1 AND $get_info[lastlogin] != 0 AND $get_info[lastlogin] > date('Y-m-d H:i:s', time() - $inactwarning_time))
{
$db->sql_query("UPDATE ".$db_prefix."_users SET inactwarning = 0 WHERE (inactwarning = 1) AND (UNIX_TIMESTAMP(lastlogin) > UNIX_TIMESTAMP(NOW()) - ".$inactwarning_time.");");
}
if ($autodel_users_time != 0)
{
if ($get_info[inactwarning] == 1 AND $get_info[lastlogin] != 0 AND $get_info[lastlogin] < date('Y-m-d H:i:s', time() - $autodel_users_time))
{
$sql = "SELECT id FROM ".$db_prefix."_users WHERE (inactwarning = 1) AND (UNIX_TIMESTAMP(lastlogin) < UNIX_TIMESTAMP(NOW()) - ".$autodel_users_time.");";
$res = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($res))
  {
  $op = "delete";
  $id = $row[id];
  include("user.php");
  }
}
}
}
}


then open user.php
find:
if (!eregi("user.php",$_SERVER["PHP_SELF"])) die ("You cannot include this file");

and replace with:
if (!eregi("user.php",$_SERVER["PHP_SELF"]) and !eregi("cleanup.php",$_SERVER["PHP_SELF"])) die ("You cannot include this file");


i didn't have the time to test this fully, but i thought i'd post what i did so far... what i need to do next are 3 options in administration for setting this up...
i'll also post a version without changing user.php later too

let me know if it needs some more work or it has some bugs or something

[Updated on: Sat, 15 March 2008 15:59]

Report message to a moderator

Re: Auto deleting users [message #1879 is a reply to message #1850] Sun, 23 March 2008 05:53 Go to previous messageGo to next message
DrAgon  United States
Messages: 192
Registered: August 2007
Super-Seeder
Bug hunter
Thanks for posting whatever you got so far.

That's great.

hopefully time will be nice to all of us and allow us to work on it.
Re: Auto deleting users [message #1895 is a reply to message #1879] Wed, 26 March 2008 22:37 Go to previous messageGo to next message
DrAgon  United States
Messages: 192
Registered: August 2007
Super-Seeder
Bug hunter
Revan,

We can't allow this to slip by as it is a great hack and it is still fresh in your mind and you are the only one who can bring it to a closure.

I have to finish another project that deals with another tracker integration with smf.

Please finish this as you know more about the mod/hack and Joe is busy with other stuff.

We need this hack.

Thank you.
Re: Auto deleting users [message #1896 is a reply to message #1353] Thu, 27 March 2008 17:10 Go to previous messageGo to next message
Revan is currently offline Revan  Czech Republic
Messages: 125
Registered: April 2007
Super-Seeder
Sure I will, I'm just little bit busy with all the work I got atm... But I got friday off - so expect it done by the end of this weekend, 99% probability Smile
Good luck with your project both of you Wink
Re: Auto deleting users [message #1897 is a reply to message #1896] Thu, 27 March 2008 19:35 Go to previous messageGo to next message
DrAgon  United States
Messages: 192
Registered: August 2007
Super-Seeder
Bug hunter
Damn..

I feel like one of those completely useless project managers that sits around and just assigns individuals or teams to tasks/projects.
Twisted Evil

If I only can get Joe to do some real work instead of acting like everything is so complicated and he has to do them alone. Razz

Okay..that's enough joking for today. Laughing

back to fun work.
Re: Auto deleting users [message #1904 is a reply to message #1353] Sun, 30 March 2008 14:34 Go to previous messageGo to next message
Revan is currently offline Revan  Czech Republic
Messages: 125
Registered: April 2007
Super-Seeder
here it is:
1st we need to run these sql queries:
CREATE TABLE `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; 

INSERT INTO `torrent_userautodel`
SET inactwarning_time = '0',
autodel_users_time = '0',
autodel_users = 'true';


ALTER TABLE `torrent_users` ADD `inactwarning` tinyint(1) NOT NULL DEFAULT '0';


then below this
if (!$row = $db->sql_fetchrow($configquery)) die("phpMyBitTorrent not correctly installed! Ensure you have run setup.php or config_default.sql!!");
in config.php add:
$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
$version = $row["version"];
add
$inactwarning_time = $row3["inactwarning_time"]*86400;
$autodel_users_time = $row3["autodel_users_time"]*86400;
$autodel_users = ($row3["autodel_users"] == "true") ? true : false;


that's it for config.php, now add this to functions.php:
function removedinactive($uid){
                        global $db, $db_prefix;
                        $sql = "SELECT username FROM ".$db_prefix."_users WHERE id = '".$uid."';";
                        $res = $db->sql_query($sql);
                        list ($username) = $db->sql_fetchrow($res);
                        $db->sql_freeresult($res);
                        if (empty($username)) return;



                        $sql = "SELECT avatar FROM ".$db_prefix."_users WHERE id = '".$id."';";
                        $res = $db->sql_query($sql);
                        list ($avatar) = $db->sql_fetchrow($res);
                        $db->sql_freeresult($sql);
                        if (eregi("^user/",$avatar)) @unlink($avatar);

                        
                        $sql = Array();
                        $sql[] = "DELETE FROM ".$db_prefix."_download_completed WHERE user = '".$uid."';";
                        $sql[] = "DELETE FROM ".$db_prefix."_privacy_backup WHERE master = '".$uid."' OR slave = '".$uid."';";
                        $sql[] = "DELETE FROM ".$db_prefix."_privacy_file WHERE master = '".$uid."' OR slave = '".$uid."';";
                        $sql[] = "DELETE FROM ".$db_prefix."_privacy_global WHERE master = '".$uid."' OR slave = '".$uid."';";
                        $sql[] = "DELETE FROM ".$db_prefix."_comments_notify WHERE user = '".$uid."';";
                        $sql[] = "DELETE FROM ".$db_prefix."_seeder_notify WHERE user = '".$uid."';";
                        $sql[] = "DELETE FROM ".$db_prefix."_online_users WHERE id = '".$uid."';";
                        $sql[] = "UPDATE ".$db_prefix."_torrents SET owner = '0', ownertype = '2' WHERE owner = '".$uid."';";
                        $sql[] = "UPDATE ".$db_prefix."_peers SET uid = '0' WHERE uid = '".$uid."';";
                        $sql[] = "DELETE FROM ".$db_prefix."_private_messages_blacklist WHERE master = '".$uid."' OR slave = '".$uid."';";
                        $sql[] = "DELETE FROM ".$db_prefix."_private_messages_bookmarks WHERE master = '".$uid."' OR slave = '".$uid."';";
                        $sql[] = "DELETE FROM ".$db_prefix."_private_messages WHERE recipient = '".$uid."';";
                        $sql[] = "DELETE FROM ".$db_prefix."_users WHERE id = '".$uid."';";

                        foreach ($sql as $query) {
                                $db->sql_query($query) or btsqlerror($sql);
                        }
} 


now find
function cleanup() {
        global $db, $db_prefix, $btuser, $autoscrape, $dead_torrent_interval, $announce_interval;

        $db->sql_query("DELETE FROM ".$db_prefix."_download WHERE date < SUBDATE(SYSDATE(), INTERVAL 7 DAY);");
        $db->sql_query("DELETE FROM ".$db_prefix."_users WHERE active = 0 AND UNIX_TIMESTAMP(regdate) < UNIX_TIMESTAMP(NOW()) - 432000;");
in cleanup.php and add below it:
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öchten darauf hinweisen , dass du auf **siteurl** seit mehr als **inactwarning_time** Tagen nicht mehr aktiv warst, 
wenn Du nicht willst, dass dein Account gelöscht wird, logge dich bitte ein. 
";
if ($autodel_users_time != 0)
{
$warntextger2 = "Du hast ab jetzt **autodel_users_time** Tage Zeit um dich auf **sitename** einzuloggen.
Ansonsten werden wir deinen Account permanent löschen.";
}
else $warntextger2 = "";
$warntextger3 = "
Danke**sitename**Admin.
**siteurl**";

$userwarninactivetext[german] = "".$warntextger1.$warntextger2.$warntextger3."";

$warntextspa1 = "Hola, 
Queriamos decirte que no visitaste nuestra pagina **siteurl** por mas de **inactwarning_time** dias.
Si no quieres que tu Cuenta sea borrada, por favor logueate. 
";
if ($autodel_users_time != 0)
{
$warntextspa2 = "Tienes **autodel_users_time** dias para loguearte nuevamente apartir de hoy.
De otra manera borraremos tu cuenta de forma permanente.";
}
else $warntextspa2 = "";
$warntextspa3 = "
Gracias. Los **sitename** administradores
**siteurl**";

$userwarninactivetext[spanish] = "".$warntextspa1.$warntextspa2.$warntextspa3."";

$warntextbra1 = "Oi,
Nós gostaríamos de avisa-lo que voce nao tem estado ativo no **siteurl** por mais de **inactwarning_time** dias.
Se voce nao quer ter sua conta excluída, por favor conecte-se. 
";
if ($autodel_users_time != 0)
{
$warntextbra2 = "Voce tem **autodel_users_time** dias a partir de hoje para fazer isso.
Caso contrário nós iremos apagar sua conta permanentemente.";
}
else $warntextbra2 = "";
$warntextbra3 = "
Obrigado **sitename** Administrador
**siteurl**";
$userwarninactivetext[brazilian] = "".$warntextbra1.$warntextbra2.$warntextbra3."";

$warntextpor1 = "Oi,
Nós gostaríamos de avisa-lo que voce nao tem estado ativo no **siteurl** por mais de **inactwarning_time** dias.
Se voce nao quer ter sua conta excluída, por favor conecte-se. 
";
if ($autodel_users_time != 0)
{
$warntextpor2 = "Voce tem **autodel_users_time** dias a partir de hoje para fazer isso.
Caso contrário nós iremos apagar sua conta permanentemente.";
}
else $warntextpor2 = "";
$warntextpor3 = "
Obrigado **sitename** Administrador
**siteurl**";

$userwarninactivetext[portuguese] = "".$warntextpor1.$warntextpor2.$warntextpor3."";

$sql = "SELECT id, email, inactwarning, lastlogin, language, ban FROM ".$db_prefix."_users;";
$res = $db->sql_query($sql);

while ($get_info = $db->sql_fetchrow($res))
{
if ($get_info["inactwarning"] == 0 AND $get_info["lastlogin"] != 0 AND $get_info["ban"] != 1 AND $get_info["lastlogin"] < date('Y-m-d H:i:s', time() - $inactwarning_time)) 
{
$db->sql_query("UPDATE ".$db_prefix."_users SET inactwarning = 1 WHERE ((UNIX_TIMESTAMP(lastlogin) < UNIX_TIMESTAMP(NOW()) - ".$inactwarning_time.") AND (UNIX_TIMESTAMP(lastlogin) <> 0));");
$replace_markers = Array("**sitename**","**siteurl**","**inactwarning_time**","**autodel_users_time**");
$replace_data = Array ("".$sitename."","".$siteurl."","".($inactwarning_time/86400)."","".($autodel_users_time/86400)."");
if ($get_info[language] == "") $get_info[language] = "english";
$warn_mail = New eMail;
$warn_mail->sender = $admin_email;
$warn_mail->subject = $userwarninactivesub[$get_info[language]];
$warn_mail->body = str_replace($replace_markers,$replace_data,$userwarninactivetext[$get_info[language]]);
$warn_mail->Add($get_info[email]);
$warn_mail->Send();
}
if ($get_info[inactwarning] == 1 AND $get_info[lastlogin] != 0 AND $get_info[lastlogin] > date('Y-m-d H:i:s', time() - $inactwarning_time))
{
$db->sql_query("UPDATE ".$db_prefix."_users SET inactwarning = 0 WHERE ((inactwarning = 1) AND (UNIX_TIMESTAMP(lastlogin) > UNIX_TIMESTAMP(NOW()) - ".$inactwarning_time."));");
}
if ($autodel_users_time != 0)
{
  if ($get_info[inactwarning] == 1 AND $get_info[lastlogin] != 0 AND $get_info[lastlogin] < date('Y-m-d H:i:s', time() - $autodel_users_time))
  {
    $sql = "SELECT id FROM ".$db_prefix."_users WHERE ((inactwarning = 1) AND (UNIX_TIMESTAMP(lastlogin) < UNIX_TIMESTAMP(NOW()) - ".$autodel_users_time."));";
    $res = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($res))
    {
      removedinactive($row[id]);
    }
  }
}
}
}


only thing left to do is to extract those two files in attached to admin directory, after that you should find "Autodeleting of Users" in your admin control panel Smile

If you find any bugs or something, let me know... Other than that the only error I know about is that the description in administration is hardcoded to english, I'll try to get it translated (if I don't forget Very Happy )
Re: Auto deleting users [message #1905 is a reply to message #1904] Sun, 30 March 2008 19:59 Go to previous messageGo to next message
DrAgon  United States
Messages: 192
Registered: August 2007
Super-Seeder
Bug hunter
holy mother of jesus! Razz
that is some hard core hack...thank you for finalizing it.

I apply to pmbt version 1.2.2 non-full-modded and see.


Re: Auto deleting users [message #1923 is a reply to message #1905] Tue, 08 April 2008 09:43 Go to previous messageGo to next message
Revan is currently offline Revan  Czech Republic
Messages: 125
Registered: April 2007
Super-Seeder
DrAgon wrote on Sun, 30 March 2008 11:59

holy mother of jesus! Razz
that is some hard core hack...thank you for finalizing it.

I apply to pmbt version 1.2.2 non-full-modded and see.




Glad you like it Smile
I hope it works without problems
Re: Auto deleting users [message #2050 is a reply to message #1923] Wed, 21 May 2008 04:53 Go to previous messageGo to next message
DrAgon  United States
Messages: 192
Registered: August 2007
Super-Seeder
Bug hunter
Will this work with my 1.2.2 version or do I have to have full-modded version?

any idea, anyone?

well..I have both of those releases and etc......

just have to try it in each..! ..ahay!

Re: Auto deleting users [message #2052 is a reply to message #1353] Wed, 21 May 2008 09:30 Go to previous messageGo to next message
Revan is currently offline Revan  Czech Republic
Messages: 125
Registered: April 2007
Super-Seeder
I think I developed it under full-modded, but it should work with 1.2.2 as well (I don't remember using any functions of modded one)
Re: Auto deleting users [message #2053 is a reply to message #2050] Wed, 21 May 2008 09:35 Go to previous messageGo to next message
joeroberts is currently offline joeroberts  United States
Messages: 1971
Registered: June 2006
Location: U.S.A
Releaser
Da HacKer
shouldn't the clean code be
<?php
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öchten darauf hinweisen , dass du auf **siteurl** seit mehr als **inactwarning_time** Tagen nicht mehr aktiv warst,
wenn Du nicht willst, dass dein Account gelöscht wird, logge dich bitte ein.
"
;
if (
$autodel_users_time != 0)
{
$warntextger2 = "Du hast ab jetzt **autodel_users_time** Tage Zeit um dich auf **sitename** einzuloggen.
Ansonsten werden wir deinen Account permanent löschen."
;
}
else
$warntextger2 = "";
$warntextger3 = "
Danke**sitename**Admin.
**siteurl**"
;

$userwarninactivetext["german"] = "".$warntextger1.$warntextger2.$warntextger3."";

$warntextspa1 = "Hola,
Queriamos decirte que no visitaste nuestra pagina **siteurl** por mas de **inactwarning_time** dias.
Si no quieres que tu Cuenta sea borrada, por favor logueate.
"
;
if (
$autodel_users_time != 0)
{
$warntextspa2 = "Tienes **autodel_users_time** dias para loguearte nuevamente apartir de hoy.
De otra manera borraremos tu cuenta de forma permanente."
;
}
else
$warntextspa2 = "";
$warntextspa3 = "
Gracias. Los **sitename** administradores
**siteurl**"
;

$userwarninactivetext["spanish"] = "".$warntextspa1.$warntextspa2.$warntextspa3."";

$warntextbra1 = "Oi,
Nós gostaríamos de avisa-lo que voce nao tem estado ativo no **siteurl** por mais de **inactwarning_time** dias.
Se voce nao quer ter sua conta excluída, por favor conecte-se.
"
;
if (
$autodel_users_time != 0)
{
$warntextbra2 = "Voce tem **autodel_users_time** dias a partir de hoje para fazer isso.
Caso contrário nós iremos apagar sua conta permanentemente."
;
}
else
$warntextbra2 = "";
$warntextbra3 = "
Obrigado **sitename** Administrador
**siteurl**"
;
$userwarninactivetext["brazilian"] = "".$warntextbra1.$warntextbra2.$warntextbra3."";

$warntextpor1 = "Oi,
Nós gostaríamos de avisa-lo que voce nao tem estado ativo no **siteurl** por mais de **inactwarning_time** dias.
Se voce nao quer ter sua conta excluída, por favor conecte-se.
"
;
if (
$autodel_users_time != 0)
{
$warntextpor2 = "Voce tem **autodel_users_time** dias a partir de hoje para fazer isso.
Caso contrário nós iremos apagar sua conta permanentemente."
;
}
else
$warntextpor2 = "";
$warntextpor3 = "
Obrigado **sitename** Administrador
**siteurl**"
;

$userwarninactivetext["portuguese"] = "".$warntextpor1.$warntextpor2.$warntextpor3."";

$sql = "SELECT id, email, inactwarning, lastlogin, language, ban FROM ".$db_prefix."_users;";
$res = $db->sql_query($sql);

while (
$get_info = $db->sql_fetchrow($res))
{
if (
$get_info["inactwarning"] == 0 AND $get_info["lastlogin"] != 0 AND $get_info["ban"] != 1 AND $get_info["lastlogin"] < date('Y-m-d H:i:s', time() - $inactwarning_time))
{
$db->sql_query("UPDATE ".$db_prefix."_users SET inactwarning = 1 WHERE ((UNIX_TIMESTAMP(lastlogin) < UNIX_TIMESTAMP(NOW()) - ".$inactwarning_time.") AND (UNIX_TIMESTAMP(lastlogin) <> 0));");
$replace_markers = Array("**sitename**","**siteurl**","**inactwarning_time**","**autodel_users_time**");
$replace_data = Array ("".$sitename."","".$siteurl."","".($inactwarning_time/86400)."","".($autodel_users_time/86400)."");
if (
$get_info["language"] == "") $get_info["language"] = "english";
$warn_mail = New eMail;
$warn_mail->sender = $admin_email;
$warn_mail->subject = $userwarninactivesub[$get_info["language"]];
$warn_mail->body = str_replace($replace_markers,$replace_data,$userwarninactivetext[$get_info["language"]]);
$warn_mail->Add($get_info["email"]);
$warn_mail->Send();
}
if (
$get_info["inactwarning"] == 1 AND $get_info["lastlogin"] != 0 AND $get_info["lastlogin"] > date('Y-m-d H:i:s', time() - $inactwarning_time))
{
$db->sql_query("UPDATE ".$db_prefix."_users SET inactwarning = 0 WHERE ((inactwarning = 1) AND (UNIX_TIMESTAMP(lastlogin) > UNIX_TIMESTAMP(NOW()) - ".$inactwarning_time."));");
}
if (
$autodel_users_time != 0)
{
  if (
$get_info["inactwarning"] == 1 AND $get_info["lastlogin"] != 0 AND $get_info["lastlogin"] < date('Y-m-d H:i:s', time() - $autodel_users_time))
  {
    
$sql = "SELECT id FROM ".$db_prefix."_users WHERE ((inactwarning = 1) AND (UNIX_TIMESTAMP(lastlogin) < UNIX_TIMESTAMP(NOW()) - ".$autodel_users_time."));";
    
$res = $db->sql_query($sql);
    while (
$row = $db->sql_fetchrow($res))
    {
      
removedinactive($row["id"]);
    }
  }
}
}
}
?>

you missed a bunch of ["]


http://a.imageshack.us/img831/5562/mybikes.png
Re: Auto deleting users [message #2056 is a reply to message #2053] Wed, 21 May 2008 18:12 Go to previous message
Revan is currently offline Revan  Czech Republic
Messages: 125
Registered: April 2007
Super-Seeder
joeroberts wrote on Wed, 21 May 2008 01:35

you missed a bunch of ["]

if the only change you did were quotation marks in arrays, then it works even without them..
but it's probably better when they'll be used when i use them later in $get_info... thanks for adding Smile
Previous Topic:torrent peerlist pecentage completion bar
Next Topic:How to remove Ed2K Upload Link
Goto Forum:
  


Current Time: Wed Feb 08 12:02:34 GMT 2012

Total time taken to generate the page: 0.00962 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software