MyBB Community Forums

Full Version: IP to country flag
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey,

I'm using the IPlog plugin of mybb, and now I'm willing to show a country flag on the user postbit where he's from.

I found out I have to put some code in the 'functions_post' file, but I don't think that is smart to do.

I've tried something like this:

$userid = $post['uid'];
		$getcountry_info = $db->query("SELECT `ipaddress` FROM `".TABLE_PREFIX."iplogs` WHERE `uid` = $userid ORDER BY `dateline` DESC LIMIT 1");
		while ($row = $getcountry_info->fetch_assoc())
		{
			$post['usercountryflag'] = $row['ipaddress'];
		}

and then copy
$post['usercountryflag'] = '';
above
eval("\$post['user_details'] = \"".$templates->get("postbit_author_guest")."\";");

Which worked out well.

Is this a smart way to do so? If not, how should I do this then?
Is using IP to determine a user's country of origin really accurate?

Give proxies? Tor? etc
True, but atleast it's better than nothing.. In my case atleast..
Since if I set it to choose self, people're gonna fake countries.
I'm not trying to troll your thread, because I don't have the answer to your initial question. But I will say, if you are looking to grow your community and keep members, the more choices you give them, the more they will like your community. Even if that means the freedom to goof off about their flag of choice. My two cents. Now I'll bugger off.
Yes you're true, that's why I was thinking about storing a addition profile field in the database, and once it's set to show flag it will show the flag in the postbit.

that's what I meant to do, but I wasn't sure if the way how I do that is correct.