Display user IP and Browser in templates.

Modifications for phpBB3.
Try the Mods here and share Your own Mods
Forum rules
You dont have to use ModX or make your mod AutoMod compatible. A simple textfile is fine
But if you post Mods here You also have to give support

Display user IP and Browser in templates.

Post by Stoker »

Its fairly easy to display the users IP and Browser in the templates.

Lets start with the users IP address
Open includes/functions.php
Find:

Code: Select all

'S_USER_BROWSER'		=> (isset($user->data['session_browser'])) ? $user->data['session_browser'] : $user->lang['UNKNOWN_BROWSER'],
Add after:

Code: Select all

'S_USER_IP'			    => $user->ip,
Now you can use this anywhere in the templates to display the users IP: {S_USER_IP}

This also opens up the possibility to display content to specific IP addresses.
Use this:

Code: Select all

<!-- IF S_USER_IP eq '89.56.45.134' -->Content for specific IP here<!-- ENDIF -->
The code will now be displayed for all users with that IP address. Even if they are guests or bots.


Now to the user Browser
This one is ready to go. With this code you can display the users Browser anywhere you want in the templates: {S_USER_BROWSER}

Remember to refresh the template ;)

Display user IP and Browser in templates.

Post by Vox Populi »

Good one Stoker.

Display user IP and Browser in templates.

Post by Terr0r »

:gp:

Display user IP and Browser in templates.

Post by martin123456 »

Nice idea but where do you recommend placing the ip code so only staff can see it ?

I had it under a users avatar but it showed for everyone :D

Display user IP and Browser in templates.

Post by Vox Populi »

Just use an IF and ENDIF statement to block users from seeing it. I have to look up the exact statement but it's simple.

Display user IP and Browser in templates.

Post by martin123456 »

Done
ip.png

open styles/prosilver/template/viewtopic_body.html

Find

Code: Select all

<dd><ul class="profile-icons">{postrow.USER_AGENT}</ul></dd>
		<!-- ENDIF -->
Add after

Code: Select all

<!-- IF MODERATORS or U_MCP -->
		{S_USER_IP}
		<!-- ENDIF -->
Now only admins and mods see the ip.

Here is how guest and member's get to see
ip 2.png
Note i have just the ip snippet installed you wont get the OS & Browser icons as i have as its a mod
You do not have the required permissions to view the files attached to this post.

Display user IP and Browser in templates.

Post by Stoker »

Martin, it doesnt work like that.
It will only display the users own IP. For you it will display your IP and for me it will display my IP.


If you want to display the users IP for mods and admins: http://www.phpbb.com/customise/db/mod/p ... viewtopic/
I think that there is more than this one out there.