Mercurial > hg > ywww
comparison index.php @ 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 | 7679346abfdb |
| children | dbc006408d2b |
comparison
equal
deleted
inserted
replaced
| 26:55a76c257dad | 27:1bb0bc3d306a |
|---|---|
| 1 <?php | 1 <?php |
| 2 try {$country_code = $_SERVER["GEOIP_COUNTRY_CODE"]; | 2 |
| 3 } catch(Exception $e) { $country_code = "US" ; } | 3 if (isset($_SERVER["GEOIP_COUNTRY_CODE"])) { |
| 4 switch($country_code){ | 4 $country_code = $_SERVER["GEOIP_COUNTRY_CODE"]; |
| 5 case "CA": | 5 } |
| 6 Header( "HTTP/1.1 301 Moved Permanently" ); | 6 elseif (isset($_SERVER["REDIRECT_GEOIP_COUNTRY_CODE"])) { |
| 7 Header ("Location: http://www.yournextread.com/ca/" ); | 7 $country_code = $_SERVER["REDIRECT_GEOIP_COUNTRY_CODE"]; |
| 8 break; | 8 } |
| 9 case "DE": | 9 else {$country_code = "US" ; } |
| 10 Header( "HTTP/1.1 301 Moved Permanently" ); | 10 file_put_contents('/var/ywww/debug/phpDebug', |
| 11 Header ("Location: http://www.yournextread.com/de/" ); | 11 "cc: $country_code\n", |
| 12 break; | 12 FILE_APPEND); |
| 13 case "FR": | 13 |
| 14 Header( "HTTP/1.1 301 Moved Permanently" ); | 14 switch($country_code) { |
| 15 Header ("Location: http://www.yournextread.com/fr/" ); | 15 case "CA": |
| 16 break; | 16 Header( "HTTP/1.1 301 Moved Permanently" ); |
| 17 case "GB": | 17 Header ("Location: http://www.yournextread.com/ca/" ); |
| 18 Header( "HTTP/1.1 301 Moved Permanently" ); | 18 break; |
| 19 Header ("Location: http://www.yournextread.com/uk/" ); | 19 case "DE": |
| 20 break; | 20 Header( "HTTP/1.1 301 Moved Permanently" ); |
| 21 case "US": | 21 Header ("Location: http://www.yournextread.com/de/" ); |
| 22 Header( "HTTP/1.1 301 Moved Permanently" ); | 22 break; |
| 23 Header ("Location: http://www.yournextread.com/us/" ); | 23 case "FR": |
| 24 break; | 24 Header( "HTTP/1.1 301 Moved Permanently" ); |
| 25 default: | 25 Header ("Location: http://www.yournextread.com/fr/" ); |
| 26 Header( "HTTP/1.1 301 Moved Permanently" ); | 26 break; |
| 27 Header ("Location: http://www.yournextread.com/us/" ); | 27 case "GB": |
| 28 break; | 28 Header( "HTTP/1.1 301 Moved Permanently" ); |
| 29 } | 29 Header ("Location: http://www.yournextread.com/uk/" ); |
| 30 break; | |
| 31 case "US": | |
| 32 Header( "HTTP/1.1 301 Moved Permanently" ); | |
| 33 Header ("Location: http://www.yournextread.com/us/" ); | |
| 34 break; | |
| 35 default: | |
| 36 Header( "HTTP/1.1 301 Moved Permanently" ); | |
| 37 Header ("Location: http://www.yournextread.com/us/" ); | |
| 38 break; | |
| 39 } | |
| 30 ?> | 40 ?> |
| 31 <html> | 41 <html> |
| 32 <head> | 42 <head> |
| 33 <title>YourNextRead: Book Recommendations</title> | 43 <title>YourNextRead: Book Recommendations</title> |
| 34 | 44 |
