<?php
function sysexec($cmd) {
$result = '';
$handle = popen($cmd, 'r');
while (!feof($handle)) {
$line = fread($handle, 1024);
$result .= $line."\n";
}
pclose($handle);
$result = trim($result)."\n";
return $result;
}
print("<h3>Random Fortune</h3>\n");
$cmd = '/usr/games/fortune 2>&1';
$msg = htmlentities(sysexec($cmd));
print("<pre>".$msg."</pre>\n");
?>