Add or find the log for ip addresses Add or find the log for ip addresses
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Add or find the log for ip addresses

Started by Yabba, October 07, 2006, 04:41:27 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yabba

Hi all

Im looking for the function to log the ip addresses in a log file like the security, database, access view in view log files menu. When users log in to the coppermine album.
GauGau has one topic that handles the vote stats on: http://forum.coppermine-gallery.net/index.php?topic=36276.0  he is able to sort out the ip addresses in that topic.

So basicly my question is to add an extra log file with just logins that includes the namne, time, ip-address

Today there is a log file (se attachment) for bad logins  I would like the same structure but an extra log with successful logins instead
Thanks in advanced
Yabba

EDIT: Just to clear it up. I do not wanna know where the user has been on the album just that he/she has logged in and i can see the logg with namen and ip address, i dont have anonymous logins only registered users.
We all cannot be pro on coding. (If so all professional programmers schould be unemployed)

Fortunately the rest of us are pro's on other stuff at least this applies to me

alexunder

Does anybody know, how to do it? I've real attack on my site and I need to block some IP's.

Thank you!

Joachim Müller

Coppermine doesn't log them. Review your server's access logs.

alexunder

No, I'd like to repeat: my question is to add an extra log file with just logins that includes the namne, time, ip-address (from first post)

Thank you!

Joachim Müller

Coppermine doesn't log that piece of information. If you need those logs written, you'll have to write that piece of extra code that does this.

alexunder

You probably understand, that I can't write it.. Just don't know how.

To whom I can ask about, even if I'll have to pay for that?

Thank you very much!

Joachim Müller

You're welcome to come up with a posting on the board "Looking for Freelancers / Paid help". Read the sticky thread "sub-board rules, read first!" on that board first.

cpinetree

#7
I don't know how safe this code is but it does work:
file to change is:   
login.php

the change I made, and it seems to work with all logging turned on, is as follows:


log_write("Success login with Username: {$_POST['username']} from IP {$_SERVER['REMOTE_ADDR']} on " . localised_date(-1,$log_date_fmt),CPG_SECURITY_LOG);

I pasted the above code after :

$cookie_warning = '';

if (isset($_POST['submitted'])) {
    if ( $USER_DATA = $cpg_udb->login( addslashes($_POST['username']), addslashes($_POST['password']), isset($_POST['remember_me']) ) ) {
        $referer=preg_replace("'&'","&",$referer);
        pageheader($lang_login_php['login'], "<META http-equiv=\"refresh\" content=\"3;url=$referer\">");
        msg_box($lang_login_php['login'], sprintf($lang_login_php['welcome'], $USER_DATA['user_name']), $lang_continue, $referer);


--------------------added code here approx line # 43-----------------

and before:

pagefooter();
        exit;
    } else {
        log_write("Failed login attempt with Username: {$_POST['username']} from IP {$_SERVER['REMOTE_ADDR']} on " . localised_date(-1,$log_date_fmt),CPG_SECURITY_LOG);



hope that helps and makes sense to you.

Joachim Müller

Edited your posting, adding some bbcode code tags to make it more readable.

cpinetree

thanks for the edit, I am kind of new to forum use.
much more readable now,
   thanks again.