X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=contrib%2Fdecrypt_headers.php;h=2fec8df750be760566416fba12271da8c9f77e5b;hp=7304b72785d3fe7bed3be34146856ed7cf7ceae5;hb=ad2d75f676d6567af5439e27ee338b54eb5d028d;hpb=151562a780a0919b32e04d204ba7f33fb215bd84 diff --git a/contrib/decrypt_headers.php b/contrib/decrypt_headers.php index 7304b727..2fec8df7 100644 --- a/contrib/decrypt_headers.php +++ b/contrib/decrypt_headers.php @@ -3,7 +3,7 @@ /** * Script provides form to decode encrypted header information. * - * @copyright © 2005-2006 The SquirrelMail Project Team + * @copyright 2005-2010 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version $Id$ * @package squirrelmail @@ -16,10 +16,11 @@ define('SM_PATH','../'); /** - * include SquirrelMail string functions + * include SquirrelMail string and generic functions * script needs OneTimePadDecrypt() (functions/strings.php) - * and sqgetGlobalVar() (functions/global.php, loaded by strings.php) + * and sqgetGlobalVar() (functions/global.php) */ +include_once(SM_PATH.'functions/global.php'); include_once(SM_PATH.'functions/strings.php'); /** @@ -36,14 +37,14 @@ function hex2ip($hex) { .hexdec(substr($hex,4,2)).'.' .hexdec(substr($hex,6,2)); } elseif (strlen($hex)==32) { - $ret=hexdec(substr($hex,0,4)).':' - .hexdec(substr($hex,4,4)).':' - .hexdec(substr($hex,8,4)).':' - .hexdec(substr($hex,12,4)).':' - .hexdec(substr($hex,16,4)).':' - .hexdec(substr($hex,20,4)).':' - .hexdec(substr($hex,24,4)).':' - .hexdec(substr($hex,28,4)); + $ret=substr($hex,0,4).':' + .substr($hex,4,4).':' + .substr($hex,8,4).':' + .substr($hex,12,4).':' + .substr($hex,16,4).':' + .substr($hex,20,4).':' + .substr($hex,24,4).':' + .substr($hex,28,4); } else { $ret=$hex; } @@ -59,33 +60,40 @@ echo '"; if (sqgetGlobalVar('submit',$submit,SQ_POST)) { + $continue = TRUE; if (! sqgetGlobalVar('secret',$secret,SQ_POST) || - empty($secret)) - echo "

You must enter encryption key.

\n"; + empty($secret)) { + $continue = FALSE; + echo "

You must enter an encryption key.

\n"; + } if (! sqgetGlobalVar('enc_string',$enc_string,SQ_POST) || - empty($enc_string)) - echo "

You must enter encrypted string.

\n"; + empty($enc_string)) { + $continue = FALSE; + echo "

You must enter an encrypted string.

\n"; + } - if (isset($enc_string) && ! base64_decode($enc_string)) { - echo "

Encrypted string should be BASE64 encoded.
\n" - ."Please enter all characters that are listed after header name.

\n"; - } elseif (isset($secret)) { - $string=OneTimePadDecrypt($enc_string,base64_encode($secret)); + if ($continue) { + if (isset($enc_string) && ! base64_decode($enc_string)) { + echo "

Encrypted string should be BASE64 encoded.
\n" + ."Please enter all characters that are listed after header name.

\n"; + } elseif (isset($secret)) { + $string=OneTimePadDecrypt($enc_string,base64_encode($secret)); - if (sqgetGlobalVar('ip_addr',$is_addr,SQ_POST)) { - $string=hex2ip($string); + if (sqgetGlobalVar('ip_addr',$is_addr,SQ_POST)) { + $string=hex2ip($string); + } + echo "

Decoded string: ".htmlspecialchars($string)."

\n"; } - echo "

Decoded string: ".$string."

\n"; } echo "
"; } ?> -
+

Secret key:
Encrypted string:
-Check, if it is an address string:
+

- \ No newline at end of file +