WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : WWW interface to Unix Manual(phpMan)
Categories : Program Execution, Strings, Arrays, PHP Click here to Update Your Picture
Dong Che,
Date : Jan 17th 2002
Grade : 2 of 5 (graded 1 times)
Viewed : 3852
File : phpMan.php
Images : No Images for this code example.
Search : More code by Dong Che,
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?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)
=> '&gt;';
                                        "/</", //html special char: '>' => chr(6)
=> '&lt;';
                                        "/>/", //html special char: '<' => chr(7)
=> '&gt;';
                                        "/_".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",
                                        "&amp;",
                                        "&lt;",
                                        "&gt;",
                                        "<a href=\"?docType=$docType&amp;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