WEB Does $_SERVER['HTTP_REFERER'] contain the referring page's title?

Discussion in 'OT Technology' started by m3s3lf, May 5, 2009.

  1. m3s3lf

    m3s3lf *Jeep Crew*

    Joined:
    Oct 4, 2001
    Messages:
    5,460
    Likes Received:
    0
    Location:
    Sacramento, CA
    I'm trying to retrieve the referring page's title (which would be an external page). I doubt this is possible, but anybody have any ideas?
     
  2. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    only gives the url.

    you could try to make a GET request to the url, and retrieve the title though
     
  3. Deviance

    Deviance Can't you smell that smell? OT Supporter

    Joined:
    Jul 10, 2007
    Messages:
    4,994
    Likes Received:
    12
    Location:
    Rocky Mountain High
    Normally you would pass it as a variable like..

    <?php
    $_Session["referrerTitle"] = $pageTitle;
    ?>

    Not sure how you would do it from an external site unless you add a script that looks up the page title when receiving a referrer without a title variable.
     
  4. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    Why not file_get_contents on the http referer then parse for what's in the <title></title>.

    Code:
    $refererPageContent = file_get_contents( $_SERVER['HTTP_REFERER'] );
    
     
    Last edited: May 8, 2009
  5. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,652
    Likes Received:
    15
    Location:
    Atlanta

    this
     
  6. m3s3lf

    m3s3lf *Jeep Crew*

    Joined:
    Oct 4, 2001
    Messages:
    5,460
    Likes Received:
    0
    Location:
    Sacramento, CA
    It's an external page. Otherwise it'd be a piece of cake.
     
  7. m3s3lf

    m3s3lf *Jeep Crew*

    Joined:
    Oct 4, 2001
    Messages:
    5,460
    Likes Received:
    0
    Location:
    Sacramento, CA
    Will that work for an external page? I'll check it out!
     
  8. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    It should as long as they don't clear the referrer information, and there is no POST dynamic content on it.
     
  9. m3s3lf

    m3s3lf *Jeep Crew*

    Joined:
    Oct 4, 2001
    Messages:
    5,460
    Likes Received:
    0
    Location:
    Sacramento, CA
    I got it working with:
    Code:
    <?php
    $refererPageContent = file_get_contents($_SERVER['HTTP_REFERER']);
    
    preg_match("'<title>([^<]*?)</title>'", $refererPageContent, $matches);
    $webpage_title = $matches[1]; 
    
    echo $webpage_title;
    ?>
    Is yours more efficient? I'm just concerned that mine will eat up a lot of CPU.
    Thanks all!
     

Share This Page