Permalink
Browse files

Merge pull request #4 from ivebeenlinuxed/master

Make project deploying easier.
  • Loading branch information...
2 parents c66cb34 + f368ce5 commit c01a7cec9cd5064b4084dd2fc06cdb7e1640f33e @pezholio committed Nov 4, 2012
Showing with 42 additions and 40 deletions.
  1. +4 −3 .htaccess
  2. +4 −4 404.php
  3. +2 −2 alternative.php
  4. +6 −6 api.php
  5. +2 −2 apps.php
  6. +1 −1 csv.php
  7. +1 −1 detect.php
  8. +5 −5 index.php
  9. +1 −1 json.php
  10. +1 −1 kml.php
  11. +1 −1 php.php
  12. +5 −4 postcode.php
  13. +2 −2 postcode2.php
  14. +2 −2 rdf.php
  15. +4 −4 result.php
  16. +1 −1 xml.php
View
@@ -1,9 +1,10 @@
+Options -MultiViews
RewriteEngine on
RewriteBase /
-RewriteCond %{HTTP_HOST} !^www.uk-postcodes.com$
-RewriteRule ^(.*)$ http://www.uk-postcodes.com/$1 [R=301]
+#RewriteCond %{HTTP_HOST} !^www.uk-postcodes.com$
+#RewriteRule ^(.*)$ http://www.uk-postcodes.com/$1 [R=301]
RewriteRule ^postcode/(all)\.?(xml|json|rdf|csv)?$ all.php?format=$2 [NC]
RewriteCond %{QUERY_STRING} callback=(.*)
RewriteRule ^postcode/([a-z0-9\ ]+)\.?(xml|json|rdf|csv)?$ postcode.php?postcode=$1&format=$2&callback=%1 [NC]
RewriteRule ^postcode/([a-z0-9\ ]+)\.?(xml|json|rdf|csv)?$ postcode.php?postcode=$1&format=$2 [NC]
-RewriteRule ^latlng/([0-9.]+),([-0-9.]+)(\.xml|\.json|\.rdf|\.csv)?$ postcode.php?lat=$1&lng=$2&format=$3 [NC,QSA]
+RewriteRule ^latlng/([0-9.]+),([-0-9.]+)(\.xml|\.json|\.rdf|\.csv)?$ postcode.php?lat=$1&lng=$2&format=$3 [NC,QSA]
View
@@ -6,18 +6,18 @@
<link type="text/css" rel="stylesheet" href="http://www.blueprintcss.org/blueprint/src/grid.css" />
<link type="text/css" rel="stylesheet" href="http://www.blueprintcss.org/blueprint/src/typography.css" />
<link type="text/css" rel="stylesheet" href="http://www.blueprintcss.org/blueprint/src/forms.css" />
-<link type="text/css" rel="stylesheet" href="http://www.uk-postcodes.com/style.css" />
+<link type="text/css" rel="stylesheet" href="/style.css" />
</head>
<body>
<div id="header">
-<h1><a href="http://www.uk-postcodes.com">UK Postcodes</a></h1>
+<h1><a href="/">UK Postcodes</a></h1>
</div>
<div id="main">
<h2>Resource not found</h2>
<div id="wrapper">
-<p>http://www.uk-postcodes.com/postcode/<?php echo $postcode; ?> was not found on this server.</p>
-<p>Why not try <a href="http://www.uk-postcodes.com">searching again</a>?</p>
+<p>http://<?php echo $_SERVER['SERVER_NAME'] ?>/postcode/<?php echo $postcode; ?> was not found on this server.</p>
+<p>Why not try <a href="/">searching again</a>?</p>
</div>
</div>
View
@@ -11,7 +11,7 @@
</head>
<body>
<div id="header">
-<h1><a href="http://www.uk-postcodes.com">UK Postcodes</a></h1>
+<h1><a href="/">UK Postcodes</a></h1>
</div>
<div id="main">
@@ -28,7 +28,7 @@
</div>
<div id="formats">
-<p>Created using <a href="http://www.ordnancesurvey.co.uk/oswebsite/opendata/">Ordnance Survey Open Data</a> | <a href="api.php">API</a> | <a href="http://www.uk-postcodes.com/alternative.php">Alternative services</a> | <a href="apps.php">Apps</a><img src="http://m.okfn.org/images/ok_buttons/od_80x15_blue.png" alt="Open Data" style="float:right;" /></p>
+<p>Created using <a href="http://www.ordnancesurvey.co.uk/oswebsite/opendata/">Ordnance Survey Open Data</a> | <a href="api.php">API</a> | <a href="/alternative.php">Alternative services</a> | <a href="apps.php">Apps</a><img src="http://m.okfn.org/images/ok_buttons/od_80x15_blue.png" alt="Open Data" style="float:right;" /></p>
<p>Built by <a href="http://www.pezholio.co.uk">Pezholio</a></p>
</div>
<script type="text/javascript">
View
12 api.php
@@ -11,20 +11,20 @@
</head>
<body>
<div id="header">
-<h1><a href="http://www.uk-postcodes.com">UK Postcodes</a></h1>
+<h1><a href="/">UK Postcodes</a></h1>
</div>
<div id="main">
<h2>API</h2>
<div id="wrapper">
<p>Get the data you want simply by constructing your URLs as follows:</p>
<h3>Return data for a postcode</h3>
-<code>http://www.uk-postcodes.com/postcode/<strong>[postcode (no space)]</strong>.<strong>['xml', 'csv', 'json'* or 'rdf']</strong></code>
+<code>http://<?php echo $_SERVER['SERVER_NAME'] ?>/postcode/<strong>[postcode (no space)]</strong>.<strong>['xml', 'csv', 'json'* or 'rdf']</strong></code>
<h3>Return data for the nearest postcode to a point</h3>
-<code>http://www.uk-postcodes.com/latlng/<strong>[latitude]</strong>,<strong>[longitude]</strong>.<strong>['xml', 'csv', 'json'* or 'rdf']</strong></code>
+<code>http://<?php echo $_SERVER['SERVER_NAME'] ?>/latlng/<strong>[latitude]</strong>,<strong>[longitude]</strong>.<strong>['xml', 'csv', 'json'* or 'rdf']</strong></code>
<h3>Return data for postcodes within x distance (miles) of a postcode or lat/lng</h3>
-<code>http://www.uk-postcodes.com/distance.php?<strong>postcode=[postcode]</strong>&<strong>distance=[distance in miles]</strong>&<strong>format=[xml|csv|json]</strong></code>
-<code>http://www.uk-postcodes.com/distance.php?<strong>lat=[latitude]</strong>&<strong>lng=[longitude]</strong>&<strong>distance=[distance in miles]</strong>&<strong>format=[xml|csv|json]</strong></code>
+<code>http://<?php echo $_SERVER['SERVER_NAME'] ?>/distance.php?<strong>postcode=[postcode]</strong>&<strong>distance=[distance in miles]</strong>&<strong>format=[xml|csv|json]</strong></code>
+<code>http://<?php echo $_SERVER['SERVER_NAME'] ?>/distance.php?<strong>lat=[latitude]</strong>&<strong>lng=[longitude]</strong>&<strong>distance=[distance in miles]</strong>&<strong>format=[xml|csv|json]</strong></code>
<p>That's it! Be nice to the server and cache your requests!</p>
<p><small>* If using JSON, add '?callback=<strong>[some function call]</strong>' to the url to return JSONP</small></p>
<h2 id="libraries">Helper Libraries</h2>
@@ -37,7 +37,7 @@
</div>
<div id="formats">
-<p>Created using <a href="http://www.ordnancesurvey.co.uk/oswebsite/opendata/">Ordnance Survey Open Data</a> | <a href="api.php">API</a> | <a href="http://www.uk-postcodes.com/alternative.php">Alternative services</a> | <a href="apps.php">Apps</a><img src="http://m.okfn.org/images/ok_buttons/od_80x15_blue.png" alt="Open Data" style="float:right;" /></p>
+<p>Created using <a href="http://www.ordnancesurvey.co.uk/oswebsite/opendata/">Ordnance Survey Open Data</a> | <a href="api.php">API</a> | <a href="/alternative.php">Alternative services</a> | <a href="apps.php">Apps</a><img src="http://m.okfn.org/images/ok_buttons/od_80x15_blue.png" alt="Open Data" style="float:right;" /></p>
<p>Built by <a href="http://www.pezholio.co.uk">Pezholio</a></p>
</div>
<script type="text/javascript">
View
@@ -11,7 +11,7 @@
</head>
<body>
<div id="header">
-<h1><a href="http://www.uk-postcodes.com">UK Postcodes</a></h1>
+<h1><a href="/">UK Postcodes</a></h1>
</div>
<div id="main">
@@ -28,7 +28,7 @@
</div>
<div id="formats">
-<p>Created using <a href="http://www.ordnancesurvey.co.uk/oswebsite/opendata/">Ordnance Survey Open Data</a> | <a href="api.php">API</a> | <a href="http://www.uk-postcodes.com/alternative.php">Alternative services</a> | <a href="apps.php">Apps</a><img src="http://m.okfn.org/images/ok_buttons/od_80x15_blue.png" alt="Open Data" style="float:right;" /></p>
+<p>Created using <a href="http://www.ordnancesurvey.co.uk/oswebsite/opendata/">Ordnance Survey Open Data</a> | <a href="api.php">API</a> | <a href="/alternative.php">Alternative services</a> | <a href="apps.php">Apps</a><img src="http://m.okfn.org/images/ok_buttons/od_80x15_blue.png" alt="Open Data" style="float:right;" /></p>
<p>Built by <a href="http://www.pezholio.co.uk">Pezholio</a></p>
</div>
<script type="text/javascript">
View
@@ -5,7 +5,7 @@
} elseif ($distance) {
header("Content-Disposition: attachment; filename=\"".$distance." miles of ". $title .".csv\"");
while ($row = mysql_fetch_array($result)) {
-echo $row['postcode'] .",". $row['lat'] .",". $row['lng']. ",http://www.uk-postcodes.com/postcode/". str_replace(" ", "", $row['postcode']) ."\r\n";
+echo $row['postcode'] .",". $row['lat'] .",". $row['lng']. ",http://".$_SERVER['SERVER_NAME']."/postcode/". str_replace(" ", "", $row['postcode']) ."\r\n";
}
}
?>
View
@@ -15,7 +15,7 @@ function showMap(position) {
longitude = position.coords.longitude;
accuracy = position.coords.accuracy;
if (accuracy < 250) {
- window.location="http://www.uk-postcodes.com/latlng/"+ latitude +","+ longitude;
+ window.location="http://<?php echo $_SERVER['SERVER_NAME'] ?>/latlng/"+ latitude +","+ longitude;
}
}
View
@@ -1,10 +1,10 @@
<?php
if ($_POST['form'] == 1) {
-header("Location: http://www.uk-postcodes.com/postcode/".str_replace(" ", "", $_POST['postcode']). $_POST['type']);
+header("Location: /postcode/".str_replace(" ", "", $_POST['postcode']). $_POST['type']);
} elseif ($_POST['form'] == 2) {
-header("Location: http://www.uk-postcodes.com/distance.php?postcode=".str_replace(" ", "", $_POST['postcode'])."&distance=". $_POST['distance'] ."&format=". $_POST['type']);
+header("Location: /distance.php?postcode=".str_replace(" ", "", $_POST['postcode'])."&distance=". $_POST['distance'] ."&format=". $_POST['type']);
} elseif ($_POST['form'] == 3) {
-header("Location: http://www.uk-postcodes.com/latlng/".$_POST['lat'].",".$_POST['lng']. $_POST['type']);
+header("Location: /latlng/".$_POST['lat'].",".$_POST['lng']. $_POST['type']);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -39,7 +39,7 @@
</head>
<body>
<div id="header">
-<h1><a href="http://www.uk-postcodes.com">UK Postcodes</a></h1>
+<h1><a href="/">UK Postcodes</a></h1>
<div id="corner">Now including Northern Ireland postcodes!</div>
<ul id="tab">
@@ -99,7 +99,7 @@
</div>
<div id="formats">
-<p>Created using <a href="http://www.ordnancesurvey.co.uk/oswebsite/opendata/">Ordnance Survey Open Data</a> | <a href="api.php">API</a> | <a href="http://www.uk-postcodes.com/alternative.php">Alternative services</a> | <a href="apps.php">Apps</a><img src="http://m.okfn.org/images/ok_buttons/od_80x15_blue.png" alt="Open Data" style="float:right;" /></p>
+<p>Created using <a href="http://www.ordnancesurvey.co.uk/oswebsite/opendata/">Ordnance Survey Open Data</a> | <a href="api.php">API</a> | <a href="/alternative.php">Alternative services</a> | <a href="apps.php">Apps</a><img src="http://m.okfn.org/images/ok_buttons/od_80x15_blue.png" alt="Open Data" style="float:right;" /></p>
<p>Built by <a href="http://www.pezholio.co.uk">Pezholio</a></p>
</div>
<div id="copyright">
View
@@ -45,7 +45,7 @@
$json[$num]['lat'] = $row['lat'];
$json[$num]['lng'] = $row['lng'];
$json[$num]['distance'] = $row['distance'];
-$json[$num]['uri'] = "http://www.uk-postcodes.com/postcode/". str_replace(" ", "", $row['postcode']);
+$json[$num]['uri'] = "http://".$_SERVER['SERVER_NAME']."/postcode/". str_replace(" ", "", $row['postcode']);
$num++;
}
if ($callback) {
View
@@ -12,7 +12,7 @@
<name><?php echo $row['postcode']; ?></name>
<description>
<![CDATA[
-<a href="http://www.uk-postcodes.com/postcode/<?php echo str_replace(" ", "", $row['postcode']); ?>"><?php echo $row['postcode']; ?></a>
+<a href="http://<?php echo $_SERVER['SERVER_NAME'] ?>/postcode/<?php echo str_replace(" ", "", $row['postcode']); ?>"><?php echo $row['postcode']; ?></a>
]]>
</description>
<Point>
View
@@ -3,7 +3,7 @@ function ernest_marples($postcode) {
$postcode = str_replace(" ", "", $postcode);
-$url = "http://www.uk-postcodes.com/postcode/". urlencode($postcode) .".csv"; // Build the URL
+$url = "http://".$_SERVER['SERVER_NAME']."/postcode/". urlencode($postcode) .".csv"; // Build the URL
$file = file_get_contents($url);
View
@@ -16,9 +16,9 @@
header ('HTTP/1.1 301 Moved Permanently');
if (strlen($_GET['format']) > 0) {
- header("Location: http://www.uk-postcodes.com/postcode/".strtoupper($postcode).".".$_GET['format']);
+ header("Location: /postcode/".strtoupper($postcode).".".$_GET['format']);
} else {
- header("Location: http://www.uk-postcodes.com/postcode/".strtoupper($postcode));
+ header("Location: /postcode/".strtoupper($postcode));
}
exit;
}
@@ -27,9 +27,9 @@
header ('HTTP/1.1 301 Moved Permanently');
if (strlen($_GET['format']) > 0) {
- header("Location: http://www.uk-postcodes.com/postcode/".str_replace(" ", "", $postcode).".".$_GET['format']);
+ header("Location: /postcode/".str_replace(" ", "", $postcode).".".$_GET['format']);
} else {
- header("Location: http://www.uk-postcodes.com/postcode/".str_replace(" ", "", $postcode));
+ header("Location: /postcode/".str_replace(" ", "", $postcode));
}
exit;
}
@@ -45,6 +45,7 @@
} else {
$lat = mysql_real_escape_string($_GET['lat']);
$lng = mysql_real_escape_string($_GET['lng']);
+ //$result = mysql_query("SELECT postcode, ( 3959 * acos( cos( radians($lat) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( lat ) ) ) ) AS distance FROM postcodes WHERE ".($lat-0.1)." < lat AND ".($lat+0.1)." > lat AND ".($lng-0.1)." < lng AND ".($lng+0.1)." > lng ORDER BY distance LIMIT 0,1");
$result = mysql_query("SELECT postcode, ( 3959 * acos( cos( radians($lat) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( lat ) ) ) ) AS distance FROM postcodes ORDER BY distance LIMIT 0,1");
$row = mysql_fetch_array($result);
View
@@ -18,9 +18,9 @@
header ('HTTP/1.1 301 Moved Permanently');
if (strlen($_GET['format']) > 0) {
- header("Location: http://www.uk-postcodes.com/postcode/".strtoupper($postcode).".".$_GET['format']);
+ header("Location: /postcode/".strtoupper($postcode).".".$_GET['format']);
} else {
- header("Location: http://www.uk-postcodes.com/postcode/".strtoupper($postcode));
+ header("Location: /postcode/".strtoupper($postcode));
}
}
View
@@ -3,7 +3,7 @@
$row['postcode'] = str_replace(" ", "", $row['postcode']);
?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:spatialrelations="http://data.ordnancesurvey.co.uk/ontology/spatialrelations/" xmlns:admingeo="http://statistics.data.gov.uk/def/administrative-geography/" xmlns:elecgeo="http://statistics.data.gov.uk/def/electoral-geography/" xmlns:osadmingeo="http://data.ordnancesurvey.co.uk/ontology/admingeo/" xmlns:owl="http://www.w3.org/2002/07/owl#" >
- <rdf:Description rdf:about="http://www.uk-postcodes.com/postcode/<?php echo strtoupper($row['postcode']); ?>">
+ <rdf:Description rdf:about="http://<?php echo $_SERVER['SERVER_NAME'] ?>/postcode/<?php echo strtoupper($row['postcode']); ?>">
<rdfs:label><?php echo strtoupper($row['postcode']); ?></rdfs:label>
<owl:sameAs rdf:resource="http://data.ordnancesurvey.co.uk/id/postcodeunit/<?php echo strtoupper($row['postcode']); ?>"/>
<geo:lat rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal"><?php echo $lat; ?></geo:lat>
@@ -45,7 +45,7 @@
while ($row = mysql_fetch_array($result)) {
$row['postcode'] = str_replace(" ", "", $row['postcode']);
?>
- <rdf:Description rdf:about="http://www.uk-postcodes.com/postcode/<?php echo strtoupper($row['postcode']); ?>">
+ <rdf:Description rdf:about="http://<?php echo $_SERVER['SERVER_NAME'] ?>/postcode/<?php echo strtoupper($row['postcode']); ?>">
<rdfs:label><?php echo strtoupper($row['postcode']); ?></rdfs:label>
<geo:lat rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal"><?php echo $lat; ?></geo:lat>
<geo:long rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal"><?php echo $lng; ?></geo:long>
View
@@ -17,7 +17,7 @@
</head>
<body onload="init();">
<div id="header">
-<h1><a href="http://www.uk-postcodes.com">UK Postcodes</a></h1>
+<h1><a href="/">UK Postcodes</a></h1>
</div>
<div id="main" class="vcard">
<div class="adr">
@@ -71,7 +71,7 @@
</div>
</div>
<div id="formats">
-<p>Get this information as <a href="http://www.uk-postcodes.com<?php echo $_SERVER['REQUEST_URI']; ?>.xml">XML</a>, <a href="http://www.uk-postcodes.com<?php echo $_SERVER['REQUEST_URI']; ?>.csv">CSV</a>, <a href="http://www.uk-postcodes.com<?php echo $_SERVER['REQUEST_URI']; ?>.json">JSON</a> or <a href="http://www.uk-postcodes.com<?php echo $_SERVER['REQUEST_URI']; ?>.rdf">RDF</a> <img src="http://www.uk-postcodes.com/microformats.png" alt="Microformats" style="float:right; margin-left: 10px;" /> <img src="http://m.okfn.org/images/ok_buttons/od_80x15_blue.png" alt="Open Data" style="float:right;" /></p>
+<p>Get this information as <a href="<?php echo $_SERVER['REQUEST_URI']; ?>.xml">XML</a>, <a href="<?php echo $_SERVER['REQUEST_URI']; ?>.csv">CSV</a>, <a href="<?php echo $_SERVER['REQUEST_URI']; ?>.json">JSON</a> or <a href="<?php echo $_SERVER['REQUEST_URI']; ?>.rdf">RDF</a> <img src="/microformats.png" alt="Microformats" style="float:right; margin-left: 10px;" /> <img src="http://m.okfn.org/images/ok_buttons/od_80x15_blue.png" alt="Open Data" style="float:right;" /></p>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
@@ -97,7 +97,7 @@
</head>
<body>
<div id="header">
-<h1><a href="http://www.uk-postcodes.com">UK Postcodes</a></h1>
+<h1><a href="/">UK Postcodes</a></h1>
</div>
<div id="main">
<h2>Postcodes within <?php echo $distance; ?> miles of <?php echo $title; ?></h2>
@@ -106,7 +106,7 @@
<?php
while ($row = mysql_fetch_array($result)) {
?>
-<li><a href="http://www.uk-postcodes.com/postcode/<?php echo str_replace(" ", "", $row['postcode']); ?>"><?php echo $row['postcode']; ?></a></li>
+<li><a href="/postcode/<?php echo str_replace(" ", "", $row['postcode']); ?>"><?php echo $row['postcode']; ?></a></li>
<?php
}
?>
View
@@ -61,7 +61,7 @@
<lat><?php echo $row['lat']; ?></lat>
<lng><?php echo $row['lng']; ?></lng>
<distance><?php echo $row['distance']; ?></distance>
- <uri>http://www.uk-postcodes.com/postcode/<?php echo str_replace(" ", "", $row['postcode']); ?></uri>
+ <uri>http://<?php echo $_SERVER['SERVER_NAME'] ?>/postcode/<?php echo str_replace(" ", "", $row['postcode']); ?></uri>
</postcode>
<?php } ?>
</postcodes>

0 comments on commit c01a7ce

Please sign in to comment.