Retarded PHP question

Status
Not open for further replies.

mattonitto

So not gangster....
Oct 30, 2007
160
3
0
How do I make these PHP have sex with each other to join as one?

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")){
    Header( "HTTP/1.1 301 Moved Permanently" );
    Header( "Location: " . $cloaked_url );
  } else {
    Header( "HTTP/1.1 301 Moved Permanently" );
    Header( "Location: " . $normal_url );
  }
?>
and

Code:
if (stristr($_SERVER["HTTP_REFERER"], “dev.facebook”)) $cloak = 1;

if (stristr($_SERVER["HTTP_REFERER"], “devrs001.facebook.com”))  $cloak = 1;

if (stristr($_SERVER["HTTP_REFERER"], “/intern/ads/review.php”))$cloak = 1;)

Thanks in advance for any help.
 


heehee bad idea but

if (strpos($tracking_ref,"dev.facebook") || stristr($tracking_ref, “devrs001.facebook.com”) || stristr($tracking_ref, “/intern/ads/review.php”))
{ header( "Location: " . $cloaked_url );} else { header( "Location: " . $normal_url );}

FWIW that's not a good idea, there's other ways to skin that cat and FB isn't stupid.
 
Code:
<?php
// simple cloaker

$referer= $_SERVER['HTTP_REFERER'];

// edit these variables
$hidefrom = array("dev.facebook", "devrs001.facebook.com", "/intern/ads/review.php");
$normal_url ="www.evil-landing-page.com";
$cloaked_url ="www.passable-landing-page.com";

// uncomment below for testing yourself as one of the referers
// $referer = "dev.facebook"; 

foreach ( $hidefrom as $value ) {
    if ( strpos( $referer, $value ) !== false ) {
        header("Location: http://" . $cloaked_url );
        exit;
    }
}

header("Location: http://" . $normal_url );
exit;

?>
 
Code:
$getout = false;
$goaway_bunch = array('dev.facebook', 'devrs001.facebook.com', '/intern/ads/review.php', 'addmorehere', 'andevenmore', 'etc');

$tracking_ref = $_SERVER['HTTP_REFERER'];
$cloaked_url = "http://www.google.com"; // devs go here
$normal_url = "http://www.yahoo.com";  // everyone else goes here

foreach($goaway_bunch as $nailed)
    if(strpos($tracking_ref, $nailed))
        $getout = true;

if($getout)
    header('location: '.$cloaked_url);
else
    header('location: '.$normal_url);
:D
 
lol I just saw you posted the same thing somlor :)
Haha.... nice. FWIW though I don't think strpos will return true on first occurrence, it returns integer of location in the string. Hence the need for != false.

Sean
 
Thanks for the overwhelming response. Much appreciated.

heehee bad idea but

FWIW that's not a good idea, there's other ways to skin that cat and FB isn't stupid.


What would you recommend? Just getting the ad approved with something legit and then running a redirect?
 
Why would you post the source code to this on a board you know facebook employees are on?

I found both pieces of PHP via this board, so I didn't expect it to be an issue. Feel free to delete the thread by all means though.
 
Why would you post the source code to this on a board you know facebook employees are on?

Because the technique is no longer relevant if it ever was; it's primarily useful to determine how Machiavellian the approvers are being. Cursory monitoring shows they're quite savvy of these pedestrian measures undertaken to deceive them, and all it does is probably put you on the list of wicked, tricksy, false hobbits.
 
I found both pieces of PHP via this board, so I didn't expect it to be an issue. Feel free to delete the thread by all means though.

Because the technique is no longer relevant if it ever was; it's primarily useful to determine how Machiavellian the approvers are being. Cursory monitoring shows they're quite savvy of these pedestrian measures undertaken to deceive them, and all it does is probably put you on the list of wicked, tricksy, false hobbits.
Points taken.
 
Haha.... nice. FWIW though I don't think strpos will return true on first occurrence, it returns integer of location in the string. Hence the need for != false.

Sean

if($var) without any comparison is exactly the same as if($var != false)... Please correct me if I'm wrong though.

strpos returns either false or the position of the occurence, and we're only checking to see IF it found something, we're not really interested in the location (for this purpose).

Why would you post the source code to this on a board you know facebook employees are on?

Facebook only serves as an example in this case, like Yahoo and Google in OP's code. It's just among the first names that come to mind when looking for an example everybody knows and can understand, given its ubiquity.
 
if($var) without any comparison is exactly the same as if($var != false)... Please correct me if I'm wrong though.

strpos returns either false or the position of the occurence, and we're only checking to see IF it found something, we're not really interested in the location (for this purpose).

I think if($var) is the same as if($var == true). In this case it won't evaluate to true since the value returned from strpos will be 3, or 15, etc.

Sean
 
Bear in mind that its a piece of piss to change your referrer to anything you fancy using firefox extensions, I'm sure the Facebook test guys know this too...
 
I think if($var) is the same as if($var == true). In this case it won't evaluate to true since the value returned from strpos will be 3, or 15, etc.

Sean

if($var == true), if($var != false), if($var) all do the same - check if $var is set at all.

The question is what values are considered FALSE:

# the boolean FALSE itself
# the integer 0 (zero)
# the float 0.0 (zero)
# the empty string, and the string "0"
# an array with zero elements
.
.
.
Every other value is considered TRUE...

(from PHP: Booleans - Manual )

When using if($var), you just check if it is set or not (if it contains any value at all).

Apart from that, if $var has not been initialized before, it is being treated as boolean. As soon as the foreach loop fills it with anything (in this case an integer), it contains a value, thus validates as true in if.

To make sure, I initialzed $getout in my code above and set it to false. I always try to do that when not inside a function/class because you might have already used that same variable somewhere above in the code.

This at least is my perception of it - it always worked for me this way. But in case I'm off with this, I'll gladly stand corrected :)
 
HEh, thanks, this may be turning into PHP 101 for somlor.

Alright, so try changing my code from:
Code:
if (strpos($referer, $value) !== false ) {

to:
Code:
if (strpos($referer, $value)) {

The latter doesn't redirect to $cloaked_url, even when there is a referer match.

Sean
 
Status
Not open for further replies.