PDA

View Full Version : Working around auto_prepend_file?


Alex Vincent
11-02-2002, 11:44 PM
Well, I'm trying to put together a nice little ZIP for Firepages to add to his phpdev server, to support XML files themselves going through the PHP interpreter. ("Assimilate this!", Simon)

I have a workaround that lets PHP set the mimetype without having a character in front of the XML declaration tag <?xml version="1.0" ?> (if there were a character in front, that would violate XML 1.0 well-formedness). It involves "prepending" a special PHP script when the Apache server retrieves the XML document.

There's one problem, though: it uses the auto_prepend_file feature -- and you can only prepend one file. Meaning a deeper .htaccess file with a "php_value auto_prepend_file" will override my own prepend and disable the mime-type script.

I'm wondering if anyone here has ideas that might help me avoid or improve upon the auto-prepend, still include the file, and still keep the XML declaration intact as the very first characters in the document. I'll even take suggestions from mod_perl if I have to...

mordred
11-03-2002, 10:06 AM
Just curious, from what I understand in your post you rule out


<?php
header('Content-type: text/xml');
?>


because this must come before the xml declaration. But why? The generated xml should still be valid when it comes to the client.

On the other hand, isn't there a possiblity for the server admin to disallow overriding of .htaccess values?

Bawy
11-04-2002, 12:34 AM
You could set the .htaccess to disallow overrides, but of course that would seriously limit functionality. Whatever file you are prepending could have an include_once 'yourXMLfile.php' tag, no?

Alex Vincent
11-06-2002, 02:47 AM
Mordred: You just stumbled on the gist of the file I prepend. :)

I just conceptually like the idea of a document being well-formed before it goes through PHP and after it goes through PHP. So that if you call the file and PHP is not interfering, it's still XML.

Bawy: I'm thinking the approach you suggest is probably the way to go -- but how would I create a standardized approach? Say each directory had a prepend_php file, and the script wanted to include each such file in every directory above it?