* * BSD 3-Clause License (BSD-3-Clause) * See LICENSE for details */ require 'common.php'; ?> Manup               Lonely MAN near You
.+\((.+)\)\<\/td>/i', $lines[4], $sect); $url = "$root/?query=". urlencode($query) ."&section=". urlencode($sect[1]) ."&action=lmmtfy"; /* HACK: fucking mandoc just generates tons of useless
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) { $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.

"; } ?>