Country Flags by IP Address [Deleted]

Apologies, of course you're right about the readme and the folder permissions, sorry.
The GeoLite file is there.
What information do you need? It's https://www.avforums.com and only moderators and admin can see the flags at the moment.
By some chance are you running nginx or varnish?

I have a feeling the remote_addr variable is returning your server's IP address as your user's ip address.
 
Last edited:
NGINX, yes. Is that a trustworthy variable to be using? Will I need to contact my host to get him to check that in PHP?
I believe NGINX returns the server's private IP with the PHP $_SERVER['remote_addr'].

I think it can be solved by installing apache mod_rpaf, but I don't have enough experience with NGINX to say that for sure.
 
Installed on XF 1.2.7 but has put everyone's country as New Zealand :eek:.

Great addon btw thanks Snog :).
I would need more information to figure out what would cause that. I've never seen a single country flag shown for all users unless there was a problem with what was being returned to PHP from Apache like Stuart encountered with NGINX.

You wouldn't be running NGINX would you?
 
No not running NGINX, am on a Hostgator account.​
If you could, uncomment the commented lines in the library/Snog/CountryFlags/Listener/Visitor.php file so they look like this...

Code:
// ***********************************************
// LOG IP ADDRESS VARIABLES
// DO NOT UNCOMMENT THIS AREA UNLESS TOLD TO DO SO
// ***********************************************
// ===============================================
$filename = 'data/countryflags/ipaddress.log';
$somecontent = 'Raw HTTP REMOTE ADDR: ' . $_SERVER['REMOTE_ADDR'];
if(isset($_SERVER['HTTP_X_REAL_IP'])) $somecontent .= ' Raw X_REAL: ' . $_SERVER['HTTP_X_REAL_IP'];
if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $somecontent .= ' Raw X_FORWARDED: ' . $_SERVER['HTTP_X_FORWARDED_FOR'];
$somecontent .= ' Result IP address: ' . $ipaddress . "\r\n";
$handle = fopen($filename, 'a');
fwrite($handle, $somecontent);
fclose($handle);
// ===============================================
// ***********************************************

Leave it run for a while and then send me the resulting ipaddress.log file in data/countryflags by Private Conversation here.

Once you send the log file, you can comment out the area in that file again so it looks like this..
Code:
// ***********************************************
// LOG IP ADDRESS VARIABLES
// DO NOT UNCOMMENT THIS AREA UNLESS TOLD TO DO SO
// ***********************************************
// ===============================================
// $filename = 'data/countryflags/ipaddress.log';
// $somecontent = 'Raw HTTP REMOTE ADDR: ' . $_SERVER['REMOTE_ADDR'];
// if(isset($_SERVER['HTTP_X_REAL_IP'])) $somecontent .= ' Raw X_REAL: ' . $_SERVER['HTTP_X_REAL_IP'];
// if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $somecontent .= ' Raw X_FORWARDED: ' . $_SERVER['HTTP_X_FORWARDED_FOR'];
// $somecontent .= ' Result IP address: ' . $ipaddress . "\r\n";
// $handle = fopen($filename, 'a');
// fwrite($handle, $somecontent);
// fclose($handle);
// ===============================================
// ***********************************************
 
Hi Snog, have done that, how long would you like me to leave it uncommented for. Isn't a very busy site.

I should add that it has put people's country flags as NZ who haven't been on the site since I installed the addon.
 
Hi Snog, have done that, how long would you like me to leave it uncommented for. Isn't a very busy site.

I should add that it has put people's country flags as NZ who haven't been on the site since I installed the addon.
Just run it until someone who's flag is showing as NZ is online.

I don't see how it's possible that a flag would be assigned to someone that hasn't been online unless you've had this add-on installed and just installed this as an update. Flags aren't assigned until a user with a valid user ID is online.
 
I think I may have had this installed earlier but for whatever reason uninstalled it. Is there a cache I can clear to reset it?
 
I think I may have had this installed earlier but for whatever reason uninstalled it. Is there a cache I can clear to reset it?
There is no cache. The data is held in the user table.

If you've had any visitors to your site, I think you can send me the log file. It's been a number of hours and I'd imagine someone has logged into your site.
 
Last edited:
Love the add-on... but one thing nags me a little, actually more than a little..lol

My country flag comes up as the Union Jack for The United Kingdom ( this is the bit that gets up my nose )
I was born in England and live in England . There is no such country as United Kingdom , it is what it says on the tin A Kingdom made up of 4 countries.
England , Scotland , Wales & Northern Ireland..

Question;
So is there any way I can alter to show the 4 countries as they should be shown ,not as a kingdom..?

Regards..
 
Love the add-on... but one thing nags me a little, actually more than a little..lol

My country flag comes up as the Union Jack for The United Kingdom ( this is the bit that gets up my nose )
I was born in England and live in England . There is no such country as United Kingdom , it is what it says on the tin A Kingdom made up of 4 countries.
England , Scotland , Wales & Northern Ireland..

Question;
So is there any way I can alter to show the 4 countries as they should be shown ,not as a kingdom..?

Regards..
Unfortunately I don't have control over how the internet or the database specifies countries. All IP addresses in England, Scotland, Wales and Northern Ireland come up as United Kingdom in the database from MaxMind.

Here's the list of the official ISO codes used for countries...
http://en.wikipedia.org/wiki/ISO_3166-1
 
Last edited:
XF 1.4

After the update from 1.0.9 to 1.1.0 I get this error on the forum en can't login in admin.php.

Server ERROR

  1. Countryflags\Db\Reader->__construct() in Snog/CountryFlags/Listener/Visitor.php at line 69
  2. Snog_CountryFlags_Listener_Visitor::visitor()
  3. call_user_func_array() in XenForo/CodeEvent.php at line 90
  4. XenForo_CodeEvent::fire() in XenForo/Visitor.php at line 469
  5. XenForo_Visitor::setup() in XenForo/Session.php at line 274
  6. XenForo_Session::startPublicSession() in XenForo/Controller.php at line 291
  7. XenForo_Controller->_setupSession() in XenForo/Controller.php at line 304
  8. XenForo_Controller->preDispatch() in XenForo/FrontController.php at line 346
  9. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
  10. XenForo_FrontController->run() in /var/www/html/index.php at line 13
 
Back
Top Bottom