8 * This module tries to decrypt the user dictionary with a newly provided
9 * old password, or erases the file if everything else fails. :(
11 * @author Konstantin Riabitsev <icon at duke.edu>
12 * @copyright © 1999-2006 The SquirrelMail Project Team
13 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
16 * @subpackage squirrelspell
20 sqgetGlobalVar('SCRIPT_NAME',$SCRIPT_NAME,SQ_SERVER);
22 if (! sqgetGlobalVar('delete_words',$delete_words,SQ_POST)){
23 $delete_words = 'OFF';
25 if (! sqgetGlobalVar('old_key',$old_key,SQ_POST)) {
29 if (! sqgetGlobalVar('old_setup',$temp,SQ_POST)) {
36 * Displays information about deleted dictionary
37 * @since 1.5.1 (sqspell 0.5)
39 function sqspell_dict_deleted() {
42 * See where we were called from -- pop-up window or options page
43 * and call whichever wrapper is appropriate.
44 * I agree, this is dirty.
45 * TODO: make it so it's not dirty.
46 * TODO: add upgrade handing
48 if (strstr($SCRIPT_NAME, 'sqspell_options')){
49 $msg='<p>' . _("Your personal dictionary was erased.") . '</p>';
50 sqspell_makePage(_("Dictionary Erased"), null, $msg);
53 * The _("Your....") has to be on one line. Otherwise xgettext borks
54 * on getting the strings.
57 . _("Your personal dictionary was erased. Please close this window and click \"Check Spelling\" button again to start your spellcheck over.")
59 . '<p align="center"><form>'
60 . '<input type="button" value=" '
61 . _("Close this Window") . ' " onclick="self.close()" />'
63 sqspell_makeWindow(null, _("Dictionary Erased"), null, $msg);
69 * Displays information about reencrypted dictionary
70 * @since 1.5.1 (sqspell 0.5)
72 function sqspell_dict_reencrypted() {
75 * See where we are and call a necessary GUI-wrapper.
77 * TODO: Make this not dirty.
78 * TODO: add upgrade handing
80 if (strstr($SCRIPT_NAME, 'sqspell_options')){
82 . _("Your personal dictionary was re-encrypted successfully. Now return to the "SpellChecker options" menu and make your selection again." )
84 sqspell_makePage(_("Successful re-encryption"), null, $msg);
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>';
91 sqspell_makeWindow(null, _("Dictionary re-encrypted"), null, $msg);
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();
102 } elseif ($delete_words=='ON'){
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.
108 sqspell_deleteWords_old();
109 sqspell_dict_deleted();
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();
120 * User provided another key to try and decrypt the dictionary.
121 * Call sqspell_getWords. If this key fails, the function will
124 $words=sqspell_getWords_old();
126 * It worked! Pinky, you're a genius!
127 * Write it back this time encrypted with a new key.
129 sqspell_writeWords_old($words);
130 sqspell_dict_reencrypted();
133 // TODO: handle broken calls