Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   TBDev (http://www.bvlist.com/forumdisplay.php?f=20)
-   -   Inactive Users with send mail. (http://www.bvlist.com/showthread.php?t=9301)

asdy 15th July 2013 23:58

Inactive Users with send mail.
 
Hello. i want to inactive users script for tbdev.net-01-03-06. Thanks

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("
");
print("\n");
print("");
print("");
print("");
print("");
print("");
print("");
print("");

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"]))." ago" );
$class=get_user_class_name($arr["class"]);
$joindate = substr($arr['added'], 0, strpos($arr['added'], " "));
print("");
print("");
print("");
print("");
print("");
print("");
print("");
print("");
print("");
}
print("");

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("");
}

print("
UsernameClassIPRatioJoin DateLast Seenx
".htmlspecialchars($arr["username"])."".$class."".($arr["ip"] == "" ? "---" : $arr["ip"] )."".$ratio."
D: ".$downloaded." U: ".$uploaded."
".$joindate."".$last_seen."

    
Last mail sent by ".$date["username"]." on ".gmdate("d M Y",$date["last_mail"])." and ".$date["mails"]." mail".($date["mails"] > 1 ? "s" : "")." was sent!
");
}else{
print("

No account inactive for longer than ".$days." days.

");
}
stdfoot();
?>



fill in the sitelinkhere with yours

asdy 16th July 2013 00:25

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.

wMan 16th July 2013 00:30

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();
?>



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 $username was deleted by $CURUSER[username].");
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\n\nReturn to the Account Inactivity Status page.");
}
} 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\n\n
\n \n\n
");

} else {
if ($countnumber > 250) { print("

$countnumber accounts inactive for longer than $days days.Only the first 250 are shown.

\n"); } else { print("

$countnumber accounts inactive for longer than $days days.

\n"); }
print("
\n");
print(" \n");
print("\n
\n");
print("
\n");
print("\n\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 = "$ratio";
}
print("");
print("");
print("");
print("\n");
}

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

print("
Delete PMReport Class Username RatioLast Seen
");
print("
".get_user_class_name($row["class"])."".$row["username"]."$ratio$lastseen
\n\n\n");
print("\n");
print(" print("\n");
print("\n");
stdfoot();

}
}

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

?>

try this one

mpx 5th August 2014 09:54

This JS code did not work for me. Missing }

My javascript code:

Code:


in php.ini enable this line:
Quote:

; How many GET/POST/COOKIE input variables may be accepted
max_input_vars = 1000


All times are GMT +2. The time now is 15:18.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.