PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
dankish
Forum Newbie
Posts: 3 Joined: Wed Jan 26, 2005 7:56 pm
Post
by dankish » Wed Jan 26, 2005 7:58 pm
how do i block a site,not an IP from having access to my site?
Code: Select all
$referer = $_SERVERїHTTP_REFERER];
if ($refer=="0.0.0.0") Header("Location: http://www.google.com");
isnt working
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Jan 26, 2005 8:56 pm
blocking a site? Your code appears to try to block a referrer. Referral information is optional for a browser to send, and as such, cannot be trusted to exist.
dankish
Forum Newbie
Posts: 3 Joined: Wed Jan 26, 2005 7:56 pm
Post
by dankish » Wed Jan 26, 2005 10:38 pm
yes,its to block a referrer...i keep getting spammed in my guestbook from this site.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Jan 26, 2005 10:44 pm
provided the referrer is set, you can use parse_url() to break out the domain name, and a string function like strpos() to check if the domain is them..
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Jan 26, 2005 10:47 pm
thegreatone2176
Forum Contributor
Posts: 102 Joined: Sun Jul 11, 2004 1:27 pm
Post
by thegreatone2176 » Sat Jan 29, 2005 2:38 pm
i believe an easier way to do this would be to check to make sure the referer is from your guestbook page
i used this for my guestbook
Code: Select all
if (!empty($_POSTї'username']) && !empty($_POSTї'message'])){
$ref = $_SERVERї"HTTP_REFERER"];
if ($ref != "www.bluelightningblade.com/guestbook" || $ref != "www.bluelightningblade.com/guestbook/index.php"){
echo "Invalid Referer";
die;
}
}
it first checks if the username and message is sent because if its not they page needs to be accessed so people can post
then if they are posted it checks to make sure they came from where the form is submitted
Last edited by
thegreatone2176 on Sat Jan 29, 2005 2:45 pm, edited 1 time in total.
Joe
Forum Regular
Posts: 939 Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow
Post
by Joe » Sat Jan 29, 2005 2:42 pm
.htaccess roX my SoX
(look it up)