coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: GlenVision on January 28, 2008, 08:50:31 AM

Title: How to show the user name, instead of IP address, in "last viewed"
Post by: GlenVision on January 28, 2008, 08:50:31 AM
The "last viewed" feature shows IP addresses when viewed as an admin. Is there a way to modify Coppermine to allow showing the person's user name instead of their IP address?

Having the ability to show both might be nice as well. Also, I only want this information displayed when browsing as an admin. I don't want the general public knowing who has looked at what.

I looked for a mod, plugin, or hack that would do this, but I can't find anything. I might have a go at it myself, if someone wanted to point me in the right direction. (I'm a total beginner at php.)

thanks,
Glen
Title: Re: How to show the user name, instead of IP address, in "last viewed"
Post by: Nibbler on January 28, 2008, 09:07:27 AM
Not a feature request. Moving to support board.
Title: Re: How to show the user name, instead of IP address, in "last viewed"
Post by: GlenVision on February 10, 2008, 08:56:21 PM
So, does anyone know how to do this?

thanks,
Glen
Title: Re: How to show the user name, instead of IP address, in "last viewed"
Post by: Veronica on February 10, 2008, 10:33:13 PM
It's easy

find in /include/functions.inc.php
cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET hits=hits+1, lasthit_ip='$raw_ip', mtime=CURRENT_TIMESTAMP WHERE pid='$pid'");

replace with
cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET hits=hits+1, lasthit_ip='" . USER_NAME . "', mtime=CURRENT_TIMESTAMP WHERE pid='$pid'");

probably you should remove slashes too in same functions.inc.php

find
$caption .="<br/>".row['lasthit_ip'];

replace with
$caption .="<br/>".stripslashes ($row['lasthit_ip']);

and also replace the heading IP to username in your theme
Title: Re: How to show the user name, instead of IP address, in "last viewed"
Post by: GlenVision on February 11, 2008, 12:40:00 AM
Thank you, Veronica! That does exactly what I wanted.