L
m
m
t
F
y
BETA!
stuff
* look horrible. So I just remove it here.
* As you can see, they also decided to pepper the HTML with inline style coz they
* just absolutely hate me, so I strip it too.
*/
for($i = 0; $i < count($lines); $i++)
{
$line = preg_replace('/\/i', '', $lines[$i]);
$line = preg_replace('/style=".*"/i', '', $line);
if(!empty(trim($line))) $lines2[$i] = $line;
}
echo "";
echo "". implode(PHP_EOL, $lines2) ." ";
echo "";
$found_man = true;
}
}
if(($action === "apropos") || !$found_man)
{
$res = exec("man -M $manpath -k " . escapeshellarg($query), $lines, $ret);
if($ret === 0)
{
$n = count($lines);
$s = $n > 1 ? "s" : "";
echo " Found $n result$s
";
foreach($lines as $line)
{
$split = explode(") - ", $line);
$full = $split[0];
$desc = $split[1];
$split = explode("(", $full);
$name = explode(",", $split[0])[0];
$sect = strtolower(explode(",", $split[1])[0]);
$url = "$root/search.php?query=". urlencode($name) ."§ion=". urlencode($sect)
."&action=man";
echo '';
echo " - $full)
";
echo " - $desc
";
echo '
';
}
}
else echo " No results.
";
}
?>