crypto_badkey.mod 2.9 KB

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