These forums are locked and archived, but all topics have been migrated to the new forum. You can search for this topic on the new forum: Search for Enable "fancy" PHP source higlighting w/ .phps ? on the new forum.
Is there any way to enable automatic highlighing of php source files (.phps extension)?
In a non-suexec environment it's enabled by adding: AddType application/x-httpd-php-source .phps to /etc/apache2/mods-available/php5.conf
Thanks!
Depending on your setup -- in the individual domains listed in /etc/apache2/sites-enabled/SITENAME, there may be a number of sections such as:
[code:1]
AddType application/x-httpd-php5 .php5
AddType application/x-httpd-php4 .php
[/code:1]
Try adding the .phps type to one of them, restart Apache, and see if that does the trick.
-Eric
I have tried various combinations of the following, in the <Directory ...public_html> section and in the <VirtualHost...> section:
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php5 .phps
AddHandler fcgid-script .phps
AddHandler application/x-httpd-php-source .phps
I even tried creating an alternate fcgi wrapper script that passed the -s switch to the php binary.
On the off chance that anyone else is looking for a solution to this, I was able to solve it by creating my own highlight script, which has the added benefit of generating a complete & valid HTML 4.01 page:
Services > Configure Website > Edit Directives and add (somewhere after "RewriteEngine on"):
RewriteCond %{REQUEST_URI} \.phps$ [NC]
RewriteCond %{REQUEST_URI} !\^source.php
RewriteRule ^(.*)$ /source.php?file=$1 [L]
/home/whatever/public_html/source.php:
<?php
$file = isset($_REQUEST['file']) ? ('/' . trim($_SERVER['DOCUMENT_ROOT'], ' /') . '/' . trim(str_replace('../', '', $_REQUEST['file']), ' /')) : '';
if (strlen($file) > 5 && substr($file, -5) == '.phps' && file_exists($file)):
?>
Source of <?php echo htmlentities(substr(strrchr($file, DIRECTORY_SEPARATOR), 1, -1)); ?>
<?php
echo str_replace('', '', highlight_file($file, TRUE));
?><?php
else:
header('HTTP/1.0 404 Not Found');
?>
404 Not Found
Not Found
The requested URL <?php echo htmlentities($_SERVER['REQUEST_URI']); ?> was not found on this server.
<?php endif; ?>