GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Show content if country with mod_geoip by maxmind (https://gfy.com/showthread.php?t=1129842)

Oracle Porn 12-30-2013 05:55 AM

Show content if country with mod_geoip by maxmind
 
Anyone has a code that can show banner a for all countries except for example, germany, I want to show banner b. I have maxmind's geoip installed on my server but can't find a code that will show everyone banner A except one country to see banner B.

Klen 12-30-2013 05:58 AM

I have it.

Oracle Porn 12-30-2013 05:59 AM

Can you post it or do you just want to show the size or your e-penis?

Klen 12-30-2013 06:17 AM

Quote:

Originally Posted by Oracle Porn (Post 19927153)
Can you post it or do you just want to show the size or your e-penis?

That is correct my e-penis is hugeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.
PHP Code:

if ($country_code==DE){ echo '<img src="Debanner.jpg"></img>';}
else
{echo 
'<img src="allbanner.jpg"></img>';} 

Better way:
PHP Code:

 <?php

    $country 
getenv(GEOIP_COUNTRY_NAME);
    
$country_code getenv(GEOIP_COUNTRY_CODE);


switch (
$country_code) {
        case 
'US':
        echo 
'<img src="Usbanner.jpg"></img>';
            
        case 
'DE':
        echo 
'<img src="Debanner.jpg"></img>';
        
        default:
         echo 
'<img src="Other.jpg"></img>';
            
            
    }
?>


AHarper 12-30-2013 06:46 AM

Thanks for sharing :thumbsup (as replacement for the like button)

freecartoonporn 12-30-2013 07:10 AM

bookmarked

Barry-xlovecam 12-30-2013 07:22 AM

Another approach is to:
my $lang = "$ENV{'HTTP_ACCEPT_LANGUAGE'}";

that would envelope the browser language.
First of all: it is faster than a Max-Mind Geo-IP lookup -- there is no database overhead.
Secondly as an example, if you are in Montreal and using a French-Canadian language browser your HTTP_ACCEPT_LANGUAGE would be :
Accept-Language: fr-CA;q=0.5
Using Geo-IP you would assume Canada and offer the default English language version which would be in error. Say your surfer is an American travelling in Italy using a hotel wireless with an Italian IP but with his laptop's en-US language browser?

Well, you see my point ...

http://en.wikipedia.org/wiki/Content_negotiation

http://www.w3.org/International/ques...-http-and-lang

Constantine 12-30-2013 07:31 AM

Another graceful way to do the same:

PHP Code:

<?php

    $banner
['default'] = 'default-banner.jpg';

    
$banner['AU'] = 'au-banner.jpg';
    
$banner['DE'] = 'de-banner.jpg';
    
$banner['US'] = 'us-banner.jpg';


    
$country_code getenv(GEOIP_COUNTRY_CODE);

    if (isset(
$banner[$country_code]))
    {
        
$banner['default'] = $banner[$country_code];
    }

    echo (
'<img src="' $banner['default'] . '" alt=""/>');
?>


Constantine 12-30-2013 07:34 AM

Sure, you can get visitor's country_code from various sources.

Oracle Porn 12-30-2013 09:43 AM

thanks everyone :)

Oracle Porn 12-30-2013 10:03 AM

Quote:

Originally Posted by KlenTelaris (Post 19927171)
That is correct my e-penis is hugeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.
PHP Code:

if ($country_code==DE){ echo '<img src="Debanner.jpg"></img>';}
else
{echo 
'<img src="allbanner.jpg"></img>';} 

Better way:
PHP Code:

 <?php

    $country 
getenv(GEOIP_COUNTRY_NAME);
    
$country_code getenv(GEOIP_COUNTRY_CODE);


switch (
$country_code) {
        case 
'US':
        echo 
'<img src="Usbanner.jpg"></img>';
            
        case 
'DE':
        echo 
'<img src="Debanner.jpg"></img>';
        
        default:
         echo 
'<img src="Other.jpg"></img>';
            
            
    }
?>


this doesn't seem to work for me....

Quote:

Originally Posted by Constantine (Post 19927216)
Another graceful way to do the same:

PHP Code:

<?php

    $banner
['default'] = 'default-banner.jpg';

    
$banner['AU'] = 'au-banner.jpg';
    
$banner['DE'] = 'de-banner.jpg';
    
$banner['US'] = 'us-banner.jpg';


    
$country_code getenv(GEOIP_COUNTRY_CODE);

    if (isset(
$banner[$country_code]))
    {
        
$banner['default'] = $banner[$country_code];
    }

    echo (
'<img src="' $banner['default'] . '" alt=""/>');
?>



this works, but how do I show nothing for some countries?

Klen 12-30-2013 11:38 AM

Quote:

Originally Posted by Oracle Porn (Post 19927400)
this doesn't seem to work for me....

Just tested it and works fine,tho i did forgot to add break;
PHP Code:

 <?php

    $country 
getenv(GEOIP_COUNTRY_NAME);
    
$country_code getenv(GEOIP_COUNTRY_CODE);

echo 
$country_code;
switch (
$country_code) {
        case 
'UK':
        echo 
'<img src="Ukbanner.jpg"></img>';
        break;
        case 
'DE':
        echo 
'<img src="Debanner.jpg"></img>';
        break;
        case 
'US':
        echo 
'<img src="Usbanner.jpg"></img>';
        break;
        default:
         echo 
'<img src="Other.jpg"></img>';
         break;
            
    }

?>

Here is an article where you can check do you have everything installed fine:
http://www.tecmint.com/install-mod_g...centos-6-35-8/

Oracle Porn 12-30-2013 12:43 PM

Quote:

Originally Posted by KlenTelaris (Post 19927557)
Just tested it and works fine,tho i did forgot to add break;
PHP Code:

 <?php

    $country 
getenv(GEOIP_COUNTRY_NAME);
    
$country_code getenv(GEOIP_COUNTRY_CODE);

echo 
$country_code;
switch (
$country_code) {
        case 
'UK':
        echo 
'<img src="Ukbanner.jpg"></img>';
        break;
        case 
'DE':
        echo 
'<img src="Debanner.jpg"></img>';
        break;
        case 
'US':
        echo 
'<img src="Usbanner.jpg"></img>';
        break;
        default:
         echo 
'<img src="Other.jpg"></img>';
         break;
            
    }

?>

Here is an article where you can check do you have everything installed fine:
http://www.tecmint.com/install-mod_g...centos-6-35-8/

this works great, thanks.

Constantine 12-31-2013 05:36 AM

Quote:

Originally Posted by Oracle Porn (Post 19927400)
this works, but how do I show nothing for some countries?

No problem, try this one:

PHP Code:

<?php

    $banner
['default'] = '<img src="default-banner.jpg" alt=""/>';

    
$banner['AU'] = '<img src="au-banner.jpg" alt=""/>';
    
$banner['DE'] = '<img src="de-banner.jpg" alt=""/>';
    
$banner['US'] = '<img src="us-banner.jpg" alt=""/>';


    
$country_code getenv(GEOIP_COUNTRY_CODE);

    echo (isset(
$banner[$country_code]))
        ? 
$banner[$country_code] : $banner['default'];
?>


And if you wanna to show "nothing" for specified country just add:

PHP Code:

$banner['BE'] = ''



All times are GMT -7. The time now is 09:29 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123