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("$manbin -M $manpath $arg_section -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];
$desc = $matches[4];
$sect = explode(',', $fsect);
$arch = explode('/', end($sect));
$sect = trim($arch[0]);
$arch = trim(end($arch));
$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)
."&arch=". urlencode($arch) ."&action=man";
echo '';
echo " - $fname($fsect)
";
echo " - $desc
";
echo '
';
}
}
else echo " No results.
";
}
?>