One more
[squirrelmail.git] / plugins / squirrelspell / modules / crypto_badkey.mod.php
1 <?php
2 /**
3 CRYPTO_BADKEY.MOD.PHP
4 ---------------------
5 This module tries to decrypt the user dictionary with a newly provided
6 old password, or erases the file if everything else fails. :(
7 **/
8 // Just for fidian! :)
9 global $delete_words, $SCRIPT_NAME, $old_key;
10 if ($delete_words=="ON"){
11 // All attemts to decrypt the file were futile. Erase the bastard and
12 // hope this never happens again.
13 sqspell_deleteWords();
14 // See where we were called from -- pop-up window or options page
15 // and call whichever wrapper is appropriate.
16 if (strstr($SCRIPT_NAME, "sqspell_options")){
17 $msg="<p>Your personal dictionary was erased.</p>";
18 sqspell_makePage("Dictionary Erased", null, $msg);
19 } else {
20 $msg = "<p>Your personal dictionary was erased. Please close this window and
21 click \"Check Spelling\" button again to start your spellcheck over.</p>
22 <p align=\"center\"><form>
23 <input type=\"button\" value=\" Close this Window \" onclick=\"self.close()\">
24 </form></p>";
25 sqspell_makeWindow(null, "Dictionary Erased", null, $msg);
26 }
27 exit;
28 }
29
30 if ($old_key){
31 // User provided another key to try and decrypt the dictionary.
32 // call sqspell_getWords. If this key fails, the function will
33 // handle it.
34 $words=sqspell_getWords();
35 // It worked! Pinky, you're a genius!
36 // Write it back this time encrypted with a new key.
37 sqspell_writeWords($words);
38 // See where we are and call a necessary GUI-wrapper.
39 if (strstr($SCRIPT_NAME, "sqspell_options")){
40 $msg="<p>Your personal dictionary was re-encrypted successfully. Now
41 return to the &quot;SpellChecker options&quot; menu and make your selection
42 again.</p>";
43 sqspell_makePage("Successful Re-encryption", null, $msg);
44 } else {
45 $msg = "<p>Your personal dictionary was re-encrypted successfully. Please
46 close this window and click \"Check Spelling\" button again to start your
47 spellcheck over.</p>
48 <form><p align=\"center\"><input type=\"button\" value=\" Close this Window \"
49 onclick=\"self.close()\"></p></form>";
50 sqspell_makeWindow(null, "Dictionary re-encrypted", null, $msg);
51 }
52 exit;
53 }
54 ?>