1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Referer Log Script

Discussion in 'Other Languages' started by neta1o, May 29, 2009.

  1. neta1o

    neta1o Regular Member

    Joined:
    Sep 29, 2008
    Messages:
    388
    Likes Received:
    318
    Home Page:
    Here is a basic script you can add to save the referrers to your page in a txt file refer.txt

    PHP:
    <?php
    $refer 
    $_SERVER['HTTP_REFERER']; //save refer in variable
    $file "refer.txt";
    $fp fopen($file"a"); // append to end of content in log file
    chmod("refer.txt"0777); // make sure file is writable
    fwrite($fp"\r\n".$refer); // < br /> added for screen output clarity
    fclose($fp);
    echo 
    '<META http-equiv="refresh" content="0;URL=http://www.google.com">';
    ?>
    You just make the refer.txt file in the same directory as the file that has this code in it, and make the refer.txt file 777 writable

    Also this part is optional

    HTML:
    <META http-equiv="refresh" content="0;URL=http://www.google.com">
    You could display a page via html or anything else
     
    • Thanks Thanks x 1
  2. blackcat.private

    blackcat.private Newbie

    Joined:
    Apr 23, 2009
    Messages:
    18
    Likes Received:
    0
    Please don't chmod it to 777, it's a quite big security issue...you just need to have read/write access for your apache user ;)