';
- 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 ' |