crypto.mod 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * crypto.mod
  4. *
  5. * Squirrelspell module
  6. *
  7. * This module handles the encryption/decryption of the user dictionary
  8. * if the user so chooses from the options page.
  9. *
  10. * @author Konstantin Riabitsev <icon at duke.edu>
  11. * @copyright &copy; 1999-2006 The SquirrelMail Project Team
  12. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  13. * @version $Id$
  14. * @package plugins
  15. * @subpackage squirrelspell
  16. */
  17. /**
  18. * Declaring globals for E_ALL
  19. */
  20. global $SQSPELL_CRYPTO;
  21. $langs=sqspell_getSettings();
  22. if (! sqgetGlobalVar('encaction', $crypt_action, SQ_POST)) {
  23. $crypt_action = 'noaction';
  24. }
  25. switch ($crypt_action){
  26. case 'encrypt':
  27. $SQSPELL_CRYPTO_ORIG=$SQSPELL_CRYPTO;
  28. foreach ($langs as $lang) {
  29. $SQSPELL_CRYPTO = $SQSPELL_CRYPTO_ORIG;
  30. /**
  31. * Let's encrypt the file and save it in an encrypted format.
  32. */
  33. $words=sqspell_getLang($lang);
  34. /**
  35. * Flip the flag so the sqspell_writeWords function knows to encrypt
  36. * the message before writing it to the disk.
  37. */
  38. $SQSPELL_CRYPTO=true;
  39. /**
  40. * Call the function that does the actual encryption_decryption.
  41. */
  42. sqspell_writeWords($words,$lang);
  43. }
  44. $msg='<p>'
  45. . _("Your personal dictionary has been encrypted and is now stored in an encrypted format.")
  46. . '</p>';
  47. break;
  48. case 'decrypt':
  49. $SQSPELL_CRYPTO_ORIG=$SQSPELL_CRYPTO;
  50. foreach ($langs as $lang) {
  51. $SQSPELL_CRYPTO = $SQSPELL_CRYPTO_ORIG;
  52. /**
  53. * Let's encrypt the file and save it in an encrypted format.
  54. */
  55. $words=sqspell_getLang($lang);
  56. /**
  57. * Flip the flag so the sqspell_writeWords function knows to decrypt
  58. * the message before writing it to the disk.
  59. */
  60. $SQSPELL_CRYPTO=false;
  61. /**
  62. * Call the function that does the actual encryption_decryption.
  63. */
  64. sqspell_writeWords($words,$lang);
  65. }
  66. $msg='<p>'
  67. . _("Your personal dictionary has been decrypted and is now stored as plain text.")
  68. . '</p>';
  69. break;
  70. default:
  71. /**
  72. * Wait, this shouldn't happen! :)
  73. */
  74. $msg = '<p>'._("No action requested.").'</p>';
  75. break;
  76. }
  77. sqspell_makePage( _("Personal Dictionary Crypto Settings"), null, $msg);
  78. /**
  79. * For Emacs weenies:
  80. * Local variables:
  81. * mode: php
  82. * End:
  83. * vim: syntax=php
  84. */