Read in a sig file in horde/imp August 19, 2006 at 12:27 pm

[ Listening: Gina Escapes from the album “Battlestar Galactica: Season 2” by Bear McCreary ]

I’ve had a cron job that randomly updates my .signature file on my unix systems every 5 minutes for years now and I really wanted to have the same kind of random signatures in IMP as well. So I made a very simple change to the imp.php file (in <horde>/imp/lib/Identity) that allows you to read in a file rather then only read the signature that you’ve saved in the database. Syntax is very easy.. set your signature in the horde prefrences to FILE:<filename> like FILE:/home/mmarion/.signature and this small bit I added will read in that file instead of printing out the value set in the database.

Patch is simple, download here and here’s how it looks:

--- imp.php.orig        2006-08-19 11:53:24.000000000 -0700
+++ imp.php     2006-08-19 11:53:50.000000000 -0700
@@ -455,6 +455,15 @@

$this->_signatures[$ident] = $val;

+       if (preg_match('/FILE:/',$val)) {
+                       $sigFileSplit=preg_split('/:/',$val);
+                       $sigFile=$sigFileSplit[1];
+                       $sigFileSize=filesize($sigFile);
+                       $sigFilePtr = @fopen($sigFile, 'r');
+                       $val = "-- \n" . fread($sigFilePtr, $sigFileSize);
+                       fclose($sigFilePtr);
+       }
+
return $val;
}

Obviously I didn’t add any kind of error checking for FILE: without a valid file, or for empty files, or files that can’t be read.. but eh.. works for me.

Leave a Reply