3 * Script provides form to decode encrypted header information.
5 * Copyright (c) 2005 The SquirrelMail Project Team
6 * This file is part of SquirrelMail webmail interface.
8 * SquirrelMail is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * SquirrelMail is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with SquirrelMail; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * @package squirrelmail
27 * Set constant to path of your SquirrelMail install.
30 define('SM_PATH','../');
33 * include SquirrelMail string functions
34 * script needs OneTimePadDecrypt() (functions/strings.php)
35 * and sqgetGlobalVar() (functions/global.php, loaded by strings.php)
37 include_once(SM_PATH
.'functions/strings.php');
40 * converts hex string to ip address
41 * @param string $hex hexadecimal string created with squirrelmail ip2hex
42 * function in delivery class.
43 * @return string ip address
44 * @since 1.5.1 and 1.4.5
46 function hex2ip($hex) {
47 if (strlen($hex)==8) {
48 $ret=hexdec(substr($hex,0,2)).'.'
49 .hexdec(substr($hex,2,2)).'.'
50 .hexdec(substr($hex,4,2)).'.'
51 .hexdec(substr($hex,6,2));
52 } elseif (strlen($hex)==32) {
53 $ret=hexdec(substr($hex,0,4)).':'
54 .hexdec(substr($hex,4,4)).':'
55 .hexdec(substr($hex,8,4)).':'
56 .hexdec(substr($hex,12,4)).':'
57 .hexdec(substr($hex,16,4)).':'
58 .hexdec(substr($hex,20,4)).':'
59 .hexdec(substr($hex,24,4)).':'
60 .hexdec(substr($hex,28,4));
67 /** create page headers */
68 header('Content-Type: text/html');
70 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'
71 ."\n<head>\n<meta name=\"robots\" content=\"noindex,nofollow\">\n"
74 if (sqgetGlobalVar('submit',$submit,SQ_POST
)) {
75 if (! sqgetGlobalVar('secret',$secret,SQ_POST
) ||
77 echo "<p>You must enter encryption key.</p>\n";
78 if (! sqgetGlobalVar('enc_string',$enc_string,SQ_POST
) ||
80 echo "<p>You must enter encrypted string.</p>\n";
82 if (isset($enc_string) && ! base64_decode($enc_string)) {
83 echo "<p>Encrypted string should be BASE64 encoded.<br />\n"
84 ."Please enter all characters that are listed after header name.</p>\n";
85 } elseif (isset($secret)) {
86 $string=OneTimePadDecrypt($enc_string,base64_encode($secret));
88 if (sqgetGlobalVar('ip_addr',$is_addr,SQ_POST
)) {
89 $string=hex2ip($string);
91 echo "<p>Decoded string: ".$string."</p>\n";
96 <form action
="<?php echo $PHP_SELF ?>" method
="post" >
98 Secret key
: <input type
="password" name
="secret"><br
/>
99 Encrypted
string: <input type
="text" name
="enc_string"><br
/>
100 Check
, if it is an address
string: <input type
="checkbox" name
="ip_addr" /><br
/>
101 <button type
="submit" name
="submit" value
="submit">Submit
</button
>