Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
[Mod] Manage Inactive Users
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / v2.08 / v2 Only Mods Complete

Unknown User
2012-01-31 09:24:43
[size=18px]This mod works very well on my tracker TT v2.07, so I thought not to be selfish and share it to all members[/size]   :)

Create a file called inactiveusers.php and upload it in your root:

<?

//-----------------------------------------------//

//  Inactive Users Management //

//-----------------------------------------------//

//  Modified for TorrentTrader v2.xx by BigMax   //

//-----------------------------------------------//



require_once("backend/functions.php");

dbconn(true);

loggedinonly();



if(get_user_class() < 6)

show_error_msg("Acces Denied","I smelled a rat here!");



// Config

$sitename = "".$site_config['SITENAME'].""; // Sitename

$siteurl = "".$site_config['SITEURL'].""; // Default site url

$replyto = "".$site_config['SITEEMAIL'].""; // The Reply-to email

$record_mail = true; // Set this true or false . If you set this true every time whene you send a mail the time , userid , and the number of mail sent will be recorded

$days = 30; // Number of days of inactivite

// End config



if ($_SERVER["REQUEST_METHOD"] == "POST")

{



$action = $_POST["action"];

$cday = 0 + $_POST["cday"];



if (!is_numeric($cday))

show_error_msg("Err","Smell rat !");



if (empty($_POST["userid"]) && (($action == "deluser") || ($action == "mail")))

show_error_msg("Err","For this to work you must select at least a user !");



if ($action == "deluser" && (!empty($_POST["userid"])))

{

mysql_query("DELETE FROM users WHERE id IN (" . implode(", ", $_POST['userid']) . ") ");

show_error_msg("Successfully","You have successfully deleted the selected accounts! <a href="".$BASEURL."/inactiveusers.php">Go back</a>");

}



if ($action == "cday" && ($cday > $days))

$days = $cday;



if ($action == "disable" && (!empty($_POST["userid"])))

{

$res = mysql_query("SELECT id, modcomment FROM users WHERE id IN (" . implode(", ", $_POST['userid']) . ") ORDER BY id DESC ")or sqlerr(__FILE__, __LINE__);

while ($arr = mysql_fetch_array($res))

{

$id = 0 + $arr["id"];

$cname = $CURUSER["username"];

$modcomment = $arr["modcomment"];

$modcomment = gmdate("Y-m-d") . " - Disabled for inactivity by $cname.n".$modcomment;



mysql_query("UPDATE users SET modcomment=".sqlesc($modcomment).", enabled='no' WHERE id=$id ") or sqlerr(__FILE__, __LINE__);

}

show_error_msg("Successfully","You have successfully disabled the selected accounts! <a href="".$BASEURL."/inactiveusers.php">Go back</a>");

}



if ($action == "mail" && (!empty($_POST["userid"])))

{



$res = mysql_query("SELECT id, email , username, added, last_access FROM users WHERE id IN (" . implode(", ", $_POST['userid']) . ") ORDER BY last_access DESC ");

$count = mysql_num_rows($res);

while ($arr = mysql_fetch_array($res))

{

$id = $arr["id"];

$username = htmlspecialchars($arr["username"]);

$email = htmlspecialchars($arr["email"]);

$added = $arr["added"];

$last_access = $arr["last_access"];



$subject = "Warning for inactive account on $sitename";

$message = "

Your account on  $sitename  was marked as inactive and will be deleted within a few days.

If you want to remain member at $sitename you must just login and download something nice!



Your username it's:  $username

Account created on:  $added

Last visit on site:  $last_access



You can login here:  $siteurl/account-login.php

Recovery password: $siteurl/account-recover.php

";

$headers = 'From: no-reply@' . $sitename . "rn" .

'Reply-To:' . $replyto . "rn" .

'X-Mailer: PHP/' . phpversion();



$mail= @mail($email, $subject, $message, $headers);

}



if($record_mail){

$date = time();

$userid = 0 + $CURUSER["id"];

if ($count > 0 && $mail)

mysql_query("update avps set value_i='$date', value_u='$count', value_s='$userid' WHERE arg='inactivemail' ") or sqlerr(__FILE__, __LINE__);

}



if ($mail)

show_error_msg("Success", "Messages sent.");

else

show_error_msg("Error", "Try again.");

}

}

stdhead("Inactive Users");

begin_frame("Inactive Users");



$dt = sqlesc(get_date_time(gmtime() - ($days * 86400)));



$res= mysql_query("SELECT id,username,class,email,uploaded,downloaded,last_access,ip,added FROM users WHERE last_access<$dt AND status='confirmed' AND enabled='yes' ORDER BY last_access DESC ") or sqlerr(__FILE__, __LINE__);

$count = mysql_num_rows($res);

if ($count > 0){

?>

<script type="text/javascript" LANGUAGE="JavaScript">



<!-- Begin

var checkflag = "false";

function check(field) {

if (checkflag == "false") {

for (i = 0; i < field.length; i++) {

field[i].checked = true;}

checkflag = "true";

return "Uncheck All"; }

else {

for (i = 0; i < field.length; i++) {

field[i].checked = false; }

checkflag = "false";

return "Check All"; }

}

// End -->

</script>

<?

print("<form action="inactiveusers.php" method="post">");

print("<br><table class=table_table align=center border=1 cellspacing=0 cellpadding=5><tr>n");

print("<td class=table_head>Number of days</td><td class=table_head><input type="text" name="cday" size="10" value="".($cday > $days ? $cday : $days)."" maxlength="3" /></td>");

print("<td class="table_head"><input type="submit" value="Change" /><input type="hidden" name='action' value="cday" />");

print("</td></tr></table></form><br/>");



print("<h2 align=center>".$count." accounts inactive for longer than ".$days." days.</h2>");

print("<form action="inactiveusers.php" method="post">");

print("<table class=table_table align=center width=800 border=1 cellspacing=0 cellpadding=5><tr>n");

print("<td class=table_head>Username</td>");

print("<td class=table_head>Class</td>");

print("<td class=table_head>IP</td>");

print("<td class=table_head>Ratio</td>");

print("<td class=table_head>Join Date</td>");

print("<td class=table_head>Last Seen</td>");

print("<td class=table_head align="center">x</td>");



while ($arr = mysql_fetch_assoc($res)) {

$ratio = ($arr["downloaded"] > 0 ? number_format($arr["uploaded"] / $arr["downloaded"], 3) : ($arr["uploaded"] > 0 ? "Inf." : "---"));

$ratio = "<font color=" . get_ratio_color($ratio) . ">$ratio</font>";

$downloaded = mksize($arr["downloaded"]);

$uploaded = mksize($arr["uploaded"]);

$last_seen = (($arr["last_access"] == "0000-00-00 00:00:00") ? "never" : "".get_elapsed_time(sql_timestamp_to_unix_timestamp($arr["last_access"]))."&nbsp;ago" );

$class=get_user_class_name($arr["class"]);

$joindate = substr($arr['added'], 0, strpos($arr['added'], " "));

print("<tr>");



// Make a choise here:

print("<td><a href="account-details.php?id=".$arr["id"]."">".htmlspecialchars($arr["username"])."</a></td>"); //=== Use this line if you did not have the function class_user ===//

//print("<td><a href="account-details.php?id=".$arr["id"].""><b>".class_user($arr["username"])."</b></a></td>"); //=== Use this line if you have the function class_user ===//



print("<td>".$class."</td>");

print("<td>".($arr["ip"] == "" ? "----" : $arr["ip"] )."</td>");

print("<td><b>".$ratio."</b><font class="small"> | Dl:<font color=red><b>".$downloaded."</b></font> | Up:<font color=lime><b>".$uploaded."</b></font></font></td>");

print("<td>".$joindate."</td>");

print("<td>".$last_seen."</td>");



print("<td align="center" bgcolor="#FF0000"><input type="checkbox" name="userid[]" value="".$arr["id"]."" /></td>");

print("</tr>");

}

print("<tr><td colspan="7" class="table_head" align="center">

<select name="action">

<option value="mail">Send mail</option>

<option value="deluser">Delete users</option>

<option value="disable">Disable Accounts</option>

</select>&nbsp;&nbsp;<input type="submit" name="submit" value="Apply Changes"/>&nbsp;&nbsp;<input type="button" value="Check all" onClick="this.value=check(form)" /></td></tr>");



if($record_mail){

$ress = mysql_query("SELECT avps.value_s AS userid, avps.value_i AS last_mail, avps.value_u AS mails, users.username FROM avps LEFT JOIN users ON avps.value_s=users.id WHERE avps.arg='inactivemail' LIMIT 1");

$date = mysql_fetch_assoc($ress);

if ($date["last_mail"] > 0 )

print("<tr><td colspan="7" class="table_head" align="center" style="color:red;">Last mail sent by <a href="account-details.php?id=".$date["userid"]."">".$date["username"]."</a> on <b>".gmdate("d M Y",$date["last_mail"])."</b> and <b>".$date["mails"]."</b> mail".($date["mails"] > 1 ? "s" : "")." was sent!</td></tr>");

}



print("</table></form>");

}else{

print("<h2 align=center>No account inactive for longer than ".$days." days.</h2>");

}

end_frame();

stdfoot();

die;

?>
Extract attached file avps.zip and import in your database.



Upload attached file inactiveusers.png in: /images/admin



Add in admincp.php (Staff CP):


<td align=center><a href=inactiveusers.php><img src="images/admin/inactiveusers.png" border=0 width=32 height=32><br>Inactive Users</a><BR></td>

[url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=5530"]avps.zip[/url]

avps.zip
Download
inactiveusers.png
inactiveusers.png
Unknown User
2012-01-31 13:33:07
thanks very much.looks great!
2012-02-25 16:48:12
Big thanks!  :D

TT V2.07
Unknown User
2012-02-28 23:44:04
is it possible to see the mail i sent...im confused..if the users gets the mail or not.. :o
Unknown User
2012-03-02 17:08:48
noone..:blink:
Unknown User
2012-03-02 18:55:17
thank you .... works very well with TT V2.05
Unknown User
2012-07-22 12:19:38
ok I had to do a lot of editing to get it up to snuff for the 2.08 ver

import to sql





CREATE TABLE IF NOT EXISTS `avps` (

`arg` varchar(20) character set latin1 collate latin1_general_ci NOT NULL default '',

`value_s` text character set latin1 collate latin1_general_ci NOT NULL,

`value_i` int(11) NOT NULL default '0',

`value_u` int(10) unsigned NOT NULL default '0',

PRIMARY KEY (`arg`)

) ENGINE=MyISAM DEFAULT CHARSET=utf8;



copy and name this inactiveusers.php.Put it in your root folder


<?

//-----------------------------------------------//

// Inactive Users Management //

//-----------------------------------------------//

// Modified for TorrentTrader v2.xx by BigMax //

//-----------------------------------------------//



require_once("backend/functions.php");

dbconn(true);

loggedinonly();



if(get_user_class() < 6)

show_error_msg("Acces Denied","I smelled a rat here!");



// Config

$sitename = "".$site_config['SITENAME'].""; // Sitename

$siteurl = "".$site_config['SITEURL'].""; // Default site url

$replyto = "".$site_config['SITEEMAIL'].""; // The Reply-to email

$record_mail = true; // Set this true or false . If you set this true every time whene you send a mail the time , userid , and the number of mail sent will be recorded

$days = 30; // Number of days of inactivite

// End config



if ($_SERVER["REQUEST_METHOD"] == "POST")

{



$action = $_POST["action"];

$cday = 0 + $_POST["cday"];



if (!is_numeric($cday))

show_error_msg("Err","Smell rat !");



if (empty($_POST["userid"]) && (($action == "deluser") || ($action == "mail")))

show_error_msg("Err","For this to work you must select at least a user !");



if ($action == "deluser" && (!empty($_POST["userid"])))

{

mysql_query("DELETE FROM users WHERE id IN (" . implode(", ", $_POST['userid']) . ") ");

show_error_msg("Successfully","You have successfully deleted the selected accounts! <a href=".$BASEURL."/inactiveusers.php>Go back</a>");

}



if ($action == "cday" && ($cday > $days))

$days = $cday;



if ($action == "disable" && (!empty($_POST["userid"])))

{

$res = mysql_query("SELECT id, modcomment FROM users WHERE id IN (" . implode(", ", $_POST['userid']) . ") ORDER BY id DESC ")or sqlerr(__FILE__, __LINE__);

while ($arr = mysql_fetch_array($res))

{

$id = 0 + $arr["id"];

$cname = $CURUSER["username"];

$modcomment = $arr["modcomment"];

$modcomment = gmdate("Y-m-d") . " - Disabled for inactivity by $cname.n".$modcomment;



mysql_query("UPDATE users SET modcomment=".sqlesc($modcomment).", enabled='no' WHERE id=$id ") or sqlerr(__FILE__, __LINE__);

}

show_error_msg("Successfully","You have successfully disabled the selected accounts! <a href=".$BASEURL."/inactiveusers.php>Go back</a>");

}



if ($action == "mail" && (!empty($_POST["userid"])))

{



$res = mysql_query("SELECT id, email , username, added, last_access FROM users WHERE id IN (" . implode(", ", $_POST['userid']) . ") ORDER BY last_access DESC ");

$count = mysql_num_rows($res);

while ($arr = mysql_fetch_array($res))

{

$id = $arr["id"];

$username = htmlspecialchars($arr["username"]);

$email = htmlspecialchars($arr["email"]);

$added = $arr["added"];

$last_access = $arr["last_access"];



$subject = "Warning for inactive account on $sitename";

$message = "

Your account on $sitename was marked as inactive and will be deleted within a few days.

If you want to remain member at $sitename you must just login and download something nice!



Your username it's: $username

Account created on: $added

Last visit on site: $last_access



You can login here: $siteurl/account-login.php

Recovery password: $siteurl/account-recover.php

";

$headers = 'From: no-reply@' . $sitename . "rn" .

'Reply-To:' . $replyto . "rn" .

'X-Mailer: PHP/' . phpversion();



$mail= @mail($email, $subject, $message, $headers);

}



if($record_mail){

$date = time();

$userid = 0 + $CURUSER["id"];

if ($count > 0 && $mail)

mysql_query("update avps set value_i='$date', value_u='$count', value_s='$userid' WHERE arg='inactivemail' ") or sqlerr(__FILE__, __LINE__);

}



if ($mail)

show_error_msg("Success", "Messages sent.");

else

show_error_msg("Error", "Try again.");

}

}

stdhead("Inactive Users");

begin_frame("Inactive Users");



$dt = sqlesc(get_date_time(gmtime() - ($days * 86400)));



$res= mysql_query("SELECT id,username,class,email,uploaded,downloaded,last_access,ip,added FROM users WHERE last_access<$dt AND status='confirmed' AND enabled='yes' ORDER BY last_access DESC ") or sqlerr(__FILE__, __LINE__);

$count = mysql_num_rows($res);

if ($count > 0){

?>

<script type="text/javascript" LANGUAGE="JavaScript">



<!-- Begin

var checkflag = "false";

function check(field) {

if (checkflag == "false") {

for (i = 0; i < field.length; i++) {

field[i].checked = true;}

checkflag = "true";

return "Uncheck All"; }

else {

for (i = 0; i < field.length; i++) {

field[i].checked = false; }

checkflag = "false";

return "Check All"; }

}

// End -->

</script>

<?

print("<form action='inactiveusers.php' method='post'>");

print("<br><table class=table_table align=center border=1 cellspacing=0 cellpadding=5><tr>n");

print("<td class=table_head>Number of days</td><td class=table_head><input type='text' name='cday' size='10' value=''.($cday > $days ? $cday : $days).'' maxlength='3' /></td>");

print("<td class='table_head'><input type='submit' value='Change' /><input type=''hidden' name='action' value='cday' />");

print("</td></tr></table></form><br/>");



print("<h2 align=center>".$count." accounts inactive for longer than ".$days." days.</h2>");

print("<form action='inactiveusers.php' method='post'>");

print("<table class=table_table align=center width=800 border=1 cellspacing=0 cellpadding=5><tr>n");

print("<td class=table_head>Username</td>");

print("<td class=table_head>Class</td>");

print("<td class=table_head>IP</td>");

print("<td class=table_head>Ratio</td>");

print("<td class=table_head>Join Date</td>");

print("<td class=table_head>Last Seen</td>");

print("<td class=table_head align='center'>x</td>");



while ($arr = mysql_fetch_assoc($res)) {

$ratio = ($arr["downloaded"] > 0 ? number_format($arr["uploaded"] / $arr["downloaded"], 3) : ($arr["uploaded"] > 0 ? "Inf." : "---"));

$ratio = "<font color=" . get_ratio_color($ratio) . ">$ratio</font>";

$downloaded = mksize($arr["downloaded"]);

$uploaded = mksize($arr["uploaded"]);

$last_seen = (($arr["last_access"] == "0000-00-00 00:00:00") ? "never" : "".get_elapsed_time(sql_timestamp_to_unix_timestamp($arr["last_access"]))."&nbsp;ago" );

$class=get_user_class_name($arr["class"]);

$joindate = substr($arr['added'], 0, strpos($arr['added'], " "));

print("<tr>");



// Make a choise here:

print("<td><a href='account-details.php?id=".$arr["id"]."'>".htmlspecialchars($arr["username"])."</a></td>"); //=== Use this line if you did not have the function class_user ===//



//print("<td><a href="account-details.php?id=".$arr["id"].""><b>".class_user($arr["username"])."</b></a></td>"); //=== Use this line if you have the function class_user ===//



print("<td>".$class."</td>");

print("<td>".($arr["ip"] == "" ? "----" : $arr["ip"] )."</td>");

print("<td><b>".$ratio."</b><font class='small'> | Dl:<font color=red><b>".$downloaded."</b></font> | Up:<font color=lime><b>".$uploaded."</b></font></font></td>");

print("<td>".$joindate."</td>");

print("<td>".$last_seen."</td>");



print("<td align='center' bgcolor='#FF0000'><input type='checkbox' name='userid[]' value='".$arr["id"]."' /></td>");

print("</tr>");

}

print("<tr><td colspan=7 class='table_head' align='center'>

<select name='action'>

<option value=mail>'Send mail'</option>

<option value='deluser'>Delete users</option>

<option value='disable'>Disable Accounts</option>

</select>&nbsp;&nbsp;<input type='submit' name='submit' value='Apply Changes'/>&nbsp;&nbsp;<input type='button' value='Check all' onClick='this.value=check(form)' /></td></tr>");



if($record_mail){

$ress = mysql_query("SELECT avps.value_s AS userid, avps.value_i AS last_mail, avps.value_u AS mails, users.username FROM avps LEFT JOIN users ON avps.value_s=users.id WHERE avps.arg='inactivemail' LIMIT 1");

$date = mysql_fetch_assoc($ress);

if ($date["last_mail"] > 0 )

print("<tr><td colspan='7' class='table_head' align='center' style='color:red;'>Last mail sent by <a href='account-details.php?id=".$date["userid"]."'>".$date["username"]."</a> on <b>".gmdate("d M Y",$date["last_mail"])."</b> and <b>".$date["mails"]."</b> mail".($date["mails"] > 1 ? "s" : "")." was sent!</td></tr>");

}



print("</table></form>");

}else{

print("<h2 align=center>No account inactive for longer than ".$days." days.</h2>");

}

end_frame();

stdfoot();

die;

?>





add in admincp.php



<td align=center><a href=inactiveusers.php><img src="images/admin/inactiveusers.png" border=0 width=32 height=32><br>Inactive Users</a><BR></td>

inactiveusers.png
inactiveusers.png
2012-07-22 14:58:06
Thanks...langues lol  :)

TT V2.08

Anglais

// Inactive Users

$LANG["NUMBER0FDAYS"] = "Number of days";

$LANG["JOINDATE"] = "Join Date";

$LANG["SENDMAIL"] = "Send mail";

$LANG["DELETEUSERS"] = "Delete users";

$LANG["DISABLED_ACCOUNTS"] = "Disable accounts";

$LANG["LASTMAILSENTBY"] = "Last mail sent by";

$LANG["WASSENT"] = "was sent!";

$LANG["NOACOUNTINATIVE"] = "No account inactive for longer than";

$LANG["ON"] = "on";

$LANG["USURSINACTIVE"] = "Inactive Users";

$LANG["DAYS"] = "Jours";

Français

// Inactive Users

$LANG["NUMBER0FDAYS"] = "Nombre de jours";

$LANG["JOINDATE"] = "Date d'inscription";

$LANG["SENDMAIL"] = "Envoyer un Email";

$LANG["DELETEUSERS"] = "Supprimer membres";

$LANG["DISABLED_ACCOUNTS"] = "Compte désactivé";

$LANG["LASTMAILSENTBY"] = "Dernière dépêche envoyée par";

$LANG["ON"] = "sur";

$LANG["WASSENT"] = "a été envoyé!";

$LANG["NOACOUNTINATIVE"] = "Pas de compte inactif pendant plus de";

$LANG["USURSINACTIVE"] = "Les utilisateurs inactifs";

$LANG["DAYS"] = "Days";

Replace



<td align=center><a href=inactiveusers.php><img src="images/admin/inactiveusers.png" border=0 width=32 height=32><br>Inactive Users</a><BR></td>

For


   <td align="center"><a href="inactiveusers.php"><img src="images/admin/inactiveusers.png" border="0" width="32" height="32"><br /><?php echo T_("USURSINACTIVE"); ?></a><br /></td> 

[url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=5881"]inactiveusers.php[/url]
inactiveusers.php
Download

Unknown User
2012-10-09 01:01:52
Tnx. Works Fine on TT 2.08 :)
Unknown User
2012-11-17 20:44:12
Thanke, works nice on tt v2-svn
Unknown User
2012-12-13 05:42:36
er..... yeah..... but HOW does one actually check the mail that has been sent?
Unknown User
2012-12-13 08:47:01
you have to check your hosts email logs to see if sent out!!!.. Another reason I like using the gmail smtp thing is gmail records all emails send, in the sent folder:)
Unknown User
2012-12-13 09:49:36
Righto, good advice that, will use that smtp gmail thingy in future thanks mate....
Unknown User
2012-12-13 10:35:32
.. side note i see some issues in this addon anyway to be truly 2.08..

its using stuff like

show_error_msg("Acces Denied","I smelled a rat here!");
to error out but if dont have ,1 after it it will not really error out:(.. like
show_error_msg("Acces Denied","I smelled a rat here!",1);


and @mail should be @sendmail to use smtp..

and it still uses the old mysql_query thing..
Unknown User
2012-12-13 14:05:52
mmmm... also this simply doesnt make any sense????

print("<td class=table_head>".T_("NUMBER0FDAYS")."</td><td class=table_head><input type='text' name='cday' size='10' value=''.($cday > $days ? $cday : $days).'' maxlength='3' /></td>");

print("<td class='table_head'><input type='submit' value='Change' /><input type=''hidden' name='action' value='cday' />");

for the time period doesnt change at all.....
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 2
  • Members: 0
  • Guests online: 2
  • Comments: 3
  • Messages: 1,728