httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dAniel hAhler <apache-us...@thequod.de>
Subject Re: [users@httpd] .phps extension with mod_fastcgi
Date Sun, 17 Jul 2005 20:16:19 GMT
On Thursday 14 July 2005 13:27, Chris Hall wrote:

> it's a PHP thing.
>
> add:
>
> # display formatted, syntax hilighted php source code
> AddType application/x-httpd-php-source .phps
>
> to httpd.conf and restart the server

It's seems to be only the case that only mod_php supports it. The content type 
for .phps is application/x-httpd-php-source by default.

But thanks anyway!

You would have to do something like this for cgi:

in an .htaccess file for example:
RewriteRule (.*)\.phps$ /phpsource.php?$1

and the phpsource.php script could be like this (SECURITY!):
<?php
/**
 * Highlights a PHP file as PHP source.
 * The filename is taken of from PATH_INFO with the php extension added.
 *
 * We exclude files that are with "conf" or "cfg" in their name. Should be
 * probably even more adjusted!
 */

$file = $_SERVER['DOCUMENT_ROOT'].'/'.$_SERVER['PATH_INFO'].'.php';

if( !file_exists( $file ) || preg_match( '#conf|cfg#i', $file ) )
{
    header('Status: 404');
    ?>
    <html>
        <head><title>N0T F0UND</head></head>
        <body>
        <h1>NOT FOUND</h1>
        <h2>Please don't cheat!</h2>
        </body>
    </html>
    <?php
    return;
}

highlight_string( file_get_contents( $file  ) );
?>

>
> On 7/13/05, dAniel hAhler <apache-users@thequod.de> wrote:
> > Hi,
> >
> > is the handling of .phps extensions (probably as text/html, with syntax
> > coloured php source code) a feature of mod_php only or can I activate/use
> > it with mod_fastcgi (+PHP) also?
> >
> > Thank you.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message