c9ff535e60c3701ee0d8513802af7d550802b447
[squirrelmail.git] / plugins / squirrelspell / modules / crypto_badkey.mod
1 <?php
2 /**
3 * crypto_badkey.mod
4 * ------------------
5 * Squirrelspell module
6 *
7 * Copyright (c) 1999-2005 The SquirrelMail Project Team
8 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 *
10 * This module tries to decrypt the user dictionary with a newly provided
11 * old password, or erases the file if everything else fails. :(
12 *
13 * @author Konstantin Riabitsev <icon@duke.edu>
14 * @version $Id$
15 * @package plugins
16 * @subpackage squirrelspell
17 */
18
19 global $SCRIPT_NAME;
20
21 $delete_words = $_POST['delete_words'];
22 if(isset($_POST['old_key'])) {
23 $old_key = $_POST['old_key'];
24 }
25
26 if ($delete_words=='ON'){
27 /**
28 * $delete_words is passed via the query_string. If it's set, then
29 * the user asked to delete the file. Erase the bastard and hope
30 * this never happens again.
31 */
32 sqspell_deleteWords();
33 /**
34 * See where we were called from -- pop-up window or options page
35 * and call whichever wrapper is appropriate.
36 * I agree, this is dirty. TODO: make it so it's not dirty.
37 */
38 if (strstr($SCRIPT_NAME, 'sqspell_options')){
39 $msg='<p>' . _("Your personal dictionary was erased.") . '</p>';
40 sqspell_makePage(_("Dictionary Erased"), null, $msg);
41 } else {
42 /**
43 * The _("Your....") has to be on one line. Otherwise xgettext borks
44 * on getting the strings.
45 */
46 $msg = '<p>'
47 . _("Your personal dictionary was erased. Please close this window and click \"Check Spelling\" button again to start your spellcheck over.")
48 . '</p> '
49 . '<p align="center"><form>'
50 . '<input type="button" value=" '
51 . _("Close this Window") . ' " onclick="self.close()" />'
52 . '</form></p>';
53 sqspell_makeWindow(null, _("Dictionary Erased"), null, $msg);
54 }
55 exit;
56 }
57
58 if ($old_key){
59 /**
60 * User provided another key to try and decrypt the dictionary.
61 * Call sqspell_getWords. If this key fails, the function will
62 * handle it.
63 */
64 $words=sqspell_getWords();
65 /**
66 * It worked! Pinky, you're a genius!
67 * Write it back this time encrypted with a new key.
68 */
69 sqspell_writeWords($words);
70 /**
71 * See where we are and call a necessary GUI-wrapper.
72 * Also dirty. TODO: Make this not dirty.
73 */
74 if (strstr($SCRIPT_NAME, 'sqspell_options')){
75 $msg = '<p>'
76 . _("Your personal dictionary was re-encrypted successfully. Now return to the &quot;SpellChecker options&quot; menu and make your selection again." )
77 . '</p>';
78 sqspell_makePage(_("Successful re-encryption"), null, $msg);
79 } else {
80 $msg = '<p>'
81 . _("Your personal dictionary was re-encrypted successfully. Please close this window and click \"Check Spelling\" button again to start your spellcheck over.")
82 . '</p><form><p align="center"><input type="button" value=" '
83 . _("Close this Window") . ' "'
84 . 'onclick="self.close()" /></p></form>';
85 sqspell_makeWindow(null, _("Dictionary re-encrypted"), null, $msg);
86 }
87 exit;
88 }
89
90 /**
91 * For Emacs weenies:
92 * Local variables:
93 * mode: php
94 * End:
95 * vim: syntax=php
96 */
97 ?>