I just upgraded to Mint 1.2. When I installed it, the option of automatically inserting the JavaScript include file came up. I never knew that this could be done, but with a few tricks, here it is.
Add this to the .htaccess file in the root html folder, usually named public_html.
<code>AddType application/x-httpd-php .html .htm .php<br /> php_value auto_prepend_file /home/yourcode.php</code>
In that yourcode.php file, buffer the page output with the ob_start function. Then write your function to be called by ob_start that will replace the </head> tags with your script. Here is an example (not taken from the source code of Mint).
<code>&lt;?<br />
function replaceHeaders() {<br />
= '&lt;script scr="/yourjs.js"&gt;&lt;/script&gt;';<br />
return str_replace('&lt;/head&gt;', ."&lt;/head&gt;", );<br />
}<br />
ob_start("replaceHeaders");<br />
?&gt;</code>
Then you get that script inserted in front of the head tag for every freaking page on your site. Even the html ones that don’t include php pages. Damn I’m smart.
Same goes for appending files à la
php_value auto_append_file /foo/bar/append.php. I have been applying this functionality to automatically Gzip every document for as long as I can remember, and it works like a charm.prepend.phpappend.phpMatthias: As far as I know, flushing the file is not necessary, as it’s handled automatically by php.
I wonder if you could make images work, based off the file url and something like this:
AddType application/x-httpd-php .*php_value auto_prepend_file /home/yourcode.php
And then detect the filename of the requested file, and set the correct header based on that.