[Tickets #5215] Logging for deleted messages

bugs at bugs.horde.org bugs at bugs.horde.org
Wed Apr 4 18:52:50 UTC 2007


DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.

Ticket URL: http://bugs.horde.org/ticket/?id=5215
-----------------------------------------------------------------------
 Ticket             | 5215
 Created By         | webadmin at ualberta.ca
 Summary            | Logging for deleted messages
 Queue              | IMP
 Version            | 4.1.2
 Type               | Enhancement
 State              | New
 Priority           | 1. Low
 Owners             | 
-----------------------------------------------------------------------


webadmin at ualberta.ca (2007-04-04 11:52) wrote:

The one thing that keeps biting us on the ass is when users claim that Imp
"ate my mail".  As it stands there's no way for us to prove that the user
himself didn't delete his messages so it makes it a bit sticky when going
to charge them for data recovery.  So I hacked in the following code to
add log messages when a user empties the trash folder.  The reason I'm
submitting it as an enhancement is because a) I think it's very useful
from an administration standpoint to be able to determine when a user
empties his trash folder so other admins should have this ability and b) I
want to keep my codebase as "stock" as I can to make future upgrades
possible.

Please note... there is very likely a better way to do this (especially
since my php skills are rudimentary) but it achieved the desired result. 
The hacked file is /horde/imp/lib/Message.php.  If this addition will
cause problems that I'm not seeing please let me know so I can remove it
from my local installation.


--- Message.php.orig    Wed Apr  4 12:06:43 2007
+++ Message.php Wed Apr  4 12:39:20 2007
@@ -237,6 +237,14 @@
                     $overview = @imap_fetch_overview($imp['stream'],
$sequence, FT_UID);
                 }
 
+               /*  
+                *  Added by KK Apr4/07
+                *
+                *  Get the list of Message-IDs for the deleted messages 
+                */
+
+               $delArray = @imap_fetch_overview($imp['stream'],
$sequence, FT_UID);
+
                 /* Delete the messages. */
                 if (!@imap_delete($imp['stream'], $sequence, FT_UID)) {
                     if ($this->_usepop) {
@@ -277,6 +285,27 @@
                         require_once IMP_BASE . '/lib/Maillog.php';
                         IMP_Maillog::deleteLog($msg_ids);
                     }
+
+
+
+                /*  
+                 *  Added by KK Apr4/07
+                 *
+                 *  Count the number of messages that have been deleted
and log the info. 
+                 */
+
+               $msg_ids = array();
+                foreach ($delArray as $val) {
+                       if (!empty($val->message_id)) {
+                               $msg_ids[] = $val->message_id;
+                        }
+                }
+               $kk = count($msg_ids);
+               $entry = sprintf("%s Messages in Trash folder [%d] deleted
by user %s", $_SERVER['REMOTE_ADDR'], $kk,$imp['user']);
+               Horde::logMessage($entry, __FILE__, __LINE__,
PEAR_LOG_INFO);
+
+
+
                 }
             }
         }




More information about the bugs mailing list