crypto.mod 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * crypto.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 handles the encryption/decryption of the user dictionary
  11. * if the user so chooses from the options page.
  12. *
  13. * $Id$
  14. *
  15. * @author Konstantin Riabitsev <icon@duke.edu> ($Author$)
  16. * @version $Date$
  17. */
  18. /**
  19. * Declaring globals for E_ALL
  20. */
  21. global $SQSPELL_CRYPTO;
  22. switch ($_POST['action']){
  23. case 'encrypt':
  24. /**
  25. * Let's encrypt the file and save it in an encrypted format.
  26. */
  27. $words=sqspell_getWords();
  28. /**
  29. * Flip the flag so the sqspell_writeWords function knows to encrypt
  30. * the message before writing it to the disk.
  31. */
  32. $SQSPELL_CRYPTO=true;
  33. /**
  34. * Call the function that does the actual encryption_decryption.
  35. */
  36. sqspell_writeWords($words);
  37. $msg='<p>'
  38. . _("Your personal dictionary has been encrypted and is now stored in an encrypted format.")
  39. . '</p>';
  40. break;
  41. case 'decrypt':
  42. /**
  43. * Let's decrypt the file and save it as plain text.
  44. */
  45. $words=sqspell_getWords();
  46. /**
  47. * Flip the flag and tell the sqspell_writeWords() function that we
  48. * want to save it plaintext.
  49. */
  50. $SQSPELL_CRYPTO=false;
  51. sqspell_writeWords($words);
  52. $msg='<p>'
  53. . _("Your personal dictionary has been decrypted and is now stored as plain text."),
  54. . '</p>';
  55. break;
  56. case '':
  57. /**
  58. * Wait, this shouldn't happen! :)
  59. */
  60. $msg = '<p>No action requested.</p>';
  61. break;
  62. }
  63. sqspell_makePage( _("Personal Dictionary Crypto Settings"), null, $msg);
  64. /**
  65. * For Emacs weenies:
  66. * Local variables:
  67. * mode: php
  68. * End:
  69. * vim: syntax=php
  70. */
  71. ?>