X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=plugins%2Ffortune%2Ffunctions.php;h=dddfdabdb5c2f0cc1dbc8aa09a59d3c91907a54b;hp=fe1b9c627428c134400fde15faa36bee89564224;hb=c3806a9dc07e4bf45491e7120a1c931332f2e555;hpb=ee2375c0962984cbdf0c05a204e7e8eab8fb279a diff --git a/plugins/fortune/functions.php b/plugins/fortune/functions.php index fe1b9c62..dddfdabd 100644 --- a/plugins/fortune/functions.php +++ b/plugins/fortune/functions.php @@ -1,8 +1,9 @@ \n". + echo "
\n". "
\n". "
\n"; echo '
'; - if (!$exist) { - printf(_("%s is not found."),$fortune_location); - } else { - echo "
" . _("Today's Fortune") . "
\n" .
-            htmlspecialchars(shell_exec($fortune_command)) .
-            "
\n"; + + /* open handle and get all command output*/ + $handle = popen($fortune_command,'r'); + $fortune = ''; + while ($read = fread($handle,1024)) { + $fortune .= $read; } + /* if pclose return != 0, popen command failed. Yes, I know that it is broken when --enable-sigchild is used */ + if (pclose($handle)) { + // %s shows executed fortune cookie command. + $fortune = sprintf(_("Unable to execute \"%s\"."),$fortune_command); + } + echo "
" . _("Today's Fortune") . "
\n" .
+            htmlspecialchars($fortune) .
+            "
\n"; - echo '
'; + echo ''; } /** @@ -90,4 +87,3 @@ function fortune_function_load() { $fortune_visible = getPref($data_dir, $username, 'fortune_visible'); } -?>