replace reserved word 'action' with 'encaction'
[squirrelmail.git] / plugins / squirrelspell / modules / crypto.mod
CommitLineData
849bdf42 1<?php
4b4abf93 2
d112ed5a 3/**
2ad4cea9 4 * crypto.mod
d112ed5a 5 *
4b4abf93 6 * Squirrelspell module
d112ed5a 7 *
8 * This module handles the encryption/decryption of the user dictionary
9 * if the user so chooses from the options page.
10 *
4b4abf93 11 * @author Konstantin Riabitsev <icon at duke.edu>
47ccfad4 12 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
4b4abf93 13 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
44d661aa 14 * @version $Id$
15 * @package plugins
16 * @subpackage squirrelspell
d112ed5a 17 */
849bdf42 18
d112ed5a 19/**
20 * Declaring globals for E_ALL
21 */
d8aa9efe 22global $SQSPELL_CRYPTO;
23
7996c920 24$langs=sqspell_getSettings();
25
0c961f1d 26if (! sqgetGlobalVar('encaction', $crypt_action, SQ_POST)) {
7996c920 27 $crypt_action = 'noaction';
28}
29
30switch ($crypt_action){
2ad4cea9 31 case 'encrypt':
7996c920 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 }
2ad4cea9 50 $msg='<p>'
91e0dccc 51 . _("Your personal dictionary has been encrypted and is now stored in an encrypted format.")
2ad4cea9 52 . '</p>';
53 break;
54 case 'decrypt':
7996c920 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 }
2ad4cea9 73 $msg='<p>'
0091d9ae 74 . _("Your personal dictionary has been decrypted and is now stored as plain text.")
2ad4cea9 75 . '</p>';
76 break;
7996c920 77 default:
2ad4cea9 78 /**
79 * Wait, this shouldn't happen! :)
80 */
7996c920 81 $msg = '<p>'._("No action requested.").'</p>';
2ad4cea9 82 break;
d112ed5a 83}
84sqspell_makePage( _("Personal Dictionary Crypto Settings"), null, $msg);
85
86/**
87 * For Emacs weenies:
88 * Local variables:
89 * mode: php
90 * End:
2b6b400e 91 * vim: syntax=php
d112ed5a 92 */