So in file first.php I will include file original.php with include_once.
Problem occurs, when I try to call functions which are inside original.php and that file is not loading if there is no user session.
Basicaly I’m include file original.php in which are few functions im calling later in first.php, but those functions are inaccesible due to restrictions I’ve set in original.php, but now I want to add rule to original.php to allow such requests from first.php or any other PHP file that will include original.php…
I wonder what could I do in this case OR could I simply add some if clause to original.php, like:
if($fileIncluded == 'yes')
{
// do not check if user session exist etc.
}
else
{
// check for user session
}
Thanks for ideas and help in advance!
You can set a constant in the file to be included like so:
In
original.php:Then in
first.phpyou check if the constant exists:Unlike get_included_files() this will work when a script includes a script.
get_included_files()will only return the files included in the main script, but not scripts included in child scripts.Or in
original.php: