This is a modification to the spellerpages/server-scripts/spellchecker.php file that optionally uses PHP's built-in pspell functions instead of executing a shell command request to spell check via aspell.
Line 16 - a new constant - USEPSPELL is defined to be true or false, depending on choice of usage pf PSPELL over ASPELL.
Line 74 - added global reference to $lang. Necessary for selecting proper dictionary. This could be moved from a global variable to a paramter to the function's parameter list.
Lines 78,79 - Diagnostic lines, commented out. These are not necessary, but help in debugging to determine which spelling mechanism is used.
Lines 81-111 - new code added to support pspell. Note that this is written in-line in the function to reduce the amount of change that was introduced to the script. This could/should be moved to it's own method and encapsulated.
* Note that lines 98 and 99 do simple regular expression translations of the incoming text to remove all the strings that are <> tags and &xxx; strings. This may need to be examined to make it more robust as it might be possible with very well formed code (though I cannot at this time come up with an example) to pass a string that would be passed back through the javascript to the browser that might function as an exploit. I'm not capable of determing this at this time.
* Note also line 110 short-circuits this function with a RETURN TRUE. A better structure to this code would be to have it contine to flow out to the bottom or to encapsulate the pspell into a different function entirely and called from this function. In an effort to introduce a minimum of changes to the code, it is presented in this format.
Lines 191,192,195,196 - Diagnostic code. This code is commented out. If the comments are removed and the code allowed to execute, the entire output buffer from the print_textinputs_var() and print_checker_results() functions will be recorded to a file. This was the only way that I could determine how to debug errors in this code without contriving a calling program.
There should be no other changes to this code.
PHP server side spell checker with pspell function support