|
|
|
<?php
/**
* phpMan is a web interface of Unix command 'man' and 'perldoc'.
* This script makes it easier to read man pages which is lengthy
* and require you to use 'more' or 'pg' filters.
* Just try it if you feel hard to remember the command for page back
* or need to dump man page into text/html format.
*
* $Id: phpMan.php,v 1.2 2002/06/03 08:58:26 chedong Exp $
* Author: Che, Dong
* chedong@bigfoot.com
*
* Tested on Linux and FreeBSD
*/
//global title
$PHP_MAN_TITLE = "phpMan: Unix Manual / Perldoc Web Interface";
//header
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-
transitional.dtd\">
<html>
<head>
<title>$PHP_MAN_TITLE</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\"/>
<style type=\"text/css\">
<!--
b {color:brown}
u {color:green}
//-->
</style>
</head>
<body bgcolor=\"#EEEEEE\">";
//option checker
if ($docType == "perldoc") {
$check_man = "";
$check_perldoc = " checked=\"checked\"";
}
else {
$check_man = " checked=\"checked\"";
$check_perldoc = "";
}
//promter and recursive call
echo "<b>$PHP_MAN_TITLE</b>
<form action=\"$PHP_SELF\">
Command:
<input type=\"text\" size=\"20\" name=\"parm\" value=\"$parm\"/>
<input type=\"radio\" name=\"docType\" value=\"man\"$check_man/>man
<input type=\"radio\" name=\"docType\" value=\"perldoc\"$check_perldoc/>perldoc
<input type=\"submit\"/>
</form>";
echo "<hr /><br />";
echo "<pre>";
//remove arbitrary commands
$semi = strpos($parm,";");
if ($semi > 1)
$parm = substr($parm, 0, $semi);
//get
if ( $docType == "perldoc" )
exec("perldoc $parm",$lines,$rc);
else
exec("man $parm",$lines,$rc);
$count = count($lines);
for ( $i = 1; $i <= $count; $i ++ ) {
//highlighting attribute characters
$patterns = array(
"/&/", //html special char: '&' => chr(5)
=> '>';
"/</", //html special char: '>' => chr(6)
=> '<';
"/>/", //html special char: '<' => chr(7)
=> '>';
"/_".chr(8)."(.)".chr(8)."./", // _^H?^H?
=> <b><u>?</u></b>
"/_".chr(8)."(.)/", //_^H? => <u>?</u>
"/.".chr(8)."(.)/", //?^H? => <b>?</b>
"/<b>.<\/b>".chr
(8)."(<b>.<\/b>)/", //duplicated: <b>?</b>^H<b>?</b> => <b>?</b>
"/".chr(5)."/", //reverse '&'
"/".chr(6)."/", //reverse '<'
"/".chr(7)."/", //reverse '>'
//ifconfig(8) => <a href="8
ifconfig">ifconfig(8)</f>
//IO::Handle(3) => IO::Handle
"/([\w:\.]+)\((\d)\)/",
);
$replace = array(
chr(5),
chr(6),
chr(7),
"<b><u>\\1</u></b>",
"<u>\\1</u>",
"<b>\\1</b>",
"\\1",
"&",
"<",
">",
"<a href=\"?docType=$docType&parm=\\2 \\1
\">\\1(\\2)</a>",
);
$lines[$i] = preg_replace($patterns, $replace, $lines[$i]);
echo "$lines[$i] <br />";
}
//footer
echo "</pre>
<hr />
<br />
<p>
<a href=\"http://validator.w3.org/check/referer\">
<img src=\"http://www.w3.org/Icons/valid-xhtml10\" alt=\"Valid XHTML 1.0!\"
height=\"31\" width=\"88\" border=\"0\" />
</a>
<a href=\"http://sourceforge.net/projects/phpunixman/\">\$Id: phpMan.php,v 1.2
2002/06/03 08:58:26 chedong Exp $</a>
</p>
</body>
</html>";
?>
|
|
| Takes an array and returns a string, suitable for inputing in an SQL statement
Categories : Arrays, Strings, PHP | | | columned txt file to array()? Categories : Arrays, Strings, Regexps, PHP | | | How to ifconfig down/up a list of IP's Categories : Arrays, Strings, Filesystem, PHP | | | Grab images from one or more URLs and save them to a specified local directory. Categories : PHP, Filesystem, Strings, Arrays | | | Variable serialization and unserialization. Loading and saving variable structures
to and from file. Categories : Arrays, Filesystem, Variables, Strings, PHP | | | Compare two texts and display a block of text with the differences between them. Categories : PHP, PHP Classes, Filesystem, Strings, Arrays | | | Function to create a separated list Categories : PHP, Arrays, Strings | | | How to Get a character array from a string Categories : PHP, Strings, Arrays | | | Can the word DO be used in arrays? Categories : Arrays, PHP, Strings | | | Get TemplateMonster data Categories : Arrays, Ecommerce, PHP, Strings | | | clearing variables in php3 Categories : Variables, Arrays, PHP | | | Avoiding or Detecting high bit characters in a string. Useful when you want to create a valid RSS feed Categories : PHP, Strings, Unicode, Regexps, Rich Site Summary (RSS) | | | Select with current month Categories : PHP, HTML and PHP, Date Time, Arrays | | | mysql_escape_string Categories : PHP, MySQL, Databases, Strings | | | Allows you to parse a deliniated string and put the individual fields in a SELECT option in a form Categories : HTML, PHP, Strings | |
|
|
|