##############################################################
## MOD Title: IP Country Flag 2.1.0
## MOD Author: 3Di < 3d AT phpbb2italia DOT za DOT net > (Marco) http://phpbb2italia.za.net/phpbb2/index.php
## MOD Author: Nightwatch DL < nightwatch@darklight.co.za > (Riaan Burger)
## MOD Description: Logs the country any user comes from by IP address and displays the related Flag all over your Forum.
## Who's online screen, statistics box, memberlist, user profile mini profile next to posts and also for 
## the Newest User on Index (User ID, Chosen Language and Flag).
## Adds Flags on index and viewforum related to the Authors of Topics and Last Posters -
## displays also on your Board's index the list of the users (with IP Flags) who have visited
## you during the last 24 hours or the day, switch in IP Country Flag ACP Tools.
## Lets ADMIN and MODerators have an Avatars Secret Gallery that doesn't appear to Registered Users
## Gives to any user a default avatar (if none) based on their IP address (Country Location)
## Guests have a Guest_Avatar, unknown IPs have an Unknown_IP_Avatar
## Default IP Avatar will appear or disappear depending if the User have one..
## Into the Avatars Flags Gallery supplied there are also a lot of flags the User can choice from.
## The Gallery includes also: Australian States, Organisations, UK Nationals, US States, Arabian States and EU Avatars.
## An ACP Tool will allow you to erase all the user's avatars in a shoot!
##
## MOD Version: 2.1.0
##
## Installation Level: (Intermediate) 
## Installation Time:  30 minutes (3 minutes with EM)
##
## Traduccion Espaol: ThE KuKa - http://www.phpbb-es.com
##
## Files to Edit::
##
##    index.php
##    memberlist.php
##    viewonline.php
##    viewforum.php
##    viewtopic.php
##    includes/constants.php
##    includes/functions.php
##    includes/page_header.php
##    includes/sessions.php
##    includes/usercp_viewprofile.php
##    includes/usercp_avatar.php
##    templates/subSilver/index_body.tpl
##    templates/subSilver/memberlist_body.tpl
##    templates/subSilver/profile_view_body.tpl
##    templates/subSilver/viewforum_body.tpl
##    templates/subSilver/viewonline_body.tpl
##    templates/subSilver/viewtopic_body.tpl
##
## Included Files:
##
##    IPCF200.txt (how-to script)
##    root/install/*.* (DBAL database installer files)
##    root/admin/admin_ip_cf_today_userlist.php
##    root/admin/admin_ip_cf_avatars.php
##    root/images/flags/*.png (241 files)
##    root/images/flags/small/*.png (241 files)
##    root/images/avatars/gallery/1secretGalley/*.*
##    root/images/avatars/gallery/ipcf_flags/*.gif (187 + Guest + Unknown IP ..at the moment)
##    root/images/avatars/gallery/*.* variouses galleries with all Flags
##    root/includes/today_userlist.php
##    root/templates/subSilver/admin/admin_ip_cf_avatars.tpl
##    root/templates/subSilver/admin/admin_ip_cf_today_userlist.tpl
##    root/language/lang_english/lang_extend_ip_cf.php
##    pre-modded/*.* (phpbb 2.0.18 pre-modded files)
##    contribs/*.* (contributions people made for IP Country Flag)
##
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
## Author Notes: tested on 2.0.18 with EasyMod 0.2.1a
##
## IP Country Flag 2.0.0 "The 'Sweetarts and Jack Daniel's' Flag That Rules Them All" Edition, credits:
##
## DBAL compliance finalized thanks to the valuable help and contribution of markus_petrux http://www.phpmix.com/
## Avatars are a courtesy of MauS, http://www.phobbia.net/mods/ (great job, really!)
## Today Userlist 1.0.1 integration, thanks to reddog who gave me permission http://www.reddevboard.com/forum/
## Thanks to Dicky for his valuable help and cooperation in MODding phpBB.
## Thanks to everybody helped here, forgive me if i'm forgetting you now..
##
## This MOD uses http://ip-to-country.webhosting.info/ DB, updated the 13-Oct-2005, 61.500 entries ca. 
## 
##    Try to follow this: The default country for all your members will
##    initially be wo: "World" with wo.png as the flag (blue flag).
##    IP-to-World detection only happens once, when a new session is
##    created and is then stored in that session record and transferred
##    from there to the user record once a user logs in. This means that
##    anyone with a session at the time this mod is installed will only
##    be detected correctly once that session expires and a new session
##    is created. You may force new sessions by emptying your
##    phpbb_sessions table. Take note though, this will also log out
##    all your registered users.
##
##    MOD Compatibility: phpbb 2.0.18 (http://www.phpbb.com)
## 
##    Demo and support:	http://www.phpbb2italia.za.net/phpbb2/index.php
##
##    Pre-modded installation files are for phpBB 2.0.18
##    If you have a new installation of phpbb 2.0.18 you do not need to
##    do the file edits. Simply copy the files from pre-modded/ to your installation overwriting the
##    overwriting the files already there. 
##
##############################################################
## MOD History:
##
##   2005-11-05 - Version 2.1.0
##      - DB updater totally changed (this have not the Integer bug..)
##      - Guest flag in viewtopic fixed
##      - Language file amended
##      - Repackaged
##
##   2005-11-05 - Version 2.0.0
##      - DBAL compliance added
##      - 3 queries removed
##      - multilanguage capability added 100%
##      - added guest miniflag for Guests in viewtopic
##      - fixed various minor bugs
##      - code cleaned
##      - old history removed (lies into the contribs folder)
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ DIY INSTRUCTIONS ]------------------------------------------
#

WARNING: Make backups of your database before proceeding!

Once the MOD has been installed, you should run the DB Updater to populate the IP to Country table.

This files has been located in the install folder of your phpBB installation.

Open the script using your browser of choice as in the following example:

	http://www.example.com/forums/install/ip200_1.php
	http://www.example.com/forums/install/ip200_2.php
	http://www.example.com/forums/install/ip200_3.php

...and follows till the last: ip200_7.php

Once, your DB has been updated, remove the install directory.
#
#-----[ COPY ]------------------------------------------------
#
copy root/*.* to /*.*
#
#-----[ SQL ]-------------------------------------------------
#
CREATE TABLE phpbb_cf_ip_to_iso3661_1 (
	ip_from int(11) unsigned NOT NULL default '0',
	ip_to int(11) unsigned NOT NULL default '0',
	iso3661_1 CHAR(2) NOT NULL,
	KEY ip_from (ip_from, ip_to)
);
ALTER TABLE phpbb_sessions ADD session_cf_iso3661_1 CHAR(2) DEFAULT 'wo' NOT NULL;
ALTER TABLE phpbb_users ADD user_cf_iso3661_1 CHAR(2) DEFAULT 'wo' NOT NULL;
INSERT INTO phpbb_config (config_name, config_value) VALUES ('today_day_selected', '0');

#
#
#-----[ OPEN ]------------------------------------------------
#
index.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		case 'postgresql':
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
// ADD , u.user_cf_iso3661_1
#
#-----[ FIND ]------------------------------------------------
# the line is longer..
			$sql = "SELECT f.*, p.post_time
#
#-----[ IN-LINE FIND ]----------------------------------------
#
u.user_id
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, u.user_cf_iso3661_1
#
#-----[ FIND ]------------------------------------------------
#
		case 'oracle':
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
// ADD , u.user_cf_iso3661_1
#
#-----[ FIND ]------------------------------------------------
# the line is longer..
			$sql = "SELECT f.*, p.post_time
#
#-----[ IN-LINE FIND ]----------------------------------------
#
u.user_id
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, u.user_cf_iso3661_1
#
#-----[ FIND ]------------------------------------------------
#
		default:
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
// ADD , u.user_cf_iso3661_1
#
#-----[ FIND ]------------------------------------------------
# the line is longer..
			$sql = "SELECT f.*, p.post_time
#
#-----[ IN-LINE FIND ]----------------------------------------
#
u.user_id
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, u.user_cf_iso3661_1
#
#-----[ FIND ]------------------------------------------------
#
	// First users, then groups ... broken into two queries
	//
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
// ADD , u.user_cf_iso3661_1
#
#-----[ FIND ]------------------------------------------------
# the line is longer..
	$sql = "SELECT aa.forum_id, u.user_id, u.username
#
#-----[ IN-LINE FIND ]----------------------------------------
#
u.username
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, u.user_cf_iso3661_1
#
#-----[ FIND ]------------------------------------------------
#
	include($phpbb_root_path . 'includes/page_header.'.$phpEx);
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
//-- mod : today userlist ------------------------------------------------------
	include_once($phpbb_root_path . 'includes/today_userlist.'.$phpEx);
//-- fin mod : today userlist --------------------------------------------------
	$newest_iso3661_1 = $newest_userdata['user_cf_iso3661_1'];
	$newest_country = $lang['IP2Country'][$newest_userdata['user_cf_iso3661_1']];
	$newest_user_lang = $newest_userdata['user_lang'];
//-- end mod : IP Country Flag II ----------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		'L_ONLINE_EXPLAIN' => $lang['Online_explain'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
		'L_NEWEST_ID' => $lang['IP_CF_Newest_Registered_Id'],
		'L_NEWEST_LANG' => $lang['IP_CF_Newest_Registered_Lang'],
		'L_NEWEST_FROM' => $lang['IP_CF_Newest_Registered_From'],
//-- end mod : IP Country Flag II ------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		'L_MARK_FORUMS_READ' => $lang['Mark_all_forums'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
		'NEWEST_FLAG' => $newest_iso3661_1,
		'NEWEST_COUNTRY' => $newest_country,
		'NEWEST_LANG' => $newest_user_lang,
		'NEWEST_UID' => $newest_uid,
//-- end mod : IP Country Flag II ------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
								$last_post = $last_post_time . '<br />';
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ---------------------------------------------- 
								$lastpost_iso3661_1 = $forum_data[$j]['user_cf_iso3661_1'];
								$last_post .= '<img src="images/flags/small/' . $lastpost_iso3661_1 . '.png" width="14" height="9" alt="' . $lang['IP2Country'][$lastpost_iso3661_1] . '" title="' . $lang['IP2Country'][$lastpost_iso3661_1] . '" />&nbsp;';
//-- end mod : IP Country Flag II ----------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
memberlist.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
// Memberlist sorting
//
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ---------------------------------------------- 
// add , $lang['Sort_Country'] and , 'country'
#
#-----[ FIND ]------------------------------------------------
# the line is longer...
$mode_types_text = array($lang['Sort_Joined'],
#
#-----[ IN-LINE FIND ]----------------------------------------
#
$lang['Sort_Top_Ten']
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, $lang['Sort_Country']
#
#-----[ FIND ]------------------------------------------------
# the line is longer...
$mode_types = array('joined'
#
#-----[ IN-LINE FIND ]----------------------------------------
#
'topten'
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, 'country'
#
#-----[ FIND ]------------------------------------------------
#
	'L_PM' => $lang['Private_Message'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
// add
	'L_COUNTRY' => $lang['Country'],
//-- end mod : IP Country Flag II ------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	case 'topten':
		$order_by = "user_posts $sort_order LIMIT 10";
		break;
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
	case 'country':
		$order_by = "user_cf_iso3661_1 $sort_order LIMIT $start, " . $board_config['topics_per_page'];
		break;
//-- End mod : IP Country Flag II -----------------------------------------
#
#-----[ FIND ]------------------------------------------------
#the line is longer..
$sql = "SELECT username, user_id, user_viewemail
#
#-----[ FIND ]------------------------------------------------
#
	ORDER BY $order_by";
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
// add
$sql = str_replace ('SELECT ', 'SELECT user_cf_iso3661_1, ' . $sql_where, $sql);
//-- end mod : IP Country Flag II ------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		$search = '<a href="' . $temp_url . '">' . $lang['Search_user_posts'] . '</a>';
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
		$iso3661_1 = $row['user_cf_iso3661_1'];
//-- end mod : IP Country Flag II ------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			'YIM' => $yim,
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
			'FLAG' => $iso3661_1,
			'COUNTRY' => $lang['IP2Country'][$iso3661_1],
//-- end mod : IP Country Flag II ------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
viewonline.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
// Get user list
//
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
// add , s.session_cf_iso3661_1
#
#-----[ FIND ]------------------------------------------------
# the line is longer..
$sql = "SELECT u.user_id, u.username,
#
#-----[ IN-LINE FIND ]----------------------------------------
#
s.session_ip
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, s.session_cf_iso3661_1
#
#-----[ FIND ]------------------------------------------------
#
	message_die(GENERAL_ERROR, 'Could not obtain regd user/online information', '', __LINE__, __FILE__, $sql);
}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- end mod : IP Country Flag II ----------------------------------------------

#
#-----[ FIND ]------------------------------------------------
#
		$template->assign_block_vars("$which_row", array(
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : IP Country Flags ----------------------------------------------
		$country = $lang['IP2Country'][$row['session_cf_iso3661_1']];
		$tpl_guests_flags = array (
			'FLAG' => $row['session_cf_iso3661_1'],
			'COUNTRY' => $country,
		);
//-- end mod : IP Country Flags ------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			'FORUM_LOCATION' => $location,
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flags ----------------------------------------------
			'FLAG' => $row['session_cf_iso3661_1'],
			'COUNTRY' => $lang['IP2Country'][$row['session_cf_iso3661_1']],
//-- end mod : IP Country Flag II ------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
viewforum.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
// First users, then groups ... broken into two queries
//
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ---------------------------------------------- 
// add , u.user_cf_iso3661_1
#
#-----[ FIND ]------------------------------------------------
#the line is longer...
$sql = "SELECT u.user_id
#
#-----[ IN-LINE FIND ]----------------------------------------
#
u.username
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, u.user_cf_iso3661_1
#
#-----[ FIND ]------------------------------------------------
#
{
	message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- end mod : IP Country Flag II ----------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
// on each viewforum page ...
//
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ---------------------------------------------- 
// add , u.user_cf_iso3661_1 AND , u2.user_cf_iso3661_1 as user2flag
#
#-----[ FIND ]------------------------------------------------
#the line is longer...
$sql = "SELECT t.*, u.username, u.user_id
#
#-----[ IN-LINE FIND ]----------------------------------------
#
u.user_id
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, u.user_cf_iso3661_1
#
#-----[ IN-LINE FIND ]----------------------------------------
#
u2.user_id as id2
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, u2.user_cf_iso3661_1 as user2flag
#
#-----[ FIND ]------------------------------------------------
#
   message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- end mod : IP Country Flag II ----------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
// for this forum
//
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ---------------------------------------------- 
// add , u.user_cf_iso3661_1 and , u2.user_cf_iso3661_1 as user2flag
#
#-----[ FIND ]------------------------------------------------
#the line is longer..
$sql = "SELECT t.*, u.username
#
#-----[ IN-LINE FIND ]----------------------------------------
#
u.user_id
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, u.user_cf_iso3661_1
#
#-----[ IN-LINE FIND ]----------------------------------------
#
u2.user_id as id2
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, u2.user_cf_iso3661_1 as user2flag
#
#-----[ FIND ]------------------------------------------------
#
   message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- end mod : IP Country Flag II ----------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#the line is longer..
		$last_post_time = create_date(
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ---------------------------------------------- 
		$topic_author_ipcf = $topic_rowset[$i]['user_cf_iso3661_1'];
		$lastpost_iso3661_1 = $topic_rowset[$i]['user2flag'];
//-- end mod : IP Country Flag II ------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			'TOPIC_AUTHOR' => $topic_author, 
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ---------------------------------------------- 
			'TOPIC_AUTHOR_FLAG' => $topic_author_ipcf, 
			'TOPIC_AUTHOR_FLAG_ALT' => $lang['IP2Country'][$topic_author_ipcf], 
//-- mod : IP Country Flag II ---------------------------------------------- 
#
#-----[ FIND ]------------------------------------------------
#
			'LAST_POST_IMG' => $last_post_url, 
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ---------------------------------------------- 
			'IP_CF_LAST_POST' => $lastpost_iso3661_1,
			'IP_CF_LAST_POST_ALT' => $lang['IP2Country'][$lastpost_iso3661_1],
//-- mod : IP Country Flag II ----------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
viewtopic.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
// Go ahead and pull all data for this topic
//
#
#-----[ AFTER, ADD ]------------------------------------------
#
//--  mod : IP Country Flag II ------------------------------------------
// add , u.user_cf_iso3661_1
#
#-----[ FIND ]------------------------------------------------
#the line is longer...
$sql = "SELECT u.username, u.user_id, u.user_posts
#
#-----[ IN-LINE FIND ]----------------------------------------
#
u.user_allowsmile
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, u.user_cf_iso3661_1
#
#-----[ FIND ]------------------------------------------------
#
	message_die(GENERAL_ERROR, "Could not obtain post/user information.", '', __LINE__, __FILE__, $sql);
}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- end mod : IP Country Flag II ----------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	$poster_avatar = '';
#
#-----[ FIND ]------------------------------------------------
#
		}
	}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//--  mod : IP Country Flag II ------------------------------------------
$ipcfguest = 'guest';
$ipcfguestalt = $lang['IPCF_Guest'];

if ($postrow[$i]['user_id'] == -1)
		{
			$poster_avatar = '<img src="images/avatars/gallery/ipcf_flags/' . $ipcfguest . '.gif" alt="' . $ipcfguestalt . '" title="' . $ipcfguestalt . '" border="0" />';
		}
			else if ($postrow[$i]['user_avatar_type'] == 0)
			{
				$poster_avatar = '<img src="images/avatars/gallery/ipcf_flags/' . $postrow[$i]['user_cf_iso3661_1'] . '.gif" alt="' . $lang['IP2Country'][$postrow[$i]['user_cf_iso3661_1']] . '" title="' . $lang['IP2Country'][$postrow[$i]['user_cf_iso3661_1']] . '" border="0" />';
			}
//-- end mod : IP Country Flag II ------------------------------------------
#
#-----[ FIND ]------------------------------------------------
# the line is longer...
		$yim = ( $postrow[$i]['user_yim'] ) ?
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
		$flag = $lang['Country'] . ': <img src="images/flags/small/' . $postrow[$i]['user_cf_iso3661_1'] . '.png" alt="' . $lang['IP2Country'][$postrow[$i]['user_cf_iso3661_1']] . '" title="' . $lang['IP2Country'][$postrow[$i]['user_cf_iso3661_1']] . '" border="0" />';
		$country = $lang['Country'] . ': ' . $lang['IP2Country'][$postrow[$i]['user_cf_iso3661_1']];
//-- end mod : IP Country Flag II ------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		$yim = '';
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
		$flag = $lang['Country'] . ': <img src="images/flags/small/wo.png" alt="' . $lang['IPCF_Guest'] . '" title="' . $lang['IPCF_Guest'] . '" border="0" />';
		$country = $lang['Country'] . ': ' . $lang['IPCF_Guest'];
//-- end mod : IP Country Flag II ------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		'EDITED_MESSAGE' => $l_edited_by,
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
		'FLAG' => $flag,
		'COUNTRY' => $country,
		'L_COUNTRY' => $lang['IP2Country'][$postrow[$i]['user_cf_iso3661_1']],
//-- end mod : IP Country Flag II ------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/constants.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
define ('CF_ISO_TABLE', $table_prefix.'cf_ip_to_iso3661_1');
//-- end mod : IP Country Flag II -----------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/functions.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		case 'newestuser':
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
// add , user_cf_iso3661_1, user_lang
#
#-----[ FIND ]------------------------------------------------
# the line is longer..
			$sql = "SELECT user_id
#
#-----[ IN-LINE FIND ]----------------------------------------
#
username
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, user_cf_iso3661_1, user_lang
#
#-----[ FIND ]------------------------------------------------
#
			break;
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- end mod : IP Country Flag II ----------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx);
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
if( @file_exists($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_extend_ip_cf.' . $phpEx) )
{
	include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_extend_ip_cf.' . $phpEx); 
}
else 
{
	include($phpbb_root_path . 'language/lang_english/lang_extend_ip_cf.' . $phpEx); 
}
//-- end mod : IP Country Flag II ----------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/page_header.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	$user_forum_sql =
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
// add , s.session_cf_iso3661_1
#
#-----[ FIND ]------------------------------------------------
# the line is longer...
	$sql = "SELECT u.username
#
#-----[ IN-LINE FIND ]----------------------------------------
#
s.session_ip
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, s.session_cf_iso3661_1
#
#-----[ FIND ]------------------------------------------------
#
				if ( $row['user_allow_viewonline'] )
				{
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
#
#-----[ FIND ]---------------------------------------------------------
# the line is longer..
					$user_online_link = 
#
#-----[ IN-LINE FIND ]----------------------------------------
#
.'>' . $row['username']
#
#-----[ IN-LINE REPLACE WITH ]--------------------------------
#
.'><img src="images/flags/small/' . $row['session_cf_iso3661_1'] . '.png" width="14" height="9" border="0" alt="' . $lang['IP2Country'][$row['session_cf_iso3661_1']] . '" title="' . $lang['IP2Country'][$row['session_cf_iso3661_1']] . '" /> ' . $row['username']
#
#-----[ AFTER, ADD ]------------------------------------------
# on a new line..
//-- end mod : IP Country Flag II ------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
				else
				{
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
#
#-----[ FIND ]---------------------------------------------------------
# the line is longer..
					$user_online_link =
#
#-----[ IN-LINE FIND ]----------------------------------------
#
.'><i>' . $row['username']
#
#-----[ IN-LINE REPLACE WITH ]--------------------------------
#
.'><i><img src="images/flags/small/' . $row['session_cf_iso3661_1'] . '.png" width="14" height="9" border="0" alt="' . $lang['IP2Country'][$row['session_cf_iso3661_1']] . '" title="' . $lang['IP2Country'][$row['session_cf_iso3661_1']] . '" /> ' . $row['username']
#
#-----[ AFTER, ADD ]------------------------------------------
# on a new line..
//-- end mod : IP Country Flag II ------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
				$guests_online++;
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flags ----------------------------------------------
				$guests_flags .= '<img src="images/flags/small/' . $row['session_cf_iso3661_1'] . '.png" width="14" height="9" border="0" alt="' . $lang['IP2Country'][$row['session_cf_iso3661_1']] . '" title="' . $lang['IP2Country'][$row['session_cf_iso3661_1']] . '" /> ';
//-- end mod : IP Country Flags ------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		$l_g_user_s = $lang['Guest_user_total'];
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
		$guests_from = '<br />' . $lang['Guests_From'] . ' ' . $guests_flags;
		$online_userlist .= $guests_from;
//-- end mod : IP Country Flag II ------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		$l_g_user_s = $lang['Guest_users_total'];
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
		$guests_from = '<br />' . $lang['Guests_From'] . ' ' . $guests_flags;
		$online_userlist .= $guests_from;
//-- end mod : IP Country Flag II ------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/sessions.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		$session_id = md5(uniqid(mt_rand(), true));
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
		$cf_sql = 'SELECT iso3661_1
			FROM ' . CF_ISO_TABLE . '
			WHERE ip_from <= ' . hexdec($user_ip) . '
				AND ip_to >= ' . hexdec($user_ip);
		if( ($cf_result = $db->sql_query($cf_sql)) && ($cf_row = $db->sql_fetchrow($cf_result)) )
		{
			$iso3661_1 = strtolower($cf_row['iso3661_1']);
			$country = $lang['IP2Country'][$iso3661_1];
		}
		else
		{
			$iso3661_1 = 'wo';
			$country = 'World';
		}
//-- end mod : IP Country Flag II ------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		$sql = "INSERT INTO " . SESSIONS_TABLE . "
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
// add , session_cf_iso3661_1 and , '$iso3661_1'

#
#-----[ FIND ]------------------------------------------------
# the line is longer..
			(session_id
#
#-----[ IN-LINE FIND ]----------------------------------------
#
session_admin
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, session_cf_iso3661_1
#
#-----[ FIND ]---------------------------------------------------------
#	the line is longer..
			VALUES ('$session_id'
#
#-----[ IN-LINE FIND ]-------------------------------------------------
#
$admin
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, '$iso3661_1'
#
#-----[ FIND ]---------------------------------------------------------
#
			message_die(CRITICAL_ERROR, 'Error creating new session', '', __LINE__, __FILE__, $sql);
		}
	}
#
#-----[ AFTER, ADD ]------------------------------------------
# on a new line...
//-- end mod : IP Country Flag II ------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		if (!$admin)
		{
#
#-----[ AFTER, ADD ]-----------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
// add
		$cf_sql = 'SELECT iso3661_1
			FROM ' . CF_ISO_TABLE . '
			WHERE ip_from <= ' . hexdec($user_ip) . '
				AND ip_to >= ' . hexdec($user_ip);
		if( ($cf_result = $db->sql_query($cf_sql)) && ($cf_row = $db->sql_fetchrow($cf_result)) )
		{
			$iso3661_1 = strtolower($cf_row['iso3661_1']);
			$country = $lang['IP2Country'][$iso3661_1];
		}
		else
		{
			if( !$cf_result )
			{
				message_die(CRITICAL_ERROR, 'Error reading IP to Country table', '', __LINE__, __FILE__, $sql);
			}
			$iso3661_1 = 'wo';
			$country = 'World';
		}
//-- end mod : IP Country Flag II ------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			$sql = "UPDATE " . USERS_TABLE . "
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
// add , user_cf_iso3661_1 = '$iso3661_1'
#
#-----[ FIND ]------------------------------------------------
# the line is longer..
				SET user_session_time =
#
#-----[ IN-LINE FIND ]----------------------------------------
#
$last_visit
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, user_cf_iso3661_1 = '$iso3661_1'
#
#-----[ FIND ]------------------------------------------------
# 
				message_die(CRITICAL_ERROR, 'Error updating last visit time', '', __LINE__, __FILE__, $sql);
			}
		}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- end mod : IP Country Flag II ------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/usercp_viewprofile.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
$avatar_img = '';
#
#-----[ FIND ]------------------------------------------------
#
	}
}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
$ipcfguest = 'guest';
$ipcfguestalt = $lang['IPCF_Guest'];

if ($profiledata['user_id'] == -1)
		{
			$avatar_img = '<img src="images/avatars/gallery/ipcf_flags/' . $ipcfguest . '.gif" alt="' . $ipcfguestalt . '" title="' . $ipcfguestalt . '" border="0" />';
		}
			else if ($profiledata['user_avatar_type'] == 0)
			{
				$avatar_img = '<img src="images/avatars/gallery/ipcf_flags/' . $profiledata['user_cf_iso3661_1'] . '.gif" alt="' .  $lang['IP2Country'][$profiledata['user_cf_iso3661_1']] . '" title="' .  $lang['IP2Country'][$profiledata['user_cf_iso3661_1']] . '" border="0" />';
			}
//-- mod : IP Country Flag II ----------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	'POST_PERCENT_STATS' => sprintf($lang['User_post_pct_stats'], $percentage), 
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
	'COUNTRY' => $lang['IP2Country'][$profiledata['user_cf_iso3661_1']],
	'FLAG' => $profiledata['user_cf_iso3661_1'],
	'L_COUNTRY' => $lang['Country'],
//-- mod : IP Country Flag II ----------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/usercp_avatar.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
#
#-----[ FIND ]------------------------------------------
#	the line is longer..
	global $board_config, $db, $template
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
// add , $userdata
#
#-----[ FIND ]------------------------------------------
#	the line is longer..
	global $phpbb_root_path
#
#-----[ IN-LINE FIND ]------------------------------------------
#
$phpEx
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, $userdata
#
#-----[ AFTER, ADD ]------------------------------------------
# on a new line...
//-- endmod : IP Country Flag II ------------------------------------------
#
#-----[ FIND ]------------------------------------------
#
		list($category, ) = each($avatar_images);
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : IP Country Flag II ----------------------------------------------
//MOD Avatars Secret Gallery - Set the default category
		$category='NonSecretCategory';
#
#-----[ FIND ]------------------------------------------
#
	while( list($key) = each($avatar_images) )
	{
#
#-----[ AFTER, ADD ]------------------------------------------
#
//----------- Unless MOD or ADMIN, hide the folder '1SecretGallery' ---------
		if ($userdata['user_level'] != USER || $key != '1SecretGallery' ) 
		{
#
#-----[ FIND ]------------------------------------------
#
		{
			$s_categories .= '<option value="' . $key . '"' . $selected . '>' . ucfirst($key) . '</option>';
		}
	}
#
#-----[ REPLACE WITH ]------------------------------------------
#
			{
				$s_categories .= '<option value="' . $key . '"' . $selected . '>' . ucfirst($key) . '</option>';
			}
		}
	}
//MOD Avatars Secret Gallery
//-- end mod : IP Country Flag II ----------------------------------------------
#
#-----[ OPEN ]---------------------------------------------------------
#
templates/subSilver/index_body.tpl
#
#-----[ FIND ]------------------------------------------------ 
# the line is longer...
# The found value can be different, if other mods look for rowspan="2"
# look for 	<td class="row1" align="center" valign="middle" rowspan="2"
	<td class="row1" align="center" valign="middle" rowspan="{%:1}"
#
#-----[ INCREMENT ]-------------------------------- 
#
# add 2 to the preceding value
# like rowspan="4"
%:1 +2
#
#-----[ FIND ]------------------------------------------------
# the line is longer..
	<td class="row1" align="left" width="100%"><span class="gensmall">{TOTAL_POSTS}<br />
#
#-----[ IN-LINE FIND ]----------------------------------------
#
/>{NEWEST_USER}</span>
#
#-----[ IN-LINE REPLACE WITH ]--------------------------------
#
/>{NEWEST_USER}&nbsp;-&nbsp;{L_NEWEST_ID}&nbsp;<b>{NEWEST_UID}</b>&nbsp;-&nbsp;{L_NEWEST_LANG}&nbsp;<b>{NEWEST_LANG}</b>&nbsp;-&nbsp;{L_NEWEST_FROM}&nbsp;<img width="14" height="9" border="0" src="images/flags/small/{NEWEST_FLAG}.png" alt="{NEWEST_COUNTRY}" title="{NEWEST_COUNTRY}" /></span>
#
#-----[ FIND ]------------------------------------------------
#
</table>
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
  <!-- start today userlist -->
  <tr>
	<td class="row1" align="left"><span class="gensmall">{TOTAL_TODAY_ONLINE}<br />{TOTAL_LASTHOUR_ONLINE}<br /></span></td>
  </tr>
  <tr>
	<td class="row1" align="left"><span class="gensmall">{L_TODAY_IN_USER_LIST}<br />{TODAY_IN_USER_LIST}</span></td>
  </tr>
  <!-- fin today userlist -->
#
#-----[ OPEN ]---------------------------------------------------------
#
templates/subSilver/memberlist_body.tpl
#
#-----[ FIND ]---------------------------------------------------------
#
	  <th class="thTop" nowrap="nowrap">{L_USERNAME}</th>
#
#-----[ AFTER, ADD ]---------------------------------------------------
#
	  <th class="thTop" nowrap="nowrap">{L_COUNTRY}</th>
#
#-----[ FIND ]---------------------------------------------------------
#
	  <td class="{memberrow.ROW_CLASS}" align="center"><span class="gen"><a href="{memberrow.U_VIEWPROFILE}" class="gen">{memberrow.USERNAME}</a></span></td>
#
#-----[ AFTER, ADD ]---------------------------------------------------
#
	  <td class="{memberrow.ROW_CLASS}" align="center"> <img src="images/flags/{memberrow.FLAG}.png" width="18" height="12" title="{memberrow.COUNTRY}" /> </td>
#
#-----[ FIND ]---------------------------------------------------------
#	the line to find on a virgin phpBB 2.0.18 is longer and looks like..
#	  <td class="catBottom" colspan="8" height="28">&nbsp;</td>
#	you have to increment colspan="X" by 1
#
<td class="catBottom" colspan="{%:1}"
#
#-----[ INCREMENT ]-------------------------------------------------
#
%:1
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/profile_view_body.tpl
#
#-----[ FIND ]------------------------------------------------
# the line is longer...
		  <td valign="top"><b><span class="gen">{POSTS}
#
#-----[ FIND ]------------------------------------------------
#
		</tr>
#
#-----[ AFTER, ADD ]------------------------------------------
#
		<tr> 
		  <td valign="middle" align="right" nowrap="nowrap"><span class="gen">{L_COUNTRY}:&nbsp;</span></td>
		  <td><img width="18" height="12" border="0" src="images/flags/{FLAG}.png" alt="{COUNTRY}" title="{COUNTRY}" />&nbsp;<b><span class="gen">{COUNTRY}</span></b></td>
		</tr>
#
#-----[ OPEN ]---------------------------------------------------------
#
templates/subSilver/viewonline_body.tpl
#
#-----[ FIND ]---------------------------------------------------------
#	the line is longer..
<td width="35%" class="{reg_user_row.ROW_CLASS}">
#
#-----[ IN-LINE FIND ]-------------------------------------------------
#
class="gen">{reg_user_row.USERNAME}
#
#-----[ IN-LINE REPLACE WITH ]-----------------------------------------
#
class="gen" title="{reg_user_row.COUNTRY}"><img width="18" height="12" border="0" src="images/flags/{reg_user_row.FLAG}.png" alt="{reg_user_row.COUNTRY}" title="{reg_user_row.COUNTRY}" /> {reg_user_row.USERNAME}
#
#-----[ FIND ]---------------------------------------------------------
#	the line is longer..
<td width="35%" class="{guest_user_row.ROW_CLASS}">
#
#-----[ IN-LINE FIND ]-------------------------------------------------
#
class="gen">{guest_user_row.USERNAME}
#
#-----[ IN-LINE REPLACE WITH ]-----------------------------------------
#
 class="gen"><img width="18" height="12" border="0" src="images/flags/{guest_user_row.FLAG}.png" alt="{guest_user_row.COUNTRY}" title="{guest_user_row.COUNTRY}" /> {guest_user_row.USERNAME}
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/viewforum_body.tpl
#
#-----[ FIND ]------------------------------------------------
#	the line is longer..
	  <td class="row3" align="center" valign="middle">
#
#-----[ IN-LINE FIND ]----------------------------------------
#
class="name">{topicrow.TOPIC_AUTHOR}
#
#-----[ IN-LINE REPLACE WITH ]--------------------------------
#
class="name"><img src="images/flags/small/{topicrow.TOPIC_AUTHOR_FLAG}.png" width="14" height="9" title="{topicrow.TOPIC_AUTHOR_FLAG_ALT}" alt="{topicrow.TOPIC_AUTHOR_FLAG_ALT}" />&nbsp;{topicrow.TOPIC_AUTHOR}
#
#-----[ FIND ]------------------------------------------------
#	the line is longer..
	  <td class="row3Right"
#
#-----[ IN-LINE FIND ]----------------------------------------
#
/>{topicrow.LAST_POST_AUTHOR} 
#
#-----[ IN-LINE REPLACE WITH ]--------------------------------
#
/><img src="images/flags/small/{topicrow.IP_CF_LAST_POST}.png" width="14" height="9" title="{topicrow.IP_CF_LAST_POST_ALT}" alt="{topicrow.IP_CF_LAST_POST_ALT}" />&nbsp;{topicrow.LAST_POST_AUTHOR} 
#
#-----[ OPEN ]---------------------------------------------------------
#
templates/subSilver/viewtopic_body.tpl
#
#-----[ FIND ]---------------------------------------------------------
#	the line is longer..
		<td width="150" align="left" valign="top" class="{postrow.ROW_CLASS}
#
#-----[ IN-LINE FIND ]-------------------------------------------------
#
{postrow.POSTER_FROM}
#
#-----[ IN-LINE BEFORE, ADD ]---------------------------------
#
{postrow.FLAG}<br />
#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------------
#
# EoM