1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 06:07:32 +02:00

Bounce processing mods

This commit is contained in:
e107steved
2007-09-28 20:50:23 +00:00
parent 6bc203e893
commit 862d1b4fb2
2 changed files with 121 additions and 85 deletions

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_admin/users.php,v $ | $Source: /cvs_backup/e107_0.8/e107_admin/users.php,v $
| $Revision: 1.5 $ | $Revision: 1.6 $
| $Date: 2007-08-06 19:35:11 $ | $Date: 2007-09-28 20:50:11 $
| $Author: e107steved $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -72,6 +72,7 @@ $amount = 30;
$bounce_act = ''; $bounce_act = '';
if (isset($_POST['check_bounces'])) $bounce_act = 'first_check'; if (isset($_POST['check_bounces'])) $bounce_act = 'first_check';
if (isset($_POST['delnonbouncesubmit'])) $bounce_act = 'delnonbounce'; if (isset($_POST['delnonbouncesubmit'])) $bounce_act = 'delnonbounce';
if (isset($_POST['clearemailbouncesubmit'])) $bounce_act = 'clearemailbounce';
if (isset($_POST['delcheckedsubmit'])) $bounce_act = 'delchecked'; if (isset($_POST['delcheckedsubmit'])) $bounce_act = 'delchecked';
if (isset($_POST['delallsubmit'])) $bounce_act = 'delall'; if (isset($_POST['delallsubmit'])) $bounce_act = 'delall';
if ($bounce_act) if ($bounce_act)
@@ -791,11 +792,12 @@ class users{
function show_options($action) { function show_options($action) {
global $unverified; global $unverified;
// ##### Display options --------------------------------------------------------------------------------------------------------- // ##### Display options
if ($action == "") { if ($action == "")
{
$action = "main"; $action = "main";
} }
// ##### Display options --------------------------------------------------------------------------------------------------------- // ##### Display options
$var['main']['text'] = USRLAN_71; $var['main']['text'] = USRLAN_71;
$var['main']['link'] = e_SELF; $var['main']['link'] = e_SELF;
@@ -1080,6 +1082,7 @@ class users{
// $bounce_act has the task to perform: // $bounce_act has the task to perform:
// 'first_check' - initial read of list of bounces // 'first_check' - initial read of list of bounces
// 'delnonbounce' - delete any emails that aren't bounces // 'delnonbounce' - delete any emails that aren't bounces
// 'clearemailbounce' - delete email address for any user whose emails bounced
// 'delchecked' - delete the emails whose comma-separated IDs are in $bounce_arr // 'delchecked' - delete the emails whose comma-separated IDs are in $bounce_arr
// 'delall' - delete all bounced emails // 'delall' - delete all bounced emails
@@ -1088,18 +1091,19 @@ class users{
global $sql,$pref; global $sql,$pref;
include(e_HANDLER."pop3_class.php"); include(e_HANDLER."pop3_class.php");
if (!$bounce_act) $bounce_act='first_check'; if (!trim($bounce_act)) $bounce_act='first_check';
// echo "Check bounces. Action: {$bounce_act}; Entries: {$bounce_arr}<br />"; // echo "Check bounces. Action: {$bounce_act}; Entries: {$bounce_arr}<br />";
$obj= new receiveMail($pref['mail_bounce_user'],$pref['mail_bounce_pass'],$pref['mail_bounce_email'],$pref['mail_bounce_pop3'],'pop3','110'); $obj= new receiveMail($pref['mail_bounce_user'],$pref['mail_bounce_pass'],$pref['mail_bounce_email'],$pref['mail_bounce_pop3'],'pop3','110');
$del_count = 0;
if ($bounce_act !='first_check') if ($bounce_act !='first_check')
{ // Must do some deleting { // Must do some deleting
$obj->connect(); $obj->connect();
$tot=$obj->getTotalMails(); $tot=$obj->getTotalMails();
$del_array = explode(',',$bounce_arr); $del_array = explode(',',$bounce_arr);
for($i=1;$i<=$tot;$i++) for($i=1;$i<=$tot;$i++)
{ { // Scan all emails; delete current one if meets the criteria
$dodel = FALSE; $dodel = FALSE;
switch ($bounce_act) switch ($bounce_act)
{ {
@@ -1107,6 +1111,23 @@ class users{
$head=$obj->getHeaders($i); $head=$obj->getHeaders($i);
$dodel = (!$head['bounce']); $dodel = (!$head['bounce']);
break; break;
case 'clearemailbounce' :
if (!in_array($i, $del_array)) break;
$head=$obj->getHeaders($i);
if($head['bounce'])
{
if (preg_match("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $obj->getBody($i), $result)) $usr_email = trim($result[0]);
if ($sql->db_Select('user','user_id, user_name, user_email',"user_email='".$usr_email."' "))
{
$row = $sql->db_Fetch();
if ($sql->db_Update('user',"`user_email`='' WHERE `user_id` = '".$row['user_id']."' ") !== FALSE)
{
// echo "Deleting user email {$row['user_email']} for user {$row['user_name']}, id={$row['user_id']}<br />";
$dodel = TRUE;
}
}
}
break;
case 'delall' : case 'delall' :
$dodel = TRUE; $dodel = TRUE;
break; break;
@@ -1118,27 +1139,34 @@ class users{
{ {
// echo "Delete email ID {$i}<br />"; // echo "Delete email ID {$i}<br />";
$obj->deleteMails($i); $obj->deleteMails($i);
$del_count++; // Keep track of number of emails deleted
} }
} } // End - Delete one email
$obj->close_mailbox(); // This actually deletes the emails $obj->close_mailbox(); // This actually deletes the emails
} } // End of email deletion
// Now list the emails that are left
$obj->connect(); $obj->connect();
$tot=$obj->getTotalMails(); $tot=$obj->getTotalMails();
$found = FALSE; $found = FALSE;
$DEL = ($pref['mail_bounce_delete']) ? TRUE : FALSE; $DEL = ($pref['mail_bounce_delete']) ? TRUE : FALSE;
$text = "<br /><div><form method='post' action='".e_SELF.$qry."'><table class='fborder' style='".ADMIN_WIDTH."'> $text = "<br /><div><form method='post' action='".e_SELF.$qry."'><table class='fborder' style='".ADMIN_WIDTH."'>
<tr><td class='fcaption' style='width:5%'>#</td><td class='fcaption'>e107-id</td><td class='fcaption'>email</td><td class='fcaption'>Subject</td><td class='fcaption'>Bounce</td></tr>\n"; <tr><td class='fcaption' style='width:5%'>#</td><td class='fcaption'>e107-id</td><td class='fcaption'>email</td><td class='fcaption'>Subject</td><td class='fcaption'>Bounce</td></tr>\n";
for($i=1;$i<=$tot;$i++) for($i=1;$i<=$tot;$i++)
{ {
$head=$obj->getHeaders($i); $head=$obj->getHeaders($i);
if($head['bounce']) if($head['bounce'])
{ { // Its a 'bounce' email
if (ereg('.*X-e107-id:(.*)MIME', $obj->getBody($i), $result)) if (ereg('.*X-e107-id:(.*)MIME', $obj->getBody($i), $result))
{ {
if($result[1]) if($result[1])
{ {
$id[$i] = intval($result[1]); $id[$i] = intval($result[1]); // This should be a user ID - but not on special mailers!
// Try and pull out an email address from body - should be the one that failed // Try and pull out an email address from body - should be the one that failed
if (preg_match("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $obj->getBody($i), $result)) if (preg_match("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $obj->getBody($i), $result))
{ {
@@ -1146,7 +1174,6 @@ class users{
} }
$found = TRUE; $found = TRUE;
} }
} }
elseif (preg_match("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $obj->getBody($i), $result)) elseif (preg_match("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $obj->getBody($i), $result))
{ {
@@ -1161,7 +1188,11 @@ class users{
$found = TRUE; $found = TRUE;
} }
} }
if($DEL && $found){ $obj->deleteMails($i); } if ($DEL && $found)
{ // Auto-delete bounced emails once noticed (if option set)
$obj->deleteMails($i);
$del_count++;
}
} }
else else
{ // Its a warning message or similar { // Its a warning message or similar
@@ -1172,16 +1203,20 @@ class users{
$wmails[$i] = "'".$result[0]."'"; $wmails[$i] = "'".$result[0]."'";
} }
} }
$text .= "<tr><td class='forumheader3'>".$i."</td><td class='forumheader3'>".$id[$i]."</td><td class='forumheader3'>".(isset($emails[$i]) ? $emails[$i] : $wmails[$i])."</td><td class='forumheader3'>".$head['subject']."</td><td class='forumheader3'>".($head['bounce'] ? ADMIN_TRUE_ICON : ADMIN_FALSE_ICON); $text .= "<tr><td class='forumheader3'>".$i."</td><td class='forumheader3'>".$id[$i]."</td><td class='forumheader3'>".(isset($emails[$i]) ? $emails[$i] : $wmails[$i])."</td><td class='forumheader3'>".$head['subject']."</td><td class='forumheader3'>".($head['bounce'] ? ADMIN_TRUE_ICON : ADMIN_FALSE_ICON);
$text .= "<input type='checkbox' name='delete_email[]' value='{$i}' /></td></tr>\n"; $text .= "<input type='checkbox' name='delete_email[]' value='{$i}' /></td></tr>\n";
} }
if ($tot) if ($tot)
{ // Option to delete emails { // Option to delete emails - only if there are some in the list
$text .= "</table><table style='".ADMIN_WIDTH."'><tr> $text .= "</table><table style='".ADMIN_WIDTH."'><tr>
<td class='forumheader3'><input class='button' type='submit' name='delnonbouncesubmit' value='".USRLAN_153."' /></td>\n <td class='forumheader3' style='text-align: center;'><input class='button' type='submit' name='delnonbouncesubmit' value='".USRLAN_153."' /></td>\n
<td class='forumheader3'><input class='button' type='submit' name='delcheckedsubmit' value='".USRLAN_149."' /></td>\n <td class='forumheader3' style='text-align: center;'><input class='button' type='submit' name='clearemailbouncesubmit' value='".USRLAN_154."' /></td>\n
<td class='forumheader3'><input class='button' type='submit' name='delallsubmit' value='".USRLAN_150."' /></td>\n <td class='forumheader3' style='text-align: center;'><input class='button' type='submit' name='delcheckedsubmit' value='".USRLAN_149."' /></td>\n
<td class='forumheader3' style='text-align: center;'><input class='button' type='submit' name='delallsubmit' value='".USRLAN_150."' /></td>\n
</td></tr>"; </td></tr>";
} }
$text .= "</table></form></div>"; $text .= "</table></form></div>";
@@ -1192,18 +1227,18 @@ class users{
$all_ids = implode(",",$id); $all_ids = implode(",",$id);
$all_emails = implode(",",$emails); $all_emails = implode(",",$emails);
$obj->close_mailbox(); $obj->close_mailbox(); // This will actually delete emails
// $found = count($id) + count($emails);
$found = count($emails); // Number of bounce emails found // $tot has total number of emails in the mailbox
$found = count($emails); // $found - Number of bounce emails found
// $del_count has number of emails deleted
// Update bounce status for users // Update bounce status for users
if($ed = $sql -> db_Update("user", "user_ban=3 WHERE (`user_id` IN (".$all_ids.") OR `user_email` IN (".$all_emails.")) AND user_sess !='' ")) $ed = $sql -> db_Update("user", "user_ban=3 WHERE (`user_id` IN (".$all_ids.") OR `user_email` IN (".$all_emails.")) AND user_sess !='' ");
{ if (!$ed) $ed = '0';
$this->show_message(LAN_UPDATED."<br >Found {$tot}, updated {$ed} / {$found}".$text); $this->show_message(str_replace(array('{TOTAL}','{DELCOUNT}','{DELUSER}','{FOUND}'),
} array($tot,$del_count,$ed,$found),USRLAN_155).$text);
else
{
$this->show_message(LAN_UPDATED_FAILED."<br >Found {$tot}, not updated {$ed} / {$found}".$text);
}
} }

View File

@@ -4,8 +4,8 @@
| e107 website system - Language File. | e107 website system - Language File.
| |
| $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/lan_users.php,v $ | $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/lan_users.php,v $
| $Revision: 1.5 $ | $Revision: 1.6 $
| $Date: 2007-08-06 19:35:17 $ | $Date: 2007-09-28 20:50:21 $
| $Author: e107steved $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -154,7 +154,8 @@ define("USRLAN_150", "Delete all emails");
define("USRLAN_151", "Clear bounce, require Activation"); define("USRLAN_151", "Clear bounce, require Activation");
define("USRLAN_152", "Clear bounce and Activate"); define("USRLAN_152", "Clear bounce and Activate");
define("USRLAN_153", "Delete non-bounce emails"); define("USRLAN_153", "Delete non-bounce emails");
define("USRLAN_154", "Clear email for checked");
define("USRLAN_155", "Total {TOTAL} emails found. {DELCOUNT} deleted through options.<br />{DELUSER} users marked as 'bounced' (out of {FOUND} emails)");
define("LAN_MAINADMIN","Main Admin"); define("LAN_MAINADMIN","Main Admin");
define("LAN_ADMIN","Admin"); define("LAN_ADMIN","Admin");