Send warning mail before account deletion

Started by swizzles, August 29, 2012, 08:24:28 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Payaa

#2
Here is mine:

Add mailkuldve enum(yes,no) to the SQL db to users table.

Then in cleanup.php add this before inactive account delete script:


//if inactive login after inactive mail then switch back the inactive mail sending
$days = 5*86400;  ///5 days
$dt = sqlesc(get_date_time(gmtime() - $days));
mysql_query("UPDATE users SET mailkuldve='no' WHERE last_access>$dt AND mailkuldve='yes'") or sqlerr(__FILE__, __LINE__);
/// vége


//inactive users and members got mail before they deleted
$secs = 55*86400; //how many days inactive
$ertesitonap = 55; //how many days inactive
$hatarido = 60; // deadline (set this in the delete section too)
$dt = sqlesc(get_date_time(gmtime() - $secs));
$maxclass = UC_POWER_USER;
$res = mysql_query("SELECT id,email, username FROM users WHERE parked='no' AND status='confirmed' AND class <= $maxclass AND last_access < $dt AND mailkuldve='no'") or sqlerr(__FILE__, __LINE__);

$SITEEMAIL = "yoursite@emailaddress";
$DEFAULTBASEURL = "yoursiteurl";

$subject = "Email subject here";

while($arr=mysql_fetch_assoc($res))
{
$to = $arr["email"];
$username = $arr["username"];

$body = <<<EOD
Hi {$username}!
You are receiving this email because you have more than {$ertesitonap} days you have not logged into the site and the vacation mode is not enabled accodon!
Thus, if the inactivity time to reach {$hatarido} day, it will automatically be deleted from the database, so there is still 5 days!
Login here: $DEFAULTBASEURL/login.php
Reset lost password: $DEFAULTBASEURL/recover.php
EOD;

mail($to, $subject, $body, "From: $SITEEMAIL");
mysql_query("UPDATE users SET mailkuldve='yes' WHERE id=$arr[id]") or sqlerr(__FILE__, __LINE__);
}
/// email küldés vége

swizzles

Hi All
Again something else I found, posted by x0r:

"Posted 06 September 2006 - 01:54 PM
Hi, ive made a mod that sends users with last_access = x days a warning mail, but i cant seem to get the cleanup-stuff to work.

This is what the mod looks like:

Create table:

<?php
/***Config***/
$maxday 43;                                // Maximum number of days from last_access (7 days before accound deletion by cleanup.php).
// $parked = "parked = no AND";          // Send email to parked _OR_ unparked accounts, yes/no. Comment out to send to all.
$mindownload=0;                              // The downloaded bytes that are already too small.
$minupload=0;                                // Minimum bytes uploaded.
$savedclass=UC_VIP;                          // This class and up are saved from email warn.
$sitename "site.org";      // Sitename, format: site.com
$replyto "support@site.org";   // The Reply-to email.
/*End Config*/

$stats_general stats_general();
$currtime time();
$daysbefore$currtime - ($maxday 24 60 60);
// $res=mysql_query("SELECT id, username, email, added, last_access, uploaded, downloaded FROM users WHERE $parked last_access = '".date('Y-m-d',$daysbefore)."%' AND downloaded <= $mindownload AND uploaded <= $minupload AND CLASS < $savedclass");

// Testing query, send mail only to user id = 1.
$res=mysql_query("SELECT id, username, email, added, last_access, uploaded, downloaded FROM users WHERE id = 1");
// End testing query.

if($res 0){

        while(
$inf mysql_fetch_assoc($res))
 {
 
$id $inf["id"];
 
$username $inf["username"];
 
$email $inf["email"];
 
$added $inf["added"];
 
$last_access $inf["last_access"];

$subject "Your account at $sitename will be deleted in 7 days!";
$message "Hi!
Your account at 
$sitename has been marked as inactive, and will be deleted in seven days if not accessed before then. If you wish to remain a member at YourSite.org please login.
We currently have 
$stats_general[registered] members and $stats_general[torrents] active torrents, with $stats_general[seeders] seeders and $stats_general[leechers] leechers.

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

Login at: [url="
http://www.$sitename/login.php"]http://www.$sitename/login.php[/url]
If you have forgotten your password you can retrieve it at [url="http://www.$sitename/recover.php"]http://www.$sitename/recover.php[/url]

Welcome back//Staff at $sitename
";
$headers = 'From: no-reply@' . $sitename . "\r\n" .
   'Reply-To:' . 
$replyto . "\r\n" .
   'X-Mailer: PHP/' . phpversion();

mail(
$email$subject$message$headers);
 
 }
 
$day = date("Y-m-d");
mysql_query("
UPDATE warnday SET day '$day'") or sqlerr();
}

?>




In cleanup.php add:

// Warn inactive users by email, runs once every day //
$day = date("Y-m-d");
$res = do_mysql_query("SELECT day FROM warnday");
while ($req = mysql_fetch_assoc($res)){
if ($req[day] != $day)
{
           require_once("warnmail.php");
         
}
}



Its the cleanup.php-stuff that does not work for some reason.. If i goto include/warnmail.php it sends the mail just fine.. "