Some changes. En-route. Most likely broken. ;)
authorgraf25 <graf25@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 31 Jan 2002 03:00:55 +0000 (03:00 +0000)
committergraf25 <graf25@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 31 Jan 2002 03:00:55 +0000 (03:00 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2299 7612ce4b-ef26-0410-bec9-ea0150e637f0

18 files changed:
plugins/squirrelspell/index.php
plugins/squirrelspell/js/check_me.js
plugins/squirrelspell/modules/check_me.mod
plugins/squirrelspell/modules/crypto.mod
plugins/squirrelspell/modules/crypto_badkey.mod
plugins/squirrelspell/modules/edit_dic.mod
plugins/squirrelspell/modules/enc_setup.mod
plugins/squirrelspell/modules/forget_me.mod
plugins/squirrelspell/modules/forget_me_not.mod
plugins/squirrelspell/modules/init.mod
plugins/squirrelspell/modules/lang_change.mod
plugins/squirrelspell/modules/lang_setup.mod
plugins/squirrelspell/modules/options_main.mod
plugins/squirrelspell/setup.php
plugins/squirrelspell/sqspell_config.php
plugins/squirrelspell/sqspell_functions.php
plugins/squirrelspell/sqspell_interface.php
plugins/squirrelspell/sqspell_options.php

index 186c259b78042beccd720b1db3996372e3ef552a..3afdbfab26fdb89c42e9a8a90c7d691f809d9032 100644 (file)
@@ -13,7 +13,7 @@
  * $Id$
  */
 
-header("Location:../../index.php");
+header("Location: ../../index.php");
 
 /* pretty impressive huh? */
 
index 852ca0e4d56b7d0dbf6554fe9ba7fbba40fc63ba..1abc4e0dcb910ad2d9dc3c2c62e3c2db571cf1c2 100644 (file)
@@ -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 <icon@duke.edu> ($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<allLoc.length; z++){
     tmp = allLoc[z].split(":");
     lLine = parseInt(tmp[0]);  lSymbol = parseInt(tmp[1]);
     updateLine(lLine, lSymbol, CurrentWord, NewWord);
-    // Load it again to reflect the changes in symbol data
+    /**
+     * Load it again to reflect the changes in symbol data
+     */
     allLoc = locations[CurrentError].split(", ");
-  }
-       
+  }       
   CurrentLocation=0;
   proceed();
 }
 
+/**
+ * This function is only here for consistency. It is called when
+ * "Ignore" is pressed.
+ *
+ * @return void
+ */
 function sqspellIgnore(){
-  // Only here for consistency. Called when pressed the "Ignore" button
   proceed();
 }
 
+/**
+ * This function is called when the "Ignore All" button is pressed.
+ * 
+ * @return void
+ */
 function sqspellIgnoreAll(){
-  // Called when pressed the "Ignore All" button
   CurrentLocation=0;
   proceed();
 }
 
+/**
+ * This function clears the options in a select box "sqspell_suggestions".
+ *
+ * @return void
+ */
 function clearSqspellForm(){
-  // Clears the options in selectbox "sqspell_suggestions"
   for (i=0; i<document.forms[0].sqspell_suggestion.length; i++){
     document.forms[0].sqspell_suggestion.options[i]=null;
   }
        
-  // Now, I've been instructed by the Netscape Developer docs to call
-  // history.go(0) to refresh the page after I've changed the options.
-  // However, that brings so many pains with it that I just decided not
-  // to do it. It works like it is in Netscape 4.x. If there are problems
-  // in earlier versions of Netscape, then oh well. I'm not THAT anxious
-  // to have it working on all browsers... ;)
-
+  /**
+   * Now, I've been instructed by the Netscape Developer docs to call
+   * history.go(0) to refresh the page after I've changed the options.
+   * However, that brings so many pains with it that I just decided not
+   * to do it. It works like it is in Netscape 4.x. If there are problems
+   * in earlier versions of Netscape, then oh well. I'm not THAT anxious
+   * to have it working on all browsers... ;)
+   */
   document.forms[0].sqspell_oruse.value="";
 }
 
+/**
+ * This function goes on to the next error, or finishes nicely if
+ * no more errors are available.
+ *
+ * @return void
+ */
 function proceed(){
-  // Goes on to the next error if any, or finishes.
   if (!CurrentLocation) CurrentError++;
   if (misses[CurrentError]){
     clearSqspellForm();
     populateSqspellForm();
   } else {
     if (ChangesMade || document.forms[0].words.value){
-      if (confirm("SpellCheck complete. Commit Changes?"))
+      if (confirm(ui_completed))
        sqspellCommitChanges();
-       else self.close();
+      else self.close();
     } else {
-      confirm ("No changes were made.");
+      confirm (ui_nochange);
       self.close();
     }
   }
 }
 
+/**
+ * This function updates the symbol locations after there have been
+ * word length changes in the lines. Otherwise SquirrelSpell barfs all
+ * over your message... ;)
+ *
+ * @param  lLine      line number on which the error occurs
+ * @param  lSymbol    symbol number at which error occurs
+ * @param  difference the difference in length between the old word
+ *                    and the new word. Can be negative or positive.
+ * @return            void
+ */
 function updateSymbol(lLine, lSymbol, difference){
-  // Now, I will admit that this is not the best way to do stuff,
-  // However that's the solution I've come up with.
-  // This function updates the symbol locations after there have been
-  // word length changes in the lines. Otherwise SquirrelSpell barfs all
-  // over your message... ;)
-  //
-  // If you are wondering why I didn't use two-dimensional arrays instead,
-  // well, sometimes there will be a long line with an error close to the
-  // end of it, so the coordinates would be something like 2,98 and 
-  // some Javascript implementations will create 98 empty members of an 
-  // array just to have a filled number 98. This is too resource-wasteful 
-  // and I have decided to go with the below solution instead. It takes 
-  // a little more processing, but it saves a lot on memory.
+  /** 
+   * Now, I will admit that this is not the best way to do stuff,
+   * However that's the solution I've come up with.
+   *
+   * If you are wondering why I didn't use two-dimensional arrays instead,
+   * well, sometimes there will be a long line with an error close to the
+   * end of it, so the coordinates would be something like 2,98 and 
+   * some Javascript implementations will create 98 empty members of an 
+   * array just to have a filled number 98. This is too resource-wasteful 
+   * and I have decided to go with the below solution instead. It takes 
+   * a little more processing, but it saves a lot on memory.
+   *
+   * It just looks heinous. In real life it's really nice and sane. ;)
+   */
        
   for (i=0; i<misses.length; i++){
     if(locations[i].indexOf(lLine + ":") >= 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<sqspell_lines.length; i++){
-      if (i!=1) newBody+="\r\n";
-      newBody += sqspell_lines[i];
-    }
-  } else {
-    newSubject = sqspell_lines.shift();
-    newBody = sqspell_lines.join("\n");
+  newSubject = sqspell_lines[0];
+  newBody = "";
+  for (i=1; i<sqspell_lines.length; i++){
+    if (i!=1) newBody+="\r\n";
+    newBody += sqspell_lines[i];
   }
-
+  
   opener.document.forms[0].subject.value=newSubject;
   opener.document.forms[0].body.value=newBody;
-       
-  // See if any words were added to the dictionary.
+  
+  /**
+   * See if any words were added to the dictionary.
+   */
   if (document.forms[0].words.value){
-    // yeppers
-    document.forms[0].sqspell_line_area.value="Now saving your personal dictionary... Please wait.";
-    // pass focus to the parent so we can do background save.
+    /**
+     * Yeppers.
+     */
+    document.forms[0].sqspell_line_area.value=ui_wait;
+    /**
+     * pass focus to the parent so we can do background save.
+     */
     window.opener.focus();
     document.forms[0].submit();
   } else {
-     self.close();
+    self.close();
   }
 }
index f47dfd9e89dfc7c01e0610bb360e4e99429c7f83..d5991fdf83ea7ae43e94fcd5fe4dd04589becd36 100644 (file)
 <?php
-   /**
-    **  check_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 is the main workhorse of SquirrelSpell. It submits
-    **  the message to the spell-checker, parses the output, and loads
-    **  the interface window.
-    **
-    **  $Id$
-    **/
-
-function SpellLink( $cod, $tit, $ln ) {
-
-    echo "<td><a href=\"javascript:$cod\"".
-         " title=\"$tit\">$ln</a>".
-         '</td>';
+/**
+ * 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 <icon@duke.edu> ($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 "<td><a href=\"javascript:$jscode\" "
+    . "title=\"$title\">$ln</a>"
+    . '</td>';
 }
 
-// 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<sizeof($sqspell_raw_lines); $i++){
-   if (trim($sqspell_raw_lines[$i]) == '--') break;
-   if(substr($sqspell_raw_lines[$i], 0, 1) != '>')
+/**
+ * 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<sizeof($sqspell_raw_lines); $i++){
+  /**
+   * See if the signature is starting, which will be a "--" on the
+   * single line (after trimming).
+   */
+  if (trim($sqspell_raw_lines[$i]) == '--'){
+    break;
+  }
+  /**
+   * See if this is quoted text. Don't check the quoted text, since
+   * it's no business of ours how badly our correspondents misspell
+   * stuff.
+   */
+  if(substr($sqspell_raw_lines[$i], 0, 1) != '>'){
     $sqspell_new_lines[$i] = ' ' . $sqspell_raw_lines[$i];
-    else $sqspell_new_lines[$i] = '';
- }
- $sqspell_new_text=implode("\n", $sqspell_new_lines);
+  } else {
+    $sqspell_new_lines[$i] = '';
+  }
+}
+/**
+ * $sqspell_new_lines array now contains the lines to submit to the
+ * spellchecker.
+ */
+$sqspell_new_text=implode("\n", $sqspell_new_lines);
 
- // Define the command used to spellcheck the document.
- $sqspell_command=$SQSPELL_APP[$sqspell_use_app];
- // For the simplicity's sake we'll put all text into a file
- // in attachment_dir directory, then cat it and pipe it to sqspell_command.
- // There are other ways to do it, including popen(), but it's unidirectional
- // and no fun at all.
- // NOTE: This will probably change in future releases of squirrelspell
- // for privacy reasons.
- //
- $floc = "$attachment_dir/$username_sqspell_data.txt";
- $fp=fopen($floc, 'w');
- fwrite($fp, $sqspell_new_text);
- fclose($fp);
- exec("cat $floc | $sqspell_command", $sqspell_output);
- unlink($floc);
+/**
+ * Define the command used to spellcheck the document.
+ */
+$sqspell_command=$SQSPELL_APP[$sqspell_use_app];
+/**
+ * For the simplicity's sake we'll put all text into a file in
+ * attachment_dir directory, then cat it and pipe it to
+ * sqspell_command.  There are other ways to do it, including popen(),
+ * but it's unidirectional and no fun at all.  
+ *
+ * The name of the file is an md5 hash of the message itself plus
+ * microtime. This prevents symlink attacks. The loop is here to
+ * further enhance this feature, and make sure we don't overwrite
+ * someone else's data, although the possibility of this happening is
+ * QUITE remote.
+ */
+do {
+  $floc = "$attachment_dir/" . md5($sqspell_new_text . microtime());
+} while (file_exists($floc));
+/**
+ * Write the contents to the file.
+ */
+$fp=fopen($floc, 'w');
+fwrite($fp, $sqspell_new_text);
+fclose($fp);
+/**
+ * Execute ispell/aspell and catch the output.
+ */
+exec("cat $floc | $sqspell_command", $sqspell_output);
+/**
+ * Remove the temp file.
+ */
+unlink($floc);
 
- // Load the user dictionary.
- $words=sqspell_getLang(sqspell_getWords(), $sqspell_use_app);
- // define some variables.
- $current_line=0;
- $missed_words=Array();
- $misses = Array();
- $locations = Array();
- $errors=0;
- // Now we process the output of sqspell_command (ispell or aspell
- // in ispell compatibility mode, whichever).
- for ($i=0; $i<sizeof($sqspell_output); $i++){
+/**
+ * Load the user dictionary.
+ */
+$words=sqspell_getLang(sqspell_getWords(), $sqspell_use_app);
+/**
+ * Define some variables to be used during the processing.
+ */
+$current_line=0;
+$missed_words=Array();
+$misses = Array();
+$locations = Array();
+$errors=0;
+/**
+ * Now we process the output of sqspell_command (ispell or aspell in
+ * ispell compatibility mode, whichever). I'm going to be scarce on
+ * comments here, since you can just look at the ispell/aspell output
+ * and figure out what's going on. ;) The best way to describe this is
+ * "Dark Magic".
+ */
+for ($i=0; $i<sizeof($sqspell_output); $i++){
   switch (substr($sqspell_output[$i], 0, 1)){
+  /**
+   * Line is empty.
+   * Ispell adds empty lines when an end of line is reached
+   */
   case '':
-    // Ispell adds empty lines when an end of line is reached
     $current_line++;
-    break;
-
+  break;
+  /**
+   * Line begins with "&".
+   * This means there's a misspelled word and a few suggestions.
+   */
   case '&':
-    // This means there's a misspelled word and a few suggestions.
     list($left, $right) = explode(": ", $sqspell_output[$i]);
     $tmparray = explode(" ", $left);
     $sqspell_word=$tmparray[1];
-    // Check if the word is in user dictionary.
+    /**
+     * Check if the word is in user dictionary.
+     */
     if (!$SQSPELL_EREG("\n$sqspell_word\n", $words)){
-     $sqspell_symb=intval($tmparray[3])-1;
-     if (!$misses[$sqspell_word]) {
+      $sqspell_symb=intval($tmparray[3])-1;
+      if (!$misses[$sqspell_word]) {
         $misses[$sqspell_word] = $right;
         $missed_words[$errors] = $sqspell_word;
         $errors++;
-     }
-     if ($locations[$sqspell_word])
+      }
+      if ($locations[$sqspell_word]){
         $locations[$sqspell_word] .= ', ';
-     $locations[$sqspell_word] .= "$current_line:$sqspell_symb";
+      }
+      $locations[$sqspell_word] .= "$current_line:$sqspell_symb";
     }
-    break;
-
+  break;
+  /**
+   * Line begins with "#".
+   * This means a misspelled word and no suggestions.
+   */
   case '#':
-    // This means a misspelled word and no suggestions.
     $tmparray = explode(" ", $sqspell_output[$i]);
     $sqspell_word=$tmparray[1];
-    // Check if the word is in user dictionary.
+    /**
+     * 
+     * Check if the word is in user dictionary.
+     */
     if (!$SQSPELL_EREG("\n$sqspell_word\n", $words)){
-     $sqspell_symb=intval($tmparray[2])-1;
-     if (!$misses[$sqspell_word]) {
-        $misses[$sqspell_word] = '_NONE';
-        $missed_words[$errors] = $sqspell_word;
-        $errors++;
-     }
-     if ($locations[$sqspell_word]) $locations[$sqspell_word] .= ', ';
-     $locations[$sqspell_word] .= "$current_line:$sqspell_symb";
+      $sqspell_symb=intval($tmparray[2])-1;
+      if (!$misses[$sqspell_word]) {
+       $misses[$sqspell_word] = '_NONE';
+       $missed_words[$errors] = $sqspell_word;
+       $errors++;
+      }
+      if ($locations[$sqspell_word]) $locations[$sqspell_word] .= ', ';
+      $locations[$sqspell_word] .= "$current_line:$sqspell_symb";
     }
-    break;
+  break;
   }
- }
-
- if ($errors){
-  // So, there are errors
-  // This is the only place where the generic GUI-wrapper is not
-  // called, but generated right here. This is due to the complexity
-  // of the output.
-
-  echo "<html>\n".
-       "<head>\n".
-       '<title>' . _("SquirrelSpell Results") . '</title>';
-    if ($theme_css != '') {
-        echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">\n";
-    }
-    // Load the spelling errors into JavaScript arrays
-    echo "<script type=\"text/javascript\">\n".
-         "<!--\n";
+}
 
-    $sqspell_lines = explode("\n", $sqspell_text);
-    // All lines of the message
-    echo "var sqspell_lines=new Array();\n";
-    for ($i=0; $i<sizeof($sqspell_lines); $i++){
-      echo "sqspell_lines[$i] = \"" . chop(addslashes($sqspell_lines[$i])) . "\";\n";
-    }
+if ($errors){
+  /**
+   * So, there are errors
+   * This is the only place where the generic GUI-wrapper is not
+   * called, but generated right here. This is due to the complexity
+   * of the output.
+   */
+  echo "<html>\n"
+    . "<head>\n"
+    . '<title>' . _("SquirrelSpell Results") . '</title>';
+  /**
+   * Check if there are user-defined stylesheets.
+   */
+  if ($theme_css != '') {
+    echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">\n";
+  }
+  /**
+   * Load the spelling errors into JavaScript arrays
+   * (More dark magic!)
+   */
+  echo "<script type=\"text/javascript\">\n"
+    . "<!--\n";
+  
+  $sqspell_lines = explode("\n", $sqspell_text);
+  /**
+   * The javascript array sqspell_lines[] contains all lines of
+   * the message we've been checking.
+   */
+  echo "var sqspell_lines=new Array();\n";
+  for ($i=0; $i<sizeof($sqspell_lines); $i++){
+    echo "sqspell_lines[$i] = \"" 
+      . chop(addslashes($sqspell_lines[$i])) . "\";\n";
+  }  
+  echo "\n\n";
 
-    echo "\n\n";
-    // Misses are all misspelled words
-    echo "var misses=new Array();\n";
-    for ($i=0; $i<sizeof($missed_words); $i++){
-       echo "misses[$i] = \"" . $missed_words[$i] . "\";\n";
-    }
+  /**
+   * The javascript array misses[] contais all misspelled words.
+   */
+  echo "var misses=new Array();\n";
+  for ($i=0; $i<sizeof($missed_words); $i++){
+    echo "misses[$i] = \"" . $missed_words[$i] . "\";\n";
+  }
+  echo "\n\n";
+  
+  /**
+   * Suggestions are (guess what!) suggestions for misspellings
+   */
+  echo "var suggestions = new Array();\n";
+  $i=0;
+  while (list($word, $value) = each($misses)){
+    if ($value=='_NONE') $value='';
+    echo "suggestions[$i] = \"$value\";\n";
+    $i++;
+  }
+  echo "\n\n";
 
-    echo "\n\n";
-    // Suggestions are (guess what!) suggestions for misspellings
-    echo "var suggestions = new Array();\n";
-    $i=0;
-    while (list($word, $value) = each($misses)){
-       if ($value=='_NONE') $value='';
-       echo "suggestions[$i] = \"$value\";\n";
-       $i++;
-    }
+  /**
+   * Locations are where those misspellings are located, line:symbol
+   */
+  echo "var locations= new Array();\n";
+  $i=0;
+  while (list($word, $value) = each($locations)){
+    echo "locations[$i] = \"$value\";\n";
+    $i++;
+  }
 
-    echo "\n\n";
-    // Locations are where those misspellings are located, line:symbol
-    echo "var locations= new Array();\n";
-    $i=0;
-    while (list($word, $value) = each($locations)){
-       echo "locations[$i] = \"$value\";\n";
-       $i++;
-    }
-    // Why isn't there a booger fairy?
-    echo "//-->\n".
-         "</script>\n".
-         "<script src=\"js/check_me.js\" type=\"text/javascript\"></script>\n".
-         "</head>\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 "<body bgcolor=\"$color[4]\" text=\"$color[8]\" link=\"$color[7]\" alink=\"$color[7]\" vlink=\"$color[7]\" onload=\"populateSqspellForm()\">\n".
-         '<table width="100%" border="0" cellpadding="2">'.
-         "<tr><td bgcolor=\"$color[9]\" align=center><b>";
-    printf( _("Found %s errors"), $errors );
-?></b></td></tr>
-   <tr><td><hr></td></tr>
-   <tr><td>
-   <form method="post">
-   <input type="hidden" name="MOD" value="forget_me_not">
-   <input type="hidden" name="words" value="">
-   <input type="hidden" name="sqspell_use_app" value="<?php echo $sqspell_use_app ?>">
-   <table border="0" width="100%">
-    <tr align="center">
-     <td colspan="4">
-<?php
-    $sptag = "<span style=\"background-color: $color[9]\">";
-    echo $sptag . _("Line with an error:") . '</span>';
-?>
-      <br>
-      <textarea name="sqspell_line_area" cols="50" rows="3" wrap="hard" onfocus="this.blur()"></textarea>
-     </td>
-    </tr>
-    <tr valign="middle">
-     <td align="right" width="25%">
-<?php
-    echo $sptag . _("Error:") . '</span>';
-?>
-     </td>
-     <td align="left" width="25%">
-      <input name="sqspell_error" size="10" value="" onfocus="this.blur()">
-     </td>
-     <td align="right" width="25%">
-<?php
-    echo $sptag . _("Suggestions:") . '</span>';
-?>
-     </td>
-     <td align="left" width="25%">
-      <select name="sqspell_suggestion" onchange="if (this.options[this.selectedIndex].value != '_NONE') document.forms[0].sqspell_oruse.value=this.options[this.selectedIndex].value">
-<?php
-    echo '<option>' . _("Suggestions") . '</option>';
-?>
-      </select>
-     </td>
-    </tr>
-    <tr>
-     <td align="right">
-<?php
-    echo $sptag . _("Change to:") . '</span>';
-?>
-     </td>
-     <td align="left">
-      <input name="sqspell_oruse" size="15" value=""
-        onfocus="if(!this.value) this.value=document.forms[0].sqspell_error.value">
-     </td>
-     <td align="right">
-<?php
-    echo $sptag . _("Occurs times:") . '</span>';
-?>
-     </td>
-     <td align="left">
-      <input name="sqspell_likethis" size=3 value="" onfocus="this.blur()">
-     </td>
-    </tr>
-   </td></tr>
-   <tr><td colspan="4"><hr></td></tr>
-    <tr>
-     <td colspan="4">
-      <table border="0" cellpadding="0" cellspacing="3" width="100%">
-<?php
-    echo "<tr align=center bgcolor=\"$color[9]\">";
-
-    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"
+    . "</script>\n"
+    . "<script src=\"js/check_me.js\" type=\"text/javascript\"></script>\n"
+    . "</head>\n";
+  
+  echo "<body bgcolor=\"$color[4]\" text=\"$color[8]\" link=\"$color[7]\" "
+    . "alink=\"$color[7]\" vlink=\"$color[7]\" "
+    . "onload=\"populateSqspellForm()\">\n";
+  ?>
+  <table width="100%" border="0" cellpadding="2">
+   <tr>
+    <td bgcolor="<?php echo $color[9] ?>" align="center">
+     <b>
+      <?php printf( _("Found %s errors"), $errors ) ?>
+     </b>
+    </td>
+   </tr>
+   <tr>
+    <td>
+      <hr>
+    </td>
+   </tr>
+   <tr>
+    <td>
+     <form method="post">
+      <input type="hidden" name="MOD" value="forget_me_not" />
+      <input type="hidden" name="words" value="" />
+      <input type="hidden" name="sqspell_use_app" 
+             value="<?php echo $sqspell_use_app ?>" />
+      <table border="0" width="100%">
+       <tr align="center">
+        <td colspan="4">
+         <?php
+          $sptag = "<span style=\"background-color: $color[9]\">";
+          echo $sptag . _("Line with an error:") . '</span>';
+         ?>
+         <br />
+         <textarea name="sqspell_line_area" cols="50" rows="3" 
+                   wrap="hard" onfocus="this.blur()"></textarea>
+        </td>
+       </tr>
+       <tr valign="middle">
+        <td align="right" width="25%">
+         <?php
+          echo $sptag . _("Error:") . '</span>';
+         ?>
+        </td>
+        <td align="left" width="25%">
+         <input name="sqspell_error" size="10" value="" 
+                onfocus="this.blur()" />
+        </td>
+        <td align="right" width="25%">
+         <?php
+          echo $sptag . _("Suggestions:") . '</span>';
+         ?>
+        </td>
+        <td align="left" width="25%">
+         <select name="sqspell_suggestion" 
+                 onchange="if (this.options[this.selectedIndex].value != '_NONE') document.forms[0].sqspell_oruse.value=this.options[this.selectedIndex].value">
+          <?php
+           echo '<option>' . _("Suggestions") . '</option>';
+          ?>
+         </select>
+        </td>
+       </tr>
+       <tr>
+        <td align="right">
+         <?php
+          echo $sptag . _("Change to:") . '</span>';
+         ?>
+        </td>
+        <td align="left">
+         <input name="sqspell_oruse" size="15" value=""
+                onfocus="if(!this.value) this.value=document.forms[0].sqspell_error.value">
+        </td>
+        <td align="right">
+         <?php
+          echo $sptag . _("Occurs times:") . '</span>';
+         ?>
+        </td>
+        <td align="left">
+         <input name="sqspell_likethis" size=3 value="" onfocus="this.blur()">
+        </td>
+       </tr>
+        <!-- hello? What is this? </td></tr> -->
+       <tr>
+        <td colspan="4"><hr></td>
+       </tr>
+       <tr>
+        <td colspan="4">
+         <table border="0" cellpadding="0" cellspacing="3" width="100%">
+         <tr align="center" bgcolor="<?php echo $color[9] ?>">
+           <?php
+           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"));
+           ?>
+          </tr>
+         </table>
+        </td>
+       </tr>
+       <tr>
+        <td colspan="4"><hr></td>
+       </tr>
+       <tr>
+       <td colspan="4" align="center" bgcolor="<?php echo $color[9] ?>">
+        <?php
+         echo '<input type="button" value="  '
+           . _("Close and Commit")
+           . '  " onclick="if (confirm(\''
+           . _("The spellcheck is not finished. Really close and commit changes?")
+           . '\')) sqspellCommitChanges()">'
+            . ' <input type="button" value="  '
+            . _("Close and Cancel")
+            . '  " onclick="if (confirm(\''
+            . _("The spellcheck is not finished. Really close and discard changes?")
+            . '\')) self.close()">';
+         ?>
+        </td>
        </tr>
       </table>
-     </td>
-    </tr>
-    <tr><td colspan="4"><hr></td></tr>
-    <tr>
-<?php
-
-    echo "<td colspan=4 align=center bgcolor=\"$color[9]\">" .
-         '<input type="button" value="  ' .
-         _("Close and Commit") .
-         '  " onclick="if (confirm(\''.
-         _("The spellcheck is not finished. Really close and commit changes?").
-         '\')) sqspellCommitChanges()">'.
-         ' <input type="button" value="  '.
-         _("Close and Cancel") .
-         '  " onclick="if (confirm(\''.
-         _("The spellcheck is not finished. Really close and discard changes?").
-         '\')) self.close()">';
-?>
-     </td>
-    </tr>
-   </table>
-   </form>
-   </td></tr>
+     </form>
+    </td>
+   </tr>
   </table>
-  </body>
-  </html>
+  </body></html>
   <?php
- } else {
-   // AREN'T YOU SUCH A KNOW-IT-ALL!
-   $msg="<form onsubmit=\"return false\"><div align=\"center\"><input type=\"submit\" value=\"  " . _("Close") . "  \" onclick=\"self.close()\"></div></form>";
-   sqspell_makeWindow(null, _("No errors found"), null, $msg);
- }
+} else {
+  /**
+   * AREN'T YOU SUCH A KNOW-IT-ALL!
+   */
+  $msg="<form onsubmit=\"return false\"><div align=\"center\">"
+     . "<input type=\"submit\" value=\"  " . _("Close") 
+     . "  \" onclick=\"self.close()\"></div></form>";
+  sqspell_makeWindow(null, _("No errors found"), null, $msg);
+}
+
+/**
+ * For Emacs weenies:
+ * Local variables:
+ * mode: php
+ * End:
+ */
 ?>
index 4efc9002ec9fe76f3763e9447b96827fd9d3bf9f..6dd1da97f8a9ed524ed7c240509c82217e69d0f8 100644 (file)
@@ -1,45 +1,74 @@
 <?php
+/**
+ * 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$
+ *
+ * @author Konstantin Riabitsev <icon@duke.edu> ($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='<p>'
+       .  _("Your personal dictionary has been <strong>encrypted</strong> and is now stored in an <strong>encrypted format</strong>.")
+       . '</p>';
+  break;
+  case 'decrypt':
+    /**
+     * Let's decrypt the file and save it as plain text.
+     */
+    $words=sqspell_getWords();
+    /** 
+     * Flip the flag and tell the sqspell_writeWords() function that we
+     * want to save it plaintext.
+     */
+    $SQSPELL_CRYPTO=false;
+    sqspell_writeWords($words);
+    $msg='<p>'
+       . _("Your personal dictionary has been <strong>decrypted</strong> and is now stored as <strong>clear text</strong>.") 
+       . '</p>';
+  break;
+  
+  case "":
+    /**
+     * Wait, this shouldn't happen! :)
+     */
+    $msg = "<p>No action requested.</p>";
+  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='<p>' .
-           _("Your personal dictionary has been <strong>encrypted</strong> and is now stored in an <strong>encrypted format</strong>.").
-           '</p>';
-     break;
-    
-     case 'decrypt':
-      // Decrypt the file and save plain text.
-      $words=sqspell_getWords();
-      // flip the flag.
-      $SQSPELL_CRYPTO=false;
-      sqspell_writeWords($words);
-      $msg='<p>' . 
-           _("Your personal dictionary has been <strong>decrypted</strong> and is now stored as <strong>clear text</strong>.") . '</p>';
-     break;
-     
-     case "":
-      // Wait, this shouldn't happen! :)
-      $msg = "<p>No action requested.</p>";
-     break;
-    }
-     sqspell_makePage( _("Personal Dictionary Crypto Settings"), null, $msg);
 ?>
index 47dae869fdd8b4210a6324aebd85a7081ec22cd8..6a1926969da7200bbad5a5f4b77843d5be2ee7c7 100644 (file)
@@ -1,64 +1,90 @@
 <?php
+/**
+ * crypto_badkey.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 tries to decrypt the user dictionary with a newly provided
+ * old password, or erases the file if everything else fails. :(         
+ *
+ * $Id$
+ *
+ * @author Konstantin Riabitsev <icon@duke.edu> ($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='<p>' . _("Your personal dictionary was erased.") . '</p>';
-            sqspell_makePage(_("Dictionary Erased"), null, $msg);
-        } else {
-            $msg = '<p>' . ("Your personal dictionary was erased. Please close this window and click \"Check Spelling\" button again to start your spellcheck over." ) .
-                   '</p> '.
-                   '<p align="center"><form>'.
-                   '<input type="button" value=" ' _("Close this Window") . ' " onclick="self.close()">'.
-                   '</form></p>';
-            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 = '<p>' .
-                   _("Your personal dictionary was re-encrypted successfully. Now "
-                     "return to the &quot;SpellChecker options&quot; menu and make your selection "
-                     "again." ) . '</p>';
-            sqspell_makePage(_("Successful Re-encryption"), null, $msg);
-        } else {
-            $msg = '<p>'.
-                   _("Your personal dictionary was re-encrypted successfully. Please "
-                     "close this window and click \"Check Spelling\" button again to start your "
-                     "spellcheck over.") . '</p>' .
-                   '<form><p align="center"><input type="button" value=" ' . _("Close this Window") . ' "'.
-                   'onclick="self.close()"></p></form>';
-            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='<p>' . _("Your personal dictionary was erased.") . '</p>';
+    sqspell_makePage(_("Dictionary Erased"), null, $msg);
+  } else {
+    /**
+     * The _("Your....") has to be on one line. Otherwise xgettext borks
+     * on getting the strings.
+     */
+    $msg = '<p>' 
+       . _("Your personal dictionary was erased. Please close this window and click \"Check Spelling\" button again to start your spellcheck over.")
+       . '</p> '
+       . '<p align="center"><form>'
+       . '<input type="button" value=" '
+       . _("Close this Window") . ' " onclick="self.close()">'
+       . '</form></p>';
+    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 = '<p>'
+       . _("Your personal dictionary was re-encrypted successfully. Now return to the &quot;SpellChecker options&quot; menu and make your selection again." ) 
+       . '</p>';
+    sqspell_makePage(_("Successful Re-encryption"), null, $msg);
+  } else {
+    $msg = '<p>'
+       . _("Your personal dictionary was re-encrypted successfully. Please close this window and click \"Check Spelling\" button again to start your spellcheck over.") 
+       . '</p><form><p align="center"><input type="button" value=" ' 
+       . _("Close this Window") . ' "'
+       . 'onclick="self.close()"></p></form>';
+    sqspell_makeWindow(null, _("Dictionary re-encrypted"), null, $msg);
+  }
+  exit;
+}
+
+/**
+ * For Emacs weenies:
+ * Local variables:
+ * mode: php
+ * End:
+ */    
 ?>
index 1d53633648bd15651f0f7316b876e87d5e0a8414..ed8973603d28092b6d012efb7248a4cb7ae82a5b 100644 (file)
 <?php
+/**
+ * edit_dic.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 lets the user edit his/her personal dictionary.
+ *
+ * $Id$
+ *
+ * @author Konstantin Riabitsev <icon@duke.edu> ($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, '<p>' . _("No words in your personal dictionary.") . '</p>');
-    } else {
-        // We're loaded with booty.
-        $pre_msg = '<p>' . _("Please check any words you wish to delete from your dictionary.") . "</p>\n";
-        $pre_msg .= "<table border=\"0\" width=\"95%\" align=\"center\">\n";
-        $langs=sqspell_getSettings($words);
-        for ($i=0; $i<sizeof($langs); $i++){
-            $lang_words = sqspell_getLang($words, $langs[$i]);
-            if ($lang_words){
-                // No words in this dictionary.
-                if (!$msg) {
-                    $msg = $pre_msg;
-                }
-                $msg .= "<tr bgcolor=\"$color[0]\" align=\"center\"><th>" . 
-                        sprintf( _("%s dictionary"), $langs[$i] ) . '</th></tr>'.
-                        '<tr><td align="center">'.
-                        '<form method="post">'.
-                        '<input type="hidden" name="MOD" value="forget_me">'.
-                        '<input type="hidden" name="sqspell_use_app" value="' . $langs[$i] . '">'.
-                        '<table border="0" width="95%" align="center">'.
-                        '<tr>'.
-                        "<td valign=\"top\">\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<sizeof($words_ary); $j++){
-                    if ($j==intval(sizeof($words_ary)/3) || $j==intval(sizeof($words_ary)/3*2))
-                       $msg .= "</td><td valign=\"top\">\n";
-                    $msg .= "<input type=\"checkbox\" name=\"words_ary[]\" value=\"$words_ary[$j]\"> $words_ary[$j]<br>";
-                }
-                $msg .= '</td></tr></table></td></tr>' .
-                        "<tr bgcolor=\"$color[0]\" align=\"center\"><td>".
-                        '<input type="submit" value="' . _("Delete checked words") . '"></form>'.
-                        '</td></tr><tr><td><hr>'.
-                        "</td></tr>\n";
-            }
-        }
-        // Check if all dictionaries were empty.
-        if (!$msg) {
-            $msg = '<p>' . _("No words in your personal dictionary.") . '</p>';
-        } else {
-            $msg .= '</table>';
-        }
-        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, 
+                  '<p>' . _("No words in your personal dictionary.") 
+                  . '</p>');
+} else {
+  /**
+   * We're loaded with booty.
+   */
+  $pre_msg = '<p>' 
+     . _("Please check any words you wish to delete from your dictionary.") 
+     . "</p>\n";
+  $pre_msg .= "<table border=\"0\" width=\"95%\" align=\"center\">\n";
+  /**
+   * Get how many dictionaries this user has defined.
+   */
+  $langs=sqspell_getSettings($words);
+  for ($i=0; $i<sizeof($langs); $i++){
+    /**
+     * Get all words from this language dictionary.
+     */
+    $lang_words = sqspell_getLang($words, $langs[$i]);
+    if ($lang_words){
+      /**
+       * There are words in this dictionary. If this is the first
+       * language we're processing, prepend the output with the
+       * "header" message.
+       */
+      if (!$msg) {
+       $msg = $pre_msg;
+      }
+      $msg .= "<tr bgcolor=\"$color[0]\" align=\"center\"><th>"
+        . sprintf( _("%s dictionary"), $langs[$i] ) . '</th></tr>'
+        . '<tr><td align="center">'
+        . '<form method="post">'
+        . '<input type="hidden" name="MOD" value="forget_me">'
+        . '<input type="hidden" name="sqspell_use_app" value="' 
+        . $langs[$i] . '">'
+        . '<table border="0" width="95%" align="center">'
+        . '<tr>'
+        . "<td valign=\"top\">\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<sizeof($words_ary); $j++){
+       if ($j==intval(sizeof($words_ary)/3) 
+           || $j==intval(sizeof($words_ary)/3*2)){
+         $msg .= "</td><td valign=\"top\">\n";
+       }
+       $msg .= "<input type=\"checkbox\" name=\"words_ary[]\" "
+          . "value=\"$words_ary[$j]\"> $words_ary[$j]<br>";
+      }
+      $msg .= '</td></tr></table></td></tr>'
+        . "<tr bgcolor=\"$color[0]\" align=\"center\"><td>".
+        . '<input type="submit" value="' . _("Delete checked words") 
+        . '"></form>'
+        . '</td></tr><tr><td><hr>'
+        . "</td></tr>\n";
     }
+  }
+  /**
+   * Check if all dictionaries were empty.
+   */
+  if (!$msg) {
+    $msg = '<p>' . _("No words in your personal dictionary.") . '</p>';
+  } else {
+    $msg .= '</table>';
+  }
+  sqspell_makePage(_("Edit your Personal Dictionary"), null, $msg);
+}
+
+/**
+ * For Emacs weenies:
+ * Local variables:
+ * mode: php
+ * End:
+ */
 
 ?>
index 4e94548f772a1dd942c400f4765a2e5556d59d6c..5311303891b82fdc786214e73de200d832d9f0b5 100644 (file)
@@ -1,47 +1,73 @@
 <?php
+/**
+ * enc_setup.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 shows the user a nice invitation to encrypt or decypt        
+ * his/her personal dictionary and explains the caveats of such a decision. 
+ *
+ * $Id$
+ *
+ * @author Konstantin Riabitsev <icon@duke.edu> ($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 = 
+     _("<p>Your personal dictionary is <strong>currently encrypted</strong>. 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.</p> <p><strong>ATTENTION:</strong> 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.</p>")
+     . '<form method="post" onsubmit="return checkMe()">'
+     . '<input type="hidden" name="MOD" value="crypto">'
+     . '<p align="center"><input type="checkbox" name="action" '
+     . 'value="decrypt"> '
+     . _("Please decrypt my personal dictionary and store it in a clear-text format." )
+     . '</p>'
+     . '<p align="center"><input type="submit" value=" '
+     . _("Change crypto settings")
+     . ' "></p>'
+     . '</form>';
+} else {
+  /**
+   * Current format is clear text.
+   * Unfortunately, the following text needs to be all on one line,
+   * unless someone fixes xgettext. ;(
+   */
+  $msg = 
+     _("<p>Your personal dictionary is <strong>currently not encrypted</strong>. 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).</p> <strong>ATTENTION:</strong> If you decide to encrypt your personal dictionary, you must remember that it gets &quot;hashed&quot; 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.</p>")
+     . '<form method="post" onsubmit="return checkMe()">'
+     . '<input type="hidden" name="MOD" value="crypto">'
+     . '<p align="center"><input type="checkbox" name="action" '
+     . 'value="encrypt"> '
+     . _("Please encrypt my personal dictionary and store it in an encrypted format.")
+     . '</p>'
+     . '<p align="center"><input type="submit" value=" '
+     . _("Change crypto settings") . ' "></p>'
+     . '</form>';
+}
+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 = 
-        _("<p>Your personal dictionary is <strong>currently encrypted</strong>. 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.</p> <p><strong>ATTENTION:</strong> 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.</p>") .
-            '<form method="post" onsubmit="return checkMe()">'.
-            '<input type="hidden" name="MOD" value="crypto">'.
-            '<p align="center"><input type="checkbox" name="action" value="decrypt"> '.
-            _("Please decrypt my personal dictionary and store it in a clear-text format." ) .
-            '</p>'.
-            '<p align="center"><input type="submit" value=" ' . 
-            _("Change crypto settings") .
-            ' "></p>'.
-            '</form>';
-    } else {
-        // current format is clear text.
-        $msg = 
-        _("<p>Your personal dictionary is <strong>currently not encrypted</strong>. 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).</p> <strong>ATTENTION:</strong> If you decide to encrypt your personal dictionary, you must remember that it gets &quot;hashed&quot; 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.</p>").
-            '<form method="post" onsubmit="return checkMe()">'.
-            '<input type="hidden" name="MOD" value="crypto">'.
-            '<p align="center"><input type="checkbox" name="action" value="encrypt"> '.
-            _("Please encrypt my personal dictionary and store it in an encrypted format.") .
-            '</p>'.
-            '<p align="center"><input type="submit" value=" '.
-            _("Change crypto settings") . ' "></p>'.
-            '</form>';
-    }
-    sqspell_makePage(_("Personal Dictionary Crypto Settings"), "crypto_settings.js", $msg);
 ?>
index 067891efa767e485deda65936fd2cf55e5d06b86..cdfa6abe93d24775af2114cc9d6603c84d533714 100644 (file)
@@ -1,59 +1,87 @@
 <?php
+/**
+ * forget_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 deletes the words from the user dictionary. Called
+ * after EDIT_DIC module.                                        
+ *
+ * $Id$
+ *
+ * @author Konstantin Riabitsev <icon@duke.edu> ($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 = '<p>'.
-               sprintf( _("Deleting the following entries from <strong>%s</strong> dictionary:", $sqspell_use_app ) .
-               '</p>' .
-               "<ul>\n";
-        for ($i=0; $i<sizeof($words_ary); $i++){
-            // remove word by word...
-            $lang_words=str_replace("$words_ary[$i]\n", "", $lang_words);
-            $msg .= "<li>$words_ary[$i]</li>\n";
-        }
-        $new_words_ary=split("\n", $lang_words);
-        // Wipe this lang, if only 2 members in array (no words left).
-        if (sizeof($new_words_ary)<=2) {
-            $lang_words='';
-        }
-        $new_lang_words = $lang_words;
-        // process the stuff and write the dic back.
-        $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<sizeof($langs); $i++){
-            if ($langs[$i]==$sqspell_use_app) {
-              $lang_words = $new_lang_words;
-            } else {
-                $lang_words = sqspell_getLang($words, $langs[$i]);
-            }
-            if ($lang_words) {
-                $words_dic .= $lang_words;
-            }
-        }
-        $words_dic .= "# End\n";
-        sqspell_writeWords($words_dic);
-        $msg .= '</ul>' .
-                '<p>' _("All done!") . "</p>\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 = '<p>'
+     . sprintf(_("Deleting the following entries from <strong>%s</strong> dictionary:", $sqspell_use_app)) .
+     . '</p>'
+     . "<ul>\n";
+  for ($i=0; $i<sizeof($words_ary); $i++){
+    /**
+     * Remove word by word...
+     */
+    $lang_words=str_replace("$words_ary[$i]\n", "", $lang_words);
+    $msg .= "<li>$words_ary[$i]</li>\n";
+  }
+  $new_words_ary=split("\n", $lang_words);
+  /**
+   * Wipe this lang, if only 2 members in array (no words left).
+   * # Language
+   * # End
+   */
+  if (sizeof($new_words_ary)<=2) {
+    $lang_words='';
+  }
+  $new_lang_words = $lang_words;
+  /**
+   * Write the dictionary back to the disk.
+   */
+  $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<sizeof($langs); $i++){
+    /**
+     * Only rewrite the contents of the selected language.
+     * Otherwise just write the contents back.
+     */
+    if ($langs[$i]==$sqspell_use_app) {
+      $lang_words = $new_lang_words;
     } else {
-        // Click on some words first, Einstein!
-        sqspell_makePage(_("Personal Dictionary"), null, '<p>' . _("No changes requested.") . '</p>');
+      $lang_words = sqspell_getLang($words, $langs[$i]);
+    }
+    if ($lang_words) {
+      $words_dic .= $lang_words;
     }
-    
+  }
+  $words_dic .= "# End\n";
+  sqspell_writeWords($words_dic);
+  $msg .= '</ul><p>' _("All done!") . "</p>\n";
+  sqspell_makePage(_("Personal Dictionary Updated"), null, $msg);
+} else {
+  /**
+   * Click on some words first, Einstein!
+   */
+  sqspell_makePage(_("Personal Dictionary"), null, 
+                  '<p>' . _("No changes requested.") . '</p>');
+}
+
+/**
+ * For Emacs weenies:
+ * Local variables:
+ * mode: php
+ * End:
+ */    
 ?>
index 4b14d58eee2d6f6635bfc69aeed75c2402202920..eda679ab03b0cafe3029bf47a7f16f7a08f47eb3 100644 (file)
@@ -1,53 +1,80 @@
 <?php 
+/**
+ * forget_me_not.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 saves the added words into the user dictionary. Called
+ * after CHECK_ME module.                                            
+ *
+ * $Id$
+ *
+ * @author Konstantin Riabitsev <icon@duke.edu> ($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<sizeof($langs); $i++){
-            $lang_words=sqspell_getLang($words, $langs[$i]);
-            if ($langs[$i]==$sqspell_use_app){
-               if (!$lang_words) {
-                   $lang_words="# $langs[$i]\n";
-               }
-               $lang_words .= $new_words;
-            }
-            $words_dic .= $lang_words;
-        }
-        $words_dic .= "# End\n";
+global $words, $SQSPELL_VERSION, $SQSPELL_APP_DEFFAULT, $sqspell_use_app;
+/**
+ * Because of the nature of Javascript, there is no way to efficiently
+ * pass an array. Hence, the words will arrive as a string separated by
+ * "%". To get the array, we explode the "%"'s.
+ * Dirty: yes. Is there a better solution? Let me know. ;)
+ */
+$new_words = ereg_replace("%", "\n", $words);
+/**
+ * Load the user dictionary and see if there is anything in it.
+ */
+$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<sizeof($langs); $i++){
+    $lang_words=sqspell_getLang($words, $langs[$i]);
+    if ($langs[$i]==$sqspell_use_app){
+      if (!$lang_words) {
+       $lang_words="# $langs[$i]\n";
+      }
+      $lang_words .= $new_words;
     }
+    $words_dic .= $lang_words;
+  }
+  $words_dic .= "# End\n";
+}
     
-    // 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 = '<form onsubmit="return false"><div align="center"><input type="submit" value="  '.
-           _("Close") . '  " onclick="self.close()"></div></form>';
-    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 = '<form onsubmit="return false"><div align="center">'
+   . '<input type="submit" value="  '
+   . _("Close") . '  " onclick="self.close()"></div></form>';
+sqspell_makeWindow($onload, _("Personal Dictionary Updated"), null, $msg);
+
+/**
+ * For Emacs weenies:
+ * Local variables:
+ * mode: php
+ * End:
+ */
+
 ?>
index 67b934cfbf39fea791b216041871d6d435a42dc0..c96022ff455e38c1066164457654c8daaf76c06e 100644 (file)
@@ -1,50 +1,66 @@
 <?php
+/**
+ * init.mod 
+ * ---------
+ * 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$
+ *
+ * @author Konstantin Riabitsev <icon@duke.edu> ($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 = '<form method="post">'.
-           '<input type="hidden" name="MOD" value="check_me">'.
-           '<input type="hidden" name="sqspell_text">'.
-           '<p align="center">';
-    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...") .
-                '</p>'.
-                "<input type=\"hidden\" name=\"sqspell_use_app\" value=\"$langs[0]\">";
-    } 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:").
-               '</p><p align="center">' .
-               '<select name="sqspell_use_app">';
-        for ($i=0; $i<sizeof($langs); $i++){
-           $msg .= "<option";
-           if (!$i) {
-               $msg .= ' selected';
-           }
-           $msg .= " value=\"$langs[$i]\"> " . _($langs[$i]) . "</option>\n";
-        }
-        
-        $msg .= ' </select>'.
-                '<input type="submit" value="' . _("Go") . '">'.
-                '</p>';
+/**
+ * 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 = '<form method="post">'
+  . '<input type="hidden" name="MOD" value="check_me">'
+  . '<input type="hidden" name="sqspell_text">'
+  . '<p align="center">';
+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...")
+    . '</p>'
+    . "<input type=\"hidden\" name=\"sqspell_use_app\" value=\"$langs[0]\">";
+} 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:")
+    . '</p><p align="center">'
+    . '<select name="sqspell_use_app">';
+  for ($i=0; $i<sizeof($langs); $i++){
+    $msg .= "<option";
+    if (!$i) {
+      $msg .= ' selected';
     }
-    $msg .="</form>\n";
-    sqspell_makeWindow($onload, _("SquirrelSpell Initiating"), "init.js", $msg);
+    $msg .= " value=\"$langs[$i]\"> " . _($langs[$i]) . "</option>\n";
+  }  
+  $msg .= ' </select>'
+    . '<input type="submit" value="' . _("Go") . '">'
+    . '</p>';
+}
+$msg .="</form>\n";
+sqspell_makeWindow($onload, _("SquirrelSpell Initiating"), "init.js", $msg);
+
+/**
+ * For the Emacs weenies:
+ * Local variables:
+ * mode: php
+ * End:
+ */
     
 ?>
index 1a53d6016cea5332616dd9bf0c4258ebc6586549..d0ea2b424b2d6a57dde9898cc66141c951e5a37a 100644 (file)
@@ -1,71 +1,99 @@
 <?php
+/**
+ * lang_change.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 changes the international dictionaries selection
+ * for the user. Called after LANG_SETUP module.                
+ *
+ * $Id$
+ *
+ * @author Konstantin Riabitsev <icon@duke.edu> ($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 = '<p>'.
-               sprintf( _("Settings adjusted to: <strong>%s</strong> with <strong>%s</strong> as default dictionary."), $dsp_string, _($lang_default) ) .
-               '</p>';
+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 = '<p>'.
-               sprintf( _("Using <strong>%s</strong> dictionary (system default) for spellcheck." ), $SQSPELL_APP_DEFAULT ) .
-               '</p>';
-        $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 = '<p>'
+    . sprintf(_("Settings adjusted to: <strong>%s</strong> with <strong>%s</strong> as default dictionary."), $dsp_string, _($lang_default))
+    . '</p>';
+} else {
+  /**
+   * No dictionaries selected. Use system default.
+   */
+  $msg = '<p>'
+    . sprintf(_("Using <strong>%s</strong> dictionary (system default) for spellcheck." ), $SQSPELL_APP_DEFAULT)
+    . '</p>';
+  $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:
+ */
 ?>
index 557c988714d634d6ce2e15c2ff6de5e667f8774f..5a0c5c7dfc3632b6aa04b6955cd3af38f659ae17 100644 (file)
@@ -1,44 +1,59 @@
 <?php
-
-   /**
-    **  LANG_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 displays available dictionaries to the user and lets 
-    **  him/her choose which ones s/he wants to check messages with.     
-    **
-    **  $Id$
-    **/
+/**
+ * lang_setup.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 displays available dictionaries to the user and lets 
+ * him/her choose which ones s/he wants to check messages with.     
+ *
+ * $Id$
+ *
+ * @author Konstantin Riabitsev <icon@duke.edu> ($Author$)
+ * @version $Date$
+ */
     
-    // Making sure Sqspell doesn't barf when working with E_ALL
-    global $SQSPELL_APP;
+global $SQSPELL_APP;
     
-    $msg = '<p>'.
-           _("Please check any available international dictionaries which you would like to use when spellchecking:").
-           '</p>'.
-           '<form method="post">'.
-           '<input type="hidden" name="MOD" value="lang_change">'.
-           '<blockquote><p>';
-    $langs = sqspell_getSettings(null);
-    $add = '<p>'.
-           _("Make this dictionary my default selection:") .
-           " <select name=\"lang_default\">\n";
-    while (list($avail_lang, $junk) = each($SQSPELL_APP)){
-        $msg .= "<input type=\"checkbox\" name=\"use_langs[]\" value=\"$avail_lang\"";
-        if (in_array($avail_lang, $langs)) {
-            $msg .= ' checked';
-        }
-        $msg .= '> ' . _($avail_lang) . "<br>\n";
-        $add .= "<option";
-        if ($avail_lang==$langs[0]) {
-            $add .= ' selected';
-        }
-        $add .= " value=\"$avail_lang\" >" . _($avail_lang) . "</option>\n";
-    }
-    $msg .= "</p>\n" . $add . "</select>\n";
-    $msg .= "</p></blockquote><p><input type=\"submit\" value=\" " . _("Make these changes") . " \"></p>";
-    sqspell_makePage(_("Add International Dictionaries"), null, $msg); 
+$msg = '<p>'
+  . _("Please check any available international dictionaries which you would like to use when spellchecking:")
+  . '</p>'
+  . '<form method="post">'
+  . '<input type="hidden" name="MOD" value="lang_change">'
+  . '<blockquote><p>';
+/**
+ * Present a nice listing.
+ */
+$langs = sqspell_getSettings(null);
+$add = '<p>'
+  . _("Make this dictionary my default selection:")
+  . " <select name=\"lang_default\">\n";
+while (list($avail_lang, $junk) = each($SQSPELL_APP)){
+  $msg .= "<input type=\"checkbox\" name=\"use_langs[]\" "
+    . "value=\"$avail_lang\"";
+  if (in_array($avail_lang, $langs)) {
+    $msg .= ' checked';
+  }
+  $msg .= '> ' . _($avail_lang) . "<br>\n";
+  $add .= "<option";
+  if ($avail_lang==$langs[0]) {
+    $add .= ' selected';
+  }
+  $add .= " value=\"$avail_lang\" >" . _($avail_lang) . "</option>\n";
+}
+$msg .= "</p>\n" . $add . "</select>\n";
+$msg .= "</p></blockquote><p><input type=\"submit\" value=\" " 
+  . _("Make these changes") . " \"></p>";
+sqspell_makePage(_("Add International Dictionaries"), null, $msg); 
+
+/**
+ * For Emacs weenies:
+ * Local variables:
+ * mode: php
+ * End:
+ */
  
 ?>
index 27b3caeaa271aa1930efc3a50b49dd9773c92da5..844191d9920e9bab66013669090a1c4f03221efd 100644 (file)
@@ -1,45 +1,56 @@
 <?php
-
-   /**
-    **  OPTIONS_MAIN.MOD.PHP -- 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$
-    **/
-    
-    // E_ALL: protection behind 3000 miles.
-    global $SQSPELL_APP;
-    
-    $msg = '<p>' . 
-           _("Please choose which options you wish to set up:") . 
-           '</p>'.
-           '<ul>'.
-           '<li><a href="sqspell_options.php?MOD=edit_dic">' .
-           _("Edit your personal dictionary") . '</a></li>';
-    // See if more than one dictionary is defined system-wide.
-    // If so, let the user choose his preferred ones.
-    if (sizeof($SQSPELL_APP)>1) {
-        $msg .= '<li><a href="sqspell_options.php?MOD=lang_setup">'.
-                _("Set up international dictionaries") .
-                "</a></li>\n";
-    }
-    // See if MCRYPT is available.
-    // If so, let the user choose whether s/he wants to encrypt the
-    // personal dictionary file.
-    if (function_exists("mcrypt_generic")) {
-        $msg .= '<li><a href="sqspell_options.php?MOD=enc_setup">'.
-                _("Encrypt or decrypt your personal dictionary").
-                "</a></li>\n";
-    } else {
-        $msg .= '<li>'.
-                _("Encrypt or decrypt your personal dictionary") . ' <em>(' . _("not available") . ')</em>'.
-                "</li>\n";
-    }
-    $msg .= "</ul>\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 <icon@duke.edu> ($Author$)
+ * @version $Date$
+ */
     
+global $SQSPELL_APP;
+$msg = '<p>'
+  . _("Please choose which options you wish to set up:")
+  . '</p>'
+  . '<ul>'
+  . '<li><a href="sqspell_options.php?MOD=edit_dic">'
+  . _("Edit your personal dictionary") . '</a></li>';
+/**
+ * See if more than one dictionary is defined system-wide.
+ * If so, let the user choose his preferred ones.
+ */
+if (sizeof($SQSPELL_APP)>1) {
+  $msg .= '<li><a href="sqspell_options.php?MOD=lang_setup">'
+    . _("Set up international dictionaries")
+    . "</a></li>\n";
+}
+/**
+ * See if MCRYPT is available.
+ * If so, let the user choose whether s/he wants to encrypt the
+ * personal dictionary file.
+ */
+if (function_exists("mcrypt_generic")) {
+  $msg .= '<li><a href="sqspell_options.php?MOD=enc_setup">'
+    . _("Encrypt or decrypt your personal dictionary")
+    . "</a></li>\n";
+} else {
+  $msg .= '<li>'
+    . _("Encrypt or decrypt your personal dictionary") . ' <em>(' 
+    . _("not available") . ')</em></li>';
+}
+$msg .= "</ul>\n";
+sqspell_makePage( _("SquirrelSpell Options Menu"), null, $msg);
+
+/**
+ * For Emacs weenies:
+ * Local variables:
+ * mode: php
+ * End:
+ */
 ?>
index 654b1107a7de2fdbfa1907fae51a5ab39cacc8e1..ff760f6c8b01a16d01e6a77eb38ba91e39620505 100644 (file)
@@ -1,55 +1,88 @@
 <?php
+/**
+ * setup.php
+ * -----------
+ * Squirrelspell setup file, as defined by the SquirrelMail-1.2 API.
+ * 
+ * Copyright (c) 1999-2002 The SquirrelMail development team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * $Id$
+ *
+ * @author Konstantin Riabitsev <icon@duke.edu> ($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 "<script type=\"text/javascript\">\n".
-                    "<!--\n".
-                    'document.write("<input type=\"button\" value=\"' .
-                        _("Check Spelling") . '\" onclick=\"window.open(\'../plugins/squirrelspell/sqspell_interface.php\', \'sqspell\', \'status=yes,width=550,height=370,resizable=yes\')\">");'. "\n" .
-                    "//-->\n".
-                    "</script>\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 '<script type="text/javascript">\n'
+      . '<!--\n'
+      . 'document.write("<input type=\"button\" value=\"'
+      . _("Check Spelling") 
+      . '\" onclick=\"window.open(\'../plugins/squirrelspell/sqspell_'
+      . 'interface.php\', \'sqspell\', \'status=yes,width=550,height=370,'
+      . 'resizable=yes\')\">");\n'
+      . '//-->\n'
+      . "</script>\n";
+  }
+}
 
 ?>
index 46acc575160c66142e424bf5e9121b2568530ec7..b51c9597e67dc43928d3b2f8a82fd5cccf2c5116 100644 (file)
@@ -1,27 +1,33 @@
 <?php
+/**
+ * sqspell_config.php -- SquirrelSpell Configuration file.
+ *
+ * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ *
+ *
+ * $Id$
+ */
 
-   /**
-    * sqspell_config.php -- SquirrelSpell Configuration file.
-    *
-    * Copyright (c) 1999-2002 The SquirrelMail Project Team
-    * Licensed under the GNU GPL. For full terms see the file COPYING.
-    *
-    *
-    *
-    * $Id$
-    */
+require_once('../functions/prefs.php');
 
-    require_once('../functions/prefs.php');
+/* Just for poor wretched souls with E_ALL. :) */
+global $username, $data_dir;
 
-    /* Just for poor wretched souls with E_ALL. :) */
-    global $username, $data_dir;
+/**
+ * Example:
+ *
+ * $SQSPELL_APP = array( 'English' => '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';
 
 ?>
index 560c76b2c5d67c461a29e425da19eddb62d20dd4..00b031bde17627741e9fe4723cec3cdd1a6527e8 100644 (file)
 <?php
-
 /**
- * sqspell_functions.php -- All SquirrelSpell-wide functions are in this file.
+ * sqspell_functions.php 
+ * ----------------------
+ * All SquirrelSpell-wide functions are in this file.
  *
  * Copyright (c) 1999-2002 The SquirrelMail development team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * $Id$
+ *
+ * @author Konstantin Riabitsev <icon@duke.edu> ($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 "&nbsp;<br>\n";
-    if($scriptsrc) { 
-        echo "<script type=\"text/javascript\" src=\"js/$scriptsrc\"></script>\n";
-    }
-    echo '<table width="95%" align="center" border="0" cellpadding="2" cellspacing="0">'.
-            '<tr>'.
-                "<td bgcolor=\"$color[9]\" align=center>".
-                "<strong>$title</strong>".
-                '</td>'.
-            '</tr>'.
-            '<tr><td><hr></td></tr>'.
-            "<tr><td>$body</td></tr>";
-    if ($MOD!="options_main"){ 
-        // Generate a nice return-to-main link.
-        echo '<tr><td><hr></td></tr>'.
-             '<tr><td align="center"><a href="sqspell_options.php">' .
-                _("Back to &quot;SpellChecker Options&quot; page") . '</a></td></tr>';
-    }
-    echo '<tr><td><hr></td></tr>'.
-         '<tr>'.
-            "<td bgcolor=\"$color[9]\" align=center>".
-                "SquirrelSpell $SQSPELL_VERSION".
-            '</td>'.
-         '</tr>'.
-        '</table>';
-    }
-    
-    function sqspell_makeWindow($onload, $title, $scriptsrc, $body){
-    
-        /*
-        ** GUI wrap-around for the pop-up window interface.
-        */
-        global $color, $SQSPELL_VERSION, $theme_css;
-        
-        echo "<html>\n".
-              "<head>\n".
-              "<title>$title</title>\n";
-        if ($theme_css != "") {
-            echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">\n";
-        }          
-        if ($scriptsrc){
-            echo "<script type=\"text/javascript\" src=\"js/$scriptsrc\"></script>\n";
-        }
-        echo "</head>\n".
-             "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\"";
-        if ($onload) {
-            echo " onload=\"$onload\"";
-        }
-        echo '>'.
-             '<table width="100%" border="0" cellpadding="2">'.
-                '<tr>'.
-                    "<td bgcolor=\"$color[9]\" align=center>".
-                        "<strong>$title</strong>".
-                    '</td>'.
-                '</tr>'.
-                '<tr><td><hr></td></tr>'.
-                '<tr>'.
-                    "<td>$body</td>".
-                '</tr>'.
-                '<tr><td><hr></td></tr>'.
-                '<tr>'.
-                    "<td bgcolor=\"$color[9]\" align=center>".
-                        "SquirrelSpell $SQSPELL_VERSION".
-                    '</td>'.
-                '</tr>'.
-            '</table>'.
-            "</body>\n</html>\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 
+ *                    <script src="file.js"></script> 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 "&nbsp;<br>\n";
+  /**
+   * Check if we need to link in a script.
+   */
+  if($scriptsrc) { 
+    echo "<script type=\"text/javascript\" src=\"js/$scriptsrc\"></script>\n";
+  }
+  echo '<table width="95%" align="center" border="0" cellpadding="2" '
+    . 'cellspacing="0">'
+    . '<tr>'
+    . "<td bgcolor=\"$color[9]\" align=center>"
+    . "<strong>$title</strong>"
+    . '</td>'
+    . '</tr>'
+    . '<tr><td><hr></td></tr>'
+    . "<tr><td>$body</td></tr>";
+  /**
+   * Generate a nice "Return to Options" link, unless this is the
+   * starting page.
+   */
+  if ($MOD != "options_main"){ 
+    echo '<tr><td><hr></td></tr>'
+      . '<tr><td align="center"><a href="sqspell_options.php">'
+      . _("Back to &quot;SpellChecker Options&quot; page") 
+      . '</a></td></tr>';
+  }
+  /**
+   * Close the table and display the version.
+   */
+  echo '<tr><td><hr></td></tr>'
+    . '<tr>'
+    . "<td bgcolor=\"$color[9]\" align=center>"
+    . "SquirrelSpell $SQSPELL_VERSION"
+    . '</td>'
+    . '</tr>'
+    . '</table>';
+}
+
+/**
+ * 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 <body onload="function()" for automatic
+ *                    onload script execution.
+ * @param  $title     Title of the page.
+ * @param  $scriptsrc If defined, link this javascript source page into
+ *                    the document using <script src="file.js"> format.
+ * @param  $body      The content to include.
+ * @return            void
+ */
+function sqspell_makeWindow($onload, $title, $scriptsrc, $body){
+  global $color, $SQSPELL_VERSION, $theme_css;
+  echo "<html>\n"
+    . "<head>\n"
+    . "<title>$title</title>\n";
+  /**
+   * Check if we have a defined css theme to use.
+   */
+  if ($theme_css != "") {
+    echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">\n";
+  }
+  /**
+   * Link in the .js file if needed
+   */         
+  if ($scriptsrc){
+    echo "<script type=\"text/javascript\" src=\"js/$scriptsrc\"></script>\n";
+  }
+  echo "</head>\n"
+    . "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" "
+    . "vlink=\"$color[7]\" alink=\"$color[7]\"";
+  /**
+   * Provide an onload="jsfunction()" if asked to.
+   */
+  if ($onload) {
+    echo " onload=\"$onload\"";
+  }
+  /**
+   * Draw the rest of the page.
+   */
+  echo '>'
+    . '<table width="100%" border="0" cellpadding="2">'
+    . '<tr>'
+    . "<td bgcolor=\"$color[9]\" align=center>"
+    . "<strong>$title</strong>"
+    . '</td>'
+    . '</tr>'
+    . '<tr><td><hr></td></tr>'
+    . '<tr>'
+    . "<td>$body</td>"
+    . '</tr>'
+    . '<tr><td><hr></td></tr>'
+    . '<tr>'
+    . "<td bgcolor=\"$color[9]\" align=center>"
+    . "SquirrelSpell $SQSPELL_VERSION"
+    . '</td>'
+    . '</tr>'
+    . '</table>'
+    . "</body>\n</html>\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='<p>'.
-                '<strong>' . _("ATTENTION:") . '</strong><br>' .
-                _("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.<br>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.").
-                '</p>' .
-                '<blockquote>'.
-                '<form method="post" onsubmit="return AYS()">'.
-                '<input type="hidden" name="MOD" value="crypto_badkey">'.
-                '<p><input type="checkbox" name="delete_words" value="ON">' . 
-                _("Delete my dictionary and start a new one") . '<br>'.
-                _("Decrypt my dictionary with my old password:") . 
-                '<input name="old_key" size=\"10\"></p>'.
-                '</blockquote>'.
-                '<p align="center"><input type="submit" value="' . _("Proceed") . ' &gt;&gt;"></p>'.
-                '</form>';
-                // 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='<p>'
+        . '<strong>' . _("ATTENTION:") . '</strong><br>'
+        .  _("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.<br>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.")
+        . '</p>'
+        . '<blockquote>'
+        . '<form method="post" onsubmit="return AYS()">'
+        . '<input type="hidden" name="MOD" value="crypto_badkey">'
+        . '<p><input type="checkbox" name="delete_words" value="ON">'
+        . _("Delete my dictionary and start a new one") . '<br>'
+        . _("Decrypt my dictionary with my old password:")
+        . '<input name="old_key" size=\"10\"></p>'
+        . '</blockquote>'
+        . '<p align="center"><input type="submit" value="' 
+        . _("Proceed") . ' &gt;&gt;"></p>'
+        . '</form>';
+      /**
+       * 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";
 ?>
index 3ea858c4e0ff827cc048e35dcf414e69114dd29f..1357162e17979e7e0c49d1f28431e22fbfc270ce 100644 (file)
@@ -1,48 +1,52 @@
 <?php
 
-   /**
-    **  sqspell_interface.php -- Main wrapper for the pop-up.
-    **
-    **  Copyright (c) 1999-2002 The SquirrelMail development team
-    **  Licensed under the GNU GPL. For full terms see the file COPYING.
-    **
-    **   This is a main wrapper for the pop-up window interface of
-    **   SquirrelSpell.    
-    **
-    **  $Id$
-    **/
+/**
+ * sqspell_interface.php
+ * ----------------------
+ * Main wrapper for the pop-up.
+ *
+ * Copyright (c) 1999-2002 The SquirrelMail development team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * This is a main wrapper for the pop-up window interface of
+ * SquirrelSpell.    
+ *
+ * $Id$
+ *
+ * @author Konstantin Riabitsev <icon@duke.edu> ($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");
 ?>
index 8311678b91b6550367ec05d9b5777e3edeab0a6e..1a7eba5b30f2ea93a1d28246685ba3957dd063d3 100644 (file)
@@ -1,46 +1,49 @@
 <?php
+/**
+ * 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$
+ *
+ * @author Konstantin Riabitsev <icon@duke.edu> ($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");
 ?>