|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
>>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!"; |
|
#3
|
|||
|
|||
|
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] |
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
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] |
|
#6
|
|||
|
|||
|
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?
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > how to log new environmental variables? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|