I'm trying to safely encapsulate any include() statements that may pop up in webpages in my CMS. What I'm trying to do is use preg_replace to find all occurrences of include("/something/here"); and turn it into:
Code: Select all
<?PHP $func=create_function('','include("/something/here");'); $func(); unset($func); ?>Code: Select all
$content = preg_replace("/(include\(.*?\))/i", "<?PHP \$func=create_function('', 'include($1);'); \$func(); unset(\$func); ?>", $content);Code: Select all
include("something here");
include(should not succeed);
this is a blank line;Code: Select all
;
;
this is a blank line;Any ideas?
Don't worry folks. Turns out I'm a raging idiot who doesn't know how to use str_replace. Thanks anyway.