f64f9e7de757a8fea65b038fd6d70ae486a37392
4 * sqspell_functions.php
6 * All SquirrelSpell-wide functions are in this file.
8 * @author Konstantin Riabitsev <icon at duke.edu>
9 * @copyright 1999-2017 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 * @subpackage squirrelspell
16 /** globalize configuration vars **/
17 global $SQSPELL_APP, $SQSPELL_APP_DEFAULT, $SQSPELL_WORDS_FILE, $SQSPELL_CRYPTO;
20 * load plugin configuration
21 * @todo allow storing configuration file in config/ directory
23 include_once(SM_PATH
. 'plugins/squirrelspell/sqspell_config.php');
26 * Workaround for including function squirrelspell_version() in SM 1.5 CVS,
27 * where plugins' setup.php is not included by default.
29 include_once(SM_PATH
. 'plugins/squirrelspell/setup.php');
31 /** Hooked functions **/
34 * Register option page block (internal function)
35 * @since 1.5.1 (sqspell 0.5)
38 function squirrelspell_optpage_block_function() {
39 global $optpage_blocks;
42 * Dependency on JavaScript is checked by SquirrelMail scripts
43 * Register Squirrelspell with the $optpage_blocks array.
47 'name' => _("SpellChecker Options"),
48 'url' => '../plugins/squirrelspell/sqspell_options.php',
49 'desc' => _("Here you may set up how your personal dictionary is stored, edit it, or choose which languages should be available to you when spell-checking."),
54 * This function adds a "Check Spelling" link to the "Compose" row
55 * during message composition (internal function).
56 * @since 1.5.1 (sqspell 0.5)
59 function squirrelspell_setup_function() {
61 global $data_dir, $username;
62 $sqspell_show_button = getPref($data_dir, $username, 'sqspell_show_button', 1);
65 * Check if this browser is capable of displaying SquirrelSpell
68 if ($sqspell_show_button && checkForJavascript()) {
70 global $oTemplate, $base_uri, $nbsp;
72 $output = addButton(_("Check Spelling"),
74 array('onclick' => 'window.open(\'' . $base_uri
75 . 'plugins/squirrelspell/sqspell_interface.php\', \'sqspell\', \'status=yes,width=550,height=370,resizable=yes\')')) . $nbsp;
77 return array('compose_button_row' => $output);
82 * Upgrade dictionaries (internal function)
84 * Transparently upgrades user's dictionaries when message listing is loaded
85 * @since 1.5.1 (sqspell 0.5)
87 function squirrelspell_upgrade_function() {
88 global $data_dir, $username;
90 if (! sqspell_check_version(0,5)) {
91 $langs=sqspell_getSettings_old(null);
92 $words=sqspell_getWords_old();
93 sqspell_saveSettings($langs);
94 foreach ($langs as $lang) {
95 $lang_words=sqspell_getLang_old($words,$lang);
96 $aLang_words=explode("\n",$lang_words);
98 foreach($aLang_words as $word) {
99 if (! preg_match("/^#/",$word) && trim($word)!='') {
103 sqspell_writeWords($new_words,$lang);
105 // bump up version number
106 setPref($data_dir,$username,'sqspell_version','0.5');
110 /** Internal functions **/
113 * This function is the GUI wrapper for the options page. SquirrelSpell
114 * uses it for creating all Options pages.
116 * @param string $title The title of the page to display
117 * @param string $scriptsrc This is used to link a file.js into the
118 * <script src="file.js"></script> format. This
119 * allows to separate javascript from the rest of the
120 * plugin and place it into the js/ directory.
121 * @param string $body The body of the message to display.
124 function sqspell_makePage($title, $scriptsrc, $body){
127 if (! sqgetGlobalVar('MOD', $MOD, SQ_GET
) ) {
128 $MOD = 'options_main';
131 displayPageHeader($color);
132 echo " <br />\n";
134 * Check if we need to link in a script.
137 echo "<script type=\"text/javascript\" src=\"js/$scriptsrc\"></script>\n";
139 echo html_tag( 'table', '', 'center', '', 'width="95%" border="0" cellpadding="2" cellspacing="0"' ) . "\n"
140 . html_tag( 'tr', "\n" .
141 html_tag( 'td', '<strong>' . $title .'</strong>', 'center', $color[9] )
143 . html_tag( 'tr', "\n" .
144 html_tag( 'td', '<hr />', 'left' )
146 . html_tag( 'tr', "\n" .
147 html_tag( 'td', $body, 'left' )
150 * Generate a nice "Return to Options" link, unless this is the
153 if ($MOD != "options_main"){
154 echo html_tag( 'tr', "\n" .
155 html_tag( 'td', '<hr />', 'left' )
157 . html_tag( 'tr', "\n" .
158 html_tag( 'td', '<a href="sqspell_options.php">'
159 . _("Back to "SpellChecker Options" page")
165 * Close the table and display the version.
167 echo html_tag( 'tr', "\n" .
168 html_tag( 'td', '<hr />', 'left' )
171 html_tag( 'td', 'SquirrelSpell ' . squirrelspell_version(), 'center', $color[9] )
173 echo '</body></html>';
177 * Function similar to the one above. This one is a general wrapper
178 * for the Squirrelspell pop-up window. It's called form nearly
179 * everywhere, except the check_me module, since that one is highly
182 * @param string $onload Used to indicate and pass the name of a js function
183 * to call in a <body onload="function()" for automatic
184 * onload script execution.
185 * @param string $title Title of the page.
186 * @param string $scriptsrc If defined, link this javascript source page into
187 * the document using <script src="file.js"> format.
188 * @param string $body The content to include.
191 function sqspell_makeWindow($onload, $title, $scriptsrc, $body){
194 displayHtmlHeader($title,
195 ($scriptsrc ?
"\n<script type=\"text/javascript\" src=\"js/$scriptsrc\"></script>\n" : ''));
197 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" "
198 . "vlink=\"$color[7]\" alink=\"$color[7]\"";
200 * Provide an onload="jsfunction()" if asked to.
203 echo " onload=\"$onload\"";
206 * Draw the rest of the page.
209 . html_tag( 'table', "\n" .
210 html_tag( 'tr', "\n" .
211 html_tag( 'td', '<strong>' . $title . '</strong>', 'center', $color[9] )
213 html_tag( 'tr', "\n" .
214 html_tag( 'td', '<hr />', 'left' )
216 html_tag( 'tr', "\n" .
217 html_tag( 'td', $body, 'left' )
219 html_tag( 'tr', "\n" .
220 html_tag( 'td', '<hr />', 'left' )
222 html_tag( 'tr', "\n" .
223 html_tag( 'td', 'SquirrelSpell ' . squirrelspell_version(), 'center', $color[9] )
225 '', '', 'width="100%" border="0" cellpadding="2"' );
228 $oTemplate->display('footer.tpl');
232 * Encryption function used by plugin (old format)
234 * This function does the encryption and decryption of the user
235 * dictionary. It is only available when PHP is compiled with
236 * mcrypt support (--with-mcrypt). See doc/CRYPTO for more
239 * @param $mode A string with either of the two recognized values:
240 * "encrypt" or "decrypt".
241 * @param $ckey The key to use for processing (the user's password
243 * @param $input Content to decrypt or encrypt, according to $mode.
244 * @return encrypted/decrypted content, or "PANIC" if the
246 * @since 1.5.1 (sqspell 0.5)
249 function sqspell_crypto_old($mode, $ckey, $input){
251 * Double-check if we have the mcrypt_generic function. Bail out if
254 if (!function_exists('mcrypt_generic')) {
258 * Setup mcrypt routines.
260 $td = mcrypt_module_open(MCRYPT_Blowfish
, "", MCRYPT_MODE_ECB
, "");
261 $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size ($td), MCRYPT_RAND
);
262 mcrypt_generic_init($td, $ckey, $iv);
264 * See what we have to do depending on $mode.
265 * 'encrypt' -- Encrypt the content.
266 * 'decrypt' -- Decrypt the content.
270 $crypto = mcrypt_generic($td, $input);
273 $crypto = mdecrypt_generic($td, $input);
275 * See if it decrypted successfully. If so, it should contain
276 * the string "# SquirrelSpell". If not, then bail out.
278 if (!strstr($crypto, "# SquirrelSpell")){
284 * Finish up the mcrypt routines and return the processed content.
286 if (function_exists('mcrypt_generic_deinit')) {
288 mcrypt_generic_deinit ($td);
289 mcrypt_module_close ($td);
291 // older deprecated function
292 mcrypt_generic_end ($td);
298 * Encryption function used by plugin
300 * This function does the encryption and decryption of the user
301 * dictionary. It is only available when PHP is compiled with
302 * mcrypt support (--with-mcrypt). See doc/CRYPTO for more
305 * @param $mode A string with either of the two recognized values:
306 * "encrypt" or "decrypt".
307 * @param $ckey The key to use for processing (the user's password
309 * @param $input Content to decrypt or encrypt, according to $mode.
310 * @return encrypted/decrypted content, or "PANIC" if the
313 function sqspell_crypto($mode, $ckey, $input){
315 * Double-check if we have the mcrypt_generic function. Bail out if
318 if (!function_exists('mcrypt_generic')) {
322 * Setup mcrypt routines.
324 $td = mcrypt_module_open(MCRYPT_Blowfish
, "", MCRYPT_MODE_ECB
, "");
325 $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size ($td), MCRYPT_RAND
);
326 mcrypt_generic_init($td, $ckey, $iv);
328 * See what we have to do depending on $mode.
329 * 'encrypt' -- Encrypt the content.
330 * 'decrypt' -- Decrypt the content.
334 $crypto = mcrypt_generic($td, '{sqspell}'.$input);
337 $crypto = mdecrypt_generic($td, $input);
338 if (preg_match("/^\{sqspell\}(.*)/",$crypto,$match)){
339 $crypto = trim($match[1]);
346 * Finish up the mcrypt routines and return the processed content.
348 if (function_exists('mcrypt_generic_deinit')) {
350 mcrypt_generic_deinit ($td);
351 mcrypt_module_close ($td);
353 // older deprecated function
354 mcrypt_generic_end ($td);
360 * This function transparently upgrades the 0.2 dictionary format to the
361 * 0.3 format, since user-defined languages have been added in 0.3 and
362 * the new format keeps user dictionaries selection in the file.
364 * This function will be retired soon, as it's been a while since anyone
365 * has been using SquirrelSpell-0.2.
367 * @param $words_string Contents of the 0.2-style user dictionary.
368 * @return Contents of the 0.3-style user dictionary.
371 function sqspell_upgradeWordsFile($words_string){
372 global $SQSPELL_APP_DEFAULT, $SQSPELL_VERSION;
374 * Define just one dictionary for this user -- the default.
375 * If the user wants more, s/he can set them up in personal
376 * preferences. See doc/UPGRADING for more info.
379 substr_replace($words_string,
380 "# SquirrelSpell User Dictionary $SQSPELL_VERSION\n# "
381 . "Last Revision: " . date("Y-m-d")
382 . "\n# LANG: $SQSPELL_APP_DEFAULT\n# $SQSPELL_APP_DEFAULT",
383 0, strpos($words_string, "\n")) . "# End\n";
384 sqspell_writeWords($new_words_string);
385 return $new_words_string;
389 * gets list of available dictionaries from user's prefs.
390 * Function was modified in 1.5.1 (sqspell 0.5).
391 * Older function is suffixed with '_old'
392 * @return array list of dictionaries used by end user.
394 function sqspell_getSettings(){
395 global $data_dir, $username, $SQSPELL_APP_DEFAULT, $SQSPELL_APP;
399 $sLangs=getPref($data_dir,$username,'sqspell_langs','');
401 $ret[0]=$SQSPELL_APP_DEFAULT;
403 $aLangs = explode(',',$sLangs);
404 foreach ($aLangs as $lang) {
405 if (array_key_exists($lang,$SQSPELL_APP)) {
414 * Saves user's language preferences
415 * @param array $langs languages array (first key is default language)
416 * @since 1.5.1 (sqspell 0.5)
418 function sqspell_saveSettings($langs) {
419 global $data_dir, $username;
420 setPref($data_dir,$username,'sqspell_langs',implode(',',$langs));
424 * Get list of enabled languages.
426 * Right now it just returns an array with the dictionaries
427 * available to the user for spell-checking. It will probably
428 * do more in the future, as features are added.
430 * @param string $words The contents of the user's ".words" file.
431 * @return array a strings array with dictionaries available
432 * to this user, e.g. {"English", "Spanish"}, etc.
433 * @since 1.5.1 (sqspell 0.5)
436 function sqspell_getSettings_old($words){
437 global $SQSPELL_APP, $SQSPELL_APP_DEFAULT;
439 * Check if there is more than one dictionary configured in the
442 if (sizeof($SQSPELL_APP) > 1){
444 * Now load the user prefs. Check if $words was empty -- a bit of
445 * a dirty fall-back. TODO: make it so this is not required.
448 $words=sqspell_getWords_old();
452 * This user has a ".words" file.
453 * Find which dictionaries s/he wants to use and load them into
456 preg_match("/# LANG: (.*)/i", $words, $matches);
457 $langs=explode(", ", $matches[1]);
460 * User doesn't have a personal dictionary. Grab the default
463 $langs[0]=$SQSPELL_APP_DEFAULT;
467 * There is no need to read the ".words" file as there is only one
468 * dictionary defined system-wide.
470 $langs[0]=$SQSPELL_APP_DEFAULT;
476 * Get user dictionary for selected language
477 * Function was modified in 1.5.1 (sqspell 0.5).
478 * Older function is suffixed with '_old'
479 * @param string $lang language
480 * @param array words stored in selected language dictionary
482 function sqspell_getLang($lang) {
483 global $data_dir, $username,$SQSPELL_CRYPTO;
484 $sWords=getPref($data_dir,$username,'sqspell_dict_' . $lang,'');
485 if (preg_match("/^\{crypt\}(.*)/i",$sWords,$match)) {
487 * Dictionary is encrypted or mangled. Try to decrypt it.
488 * If fails, complain loudly.
490 * $old_key would be a value submitted by one of the modules with
491 * the user's old mailbox password. I admin, this is rather dirty,
494 if (sqgetGlobalVar('old_key', $old_key, SQ_POST
)) {
497 sqgetGlobalVar('key', $key, SQ_COOKIE
);
498 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
500 * Get user's password (the key).
502 $clear_key = OneTimePadDecrypt($key, $onetimepad);
505 * Invoke the decryption routines.
507 $sWords=sqspell_crypto("decrypt", $clear_key, $match[1]);
509 * See if decryption failed.
511 if ($sWords=="PANIC"){
512 sqspell_handle_crypt_panic($lang);
513 // script execution stops here
516 * OK! Phew. Set the encryption flag to true so we can later on
517 * encrypt it again before saving to HDD.
519 $SQSPELL_CRYPTO=true;
523 * No encryption is/was used. Set $SQSPELL_CRYPTO to false,
524 * in case we have to save the dictionary later.
526 $SQSPELL_CRYPTO=false;
528 // rebuild word list and remove empty entries
530 foreach (explode(',',$sWords) as $word) {
531 if (trim($word) !='') {
532 $aWords[]=trim($word);
539 * Get user's dictionary (old format)
541 * This function returns only user-defined dictionary words that correspond
542 * to the requested language.
544 * @param $words The contents of the user's ".words" file.
545 * @param $lang Which language words to return, e.g. requesting
546 * "English" will return ONLY the words from user's
547 * English dictionary, disregarding any others.
548 * @return The list of words corresponding to the language
550 * @since 1.5.1 (sqspell 0.5)
553 function sqspell_getLang_old($words, $lang){
554 $start=strpos($words, "# $lang\n");
556 * strpos() will return -1 if no # $lang\n string was found.
557 * Use this to return a zero-length value and indicate that no
558 * words are present in the requested dictionary.
560 if (!$start) return '';
562 * The words list will end with a new directive, which will start
563 * with "#". Locate the next "#" and thus find out where the
566 $end=strpos($words, "#", $start+
1);
567 $lang_words = substr($words, $start, $end-$start);
572 * Saves user's dictionary (old format)
574 * This function operates the user dictionary. If the format is
575 * clear-text, then it just reads the file and returns it. However, if
576 * the file is encrypted (well, "garbled"), then it tries to decrypt
577 * it, checks whether the decryption was successful, troubleshoots if
578 * not, then returns the clear-text dictionary to the app.
580 * @return the contents of the user's ".words" file, decrypted if
582 * @since 1.5.1 (sqspell 0.5)
585 function sqspell_getWords_old(){
586 global $SQSPELL_WORDS_FILE, $SQSPELL_CRYPTO;
588 if (file_exists($SQSPELL_WORDS_FILE)){
592 $fp=fopen($SQSPELL_WORDS_FILE, 'r');
593 $words=fread($fp, filesize($SQSPELL_WORDS_FILE));
597 * Check if this is an encrypted file by looking for
598 * the string "# SquirrelSpell" in it (the crypto
599 * function does that).
601 if ($words && !strstr($words, "# SquirrelSpell")){
603 * This file is encrypted or mangled. Try to decrypt it.
604 * If fails, complain loudly.
606 * $old_key would be a value submitted by one of the modules with
607 * the user's old mailbox password. I admin, this is rather dirty,
610 sqgetGlobalVar('key', $key, SQ_COOKIE
);
611 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
613 sqgetGlobalVar('old_key', $old_key, SQ_POST
);
615 if ($old_key != '') {
619 * Get user's password (the key).
621 $clear_key = OneTimePadDecrypt($key, $onetimepad);
624 * Invoke the decryption routines.
626 $words=sqspell_crypto_old("decrypt", $clear_key, $words);
628 * See if decryption failed.
630 if ($words=="PANIC"){
631 sqspell_handle_crypt_panic();
632 // script execution stops here.
635 * OK! Phew. Set the encryption flag to true so we can later on
636 * encrypt it again before saving to HDD.
638 $SQSPELL_CRYPTO=true;
642 * No encryption is/was used. Set $SQSPELL_CRYPTO to false,
643 * in case we have to save the dictionary later.
645 $SQSPELL_CRYPTO=false;
648 * Check if we need to upgrade the dictionary from version 0.2.x
649 * This is going away soon.
651 if (strstr($words, "Dictionary v0.2")){
652 $words=sqspell_upgradeWordsFile($words);
658 * Saves user's dictionary
659 * Function was replaced in 1.5.1 (sqspell 0.5).
660 * Older function is suffixed with '_old'
661 * @param array $words words that should be stored in dictionary
662 * @param string $lang language
664 function sqspell_writeWords($words,$lang){
665 global $SQSPELL_CRYPTO,$username,$data_dir;
667 $sWords = implode(',',$words);
668 if ($SQSPELL_CRYPTO){
670 * User wants to encrypt the file. So be it.
671 * Get the user's password to use as a key.
673 sqgetGlobalVar('key', $key, SQ_COOKIE
);
674 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
676 $clear_key=OneTimePadDecrypt($key, $onetimepad);
678 * Try encrypting it. If fails, scream bloody hell.
680 $save_words = sqspell_crypto("encrypt", $clear_key, $sWords);
681 if ($save_words == 'PANIC'){
682 // FIXME: handle errors here
685 $save_words='{crypt}'.$save_words;
689 setPref($data_dir,$username,'sqspell_dict_'.$lang,$save_words);
693 * Writes user dictionary into the $username.words file, then changes mask
694 * to 0600. If encryption is needed -- does that, too.
696 * @param $words The contents of the ".words" file to write.
698 * @since 1.5.1 (sqspell 0.5)
701 function sqspell_writeWords_old($words){
702 global $SQSPELL_WORDS_FILE, $SQSPELL_CRYPTO;
704 * if $words is empty, create a template entry by calling the
705 * sqspell_makeDummy() function.
708 $words=sqspell_makeDummy();
710 if ($SQSPELL_CRYPTO){
712 * User wants to encrypt the file. So be it.
713 * Get the user's password to use as a key.
715 sqgetGlobalVar('key', $key, SQ_COOKIE
);
716 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
718 $clear_key=OneTimePadDecrypt($key, $onetimepad);
720 * Try encrypting it. If fails, scream bloody hell.
722 $save_words = sqspell_crypto("encrypt", $clear_key, $words);
723 if ($save_words == 'PANIC'){
725 * AAAAAAAAH! I'm not handling this yet, since obviously
726 * the admin of the site forgot to compile the MCRYPT support in
727 * when upgrading an existing PHP installation.
728 * I will add a handler for this case later, when I can come up
729 * with some work-around... Right now, do nothing. Let the Admin's
732 /** save some hairs on admin's head and store error message in logs */
733 error_log('SquirrelSpell: php does not have mcrypt support');
736 $save_words = $words;
739 * Do the actual writing.
741 $fp=fopen($SQSPELL_WORDS_FILE, "w");
742 fwrite($fp, $save_words);
744 chmod($SQSPELL_WORDS_FILE, 0600);
748 * Deletes user's dictionary
749 * Function was modified in 1.5.1 (sqspell 0.5). Older function is suffixed
751 * @param string $lang dictionary
753 function sqspell_deleteWords($lang) {
754 global $data_dir, $username;
755 removePref($data_dir,$username,'sqspell_dict_'.$lang);
759 * Deletes user's dictionary when it is corrupted.
760 * @since 1.5.1 (sqspell 0.5)
763 function sqspell_deleteWords_old(){
765 * So I open the door to my enemies,
766 * and I ask can we wipe the slate clean,
767 * but they tell me to please go...
768 * uhm... Well, this just erases the user dictionary file.
770 global $SQSPELL_WORDS_FILE;
771 if (file_exists($SQSPELL_WORDS_FILE)){
772 unlink($SQSPELL_WORDS_FILE);
776 * Creates an empty user dictionary for the sake of saving prefs or
779 * @return The template to use when storing the user dictionary.
782 function sqspell_makeDummy(){
783 global $SQSPELL_VERSION, $SQSPELL_APP_DEFAULT;
784 $words = "# SquirrelSpell User Dictionary $SQSPELL_VERSION\n"
785 . "# Last Revision: " . date('Y-m-d')
786 . "\n# LANG: $SQSPELL_APP_DEFAULT\n# End\n";
791 * This function checks for security attacks. A $MOD variable is
792 * provided in the QUERY_STRING and includes one of the files from the
793 * modules directory ($MOD.mod). See if someone is trying to get out
794 * of the modules directory by providing dots, unicode strings, or
797 * @param string $rMOD the name of the module requested to include.
798 * @return void, since it bails out with an access error if needed.
800 function sqspell_ckMOD($rMOD){
801 if (strstr($rMOD, '.')
802 ||
strstr($rMOD, '/')
803 ||
strstr($rMOD, '%')
804 ||
strstr($rMOD, "\\")){
805 echo _("Invalid URL");
811 * Used to check internal version of SquirrelSpell dictionary
812 * @param integer $major main version number
813 * @param integer $minor second version number
814 * @return boolean true if stored dictionary version is $major.$minor or newer
815 * @since 1.5.1 (sqspell 0.5)
817 function sqspell_check_version($major,$minor) {
818 global $data_dir, $username;
819 // 0.4 version is internal version number that is used to indicate upgrade from
820 // separate files to generic SquirrelMail prefs storage.
821 $sqspell_version=getPref($data_dir,$username,'sqspell_version','0.4');
823 $aVersion=explode('.',$sqspell_version);
825 if ($aVersion[0] < $major ||
826 ( $aVersion[0] == $major && $aVersion[1] < $minor)) {
833 * Displays form that allows to enter different password for dictionary decryption.
834 * If language is not set, function provides form to handle older dictionary files.
835 * @param string $lang language
836 * @since 1.5.1 (sqspell 0.5)
838 function sqspell_handle_crypt_panic($lang=false) {
839 if (! sqgetGlobalVar('SCRIPT_NAME',$SCRIPT_NAME,SQ_SERVER
))
843 * AAAAAAAAAAAH!!!!! OK, ok, breathe!
844 * Let's hope the decryption failed because the user changed his
845 * password. Bring up the option to key in the old password
846 * or wipe the file and start over if everything else fails.
848 * The _("SquirrelSpell...) line has to be on one line, otherwise
849 * gettext will bork. ;(
851 $msg = html_tag( 'p', "\n" .
852 '<strong>' . _("ATTENTION:") . '</strong><br />'
853 . _("SquirrelSpell was unable to decrypt your personal dictionary. This is most likely due to the fact that you have changed your mailbox password. In order to proceed, you will have to supply your old password so that SquirrelSpell can decrypt your personal dictionary. It will be re-encrypted with your new password after this. If you haven't encrypted your dictionary, then it got mangled and is no longer valid. You will have to delete it and start anew. This is also true if you don't remember your old password -- without it, the encrypted data is no longer accessible.") ,
855 . (($lang) ?
html_tag('p',sprintf(_("Your %s dictionary is encrypted with password that differs from your current password."),
856 sm_encode_html_special_chars($lang)),'left') : '')
857 . '<blockquote>' . "\n"
858 . '<form method="post" onsubmit="return AYS()">' . "\n"
859 . '<input type="hidden" name="MOD" value="crypto_badkey" />' . "\n"
861 '<input type="hidden" name="dict_lang" value="'.sm_encode_html_special_chars($lang).'" />' :
862 '<input type="hidden" name="old_setup" value="yes" />')
863 . html_tag( 'p', "\n" .
864 '<input type="checkbox" name="delete_words" value="ON" id="delete_words" />'
865 . '<label for="delete_words">'
866 . _("Delete my dictionary and start a new one")
867 . '</label><br /><label for="old_key">'
868 . _("Decrypt my dictionary with my old password:")
869 . '</label><input type="text" name="old_key" id="old_key" size="10" />' ,
871 . '</blockquote>' . "\n"
872 . html_tag( 'p', "\n"
873 . '<input type="submit" value="'
874 . _("Proceed") . ' >>" />' ,
878 * Add some string vars so they can be i18n'd.
880 $msg .= "<script type=\"text/javascript\"><!--\n"
881 . "var ui_choice = \"" . _("You must make a choice") ."\";\n"
882 . "var ui_candel = \"" . _("You can either delete your dictionary or type in the old password. Not both.") . "\";\n"
883 . "var ui_willdel = \"" . _("This will delete your personal dictionary file. Proceed?") . "\";\n"
884 . "//--></script>\n";
886 * See if this happened in the pop-up window or when accessing
887 * the SpellChecker options page.
888 * This is a dirty solution, I agree.
889 * TODO: make this prettier.
891 if (strstr($SCRIPT_NAME, "sqspell_options")){
892 sqspell_makePage(_("Error Decrypting Dictionary"),
893 "decrypt_error.js", $msg);
895 sqspell_makeWindow(null, _("Error Decrypting Dictionary"),
896 "decrypt_error.js", $msg);
902 * SquirrelSpell version. Don't modify, since it identifies the format
903 * of the user dictionary files and messing with this can do ugly
905 * @global string $SQSPELL_VERSION
908 $SQSPELL_VERSION="v0.3.8";