L
m
m
t
F
y
BETA!
s that make
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)
{
preg_match('/^((.+)(?:,.+)*)\(((.+)(?:,.+)*)\)\s?-\s?(.*)$/Uu', $line, $matches);
$fname = $matches[1];
$name = $matches[2];
$fsect = $matches[3];
$sect = $matches[4];
$desc = $matches[5];
$descl = strlen($desc);
if($descl > 320) $desc = substr($desc, 0, 320) . "...";
elseif($descl === 0) $desc = "No synopsis.";
$url = "$root/search.php?query=". urlencode($name) ."§ion=". urlencode($sect)
."&action=man";
echo '';
echo " - $fname($fsect)
";
echo " - $desc
";
echo '
';
}
}
else echo " No results.
";
}
?>