Daily IP Logger

Discussion in 'PHP' started by bluesky422, Jun 16, 2008.

  1. #1
    Hello Everyone, I am trying to modified the code below to create a daily IP log file. I am a newbie so any help would be appreciated. Thanks!

    ---------------------------------------------------------------------

    <?php

    function logIP()
    {
    // $ipLog="logfile.html"; // Your logfiles name
    $ipLog=("iplogfile2-".gmdate('Y-m-d').".html");

    // IP logging

    $register_globals = (bool) ini_get('register_gobals');
    if ($register_globals) $ip = getenv(REMOTE_ADDR);
    else $ip = $_SERVER['REMOTE_ADDR'];

    $date=date ("H:i");
    $log=fopen("$ipLog", "a+");

    if (preg_match("/\bhtm\b/i", $ipLog) || preg_match("/\bhtml\b/i", $ipLog))
    {
    fputs($log, "$ip - $date<br>");
    }
    else fputs($log, "$ip - $date\n");

    fclose($log);
    }

    logIp();


    ?>
    --------------------------------------------------------
     
    bluesky422, Jun 16, 2008 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    kmap, Jun 16, 2008 IP
  3. bluesky422

    bluesky422 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks Alex but I do not see an example of creating a unique IP log file on a daily basis. Can you please explain further. Thanks!
     
    bluesky422, Jun 17, 2008 IP