File/plugins/spellcheck/functions.php

Description

functions.php - main plugin functions Copyright (c) 1999-2006 The SquirrelMail Project Team Copyright (c) 2006-2008 The NaSMail Project Licensed under the GNU GPL. For full terms see the file COPYING.

Original plugin (SquirrelSpell) was written by Konstantin Riabitsev <icon@duke.edu>. This plugin version is maintained by The NaSMail Project developers.

  • version: $Id: functions.php 1249 2008-04-05 07:34:50Z tokul $
Includes
 include_once (SM_PATH.'plugins/spellcheck/config.php') (line 21)

load plugin configuration

Variables
string $SQSPELL_VERSION (line 811)

SquirrelSpell version. Don't modify, since it identifies the format

of the user dictionary files and messing with this can do ugly stuff. :)

  • deprecated:
Functions
sqspell_check_version (line 723)

Used to check internal version of SquirrelSpell dictionary

  • return: true if stored dictionary version is $major.$minor or newer
boolean sqspell_check_version (integer $major, integer $minor)
  • integer $major: main version number
  • integer $minor: second version number
sqspell_ckMOD (line 707)

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.

  • return: since it bails out with an access error if needed.
void, sqspell_ckMOD (string $rMOD)
  • string $rMOD: the name of the module requested to include.
sqspell_crypto (line 228)

Encryption function used by plugin

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.

  • return: content, or "PANIC" if the process bails out.
encrypted/decrypted sqspell_crypto ($mode $mode, $ckey $ckey, $input $input)
  • $mode $mode: A string with either of the two recognized values: "encrypt" or "decrypt".
  • $ckey $ckey: The key to use for processing (the user's password in our case.
  • $input $input: Content to decrypt or encrypt, according to $mode.
sqspell_crypto_old (line 164)

Encryption function used by plugin (old format)

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.

  • return: content, or "PANIC" if the process bails out.
  • deprecated:
encrypted/decrypted sqspell_crypto_old ($mode $mode, $ckey $ckey, $input $input)
  • $mode $mode: A string with either of the two recognized values: "encrypt" or "decrypt".
  • $ckey $ckey: The key to use for processing (the user's password in our case.
  • $input $input: Content to decrypt or encrypt, according to $mode.
sqspell_deleteWords (line 661)

Deletes user's dictionary

Function was modified in 1.5.1 (sqspell 0.5). Older function is suffixed with '_old'

void sqspell_deleteWords (string $lang)
  • string $lang: dictionary
sqspell_deleteWords_old (line 670)

Deletes user's dictionary when it is corrupted.

  • deprecated:
void sqspell_deleteWords_old ()
sqspell_getLang (line 403)

Get user dictionary for selected language Function was modified in 1.5.1 (sqspell 0.5).

Older function is suffixed with '_old'

void sqspell_getLang (string $lang, array 1)
  • string $lang: language
  • array 1: words stored in selected language dictionary
sqspell_getLang_old (line 471)

Get user's dictionary (old format)

This function returns only user-defined dictionary words that correspond to the requested language.

  • return: list of words corresponding to the language requested.
  • deprecated:
The sqspell_getLang_old ($words $words, $lang $lang)
  • $words $words: The contents of the user's ".words" file.
  • $lang $lang: Which language words to return, e.g. requesting "English" will return ONLY the words from user's English dictionary, disregarding any others.
sqspell_getSettings (line 314)

gets list of available dictionaries from user's prefs.

Function was modified in 1.5.1 (sqspell 0.5). Older function is suffixed with '_old'

  • return: list of dictionaries used by end user.
array sqspell_getSettings ()
sqspell_getSettings_old (line 357)

Get list of enabled languages.

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.

  • return: a strings array with dictionaries available to this user, e.g. {"English", "Spanish"}, etc.
  • deprecated:
array sqspell_getSettings_old (string $words)
  • string $words: The contents of the user's ".words" file.
sqspell_getWords_old (line 502)

Saves user's dictionary (old format)

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: contents of the user's ".words" file, decrypted if necessary.
  • deprecated:
the sqspell_getWords_old ()
sqspell_handle_crypt_panic (line 743)

Displays form that allows to enter different password for dictionary decryption.

If language is not set, function provides form to handle older dictionary files.

void sqspell_handle_crypt_panic ([string $lang = false])
  • string $lang: language
sqspell_makeDummy (line 689)

Creates an empty user dictionary for the sake of saving prefs or whatever.

  • return: template to use when storing the user dictionary.
  • deprecated:
The sqspell_makeDummy ()
sqspell_makePage (line 65)

This function is the GUI wrapper for the options page.

void sqspell_makePage (string $title, string $scriptsrc, string $body)
  • string $title: The title of the page to display
  • string $scriptsrc: This is used to link a file.js into the <script src="file.js"></script> format. This allows to separate javascript from the rest of the plugin and place it into the js/ directory.
  • string $body: The body of the message to display.
sqspell_makeWindow (line 122)

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.

void sqspell_makeWindow (string $onload, string $title, string $scriptsrc, string $body)
  • string $onload: Used to indicate and pass the name of a js function to call in a <body onload="function()" for automatic onload script execution.
  • string $title: Title of the page.
  • string $scriptsrc: If defined, link this javascript source page into the document using <script src="file.js"> format.
  • string $body: The content to include.
sqspell_saveSettings (line 340)

Saves user's language preferences

void sqspell_saveSettings (array $langs)
  • array $langs: languages array (first key is default language)
sqspell_upgradeWordsFile (line 291)

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.

  • return: of the 0.3-style user dictionary.
  • deprecated:
Contents sqspell_upgradeWordsFile ($words_string $words_string)
  • $words_string $words_string: Contents of the 0.2-style user dictionary.
sqspell_writeWords (line 579)

Saves user's dictionary Function was replaced in 1.5.1 (sqspell 0.5).

Older function is suffixed with '_old'

void sqspell_writeWords (array $words, string $lang)
  • array $words: words that should be stored in dictionary
  • string $lang: language
sqspell_writeWords_old (line 612)

Writes user dictionary into the $username.words file, then changes mask to 0600. If encryption is needed -- does that, too.

  • deprecated:
void sqspell_writeWords_old ($words $words)
  • $words $words: The contents of the ".words" file to write.
squirrelspell_upgrade_function (line 29)

Upgrade dictionaries (internal function)

Transparently upgrades user's dictionaries when message listing is loaded

void squirrelspell_upgrade_function ()

Documentation generated on Sun, 22 Nov 2009 17:36:34 +0200 by phpDocumentor 1.4.3