Hi,
I have inherited a number of grossly coded PHP files, whose output I need to alter programmatically.
To achieve this, I chose to run them through another PHP file, rewriter.php, which looks approximately like this:
<?php
if(!preg_match('/^([a-zA-Z0-9\-_]*)$/', $_GET['page']))
die('Incorrect page supplied.');
ob_start('changeOutput');
include($_GET['page'].'.php');
ob_end_flush();
function changeOutput ($buffer) {
...
}
?>
I use mod_rewrite to force them to run through this file:
RewriteEngine On
RewriteRule ^([^\.]*)\.php$ rewriter.php?page=$1
However an error message is displayed which makes me believe that the include() statement is affected by the RewriteRule above, i.e. it tries to run rewriter.php through rewriter.php and so on.
I suppose there are many ways to tackle this problem but I am specifically looking for a way to escape the include() statement from being affected by mod_rewrite. I looked through the module documentation but I couldn't find anything relevant.
Of course, alternatives to this approach are welcome too.
Thank you for your time and thinking.
Best regards,
Daniel