annotate index.php @ 45:8bc395c87c6f

less built-in use of full site address
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Sun, 06 Jan 2019 08:09:47 -0500
parents 38d209611508
children a67bf725e87b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
1 <?php
44
38d209611508 change includes to assume (contra previos ASSUMES) that we have .user.ini which adds /var/test to include_path
Charlie Root
parents: 43
diff changeset
2 include_once "ywww/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");
27
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
13
45
8bc395c87c6f less built-in use of full site address
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 44
diff changeset
14 $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
15 $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
16 $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
17 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
18
27
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
19 switch($country_code) {
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
20 case "CA":
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
21 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
22 Header ("Location: $myBase/ca/" );
27
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
23 break;
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
24 case "DE":
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
25 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
26 Header ("Location: $myBase/de/" );
27
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
27 break;
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
28 case "FR":
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
29 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
30 Header ("Location: $myBase/fr/" );
27
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
31 break;
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
32 case "GB":
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
33 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
34 Header ("Location: $myBase/uk/" );
27
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
35 break;
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
36 case "US":
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
37 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
38 Header ("Location: $myBase/us/" );
27
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
39 break;
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
40 default:
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
41 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
42 Header ("Location: $myBase/us/" );
27
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
43 break;
1bb0bc3d306a update where to look for geoip info
Robert Boland <robert@markup.co.uk>
parents: 20
diff changeset
44 }
0
5f4560ac65b7 original
robert
parents:
diff changeset
45 ?>
5f4560ac65b7 original
robert
parents:
diff changeset
46 <html>
5f4560ac65b7 original
robert
parents:
diff changeset
47 <head>
5f4560ac65b7 original
robert
parents:
diff changeset
48 <title>YourNextRead: Book Recommendations</title>
5f4560ac65b7 original
robert
parents:
diff changeset
49
5f4560ac65b7 original
robert
parents:
diff changeset
50 <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!">
5f4560ac65b7 original
robert
parents:
diff changeset
51 <meta name="google-site-verification" content="0XCtbGM_bvOH363P2XE6DVjh-APTICOREquY8F38T84" />
5f4560ac65b7 original
robert
parents:
diff changeset
52 </HEAD>
5f4560ac65b7 original
robert
parents:
diff changeset
53 <body>
19
84a412b8122c try to protect against a range of missing info
Charlie Root
parents: 16
diff changeset
54 <script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&adInstanceId=322bafc0-69fa-4664-8e1c-0b9159259748"></script>
0
5f4560ac65b7 original
robert
parents:
diff changeset
55 </body>
5f4560ac65b7 original
robert
parents:
diff changeset
56