Gossamer Forum
Home : Products : DBMan : Customization :

date in logfile not right

Quote Reply
date in logfile not right
I get the date 01-jan-1970 in my log file for dbMan - this is the default date I understand, but I have tried changing the date-routines in dbman.cgi as shown - it is the JPDeni fix:

What do I do wrong:

my ($time1) = $_[0];
($time1) or ($time1 = time());

my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time1);
my (@months) = qw!jan feb mar apr maj jun jul aug sep okt nov dec!;
($day < 10) and ($day = "0$day");
$year = $year + 1900;

return "$day-$months[$mon]-$year";
}


sub date_to_unix {
# --------------------------------------------------------
# This routine must take your date format and return the time a la UNIX time().
# Some things to be careful about..
# int your values just in case to remove spaces, etc.
# catch the fatal error timelocal will generate if you have a bad date..
# don't forget that the month is indexed from 0!
#
my ($date) = $_[0];
my (%months) = ("jan" => 0, "feb" => 1, "mar" => 2, "apr" => 3, "maj" => 4, "jun" => 5,
"jul" => 6, "aug" => 7, "sep" => 8, "okt" => 9, "nov" => 10,"dec" => 11);
my ($time);
my ($day, $mon, $year) = split(/-/, $_[0]);
unless ($day and $mon and $year) { return undef; }
unless (defined($months{$mon})) { return undef; }

use Time::Local;
eval {
$day = int($day); $year = int($year) - 0;
$time = timelocal(0,0,0,$day, $months{$mon}, $year);
};
if ($@) { return undef; } # Could return 0 if you want.
return ($time);
}
Quote Reply
Re: [poulR] date in logfile not right In reply to
Check out or search for this thread:

http://gossamer-threads.com/p/96233 (may have changed)
Subject: Default.log
lanerj - 26-Jul-00

It will also refer you to a fix I use for my databases called:

Hypermart fix for auth.pl file.

It seems that Hypermart servers does not use the remote host command as needed by DBMan. This solution will let you log
remote hosts:

In auth.pl file make the following changes:

Add the sub GetHost to your auth.pl file. In sub auth_logging,

After: my ($date) = &get_date(time);

which may have to be replaced with: my ($date) = &get_date(time()); # in get_time and get_date.

Add: my($host) = &GetHost; #### change for Hypermart servers

and then change:

print LOG "$uid $action at $time on $date from $ENV{'REMOTE_HOST'}\n";

To:

print LOG "$uid $action at $time on $date from $host\n";
#### added for Hypermart ###########

sub GetHost {
#------------------------------------------------------
if (($ENV{'REMOTE_HOST'} eq $ENV{'REMOTE_ADDR'}) && ($ENV{'REMOTE_ADDR'} =~/(\d+)\.(\d+)\.(\d+)\.(\d+)/)) {
$ip = pack('C4', $1, $2, $3, $4);
$DNS_Address = (gethostbyaddr($ip, 2))[0];
$ENV{'REMOTE_HOST'} = $DNS_Address if $DNS_Address; }
$ENV{'REMOTE_HOST'} =~ tr/[A-Z]/[a-z]/;
$hostname = gethostbyaddr pack ( 'C4' , split /\./, $ENV {REMOTE_ADDR} ) ,2;
}
### end add for Hypermart servers ###

I have used this for various host providers and it works.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] date in logfile not right In reply to
YES !

I used the my ($date) = &get_date(time()); # in get_time and get_date. in auth.pl

That did it.

Thank You very much.
Quote Reply
Re: [poulR] date in logfile not right In reply to
BUT now I do not get any "action" messages in the logfile.

As: NN modified record: 2004001 at 11:31:01 on 01-jan-1970 from 0x50c62e41.k....

which I had prviously.

I only get the logon time and date written to the file?
Quote Reply
Re: [poulR] date in logfile not right In reply to
Sorry, it seems ok now, I think the file got cached in the Ftp prog, so I couldnt see the changes.

But my Modify Multiple Records patch does not write to the logfile, so I will have to look into that.

But that will be a new question.