Problème variable vide

WRInaute discret
Bonjour,

Je me bagarre depuis ce matin sur un bout de code et je ne comprend pas ce qui cloche peut être pouvez vous m'aider :

Code:
$ref = $_SERVER['HTTP_REFERER'];
    $ref_exp = explode("/", $ref);
    // Clean our referer
    $ref1 = $ref_exp[2];
    $ref2 = str_replace("www.", "", $ref1);

    // We're dealing with a local/intranet referer, which is no good to us
    if(!preg_match("/\./", $ref2))
    {	return;	}

    // We've been brought to this page from a link on the same site
    //if(preg_match("/{$ref2}/", $HTTP_SERVER_VARS['HTTP_HOST']))
      if(preg_match("/{$ref2}/", $_SERVER['HTTP_HOST']))
    {	return;	}

    $domainarray = parse_url($ref2);
    $ref3 = $domainarray['host'];

    $domain = $ref3;

La variable $sdomaine est vide alors qu'elle fonctionne si je met la ligne :
$ref2 = http://www.monsitedetest.com";
avant : $domainarray = parse_url($ref2);
 
Nouveau WRInaute
Bonjour,

je me trompe peut etre mais je pense que ton soucis viens de
Code:
// We've been brought to this page from a link on the same site
    //if(preg_match("/{$ref2}/", $HTTP_SERVER_VARS['HTTP_HOST']))
      if(preg_match("/{$ref2}/", $_SERVER['HTTP_HOST']))
    {   return;   }

Surtout si tu test en local, en espérant t'avoir un peu aidé
 
Discussions similaires
Haut