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