crypto_badkey.mod 3.0 KB

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