Help with this code

Discussion in 'PHP' started by hexmax, Nov 13, 2008.

  1. #1
    Hello

    I have php page i need code to prevents them from working on any site out side my domain
    thank you
     
    hexmax, Nov 13, 2008 IP
  2. rene7705

    rene7705 Peon

    Messages:
    233
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    check $_SERVER["HTTP_REFERER"] if it comes from your own domain. be sure to allow both www.something.com and something.com
     
    rene7705, Nov 13, 2008 IP
  3. garrettheel

    garrettheel Peon

    Messages:
    341
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    
    <?php
    
    if (!$_SERVER["HTTP_REFERER"] == 'mysite.com' || !$_SERVER["HTTP_REFERER"] == www.mysite.com)
    {
               die('Must come from this domain');
    }
    
    ?>
    
    Code (markup):
     
    garrettheel, Nov 13, 2008 IP
  4. nepasolutions

    nepasolutions Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    it help for me too
     
    nepasolutions, Nov 14, 2008 IP
  5. atlantaazfinest

    atlantaazfinest Peon

    Messages:
    389
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    If you do use $_SERVER["HTTP_REFERER"] i recommend regexing it and just compare to the domain part of the url .
    [edit]

    ps. some browsers strip the referrer so make other checks also.
     
    atlantaazfinest, Nov 14, 2008 IP
  6. hexmax

    hexmax Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thank you very much for your help
     
    hexmax, Nov 14, 2008 IP