Version: 1.0
Type: Full Script
Category: HTML
License: BSD License
Description: View unix man-pages with PHP
<?php // // $Id: viewman.php,v 1.1 2002/01/21 04:09:59 mavetju Exp $ // // Viewman.php by Edwin Groothuis ([email protected]) // // Viewman is developed to view man-pages in a webbroswer. // // How to use: // In a shell, do "man ls > /path/ls.man" // On your webpage, add this link: viewman.php?page=/path/ls // // That's all. // // See CONTACT and LICENCE on the status of this project and // on how to contact me. // if ($page=="") { echo "No page specified."; exit; } $file=$page.".man"; if (!file_exists($file)) { echo "Page not found."; exit; } $fd=fopen($file,"r"); $line=fgets($fd,4096); $t=explode("t",$line); $title="Man page for $t[0]"; fclose($fd); echo "<html><head><title>$title</title></head><body>n"; echo "<pre>n"; $fd=fopen($file,"r"); while (!feof($fd)) { $line=fgets($fd,4096); if (strstr($line,"x8")) { // // replace _^H..._ 's by a bold _ // $line=ereg_replace("(_x8)+_","<b><u> </u></b>",$line); // // replace _^H(whatever) by an underlined (whatever) // $line=ereg_replace("_x8(.)","<u>1</u>",$line); // // replace (whatever)^H(whatever) by a bold (whatever) // $line=ereg_replace("(.)(x8.)+","<b>1</b>",$line); } echo $line; } echo "</pre></body></html>n"; ?>