Results 1 to 5 of 5

Thread: IP Tracker

  1. #1
    Join Date
    Sep 2004
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default IP Tracker

    I found this script:

    PHP Code:
    <?

    /*
     * This script is copyright PHPGarage.com (On Line Construction Inc.). It may be used,
     * changed, and distributed freely as long as this message and/or some type of recognition
     * is given to PHPGarage.com or On Line Construction Inc.
     * 
     * http://www.phpgarage.com
     * http://www.onlineconstructioninc.com
     *  
    */
    $register_globals = (bool) ini_get('register_gobals');
         if (
    $register_globals$ip getenv(REMOTE_ADDR);
    $ip $_SERVER['REMOTE_ADDR'];

    $CurrentDate date("m-d-Y h:ia");
    $TextFile "aimtracker.html";
    $Body "$_REQUEST[name]  $ip<br>";
    $Body .= file_get_contents($TextFile);
    $Anon "Unknown User";
    {
    if ( empty (
    $_REQUEST[name]) ) {
      (
    $FP fopen ($TextFile"w") ) 
      
    fwrite($FP$Anon);
      
    fclose($FP);
    }
    {
    else ((
    $FP fopen($TextFile"w"))
      
    fwrite($FP$Body);
      
    fclose($FP);
    }
    ?>
    But it gives me this error when I try to execute it:

    Parse error: parse error, unexpected T_STRING in /home/public_html/folder/main2.php on line 24

    Line 24 is fwrite($FP, $Anon);

    Any ideas? I'm pretty new to php, sorry.

  2. #2
    Join Date
    Sep 2004
    Location
    UK
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry, I changed the script quite a bit, hopefully you can still see what it's doing. Also I added the date into the log seen as it wasn't doing anything, and changed the writing for an unknown user, which would've wiped out your log.

    PHP Code:
    <?php

    /*
    * This script is copyright PHPGarage.com (On Line Construction Inc.). It may be used,
    * changed, and distributed freely as long as this message and/or some type of recognition
    * is given to PHPGarage.com or On Line Construction Inc.
    *
    * http://www.phpgarage.com
    * http://www.onlineconstructioninc.com
    *  
    */ 

    $TextFile "aimtracker.html";
    $contents file_get_contents($TextFile);
    $CurrentDate date("m-d-Y h:ia");
    $ip = (isset($_SERVER)) ? $_SERVER['REMOTE_ADDR'] : $HTTP_SERVER_VARS['REMOTE_ADDR'];
    $info = (empty($_REQUEST['name'])) ? 'Unknown User' $_REQUEST['name'].' '.$ip;
    $log $CurrentDate.' '.$info."<br />\n".$contents;
    if(
    $FP fopen($TextFile"w")){
        
    fwrite($FP$log);
        
    fclose($FP);
    }

    ?>

  3. #3
    Join Date
    Sep 2004
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks a bunch Odin! Works great.

  4. #4
    Join Date
    Sep 2004
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Doh, ok almost there!

    It doesn't log the IP for anonymous users, I can't tell why not, any ideas?

  5. #5
    Join Date
    Sep 2004
    Location
    UK
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok, change:
    $info = (empty($_REQUEST['name'])) ? 'Unknown User' : $_REQUEST['name'].' '.$ip;
    $log = $CurrentDate.' '.$info."<br />\n".$contents;

    To:
    $user = (empty($_REQUEST['name'])) ? 'Unknown User' : $_REQUEST['name'];
    $log = $CurrentDate.' '.$user.' '.$ip."<br />\n".$contents;

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •