#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    6
    Rep Power
    0
    For privacy reason, I don't want to log the ip address of visitors. So that I use MD5->hexhash() to encrypt the ip address. I want to add a new environmental variable, which is the encrypted ip address, then I can log it.
    Does anyone know how to add a new environmental variable, and how to log it?
    Thanks.
  2. #2
  3. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    >>I don't want to log the ip address of visitors.
    >>So that I use MD5->hexhash() to encrypt the ip address.

    You can't decrypt the encrypted ip back to the original ip. So why do you have to log ip addresses at all? Just for curiousity? Will they be visible by everyone and not just yourself? Well, for whatever reason, here is the script anyway..

    #!/usr/local/bin/perl
    $log_file ="/path/to/log.txt";
    $ip = $ENV{'REMOTE_ADDR'};
    $salt = substr($ip,0,2);
    $encrypted_ip = crypt($ip,$salt);
    open(LOG,">>$log_file");
    flock (LOG, 2);
    print LOG "$encrypted_ipn";
    close(LOG);
    print "Content-type: text/htmlnn";
    print "Hello World!";
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    6
    Rep Power
    0
    The reason I wanna to use MD5->hexhash() to encrypt the ip is that we want to discriminate different users but don't want to know their identities. I want to replace the client ip address in the access_log with encrypted ip address. Would you tell me how to do it? Thanks.

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by freebsd:
    >>I don't want to log the ip address of visitors.
    >>So that I use MD5->hexhash() to encrypt the ip address.

    You can't decrypt the encrypted ip back to the original ip. So why do you have to log ip addresses at all? Just for curiousity? Will they be visible by everyone and not just yourself? Well, for whatever reason, here is the script anyway..

    #!/usr/local/bin/perl
    $log_file ="/path/to/log.txt";
    $ip = $ENV{'REMOTE_ADDR'};
    $salt = substr($ip,0,2);
    $encrypted_ip = crypt($ip,$salt);
    open(LOG,">>$log_file");
    flock (LOG, 2);
    print LOG "$encrypted_ipn";
    close(LOG);
    print "Content-type: text/htmlnn";
    print "Hello World!";
    [/quote]

  6. #4
  7. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    access_log?? So you were talking about Apache then.

    Well, you can't. You need a customize script for that. What you can do is to keep your acess_log untouched. Write a customize script to read access_log and print the encrypted IPs back to screen.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    6
    Rep Power
    0
    thanks. Freebsd.
    I know that we can log any environmental variables. If we can set a new environmental variable, and set its value to be the encrypted ip address, then we can implement it. I have the perl encryption script already. I just dont' know how to add an environmental variable, and set its value to the result of a perl script.
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by freebsd:
    access_log?? So you were talking about Apache then.

    Well, you can't. You need a customize script for that. What you can do is to keep your acess_log untouched. Write a customize script to read access_log and print the encrypted IPs back to screen.
    [/quote]

  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 1999
    Posts
    33
    Rep Power
    15
    mod_rewrite for apache? you can do some funky stuff with that. Maybe write your own apache module? Or, why even log the ip at all?

IMN logo majestic logo threadwatch logo seochat tools logo