Mercurial > hg > ywww
annotate index.php @ 50:99a730ffeaf6
more parameterisation
author | Charlie Root |
---|---|
date | Sun, 27 Jan 2019 14:24:02 -0500 |
parents | a67bf725e87b |
children |
rev | line source |
---|---|
27
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
1 <?php |
49
a67bf725e87b
put both paths in include_path and depend on that
Charlie Root
parents:
45
diff
changeset
|
2 include_once "dlog.php"; |
27
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
3 |
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
4 if (isset($_SERVER["GEOIP_COUNTRY_CODE"])) { |
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
5 $country_code = $_SERVER["GEOIP_COUNTRY_CODE"]; |
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
6 } |
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
7 elseif (isset($_SERVER["REDIRECT_GEOIP_COUNTRY_CODE"])) { |
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
8 $country_code = $_SERVER["REDIRECT_GEOIP_COUNTRY_CODE"]; |
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
9 } |
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
10 else {$country_code = "US" ; } |
43
dbc006408d2b
ASSUMES we have SetEnv PHP_VALUE "include_path =.:/var/test/private:/var/test/ywww:/usr/share/php" in apache2/.../test.conf
Charlie Root
parents:
27
diff
changeset
|
11 |
dbc006408d2b
ASSUMES we have SetEnv PHP_VALUE "include_path =.:/var/test/private:/var/test/ywww:/usr/share/php" in apache2/.../test.conf
Charlie Root
parents:
27
diff
changeset
|
12 dl("cc: $country_code\n"); |
50 | 13 dl("tp: ".getenv("TEST_PREFIX")."\n"); |
14 dl("ip: ".getenv("IP_PREFIX")." ".ini_get('include_path')."\n"); | |
27
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
15 |
45
8bc395c87c6f
less built-in use of full site address
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
44
diff
changeset
|
16 $home=$_SERVER['SERVER_NAME']; |
8bc395c87c6f
less built-in use of full site address
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
44
diff
changeset
|
17 $path=$_SERVER['SCRIPT_NAME']; |
8bc395c87c6f
less built-in use of full site address
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
44
diff
changeset
|
18 $myBase="http://$home".substr($path,0,strlen($path)-10); |
8bc395c87c6f
less built-in use of full site address
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
44
diff
changeset
|
19 dl("base: $myBase\n"); |
8bc395c87c6f
less built-in use of full site address
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
44
diff
changeset
|
20 |
27
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
21 switch($country_code) { |
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
22 case "CA": |
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
23 Header( "HTTP/1.1 301 Moved Permanently" ); |
45
8bc395c87c6f
less built-in use of full site address
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
44
diff
changeset
|
24 Header ("Location: $myBase/ca/" ); |
27
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
25 break; |
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
26 case "DE": |
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
27 Header( "HTTP/1.1 301 Moved Permanently" ); |
45
8bc395c87c6f
less built-in use of full site address
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
44
diff
changeset
|
28 Header ("Location: $myBase/de/" ); |
27
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
29 break; |
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
30 case "FR": |
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
31 Header( "HTTP/1.1 301 Moved Permanently" ); |
45
8bc395c87c6f
less built-in use of full site address
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
44
diff
changeset
|
32 Header ("Location: $myBase/fr/" ); |
27
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
33 break; |
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
34 case "GB": |
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
35 Header( "HTTP/1.1 301 Moved Permanently" ); |
45
8bc395c87c6f
less built-in use of full site address
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
44
diff
changeset
|
36 Header ("Location: $myBase/uk/" ); |
27
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
37 break; |
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
38 case "US": |
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
39 Header( "HTTP/1.1 301 Moved Permanently" ); |
45
8bc395c87c6f
less built-in use of full site address
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
44
diff
changeset
|
40 Header ("Location: $myBase/us/" ); |
27
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
41 break; |
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
42 default: |
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
43 Header( "HTTP/1.1 301 Moved Permanently" ); |
45
8bc395c87c6f
less built-in use of full site address
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
44
diff
changeset
|
44 Header ("Location: $myBase/us/" ); |
27
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
45 break; |
1bb0bc3d306a
update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents:
20
diff
changeset
|
46 } |
0 | 47 ?> |
48 <html> | |
49 <head> | |
50 <title>YourNextRead: Book Recommendations</title> | |
51 | |
52 <META NAME="Description" CONTENT="YourNextRead recommends your next book. YourNextRead provides a book recommendation system showing aggregated book reviews, updated by real peoples opinions, in a simple visual map, helping you to decide 'What Should I Read Next?'. Perfect for both bookworms and casual readers!"> | |
53 <meta name="google-site-verification" content="0XCtbGM_bvOH363P2XE6DVjh-APTICOREquY8F38T84" /> | |
54 </HEAD> | |
55 <body> | |
19 | 56 <script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&adInstanceId=322bafc0-69fa-4664-8e1c-0b9159259748"></script> |
0 | 57 </body> |
58 |