Gossamer Forum
Home : Products : DBMan : Customization :

Log question

Quote Reply
Log question
Is there a way to make a mod for viewing the default.log through a browser?

I would like to set this up as an admin only function. Also, I would like to ultimately display the last 3 logins on the sub html_home like: "name , day and time of login".

I used the search and was unable to find anything like this.

Any ideas?
----------------
donm
Quote Reply
Re: Log question In reply to
I'm sure such a thing could be done. Seems to me like anything that opens, reads and displays a file is possible.

Not today, though. I'm not going to spend all day in front of the computer. I promised hubby I'd make him some cookies today. Smile


------------------
JPD





Quote Reply
Re: Log question In reply to
Good for you Carol ! Maybe when you have some time you can give it some thought?



------------------
Quote Reply
Re: Log question In reply to
I have a few questions, Don.

Do you want to view the log page from within the Admin display page or a separate page? Do you need to be able to edit the .log file or just view it?



------------------
JPD





Quote Reply
Re: Log question In reply to
We just want to view the last 3-5 logins from the sub html_home page.

Name and time of login.

Thanks!
------------
donm
Quote Reply
Re: Log question In reply to
I thought you wanted admins to be able to view the .log file. And the last 3-5 logins (gotta know how many you want) would be something to add later. Unless I completely misread your first post.


------------------
JPD





Quote Reply
Re: Log question In reply to
Carol - I apologize, you are correct. At first, the admin would be able to read the log file from the admin page.

and.....

Ultimately, you could see the last 3-5 logins from the sub html_home page this way:

"Name - time and day of login"

Thanks :-)
-------------
donm
Quote Reply
Re: Log question In reply to
Okay. So you just want the admin to be able to view the .log file from the admin display. Do you want the admin to be able to modify it as well?

How many logins do you want to to display on the home page? You say "3-5." Do you want 3? 4? 5?


------------------
JPD





Quote Reply
Re: Log question In reply to
Carol - We would like for the admin to be able to view the log file using a link from the admin screen.

We would like to display the last 5 logins like: Name - time/date on the sub home_html page.

--------------
donm

[This message has been edited by donm (edited October 06, 1999).]

[This message has been edited by donm (edited October 07, 1999).]
Quote Reply
Re: Log question In reply to
I don't think it has been done before. I just needed to know what you wanted so I wouldn't be giving you something you didn't want.

As soon as I get this bunch of questions answered, I'll make your mod for you. That's a separate link, available only on the admin display, to view (but not edit) the log file. And a list of the last five people who have logged in.



------------------
JPD





Quote Reply
Re: Log question In reply to
Carol - Thanks ! I just thought that if it had been discussed before I would read what had been done.

Thanks for your help !



------------------
donm
My theory on evolution is that Darwin was adopted.--Steven Wright

Quote Reply
Re: Log question In reply to
Has this been done before? I searched and could not find a post on it? Maybe I am searching using the wrong words?



------------------
donm
My theory on evolution is that Darwin was adopted.--Steven Wright

Quote Reply
Re: Log question In reply to
Carol - Thank you - it works great !!



------------------
donm
My theory on evolution is that Darwin was adopted.--Steven Wright

Quote Reply
Re: Log question In reply to
Okey-dokey. With all my usual caveats, here's the code.

In sub html_home, where you want to print out the last 5 logins, add

Code:
open (LOG, "<$auth_log_file") or &cgierr("error in view_log.
unable to open log file: $auth_log_file.\nReason: $!");
if ($db_use_flock) { flock(LOG, 1); }
@lines = <LOG>;
close LOG;

$log_number = $#lines;

print "Our last 5 visitors:<BR>\n";

while ($log_count < 5) {
$line = $lines[$log_number];
--$log_number;
chomp $line;
if ($line =~ /logged on at /) {
++$log_count;
$line =~ s/logged on at //;
$line =~ s/ on /\//;
$place = index $line, " from ";
$line = substr($line,0,$place);
print "$line<BR>\n";
}

}

In sub html_admin_display, add the following link:

Code:
print qq!| <A HREF="$db_script_link_url&view_log=1">View Log</A> !;

In sub html.pl add the following subroutine:

Code:
sub html_view_log {
# --------------------------------------------------------


&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: View Log</title>
</head>

<body bgcolor="#DDDDDD">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: View Log</b>
</td></tr>
<tr><td><p><center><$font_title><b>View Log</b></font></center><br>
<$font>This is the current contents of the log file:<BR><BR>|;

open (LOG, "<$auth_log_file") or &cgierr("error in view_log.
unable to open log file: $auth_log_file.\nReason: $!");
if ($db_use_flock) { flock(LOG, 1); }
@lines = <LOG>;
close LOG;

foreach $line (@lines) {
print "$line<BR>";
}
print qq|</font></p>|;
&html_footer;
print qq|</td></tr></table></center></body></html>|;
}

In db.cgi, sub main, add

Code:
elsif ($in{'view_log'}) { if ($per_admin) { &html_view_log; } else { &html_unauth; } }

That should do it.


------------------
JPD





Quote Reply
Re: Log question In reply to
Cool! Smile

(I always hold my breath when I post code. Now I can breathe again!! )

You're welcome.


------------------
JPD





Quote Reply
Re: Log question In reply to
Carol - one more question about this. Maybe this is asking too much but is there a way to NOT log when the admin logs in?



------------------
donm
My theory on evolution is that Darwin was adopted.--Steven Wright

Quote Reply
Re: Log question In reply to
You can try changing the line

&auth_logging('logged on', $userid) if ($auth_logging);

in auth.pl to

Code:
unless ($admin) {
&auth_logging('logged on', $userid) if ($auth_logging);
}

It might work. (Notice that I'm using $admin and not $per_admin. That is intentional.)


------------------
JPD





Quote Reply
Re: Log question In reply to
Carol - Again - it works great !!!!!

Thanks!



------------------
donm
My theory on evolution is that Darwin was adopted.--Steven Wright