Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > TBDev
Reply
  #1  
Old 15th July 2013, 23:58
asdy's Avatar
asdy asdy is offline
Member
 
Join Date: Dec 2007
Posts: 3
Default Inactive Users with send mail.
Hello. i want to inactive users script for tbdev.net-01-03-06. Thanks
Reply With Quote
  #2  
Old 16th July 2013, 00:11
wMan's Avatar
wMan wMan is offline
Banned
 
Join Date: Feb 2008
P2P
Posts: 1,433
Thumbs up
Code:
<?
require "include/bittorrent.php";

//made by putyn @ tbdev.net
//email part by x0r @ tbdev.net

dbconn(true);
loggedinorreturn();

if(get_user_class() < UC_OWNER)
stderr("Err","Smell rat !");

//config
$sitename = "sitelinkhere"; // Sitename, format: site.com
$replyto = "noreply@sitelinkhere"; // 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 = 352; //number of days of inactivite
//end config

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

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

if (empty($_POST["userid"]) && (($action == "deluser") || ($action == "mail")))
stderr("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']) . ") ");
stderr("Successfully","You have successfully deleted the selected accounts! Go back");
}

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__);
}
stderr("Successfully","You have successfully disabled the selected accounts! <a href=\"".$BASEURL."/inactive.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 = "Your account at $sitename !";
$message = "Hi!
Your account at $sitename has been marked as inactive and will be deleted. If you wish to remain a member at $sitename, please login.

Your username is: $username
And was created: $added
Last accessed: $last_access

Login at: http://sitelinkhere/login.php
If you have forgotten your password you can retrieve it at http://sitelinkhere/recover.php

Welcome back! //Staff
";
$headers = 'From: no-reply@' . $sitename . "\r\n" .
'Reply-To:' . $replyto . "\r\n" .
'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)
stderr("Success", "Messages sent.");
else
stderr("Error", "Try again.");
}
}
stdhead("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("<h2>".$count." accounts inactive for longer than ".$days." days.</h2>");
print("<form action=\"inactive.php\" method=\"post\">");
print("<table class=main border=1 cellspacing=0 cellpadding=5><tr>\n");
print("<td class=colhead>Username</td>");
print("<td class=colhead>Class</td>");
print("<td class=colhead>IP</td>");
print("<td class=colhead>Ratio</td>");
print("<td class=colhead>Join Date</td>");
print("<td class=colhead>Last Seen</td>");
print("<td class=colhead 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." : "---"));
$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>");
print("<td><a href=\"userdetails.php?id=".$arr["id"]."\">".htmlspecialchars($arr["username"])."</a></td>");
print("<td>".$class."</td>");
print("<td>".($arr["ip"] == "" ? "---" : $arr["ip"] )."</td>");
print("<td>".$ratio."<br/><font class=\"small\"> D: ".$downloaded." U: ".$uploaded."</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=\"colhead\" align=\"center\">
<select name=\"action\">
<option value=\"mail\">Send mail</option>
<option value=\"deluser\" ".($CURUSER["class"] < UC_SITE_OWNER ? "disabled" : "" ).">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=\"colhead\" align=\"center\" style=\"color:red;\">Last mail sent by <a href=\"usersdetails.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>No account inactive for longer than ".$days." days.</h2>");
}
stdfoot();
?>


fill in the sitelinkhere with yours
Reply With Quote
  #3  
Old 16th July 2013, 00:25
asdy's Avatar
asdy asdy is offline
Member
 
Join Date: Dec 2007
Posts: 3
Default
don't work send email and disable..and few times appear "For this to work you must select at least a user !" but is cheked.
Reply With Quote
  #4  
Old 16th July 2013, 00:30
wMan's Avatar
wMan wMan is offline
Banned
 
Join Date: Feb 2008
P2P
Posts: 1,433
Thumbs up
Code:
<?
ob_start("ob_gzhandler");
require "include/bittorrent.php";
dbconn(true);
if ($CURUSER["class"] > 15)
{
stdhead();
  stdmsg("FUCK OFF...", "STOP CHEATING MOTHER FUCKER");
  stdfoot();
  exit;
}

loggedinorreturn();
stdhead();
?>
<script language="JavaScript" type="text/javascript">
function selectAll(){
t=document.forms[0].length;
for(i=1; i<t; i++) document.forms[0][i].checked=document.forms[0][0].checked;
}
</script>
<?


if (get_user_class() >= UC_OWNER) {

$cba='';
if ( isset($_GET["select"]) )
{
$select=$_GET["select"];
if ( $select == 'all' ) $cba='checked';
elseif ( $select =='none' ) $cba='';
}

if (isset($_POST['delcheck'])) {

if ($_POST['delcheck'] == ""){ stderr("Sorry", "No accounts selected!"); } else {

$i = 0;
$delray = $_POST['delcheck'];
$result=mysql_query("Select * FROM users") or sqlerr();
$count=mysql_num_rows($result);

for($i=0;$i<$count;$i++){
$del_id = $delray[$i];
if ($del_id == "") {
} else {
$indquery = mysql_query("SELECT * FROM users WHERE id=$del_id") or sqlerr();
$indarray = mysql_fetch_array($indquery);
$username = $indarray["username"];
write_log("banstat", "The account <b>$username</b> was deleted by <i>$CURUSER[username]</i>.");
delete_phpBB2user($username,"nopasswordcheck",false);
mysql_query("DELETE FROM users WHERE id=$del_id LIMIT 1") or sqlerr();
}
}
$days = $_POST['count'];
stderr("Accounts Successfully Deleted", "You have successfully deleted the selected accounts!\n<br>\n<br>\n<a href=\"inactive.php?count=$days\">Return to the Account Inactivity Status page</a>.");
}
} else {

if (isset($_GET['count'])) { $days = $_GET['count']; } else { $days = 35; }

$dt = sqlesc(get_date_time(gmtime() - ($days * 86400)));
$countresult = mysql_query("SELECT * FROM users WHERE last_access < $dt ORDER BY last_access DESC");
$countnumber = mysql_num_rows($countresult);
$result = mysql_query("SELECT * FROM users WHERE last_access < $dt ORDER BY last_access DESC LIMIT 250");
$number = mysql_num_rows($result);
$dt = sqlesc(get_date_time(gmtime() - ($days * 86400)));

if ($number == 0) {

stderr("No Inactive Accounts", "Sorry, there are no accounts that have been inactive for more than $days days.\n<br>\n<br>\n<form method=\"get\" action=\"inactive.php\" name=\"daycount\">\n<input type=\"text\" name=\"count\" value=\"$days\" size=\"20\" maxlength=\"3\" style=\"padding:2px\" />&nbsp;\n<input type=\"submit\" value=\"Change Day Range\" style=\"padding:2px\" />\n</form>");

} else {
if ($countnumber > 250) { print("<h2 style=\"margin-bottom:15px\">$countnumber accounts inactive for longer than $days days.<br><span style=\"font-size:12px\">Only the first 250 are shown.</span></h2>\n"); } else { print("<h2 style=\"margin-bottom:15px\">$countnumber accounts inactive for longer than $days days.</h2>\n"); }
print("<form method=\"get\" action=\"inactive.php\" name=\"daycount\">\n");
print("<input type=\"text\" name=\"count\" value=\"$days\" size=\"20\" maxlength=\"3\" style=\"padding:2px\" />&nbsp;\n");
print("<input type=\"submit\" value=\"Change Day Range\" style=\"padding:2px\" />\n</form>\n");
print("<form method=\"post\" action=\"inactive.php\" name=\"delform\">\n");
print("<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\" align=\"center\" style=\"margin-top:20px\">\n<tr><td class=\"colhead\">Delete </td><td class=\"colhead\"> PM</td><td class=\"colhead\">Report</td><td class=\"colhead\"> Class</td><td class=\"colhead\"> Username</td><td class=\"colhead\"> Ratio</td><td class=\"colhead\">Last Seen</td></tr>\n");

if ($row = mysql_fetch_array($result)) {
do {
$lastseen = $row["last_access"];
if ($lastseen == "0000-00-00 00:00:00") {
$lastseen = "never";
} else {
$lastseen .= " (" . get_elapsed_time(sql_timestamp_to_unix_timestamp($lastseen)) . " ago)";
}

if ($row["uploaded"] == "0") {
$ratio = "inf";
}
elseif ($row["downloaded"] == "0") {
$ratio = "inf";
} else {
$ratio = number_format($row["uploaded"] / $row["downloaded"], 3);
$ratio = "<u><font color=white>$ratio</font></u>";
}
print("<tr><td class=\"colhead\" align=\"center\">");
print("<input type=\"checkbox\" name=\"delete[]\" value=\"".$row["id"]."\"></td>");
print("<td class=\"colhead\"><a href=sendmessage.php?receiver=".$row["id"]."><img src=pic/button_pm.gif border=0></a></td>");
print("<td class=\"colhead\"><form method=post action=report.php?type=User&id=".$row["id"]."><input type=submit value=\"Report User\" style='height: 23px'></form></td>");
print("<td class=\"colhead\">".get_user_class_name($row["class"])."</td><td class=\"colhead\"><a href=userdetails.php?id=".$row["id"].">".$row["username"]."</a></td><td class=\"colhead\"><b>$ratio</b></td><td class=\"colhead\">$lastseen</td></tr>\n");
}

while($row = mysql_fetch_array($result));
}

print("</table>\n<br>\n<br>\n");
print("<input type=\"button\" value=\"Check All\" onclick=\"this.value=check(form)\" style=\"margin-right:10px\" />\n");
print("<input type=\"hidden\" name=\"count\" value=\"$days\"");
print("<input type=\"submit\" value=\"Delete Selected Accounts\">\n");
print("</form>\n");
stdfoot();

}
}

} else { stderr("Unauthorized", "Sorry, you are not authorized to view this page."); }

?>
try this one
Reply With Quote
  #5  
Old 5th August 2014, 09:54
mpx's Avatar
mpx mpx is offline
Senior Member
 
Join Date: Jun 2009
P2P
Posts: 39
Default
This JS code did not work for me. Missing }

My javascript code:

Code:
<script type="text/javascript">
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";
  }
}

</script>
in php.ini enable this line:
Quote:
; How many GET/POST/COOKIE input variables may be accepted
max_input_vars = 1000
Reply With Quote
Reply

Tags
inactive , mail , send , users

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 06:35. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2021, vBulletin Solutions Inc.