[ABD] TULIP: Tiny User Locator by IP

Any abandoned MODs will be moved to this forum.

WARNING: MODs in this forum are not currently being supported or maintained by the original MOD author. Proceed at your own risk.
Forum rules
IMPORTANT: MOD Development Forum rules

WARNING: MODs in this forum are not currently being supported nor updated by the original MOD author. Proceed at your own risk.
Locked
User avatar
dpaanlka
Registered User
Posts: 286
Joined: Wed May 10, 2006 6:48 pm
Location: Chicago, USA
Contact:

[ABD] TULIP: Tiny User Locator by IP

Post by dpaanlka » Mon Aug 17, 2009 4:01 pm

SUMMARY:

This mod displays a flag image and the name of the country based on the IP address a user used to register at your board. The instructions below for viewtopic.php can be easily modified and included basically anywhere on the board where a registered user's id is accessible.

I have created a simple MOD that works great on my board. It only takes like one minute to install and has impressive results. At it's most basic, there are only two PHP files and one template file to edit. There are no database modifications whatsoever. Since installing it I've seen many interesting countries on my board, including China, Australia, Trinidad & Tobago, Thailand, Ukraine, Canada, Japan, the UK, and others! It's nice to see how international your board is!

I am now actively working to turn this into an approved MOD. I'm adding location detection down to a city/region level. This is my first MOD, so tips from seasoned phpBB MOD experts is much appreciated!

TO INSTALL:

First, download this zip file. It includes a directory named flags which has gif icons for the flags (obviously), the free GeoIP.dat data file for October 2009 (it's updated and freely downloadable every month from MaxMind), a php include named geoip.inc which contains the lookup scripts and is also provided by MaxMind, and functions_tulip.php, the TULIP functions.

Upload /flags to your root phpBB 3.x directory. Upload GeoIP.dat, geoip.inc and functions_tulip.php to the phpBB 3.x /includes directory.

Next, open viewtopic.php and find the following line:

Code: Select all

include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
Below, add:

Code: Select all

include($phpbb_root_path . 'includes/functions_tulip.' . $phpEx);
Then, find:

Code: Select all

'POSTER_ID'			=> $poster_id,
Below, add:

Code: Select all

########## BEGIN TULIP ##########
'POSTER_COUNTRY'	=> iptocountry($poster_id),
'POSTER_COUNTRY_FULL'	=> iptocountryname($poster_id),
########## END TULIP ##########
Close viewtopic.php.

Finally, find the viewtopic_body.html template file inside the directory for whichever style you're using, and add the following line inside the postrow wherever you'd like the flag of the post author to appear:

Code: Select all

<img src="./flags/{postrow.POSTER_COUNTRY}.gif">
You can also add this wherever you want the full name of the country to appear, such as in the above image's ALT tag:

Code: Select all

{postrow.POSTER_COUNTRY_FULL}
So you would in the ALT tag example end up with this line:

Code: Select all

<img src="./flags/{postrow.POSTER_COUNTRY}.gif" alt="{postrow.POSTER_COUNTRY_FULL}">
Tadaa!!!

MISCELLANEOUS NOTES:

I've so far found this to work for every country of every author that has yet posted, including Russia and China for spammers :roll: I don't know what will happen if the script somehow doesn't recognize an IP address, but I've included an extra flag called UN.gif which is simply the flag of the United Nations, which could be used as a placeholder or default flag. Also, since I created the zip file from the Mac OS X Finder, there is probably some rogue Finder database file in there. Just delete that...

Q&A:

Question: How can I put this on other pages other than viewtopic.php?
Answer: You'll paste in the same code for viewtopic.php mentioned in the instructions, but modify it if necessary to suit the needs of the new use. For example, if you wanted to add it to search results, then you'd want to pull the result row's user_id in search.php, like this:

Code: Select all

'POSTER_COUNTRY'	=> iptocountry($row['poster_id']),
'POSTER_COUNTRY_FULL'	=> iptocountryname($row['poster_id']),
I've easily gotten this to work in search.php, viewforum.php, viewonline.php, memberlist.php, and others by making simple modifications of the original. The only requirement is that, on whatever page you're adding it to, you must be able to access the ID of a user. This is usually referred to as poster_id, user_id, or something similar.

Question: How can I make sure my IP address database is up-to-date?
Answer: To updated your database of IP address country codes, simply download a new GeoIP.dat binary database file from MaxMind and upload it to /includes replacing your old copy. MaxMind releases a new GeoIP.dat file on the first of every month.

Question: How can I fix a user's incorrectly reported country?
Answer: If a country is reported incorrectly or not at all, this means the user registered from an unrecognized IP address. To repair this, simply edit the user_ip entry for the affected user in the database, replacing whatever is there with either a corrected IP address, or a "generic" IP address that reflects the user's country. You can find generic IP addresses for every country here. Simply select the desired country and choose an IP address from the list. You can also use this same method to fake your own location, by changing your registered IP address to a different country, although this would be a little shady on your part.
Last edited by dpaanlka on Wed Feb 24, 2010 4:17 pm, edited 55 times in total.
phpBB user and evangelist since 2005.
My boards: Info-Mac | System 7 Today

Poldi225
Registered User
Posts: 6
Joined: Thu Feb 19, 2009 7:20 pm

Re: IP Country Flags - And here's some code to get you started!

Post by Poldi225 » Mon Aug 17, 2009 6:21 pm

great work!

ROYGES
Registered User
Posts: 13
Joined: Sat Aug 08, 2009 8:46 pm

Re: IP Country Flags - And here's some code to get you started!

Post by ROYGES » Tue Aug 18, 2009 12:55 am

does this work for any style ?

User avatar
dpaanlka
Registered User
Posts: 286
Joined: Wed May 10, 2006 6:48 pm
Location: Chicago, USA
Contact:

Re: IP Country Flags - And here's some code to get you started!

Post by dpaanlka » Tue Aug 18, 2009 5:32 am

It should yes, but why not try and find out?
phpBB user and evangelist since 2005.
My boards: Info-Mac | System 7 Today

modman
Registered User
Posts: 9
Joined: Tue Jul 07, 2009 2:02 pm

Re: IP Country Flags - And here's some code to get you started!

Post by modman » Sat Sep 05, 2009 6:07 pm

I get this error:
Fatal error: Call to undefined function: iptocountry() in /home/freestom/public_html/viewtopic.php on line 1443
I also need help insertin the last bit of code in the postrow. I tried to search the forum for that, but didn't find more specific info on adding this

Code: Select all

<img src="./flags/{postrow.POSTER_COUNTRY}.gif">
to this bit

Code: Select all

	<DT><A NAME="profile{postrow.POST_ID}"></A><!-- ENDIF --><!-- ENDIF --><!-- IF not postrow.S_IGNORE_POST --><!-- IF postrow.POSTER_AVATAR --><!-- IF postrow.U_POST_AUTHOR --><A HREF="%7Bpostrow.U_POST_AUTHOR%7D">{postrow.POSTER_AVATAR}<!-- ELSE --></A>{postrow.POSTER_AVATAR}<!-- ENDIF --><BR><!-- ENDIF --><!-- IF not postrow.U_POST_AUTHOR --><STRONG>{postrow.POST_AUTHOR_FULL}<!-- ELSE --></STRONG>{postrow.POST_AUTHOR_FULL}<!-- ENDIF --><!-- IF postrow.RANK_TITLE or postrow.RANK_IMG -->
				</DT><DD>
		{postrow.RANK_TITLE}<!-- IF postrow.RANK_TITLE and postrow.RANK_IMG --><BR><!-- ENDIF -->{postrow.RANK_IMG}<!-- ENDIF -->
				</DD><DD>
		&nbsp;<!-- IF postrow.POSTER_POSTS != '' --> 
		</DD><DD>
		<STRONG>{L_POSTS}:</STRONG> {postrow.POSTER_POSTS}<!-- ENDIF --><!-- IF postrow.POSTER_JOINED -->
				</DD><DD>
		<STRONG>{L_JOINED}:</STRONG> {postrow.POSTER_JOINED}<!-- ENDIF --><!-- IF postrow.POSTER_FROM -->
				</DD><DD>
		<STRONG>{L_LOCATION}:</STRONG> {postrow.POSTER_FROM}<!-- ENDIF --><!-- IF postrow.S_PROFILE_FIELD1 --><!-- Use a construct like this to include admin defined profile fields. Replace FIELD1 with the name of your field. -->
				</DD><DD>
		<STRONG>{postrow.PROFILE_FIELD1_NAME}:</STRONG>
		{postrow.PROFILE_FIELD1_VALUE}<!-- ENDIF --><!-- BEGIN custom_fields -->
				</DD><DD>
		<STRONG>{postrow.custom_fields.PROFILE_FIELD_NAME}:</STRONG>
		{postrow.custom_fields.PROFILE_FIELD_VALUE}<!-- END custom_fields --><!-- IF not S_IS_BOT --><!-- IF postrow.U_PM or postrow.U_EMAIL or postrow.U_WWW or postrow.U_MSN or postrow.U_ICQ or postrow.U_YIM or postrow.U_AIM -->
				</DD></DL>

User avatar
dpaanlka
Registered User
Posts: 286
Joined: Wed May 10, 2006 6:48 pm
Location: Chicago, USA
Contact:

Re: IP Country Flags - And here's some code to get you started!

Post by dpaanlka » Sat Sep 05, 2009 6:24 pm

modman wrote:I get this error:
Fatal error: Call to undefined function: iptocountry() in /home/freestom/public_html/viewtopic.php on line 1443
The entire MOD has been changed since this post was made so try again with the new instructions.
Last edited by dpaanlka on Wed Oct 21, 2009 10:43 pm, edited 1 time in total.
phpBB user and evangelist since 2005.
My boards: Info-Mac | System 7 Today

modman
Registered User
Posts: 9
Joined: Tue Jul 07, 2009 2:02 pm

Re: IP Country Flags - And here's some code to get you started!

Post by modman » Sat Sep 05, 2009 7:19 pm

Parse error: syntax error, unexpected '}' in /home/freestom/public_html/cache/tpl_prosilver_viewtopic_body.html.php on line 57
Parse error: syntax error, unexpected '}' in /home/freestom/public_html/cache/tpl_prosilver_viewtopic_body.html.php on line 47
although I even started from a fresh viewtopic_body.html file...
or does this refere to an error in the php file?

thanks so much for looking into this...

User avatar
dpaanlka
Registered User
Posts: 286
Joined: Wed May 10, 2006 6:48 pm
Location: Chicago, USA
Contact:

Re: IP Country Flags - And here's some code to get you started!

Post by dpaanlka » Sat Sep 05, 2009 7:47 pm

Can you post your complete viewtopic_body.html template file and viewtopic.php script file?
phpBB user and evangelist since 2005.
My boards: Info-Mac | System 7 Today

modman
Registered User
Posts: 9
Joined: Tue Jul 07, 2009 2:02 pm

Re: IP Country Flags - And here's some code to get you started!

Post by modman » Sun Sep 06, 2009 1:01 am

errors are gone after clearing the forum cache, of course :roll: stupid me.
I put all the code here below and got a notice "message contains to few characters", although the opposite seems true....

No, tried again, it doesn't work
The forum is fine now, jus that the flags don't show up

maybe I can show this last part, from the viewtopic_body.html

Code: Select all

	<DL>
		<DT><A NAME="profile{postrow.POST_ID}"></A><!-- ENDIF --><!-- ENDIF --><!-- IF not postrow.S_IGNORE_POST --><!-- IF postrow.POSTER_AVATAR --><!-- IF postrow.U_POST_AUTHOR --><A HREF="%7Bpostrow.U_POST_AUTHOR%7D">{postrow.POSTER_AVATAR}<!-- ELSE --></A>{postrow.POSTER_AVATAR}<!-- ENDIF --><BR><!-- ENDIF --> <img src="./flags/{postrow.POSTER_COUNTRY}.gif"> <!-- IF not postrow.U_POST_AUTHOR --><STRONG>{postrow.POST_AUTHOR_FULL}<!-- ELSE --></STRONG>{postrow.POST_AUTHOR_FULL}<!-- ENDIF --><!-- IF postrow.RANK_TITLE or postrow.RANK_IMG -->
				</DT><DD>
		{postrow.RANK_TITLE}<!-- IF postrow.RANK_TITLE and postrow.RANK_IMG --><BR><!-- ENDIF -->{postrow.RANK_IMG}<!-- ENDIF -->
				</DD><DD>
		&nbsp;<!-- IF postrow.POSTER_POSTS != '' --> 
		</DD><DD>
		<STRONG>{L_POSTS}:</STRONG> {postrow.POSTER_POSTS}<!-- ENDIF --><!-- IF postrow.POSTER_JOINED -->
				</DD><DD>
		<STRONG>{L_JOINED}:</STRONG> {postrow.POSTER_JOINED}<!-- ENDIF --><!-- IF postrow.POSTER_FROM -->
				</DD><DD>
		<STRONG>{L_LOCATION}:</STRONG> {postrow.POSTER_FROM}<!-- ENDIF --><!-- IF postrow.S_PROFILE_FIELD1 --><!-- Use a construct like this to include admin defined profile fields. Replace FIELD1 with the name of your field. -->
				</DD><DD>
		<STRONG>{postrow.PROFILE_FIELD1_NAME}:</STRONG>
		{postrow.PROFILE_FIELD1_VALUE}<!-- ENDIF --><!-- BEGIN custom_fields -->
				</DD><DD>
		<STRONG>{postrow.custom_fields.PROFILE_FIELD_NAME}:</STRONG>
		{postrow.custom_fields.PROFILE_FIELD_VALUE}<!-- END custom_fields --><!-- IF not S_IS_BOT --><!-- IF postrow.U_PM or postrow.U_EMAIL or postrow.U_WWW or postrow.U_MSN or postrow.U_ICQ or postrow.U_YIM or postrow.U_AIM or postrow.U_JABBER -->
				</DD></DL>
	<UL>
		<LI><DD>
		<!-- IF postrow.U_PM --><A HREF="%7Bpostrow.U_PM%7D">{L_PRIVATE_MESSAGE}<!-- ENDIF --><!-- IF postrow.U_EMAIL --></A>
				</DD><LI><DD>
		<A HREF="%7Bpostrow.U_EMAIL%7D">{L_SEND_EMAIL_USER}
		{postrow.POST_AUTHOR}<!-- ENDIF --><!-- IF postrow.U_WWW --></A> 
		</DD><LI><DD>
		<A HREF="%7Bpostrow.U_WWW%7D">{L_WEBSITE}<!-- ENDIF --><!-- IF postrow.U_MSN --></A>
				</DD><LI><DD>
		<A HREF="%7Bpostrow.U_MSN%7D" ONCLICK="popup(this.href, 550, 320); return false;">{L_MSNM}<!-- ENDIF --><!-- IF postrow.U_ICQ --></A>
				</DD><LI><DD>
		<A HREF="%7Bpostrow.U_ICQ%7D" ONCLICK="popup(this.href, 550, 320); return false;">{L_ICQ}<!-- ENDIF --><!-- IF postrow.U_YIM --></A>
				</DD><LI><DD>
		<A HREF="%7Bpostrow.U_YIM%7D" ONCLICK="popup(this.href, 780, 550); return false;">{L_YIM}<!-- ENDIF --><!-- IF postrow.U_AIM --></A>
				</DD><LI><DD>
		<A HREF="%7Bpostrow.U_AIM%7D" ONCLICK="popup(this.href, 550, 320); return false;">{L_AIM}<!-- ENDIF --><!-- IF postrow.U_JABBER --></A>
				</DD><LI><DD STYLE="margin-bottom: 0.5cm">
		<A HREF="%7Bpostrow.U_JABBER%7D" ONCLICK="popup(this.href, 550, 320); return false;">{L_JABBER}<!-- ENDIF --></A>
				</DD></UL>
	<P STYLE="margin-bottom: 0cm"><!-- ENDIF --><!-- ENDIF --><!-- ENDIF --><A HREF="#wrap">{L_BACK_TO_TOP}</A></P>
</DIV>
<HR>
<FORM ACTION="%7BS_TOPIC_ACTION%7D" METHOD="POST">
	<P><!-- END postrow --><!-- IF S_NUM_POSTS > 1 or PREVIOUS_PAGE --><!-- IF PREVIOUS_PAGE --><A HREF="%7BPREVIOUS_PAGE%7D">{L_PREVIOUS}<!-- ENDIF --><!-- IF NEXT_PAGE --></A>
	<A HREF="%7BNEXT_PAGE%7D">{L_NEXT}<!-- ENDIF --><!-- IF not S_IS_BOT --></A>
	{L_DISPLAY_POSTS}: {S_SELECT_SORT_DAYS} {L_SORT_BY}
	{S_SELECT_SORT_KEY} {S_SELECT_SORT_DIR} <INPUT TYPE=SUBMIT NAME="sort" VALUE="{L_GO}" STYLE="width: 1.75cm; height: 0.85cm"><!-- ENDIF -->
		</P>
</FORM>
<HR>
<P STYLE="margin-bottom: 0cm"><!-- ENDIF --><!-- IF not S_IS_BOT and S_DISPLAY_REPLY_INFO --><!-- IF S_IS_LOCKED --><A HREF="%7BU_POST_REPLY_TOPIC%7D">{L_TOPIC_LOCKED_SHORT}<!-- ELSE -->{L_POST_REPLY}<!-- ENDIF --></A></P>
<P><!-- ENDIF --><!-- IF PAGINATION or TOTAL_POSTS -->{TOTAL_POSTS}<!-- IF PAGE_NUMBER --><!-- IF PAGINATION -->
&bull; <A HREF="#" ONCLICK="jumpto(); return false;">{PAGE_NUMBER}</A>
&bull; {PAGINATION}<!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
</P>
<FORM ACTION="%7BS_MOD_ACTION%7D" METHOD="POST">
	<P><!-- ENDIF --><!-- INCLUDE jumpbox.html --><!-- IF S_TOPIC_MOD -->{L_QUICK_MOD}:
	{S_TOPIC_MOD} <INPUT TYPE=SUBMIT VALUE="{L_GO}" STYLE="width: 1.75cm; height: 0.85cm">
	{S_FORM_TOKEN} 
	</P>
</FORM>
<H3><!-- ENDIF --><!-- IF S_DISPLAY_ONLINE_LIST --><!-- IF U_VIEWONLINE --><A HREF="%7BU_VIEWONLINE%7D">{L_WHO_IS_ONLINE}<!-- ELSE --></A>{L_WHO_IS_ONLINE}<!-- ENDIF --></H3>
<P>{LOGGED_IN_USER_LIST}</P>
<P><!-- ENDIF --><!-- INCLUDE overall_footer.html --><BR><BR>
</P>
</BODY>
</HTML>

User avatar
dpaanlka
Registered User
Posts: 286
Joined: Wed May 10, 2006 6:48 pm
Location: Chicago, USA
Contact:

Re: IP Country Flags - And here's some code to get you started!

Post by dpaanlka » Sun Sep 06, 2009 7:37 am

If your page is now showing up fine but there is a missing image (like a square with a question mark) then right click on it and see where it's attempting to fetch the image from. Wherever that is, is where you need to store the image files.

Where is your board?
phpBB user and evangelist since 2005.
My boards: Info-Mac | System 7 Today

modman
Registered User
Posts: 9
Joined: Tue Jul 07, 2009 2:02 pm

Re: IP Country Flags - And here's some code to get you started!

Post by modman » Sun Sep 06, 2009 6:45 pm

I cannot understand this: got back to the board, and now they viewpost template is not showing again
Parse error: syntax error, unexpected '}' in /home/freestom/public_html/cache/tpl_prosilver_viewtopic_body.html.php on line 47
http://host.spacens.com/~freestom

I swear yesterday evening it was fine. I don't get no missing image icons or anything.
The forum on that server isn't used anymore, except as test server, the forum itself has been rehosted.
thanks again

User avatar
dpaanlka
Registered User
Posts: 286
Joined: Wed May 10, 2006 6:48 pm
Location: Chicago, USA
Contact:

Re: IP Country Flags - And here's some code to get you started!

Post by dpaanlka » Wed Oct 14, 2009 1:10 am

modman wrote:I swear yesterday evening it was fine. I don't get no missing image icons or anything.
The forum on that server isn't used anymore, except as test server, the forum itself has been rehosted.
thanks again
Go to your admin control panel, purge the cache, and see what happens...

NEW MODIFICATIONS!!!

For everyone else, I've since modified my first example from the beginning of this topic. When I call the iptocountry functions, I pass the user_id, and it returns the country flag from the IP address they registered from, rather than the IP address the post was made from. This has two benefits. First, the user will have the same country flag even if they post from a foreign location. Second, if their country flag is incorrect or they registered internationally, the flags can be changed board-wide by simply editing their user IP address in the database.

Here is the new block of code in functions.php... note that this is moved from the earlier functions_user.php:

Code: Select all

########## BEGIN IP FLAG STUFF ##########

function iptocountry($the_id)
{
	global $db;

	$sql = 'SELECT user_ip
    FROM ' . USERS_TABLE . '
    WHERE user_id = ' . $the_id;
	$result = $db->sql_query($sql);

	$ip = $db->sql_fetchfield('user_ip');

	include_once("geoip.inc");
	$gi = geoip_open("./includes/GeoIP.dat",GEOIP_STANDARD);
	$two_letter_country_code = geoip_country_code_by_addr($gi, $ip);
	geoip_close($gi);
	return $two_letter_country_code;
}

function iptocountryname($the_id)
{
	global $db;

	$sql = 'SELECT user_ip
    FROM ' . USERS_TABLE . '
    WHERE user_id = ' . $the_id;
	$result = $db->sql_query($sql);

	$ip = $db->sql_fetchfield('user_ip');

	include_once("geoip.inc");
	$gi = geoip_open("./includes/GeoIP.dat",GEOIP_STANDARD);
	$country_name = geoip_country_name_by_addr($gi, $ip);
	geoip_close($gi);
	return $country_name;
}

########### END IP FLAG STUFF ###########
In viewtopic.php (or wherever else) modify the code as necessary to pass the user_id rather than the poster_ip.
phpBB user and evangelist since 2005.
My boards: Info-Mac | System 7 Today

rokhstar
Registered User
Posts: 11
Joined: Tue Oct 06, 2009 2:46 pm

Re: IP Country Flags - And here's some code to get you started!

Post by rokhstar » Tue Oct 20, 2009 9:31 am

I know this topic is a bit old. But i use this on phpbb 3.0.5 and it works great :)

Is there a way to display the name of the country somehow? I can modify it a bit to just display the Initials of them (like DK, NL, IT etc.) with this code alone:

Code: Select all

{postrow.POSTER_COUNTRY}
Is there a code that displays the full name of the country?

User avatar
3Di
Registered User
Posts: 13111
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: IP Country Flags - And here's some code to get you started!

Post by 3Di » Tue Oct 20, 2009 9:29 pm

There is the version for phpBB3 available, just click onto my signature to get in touch.
:game_die: The new Dice Roller extension for phpBB 3.2 is out! :game_die:

Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
dpaanlka
Registered User
Posts: 286
Joined: Wed May 10, 2006 6:48 pm
Location: Chicago, USA
Contact:

Re: IP Country Flags - And here's some code to get you started!

Post by dpaanlka » Tue Oct 20, 2009 9:54 pm

rokhstar wrote:I know this topic is a bit old. But i use this on phpbb 3.0.5 and it works great :)
This topic is only 2 months old. I created this code under 3.0.5, so yeah it should work great in your identical copy of 3.0.5 :lol:
rokhstar wrote:Is there a way to display the name of the country somehow? I can modify it a bit to just display the Initials of them (like DK, NL, IT etc.) with this code alone:

Code: Select all

{postrow.POSTER_COUNTRY}
Is there a code that displays the full name of the country?
Yes, as a matter of fact there is. You'll create a second function. I continuously try to improve and simplify this mod: as of right now, my entire functions.php modifications for the flags look like this:

Code: Select all

########## BEGIN IP FLAG STUFF ##########

function iptocountry($the_id)
{
	global $db;

	$sql = 'SELECT user_ip
    FROM ' . USERS_TABLE . '
    WHERE user_id = ' . $the_id;
	$result = $db->sql_query($sql);

	$ip = $db->sql_fetchfield('user_ip');

	include_once("geoip.inc");
	$gi = geoip_open("./includes/GeoIP.dat",GEOIP_STANDARD);
	$two_letter_country_code = geoip_country_code_by_addr($gi, $ip);
	geoip_close($gi);
	return $two_letter_country_code;
}

function iptocountryname($the_id)
{
	global $db;

	$sql = 'SELECT user_ip
    FROM ' . USERS_TABLE . '
    WHERE user_id = ' . $the_id;
	$result = $db->sql_query($sql);

	$ip = $db->sql_fetchfield('user_ip');

	include_once("geoip.inc");
	$gi = geoip_open("./includes/GeoIP.dat",GEOIP_STANDARD);
	$country_name = geoip_country_name_by_addr($gi, $ip);
	geoip_close($gi);
	return $country_name;
}

########### END IP FLAG STUFF ###########
As you can see, that second function returns the country name. You can put it into viewtopic.php's template variables for postrow (or anywhere else with access to poster_id information) like this:

Code: Select all

########## BEGIN IP FLAG STUFF ##########
		'POSTER_COUNTRY'	=> iptocountry($poster_id),
		'POSTER_COUNTRY_FULL'	=> iptocountryname($poster_id),
		########### END IP FLAG STUFF ###########
Call it in template with {postrow.POSTER_COUNTRY_FULL}. On my board, I put this information into the ALT tag of the country flag, which results in a tooltip containing the country name when you hover the mouse over the flag.
3Di wrote:There is the version for phpBB3 available, just click onto my signature to get in touch.
My modifications in this topic have nothing to do with your IP Country Flag mod. I haven't used it or seen it previously, and I'm sure it works wonderfully. I guess it's just a coincidence that I called it the same thing... but from what I read, your mod looks overly complicated for my needs. 45 minutes and 24 file edits? My mod takes like 5 minutes and edits a mere handful of files - only two php files plus the template file if you just want flags in viewtopic. Plus, I didn't want to put all your copywrited intellectual property into my board :P
phpBB user and evangelist since 2005.
My boards: Info-Mac | System 7 Today

Locked

Return to “[3.0.x] Abandoned MODs”

Who is online

Users browsing this forum: No registered users and 35 guests