Forum Moderators: coopster
$self = $_SERVER["PHP_SELF"];
$index = strpos($self, "index.php");
$admin = strpos($self, "admin.php");if (($index === false) ¦¦ ($admin === false))
{
die ("You can't access this file directly...");
}
However this works...
if ($index === false) // or admin.php, either works, but only one.
{
die ("You can't access this file directly...");
}
I've also tried doing this with index.php and admin.php in an array, and it still doesn't work as expected. I'd prefer to have the script be something like the following. Naturaly it does notwork either when having two strpos() functions.
$self = $_SERVER["PHP_SELF"];if ((!strpos($self, "index.php")) ¦¦ (!strpos($self, "admin.php")))
{
die ("You can't access this file directly...");
}
Any help would be greatly appreciated.
[edited by: Borgscan at 3:40 am (utc) on Aug. 17, 2007]
I think it might have been the ¦¦ in my statement that was stopping it from working.
Once again, thannks.
EDIT: Yeah, it was definetly my use of ¦¦ (OR) in the statement. is there any benefits to using strstr() instead of strpos()? Just I read somewheret that strpos was faster.
[edited by: Borgscan at 6:45 am (utc) on Aug. 17, 2007]