Forum Moderators: coopster
Example URL:
[mysite.com...]
I want code that prevents someone from calling a file from another site, for example:
[mysite.com...]
Otherwise, I could explore your whole site by trying things like:
variable=../../../etc/passwd
One way, is to parse the variable so the only part youn take is the last part -- passwd in the example. And then read it only from the one folder you keep user-accessible files in.
If they have some sway over the folder, then relax the above code a little.
I tried the following, but it doesn't seem to work:
if ($URI == ("http://mysite.com/page.php?variable=".$variable)) {
die("You are not authorized to view this page.");
}
else { blah, blah }
if ($_SERVER['REQUEST_URI'] == ("http://mysite.com/page.php?variable=".$variable)) {
die("You are not authorized to view this page.");
}
else { //continue with script
}
I assume the server doesn't distinguish between $_SERVER['REQUEST_URI'] typed in the address bar or called from the script. Is there a different variable I can call there that ONLY applies to the URI or URL typed in the address bar?