Home » Discussion Forums » M0dZ & HaCkZ » Auto deleting users
| Auto deleting users [message #1353] |
Mon, 17 September 2007 19:19  |
Revan  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 #1822 is a reply to message #1821] |
Sat, 01 March 2008 16:24   |
|
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
[Updated on: Sat, 01 March 2008 16:25] Report message to a moderator
|
|
| | |
| Re: Auto deleting users [message #1850 is a reply to message #1353] |
Fri, 14 March 2008 20:28   |
Revan  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 #1904 is a reply to message #1353] |
Sun, 30 March 2008 14:34   |
Revan  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 
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 )
|
|
| | | | |
| Re: Auto deleting users [message #2053 is a reply to message #2050] |
Wed, 21 May 2008 09:35   |
|
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 ["]
|
|
| |
Goto Forum:
Current Time: Wed Feb 08 12:02:34 GMT 2012
Total time taken to generate the page: 0.00962 seconds
|