X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;ds=sidebyside;f=plugins%2Fmail_fetch%2Ffunctions.php;h=17800cf2757806482cd16dda00d494d4e11da0f5;hb=4f51df662e39f6a118606364441ae9964006b032;hp=c426e2787f8f15eb0d6a2ec4f4341630d1446cc2;hpb=d622d38af6c2101b24c27851caf30866070c90c1;p=squirrelmail.git diff --git a/plugins/mail_fetch/functions.php b/plugins/mail_fetch/functions.php index c426e278..17800cf2 100644 --- a/plugins/mail_fetch/functions.php +++ b/plugins/mail_fetch/functions.php @@ -1,70 +1,82 @@ * and josh@superfork.com (extracted from php manual) * Adapted for MailFetch by Philippe Mingo * + * @version $Id$ + * @package plugins + * @subpackage mail_fetch */ +/** + * hex2bin - document me + */ +function hex2bin( $data ) { - function hex2bin( $data ) { - - /* Original code by josh@superfork.com */ + /* Original code by josh@superfork.com */ - $len = strlen($data); - for( $i=0; $i < $len; $i += 2 ) { - $newdata .= pack( "C", hexdec( substr( $data, $i, 2) ) ); - } - return $newdata; + $len = strlen($data); + $newdata = ''; + for( $i=0; $i < $len; $i += 2 ) { + $newdata .= pack( "C", hexdec( substr( $data, $i, 2) ) ); } + return $newdata; +} - function mf_keyED( $txt ) { +function mf_keyED( $txt ) { - global $MF_TIT; + global $MF_TIT; - if( !isset( $MF_TIT ) ) { - $MF_TIT = "MailFetch Secure for SquirrelMail 1.x"; - } + if( !isset( $MF_TIT ) ) { + $MF_TIT = "MailFetch Secure for SquirrelMail 1.x"; + } - $encrypt_key = md5( $MF_TIT ); - $ctr = 0; - $tmp = ""; - for( $i = 0; $i < strlen( $txt ); $i++ ) { - if( $ctr == strlen( $encrypt_key ) ) $ctr=0; - $tmp.= substr( $txt, $i, 1 ) ^ substr( $encrypt_key, $ctr, 1 ); - $ctr++; - } - return $tmp; + $encrypt_key = md5( $MF_TIT ); + $ctr = 0; + $tmp = ""; + for( $i = 0; $i < strlen( $txt ); $i++ ) { + if( $ctr == strlen( $encrypt_key ) ) $ctr=0; + $tmp.= substr( $txt, $i, 1 ) ^ substr( $encrypt_key, $ctr, 1 ); + $ctr++; } + return $tmp; +} - function encrypt( $txt ) { +function encrypt( $txt ) { - srand( (double) microtime() * 1000000 ); - $encrypt_key = md5( rand( 0, 32000 ) ); - $ctr = 0; - $tmp = ""; - for( $i = 0; $i < strlen( $txt ); $i++ ) { + srand( (double) microtime() * 1000000 ); + $encrypt_key = md5( rand( 0, 32000 ) ); + $ctr = 0; + $tmp = ""; + for( $i = 0; $i < strlen( $txt ); $i++ ) { if ($ctr==strlen($encrypt_key)) $ctr=0; - $tmp.= substr($encrypt_key,$ctr,1) . - (substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1)); + $tmp.= substr($encrypt_key,$ctr,1) . + (substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1)); $ctr++; - } - return bin2hex( mf_keyED( $tmp ) ); - } + return bin2hex( mf_keyED( $tmp ) ); + +} - function decrypt( $txt ) { +function decrypt( $txt ) { - $txt = mf_keyED( hex2bin( $txt ) ); - $tmp = ''; - for ( $i=0; $i < strlen( $txt ); $i++ ) { - $md5 = substr( $txt, $i, 1 ); - $i++; - $tmp.= ( substr( $txt, $i, 1 ) ^ $md5 ); - } - return $tmp; + $txt = mf_keyED( hex2bin( $txt ) ); + $tmp = ''; + for ( $i=0; $i < strlen( $txt ); $i++ ) { + $md5 = substr( $txt, $i, 1 ); + $i++; + $tmp.= ( substr( $txt, $i, 1 ) ^ $md5 ); } + return $tmp; +} ?> \ No newline at end of file