From: kink Date: Wed, 8 Feb 2012 12:11:18 +0000 (+0000) Subject: hex2bin is introduced in PHP 5.4 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f19ee57dce51c639fbfb2c2e3a29df74504ac9ca;p=squirrelmail.git hex2bin is introduced in PHP 5.4 git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@14277 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/plugins/mail_fetch/functions.php b/plugins/mail_fetch/functions.php index a91da7bf..1c4fcd9e 100644 --- a/plugins/mail_fetch/functions.php +++ b/plugins/mail_fetch/functions.php @@ -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 ) {