Re: howto config apache to allow perl to filter php pages
| From: | Steve Edberg | Date: | Mon, 17 Jul 2000 01:16:45 +0000 |
| Subject: | Re: howto config apache to allow perl to filter php pages | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-6862@lists.php.net to get a copy of this message | ||
At 4:11 PM -0400 7/16/00, Sam Carleton wrote:
I would like perl to process a php page before or after the php interpreter get's it hands on the file. I am trying to add a navbar to the PHP code. How would I go about doing that?As far as I know, you can't do that via current versions of Apache...this is known as 'stacked handlers', and I think it'll be a feature of version 2.0. If you want to process PHP output with perl, you'll have to run PHP as a module, and then call on via an exec() call, capture the output, and do what you want with it. If you want to process perl output in PHP, you can do something similar. This is exactly what I'm testing now (this is rather kludgy right now, but like I say, it's a test): pgfsun% cat test.php <?php
require 'compositdb.inc';
require 'general_functions.inc';
$PERL_PROG_PATH = '/path/to/a/directory/of/perl/programs';
$Page = new page;
$Page->header('Compositae Database Home');
?>
<CENTER><?php echo make_image_tag('images/header2.gif', 'BORDER="0" ALT=""'); ?></CENTER>
<HR>
<?php
$Page->buttons_open();
passthru("perl -I $PERL_PROG_PATH $PERL_PROG_PATH/special/webace-body class=Colleague db=lettdb");
$Page->buttons_close();
$Page->footer();
?>
pgfsun%
I just passthru() the output of the perl program in the middle of my PHP. You'll of course have to have perl in your path (or specify the complete path to it) and have execute permissions on the perl program.
I use the perl -I option so that the perl program can find some perl modules of my own.
-steve
+--- unix and cats: -----------------------------------------------------+
| Steve Edberg University of California, Davis | | sbedberg@ucdavis.edu Computer Consultant | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu |+----------------------- hard to befriend, but then friends for life! ---+