-/**
- * Define the command used to spellcheck the document.
- */
-$sqspell_command=$SQSPELL_APP[$sqspell_use_app];
-/**
- * If you have php >= 4.3.0, we can use proc_open and safe mode
- * and not mess w/ temp files. Otherwise we will do it the old
- * way, (minus the uneeded call to cat that messes up Wintel
- * boxen.)
- * Thanks Ray Ferguson for providing this patch.
- */
-if( check_php_version ( 4, 3 ) ) {
- $descriptorspec = array(
- 0 => array('pipe', 'r'), // stdin is a pipe that the child will read from
- 1 => array('pipe', 'w'), // stdout is a pipe that the child will write to
- 2 => array('pipe', 'w'), // stderr is a pipe that the child will write to
- );
- $spell_proc = @proc_open($sqspell_command, $descriptorspec, $pipes);
- if ( ! is_resource ( $spell_proc ) ) {
- // TODO: replace error_box() with sqspell_makeWindow()
- error_box ( sprintf(_("Could not run the spellchecker command (%s)."),
- htmlspecialchars($sqspell_command) ) , $color );
- // close html tags and abort script.
- echo "</body></html>";
- exit();
- }
- if ( ! @fwrite($pipes[0], $sqspell_new_text) ) {
- // TODO: replace error_box() with sqspell_makeWindow()
- error_box ( _("Error while writing to pipe.") , $color );
- // close all three $pipes here.
- for($i=0; $i<=2; $i++) {
- // disable all fclose error messages
- @fclose($pipes[$i]);
- }
- // close html tags and abort script.
- echo "</body></html>";
- exit();
- }
- fclose($pipes[0]);
- $sqspell_output = array();
- for($i=1; $i<=2; $i++) {
- while(!feof($pipes[$i])) {
- array_push($sqspell_output, rtrim(fgetss($pipes[$i],999),"\r\n"));
- }
- fclose($pipes[$i]);
- }
- $sqspell_exitcode=proc_close($spell_proc);
-} else {
- // add slash to attachment directory, if it does not end with slash.
- if (substr($attachment_dir, -1) != '/')
- $attachment_dir = $attachment_dir . '/';