From d112ed5aeee62953707e7042a1edc8e8c2b6a968 Mon Sep 17 00:00:00 2001 From: graf25 Date: Thu, 31 Jan 2002 03:00:55 +0000 Subject: [PATCH] Some changes. En-route. Most likely broken. ;) git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2299 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- plugins/squirrelspell/index.php | 2 +- plugins/squirrelspell/js/check_me.js | 211 +++-- plugins/squirrelspell/modules/check_me.mod | 635 ++++++++------ plugins/squirrelspell/modules/crypto.mod | 111 ++- .../squirrelspell/modules/crypto_badkey.mod | 146 ++-- plugins/squirrelspell/modules/edit_dic.mod | 171 ++-- plugins/squirrelspell/modules/enc_setup.mod | 110 ++- plugins/squirrelspell/modules/forget_me.mod | 136 +-- .../squirrelspell/modules/forget_me_not.mod | 123 +-- plugins/squirrelspell/modules/init.mod | 106 ++- plugins/squirrelspell/modules/lang_change.mod | 160 ++-- plugins/squirrelspell/modules/lang_setup.mod | 93 ++- .../squirrelspell/modules/options_main.mod | 95 ++- plugins/squirrelspell/setup.php | 131 +-- plugins/squirrelspell/sqspell_config.php | 46 +- plugins/squirrelspell/sqspell_functions.php | 786 +++++++++++------- plugins/squirrelspell/sqspell_interface.php | 88 +- plugins/squirrelspell/sqspell_options.php | 87 +- 18 files changed, 1974 insertions(+), 1263 deletions(-) diff --git a/plugins/squirrelspell/index.php b/plugins/squirrelspell/index.php index 186c259b..3afdbfab 100644 --- a/plugins/squirrelspell/index.php +++ b/plugins/squirrelspell/index.php @@ -13,7 +13,7 @@ * $Id$ */ -header("Location:../../index.php"); +header("Location: ../../index.php"); /* pretty impressive huh? */ diff --git a/plugins/squirrelspell/js/check_me.js b/plugins/squirrelspell/js/check_me.js index 852ca0e4..1abc4e0d 100644 --- a/plugins/squirrelspell/js/check_me.js +++ b/plugins/squirrelspell/js/check_me.js @@ -1,10 +1,15 @@ /** - CHECK_ME.JS - ------------ - This JavaScript app is the driving power of the SquirrelSpell's - main spellchecker window. Hope you have as much pain figuring - it out as it took to write. ;)) - **/ + * check_me.js + * ------------ + * This JavaScript app is the driving power of the SquirrelSpell's + * main spellchecker window. Hope you have as much pain figuring + * it out as it took to write. ;)) + * + * $Id$ + * + * @author Konstantin Riabitsev ($Author$) + * @version $Date$ + */ var CurrentError=0; var CurrentLocation=0; @@ -13,8 +18,13 @@ var CurrentLine; var CurrentSymbol; var ChangesMade=false; +/** + * This function loads spellchecking errors into the form + * displayed to the user. + * + * @return void + */ function populateSqspellForm(){ - // this function loads error data into the form. CurrentWord=Word=misses[CurrentError]; WordLocations = locations[CurrentError].split(", "); CurrentLoc = WordLocations[CurrentLocation]; @@ -23,7 +33,7 @@ function populateSqspellForm(){ } else { CurrentLocation++; } - + tmp = CurrentLoc.split(":"); CurrentLine=parseInt(tmp[0]); CurrentSymbol=parseInt(tmp[1]); @@ -55,7 +65,7 @@ function populateSqspellForm(){ document.forms[0].sqspell_oruse.focus(); document.forms[0].sqspell_oruse.select(); } - + document.forms[0].sqspell_suggestion.selectedIndex=0; if (!document.forms[0].sqspell_oruse.value) document.forms[0].sqspell_oruse.value=document.forms[0].sqspell_suggestion.options[document.forms[0].sqspell_suggestion.selectedIndex].value; @@ -64,113 +74,178 @@ function populateSqspellForm(){ document.forms[0].sqspell_likethis.value=occursTimes; } + + +/** + * This function updates a line from the message with a new value, + * received from the user. + * + * @param lLine line number. + * @param lSymbol symbol at which the misspelled word starts. + * @param lWord misspelled word + * @param lNewWord corrected word + * @return void + */ function updateLine(lLine, lSymbol, lWord, lNewWord){ - // This function updates the line with new word value sqspell_lines[lLine] = sqspell_lines[lLine].substring(0, lSymbol) + lNewWord + sqspell_lines[lLine].substring(lSymbol+lWord.length, sqspell_lines[lLine].length); if (lWord.length != lNewWord.length) updateSymbol(lLine, lSymbol, lNewWord.length-lWord.length); if (!ChangesMade) ChangesMade=true; } - + +/** + * This function is used to add a word user wishes to place in his/her + * user dictionary to the form field for later submission. Since there + * is no sane way to pass arrays between javascript and PHP, all words + * are concatenated into one strings and separated with a "%". + * + * @return void + */ function sqspellRemember(){ - // This function adds the word to the field in the form to be later - // submitted and added to the user dictionary. CurrentWord = misses[CurrentError] + "%"; document.forms[0].words.value += CurrentWord; + /** + * Now ignore all occurances of this word. + */ sqspellIgnoreAll(); } - +/** + * This function is called when the "Change" button is pressed. + * + * @return void + */ function sqspellChange(){ - // Called when pressed the "Change" button CurrentWord = misses[CurrentError]; NewWord=document.forms[0].sqspell_oruse.value; updateLine(CurrentLine, CurrentSymbol, CurrentWord, NewWord); proceed(); } +/** + * This function is called when the "Change All" button is pressed. + * + * @return void + */ function sqspellChangeAll(){ // Called when pressed the "Change All" button allLoc = locations[CurrentError].split(", "); if (allLoc.length==1) { - // There's no need to "change all", only one occurance. + /** + * There's no need to "change all", only one occurance of this + * word in the whole text. + */ sqspellChange(); return; } - + /** + * Dark magic. + */ NewWord=document.forms[0].sqspell_oruse.value; CurrentWord = misses[CurrentError]; for (z=CurrentLocation-1; z= 0){ @@ -190,32 +265,36 @@ function updateSymbol(lLine, lSymbol, difference){ } } +/** + * This function writes the changes back into the compose form. + * + * @return void + */ function sqspellCommitChanges(){ - // Write the changes back into the compose form - if (navigator.appName.indexOf("Microsoft")==0){ - // MSIE doesn't have array.shift() - newSubject = sqspell_lines[0]; - newBody = ""; - for (i=1; i$ln". - ''; +/** + * check_me.mod + * ------------- + * Squirrelspell module. + * + * Copyright (c) 1999-2002 The SquirrelMail development team + * Licensed under the GNU GPL. For full terms see the file COPYING. + * + * This module is the main workhorse of SquirrelSpell. It submits + * the message to the spell-checker, parses the output, and loads + * the interface window. + * + * $Id$ + * + * @author Konstantin Riabitsev ($Author$) + * @version $Date$ + */ +/** + * This function makes a javascript-powered link. Not sure why + * Philippe decided to move it outside the main code, but hey. ;) + * I bet for the i18n reasons. + * + * @param $jscode Javascript code to include in the link. + * @param $title A little pop-up title to provide for the links. + * @param $link The content of the link. + * @return void, since this just draws the content. + */ +function SpellLink($jscode, $title, $link) { + echo "$ln" + . ''; } -// Declaring globals for E_ALL. +/** + * Declaring globals for users with E_ALL set. + */ global $sqspell_text, $SQSPELL_APP, $sqspell_use_app, $attachment_dir, - $username, $SQSPELL_EREG, $color; + $username, $SQSPELL_EREG, $color; - // Now we explode the lines for three reasons: - // 1) So we can ignore lines starting with ">" (reply's) - // 2) So we can stop processing when we get to "--" on a single line, - // which means that the signature is starting - // 3) So we can add an extra space at the beginning of each line. This way - // ispell/aspell don't treat these as command characters. - $sqspell_raw_lines = explode("\n", $sqspell_text); - for ($i=0; $i" (reply's) + * 2) So we can stop processing when we get to "--" on a single line, + * which means that the signature is starting + * 3) So we can add an extra space at the beginning of each line. This way + * ispell/aspell don't treat these as command characters. + */ +$sqspell_raw_lines = explode("\n", $sqspell_text); +for ($i=0; $i\n". - "\n". - '' . _("SquirrelSpell Results") . ''; - if ($theme_css != '') { - echo "\n"; - } - // Load the spelling errors into JavaScript arrays - echo "\n". - "\n". - "\n"; + /** + * Add some strings so they can be i18n'd. + */ + echo "var ui_completed = \"" . _("Spellcheck completed. Commit changes?") + . "\";\n"; + echo "var ui_nochange = \"" . _("No changes were made.") . "\";\n"; + echo "var ui_wait = \"" + . _("Now saving your personal dictionary... Please wait.") + . "\";\n"; + - echo "\n". - ''. - " - -
"; - printf( _("Found %s errors"), $errors ); -?>

-
- - - - - - - - - - - - - - - - - - - - - - - + + +
-"; - echo $sptag . _("Line with an error:") . ''; -?> -
- -
-'; -?> - - - -'; -?> - - -
-'; -?> - - - -'; -?> - - -

- -"; - - SpellLink( 'sqspellChange()', - _("Change this word"), - _("Change") ); - SpellLink( 'sqspellChangeAll()', - _("Change ALL occurances of this word"), - _("Change All") ); - SpellLink( 'sqspellIgnore()', - _("Ignore this word"), - _("Ignore") ); - SpellLink( 'sqspellIgnoreAll()', - _("Ignore ALL occurances this word"), - _("Ignore All") ); - SpellLink( 'sqspellRemember()', - _("Add this word to your personal dictionary"), - _("Add to Dic") ); -?> + /** + * Did I mention that I hate dots on the end of contcatenated lines? + * Dots at the beginning make so much more sense! + */ + echo "//-->\n" + . "\n" + . "\n" + . "\n"; + + echo "\n"; + ?> +
+ + + + + + + + - - - -" . - ''. - ' '; -?> - - -
+ + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ "; + echo $sptag . _("Line with an error:") . ''; + ?> +
+ +
+ '; + ?> + + + + '; + ?> + + +
+ '; + ?> + + + + '; + ?> + + +

+ + + + +
+

+ ' + . ' '; + ?> +
-

- -
- - +
"; - sqspell_makeWindow(null, _("No errors found"), null, $msg); - } +} else { + /** + * AREN'T YOU SUCH A KNOW-IT-ALL! + */ + $msg="
" + . "
"; + sqspell_makeWindow(null, _("No errors found"), null, $msg); +} + +/** + * For Emacs weenies: + * Local variables: + * mode: php + * End: + */ ?> diff --git a/plugins/squirrelspell/modules/crypto.mod b/plugins/squirrelspell/modules/crypto.mod index 4efc9002..6dd1da97 100644 --- a/plugins/squirrelspell/modules/crypto.mod +++ b/plugins/squirrelspell/modules/crypto.mod @@ -1,45 +1,74 @@ ($Author$) + * @version $Date$ + */ - /** - ** crypto.mod.php -- Squirrelspell module - ** - ** Copyright (c) 1999-2002 The SquirrelMail development team - ** Licensed under the GNU GPL. For full terms see the file COPYING. - ** - ** This module handles the encryption/decryption of the user dictionary - ** if the user so chooses from the options page. - ** - ** $Id$ - **/ +/** + * Declaring globals for E_ALL + */ +global $action, $SQSPELL_CRYPTO; +switch ($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); + $msg='

' + . _("Your personal dictionary has been encrypted and is now stored in an encrypted format.") + . '

'; + 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); + $msg='

' + . _("Your personal dictionary has been decrypted and is now stored as clear text.") + . '

'; + break; + + case "": + /** + * Wait, this shouldn't happen! :) + */ + $msg = "

No action requested.

"; + break; +} +sqspell_makePage( _("Personal Dictionary Crypto Settings"), null, $msg); + +/** + * For Emacs weenies: + * Local variables: + * mode: php + * End: + */ - // Declaring globals for E_ALL - global $action, $SQSPELL_CRYPTO; - switch ($action){ - case 'encrypt': - // Let's encrypt the file. - $words=sqspell_getWords(); - // flip the flag. - $SQSPELL_CRYPTO=true; - sqspell_writeWords($words); - $msg='

' . - _("Your personal dictionary has been encrypted and is now stored in an encrypted format."). - '

'; - break; - - case 'decrypt': - // Decrypt the file and save plain text. - $words=sqspell_getWords(); - // flip the flag. - $SQSPELL_CRYPTO=false; - sqspell_writeWords($words); - $msg='

' . - _("Your personal dictionary has been decrypted and is now stored as clear text.") . '

'; - break; - - case "": - // Wait, this shouldn't happen! :) - $msg = "

No action requested.

"; - break; - } - sqspell_makePage( _("Personal Dictionary Crypto Settings"), null, $msg); ?> diff --git a/plugins/squirrelspell/modules/crypto_badkey.mod b/plugins/squirrelspell/modules/crypto_badkey.mod index 47dae869..6a192696 100644 --- a/plugins/squirrelspell/modules/crypto_badkey.mod +++ b/plugins/squirrelspell/modules/crypto_badkey.mod @@ -1,64 +1,90 @@ ($Author$) + * @version $Date$ + */ - /** - ** CRYPTO_BADKEY.MOD.PHP -- Squirrelspell module - ** - ** Copyright (c) 1999-2002 The SquirrelMail development team - ** Licensed under the GNU GPL. For full terms see the file COPYING. - ** - ** This module tries to decrypt the user dictionary with a newly provided - ** old password, or erases the file if everything else fails. :( - ** - ** $Id$ - **/ - - // Just for fidian! :) - global $delete_words, $SCRIPT_NAME, $old_key; - if ($delete_words=='ON'){ - // All attemts to decrypt the file were futile. Erase the bastard and - // hope this never happens again. - sqspell_deleteWords(); - // See where we were called from -- pop-up window or options page - // and call whichever wrapper is appropriate. - if (strstr($SCRIPT_NAME, 'sqspell_options')){ - $msg='

' . _("Your personal dictionary was erased.") . '

'; - sqspell_makePage(_("Dictionary Erased"), null, $msg); - } else { - $msg = '

' . ("Your personal dictionary was erased. Please close this window and click \"Check Spelling\" button again to start your spellcheck over." ) . - '

'. - '

'. - ''. - '

'; - sqspell_makeWindow(null, _("Dictionary Erased"), null, $msg); - } - exit; - } - - if ($old_key){ - // User provided another key to try and decrypt the dictionary. - // call sqspell_getWords. If this key fails, the function will - // handle it. - $words=sqspell_getWords(); - // It worked! Pinky, you're a genius! - // Write it back this time encrypted with a new key. - sqspell_writeWords($words); - // See where we are and call a necessary GUI-wrapper. - if (strstr($SCRIPT_NAME, 'sqspell_options')){ - $msg = '

' . - _("Your personal dictionary was re-encrypted successfully. Now " - "return to the "SpellChecker options" menu and make your selection " - "again." ) . '

'; - sqspell_makePage(_("Successful Re-encryption"), null, $msg); - } else { - $msg = '

'. - _("Your personal dictionary was re-encrypted successfully. Please " - "close this window and click \"Check Spelling\" button again to start your " - "spellcheck over.") . '

' . - '

'; - sqspell_makeWindow(null, _("Dictionary re-encrypted"), null, $msg); - } - exit; - } +global $delete_words, $SCRIPT_NAME, $old_key; +if ($delete_words=='ON'){ + /** + * $delete_words is passed via the query_string. If it's set, then + * the user asked to delete the file. Erase the bastard and hope + * this never happens again. + */ + sqspell_deleteWords(); + /** + * See where we were called from -- pop-up window or options page + * and call whichever wrapper is appropriate. + * I agree, this is dirty. TODO: make it so it's not dirty. + */ + if (strstr($SCRIPT_NAME, 'sqspell_options')){ + $msg='

' . _("Your personal dictionary was erased.") . '

'; + sqspell_makePage(_("Dictionary Erased"), null, $msg); + } else { + /** + * The _("Your....") has to be on one line. Otherwise xgettext borks + * on getting the strings. + */ + $msg = '

' + . _("Your personal dictionary was erased. Please close this window and click \"Check Spelling\" button again to start your spellcheck over.") + . '

' + . '

' + . '' + . '

'; + sqspell_makeWindow(null, _("Dictionary Erased"), null, $msg); + } + exit; +} +if ($old_key){ + /** + * User provided another key to try and decrypt the dictionary. + * Call sqspell_getWords. If this key fails, the function will + * handle it. + */ + $words=sqspell_getWords(); + /** + * It worked! Pinky, you're a genius! + * Write it back this time encrypted with a new key. + */ + sqspell_writeWords($words); + /** + * See where we are and call a necessary GUI-wrapper. + * Also dirty. TODO: Make this not dirty. + */ + if (strstr($SCRIPT_NAME, 'sqspell_options')){ + $msg = '

' + . _("Your personal dictionary was re-encrypted successfully. Now return to the "SpellChecker options" menu and make your selection again." ) + . '

'; + sqspell_makePage(_("Successful Re-encryption"), null, $msg); + } else { + $msg = '

' + . _("Your personal dictionary was re-encrypted successfully. Please close this window and click \"Check Spelling\" button again to start your spellcheck over.") + . '

'; + sqspell_makeWindow(null, _("Dictionary re-encrypted"), null, $msg); + } + exit; +} + +/** + * For Emacs weenies: + * Local variables: + * mode: php + * End: + */ ?> diff --git a/plugins/squirrelspell/modules/edit_dic.mod b/plugins/squirrelspell/modules/edit_dic.mod index 1d536336..ed897360 100644 --- a/plugins/squirrelspell/modules/edit_dic.mod +++ b/plugins/squirrelspell/modules/edit_dic.mod @@ -1,68 +1,113 @@ ($Author$) + * @version $Date + */ - /** - ** EDIT_DIC.MOD.PHP -- Squirrelspell module - ** - ** Copyright (c) 1999-2002 The SquirrelMail development team - ** Licensed under the GNU GPL. For full terms see the file COPYING. - ** - ** This module handles the encryption/decryption of the user dictionary - ** if the user so chooses from the options page. - ** - ** $Id$ - **/ - - // fidian, you owe me a pack of Guinness! :) - global $color; - $words=sqspell_getWords(); - if (!$words){ - // Agt. Smith: "You're empty." - // Neo: "So are you." - sqspell_makePage(_("Personal Dictionary"), null, '

' . _("No words in your personal dictionary.") . '

'); - } else { - // We're loaded with booty. - $pre_msg = '

' . _("Please check any words you wish to delete from your dictionary.") . "

\n"; - $pre_msg .= "\n"; - $langs=sqspell_getSettings($words); - for ($i=0; $i'. - '' . - "\n"; - } - } - // Check if all dictionaries were empty. - if (!$msg) { - $msg = '

' . _("No words in your personal dictionary.") . '

'; - } else { - $msg .= '
" . - sprintf( _("%s dictionary"), $langs[$i] ) . '
'. - '
'. - ''. - ''. - ''. - ''. - "
\n"; - $words_ary=explode("\n", $lang_words); - array_pop($words_ary); - array_shift($words_ary); - // Do some fancy stuff to separate the words into three columns. - for ($j=0; $j\n"; - $msg .= " $words_ary[$j]
"; - } - $msg .= '
". - ''. - '

'. - "
'; - } - sqspell_makePage(_("Edit your Personal Dictionary"), null, $msg); +global $color; +/** + * Get the user dictionary and see if it's empty or not. + */ +$words=sqspell_getWords(); +if (!$words){ + /** + * Agt. Smith: "You're empty." + * Neo: "So are you." + */ + sqspell_makePage(_("Personal Dictionary"), null, + '

' . _("No words in your personal dictionary.") + . '

'); +} else { + /** + * We're loaded with booty. + */ + $pre_msg = '

' + . _("Please check any words you wish to delete from your dictionary.") + . "

\n"; + $pre_msg .= "\n"; + /** + * Get how many dictionaries this user has defined. + */ + $langs=sqspell_getSettings($words); + for ($i=0; $i' + . '' + . "\n"; } + } + /** + * Check if all dictionaries were empty. + */ + if (!$msg) { + $msg = '

' . _("No words in your personal dictionary.") . '

'; + } else { + $msg .= '
" + . sprintf( _("%s dictionary"), $langs[$i] ) . '
' + . '
' + . '' + . '' + . '' + . '' + . "
\n"; + $words_ary=explode("\n", $lang_words); + /** + * There are two lines we need to remove: + * 1st: # Language + * last: # End + */ + array_pop($words_ary); + array_shift($words_ary); + /** + * Do some fancy stuff to separate the words into three + * columns. + */ + for ($j=0; $j\n"; + } + $msg .= " $words_ary[$j]
"; + } + $msg .= '
". + . '' + . '

' + . "
'; + } + sqspell_makePage(_("Edit your Personal Dictionary"), null, $msg); +} + +/** + * For Emacs weenies: + * Local variables: + * mode: php + * End: + */ ?> diff --git a/plugins/squirrelspell/modules/enc_setup.mod b/plugins/squirrelspell/modules/enc_setup.mod index 4e94548f..53113038 100644 --- a/plugins/squirrelspell/modules/enc_setup.mod +++ b/plugins/squirrelspell/modules/enc_setup.mod @@ -1,47 +1,73 @@ ($Author$) + * @version $Date$ + */ - /** - ** ENC_SETUP.MOD.PHP -- Squirrelspell module - ** - ** Copyright (c) 1999-2002 The SquirrelMail development team - ** Licensed under the GNU GPL. For full terms see the file COPYING. - ** - ** This module shows the user a nice invitation to encrypt or decypt - ** his/her personal dictionary and explains the caveats of such a decision. - ** - ** $Id$ - **/ +global $SQSPELL_CRYPTO; - // Something for our friends with E_ALL for error_reporting: - global $SQSPELL_CRYPTO; +$words=sqspell_getWords(); +/** + * When getting the user dictionary, the SQSPELL_CRYPTO flag will be + * set to "true" if the dictionary is encrypted, or "false" if it is + * in plain text. + */ +if ($SQSPELL_CRYPTO){ + /** + * Current format is encrypted. + * Unfortunately, the following text needs to be all on one line, + * unless someone fixes xgettext. ;( + */ + $msg = + _("

Your personal dictionary is currently encrypted. This helps protect your privacy in case the web-mail system gets compromized and your personal dictionary ends up stolen. It is currently encrypted with the password you use to access your mailbox, making it hard for anyone to see what is stored in your personal dictionary.

ATTENTION: If you forget your password, your personal dictionary will become unaccessible, since it can no longer be decrypted. If you change your mailbox password, SquirrelSpell will recognize it and prompt you for your old password in order to re-encrypt the dictionary with a new key.

") + . '
' + . '' + . '

' + . _("Please decrypt my personal dictionary and store it in a clear-text format." ) + . '

' + . '

' + . '
'; +} else { + /** + * Current format is clear text. + * Unfortunately, the following text needs to be all on one line, + * unless someone fixes xgettext. ;( + */ + $msg = + _("

Your personal dictionary is currently not encrypted. You may wish to encrypt your personal dictionary to protect your privacy in case the webmail system gets compromized and your personal dictionary file gets stolen. When encrypted, the file's contents look garbled and are hard to decrypt without knowing the correct key (which is your mailbox password).

ATTENTION: If you decide to encrypt your personal dictionary, you must remember that it gets "hashed" with your mailbox password. If you forget your mailbox password and the administrator changes it to a new value, your personal dictionary will become useless and will have to be created anew. However, if you or your system administrator change your mailbox password but you still have the old password at hand, you will be able to enter the old key to re-encrypt the dictionary with the new value.

") + . '
' + . '' + . '

' + . _("Please encrypt my personal dictionary and store it in an encrypted format.") + . '

' + . '

' + . '
'; +} +sqspell_makePage(_("Personal Dictionary Crypto Settings"), + "crypto_settings.js", $msg); + +/** + * For Emacs weenies: + * Local variables: + * mode: php + * End: + */ - $words=sqspell_getWords(); - if ($SQSPELL_CRYPTO){ - // Current format is encrypted. - $msg = - _("

Your personal dictionary is currently encrypted. This helps protect your privacy in case the web-mail system gets compromized and your personal dictionary ends up stolen. It is currently encrypted with the password you use to access your mailbox, making it hard for anyone to see what is stored in your personal dictionary.

ATTENTION: If you forget your password, your personal dictionary will become unaccessible, since it can no longer be decrypted. If you change your mailbox password, SquirrelSpell will recognize it and prompt you for your old password in order to re-encrypt the dictionary with a new key.

") . - '
'. - ''. - '

'. - _("Please decrypt my personal dictionary and store it in a clear-text format." ) . - '

'. - '

'. - '
'; - } else { - // current format is clear text. - $msg = - _("

Your personal dictionary is currently not encrypted. You may wish to encrypt your personal dictionary to protect your privacy in case the webmail system gets compromized and your personal dictionary file gets stolen. When encrypted, the file's contents look garbled and are hard to decrypt without knowing the correct key (which is your mailbox password).

ATTENTION: If you decide to encrypt your personal dictionary, you must remember that it gets "hashed" with your mailbox password. If you forget your mailbox password and the administrator changes it to a new value, your personal dictionary will become useless and will have to be created anew. However, if you or your system administrator change your mailbox password but you still have the old password at hand, you will be able to enter the old key to re-encrypt the dictionary with the new value.

"). - '
'. - ''. - '

'. - _("Please encrypt my personal dictionary and store it in an encrypted format.") . - '

'. - '

'. - '
'; - } - sqspell_makePage(_("Personal Dictionary Crypto Settings"), "crypto_settings.js", $msg); - ?> diff --git a/plugins/squirrelspell/modules/forget_me.mod b/plugins/squirrelspell/modules/forget_me.mod index 067891ef..cdfa6abe 100644 --- a/plugins/squirrelspell/modules/forget_me.mod +++ b/plugins/squirrelspell/modules/forget_me.mod @@ -1,59 +1,87 @@ ($Author$) + * @version $Date$ + */ - /** - ** FORGET_ME.MOD.PHP -- Squirrelspell module - ** - ** Copyright (c) 1999-2002 The SquirrelMail development team - ** Licensed under the GNU GPL. For full terms see the file COPYING. - ** - ** This module deletes the words from the user dictionary. Called - ** after EDIT_DIC module. - ** - ** $Id$ - **/ - - // Make it two packs of Guinness and a bag of pistachios, fidian. :) - global $words_ary, $sqspell_use_app, $SQSPELL_VERSION; - if (sizeof($words_ary)){ - // something needs to be deleted. - $words=sqspell_getWords(); - $lang_words = sqspell_getLang($words, $sqspell_use_app); - $msg = '

'. - sprintf( _("Deleting the following entries from %s dictionary:", $sqspell_use_app ) . - '

' . - "
    \n"; - for ($i=0; $i' _("All done!") . "

    \n"; - sqspell_makePage(_("Personal Dictionary Updated"), null, $msg); +global $words_ary, $sqspell_use_app, $SQSPELL_VERSION; +/** + * If something needs to be deleted, then $words_ary will be + * non-zero length. + */ +if (sizeof($words_ary)){ + $words=sqspell_getWords(); + $lang_words = sqspell_getLang($words, $sqspell_use_app); + $msg = '

    ' + . sprintf(_("Deleting the following entries from %s dictionary:", $sqspell_use_app)) . + . '

    ' + . "
      \n"; + for ($i=0; $i' . _("No changes requested.") . '

      '); + $lang_words = sqspell_getLang($words, $langs[$i]); + } + if ($lang_words) { + $words_dic .= $lang_words; } - + } + $words_dic .= "# End\n"; + sqspell_writeWords($words_dic); + $msg .= '

    ' _("All done!") . "

    \n"; + sqspell_makePage(_("Personal Dictionary Updated"), null, $msg); +} else { + /** + * Click on some words first, Einstein! + */ + sqspell_makePage(_("Personal Dictionary"), null, + '

    ' . _("No changes requested.") . '

    '); +} + +/** + * For Emacs weenies: + * Local variables: + * mode: php + * End: + */ ?> diff --git a/plugins/squirrelspell/modules/forget_me_not.mod b/plugins/squirrelspell/modules/forget_me_not.mod index 4b14d58e..eda679ab 100644 --- a/plugins/squirrelspell/modules/forget_me_not.mod +++ b/plugins/squirrelspell/modules/forget_me_not.mod @@ -1,53 +1,80 @@ ($Author$) + */ - /** - ** FORGET_ME_NOT.MOD.PHP -- Squirrelspell module - ** - ** Copyright (c) 1999-2002 The SquirrelMail development team - ** Licensed under the GNU GPL. For full terms see the file COPYING. - ** - ** This module saves the added words into the user dictionary. Called - ** after CHECK_ME module. - ** - ** $Id$ - **/ - - // For our friends with E_ALL. - global $words, $SQSPELL_VERSION, $SQSPELL_APP_DEFFAULT, $sqspell_use_app; - - $new_words = ereg_replace("%", "\n", $words); - - // Load the user dictionary. - $words=sqspell_getWords(); - - if (!$words){ - // First time. - $words_dic="# SquirrelSpell User Dictionary $SQSPELL_VERSION\n# Last Revision: " . date("Y-m-d") . "\n# LANG: $SQSPELL_APP_DEFAULT\n# $SQSPELL_APP_DEFAULT\n"; - $words_dic .= $new_words . "# End\n"; - } else { - // Do some fancy stuff in order to save the dictionary and not mangle the - // rest. - $langs=sqspell_getSettings($words); - $words_dic = "# SquirrelSpell User Dictionary $SQSPELL_VERSION\n# Last Revision: " . date("Y-m-d") . "\n# LANG: " . join(", ", $langs) . "\n"; - for ($i=0; $i'; - sqspell_makeWindow($onload, _("Personal Dictionary Updated"), null, $msg); - +/** + * Write out the file + */ +sqspell_writeWords($words_dic); +/** + * display the splash screen, then close it automatically after 2 sec. + */ +$onload = "setTimeout('self.close()', 2000)"; +$msg = '
    ' + . '
    '; +sqspell_makeWindow($onload, _("Personal Dictionary Updated"), null, $msg); + +/** + * For Emacs weenies: + * Local variables: + * mode: php + * End: + */ + ?> diff --git a/plugins/squirrelspell/modules/init.mod b/plugins/squirrelspell/modules/init.mod index 67b934cf..c96022ff 100644 --- a/plugins/squirrelspell/modules/init.mod +++ b/plugins/squirrelspell/modules/init.mod @@ -1,50 +1,66 @@ ($Author$) + * @version $Date$ + */ - /** - ** INIT.MOD.PHP -- Squirrelspell module - ** - ** Copyright (c) 1999-2002 The SquirrelMail development team - ** Licensed under the GNU GPL. For full terms see the file COPYING. - ** - ** Initial loading of the popup window interface. - ** - ** $Id$ - **/ - - // See if we need to give user the option of choosing which dictionary - // he wants to use to spellcheck his message. - $langs=sqspell_getSettings(null); - $msg = '
    '. - ''. - ''. - '

    '; - if (sizeof($langs)==1){ - // only one dictionary defined by the users. Submit the form - // automatically. - $onload="sqspell_init(true)"; - $msg .= _("Please wait, communicating with the server...") . - '

    '. - ""; - } else { - // more than one dictionary. Let the user choose the dictionary first - // then manually submit the form. - $onload="sqspell_init(false)"; - $msg .= _("Please choose which dictionary you would like to use to spellcheck this message:"). - '

    ' . - ''. - ''. - '

    '; +/** + * See if we need to give user the option of choosing which dictionary + * s/he wants to use to spellcheck his message. + */ +$langs=sqspell_getSettings(null); +$msg = '' + . '' + . '' + . '

    '; +if (sizeof($langs)==1){ + /** + * Only one dictionary defined by the user. Submit the form + * automatically. + */ + $onload="sqspell_init(true)"; + $msg .= _("Please wait, communicating with the server...") + . '

    ' + . ""; +} else { + /** + * More than one dictionary. Let the user choose the dictionary first + * then manually submit the form. + */ + $onload="sqspell_init(false)"; + $msg .= _("Please choose which dictionary you would like to use to spellcheck this message:") + . '

    ' + . '' + . '' + . '

    '; +} +$msg .="
    \n"; +sqspell_makeWindow($onload, _("SquirrelSpell Initiating"), "init.js", $msg); + +/** + * For the Emacs weenies: + * Local variables: + * mode: php + * End: + */ ?> diff --git a/plugins/squirrelspell/modules/lang_change.mod b/plugins/squirrelspell/modules/lang_change.mod index 1a53d601..d0ea2b42 100644 --- a/plugins/squirrelspell/modules/lang_change.mod +++ b/plugins/squirrelspell/modules/lang_change.mod @@ -1,71 +1,99 @@ ($Author$) + * @version $Date$ + */ - /** - ** LANG_CHANGE.MOD.PHP -- Squirrelspell module - ** - ** Copyright (c) 1999-2002 The SquirrelMail development team - ** Licensed under the GNU GPL. For full terms see the file COPYING. - ** - ** This module changes the international dictionaries selection - ** for the user. Called after LANG_SETUP module. - ** - ** $Id$ - **/ - - // For poor wretched souls with E_ALL. - global $use_langs, $lang_default, $SQSPELL_APP_DEFAULT; - - $words = sqspell_getWords(); - if (!$words) { - $words = sqspell_makeDummy(); - } - $langs = sqspell_getSettings($words); - if (sizeof($use_langs)){ - // See if the user clicked any options on the previous page. - if (sizeof($use_langs)>1){ - // See if s/he wants more than one dictionary. - if ($use_langs[0]!=$lang_default){ - // See if we need to juggle the order of the dictionaries - // to make the default dictionary first in line. - if (in_array($lang_default, $use_langs)){ - // see if the user was dumb and chose a default dictionary - // to be something other than the ones he selected. - $hold = array_shift($use_langs); - $lang_string = join(", ", $use_langs); - $lang_string = str_replace("$lang_default", "$hold", $lang_string); - $lang_string = $lang_default . ", " . $lang_string; - } else { - // Yes, he is dumb. - $lang_string = join(', ', $use_langs); - } - } else { - // No need to juggle the order -- preferred is already first. - $lang_string = join(', ', $use_langs); - } - } else { - // Just one dictionary, please. - $lang_string = $use_langs[0]; - } - $lang_array = explode( ',', $lang_string ); - $dsp_string = ''; - foreach( $lang_array as $a) { - $dsp_string .= _(trim($a)) . ', '; - } - $dsp_string = substr( $dsp_string, 0, -2 ); - $msg = '

    '. - sprintf( _("Settings adjusted to: %s with %s as default dictionary."), $dsp_string, _($lang_default) ) . - '

    '; +global $use_langs, $lang_default, $SQSPELL_APP_DEFAULT; +$words = sqspell_getWords(); +if (!$words) { + $words = sqspell_makeDummy(); +} +$langs = sqspell_getSettings($words); +if (sizeof($use_langs)){ + /** + * See if the user clicked any options on the previous page. + */ + if (sizeof($use_langs)>1){ + /** + * See if s/he wants more than one dictionary. + */ + if ($use_langs[0]!=$lang_default){ + /** + * See if we need to juggle the order of the dictionaries + * to make the default dictionary first in line. + */ + if (in_array($lang_default, $use_langs)){ + /** + * See if the user was dumb and chose a default dictionary + * to be something other than the ones he selected. + */ + $hold = array_shift($use_langs); + $lang_string = join(", ", $use_langs); + $lang_string = str_replace("$lang_default", "$hold", $lang_string); + $lang_string = $lang_default . ", " . $lang_string; + } else { + /** + * Yes, he is dumb. + */ + $lang_string = join(', ', $use_langs); + } } else { - // No dictionaries selected. Use system default. - $msg = '

    '. - sprintf( _("Using %s dictionary (system default) for spellcheck." ), $SQSPELL_APP_DEFAULT ) . - '

    '; - $lang_string = $SQSPELL_APP_DEFAULT; + /** + * No need to juggle the order -- preferred is already first. + */ + $lang_string = join(', ', $use_langs); } - $old_lang_string = join(", ", $langs); - $words = str_replace("# LANG: $old_lang_string", "# LANG: $lang_string", $words); - // write it down where the sun don't shine. - sqspell_writeWords($words); - sqspell_makePage(_("International Dictionaries Preferences Updated"), null, $msg); - + } else { + /** + * Just one dictionary, please. + */ + $lang_string = $use_langs[0]; + } + $lang_array = explode( ',', $lang_string ); + $dsp_string = ''; + foreach( $lang_array as $a) { + $dsp_string .= _(trim($a)) . ', '; + } + $dsp_string = substr( $dsp_string, 0, -2 ); + $msg = '

    ' + . sprintf(_("Settings adjusted to: %s with %s as default dictionary."), $dsp_string, _($lang_default)) + . '

    '; +} else { + /** + * No dictionaries selected. Use system default. + */ + $msg = '

    ' + . sprintf(_("Using %s dictionary (system default) for spellcheck." ), $SQSPELL_APP_DEFAULT) + . '

    '; + $lang_string = $SQSPELL_APP_DEFAULT; +} +$old_lang_string = join(", ", $langs); +$words = str_replace("# LANG: $old_lang_string", "# LANG: $lang_string", + $words); +/** + * Write it down where the sun don't shine. + */ +sqspell_writeWords($words); +sqspell_makePage(_("International Dictionaries Preferences Updated"), + null, $msg); + +/** + * For Emacs weenies: + * Local variables: + * mode: php + * End: + */ ?> diff --git a/plugins/squirrelspell/modules/lang_setup.mod b/plugins/squirrelspell/modules/lang_setup.mod index 557c9887..5a0c5c7d 100644 --- a/plugins/squirrelspell/modules/lang_setup.mod +++ b/plugins/squirrelspell/modules/lang_setup.mod @@ -1,44 +1,59 @@ ($Author$) + * @version $Date$ + */ - // Making sure Sqspell doesn't barf when working with E_ALL - global $SQSPELL_APP; +global $SQSPELL_APP; - $msg = '

    '. - _("Please check any available international dictionaries which you would like to use when spellchecking:"). - '

    '. - '
    '. - ''. - '

    '; - $langs = sqspell_getSettings(null); - $add = '

    '. - _("Make this dictionary my default selection:") . - " \n"; - $add .= "" . _($avail_lang) . "\n"; - } - $msg .= "

    \n" . $add . "\n"; - $msg .= "

    "; - sqspell_makePage(_("Add International Dictionaries"), null, $msg); +$msg = '

    ' + . _("Please check any available international dictionaries which you would like to use when spellchecking:") + . '

    ' + . '' + . '' + . '

    '; +/** + * Present a nice listing. + */ +$langs = sqspell_getSettings(null); +$add = '

    ' + . _("Make this dictionary my default selection:") + . " \n"; + $add .= "" . _($avail_lang) . "\n"; +} +$msg .= "

    \n" . $add . "\n"; +$msg .= "

    "; +sqspell_makePage(_("Add International Dictionaries"), null, $msg); + +/** + * For Emacs weenies: + * Local variables: + * mode: php + * End: + */ ?> diff --git a/plugins/squirrelspell/modules/options_main.mod b/plugins/squirrelspell/modules/options_main.mod index 27b3caea..844191d9 100644 --- a/plugins/squirrelspell/modules/options_main.mod +++ b/plugins/squirrelspell/modules/options_main.mod @@ -1,45 +1,56 @@ ' . - _("Please choose which options you wish to set up:") . - '

    '. - '\n"; - sqspell_makePage( _("SquirrelSpell Options Menu"), null, $msg); +/** + * options_main.mod + * ---------------- + * Squirrelspell module + * Copyright (c) 1999-2002 The SquirrelMail development team + * Licensed under the GNU GPL. For full terms see the file COPYING. + * + * Default page called when accessing SquirrelSpell's options. + * + * $Id$ + * + * @author Konstantin Riabitsev ($Author$) + * @version $Date$ + */ +global $SQSPELL_APP; +$msg = '

    ' + . _("Please choose which options you wish to set up:") + . '

    ' + . '\n"; +sqspell_makePage( _("SquirrelSpell Options Menu"), null, $msg); + +/** + * For Emacs weenies: + * Local variables: + * mode: php + * End: + */ ?> diff --git a/plugins/squirrelspell/setup.php b/plugins/squirrelspell/setup.php index 654b1107..ff760f6c 100644 --- a/plugins/squirrelspell/setup.php +++ b/plugins/squirrelspell/setup.php @@ -1,55 +1,88 @@ ($Author$) + * @version $Date$ + */ - /** - ** setup.php -- Squirrelspell setup file - ** - ** Copyright (c) 1999-2002 The SquirrelMail development team - ** Licensed under the GNU GPL. For full terms see the file COPYING. - ** - ** This is a standard Squirrelmail-1.2 API for plugins. - ** - ** $Id$ - **/ +/** + * Standard squirrelmail plugin initialization API. + * + * @return void + */ +function squirrelmail_plugin_init_squirrelspell() { + global $squirrelmail_plugin_hooks; + $squirrelmail_plugin_hooks['compose_button_row']['squirrelspell'] = + 'squirrelspell_setup'; + $squirrelmail_plugin_hooks['optpage_register_block']['squirrelspell'] = + 'squirrelspell_optpage_register_block'; + $squirrelmail_plugin_hooks['options_link_and_description']['squirrelspell'] = + 'squirrelspell_options'; +} - function squirrelmail_plugin_init_squirrelspell() { - /* Standard initialization API. */ - global $squirrelmail_plugin_hooks; +/** + * This function formats and adds the plugin and its description to the + * Options screen. + * + * @return void + */ +function squirrelspell_optpage_register_block() { + global $optpage_blocks; + /** + * soupNazi checks if this browser is capable of using the plugin. + */ + if (!soupNazi()) { + /** + * The browser checks out. + * Register Squirrelspell with the $optionpages array. + */ + $optpage_blocks[] = + array( + 'name' => _("SpellChecker Options"), + 'url' => '../plugins/squirrelspell/sqspell_options.php', + '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."), + 'js' => TRUE); + } +} - $squirrelmail_plugin_hooks['compose_button_row']['squirrelspell'] = 'squirrelspell_setup'; - $squirrelmail_plugin_hooks['optpage_register_block']['squirrelspell'] = 'squirrelspell_optpage_register_block'; - $squirrelmail_plugin_hooks['options_link_and_description']['squirrelspell'] = 'squirrelspell_options'; - } - - function squirrelspell_optpage_register_block() { - // Gets added to the user's OPTIONS page. - global $optpage_blocks; - - if ( !soupNazi() ) { - - /* Register Squirrelspell with the $optionpages array. */ - $optpage_blocks[] = array( - 'name' => _("SpellChecker Options"), - 'url' => '../plugins/squirrelspell/sqspell_options.php', - '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."), - 'js' => TRUE - ); - } - } - - function squirrelspell_setup() { - /* Gets added to the COMPOSE buttons row. */ - if ( !soupNazi() ) { - /* - ** using document.write to hide this functionality from people - ** with JavaScript turned off. - */ - echo "\n"; - } - } +/** + * This function adds a "Check Spelling" link to the "Compose" row + * during message composition. + * + * @return void + */ +function squirrelspell_setup() { + /** + * Check if this browser is capable of displaying SquirrelSpell + * correctly. + */ + if (!soupNazi()) { + /** + * Some people may choose to disable javascript even though their + * browser is capable of using it. So these freaks don't complain, + * use document.write() so the "Check Spelling" button is not + * displayed if js is off in the browser. + */ + echo '\n"; + } +} ?> diff --git a/plugins/squirrelspell/sqspell_config.php b/plugins/squirrelspell/sqspell_config.php index 46acc575..b51c9597 100644 --- a/plugins/squirrelspell/sqspell_config.php +++ b/plugins/squirrelspell/sqspell_config.php @@ -1,27 +1,33 @@ 'ispell -a', + * 'Spanish' => 'ispell -d spanish -a' ); + */ +$SQSPELL_APP = array('English' => 'ispell -a'); +$SQSPELL_APP_DEFAULT = 'English'; +$SQSPELL_WORDS_FILE = + getHashedFile($username, $data_dir, "$username.words"); - $SQSPELL_APP = array( 'English' => 'ispell -a', - 'Spanish' => 'ispell -d spanish -a' ); - $SQSPELL_APP_DEFAULT = 'English'; - $SQSPELL_WORDS_FILE = - getHashedFile($username, $data_dir, "$username.words"); - $SQSPELL_EREG = 'ereg'; - $SQSPELL_SOUP_NAZI = 'Mozilla/3, Mozilla/2, Opera 4, Opera/4, Macintosh'; +$SQSPELL_EREG = 'ereg'; +$SQSPELL_SOUP_NAZI = 'Mozilla/3, Mozilla/2, Opera 4, Opera/4, ' + . 'Macintosh, OmniWeb'; ?> diff --git a/plugins/squirrelspell/sqspell_functions.php b/plugins/squirrelspell/sqspell_functions.php index 560c76b2..00b031bd 100644 --- a/plugins/squirrelspell/sqspell_functions.php +++ b/plugins/squirrelspell/sqspell_functions.php @@ -1,309 +1,509 @@ ($Author$) + * @version $Date$ */ - - function sqspell_makePage($title, $scriptsrc, $body){ - /* - ** GUI wrap-around for the OPTIONS page. - */ - global $color, $SQSPELL_VERSION, $MOD; - displayPageHeader($color, 'None'); - - echo " 
    \n"; - if($scriptsrc) { - echo "\n"; - } - echo ''. - ''. - "'. - ''. - ''. - ""; - if ($MOD!="options_main"){ - // Generate a nice return-to-main link. - echo ''. - ''; - } - echo ''. - ''. - "'. - ''. - '
    ". - "$title". - '

    $body

    ' . - _("Back to "SpellChecker Options" page") . '

    ". - "SquirrelSpell $SQSPELL_VERSION". - '
    '; - } - - function sqspell_makeWindow($onload, $title, $scriptsrc, $body){ - - /* - ** GUI wrap-around for the pop-up window interface. - */ - global $color, $SQSPELL_VERSION, $theme_css; - - echo "\n". - "\n". - "$title\n"; - if ($theme_css != "") { - echo "\n"; - } - if ($scriptsrc){ - echo "\n"; - } - echo "\n". - "'. - ''. - ''. - "'. - ''. - ''. - ''. - "". - ''. - ''. - ''. - "'. - ''. - '
    ". - "$title". - '

    $body

    ". - "SquirrelSpell $SQSPELL_VERSION". - '
    '. - "\n\n"; - } - - function sqspell_crypto($mode, $ckey, $input){ - // - // This function does the encryption and decryption of the user - // dictionary. It is only available when PHP is compiled - // --with-mcrypt. See doc/CRYPTO for more information. - // - if (!function_exists(mcrypt_generic)) { - return 'PANIC'; - } - $td = mcrypt_module_open(MCRYPT_Blowfish, "", MCRYPT_MODE_ECB, ""); - $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size ($td), MCRYPT_RAND); - mcrypt_generic_init($td, $ckey, $iv); - switch ($mode){ - case 'encrypt': - $crypto = mcrypt_generic($td, $input); - break; - case 'decrypt': - $crypto = mdecrypt_generic($td, $input); - // See if it decrypted successfully. If so, it should contain - // the string "# SquirrelSpell". - if (!strstr($crypto, "# SquirrelSpell")) - $crypto='PANIC'; - break; - } - mcrypt_generic_end ($td); - return $crypto; - } - - function sqspell_upgradeWordsFile($words_string){ - /* - ** This function transparently upgrades the 0.2 dictionary format to - ** 0.3, since user-defined languages have been added in 0.3 and - ** the new format keeps user dictionaries selection in the file. - */ - global $SQSPELL_APP_DEFAULT, $SQSPELL_VERSION; - - /* Define just one dictionary for this user -- the default. - ** If the user wants more, s/he can set them up in personal - ** preferences. See doc/UPGRADING for more info. - */ - $new_words_string=substr_replace($words_string, "# SquirrelSpell User Dictionary $SQSPELL_VERSION\n# Last Revision: " . date("Y-m-d") . "\n# LANG: $SQSPELL_APP_DEFAULT\n# $SQSPELL_APP_DEFAULT", 0, strpos($words_string, "\n")) . "# End\n"; - sqspell_writeWords($new_words_string); - return $new_words_string; - } - - function sqspell_getSettings($words){ - /* - ** Right now it just returns an array with the dictionaries - ** available to the user for spell-checking. It will probably - ** do more in the future, as features are added. - */ - global $SQSPELL_APP, $SQSPELL_APP_DEFAULT; - if (sizeof($SQSPELL_APP) > 1){ - // OK, so there are more than one dictionary option. - // Now load the user prefs. - if(!$words) - $words=sqspell_getWords(); - if ($words){ - // find which dictionaries user wants to use - preg_match("/# LANG: (.*)/i", $words, $matches); - $langs=explode(", ", $matches[1]); - } else { - // User doesn't have a personal dictionary. Set him up with - // a default setting. - $langs[0]=$SQSPELL_APP_DEFAULT; - } - } else { - // There is only one dictionary defined system-wide. - $langs[0]=$SQSPELL_APP_DEFAULT; - } - return $langs; + +/** + * This function is the GUI wrapper for the options page. SquirrelSpell + * uses it for creating all Options pages. + * + * @param $title The title of the page to display + * @param $scriptsrc This is used to link a file.js into the + * format. This + * allows to separate javascript from the rest of the + * plugin and place it into the js/ directory. + * @param $body The body of the message to display. + * @return void + */ +function sqspell_makePage($title, $scriptsrc, $body){ + global $color, $SQSPELL_VERSION, $MOD; + displayPageHeader($color, 'None'); + echo " 
    \n"; + /** + * Check if we need to link in a script. + */ + if($scriptsrc) { + echo "\n"; + } + echo '' + . '' + . "' + . '' + . '' + . ""; + /** + * Generate a nice "Return to Options" link, unless this is the + * starting page. + */ + if ($MOD != "options_main"){ + echo '' + . ''; + } + /** + * Close the table and display the version. + */ + echo '' + . '' + . "' + . '' + . '
    " + . "$title" + . '

    $body

    ' + . _("Back to "SpellChecker Options" page") + . '

    " + . "SquirrelSpell $SQSPELL_VERSION" + . '
    '; +} + +/** + * Function similar to the one above. This one is a general wrapper + * for the Squirrelspell pop-up window. It's called form nearly + * everywhere, except the check_me module, since that one is highly + * customized. + * + * @param $onload Used to indicate and pass the name of a js function + * to call in a format. + * @param $body The content to include. + * @return void + */ +function sqspell_makeWindow($onload, $title, $scriptsrc, $body){ + global $color, $SQSPELL_VERSION, $theme_css; + echo "\n" + . "\n" + . "$title\n"; + /** + * Check if we have a defined css theme to use. + */ + if ($theme_css != "") { + echo "\n"; + } + /** + * Link in the .js file if needed + */ + if ($scriptsrc){ + echo "\n"; + } + echo "\n" + . "' + . '' + . '' + . "' + . '' + . '' + . '' + . "" + . '' + . '' + . '' + . "' + . '' + . '
    " + . "$title" + . '

    $body

    " + . "SquirrelSpell $SQSPELL_VERSION" + . '
    ' + . "\n\n"; +} + +/** + * This function does the encryption and decryption of the user + * dictionary. It is only available when PHP is compiled with + * mcrypt support (--with-mcrypt). See doc/CRYPTO for more + * information. + * + * @param $mode A string with either of the two recognized values: + * "encrypt" or "decrypt". + * @param $ckey The key to use for processing (the user's password + * in our case. + * @param $input Content to decrypt or encrypt, according to $mode. + * @return encrypted/decrypted content, or "PANIC" if the + * process bails out. + */ +function sqspell_crypto($mode, $ckey, $input){ + /** + * Double-check if we have the mcrypt_generic function. Bail out if + * not so. + */ + if (!function_exists(mcrypt_generic)) { + return 'PANIC'; + } + /** + * Setup mcrypt routines. + */ + $td = mcrypt_module_open(MCRYPT_Blowfish, "", MCRYPT_MODE_ECB, ""); + $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size ($td), MCRYPT_RAND); + mcrypt_generic_init($td, $ckey, $iv); + /** + * See what we have to do depending on $mode. + * 'encrypt' -- Encrypt the content. + * 'decrypt' -- Decrypt the content. + */ + switch ($mode){ + case 'encrypt': + $crypto = mcrypt_generic($td, $input); + break; + case 'decrypt': + $crypto = mdecrypt_generic($td, $input); + /** + * See if it decrypted successfully. If so, it should contain + * the string "# SquirrelSpell". If not, then bail out. + */ + if (!strstr($crypto, "# SquirrelSpell")){ + $crypto='PANIC'; } - - function sqspell_getLang($words, $lang){ - // - // Returns words of a specific user dictionary. - // - $start=strpos($words, "# $lang\n"); - if (!$start) return ''; - $end=strpos($words, "#", $start+1); - $lang_words = substr($words, $start, $end-$start); - return $lang_words; + break; + } + /** + * Finish up the mcrypt routines and return the processed content. + */ + mcrypt_generic_end ($td); + return $crypto; +} + +/** + * This function transparently upgrades the 0.2 dictionary format to the + * 0.3 format, since user-defined languages have been added in 0.3 and + * the new format keeps user dictionaries selection in the file. + * + * This function will be retired soon, as it's been a while since anyone + * has been using SquirrelSpell-0.2. + * + * @param $words_string Contents of the 0.2-style user dictionary. + * @return Contents of the 0.3-style user dictionary. + */ +function sqspell_upgradeWordsFile($words_string){ + global $SQSPELL_APP_DEFAULT, $SQSPELL_VERSION; + /** + * Define just one dictionary for this user -- the default. + * If the user wants more, s/he can set them up in personal + * preferences. See doc/UPGRADING for more info. + */ + $new_words_string = + substr_replace($words_string, + "# SquirrelSpell User Dictionary $SQSPELL_VERSION\n# " + . "Last Revision: " . date("Y-m-d") + . "\n# LANG: $SQSPELL_APP_DEFAULT\n# $SQSPELL_APP_DEFAULT", + 0, strpos($words_string, "\n")) . "# End\n"; + sqspell_writeWords($new_words_string); + return $new_words_string; +} + +/** + * Right now it just returns an array with the dictionaries + * available to the user for spell-checking. It will probably + * do more in the future, as features are added. + * + * @param $words The contents of the user's ".words" file. + * @return a strings array with dictionaries available + * to this user, e.g. {"English", "Spanish"}, etc. + */ +function sqspell_getSettings($words){ + global $SQSPELL_APP, $SQSPELL_APP_DEFAULT; + /** + * Check if there is more than one dictionary configured in the + * system config. + */ + if (sizeof($SQSPELL_APP) > 1){ + /** + * Now load the user prefs. Check if $words was empty -- a bit of + * a dirty fall-back. TODO: make it so this is not required. + */ + if(!$words){ + $words=sqspell_getWords(); } - - function sqspell_getWords(){ - // - // This baby operates the user dictionary. If the format is clear-text, - // then it just reads the file and returns it. However, if the file is - // encrypted, then it decrypts it, checks whether the decryption was - // successful, troubleshoots if not, then returns the clear-text dictionary - // to the app. - // - global $SQSPELL_WORDS_FILE, $SQSPELL_CRYPTO; - $words=""; - if (file_exists($SQSPELL_WORDS_FILE)){ - // Gobble it up. - $fp=fopen($SQSPELL_WORDS_FILE, 'r'); - $words=fread($fp, filesize($SQSPELL_WORDS_FILE)); - fclose($fp); - } - // Check if this is an encrypted file by looking for - // the string "# SquirrelSpell" in it. - if ($words && !strstr($words, "# SquirrelSpell")){ - // This file is encrypted or mangled. Try to decrypt it. - // If fails, raise hell. - global $key, $onetimepad, $old_key; - if ($old_key) { - // an override in case user is trying to decrypt a dictionary - // with his old password - $clear_key=$old_key; - } else { - // get user's password (the key). - $clear_key = OneTimePadDecrypt($key, $onetimepad); - } - // decrypt - $words=sqspell_crypto("decrypt", $clear_key, $words); - if ($words=="PANIC"){ - // AAAAAAAAAAAH!!!!! OK, ok, breathe! - // Let's hope the decryption failed because the user changed his - // password. Bring up the option to key in the old password - // or wipe the file and start over if everything else fails. - $msg='

    '. - '' . _("ATTENTION:") . '
    ' . - _("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."). - '

    ' . - '
    '. - ''. - ''. - '

    ' . - _("Delete my dictionary and start a new one") . '
    '. - _("Decrypt my dictionary with my old password:") . - '

    '. - '
    '. - '

    '. - ''; - // See if this happened in the pop-up window or when accessing - // the SpellChecker options page. - global $SCRIPT_NAME; - if (strstr($SCRIPT_NAME, "sqspell_options")) - sqspell_makePage( _("Error Decrypting Dictionary"), "decrypt_error.js", $msg); - else - sqspell_makeWindow(null, _("Error Decrypting Dictionary"), "decrypt_error.js", $msg); - exit; - } else { - // OK! Phew. Set the encryption flag to true so we can later on - // encrypt it again before saving to HDD. - $SQSPELL_CRYPTO=true; - } - } else { - // No encryption is used. Set $SQSPELL_CRYPTO to false, in case we have to - // save the dictionary later. - $SQSPELL_CRYPTO=false; - } - // Check if we need to upgrade the dictionary from version 0.2.x - if (strstr($words, "Dictionary v0.2")) $words=sqspell_upgradeWordsFile($words); - return $words; + if ($words){ + /** + * This user has a ".words" file. + * Find which dictionaries s/he wants to use and load them into + * the $langs array. + */ + preg_match("/# LANG: (.*)/i", $words, $matches); + $langs=explode(", ", $matches[1]); + } else { + /** + * User doesn't have a personal dictionary. Grab the default + * system setting. + */ + $langs[0]=$SQSPELL_APP_DEFAULT; } - - function sqspell_writeWords($words){ - // - // Writes user dictionary into the $username.words file, then changes mask - // to 0600. If encryption is needed -- does that, too. - // - global $SQSPELL_WORDS_FILE, $SQSPELL_CRYPTO; - // if $words is empty, create a template entry. - if (!$words) $words=sqspell_makeDummy(); - if ($SQSPELL_CRYPTO){ - // User wants to encrypt the file. So be it. - // get his password to use as a key. - global $key, $onetimepad; - $clear_key=OneTimePadDecrypt($key, $onetimepad); - // Try encrypting it. If fails, scream bloody hell. - $save_words = sqspell_crypto("encrypt", $clear_key, $words); - if ($save_words == 'PANIC'){ - /* - ** AAAAAAAAH! I'm not handling this yet, since obviously - ** the admin of the site forgot to compile the MCRYPT support in. - ** I will add a handler for this case later, when I can come up - ** with some work-around... Right now, do nothing. Let the Admin's - ** head hurt.. ;))) - */ - } - } else { - $save_words = $words; - } - $fp=fopen($SQSPELL_WORDS_FILE, "w"); - fwrite($fp, $save_words); - fclose($fp); - chmod($SQSPELL_WORDS_FILE, 0600); + } else { + /** + * There is no need to read the ".words" file as there is only one + * dictionary defined system-wide. + */ + $langs[0]=$SQSPELL_APP_DEFAULT; + } + return $langs; +} + +/** + * This function returns only user-defined dictionary words that correspond + * to the requested language. + * + * @param $words The contents of the user's ".words" file. + * @param $lang Which language words to return, e.g. requesting + * "English" will return ONLY the words from user's + * English dictionary, disregarding any others. + * @return The list of words corresponding to the language + * requested. + */ +function sqspell_getLang($words, $lang){ + $start=strpos($words, "# $lang\n"); + /** + * strpos() will return -1 if no # $lang\n string was found. + * Use this to return a zero-length value and indicate that no + * words are present in the requested dictionary. + */ + if (!$start) return ''; + /** + * The words list will end with a new directive, which will start + * with "#". Locate the next "#" and thus find out where the + * words end. + */ + $end=strpos($words, "#", $start+1); + $lang_words = substr($words, $start, $end-$start); + return $lang_words; +} + +/** + * This function operates the user dictionary. If the format is + * clear-text, then it just reads the file and returns it. However, if + * the file is encrypted (well, "garbled"), then it tries to decrypt + * it, checks whether the decryption was successful, troubleshoots if + * not, then returns the clear-text dictionary to the app. + * + * @return the contents of the user's ".words" file, decrypted if + * necessary. + */ +function sqspell_getWords(){ + global $SQSPELL_WORDS_FILE, $SQSPELL_CRYPTO; + $words=""; + if (file_exists($SQSPELL_WORDS_FILE)){ + /** + * Gobble it up. + */ + $fp=fopen($SQSPELL_WORDS_FILE, 'r'); + $words=fread($fp, filesize($SQSPELL_WORDS_FILE)); + fclose($fp); + } + /** + * Check if this is an encrypted file by looking for + * the string "# SquirrelSpell" in it (the crypto + * function does that). + */ + if ($words && !strstr($words, "# SquirrelSpell")){ + /** + * This file is encrypted or mangled. Try to decrypt it. + * If fails, complain loudly. + * + * $old_key would be a value submitted by one of the modules with + * the user's old mailbox password. I admin, this is rather dirty, + * but efficient. ;) + */ + global $key, $onetimepad, $old_key; + if ($old_key) { + $clear_key=$old_key; + } else { + /** + * Get user's password (the key). + */ + $clear_key = OneTimePadDecrypt($key, $onetimepad); } - - function sqspell_deleteWords(){ - /* - ** so I open the door to my enemies, - ** and I ask can we wipe the slate clean, - ** but they tell me to please go... - ** uhm... Well, this just erases the user dictionary file. - */ - global $SQSPELL_WORDS_FILE; - if (file_exists($SQSPELL_WORDS_FILE)) unlink($SQSPELL_WORDS_FILE); + /** + * Invoke the decryption routines. + */ + $words=sqspell_crypto("decrypt", $clear_key, $words); + /** + * See if decryption failed. + */ + if ($words=="PANIC"){ + /** + * AAAAAAAAAAAH!!!!! OK, ok, breathe! + * Let's hope the decryption failed because the user changed his + * password. Bring up the option to key in the old password + * or wipe the file and start over if everything else fails. + * + * The _("SquirrelSpell...) line has to be on one line, otherwise + * gettext will bork. ;( + */ + $msg='

    ' + . '' . _("ATTENTION:") . '
    ' + . _("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.") + . '

    ' + . '
    ' + . '
    ' + . '' + . '

    ' + . _("Delete my dictionary and start a new one") . '
    ' + . _("Decrypt my dictionary with my old password:") + . '

    ' + . '
    ' + . '

    ' + . ''; + /** + * See if this happened in the pop-up window or when accessing + * the SpellChecker options page. + * This is a dirty solution, I agree. TODO: make this prettier. + */ + global $SCRIPT_NAME; + if (strstr($SCRIPT_NAME, "sqspell_options")){ + sqspell_makePage( _("Error Decrypting Dictionary"), + "decrypt_error.js", $msg); + } else { + sqspell_makeWindow(null, _("Error Decrypting Dictionary"), + "decrypt_error.js", $msg); + } + exit; + } else { + /** + * OK! Phew. Set the encryption flag to true so we can later on + * encrypt it again before saving to HDD. + */ + $SQSPELL_CRYPTO=true; } - - function sqspell_makeDummy(){ - // - // Creates an empty user dictionary for the sake of saving prefs or - // whatever. - // - global $SQSPELL_VERSION, $SQSPELL_APP_DEFAULT; - $words="# SquirrelSpell User Dictionary $SQSPELL_VERSION\n# Last Revision: " . date('Y-m-d') . "\n# LANG: $SQSPELL_APP_DEFAULT\n# End\n"; - return $words; + } else { + /** + * No encryption is/was used. Set $SQSPELL_CRYPTO to false, + * in case we have to save the dictionary later. + */ + $SQSPELL_CRYPTO=false; + } + /** + * Check if we need to upgrade the dictionary from version 0.2.x + * This is going away soon. + */ + if (strstr($words, "Dictionary v0.2")){ + $words=sqspell_upgradeWordsFile($words); + } + return $words; +} + +/** + * Writes user dictionary into the $username.words file, then changes mask + * to 0600. If encryption is needed -- does that, too. + * + * @param $words The contents of the ".words" file to write. + * @return void + */ +function sqspell_writeWords($words){ + global $SQSPELL_WORDS_FILE, $SQSPELL_CRYPTO; + /** + * if $words is empty, create a template entry by calling the + * sqspell_makeDummy() function. + */ + if (!$words){ + $words=sqspell_makeDummy(); + } + if ($SQSPELL_CRYPTO){ + /** + * User wants to encrypt the file. So be it. + * Get the user's password to use as a key. + */ + global $key, $onetimepad; + $clear_key=OneTimePadDecrypt($key, $onetimepad); + /** + * Try encrypting it. If fails, scream bloody hell. + */ + $save_words = sqspell_crypto("encrypt", $clear_key, $words); + if ($save_words == 'PANIC'){ + /** + * AAAAAAAAH! I'm not handling this yet, since obviously + * the admin of the site forgot to compile the MCRYPT support in + * when upgrading an existing PHP installation. + * I will add a handler for this case later, when I can come up + * with some work-around... Right now, do nothing. Let the Admin's + * head hurt.. ;))) + */ } + } else { + $save_words = $words; + } + /** + * Do the actual writing. + */ + $fp=fopen($SQSPELL_WORDS_FILE, "w"); + fwrite($fp, $save_words); + fclose($fp); + chmod($SQSPELL_WORDS_FILE, 0600); +} - /** - VERSION: - --------- - SquirrelSpell version. Don't modify, since it identifies the format - of the user dictionary files and messing with this can do ugly - stuff. :) - **/ - $SQSPELL_VERSION="v0.3.6"; - +function sqspell_deleteWords(){ + /** + * So I open the door to my enemies, + * and I ask can we wipe the slate clean, + * but they tell me to please go... + * uhm... Well, this just erases the user dictionary file. + */ + global $SQSPELL_WORDS_FILE; + if (file_exists($SQSPELL_WORDS_FILE)){ + unlink($SQSPELL_WORDS_FILE); + } +} +/** + * Creates an empty user dictionary for the sake of saving prefs or + * whatever. + * + * @return The template to use when storing the user dictionary. + */ +function sqspell_makeDummy(){ + global $SQSPELL_VERSION, $SQSPELL_APP_DEFAULT; + $words = "# SquirrelSpell User Dictionary $SQSPELL_VERSION\n" + . "# Last Revision: " . date('Y-m-d') + . "\n# LANG: $SQSPELL_APP_DEFAULT\n# End\n"; + return $words; +} + +/** + * This function checks for security attacks. A $MOD variable is + * provided in the QUERY_STRING and includes one of the files from the + * modules directory ($MOD.mod). See if someone is trying to get out + * of the modules directory by providing dots, unicode strings, or + * slashes. + * + * @param $rMOD the name of the module requested to include. + * @return void, since it bails out with an access error if needed. + */ +function sqspell_ckMOD($rMOD){ + if (strstr($rMOD, '.') + || strstr($rMOD, '/') + || strstr($rMOD, '%') + || strstr($rMOD, "\\")){ + echo _("Cute."); + exit; + } +} + +/** + * SquirrelSpell version. Don't modify, since it identifies the format + * of the user dictionary files and messing with this can do ugly + * stuff. :) + */ +$SQSPELL_VERSION="v0.3.7"; ?> diff --git a/plugins/squirrelspell/sqspell_interface.php b/plugins/squirrelspell/sqspell_interface.php index 3ea858c4..1357162e 100644 --- a/plugins/squirrelspell/sqspell_interface.php +++ b/plugins/squirrelspell/sqspell_interface.php @@ -1,48 +1,52 @@ ($Author$) + * @version $Date$ + */ - /* - ** Set up a couple of non-negotiable constants. Don't change these, - ** the setuppable stuff is in sqspell_config.php - */ - $SQSPELL_DIR='squirrelspell'; - $SQSPELL_CRYPTO=FALSE; +/** + * Set up a couple of non-negotiable constants and + * defaults. Don't change these, * the setuppable stuff is in + * sqspell_config.php + */ +$SQSPELL_DIR='squirrelspell'; +$SQSPELL_CRYPTO=FALSE; - /* Load the necessary stuff. */ - chdir('..'); - require_once('../src/validate.php'); - require_once('../src/load_prefs.php'); - require_once("$SQSPELL_DIR/sqspell_config.php"); - require_once("$SQSPELL_DIR/sqspell_functions.php"); +/** + * Load the stuff needed from squirrelmail + */ +chdir('..'); +require_once('../src/validate.php'); +require_once('../src/load_prefs.php'); +require_once("$SQSPELL_DIR/sqspell_config.php"); +require_once("$SQSPELL_DIR/sqspell_functions.php"); - /* - ** Now load the necessary module from the modules dir. - ** - */ - if (!$MOD) - $MOD='init'; - - /* - ** see if someone is attempting to be nasty by trying to get out of the - ** modules directory, although it probably wouldn't do them any good, - ** since every module has to end with .mod. Still, they deserve - ** to be warned. ;) - */ - if (strstr($MOD, '.') || strstr($MOD, '/') || strstr($MOD, '%')){ - echo _("SECURITY BREACH ON DECK 5! CMDR TUVOK AND SECURITY TEAM REQUESTED."); - exit; - } - /* fetch the module now. */ - require_once("$SQSPELL_DIR/modules/$MOD.mod"); +/** + * $MOD is the name of the module to invoke. + * If $MOD is undefined, use "init", else check for security + * breaches. + */ +if (!$MOD){ + $MOD='init'; +} else { + sqspell_ckMOD($MOD); +} + +/** + * Include the module. + */ +require_once("$SQSPELL_DIR/modules/$MOD.mod"); ?> diff --git a/plugins/squirrelspell/sqspell_options.php b/plugins/squirrelspell/sqspell_options.php index 8311678b..1a7eba5b 100644 --- a/plugins/squirrelspell/sqspell_options.php +++ b/plugins/squirrelspell/sqspell_options.php @@ -1,46 +1,49 @@ ($Author$) + * @version $Date$ + */ - /** - ** sqspell_options.php -- Main wrapper for the options interface. - ** - ** Copyright (c) 1999-2002 The SquirrelMail development team - ** Licensed under the GNU GPL. For full terms see the file COPYING. - ** - ** - ** - ** $Id$ - **/ +/** + * Set a couple of constants and defaults. Don't change these, + * the configurable stuff is in sqspell_config.php + */ +$SQSPELL_DIR='squirrelspell'; +$SQSPELL_CRYPTO=FALSE; - /* - ** Set a couple of constants. Don't change these, the setuppable stuff is - ** in sqspell_config.php - */ - $SQSPELL_DIR='squirrelspell'; - $SQSPELL_CRYPTO=FALSE; - - /* Load some necessary stuff. */ - chdir('..'); - require_once('../src/validate.php'); - require_once('../src/load_prefs.php'); - require_once('../functions/strings.php'); - require_once('../functions/page_header.php'); - require_once("$SQSPELL_DIR/sqspell_config.php"); - require_once("$SQSPELL_DIR/sqspell_functions.php"); - - /* Access the module needed */ - if (!$MOD) - $MOD = 'options_main'; - - /* - ** see if someone is attempting to be nasty by trying to get out of the - ** modules directory, although it probably wouldn't do them any good, - ** since every module has to end with .mod. Still, they deserve - ** to be warned. ;) - */ - if (strstr($MOD, ".") || strstr($MOD, "/") || strstr($MOD, "%")){ - echo _("SECURITY BREACH ON DECK 5! CMDR TUVOK AND SECURITY TEAM REQUESTED."); - exit; - } - /* load the stuff already. */ - require_once("$SQSPELL_DIR/modules/$MOD.mod"); +/** + * Load some necessary stuff from squirrelmail. + */ +chdir('..'); +require_once('../src/validate.php'); +require_once('../src/load_prefs.php'); +require_once('../functions/strings.php'); +require_once('../functions/page_header.php'); +require_once("$SQSPELL_DIR/sqspell_config.php"); +require_once("$SQSPELL_DIR/sqspell_functions.php"); + +/** + * $MOD is the name of the module to invoke. + * If $MOD is unspecified, assign "init" to it. Else check for + * security breach attempts. + */ +if (!$MOD){ + $MOD = 'options_main'; +} else { + sqspell_ckMOD($MOD); +} + +/** + * Load the stuff already. + */ +require_once("$SQSPELL_DIR/modules/$MOD.mod"); ?> -- 2.25.1