[2.0.21] Country Flags MOD

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in here. No new MODs will be accepted into the MOD Database for phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Post Reply

Rating:

Excellent!
26
57%
Very Good
8
17%
Good
5
11%
Fair
2
4%
Poor
5
11%
 
Total votes: 46

Extensions Robot
Extensions Robot
Extensions Robot
Posts: 29220
Joined: Sat Aug 16, 2003 7:36 am

[2.0.21] Country Flags MOD

Post by Extensions Robot »

MOD Name: Country Flags MOD
Author: ycl6
MOD Description: This mod allows your registered board members to select the flag of their country/location.


MOD Version: 2.3.2 (Updated 07/15/06)

Download File: Country_Flags_2.3.2.zip
mods overview page: View
File Size: 206879 Bytes

Support for this MOD needs to be asked within this topic. The phpBB Teams are not responsible or required to give anyone support for this MOD. By installing this MOD, the phpBB Support Team or phpBB MODifications Team may not be able to provide support.

This MOD has only been tested by the phpBB MOD Team with the phpBB version in the topic title. It may not work in any other versions of phpBB.
Last edited by Extensions Robot on Mon Apr 30, 2007 12:30 am, edited 1 time in total.
(this is a non-active account manager for the phpBB Extension Customisations Team)
User avatar
webmacster87
Former Team Member
Posts: 3758
Joined: Fri Jun 11, 2004 2:30 am
Location: San Mateo, CA
Name: Douglas Bell
Contact:

Post by webmacster87 »

MOD Validated/Released

Notes:
Allows you to select what country you are from. If you choose your country, your country's flag will be listed on your profile.
(Yes, this was Nuttzy's MOD, which is finally making its premiere in the MOD Database! Thanks Mac!)
ycl6
Registered User
Posts: 5696
Joined: Sat Feb 15, 2003 10:35 am
Location: Taiwan
Contact:

Post by ycl6 »

This is a continuation of Nuttzy's Country Flag MOD. Hope that you will like this.

~Mac
h-o
Registered User
Posts: 43
Joined: Sun Mar 14, 2004 6:52 pm

Post by h-o »

ycl6 wrote: Hope that you will like this.

Yes, of course, thank you, ycl6 :-)

Well, here is the (unofficial) update code for those, who have already installed previous version 2.2.0 of Country Flags MOD:

But first some remarks:
  • Column "flag_id" in table phpbb_flags is no longer used (for example with ORDER BY in a SQL command), although it is a primary key. Maybe it would be better, to delete "flag_id" and to use "flag_name" as a primary key (alter key with phpMyAdmin).
  • border="1" in three code lines of memberlist.php, viewtopic.php and usercp_viewprofile.php looks a little bit strange, so delete it if you want :-)
  • It is better, not to run the update file when version 2.2.0 is already installed, because the flag image names have changed (for example, usa.gif is now us.gif or germany.gif is now gm.gif). Unfortunately, profiles with old flag image names are NOT automatically updated.

    There has been 193 flags in version 2.2.0. In the new version 2.3.1, there are now 261 flags. If you want to extend to all new flags, you have to find out which are the new one and add them manually via ACP :-)

Code: Select all

#
# Update Country Flag MOD 2.2.0 => 2.3.1
#
#-----[ COPY ]------------------------------------------
#
copy root/admin/*.php to admin/
copy root/templates/subSilver/admin/*.tpl to templates/subSilver/admin/

# 
#-----[ OPEN ]------------------------------------------
# 
includes/usercp_viewprofile.php

#
#-----[ FIND ]------------------------------------------
#
$flag = ( !empty($profiledata['user_from_flag']) ) ? " <img src="images/flags/" . $profiledata['user_from_flag'] . "" alt="" . $profiledata['user_from_flag'] . "">" : "";

#
#-----[ REPLACE WITH ]------------------------------------------
#
$flag = ( !empty($profiledata['user_from_flag']) ) ? ' <img src="images/flags/' . $profiledata['user_from_flag'] . '" alt="' . $profiledata['user_from_flag'] . '" title="' . $profiledata['user_from_flag'] . '" border="1" />' : '';

#
#-----[ OPEN ]------------------------------------------
# 
includes/usercp_register.php

#
#-----[ FIND ]------------------------------------------
#
	$user_flag = ( !empty($HTTP_POST_VARS['user_flag']) ) ? $HTTP_POST_VARS['user_flag'] : '' ;

#
#-----[ REPLACE WITH ]------------------------------------------
#
	$user_flag = ( !empty($HTTP_POST_VARS['user_flag']) && $HTTP_POST_VARS['user_flag'] != 'blank.gif' ) ? htmlspecialchars($HTTP_POST_VARS['user_flag']) : '';

#
#-----[ FIND ]------------------------------------------
#
#
			$sql = "UPDATE " . USERS_TABLE . "
				SET " . $username_sql . $passwd_sql

#
#-----[ IN-LINE FIND ]------------------------------------------
#
 user_from_flag = '$user_flag',

#
#-----[ IN-LINE REPLACE WITH ]------------------------------------------
#
 user_from_flag = '" . str_replace("'", "''", $user_flag) . "',

#
#-----[ FIND ]------------------------------------------
#
			$sql = "INSERT INTO " . USERS_TABLE . "	(user_id
				VALUES ($user_id

#
#-----[ IN-LINE FIND ]------------------------------------------
#
 '$user_flag',

#
#-----[ IN-LINE REPLACE WITH ]------------------------------------------
#
'" . str_replace("'", "''", $user_flag) . "',

#
#-----[ FIND ]------------------------------------------
#
	$sql = "SELECT *
		FROM " . FLAG_TABLE . "
		ORDER BY flag_id";

#
#-----[ IN-LINE FIND ]------------------------------------------
#
		ORDER BY flag_id";

#
#-----[ IN-LINE REPLACE WITH ]------------------------------------------
#
		ORDER BY flag_name";

#
#-----[ FIND ]------------------------------------------
#
	$sql = "SELECT *
		FROM " . FLAG_TABLE . "
		ORDER BY flag_id";
	if(!$flags_result = $db->sql_query($sql))
	{
		message_die(GENERAL_ERROR, "Couldn't obtain flags information.", "", __LINE__, __FILE__, $sql);
	}
	$flag_row = $db->sql_fetchrowset($ranksresult);
	$num_flags = $db->sql_numrows($ranksresult) ;

	// build the html select statement
	$flag_start_image = 'blank.gif' ;
	$selected = ( isset($user_flag) ) ? '' : ' selected="selected"'  ;
	$flag_select = "<select name="user_flag" onChange="document.images['user_flag'].src = 'images/flags/'
 + this.value;" >";
	$flag_select .= "<option value="blank.gif"$selected>" . $lang['Select_Country'] . "</option>";
	for ($i = 0; $i < $num_flags; $i++)
	{
		$flag_name = $flag_row[$i]['flag_name'];
		$flag_image = $flag_row[$i]['flag_image'];
		$selected = ( isset( $user_flag) ) ? (($user_flag == $flag_image) ? 'selected="selected"' : '' ) : '' ;
		$flag_select .= "t<option value="$flag_image"$selected>$flag_name</option>";
		if ( isset( $user_flag) && ($user_flag == $flag_image))
		{
			$flag_start_image = $flag_image ;
		}
	}
	$flag_select .= '</select>';

#	
#-----[ REPLACE WITH ]------------------------------------------
#
	$sql = "SELECT *
		FROM " . FLAG_TABLE . "
		ORDER BY flag_name";
	if(!$flags_result = $db->sql_query($sql))
	{
		message_die(GENERAL_ERROR, "Couldn't obtain flags information.", "", __LINE__, __FILE__, $sql);
	}

	// Build the html select statement
	$flag_start_image = 'blank.gif';
	$flag_select = '<select name="user_flag" onChange="document.images['user_flag'].src = 'images/flags/' + this.value;">';
	$flag_select .= '<option value="blank.gif">' . $lang['Select_country'] . '</option>';
	while ( $flag_row = $db->sql_fetchrow($flags_result) )
	{
		$flag_name = $flag_row['flag_name'];
		$flag_image = $flag_row['flag_image'];
		$selected = ( $user_flag == $flag_image ) ? ' selected="selected"' : '';
		$flag_select .= '   <option value="' . $flag_image . '"' . $selected . '">' . $flag_name . '</option>';
		if ( isset( $user_flag) && ($user_flag == $flag_image))
		{
			$flag_start_image = $flag_image;
		}
	}
	$flag_select .= '</select>';

#
#-----[ FIND ]------------------------------------------
#
		'L_FLAG' => $lang['Country_Flag'],

#
#-----[ REPLACE WITH ]------------------------------------------
#
		'L_FLAG' => $lang['Country_flag'],

# 
#-----[ OPEN ]------------------------------------------
# 
viewtopic.php

#
#-----[ FIND ]------------------------------------------
#
	$poster_from_flag = ( $postrow[$i]['user_from_flag'] && $postrow[$i]['user_id'] != ANONYMOUS ) ? "<img src="images/flags/" . $postrow[$i]['user_from_flag'] . "" alt="" . $postrow[$i]['user_from_flag'] . "" border="0" width="32" height="20" /><br />" : "";

#
#-----[ REPLACE WITH ]------------------------------------------
#
	$poster_from_flag = ( $postrow[$i]['user_from_flag'] && $postrow[$i]['user_id'] != ANONYMOUS ) ? '<br /><img src="images/flags/' . $postrow[$i]['user_from_flag'] . '" alt="' . $postrow[$i]['user_from_flag'] . '" border="1" /><br />' : '';

# 
#-----[ OPEN ]------------------------------------------
# 
memberlist.php

#
#-----[ FIND ]------------------------------------------
#
		$from = ( !empty($row['user_from']) ) ? $row['user_from'] : ' ';

#
#-----[ REPLACE WITH ]------------------------------------------
#
		$from = ( !empty($row['user_from']) ) ? $row['user_from'] : '';
		$from = ( !empty($row['user_from_flag']) ) ? $from . ' <img src="images/flags/' . $row['user_from_flag'] . '" alt="' . $row['user_from_flag'] . '" border="1" />' : $from;

#
#-----[ FIND ]------------------------------------------
#
		$flag = ( !empty($row['user_from_flag']) ) ? " <img src="images/flags/" . $row['user_from_flag'] . "" alt="" . $row['user_from_flag'] . "">" : ' <img src="images/flags/blank.gif" alt="">';

#
#-----[ REPLACE WITH ]------------------------------------------
# Just remove/delete the lines (replacing with an empty line)

#
#-----[ FIND ]------------------------------------------
#
			'FLAG' => $flag,

#
#-----[ REPLACE WITH ]------------------------------------------
# Just remove/delete the lines (replacing with an empty line)

#
#-----[ OPEN ]------------------------------------------
#
admin/admin_users.php

#
#-----[ FIND ]------------------------------------------
#
		$user_flag = ( !empty($HTTP_POST_VARS['user_flag']) ) ? $HTTP_POST_VARS['user_flag'] : '' ;

#
#-----[ REPLACE WITH ]------------------------------------------
#
		$user_flag = ( !empty($HTTP_POST_VARS['user_flag']) && $HTTP_POST_VARS['user_flag'] != 'blank.gif' ) ? htmlspecialchars($HTTP_POST_VARS['user_flag']) : '';

#
#-----[ FIND ]------------------------------------------
#
			$sql = "UPDATE " . USERS_TABLE . "
				SET " . $username_sql

#
#-----[ IN-LINE FIND ]------------------------------------------
#
 user_from_flag = '$user_flag',

#
#-----[ IN-LINE REPLACE WITH ]------------------------------------------
#
 user_from_flag = '" . str_replace("'", "''", $user_flag) . "',

#
#-----[ FIND ]------------------------------------------
#
			$location = htmlspecialchars(stripslashes($location));

#
#-----[ AFTER, ADD ]------------------------------------------
#
			$user_flag = htmlspecialchars(stripslashes($user_flag));

#
#-----[ FIND ]------------------------------------------
#
			$s_hidden_fields .= '<input type="hidden" name="user_flag" value="' . $user_flag . '" />';

#
#-----[ REPLACE WITH ]------------------------------------------
#
			$s_hidden_fields .= '<input type="hidden" name="user_flag" value="' . str_replace(""", """, $user_flag) . '" />';

#
#-----[ FIND ]------------------------------------------
#
	// query to get the list of flags
	$sql = "SELECT *
		FROM " . FLAG_TABLE . "
		ORDER BY flag_id";
	if(!$flags_result = $db->sql_query($sql))
	{
		message_die(GENERAL_ERROR, "Couldn't obtain flags information.", "", __LINE__, __FILE__, $sql);
	}
	$flag_row = $db->sql_fetchrowset($ranksresult);
	$num_flags = $db->sql_numrows($ranksresult) ;

	// build the html select statement
	$flag_start_image = 'blank.gif' ;
	$selected = ( isset($user_flag) ) ? '' : ' selected="selected"'  ;
	$flag_select = "<select name="user_flag" onChange="document.images['user_flag'].src = '../images/flags/'
 + this.value;" >";
	$flag_select .= "<option value="blank.gif"$selected>" . $lang['Select_Country'] . "</option>";
	for ($i = 0; $i < $num_flags; $i++)
	{
		$flag_name = $flag_row[$i]['flag_name'];
		$flag_image = $flag_row[$i]['flag_image'];
		$selected = ( isset( $user_flag) ) ? (($user_flag == $flag_image) ? 'selected="selected"' : '' ) : '' ;
		$flag_select .= "t<option value="$flag_image"$selected>$flag_name</option>";
		if ( isset( $user_flag) && ($user_flag == $flag_image))
		{
			$flag_start_image = $flag_image ;
		}
	}
	$flag_select .= '</select>';

#
#-----[ REPLACE WITH ]------------------------------------------
#
		// Query to get the list of flags
		$sql = "SELECT *
			FROM " . FLAG_TABLE . "
			ORDER BY flag_name";
		if(!$flags_result = $db->sql_query($sql))
		{
			message_die(GENERAL_ERROR, "Couldn't obtain flags information.", "", __LINE__, __FILE__, $sql);
		}

		// Build the html select statement
		$flag_start_image = 'blank.gif';
		$flag_select = '<select name="user_flag" onChange="document.images['user_flag'].src = '../images/flags/' + this.value;">';
		$flag_select .= '<option value="blank.gif">' . $lang['Select_country'] . '</option>';
		while ( $flag_row = $db->sql_fetchrow($flags_result) )
		{
			$flag_name = $flag_row['flag_name'];
			$flag_image = $flag_row['flag_image'];
			$selected = ( $user_flag == $flag_image ) ? ' selected="selected"' : '';
			$flag_select .= '   <option value="' . $flag_image . '"' . $selected . '">' . $flag_name . '</option>';
			if ( isset( $user_flag) && ($user_flag == $flag_image))
			{
				$flag_start_image = $flag_image;
			}
		}
		$flag_select .= '</select>';

#
#-----[ FIND ]------------------------------------------
#
			'L_FLAG' => $lang['Country_Flag'],

#
#-----[ REPLACE WITH ]------------------------------------------
#
			'L_FLAG' => $lang['Country_flag'],

#			
#-----[ OPEN ]------------------------------------------
# 
language/lang_english/lang_main.php

# 
#-----[ FIND ]------------------------------------------
# 
$lang['Country_Flag'] = 'Country Flag';
$lang['Select_Country'] = 'SELECT COUNTRY' ;

#
#-----[ REPLACE WITH ]------------------------------------------
# 
$lang['Country_flag'] = 'Flag';
$lang['Select_country'] = 'SELECT COUNTRY/LOCATION';

# 
#-----[ OPEN ]------------------------------------------
# 
templates/subSilver/viewtopic_body.tpl

#
#-----[ FIND ]------------------------------------------
#
<td width="150" align="left" valign="top" class="{postrow.ROW_CLASS}">

#
#-----[ IN-LINE FIND ]------------------------------------------
#
{postrow.POSTER_FROM_FLAG}

#
#-----[ IN-LINE REPLACE WITH ]------------------------------------------
# Just remove/delete the lines (replacing with an empty line)

# 
#-----[ OPEN ]------------------------------------------
# 
templates/subSilver/profile_add_body.tpl

#
#-----[ FIND ]------------------------------------------
#
	<tr>
	  <td class="row1"><span class="gen">{L_FLAG}:</span></td>
	  <td class="row2"><span class="gensmall">
		<table><tr>

#
#-----[ IN-LINE FIND ]------------------------------------------
#
			<td>{FLAG_SELECT}    </td>
	  		<td><img src="images/flags/{FLAG_START}" width="32" height="20" name="user_flag" /></td>

#
#-----[ IN-LINE REPLACE WITH ]------------------------------------------
#
			<td>{FLAG_SELECT}   </td>
	  		<td><img src="images/flags/{FLAG_START}" name="user_flag" /></td>

# 
#-----[ OPEN ]------------------------------------------
# 
templates/subSilver/memberlist_body.tpl

#
#-----[ FIND ]------------------------------------------
#
<table class="gen"><tr><td align=center width="100%">

#
#-----[ REPLACE WITH ]------------------------------------------
# Just remove/delete the lines (replacing with an empty line)

#
#-----[ IN-LINE FIND ]------------------------------------------
#
</td><td align=right>{memberrow.FLAG}</td></tr></table>

#
#-----[ REPLACE WITH ]------------------------------------------
# Just remove/delete the lines (replacing with an empty line)

#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/admin/user_edit_body.tpl

#
#-----[ FIND ]------------------------------------------
#
	<tr>
	  <td class="row1"><span class="gen">{L_FLAG}:</span></td>
	  <td class="row2"><span class="gensmall">

#
#-----[ IN-LINE FIND ]------------------------------------------
#
			<td>{FLAG_SELECT}    </td>
	  		<td><img src="../images/flags/{FLAG_START}" width="32" height="20" name="user_flag" /></td>

#
#-----[ IN-LINE REPLACE WITH ]------------------------------------------
#
			<td>{FLAG_SELECT}   </td>
	  		<td><img src="../images/flags/{FLAG_START}" name="user_flag" /></td>

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
User avatar
irene_haydon
Registered User
Posts: 210
Joined: Sat Apr 15, 2006 3:37 pm

Post by irene_haydon »

Demo board will be helpfull.

Thanks,

Irene
Lord Le Brand
Registered User
Posts: 306
Joined: Fri May 26, 2006 8:28 pm
Location: The Netherlands (GMT+1)

Post by Lord Le Brand »

I'd love to show you but it isn't PCP compatible... :? :(

Which is exactly my problem, I want a PCP compatible Country Flag MOD!
Lord Le Brand
Registered User
Posts: 306
Joined: Fri May 26, 2006 8:28 pm
Location: The Netherlands (GMT+1)

Post by Lord Le Brand »

ycl not here?
*bump*
could it be made compatible with PCP?
ycl6
Registered User
Posts: 5696
Joined: Sat Feb 15, 2003 10:35 am
Location: Taiwan
Contact:

Post by ycl6 »

Hi, I have no intention to work on the PCP version of this MOD because I've never used PCP, so I do not know how to code around it.

If someone is able to provide me a PCP workround, I'll be more than happen to include it in this MOD.

~Mac
User avatar
Nigelman
Registered User
Posts: 210
Joined: Sun Jun 12, 2005 3:59 pm
Contact:

Post by Nigelman »

I need help....... I manually installed this mod but after much work it isn't working. I made a backup before and tried to reinstall it but I still am not able to access my board..........help!!!!

Could not obtain post/user information.

Here's my error

Code: Select all

Could not obtain post/user information.

DEBUG MODE

SQL Error : 1054 Unknown column 'u.user_from_flag' in 'field list'

SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_from_flag, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_skype, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, u.user_allow_viewonline, u.user_session_time, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid FROM phpbb_posts p, phpbb_users u, phpbb_posts_text pt WHERE p.topic_id = 562 AND pt.post_id = p.post_id AND u.user_id = p.poster_id ORDER BY p.post_time ASC LIMIT 0, 10

Line : 400
File : viewtopic.php
Can someone tell me what I've done wrong here?

Nigelman 8)
User avatar
MHobbit
Former Team Member
Posts: 4761
Joined: Thu Mar 18, 2004 5:32 pm
Location: There and Back Again

Post by MHobbit »

Nigelman, you didn't update your database at all or properly. See this part of the MOD's install doc:
#
#-----[ DIY INSTRUCTIONS ]------------------------------------------
#
Copy root/install/db_update_en.php to install/db_update_en.php
Execute and delete after it has been run


Do as it says. ;-)
Former phpBB MOD Team member
No private support is offered.
"There’s too many things to get done, and I’m running out of days..."
Captain_Kirk76
Registered User
Posts: 52
Joined: Wed May 31, 2006 1:15 pm

Post by Captain_Kirk76 »

is this compatible with EasyMOD V0.3.0 BETA?
ycl6
Registered User
Posts: 5696
Joined: Sat Feb 15, 2003 10:35 am
Location: Taiwan
Contact:

Post by ycl6 »

Captain_Kirk76 wrote: is this compatible with EasyMOD V0.3.0 BETA?

The MOD installation file says
##############################################################
## Author Notes:
##
## Tested on 2.0.20. Can be installed using EasyMOD 0.3.0


~Mac
Liamhfc
Registered User
Posts: 4
Joined: Sun Jun 04, 2006 12:59 am

Post by Liamhfc »

Hi, I installed this manually and keeping getting these errors

I get the one bellow when i try to view a topic.

Code: Select all

Parse error: syntax error, unexpected '.', expecting ')' in /home2/liam15/public_html/forum/viewtopic.php on line 1167

And this one when i try to access my Admin Panel

I will post the Admin Panel error later, My site is down ATM :?

Any idea what i did wrong?
Liamhfc
Registered User
Posts: 4
Joined: Sun Jun 04, 2006 12:59 am

Post by Liamhfc »

Liamhfc wrote: Hi, I installed this manually and keeping getting these errors

I get the one bellow when i try to view a topic.

Code: Select all

Parse error: syntax error, unexpected '.', expecting ')' in /home2/liam15/public_html/forum/viewtopic.php on line 1167

And this one when i try to access my Admin Panel

Code: Select all

Parse error: syntax error,
unexpected
T_VARIABLE in
/home2/liam15/public_html/forum/admin/admin_users.php 
Any idea what i did wrong?
ycl6
Registered User
Posts: 5696
Joined: Sat Feb 15, 2003 10:35 am
Location: Taiwan
Contact:

Post by ycl6 »

Liamhfc wrote: Hi, I installed this manually and keeping getting these errors

I get the one bellow when i try to view a topic.

Code: Select all

Parse error: syntax error, unexpected '.', expecting ')' in /home2/liam15/public_html/forum/viewtopic.php on line 1167

How did you install this MOD? Manually or using EasyMOD?

Please upload your viewtopic.php as a zip file somewhere so that I can take a look at it. Or use pastebin.com to show me the content of your viewtopic.php.

p.s. Same goes with your admin_users.php.

~Mac
Post Reply

Return to “[2.0.x] MOD Database Releases”