849bdf42 |
1 | <?php |
d112ed5a |
2 | /** |
3 | * crypto_badkey.mod |
4 | * ------------------ |
5 | * Squirrelspell module |
6 | * |
76911253 |
7 | * Copyright (c) 1999-2003 The SquirrelMail development team |
d112ed5a |
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 | * $Id$ |
14 | * |
15 | * @author Konstantin Riabitsev <icon@duke.edu> ($Author$) |
16 | * @version $Date$ |
17 | */ |
849bdf42 |
18 | |
d8aa9efe |
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 | |
d112ed5a |
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 | } |
2b5a7157 |
57 | |
d112ed5a |
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 "SpellChecker options" 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: |
2b6b400e |
95 | * vim: syntax=php |
d112ed5a |
96 | */ |
15e6162e |
97 | ?> |