Page 2 of 3

Re: How do I identify the country the browser is in?

Posted: Wed Nov 18, 2015 10:01 am
by simonmlewis
This is in my composer.json file locally:

Code: Select all

{
    "name": "phpmyadmin/phpmyadmin",
    "type": "application",
    "description": "MySQL web administration tool",
    "keywords": ["phpmyadmin","mysql","web"],
    "homepage": "http://www.phpmyadmin.net/",
    "license": "GPL-2.0+",
    "authors": [
        {
            "name": "The phpMyAdmin Team",
            "email": "phpmyadmin-devel@lists.sourceforge.net",
            "homepage": "http://www.phpmyadmin.net/home_page/team.php"
        }
    ],
    "support": {
        "forum": "https://sourceforge.net/p/phpmyadmin/discussion/Help",
        "issues": "https://sourceforge.net/p/phpmyadmin/bugs/",
        "wiki": "http://wiki.phpmyadmin.net/",
        "source": "https://github.com/phpmyadmin/phpmyadmin"
    },
    "require": {
        "php": ">=5.3.0"
    },
    "require-dev": {
        "satooshi/php-coveralls": ">=0.6",
        "phpunit/phpunit": "<4.2",
        "phpunit/phpunit-selenium": ">=1.2"
    }
    
    "require": {
        "willdurand/geocoder": "@stable"
    }
}
How do I load it prior to loading testcountry.inc?

Re: How do I identify the country the browser is in?

Posted: Wed Nov 18, 2015 10:17 am
by Celauran
That doesn't look right. You'd be tying this project to your PMA install. What does your directory structure look like? Also, you have two require blocks. Those should be combined. First, though, let's make sure we're working in the right spot.

Re: How do I identify the country the browser is in?

Posted: Wed Nov 18, 2015 10:28 am
by simonmlewis
What do you mean Directory Structure?
As in the structure of where files are stored or?

Re: How do I identify the country the browser is in?

Posted: Wed Nov 18, 2015 10:30 am
by Celauran
Right, exactly. The composer.json you posted above is for phpMyAdmin itself.

Re: How do I identify the country the browser is in?

Posted: Wed Nov 18, 2015 10:35 am
by simonmlewis
I ran the .exe installer file. Is that wrong??

Re: How do I identify the country the browser is in?

Posted: Wed Nov 18, 2015 10:40 am
by Celauran
No, I'm sure that's fine. It's just a separate project. We want to put the composer.json in the root of the project you're currently working on, not in phpMyAdmin.

Re: How do I identify the country the browser is in?

Posted: Wed Nov 18, 2015 10:42 am
by simonmlewis
So can i copy it in there... or do i need to do it in some official way?

Re: How do I identify the country the browser is in?

Posted: Wed Nov 18, 2015 10:50 am
by Celauran
You definitely don't want it in the file above. It should be in your project's topmost folder. Typically, this is either your document root or one level above that.

Re: How do I identify the country the browser is in?

Posted: Wed Nov 18, 2015 10:58 am
by Celauran
As an example, all of my sites are in ~/Sites. I typically break this down to ~/Sites/Client Name/Project Name. Each of these latter would have its own composer.json.

~/Sites/Client A/Project 1/composer.json
~/Sites/Client A/Project 2/composer.json
~/Sites/Client B/Project 1/composer.json

would all exist.

Re: How do I identify the country the browser is in?

Posted: Wed Nov 18, 2015 11:30 am
by simonmlewis

Code: Select all

echo var_export(unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$_SERVER['REMOTE_ADDR'])));
We have found this, and it produces a nice little array.

I'm still not entirely familiar with arrays, so how do I extract the one row for:

[text]array (
'geoplugin_request' => '34.34.456.45',
'geoplugin_status' => 206,
'geoplugin_credit' => 'Some of the returned data includes GeoLite data created by MaxMind, available from http://www.maxmind.com.',
'geoplugin_city' => '',
'geoplugin_region' => '',
'geoplugin_areaCode' => '0',
'geoplugin_dmaCode' => '0',
'geoplugin_countryCode' => 'GB',
'geoplugin_countryName' => 'United Kingdom',
'geoplugin_continentCode' => 'EU',
'geoplugin_latitude' => '51.5',
'geoplugin_longitude' => '-0.13',
'geoplugin_regionCode' => '',
'geoplugin_regionName' => NULL,
'geoplugin_currencyCode' => 'GBP',
'geoplugin_currencySymbol' => '£',
'geoplugin_currencySymbol_UTF8' => '£',
'geoplugin_currencyConverter' => '0.6573',
)[/text]
.... 'geoplugin_countryCode' => 'GB',

So then I can ask if it is US, or IE... etc...?
How do I extract that line?

Re: How do I identify the country the browser is in?

Posted: Wed Nov 18, 2015 11:44 am
by Celauran

Code: Select all

$varname['geoplugin_countryCode']
Where $varname is whatever variable you stored the array in.

Re: How do I identify the country the browser is in?

Posted: Wed Nov 18, 2015 12:26 pm
by simonmlewis

Code: Select all

echo var_export(unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$_SERVER['REMOTE_ADDR'])));
$varname = array();
$varname['geoplugin_countryCode'];
echo "$varname";
I think I am doing something wrong here.....

Tried this too:

Code: Select all

$varname = var_export(unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$_SERVER['REMOTE_ADDR'])));
$varname['geoplugin_countryCode'];
echo "$varname";

Re: How do I identify the country the browser is in?

Posted: Wed Nov 18, 2015 12:28 pm
by Celauran
You don't want the var_export in there.

Re: How do I identify the country the browser is in?

Posted: Wed Nov 18, 2015 12:41 pm
by simonmlewis
If I do this, with the >> << in there to highlight it for now, it just says "array".

Code: Select all

<?php
$varname = (unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$_SERVER['REMOTE_ADDR'])));
$varname['geoplugin_countryCode'];
echo ">> $varname <<";
?>

Re: How do I identify the country the browser is in?

Posted: Wed Nov 18, 2015 12:50 pm
by Celauran
That's odd.

Code: Select all

var_dump($varname);