Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

surround PHP with filters

by maard (Pilgrim)
on Dec 29, 2005 at 13:19 UTC ( [id://519776]=perlquestion: print w/replies, xml ) Need Help??

maard has asked for the wisdom of the Perl Monks concerning the following question:

Hello, brothers in faith!

I have apache2 with mod_perl/mod_php and some php software running on it. And I want to filter request headers for php scripts and filter its output again (both headers and body). php scripts are located under /php_area. The problem is, that if I write

<Location /php_area> SetHandler modperl PerlInputFilterHandler My::PHPInputFilter PerlOutputFilterHandler My::PHPOutputFilter </Location>
then php scripts stop being processed by mod_php and instead are output as plain php code.

For now I solved the problem by writing "proxy" response handler, which uses LWP to perform requests to php and give user back what I want (it's much simpler than fix all that php code), but i'm still interested in using filters - is it possible in this situation ?

Replies are listed 'Best First'.
Re: surround PHP with filters
by pileofrogs (Priest) on Dec 30, 2005 at 17:23 UTC
Re: surround PHP with filters
by perrin (Chancellor) on Dec 29, 2005 at 19:53 UTC
    Yes, it is possible to do what you show in your sample here. The "SetHandler modperl" looks wrong to me, but the concept is correct. Did you actually write code for these filters?
      That SetHandler directive isn't wrong, see example in mod_perl2 filters. But I overlooked something obvious: use of <Files ~ "\.php"> instead of <Location>

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://519776]
Approved by Corion
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-19 16:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found