Removed the crazy code, added note about phps highlighting

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@169261 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Aidan Lister 2004-09-26 14:10:49 +00:00
parent 921b48f1e0
commit 14f713e15a

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.18 $ -->
<!-- $Revision: 1.19 $ -->
<!-- splitted from ./en/functions/misc.xml, last change in rev 1.22 -->
<refentry id="function.highlight-file">
<refnamediv>
@ -32,16 +32,6 @@
4.2.0. Before this time it behaved like the default, which is &false;
</simpara>
</note>
<caution>
<simpara>
Care should be taken when using the
<function>show_source</function> and
<function>highlight_file</function> functions to make sure that
you do not inadvertently reveal sensitive information such as
passwords or any other type of information that might create a
potential security risk.
</simpara>
</caution>
<note>
<simpara>
Since PHP 4.2.1 this function is also affected by <link
@ -49,67 +39,27 @@
linkend="ini.open-basedir">open_basedir</link>.
</simpara>
</note>
<simpara>
To setup a URL that can code highlight any script that you pass to
it, we will make use of the "ForceType" directive in
Apache to generate a nice URL pattern, and use the
function <function>highlight_file</function> to show a nice looking
code list.
</simpara>
<simpara>
In your &httpd.conf; you can add the following:
</simpara>
<caution>
<simpara>
Care should be taken when using the
<function>highlight_file</function> function to make sure that
you do not inadvertently reveal sensitive information such as
passwords or any other type of information that might create a
potential security risk.
</simpara>
</caution>
<para>
<example>
<title>Creating a source highlighting URL</title>
<programlisting role="apache-conf">
<![CDATA[
<Location /source>
ForceType application/x-httpd-php
</Location>
]]>
</programlisting>
<simpara>
And then make a file named <filename>source</filename> and put it in your
web root directory.
</simpara>
<programlisting role="php">
<![CDATA[
<html>
<head>
<title>Source Display</title>
</head>
<body bgcolor="white">
<?php
$script = getenv('SCRIPT_FILENAME');
if (!$script) {
echo "<br /><b>ERROR: Script Name needed</b><br />";
} else {
if (ereg("(\\.php|\\.inc)$", $script)) {
echo "<h1>Source of: " . getenv("PATH_INFO") . "</h1>\n<hr />\n";
highlight_file($script);
} else {
echo "<h1>ERROR: Only PHP or include script names are allowed</h1>";
}
}
echo "<hr />Processed: " . date("Y/M/d H:i:s", time());
?>
</BODY>
</HTML>
]]>
</programlisting>
<simpara>
Then you can use a URL like the one below to display a colorized
version of a script located in "/path/to/script.php"
in your web site.
</simpara>
<screen>
<![CDATA[
http://www.example.com/source/path/to/script.php
]]>
</screen>
</example>
Many servers are configured to automatically highlight files
with a <emphasis>phps</emphasis> extension. For example,
<filename>example.phps</filename> when viewed will show the
syntax highlighted source of the file. To enable this, add this
line to the &httpd.conf;:
</para>
<screen>
<![CDATA[
AddType application/x-httpd-php-source .phps
]]>
</screen>
<simpara>
See also <function>highlight_string</function>.
</simpara>