crypto.mod 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * crypto.mod.php
  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 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 $action, $SQSPELL_CRYPTO;
  22. switch ($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 <strong>encrypted</strong> and is now stored in an <strong>encrypted format</strong>.")
  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 <strong>decrypted</strong> and is now stored as <strong>clear text</strong>.")
  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. */
  70. ?>