Referer redirect txt file

Discussion in 'PHP' started by oneg, May 12, 2008.

  1. #1
    I have this code for referer redirect:

    <?
    $referrer = $_SERVER['HTTP_REFERER'];
    if (preg_match("/outsidesite.com/",$referrer)) {
    header('Location: http://www.mysite1.com');
    }
    else {
    header('Location: http://www.mysite.com');
    };
    ?>

    But the question is:
    If I want to match a LIST OF SITES stored on a txt file, insted of "outsidesite.com".
    How can I work with a txt list of sites: "mysites.txt"
    instead of only one site: "outsidesite.com"

    <?
    $referrer = $_SERVER['HTTP_REFERER'];
    if (preg_match("HERE A TXT WITH A LIST OF SITES mysites.txt",$referrer)) {
    header('Location: http://www.mysite1.com');
    }
    else {
    header('Location: ht*tp://www.mysite.com');
    };
    ?>


    Anyone knows what to put here: ("HERE A TXT WITH A LIST OF SITES mysites.txt"), to make it functional.
    Thanks.
     
    oneg, May 12, 2008 IP
  2. oneg

    oneg Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I am working with this:

    $file=file_get_contents("file.txt");

    if (preg_match ("/$file/", ...........

    But it only retrives the first value in the txt file, not the second line.
    How can I retrive all values, and then call $file?
    thank you.





     
    oneg, May 12, 2008 IP