PHP referrer cloaking script

Discussion in 'PHP' started by Ithilnet, Apr 2, 2007.

Thread Status:
Not open for further replies.
  1. #1
    Hi, I need a simple PHP script but I can't code it properly.
    It's a thing with Apache2 with URL Rewrite but I don't know how to make it.
    The script have to perform this task:

    IF the visitor comes from[LIST OF SITES]
    THAN
    display something
    ELSE
    display something else


    For example:
    if the visitor comes from digital point serve
    <html>

    <head>
    <title>Page 1</title>
    </head>

    <body>
    --Something--
    </body>

    </html>

    Else

    <html>

    <head>
    <title>Page 2</title>
    </head>

    <body>
    --Something else--
    </body>

    </html>

    In the first html piece of code I will need to put also a javascript script.

    I've seen someone posted something similar http://forums.digitalpoint.com/showthread.php?t=283871

    I'm willing to pay the get the work done.
     
    Ithilnet, Apr 2, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    It's doable, but not reliable. The referer is sent by the browser, and not all browsers send it by default. And/or it can be disabled and modified easily. So simply put, you can't trust it.
     
    nico_swd, Apr 2, 2007 IP
  3. manilodisan

    manilodisan Peon

    Messages:
    224
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can do a simple SQL to compare the visitor's referer with your list of sites ex:

    $query = mysql_query("SELECT * FROM `sites_table` WHERE `sites` = `".$_SERVER['HTTP_REFERRER']."`") or die (mysql_error());
    
    if(mysql_num_rows($query)>0)
    {//if the referer is in our list of sites
       
          // Hello, you're from my list
    
    }
    else {
    
         // Hello, you're not from my list
    
    }
    PHP:
    I haven't tested the code, it's instructional...
     
    manilodisan, Apr 2, 2007 IP
  4. SoKickIt

    SoKickIt Active Member

    Messages:
    305
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    70
    #4
    
    <?php
    
    $match = false;
    $sites = array("google.com", "yahoo.com", "msn.com");
    
    if(strlen($_SERVER['HTTP_REFERER']))
    {
    	$referer = parse_url($_SERVER['HTTP_REFERER']);
    			
    	$referer['host'] = str_replace("www.", "", strtolower($referer['host']));
    
    	$match = in_array($referer['host'], $sites);
    }
    
    
    if($match)
    {
    
    ?>
    
    <html>
    
    <head>
    <title>Page 1</title>
    </head>
    
    <body>
    --Something--
    </body>
    
    </html>
    
    <?php
    
    }
    else
    {
    
    ?>
    
    <html>
    
    <head>
    <title>Page 2</title>
    </head>
    
    <body>
    --Something else--
    </body>
    
    </html>
    
    <?php
    
    }
    
    ?>
    
    
    PHP:
     
    SoKickIt, Apr 2, 2007 IP
  5. aftermarket

    aftermarket Active Member

    Messages:
    214
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #5
    How can you specify a specific url with sokickit's version. So it only cloaks 1 refering page on the whole domain, such as yoursite.com/thepageIwantRefererCloaked for only 1 page on the site
     
    aftermarket, Apr 2, 2007 IP
  6. aftermarket

    aftermarket Active Member

    Messages:
    214
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #6
    sorry...........basicly how do you cloak based on a specific refering page, without cloaking the whole domain.
     
    aftermarket, Apr 2, 2007 IP
  7. Ithilnet

    Ithilnet Peon

    Messages:
    167
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thank you very much SoKickIt.

    What have I to change to cloak specific urls?
     
    Ithilnet, Apr 3, 2007 IP
Thread Status:
Not open for further replies.