849bdf42 |
1 | <?php |
4b4abf93 |
2 | |
d112ed5a |
3 | /** |
4 | * crypto_badkey.mod |
d112ed5a |
5 | * |
4b4abf93 |
6 | * Squirrelspell module |
d112ed5a |
7 | * |
8 | * This module tries to decrypt the user dictionary with a newly provided |
44d661aa |
9 | * old password, or erases the file if everything else fails. :( |
d112ed5a |
10 | * |
4b4abf93 |
11 | * @author Konstantin Riabitsev <icon at duke.edu> |
47ccfad4 |
12 | * @copyright © 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 | |
7996c920 |
19 | /** get script name*/ |
20 | sqgetGlobalVar('SCRIPT_NAME',$SCRIPT_NAME,SQ_SERVER); |
d8aa9efe |
21 | |
7996c920 |
22 | if (! sqgetGlobalVar('delete_words',$delete_words,SQ_POST)){ |
23 | $delete_words = 'OFF'; |
24 | } |
25 | if (! sqgetGlobalVar('old_key',$old_key,SQ_POST)) { |
26 | $old_key=null; |
d8aa9efe |
27 | } |
28 | |
7996c920 |
29 | if (! sqgetGlobalVar('old_setup',$temp,SQ_POST)) { |
30 | $old_setup = false; |
31 | } else { |
32 | $old_setup = true; |
33 | } |
34 | |
35 | /** |
36 | * Displays information about deleted dictionary |
37 | * @since 1.5.1 (sqspell 0.5) |
38 | */ |
39 | function sqspell_dict_deleted() { |
40 | global $SCRIPT_NAME; |
d112ed5a |
41 | /** |
42 | * See where we were called from -- pop-up window or options page |
43 | * and call whichever wrapper is appropriate. |
7996c920 |
44 | * I agree, this is dirty. |
45 | * TODO: make it so it's not dirty. |
46 | * TODO: add upgrade handing |
d112ed5a |
47 | */ |
48 | if (strstr($SCRIPT_NAME, 'sqspell_options')){ |
49 | $msg='<p>' . _("Your personal dictionary was erased.") . '</p>'; |
50 | sqspell_makePage(_("Dictionary Erased"), null, $msg); |
51 | } else { |
52 | /** |
53 | * The _("Your....") has to be on one line. Otherwise xgettext borks |
54 | * on getting the strings. |
55 | */ |
91e0dccc |
56 | $msg = '<p>' |
7996c920 |
57 | . _("Your personal dictionary was erased. Please close this window and click \"Check Spelling\" button again to start your spellcheck over.") |
58 | . '</p> ' |
59 | . '<p align="center"><form>' |
60 | . '<input type="button" value=" ' |
61 | . _("Close this Window") . ' " onclick="self.close()" />' |
62 | . '</form></p>'; |
d112ed5a |
63 | sqspell_makeWindow(null, _("Dictionary Erased"), null, $msg); |
64 | } |
65 | exit; |
66 | } |
91e0dccc |
67 | |
7996c920 |
68 | /** |
69 | * Displays information about reencrypted dictionary |
70 | * @since 1.5.1 (sqspell 0.5) |
71 | */ |
72 | function sqspell_dict_reencrypted() { |
73 | global $SCRIPT_NAME; |
d112ed5a |
74 | /** |
75 | * See where we are and call a necessary GUI-wrapper. |
7996c920 |
76 | * Also dirty. |
77 | * TODO: Make this not dirty. |
78 | * TODO: add upgrade handing |
d112ed5a |
79 | */ |
80 | if (strstr($SCRIPT_NAME, 'sqspell_options')){ |
81 | $msg = '<p>' |
7996c920 |
82 | . _("Your personal dictionary was re-encrypted successfully. Now return to the "SpellChecker options" menu and make your selection again." ) |
83 | . '</p>'; |
74091b64 |
84 | sqspell_makePage(_("Successful re-encryption"), null, $msg); |
d112ed5a |
85 | } else { |
86 | $msg = '<p>' |
90ad8cd1 |
87 | . _("Your personal dictionary was re-encrypted successfully. Please close this window and click \"Check Spelling\" button again to start your spellcheck over.") |
88 | . '</p><form><p align="center"><input type="button" value=" ' |
89 | . _("Close this Window") . ' "' |
90 | . 'onclick="self.close()" /></p></form>'; |
d112ed5a |
91 | sqspell_makeWindow(null, _("Dictionary re-encrypted"), null, $msg); |
92 | } |
93 | exit; |
94 | } |
95 | |
7996c920 |
96 | // main code |
97 | if (! $old_setup && $delete_words=='ON') { |
98 | if (sqgetGlobalVar('dict_lang',$dict_lang,SQ_POST)) { |
99 | sqspell_deleteWords($dict_lang); |
100 | sqspell_dict_deleted(); |
101 | } |
102 | } elseif ($delete_words=='ON'){ |
103 | /** |
104 | * $delete_words is passed via the query_string. If it's set, then |
105 | * the user asked to delete the file. Erase the bastard and hope |
106 | * this never happens again. |
107 | */ |
108 | sqspell_deleteWords_old(); |
109 | sqspell_dict_deleted(); |
110 | } |
111 | |
112 | if (! $old_setup && $old_key) { |
113 | if (sqgetGlobalVar('dict_lang',$dict_lang,SQ_POST)) { |
114 | $words=sqspell_getLang($dict_lang); |
115 | sqspell_writeWords($words,$dict_lang); |
116 | sqspell_dict_reencrypted(); |
117 | } |
118 | } elseif ($old_key){ |
119 | /** |
120 | * User provided another key to try and decrypt the dictionary. |
121 | * Call sqspell_getWords. If this key fails, the function will |
122 | * handle it. |
123 | */ |
124 | $words=sqspell_getWords_old(); |
125 | /** |
126 | * It worked! Pinky, you're a genius! |
127 | * Write it back this time encrypted with a new key. |
128 | */ |
129 | sqspell_writeWords_old($words); |
130 | sqspell_dict_reencrypted(); |
131 | } |
132 | |
133 | // TODO: handle broken calls |
134 | |
d112ed5a |
135 | /** |
136 | * For Emacs weenies: |
137 | * Local variables: |
138 | * mode: php |
139 | * End: |
2b6b400e |
140 | * vim: syntax=php |
91e0dccc |
141 | */ |