wMan |
16th July 2013 00:11 |
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! Go back");
}
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){
?>
print("".$count." accounts inactive for longer than ".$days." days.");
print("");
}else{
print("No account inactive for longer than ".$days." days.");
}
stdfoot();
?>
fill in the sitelinkhere with yours
|