My site is divided into two directories---the root for public content, and http://www.mysite.com/admin/ for administrative functions. Some scripts are used in both directories, and I'd like an easy way to determine whether one is being executed from the admin directory.
At the moment, I do the following:
$adminDir = "./admin/";
// We're in the admin directory, so execute this code
if (strstr($_SERVER['PHP_SELF'], substr($adminDir, 1)))
{
if ($user['isAdmin'] != 1)
{
exit();
}
}
Is this a reliable method of finding this out? Or is it easily breakable/exploitable?