Mercurial > hg > ywww
changeset 20:7679346abfdb
get code and use it
author | Charlie Root |
---|---|
date | Thu, 25 Oct 2018 09:40:25 -0400 |
parents | 84a412b8122c |
children | 46382face560 |
files | geoiptest.php index.php |
diffstat | 2 files changed, 6 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/geoiptest.php Thu Aug 30 17:18:12 2018 -0400 +++ b/geoiptest.php Thu Oct 25 09:40:25 2018 -0400 @@ -2,7 +2,8 @@ <body> <?php $country_name = $_SERVER["GEOIP_COUNTRY_NAME"]; -print "Country: " . $country_name; +$country_code = $_SERVER["GEOIP_COUNTRY_CODE"]; +print "Country: $country_name , code: $country_code"; ?> </body> </html>
--- a/index.php Thu Aug 30 17:18:12 2018 -0400 +++ b/index.php Thu Oct 25 09:40:25 2018 -0400 @@ -1,7 +1,8 @@ <?php - $country_code = $_SERVER["GEOIP_COUNTRY_CODE"]; + try {$country_code = $_SERVER["GEOIP_COUNTRY_CODE"]; + } catch(Exception $e) { $country_code = "US" ; } switch($country_code){ - /* case "CA": + case "CA": Header( "HTTP/1.1 301 Moved Permanently" ); Header ("Location: http://www.yournextread.com/ca/" ); break; @@ -20,7 +21,7 @@ case "US": Header( "HTTP/1.1 301 Moved Permanently" ); Header ("Location: http://www.yournextread.com/us/" ); - break; */ + break; default: Header( "HTTP/1.1 301 Moved Permanently" ); Header ("Location: http://www.yournextread.com/us/" );