a better processbounces.php

Technical discussion for developers and service providers

a better processbounces.php

Postby lpaopia » 3:43am, Tue 18 May, 2010

There is a lot of bounces that is not processed because is not possible recovery relevant data in order to identify the users' email address. I humbly propose this lines that can do it. This code can be better. I tested it, it works.

processbounces.php
insert below line 116:

Code: Select all
   if (!$user) { //finally, recover every email address for compare them with the table "user" and return its uniquid
      $filling = "";
      $at_warn = -1;
      for ($n = 0; $n < strlen($body); $n++) { //go over every char. for extract the emails in field "data"
         $character = substr($body, $n, 1);
         if ($at_warn == -1 && eregi("[0-9A-Za-z]", $character)) { //first character of the address
            $filling .= $character;
            $at_warn = 0;
         } elseif (ereg("[0-9A-Za-z._-]", $character)) { //rest of characters of the email, except "@"
            $filling .= $character;
         } elseif ($character == '@') { //'at'
            $filling .= $character;
            $at_warn = 1;
         } else {
            if ($at_warn == 1) {
               for ($m = 1; $m <= strlen($filling); $m++) { //cutting out ".-_" at the end of email
                  if (ereg("[.-_]", substr($filling, $m * -1, 1)))
                     $filling = substr($filling, 0, strlen($filling) - $m);
                  else break;
               }
               $at_warn = -1;
               if ($filling == $GLOBALS['message_envelope'] ||
                   eregi("[@.]".getConfig("domain")."$", $filling)) { //exclude the address where arrive the bounces and every address in domain
                  $filling = "";
                  break;
               }
               $userid_req = Sql_Fetch_Row_Query("select id from {$tables["user"]} where email = \"$filling\"");
               if (VERBOSE)
                  output("UID".$userid_req[0]." MSGID".$msgid);
               if (isset($userid_req[0])) {
                  if ($userid_req[0] >0) {
                     $user = $filling;
                     $filling = "";
                     break;
                  }
               }
            }
            $filling = "";
         }
      }
   }
lpaopia
phpList newbie
 
Posts: 3
Joined: 9:46pm, Sun 16 May, 2010

Re: a better processbounces.php

Postby lpaopia » 6:28pm, Tue 18 May, 2010

Also, I saw it's necessary to patch other code, for remove "buggy" behavior:

processbounces.php

Code: Select all
  if ($msgid == "systemmessage" && $userid) {


replace for:
Code: Select all
  if ($msgid === "systemmessage" && $userid) {
---------------^


This, above, does bounces with undentified number of message not be like "systemmessage", because when $msgid has the value 0, is like ($msgid == "systemmessage").

And, bounce.php

Code: Select all
  if (preg_match("#([\d]+) bouncecount increased#",$bounce["comment"],$regs)) {


replace for:
Code: Select all
---------------------------v
  if (preg_match("#([\d]+) [bouncecount increased|marked
unconfirmed]#",$bounce["comment"],$regs)) {
-----------^


This other recovery every user's id of comment line in bounce record
lpaopia
phpList newbie
 
Posts: 3
Joined: 9:46pm, Sun 16 May, 2010

Re: a better processbounces.php

Postby lpaopia » 12:00am, Wed 19 May, 2010

The "buggy" bounce.php again. I sugest to add these lines below the number 17:

Code: Select all
$useremail = isset($_GET["useremail"]) ? $_GET["useremail"] : '';
$amount = isset($_GET["amount"]) ? ( ereg("-?[0-9]+", $_GET["amount"]) ? $_GET["amount"] : '0' ) : '0';
$unconfirm = isset($_GET["unconfirm"]) ? $_GET["unconfirm"] : '0';
$maketext = isset($_GET["maketext"]) ? $_GET["maketext"] : '0';
$deleteuser = isset($_GET["deleteuser"]) ? $_GET["deleteuser"] : '0';
$deletebounce = isset($_GET["deletebounce"]) ? $_GET["deletebounce"] : '0';


And in the new 124:

Code: Select all
  print '<tr><td>'.$GLOBALS['I18N']->get('IncreaseB').'</td><td><input type=text name=amount value="'.$amount.'" size=5>'.$GLOBALS['I18N']->get('IncreaseBNote').'</td></tr>';
lpaopia
phpList newbie
 
Posts: 3
Joined: 9:46pm, Sun 16 May, 2010


Return to Developers Space

Who is online

Users browsing this forum: No registered users and 1 guest