copyright update
[squirrelmail.git] / plugins / squirrelspell / modules / crypto.mod
1 <?php
2
3 /**
4 * crypto.mod
5 *
6 * Squirrelspell module
7 *
8 * This module handles the encryption/decryption of the user dictionary
9 * if the user so chooses from the options page.
10 *
11 * @author Konstantin Riabitsev <icon at duke.edu>
12 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
13 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 * @version $Id$
15 * @package plugins
16 * @subpackage squirrelspell
17 */
18
19 /**
20 * Declaring globals for E_ALL
21 */
22 global $SQSPELL_CRYPTO;
23
24 $langs=sqspell_getSettings();
25
26 if (! sqgetGlobalVar('action', $crypt_action, SQ_POST)) {
27 $crypt_action = 'noaction';
28 }
29
30 switch ($crypt_action){
31 case 'encrypt':
32 $SQSPELL_CRYPTO_ORIG=$SQSPELL_CRYPTO;
33
34 foreach ($langs as $lang) {
35 $SQSPELL_CRYPTO = $SQSPELL_CRYPTO_ORIG;
36 /**
37 * Let's encrypt the file and save it in an encrypted format.
38 */
39 $words=sqspell_getLang($lang);
40 /**
41 * Flip the flag so the sqspell_writeWords function knows to encrypt
42 * the message before writing it to the disk.
43 */
44 $SQSPELL_CRYPTO=true;
45 /**
46 * Call the function that does the actual encryption_decryption.
47 */
48 sqspell_writeWords($words,$lang);
49 }
50 $msg='<p>'
51 . _("Your personal dictionary has been encrypted and is now stored in an encrypted format.")
52 . '</p>';
53 break;
54 case 'decrypt':
55 $SQSPELL_CRYPTO_ORIG=$SQSPELL_CRYPTO;
56
57 foreach ($langs as $lang) {
58 $SQSPELL_CRYPTO = $SQSPELL_CRYPTO_ORIG;
59 /**
60 * Let's encrypt the file and save it in an encrypted format.
61 */
62 $words=sqspell_getLang($lang);
63 /**
64 * Flip the flag so the sqspell_writeWords function knows to decrypt
65 * the message before writing it to the disk.
66 */
67 $SQSPELL_CRYPTO=false;
68 /**
69 * Call the function that does the actual encryption_decryption.
70 */
71 sqspell_writeWords($words,$lang);
72 }
73 $msg='<p>'
74 . _("Your personal dictionary has been decrypted and is now stored as plain text.")
75 . '</p>';
76 break;
77 default:
78 /**
79 * Wait, this shouldn't happen! :)
80 */
81 $msg = '<p>'._("No action requested.").'</p>';
82 break;
83 }
84 sqspell_makePage( _("Personal Dictionary Crypto Settings"), null, $msg);
85
86 /**
87 * For Emacs weenies:
88 * Local variables:
89 * mode: php
90 * End:
91 * vim: syntax=php
92 */
93
94 ?>