Is there some way to limit loading of a php file to localhost only?
I’m including some php files in my index.php file to stich together a webpage. Lets say I’m including main.php in my index.php file. Now there is nothing that can stop anyone from loading the main.php file and displaying its content. As the main.php file is made to be stiched into the index.php file it doesn’t look good alone.
Is there some code I can put in the main.php file so it doesn’t output anything if not included from a localhost php file?
Something like:
.
.
.
You can also define a constant/variable in your index.php and check for it in main.php. That’s how Joomlas of the world do it also. So, DEFINE(‘MYVAR’, 1); in index.php. Main.php would have