If we have PHP 4.3.0, we can make SquirrelSpell work with safe_mode.
[squirrelmail.git] / plugins / squirrelspell / modules / forget_me_not.mod
CommitLineData
849bdf42 1<?php
d112ed5a 2/**
3 * forget_me_not.mod
4 * ------------------
5 * Squirrelspell module
6 *
76911253 7 * Copyright (c) 1999-2003 The SquirrelMail development team
d112ed5a 8 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 *
10 * This module saves the added words into the user dictionary. Called
11 * after CHECK_ME module.
12 *
13 * $Id$
14 *
15 * @author Konstantin Riabitsev <icon@duke.edu> ($Author$)
16 */
849bdf42 17
d8aa9efe 18global $SQSPELL_VERSION, $SQSPELL_APP_DEFFAULT;
19
20$words = $_POST['words'];
21$sqspell_use_app = $_POST['sqspell_use_app'];
22
d112ed5a 23/**
24 * Because of the nature of Javascript, there is no way to efficiently
25 * pass an array. Hence, the words will arrive as a string separated by
26 * "%". To get the array, we explode the "%"'s.
27 * Dirty: yes. Is there a better solution? Let me know. ;)
28 */
29$new_words = ereg_replace("%", "\n", $words);
30/**
31 * Load the user dictionary and see if there is anything in it.
32 */
33$words=sqspell_getWords();
34if (!$words){
35 /**
36 * First time.
37 */
38 $words_dic="# SquirrelSpell User Dictionary $SQSPELL_VERSION\n# Last "
39 . "Revision: " . date("Y-m-d")
40 . "\n# LANG: $SQSPELL_APP_DEFAULT\n# $SQSPELL_APP_DEFAULT\n";
41 $words_dic .= $new_words . "# End\n";
42} else {
43 /**
44 * Do some fancy stuff in order to save the dictionary and not mangle the
45 * rest.
46 */
47 $langs=sqspell_getSettings($words);
48 $words_dic = "# SquirrelSpell User Dictionary $SQSPELL_VERSION\n# "
49 . "Last Revision: " . date("Y-m-d") . "\n# LANG: " . join(", ", $langs)
50 . "\n";
51 for ($i=0; $i<sizeof($langs); $i++){
52 $lang_words=sqspell_getLang($words, $langs[$i]);
53 if ($langs[$i]==$sqspell_use_app){
54 if (!$lang_words) {
55 $lang_words="# $langs[$i]\n";
56 }
57 $lang_words .= $new_words;
2b5a7157 58 }
d112ed5a 59 $words_dic .= $lang_words;
60 }
61 $words_dic .= "# End\n";
62}
2b5a7157 63
d112ed5a 64/**
65 * Write out the file
66 */
67sqspell_writeWords($words_dic);
68/**
69 * display the splash screen, then close it automatically after 2 sec.
70 */
71$onload = "setTimeout('self.close()', 2000)";
72$msg = '<form onsubmit="return false"><div align="center">'
73 . '<input type="submit" value=" '
74 . _("Close") . ' " onclick="self.close()"></div></form>';
75sqspell_makeWindow($onload, _("Personal Dictionary Updated"), null, $msg);
76
77/**
78 * For Emacs weenies:
79 * Local variables:
80 * mode: php
81 * End:
2b6b400e 82 * vim: syntax=php
d112ed5a 83 */
84
15e6162e 85?>