X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=plugins%2Fsquirrelspell%2Fmodules%2Fcheck_me.mod;h=d892f4a8818885a9ac6c2fb1d5233802df4d7c43;hp=3faa076c66c75cefa441b6b88d25bf59ae70ea54;hb=2fd96e6b1e3f337189d7a1a9561f1e8e2d1204c9;hpb=48a1015b888d1150c6d9ac77594c6526e9e13902 diff --git a/plugins/squirrelspell/modules/check_me.mod b/plugins/squirrelspell/modules/check_me.mod index 3faa076c..d892f4a8 100644 --- a/plugins/squirrelspell/modules/check_me.mod +++ b/plugins/squirrelspell/modules/check_me.mod @@ -4,17 +4,17 @@ * ------------- * Squirrelspell module. * - * Copyright (c) 1999-2002 The SquirrelMail development team + * Copyright (c) 1999-2005 The SquirrelMail development team * Licensed under the GNU GPL. For full terms see the file COPYING. * * This module is the main workhorse of SquirrelSpell. It submits * the message to the spell-checker, parses the output, and loads * the interface window. * - * $Id$ - * - * @author Konstantin Riabitsev ($Author$) - * @version $Date$ + * @author Konstantin Riabitsev + * @version $Id$ + * @package plugins + * @subpackage squirrelspell */ /** @@ -36,8 +36,10 @@ function SpellLink($jscode, $title, $link) { /** * Declaring globals for users with E_ALL set. */ -global $sqspell_text, $SQSPELL_APP, $sqspell_use_app, $attachment_dir, - $username, $SQSPELL_EREG, $color; +global $SQSPELL_APP, $attachment_dir, $SQSPELL_EREG, $color; + +$sqspell_text = $_POST['sqspell_text']; +$sqspell_use_app = $_POST['sqspell_use_app']; /** * Now we explode the lines for three reasons: @@ -64,7 +66,7 @@ for ($i=0; $i&1", $sqspell_output, $sqspell_exitcode); -/** - * Remove the temp file. + * 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. */ -unlink($floc); +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 ) ) { + error_box ( _("Could not run the spellchecker command (%s).", + htmlspecialchars($sqspell_command) ) , $color ); + } + if ( ! @fwrite($pipes[0], $sqspell_new_text) ) { + error_box ( _("Error while writing to pipe.", + htmlspecialchars($floc) ) , $color ); + } + 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),"\n")); + } + fclose($pipes[$i]); + } + $sqspell_exitcode=proc_close($spell_proc); +} else { + do { + $floc = "$attachment_dir/" . md5($sqspell_new_text . microtime()); + } while (file_exists($floc)); + $fp = @fopen($floc, 'w'); + if ( ! is_resource ($fp) ) { + error_box ( _("Could not open temporary file '%s'.", + htmlspecialchars($floc) ) , $color ); + } + if ( ! @fwrite($fp, $sqspell_new_text) ) { + error_box ( _("Error while writing to temporary file '%s'.", + htmlspecialchars($floc) ) , $color ); + } + fclose($fp); + exec("$sqspell_command < $floc 2>&1", $sqspell_output, $sqspell_exitcode); + unlink($floc); +} /** * Check if the execution was successful. Bail out if it wasn't. @@ -114,10 +135,10 @@ if ($sqspell_exitcode){ $msg= "
" . sprintf(_("I tried to execute '%s', but it returned:"), $sqspell_command) . "
"
-     . nl2br(join("\n", $sqspell_output)) . "
" - . "
" - . "
"; + . htmlspecialchars(join("\n", $sqspell_output)) . '' + . '
' + . '
'; sqspell_makeWindow(null, _("SquirrelSpell is misconfigured."), null, $msg); exit; } @@ -170,7 +191,7 @@ for ($i=0; $i\n" - . "\n" - . '' . _("SquirrelSpell Results") . ''; - /** - * Check if there are user-defined stylesheets. - */ - if ($theme_css != '') { - echo "\n"; - } /** * Load the spelling errors into JavaScript arrays * (More dark magic!) */ - echo "\n" - . "\n" - . "\n"; - + . "\n"; + + + displayHtmlHeader(_("SquirrelSpell Results"),$extrajs); + echo "\n"; @@ -301,7 +313,7 @@ if ($errors){ -
+
@@ -309,7 +321,7 @@ if ($errors){
- @@ -319,7 +331,7 @@ if ($errors){ echo $sptag . _("Line with an error:") . ''; ?>
- @@ -330,7 +342,7 @@ if ($errors){ ?> - + - + - @@ -425,9 +437,9 @@ if ($errors){ /** * AREN'T YOU SUCH A KNOW-IT-ALL! */ - $msg="
" - . "
"; + $msg='
'. + '
'; sqspell_makeWindow(null, _("No errors found"), null, $msg); } @@ -436,5 +448,6 @@ if ($errors){ * Local variables: * mode: php * End: + * vim: syntax=php et ts=4 */ ?>
- @@ -339,7 +351,7 @@ if ($errors){ ?> - + onfocus="if(!this.value) this.value=document.forms[0].sqspell_error.value" /> - +


- +


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