E_ALL is a moving target
[squirrelmail.git] / plugins / mail_fetch / functions.php
index 921e86eb2c5e9c6695b774f3904c432b559fb44c..1c4fcd9e75334d2802531621feafec833e770fa4 100644 (file)
@@ -9,7 +9,7 @@
  * and josh@superfork.com (extracted from php manual)
  * Adapted for MailFetch by Philippe Mingo <mingo@rotedic.com>
  *
- * @copyright 1999-2010 The SquirrelMail Project Team
+ * @copyright 1999-2012 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package plugins
@@ -312,18 +312,21 @@ function mail_fetch_folderact_function($args) {
 // end of hooked functions
 
 /**
- * hex2bin - document me
+ * hex2bin - convert a hexadecimal string into binary
+ * Exists since PHP 5.4.
  */
-function hex2bin( $data ) {
+if ( ! function_exists('hex2bin') ) {
+    function hex2bin( $data ) {
 
-    /* Original code by josh@superfork.com */
+        /* Original code by josh@superfork.com */
 
-    $len = strlen($data);
-    $newdata = '';
-    for( $i=0; $i < $len; $i += 2 ) {
-        $newdata .= pack( "C", hexdec( substr( $data, $i, 2) ) );
+        $len = strlen($data);
+        $newdata = '';
+        for( $i=0; $i < $len; $i += 2 ) {
+            $newdata .= pack( "C", hexdec( substr( $data, $i, 2) ) );
+        }
+        return $newdata;
     }
-    return $newdata;
 }
 
 function mf_keyED( $txt ) {