Does anyone know how to stop people from reloading or pointing to a php script directly?
Example: I have a script that gives 50 points to a user when they sign up. if you reload that script it gives them 100 points!
Another example i have a script that has many
different steps
member.php?step1
member.php?step5
member.php?admin
in cgi I can stop this by check to see if it came from the server. can this be done in php?
here is what I used in cgi to do this..
at the top of my cgi scrit I put this
@referers = ("www.$ENV{'SERVER_NAME'}","$ENV{'SERVER_NAME'}");
in a sub I want protected I place this inside
&checkreferer if (@referers);
and here are the sub it refers to..
I put these on the bottom of my cgi scripts.
sub errorme {
print "Content-type: text/html\n\n";
print "Sorry you can not do that!\n";
exit;
}
sub checkreferer {
local($check_referer) = 0;
if ($ENV{'HTTP_REFERER'}) {
foreach $referer (@referers) {
if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) {
$check_referer = 1;
last;
}
}
}
else { $check_referer = 2; }
if ($check_referer != 1) {
$error_status = "timeout";
&errorme;
}
}
I am looking for a way to do this in php.
Please help..
Thanks, in advance.