changeset 27:1bb0bc3d306a

update where to look for geoip info
author Robert Boland <robert@markup.co.uk>
date Fri, 04 Jan 2019 08:45:42 -0500
parents 55a76c257dad
children b058736bc9ad
files geoiptest.php index.php
diffstat 2 files changed, 49 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/geoiptest.php	Fri Jan 04 08:44:07 2019 -0500
+++ b/geoiptest.php	Fri Jan 04 08:45:42 2019 -0500
@@ -1,8 +1,18 @@
 <html>
 <body>
 <?php
+if (isset($_SERVER["GEOIP_COUNTRY_NAME"])) {
 $country_name = $_SERVER["GEOIP_COUNTRY_NAME"];
+ }
+ else {
+$country_name = $_SERVER["REDIRECT_GEOIP_COUNTRY_NAME"];
+ }
+if (isset($_SERVER["GEOIP_COUNTRY_CODE"])) {
 $country_code = $_SERVER["GEOIP_COUNTRY_CODE"];
+ }
+ else {
+$country_code = $_SERVER["REDIRECT_GEOIP_COUNTRY_CODE"];
+ }
 print "Country: $country_name , code: $country_code";
 ?>
 </body>
--- a/index.php	Fri Jan 04 08:44:07 2019 -0500
+++ b/index.php	Fri Jan 04 08:45:42 2019 -0500
@@ -1,32 +1,42 @@
-<?php 
-	  try {$country_code = $_SERVER["GEOIP_COUNTRY_CODE"];
-	    } catch(Exception $e) { $country_code = "US" ; }
-		switch($country_code){
-		case "CA":
-			Header( "HTTP/1.1 301 Moved Permanently" );
-			Header ("Location: http://www.yournextread.com/ca/" );
-			break;
-		case "DE":
-			Header( "HTTP/1.1 301 Moved Permanently" );
-			Header ("Location: http://www.yournextread.com/de/" );
-			break;
-		case "FR":
-			Header( "HTTP/1.1 301 Moved Permanently" );
-			Header ("Location: http://www.yournextread.com/fr/" );
-			break;			
-		case "GB":
-			Header( "HTTP/1.1 301 Moved Permanently" );
-			Header ("Location: http://www.yournextread.com/uk/" );
-			break;
-		case "US":
-			Header( "HTTP/1.1 301 Moved Permanently" );
-			Header ("Location: http://www.yournextread.com/us/" );
-			break;
-		default:
-			Header( "HTTP/1.1 301 Moved Permanently" );
-			Header ("Location: http://www.yournextread.com/us/" );
-			break;	
-		}	  
+<?php
+
+if (isset($_SERVER["GEOIP_COUNTRY_CODE"])) {
+$country_code = $_SERVER["GEOIP_COUNTRY_CODE"];
+ }
+elseif (isset($_SERVER["REDIRECT_GEOIP_COUNTRY_CODE"])) {
+$country_code = $_SERVER["REDIRECT_GEOIP_COUNTRY_CODE"];
+ }
+ else {$country_code = "US" ; }
+file_put_contents('/var/ywww/debug/phpDebug',
+		  "cc: $country_code\n",
+		  FILE_APPEND);
+   
+switch($country_code) {
+ case "CA":
+   Header( "HTTP/1.1 301 Moved Permanently" );
+   Header ("Location: http://www.yournextread.com/ca/" );
+   break;
+ case "DE":
+   Header( "HTTP/1.1 301 Moved Permanently" );
+   Header ("Location: http://www.yournextread.com/de/" );
+   break;
+ case "FR":
+   Header( "HTTP/1.1 301 Moved Permanently" );
+   Header ("Location: http://www.yournextread.com/fr/" );
+   break;			
+ case "GB":
+   Header( "HTTP/1.1 301 Moved Permanently" );
+   Header ("Location: http://www.yournextread.com/uk/" );
+   break;
+ case "US":
+   Header( "HTTP/1.1 301 Moved Permanently" );
+   Header ("Location: http://www.yournextread.com/us/" );
+   break;
+ default:
+   Header( "HTTP/1.1 301 Moved Permanently" );
+   Header ("Location: http://www.yournextread.com/us/" );
+   break;	
+ }	  
 	?>
 <html>
 		  <head>