X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;ds=sidebyside;f=plugins%2Fsquirrelspell%2Fmodules%2Fcheck_me.mod;h=4ff9485c1e0b871df0f8c1ade091fc9ca22c58af;hb=90ad8cd181bd2d435465b887d2769836ace5d7f0;hp=288ac4f6ca0ba74fbf38557b905acd31e57b48cf;hpb=99f2ece35427027244dd23f85259fcfdc408c1a9;p=squirrelmail.git diff --git a/plugins/squirrelspell/modules/check_me.mod b/plugins/squirrelspell/modules/check_me.mod index 288ac4f6..4ff9485c 100644 --- a/plugins/squirrelspell/modules/check_me.mod +++ b/plugins/squirrelspell/modules/check_me.mod @@ -4,17 +4,17 @@ * ------------- * Squirrelspell module. * - * Copyright (c) 1999-2004 The SquirrelMail development team + * Copyright (c) 1999-2005 The SquirrelMail Project 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,10 +36,14 @@ function SpellLink($jscode, $title, $link) { /** * Declaring globals for users with E_ALL set. */ -global $SQSPELL_APP, $attachment_dir, $SQSPELL_EREG, $color; +global $SQSPELL_APP_DEFAULT, $SQSPELL_APP, $attachment_dir, $color; -$sqspell_text = $_POST['sqspell_text']; -$sqspell_use_app = $_POST['sqspell_use_app']; +if (! sqgetGlobalVar('sqspell_text',$sqspell_text,SQ_POST)) { + $sqspell_text = ''; +} +if (! sqgetGlobalVar('sqspell_use_app',$sqspell_use_app,SQ_POST)) { + $sqspell_use_app = $SQSPELL_APP_DEFAULT; +} /** * Now we explode the lines for three reasons: @@ -82,7 +86,7 @@ $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 + * way, (minus the uneeded call to cat that messes up Wintel * boxen.) * Thanks Ray Ferguson for providing this patch. */ @@ -92,22 +96,37 @@ if( check_php_version ( 4, 3 ) ) { 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); - fwrite($pipes[0], $sqspell_new_text); + $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]); + 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'); - fwrite($fp, $sqspell_new_text); + $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); @@ -131,7 +150,7 @@ if ($sqspell_exitcode){ /** * Load the user dictionary. */ -$words=sqspell_getLang(sqspell_getWords(), $sqspell_use_app); +$words=sqspell_getLang($sqspell_use_app); /** * Define some variables to be used during the processing. */ @@ -167,7 +186,7 @@ for ($i=0; $i\n" . "\n" . "\n" . "\n"; - + displayHtmlHeader(_("SquirrelSpell Results"),$extrajs); @@ -292,7 +311,7 @@ if ($errors){ - + @@ -306,7 +325,7 @@ if ($errors){
- @@ -316,7 +335,7 @@ if ($errors){ echo $sptag . _("Line with an error:") . ''; ?>
- @@ -327,7 +346,7 @@ if ($errors){ ?> @@ -422,7 +441,7 @@ if ($errors){ /** * AREN'T YOU SUCH A KNOW-IT-ALL! */ - $msg='
'. + $msg='
' . '
'; sqspell_makeWindow(null, _("No errors found"), null, $msg); @@ -435,4 +454,4 @@ if ($errors){ * End: * vim: syntax=php et ts=4 */ -?> +?> \ No newline at end of file
- @@ -336,7 +355,7 @@ if ($errors){ ?> -
- +
@@ -399,15 +418,15 @@ if ($errors){
' - . ' '; + . _("Close and Commit") + . ' " onclick="if (confirm(\'' + . _("The spellcheck is not finished. Really close and commit changes?") + . '\')) sqspellCommitChanges()" />' + . ' '; ?>