Happy New Year
[squirrelmail.git] / plugins / squirrelspell / modules / crypto.mod
index 3c8651aba84bda3a821372bdf04e5a04e3605c7a..8aa6b95206de73b033ba0221af7336b27b03458f 100644 (file)
@@ -1,16 +1,16 @@
 <?php
+
 /**
  * crypto.mod
- * ---------------
- * Squirrelspell module
  *
- * Copyright (c) 1999-2004 The SquirrelMail development team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
+ * Squirrelspell module
  *
  * This module handles the encryption/decryption of the user dictionary
  * if the user so chooses from the options page.
  *
- * @author Konstantin Riabitsev <icon@duke.edu>
+ * @author Konstantin Riabitsev <icon at duke.edu>
+ * @copyright 1999-2018 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package plugins
  * @subpackage squirrelspell
  */
 global $SQSPELL_CRYPTO;
 
-switch ($_POST['action']){
+$langs=sqspell_getSettings();
+
+if (! sqgetGlobalVar('encaction', $crypt_action, SQ_POST)) {
+    $crypt_action = 'noaction';
+}
+
+switch ($crypt_action){
     case 'encrypt':
-        /**
-         * Let's encrypt the file and save it in an encrypted format.
-         */
-        $words=sqspell_getWords();
-        /**
-         * Flip the flag so the sqspell_writeWords function knows to encrypt
-         * the message before writing it to the disk.
-         */
-        $SQSPELL_CRYPTO=true;
-        /**
-         * Call the function that does the actual encryption_decryption.
-         */
-        sqspell_writeWords($words);
+        $SQSPELL_CRYPTO_ORIG=$SQSPELL_CRYPTO;
+
+        foreach ($langs as $lang) {
+            $SQSPELL_CRYPTO = $SQSPELL_CRYPTO_ORIG;
+            /**
+             * Let's encrypt the file and save it in an encrypted format.
+             */
+            $words=sqspell_getLang($lang);
+            /**
+             * Flip the flag so the sqspell_writeWords function knows to encrypt
+             * the message before writing it to the disk.
+             */
+            $SQSPELL_CRYPTO=true;
+            /**
+             * Call the function that does the actual encryption_decryption.
+             */
+            sqspell_writeWords($words,$lang);
+        }
         $msg='<p>'
             . _("Your personal dictionary has been encrypted and is now stored in an encrypted format.")
             . '</p>';
     break;
     case 'decrypt':
-        /**
-         * Let's decrypt the file and save it as plain text.
-         */
-        $words=sqspell_getWords();
-        /**
-         * Flip the flag and tell the sqspell_writeWords() function that we
-         * want to save it plaintext.
-         */
-        $SQSPELL_CRYPTO=false;
-        sqspell_writeWords($words);
+        $SQSPELL_CRYPTO_ORIG=$SQSPELL_CRYPTO;
+
+        foreach ($langs as $lang) {
+            $SQSPELL_CRYPTO = $SQSPELL_CRYPTO_ORIG;
+            /**
+             * Let's encrypt the file and save it in an encrypted format.
+             */
+            $words=sqspell_getLang($lang);
+            /**
+             * Flip the flag so the sqspell_writeWords function knows to decrypt
+             * the message before writing it to the disk.
+             */
+            $SQSPELL_CRYPTO=false;
+            /**
+             * Call the function that does the actual encryption_decryption.
+             */
+            sqspell_writeWords($words,$lang);
+        }
         $msg='<p>'
             . _("Your personal dictionary has been decrypted and is now stored as plain text.")
             . '</p>';
     break;
-    case '':
+    default:
         /**
          * Wait, this shouldn't happen! :)
          */
-        $msg = '<p>No action requested.</p>';
+        $msg = '<p>'._("No action requested.").'</p>';
     break;
 }
 sqspell_makePage( _("Personal Dictionary Crypto Settings"), null, $msg);
@@ -71,5 +90,3 @@ sqspell_makePage( _("Personal Dictionary Crypto Settings"), null, $msg);
  * End:
  * vim: syntax=php
  */
-
-?>
\ No newline at end of file