My php facebook cloaking accurate?

Status
Not open for further replies.

Despoil

New member
Jan 26, 2009
114
0
0
St. Louis, Mo
Anyone see any flaws in my cloaking code? I can't seem to get anything by. It started from Nicky Cakes code then I tried to add all the other reviewers.

<?php
$cloaked_url = "http://www.google.com"; // devs go here
$normal_url = "http://www.yahoo.com"; // everyone else goes here

$tracking_ref = $_SERVER['HTTP_REFERER'];

if(strpos($tracking_ref,"dev.facebook")){
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: " . "non affili site" );
} else {
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: " . "affili site" );
}
if(strpos($tracking_ref,"devrs001.facebook.com")){
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: " . "non affili site" );
} else {
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: " . "affili site" );
}
if(strpos($tracking_ref,"/intern/ads/review.php")){
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: " . "non affili site" );
} else {
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: " . "affili site" );
}
?>
 


Biggest flaw I see is, that you repeated

Code:
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: " . "affili site" ); (and it's variants)

A number of times when you could have simply
Code:
<?php
$cloaked_url = "http://www.google.com"; // devs go here
$normal_url = "http://www.yahoo.com"; // everyone else goes here

$tracking_ref = $_SERVER['HTTP_REFERER'];

if((strpos($tracking_ref,"dev.facebook") === false) && (strpos($tracking_ref,"devrs001.facebook.com") === false) && (strpos($tracking_ref,"/intern/ads/review.php") === false))
{
   $target = $normal_url;
} else {
   $target = $cloaked_url;
}

Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: " . $target);
?>

basically you want to goto the normal url when people are not coming from the review/developer section of facebook, well strpos can return 0 if the match is found at the beginning of the string, meaning a positive that appears to be a false. And since == can match 0 as a false, you want to use === to match a boolean false. In the code above its stating if this, that and that is false goto the normal url, otherwise goto the cloaked url.

Apparently nicky is not a coder if he conditioned strpos in that way on the original code. :P
 
Status
Not open for further replies.