HTTP_REFERER
Posted: Sat Sep 14, 2002 4:09 pm
I was looking @ PHP Manual but can't seem to find HTTP_REFERER. Did google search still nothing, any other manuals out there? 
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
hob_goblin wrote:didnt look hard enough
http://www.php.net/manual/en/print/rese ... iables.php
'REMOTE_ADDR'
The IP address from which the user is viewing the current page.
Code: Select all
<?php
if(!eregi("domain.com",$refr)) {
error
} else {
pass
}
?>Code: Select all
<?php
if(!strpos("domain.com", $_SERVERї'HTTP_REFERER'])) {
die('error')
}
?>Code: Select all
$block = array('bar.com', 'foo.com');
$ref = $_SERVERї'HTTP_REFERER'];
$ref = str_replace('http://www.', '', $ref);
$ref = str_replace('http://', '', $ref);
$ref = explode('/', $ref);
$ref = $refї0];
function checkblock($block_array, $url){
foreach($block_array as $key){
if($key == $url)
return TRUE;
}
}
if(!checkblock($block, $ref)){
echo 'they passed';
}Code: Select all
function check($array, $url){
foreach($array as $val){
if(!eregi($url, $val)){
return FALSE;
} else {
return TRUE;
}
}
$urls = array("foo.com", "bar.com"); // ALLOWED SITES
if(!check($urls, $_SERVERї'HTTP_REFERER'])){
echo 'you're not from my site';
} else {
echo 'heres what you want';
}