IP in profile

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Ideas Centre
marian0810
Former Team Member
Posts: 3011
Joined: Mon May 21, 2007 9:17 pm
Location: The Netherlands
Name: Marian
Contact:

IP in profile

Post by marian0810 » Fri May 01, 2009 11:01 am

How can I show a user's IP for admins and mods in memberlist_view.html?
You and me, time and space. You watch us run!

marian0810
Former Team Member
Posts: 3011
Joined: Mon May 21, 2007 9:17 pm
Location: The Netherlands
Name: Marian
Contact:

Re: IP in profile

Post by marian0810 » Sun May 03, 2009 7:56 am

Can anyone help please?
You and me, time and space. You watch us run!

mtrs
Registered User
Posts: 2049
Joined: Sat Sep 22, 2007 2:39 pm

Re: IP in profile

Post by mtrs » Sun May 03, 2009 3:32 pm

Open
memberlist.php
Find

Code: Select all

		'JOINED'		=> $user->format_date($data['user_regdate']),
After add

Code: Select all

		//Begin: registration IP in profile
		'USER_IP'		=> (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) ? $data['user_ip'] : '',
		//End: registration IP in profile
Open
styles/prosilver/template/memberlist_view.html
Find

Code: Select all

		<!-- IF S_USER_INACTIVE --><dt>{L_USER_IS_INACTIVE}:</dt> <dd>{USER_INACTIVE_REASON}</dd><!-- ENDIF -->
After add

Code: Select all

		<!-- IF USER_IP --><dt>{L_USER_IP}:</dt> <dd><a href="http://en.utrace.de/?query={USER_IP}" onclick="window.open(this.href);return false;" class="postlink">{USER_IP}</a></dd><!-- ENDIF -->		
Open
language/en/memberlist.php
Find

Code: Select all

	'USER_BAN'				=> 'Banning',
After add

Code: Select all

	'USER_IP'				=> 'Registration IP',
Last edited by mtrs on Tue May 05, 2009 11:27 am, edited 1 time in total.
I abandoned all of my mods.

marian0810
Former Team Member
Posts: 3011
Joined: Mon May 21, 2007 9:17 pm
Location: The Netherlands
Name: Marian
Contact:

Re: IP in profile

Post by marian0810 » Sun May 03, 2009 4:47 pm

Thanks, but unfortunately it doesn't work... :?
You and me, time and space. You watch us run!

mtrs
Registered User
Posts: 2049
Joined: Sat Sep 22, 2007 2:39 pm

Re: IP in profile

Post by mtrs » Sun May 03, 2009 6:31 pm

Did you purge cache after the edits?
I abandoned all of my mods.

marian0810
Former Team Member
Posts: 3011
Joined: Mon May 21, 2007 9:17 pm
Location: The Netherlands
Name: Marian
Contact:

Re: IP in profile

Post by marian0810 » Sun May 03, 2009 7:19 pm

Never mind, I found my error. I checked the profile of a member that was already there when we used phpBB2 :oops: Apparently it only works for new members. Too bad.

So it works, thank you very very much!! :D

You wouldn't happen to have a solution for that too would you? :mrgreen:
You and me, time and space. You watch us run!

mtrs
Registered User
Posts: 2049
Joined: Sat Sep 22, 2007 2:39 pm

Re: IP in profile

Post by mtrs » Sun May 03, 2009 7:59 pm

marian0810 wrote:You wouldn't happen to have a solution for that too would you? :mrgreen:
I tested a code, to fill user_ip field with the first post_ip by that user. The code first checks if (user_ip field empty and user_posts > 0), then fetches the first post_ip by that user and update the USERS_TABLE

Open
memberlist.php
Find

Code: Select all

	// Dump it out to the template
Add before

Code: Select all

//Begin: If user_ip field is empty, set user_ip value with the first post_ip by that user
	if (empty($data['user_ip']) && $data['user_posts'] > 0)
	{	
		global $db;
		
		$sql = 'SELECT poster_ip
			FROM ' . POSTS_TABLE . ' 
			WHERE poster_id = ' . (int) $data['user_id'] . '
			ORDER BY post_time ASC';
		$result = $db->sql_query_limit($sql, 1);
		$poster_ip = (string) $db->sql_fetchfield('poster_ip');
		
		$db->sql_freeresult($result);
		
		//update users_table user_ip value with first post ip by this user
		$sql = 'UPDATE ' . USERS_TABLE . "
			SET user_ip = '" . $db->sql_escape($poster_ip) . "'
			WHERE user_id = " . $data['user_id'];
		$result = $db->sql_query($sql);
		
		$db->sql_freeresult($result);
		$data['user_ip'] = $poster_ip;
	}
//End: If user_ip field is empty, set user_ip value with the first post_ip by that user
Last edited by mtrs on Mon May 04, 2009 11:24 am, edited 2 times in total.
I abandoned all of my mods.

marian0810
Former Team Member
Posts: 3011
Joined: Mon May 21, 2007 9:17 pm
Location: The Netherlands
Name: Marian
Contact:

Re: IP in profile

Post by marian0810 » Sun May 03, 2009 8:11 pm

Algemene fout
SQL ERROR [ mysql4 ]

Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause [1140]

SQL

SELECT poster_ip, MIN(post_time) FROM phpbb3_posts WHERE poster_id = 28

BACKTRACE


FILE: includes/db/mysql.php
LINE: 174
CALL: dbal->sql_error()

FILE: memberlist.php
LINE: 1891
CALL: dbal_mysql->sql_query()

FILE: memberlist.php
LINE: 536
CALL: show_profile()
This is what happens when I do that...
You and me, time and space. You watch us run!

mtrs
Registered User
Posts: 2049
Joined: Sat Sep 22, 2007 2:39 pm

Re: IP in profile

Post by mtrs » Sun May 03, 2009 8:24 pm

Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause [1140]
At my localhost test it worked, but caused error at your board. Now, I changed the sql query and updated my post above. Please try again.
I abandoned all of my mods.

marian0810
Former Team Member
Posts: 3011
Joined: Mon May 21, 2007 9:17 pm
Location: The Netherlands
Name: Marian
Contact:

Re: IP in profile

Post by marian0810 » Sun May 03, 2009 8:38 pm

Perfect!! This is really awesome, thank you sooooo much :D
You and me, time and space. You watch us run!

mtrs
Registered User
Posts: 2049
Joined: Sat Sep 22, 2007 2:39 pm

Re: IP in profile

Post by mtrs » Mon May 04, 2009 11:26 am

marian0810 wrote:Perfect!! This is really awesome, thank you sooooo much :D
Sorry to say, I found a bug in the update code above. You should update again, it just saved the ip by the user viewing profile, instead of profile owner.. :oops: I fixed that.
I abandoned all of my mods.

marian0810
Former Team Member
Posts: 3011
Joined: Mon May 21, 2007 9:17 pm
Location: The Netherlands
Name: Marian
Contact:

Re: IP in profile

Post by marian0810 » Mon May 04, 2009 11:55 am

:?: Actually I think I would have noticed that, but I doublechecked anyway. I see a different IP in every profile I view, and they all match the actual IP of that user.
You and me, time and space. You watch us run!

mtrs
Registered User
Posts: 2049
Joined: Sat Sep 22, 2007 2:39 pm

Re: IP in profile

Post by mtrs » Mon May 04, 2009 12:05 pm

:?: Actually, it was

Code: Select all

WHERE user_id = " . $user->data['user_id'];
while it should have been

Code: Select all

WHERE user_id = " . $data['user_id'];
I abandoned all of my mods.

marian0810
Former Team Member
Posts: 3011
Joined: Mon May 21, 2007 9:17 pm
Location: The Netherlands
Name: Marian
Contact:

Re: IP in profile

Post by marian0810 » Mon May 04, 2009 12:23 pm

Oops you were right, I checked the wrong users again :oops: Sorry to be such a bother.
I applied your changes but it doesn't seem to help.
You and me, time and space. You watch us run!

mtrs
Registered User
Posts: 2049
Joined: Sat Sep 22, 2007 2:39 pm

Re: IP in profile

Post by mtrs » Mon May 04, 2009 12:28 pm

marian0810 wrote:I applied your changes but it doesn't seem to help.
It doesn't not change the ip values of phpbb2 converted users, whose profile viewed with previous code.
I abandoned all of my mods.

Locked

Return to “[3.0.x] MOD Requests”