* * BSD 3-Clause License (BSD-3-Clause) * See LICENSE for details */ require 'common.php'; ?> Manup               Lonely MAN near You
.+\((.+)\)\<\/td>/iu', $lines[4], $sect); $url = "$root/?query=". urlencode($query) ."&section=". urlencode($sect[1]) ."&arch=". urlencode($arch) ."&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 $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.

"; } ?>