using HTTP_REFERER to hide content...

Discussion in 'PHP' started by ignas2526, Oct 11, 2008.

  1. #1
    Hello,
    I trying to create code what will hide content if its for example being viewed by proxy... But for unknown reason proxy still can view page, also hotlink works to. Any ideas how to fix it?
    Here is code:
    
    $validprefixes = array (
    "page.com",
    "www.page.com"
    ) ;
    function isreferrerokay ( $referrer, $validprefixes )
    {
    	$validreferrer = 0 ;
    	$authreferrer  = current( $validprefixes );
    	while ($authreferrer) {
    		if (eregi( "^https?://$authreferrer/", $referrer )) {
    		$validreferrer = 1 ;
    		break ;
    		}
    		$authreferrer = next( $validprefixes );
    	}
    	return $validreferrer ;
    }
    $referrer = getenv("HTTP_REFERER" );
    if (isset($_SERVER['QUERY_STRING'])) {
    if (empty($referrer) || isreferrerokay( $referrer, $validprefixes )) {
    //all content goes here
    }}
    PHP:
    Thanks.
     
    ignas2526, Oct 11, 2008 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
  3. ignas2526

    ignas2526 Peon

    Messages:
    75
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks, but my code does same thing like this one:
    if(stristr($_SERVER[’HTTP_REFERER’],”myBlackhatdomain.com”)!==FALSE) //we have a BH redirect
    {
    //Output the Javascript in Step 5
    }
    else
    {
    //Output pretty whitehat content that will satisfy an affiliate program
    }
    PHP:
    except "//Output the Javascript in Step 5". I cant understand why my code doesn't work, because then i tried echo $_SERVER[’HTTP_REFERER’]; it returned me my page then i was on my page.
     
    ignas2526, Oct 12, 2008 IP