Country Flags by IP Address [Deleted]

Snog

Well-known member
Snog submitted a new resource:

Country Flags by IP Address - Shows member's country flag based on their IP Address

Shows what country your members are in based on their current IP address.

This add-on uses MaxMind's GeoLite2-Country database and MaxMind's DB Reader. This add-on does not require mod_geoip to be installed on your server.

Features:
  • Works with both IPV4 and IPV6 IP addresses
  • Select what user groups can view flags
  • Select where the flags are displayed.
  • Automatic database updates

REQUIREMENTS:
cURL must be...

Read more about this resource...
 
For those that don't know how to tell if BC Math is installed and available to PHP, bring up your PHP Info page. Look for something like this...

bcmath.webp
 
Juhu! I so glad that there is finally an addon for country flags which has no complicated requirements. Unfortunately I don't really fall in love with the flag icons, maybe we can see a different set in the future or multiple to select from :)

I really like these ones for example: https://github.com/lafeber/world-flags-sprite

How do you like them?
 
Juhu! I so glad that there is finally an addon for country flags which has no complicated requirements. Unfortunately I don't really fall in love with the flag icons, maybe we can see a different set in the future or multiple to select from :)

I really like these ones for example: https://github.com/lafeber/world-flags-sprite

How do you like them?
People are free to use whatever flags they want.

You just need to match the names of the flags to what is in the snog_flags.css template.
 
Just an observation....

If using RT's "online status Ribbon" (http://xenforo.com/community/resources/rt-online-status-ribbon.1276/), when the user is offline, then everything is fine...

however if the user is online...

It shifts the flag onto the next line.

Just to let you know... However Nice Add-on. Many thanks.
I wasn't ignoring you. I wanted to test what you're showing.

This isn't a problem with the flag display. It's a problem with the Status Ribbon mod. It happens with any field, even the in default XF template. Fields are pushed over, that's what causes the flag to drop lower and if the message count was a large number, it would drop lower also....
compare.webp
 
Many thanks Snog for checking it out for me :)

Interestingly, have woken up this morning to find my error log full of errors.... however it seems all from the same user. I have checked and there's nothing different in his setup as opposed to everyone elses.. He is a registered user on the board.

Code:
ErrorException: Undefined index: country - library/Snog/CountryFlags/Listener/Visitor.php:39
Generated By: kevlar, Today at 5:54 AM
Stack Trace
#0 /home/pinball/public_html/community/library/Snog/CountryFlags/Listener/Visitor.php(39): XenForo_Application::handlePhpError(8, 'Undefined index...', '/home/pinball/p...', 39, Array)
#1 [internal function]: Snog_CountryFlags_Listener_Visitor::visitor(Object(XenForo_Visitor))
#2 /home/pinball/public_html/community/library/XenForo/CodeEvent.php(90): call_user_func_array(Array, Array)
#3 /home/pinball/public_html/community/library/XenForo/Visitor.php(461): XenForo_CodeEvent::fire('visitor_setup', Array)
#4 /home/pinball/public_html/community/library/XenForo/Session.php(274): XenForo_Visitor::setup(510, Array)
#5 /home/pinball/public_html/community/library/XenForo/Controller.php(291): XenForo_Session::startPublicSession(Object(Zend_Controller_Request_Http))
#6 /home/pinball/public_html/community/library/XenForo/Controller.php(304): XenForo_Controller->_setupSession('Preview')
#7 /home/pinball/public_html/community/library/XenForo/FrontController.php(346): XenForo_Controller->preDispatch('Preview', 'XenForo_Control...')
#8 /home/pinball/public_html/community/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#9 /home/pinball/public_html/community/index.php(13): XenForo_FrontController->run()
#10 {main}
Request State
array(3) {
["url"] => string(273) "http://www.pinballinfo.com/community/threads/new-driverboard-installed-now-flipper-coil-melted-why.11045/preview?_xfRequestUri=%2Fcommunity%2Ffind-new%2F256784%2Fposts&_xfNoRedirect=1&_xfToken=510%2C1397278319%2C10342126ad87df5a722fbd8df02a5de8a3c19735&_xfResponseType=json"
["_GET"] => array(4) {
["_xfRequestUri"] => string(32) "/community/find-new/256784/posts"
["_xfNoRedirect"] => string(1) "1"
["_xfToken"] => string(55) "510,1397278319,10342126ad87df5a722fbd8df02a5de8a3c19735"
["_xfResponseType"] => string(4) "json"
}
["_POST"] => array(0) {
}
}

Just to add - i see where you are coming from with respect to the ribbon. I have changed to "covering ribbon" and this seems to fix the problem, whilst not making that much of a difference to the layout :)
 
Last edited:
Many thanks Snog for checking it out for me :)

Interestingly, have woken up this morning to find my error log full of errors.... however it seems all from the same user. I have checked and there's nothing different in his setup as opposed to everyone elses.. He is a registered user on the board.

Code:
ErrorException: Undefined index: country - library/Snog/CountryFlags/Listener/Visitor.php:39
Generated By: kevlar, Today at 5:54 AM
Stack Trace
#0 /home/pinball/public_html/community/library/Snog/CountryFlags/Listener/Visitor.php(39): XenForo_Application::handlePhpError(8, 'Undefined index...', '/home/pinball/p...', 39, Array)
#1 [internal function]: Snog_CountryFlags_Listener_Visitor::visitor(Object(XenForo_Visitor))
#2 /home/pinball/public_html/community/library/XenForo/CodeEvent.php(90): call_user_func_array(Array, Array)
#3 /home/pinball/public_html/community/library/XenForo/Visitor.php(461): XenForo_CodeEvent::fire('visitor_setup', Array)
#4 /home/pinball/public_html/community/library/XenForo/Session.php(274): XenForo_Visitor::setup(510, Array)
#5 /home/pinball/public_html/community/library/XenForo/Controller.php(291): XenForo_Session::startPublicSession(Object(Zend_Controller_Request_Http))
#6 /home/pinball/public_html/community/library/XenForo/Controller.php(304): XenForo_Controller->_setupSession('Preview')
#7 /home/pinball/public_html/community/library/XenForo/FrontController.php(346): XenForo_Controller->preDispatch('Preview', 'XenForo_Control...')
#8 /home/pinball/public_html/community/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#9 /home/pinball/public_html/community/index.php(13): XenForo_FrontController->run()
#10 {main}
Request State
array(3) {
["url"] => string(273) "http://www.pinballinfo.com/community/threads/new-driverboard-installed-now-flipper-coil-melted-why.11045/preview?_xfRequestUri=%2Fcommunity%2Ffind-new%2F256784%2Fposts&_xfNoRedirect=1&_xfToken=510%2C1397278319%2C10342126ad87df5a722fbd8df02a5de8a3c19735&_xfResponseType=json"
["_GET"] => array(4) {
["_xfRequestUri"] => string(32) "/community/find-new/256784/posts"
["_xfNoRedirect"] => string(1) "1"
["_xfToken"] => string(55) "510,1397278319,10342126ad87df5a722fbd8df02a5de8a3c19735"
["_xfResponseType"] => string(4) "json"
}
["_POST"] => array(0) {
}
}

Just to add - i see where you are coming from with respect to the ribbon. I have changed to "covering ribbon" and this seems to fix the problem, whilst not making that much of a difference to the layout :)
I'm totally unable to duplicate the problem. Could you send the IP address for that user to me via PC?

And so far as the online status, you can also use 'Below Avatar' with the 'Rank Ribbons' fix set to yes.
 
Last edited:
is the addon open source and I'm allowed to create a git repo that I can merge possible future updates?
 
is the addon open source and I'm allowed to create a git repo that I can merge possible future updates?
My code that interfaces to XenForo is not open source.

However, the code in the Listener/Includes directory (the DB reader) is open source and covered by the Apache 2.0 license which allows me to add my own license terms and conditions to my work. You can obtain the DB reader that is in the Listener/Includes directory at the MaxMind web site.
 
thanks :) Is it normal that I need to confirm the template changes? What about the member list, there is only a css import yet?
 
thanks :) Is it normal that I need to confirm the template changes? What about the member list, there is only a css import yet?
I'm not sure why people are having to confirm template changes. The 3 sites I've installed this on never asked for that so I don't know where it's coming from. What version of XF are you running?

What do you mean by member list and css import?
 
Last edited:
I'm not sure why people are having to confirm template changes. The 3 sites I've installed this on never asked for that so I don't know where it's coming from.

What do you mean by member list and css import?
this is how my member_list_item looks like, I only find the css import, but nothing else:

HTML:
<xen:require css="xenforo_member_list_item.css" />
<xen:if is="{$xenOptions.snog_countryflags_list}"><xen:require css="snog_flags.css" /></xen:if>

<li class="primaryContent memberListItem{xen:if $extended, ' extended'}"{xen:if $id, ' id="{$id}"'}>

    <xen:avatar user="$user" size="s" class="{xen:if $noOverlay, 'NoOverlay'}" />

    <xen:if is="{$extraTemplate}"><div class="extra">{xen:raw $extraTemplate}</div></xen:if>

    <div class="member">
   
        <xen:if is="{$user.user_id}">
       
            <h3 class="username"><xen:username user="$user" rich="true" class="StatusTooltip{xen:if $noOverlay, ' NoOverlay'}" title="{xen:string censor, $user.status}" /></h3>
           
            <div class="userInfo">
                <div class="userBlurb dimmed">{xen:helper userBlurb, $user}</div>
                <dl class="userStats pairsInline">
                    <dt title="{xen:phrase total_messages_posted_by_x, 'name={$user.username}'}">{xen:phrase messages}:</dt> <dd>{xen:number $user.message_count}</dd>
                    <dt title="{xen:phrase number_of_times_something_posted_by_x_has_been_liked, 'name={$user.username}'}">{xen:phrase likes_received}:</dt> <dd>{xen:number $user.like_count}</dd>
                    <dt>{xen:phrase trophy_points}:</dt> <dd title="{xen:phrase trophy_points}">{xen:number $user.trophy_points}</dd>
                </dl>
            </div>
           
        <xen:elseif is="{$guestHtml}" />
            <h3 class="username guest dimmed">{xen:raw $guestHtml}</h3>
        <xen:else />
            <h3 class="username guest dimmed">{xen:phrase guest}</h3>
        </xen:if>
       
        <xen:if hascontent="true">
            <div class="contentInfo"><xen:contentcheck>{xen:raw $contentTemplate}</xen:contentcheck></div>
        </xen:if>
       
    </div>
   
</li>
 
this is how my member_list_item looks like, I only find the css import, but nothing else:

HTML:
<xen:require css="xenforo_member_list_item.css" />
<xen:if is="{$xenOptions.snog_countryflags_list}"><xen:require css="snog_flags.css" /></xen:if>
 
<li class="primaryContent memberListItem{xen:if $extended, ' extended'}"{xen:if $id, ' id="{$id}"'}>
 
    <xen:avatar user="$user" size="s" class="{xen:if $noOverlay, 'NoOverlay'}" />
 
    <xen:if is="{$extraTemplate}"><div class="extra">{xen:raw $extraTemplate}</div></xen:if>
 
    <div class="member">
  
        <xen:if is="{$user.user_id}">
      
            <h3 class="username"><xen:username user="$user" rich="true" class="StatusTooltip{xen:if $noOverlay, ' NoOverlay'}" title="{xen:string censor, $user.status}" /></h3>
          
            <div class="userInfo">
                <div class="userBlurb dimmed">{xen:helper userBlurb, $user}</div>
                <dl class="userStats pairsInline">
                    <dt title="{xen:phrase total_messages_posted_by_x, 'name={$user.username}'}">{xen:phrase messages}:</dt> <dd>{xen:number $user.message_count}</dd>
                    <dt title="{xen:phrase number_of_times_something_posted_by_x_has_been_liked, 'name={$user.username}'}">{xen:phrase likes_received}:</dt> <dd>{xen:number $user.like_count}</dd>
                    <dt>{xen:phrase trophy_points}:</dt> <dd title="{xen:phrase trophy_points}">{xen:number $user.trophy_points}</dd>
                </dl>
            </div>
          
        <xen:elseif is="{$guestHtml}" />
            <h3 class="username guest dimmed">{xen:raw $guestHtml}</h3>
        <xen:else />
            <h3 class="username guest dimmed">{xen:phrase guest}</h3>
        </xen:if>
      
        <xen:if hascontent="true">
            <div class="contentInfo"><xen:contentcheck>{xen:raw $contentTemplate}</xen:contentcheck></div>
        </xen:if>
      
    </div>
  
</li>
What version of XF are you running?

What is shown in your template is a Template Modification using the TMS in 1.2/1.3. It shouldn't appear in your actual template.
 
Back
Top Bottom