Пример #1
0
function api_getDivisions_postcode($pc)
{
    $pc = preg_replace('#[^0-9]#i', '', $pc);
    $output = array();
    if (is_postcode($pc)) {
        $constituency = postcode_to_constituency($pc);
        if ($constituency == 'CONNECTION_TIMED_OUT') {
            api_error('Connection timed out');
        } elseif ($constituency) {
            if (is_array($constituency)) {
                $constituencies = $constituency;
            } else {
                $constituencies = array($constituency);
            }
            foreach ($constituencies as $c) {
                $output[] = array('name' => html_entity_decode($c));
            }
        } else {
            api_error('Unknown postcode');
        }
    } else {
        api_error('Invalid postcode');
    }
    api_output($output);
}
Пример #2
0
function api_getRepresentatives_postcode($pc)
{
    $pc = preg_replace('#[^0-9]#i', '', $pc);
    if (is_postcode($pc)) {
        $constituency = postcode_to_constituency($pc);
        if ($constituency == 'CONNECTION_TIMED_OUT') {
            api_error('Connection timed out');
        } elseif ($constituency) {
            if (is_array($constituency)) {
                $constituencies = $constituency;
            } else {
                $constituencies = array($constituency);
            }
            $output = array();
            foreach ($constituencies as $c) {
                $output[] = _api_getMP_constituency($c);
            }
            api_output($output);
        } else {
            api_error('Unknown postcode');
        }
    } else {
        api_error('Invalid postcode');
    }
}
Пример #3
0
 function validate()
 {
     if ($this->email == "" || !valid_email($this->email)) {
         $this->email_warn = true;
         $this->warnings .= " Please enter a valid email address.";
     }
     if ($this->postcode == "" || !is_postcode($this->postcode)) {
         $this->postcode_warn = true;
         $this->warnings .= " Please enter a valid postcode.";
     }
     if ($this->alert_area_size != "s" && $this->alert_area_size != "m" && $this->alert_area_size != "l") {
         $this->warnings .= " Please select an area for the alerts.";
     }
     return $this->warnings == "";
 }
function api_getconstituency_postcode($pc)
{
    $pc = preg_replace('#[^a-z0-9 ]#i', '', $pc);
    if (is_postcode($pc)) {
        $constituency = postcode_to_constituency($pc);
        if ($constituency == 'CONNECTION_TIMED_OUT') {
            api_error('Connection timed out');
        } elseif ($constituency) {
            $output['name'] = html_entity_decode($constituency);
            api_output($output);
        } else {
            api_error('Unknown postcode');
        }
    } else {
        api_error('Invalid postcode');
    }
}
Пример #5
0
function api_getMP_postcode($pc)
{
    $pc = preg_replace('#[^0-9]#i', '', $pc);
    if (is_postcode($pc)) {
        $constituency = postcode_to_constituency($pc);
        if ($constituency == 'CONNECTION_TIMED_OUT') {
            api_error('Connection timed out');
        } elseif ($constituency) {
            $person = _api_getMP_constituency($constituency);
            $output = $person;
            api_output($output, strtotime($output['lastupdate']));
        } else {
            api_error('Unknown postcode');
        }
    } else {
        api_error('Invalid postcode');
    }
}
Пример #6
0
 function load()
 {
     $search = factory::create('search');
     $postcode = get_http_var('p');
     $constituency_url_id = get_http_var('c');
     $constituency = null;
     $election_id = get_election_id();
     //is postcode set?
     if (isset($postcode) && $postcode != '' && is_postcode($postcode)) {
         $this->has_search = true;
         //lookup constituency and redirect
         $constituency_lookup = $this->lookup_constituency($postcode);
         if ($constituency_lookup) {
             $constituencies = array();
             foreach ($constituency_lookup as $name) {
                 $result = $search->search("constituency", array(array("name", "=", $name), array("constituency_election.election_id", "=", $election_id)), "AND", array(array("constituency_election", "inner")), array(array("name", "ASC")));
                 if (count($result) == 1) {
                     $constituencies[] = $result[0];
                 }
             }
             // Loop through the names and assign
             if (count($constituencies) == 1) {
                 $constituency = $constituencies[0];
             } else {
                 if (count($constituencies) > 1) {
                     $this->constituencies = $constituencies;
                     $this->postcode = $postcode;
                 }
             }
         }
     } else {
         if (isset($constituency_url_id) && $constituency_url_id != '') {
             $this->has_search = true;
             $result = $search->search("constituency", array(array("url_id", "=", $constituency_url_id), array("constituency_election.election_id", "=", $election_id)), "AND", array(array("constituency_election", "inner")), null);
             if (count($result) == 1) {
                 $constituency = $result[0];
             }
         }
     }
     //redirect
     if (isset($constituency)) {
         redirect(WWW_SERVER . "/" . AREA_NAMES . "/" . $result[0]->url_id);
     }
 }
 function validate()
 {
     if (!isset($this->data['txtTitle']) || $this->data['txtTitle'] == '') {
         $this->add_warning('Please add a title for this leaflet');
         $this->add_warn_control('txtTitle');
     }
     if (!isset($this->data['ddlPartyBy']) || $this->data['ddlPartyBy'] == '') {
         $this->add_warning('Please specify the party responsible for this leaflet');
         $this->add_warn_control('ddlPartyBy');
     }
     if (!isset($this->data['txtName']) || $this->data['txtName'] == '') {
         $this->add_warning('Please add your name');
         $this->add_warn_control('txtName');
     }
     if (!isset($this->data['txtEmail']) || $this->data['txtEmail'] == '' || !valid_email($this->data['txtEmail'])) {
         $this->add_warning('Please add a valid email address');
         $this->add_warn_control('txtEmail');
     }
     //TODO: handle non-UK postcodes
     if (!isset($this->data['txtPostcode']) || $this->data['txtPostcode'] == '') {
         $this->add_warning('Please add a post code for this leaflet');
         $this->add_warn_control('txtPostcode');
     } else {
         if (!is_postcode($this->data['txtPostcode'])) {
             $this->add_warning('Please enter a valid postcode');
             $this->add_warn_control('txtPostcode');
         } else {
             $geocoder = factory::create('geocoder');
             $success = $geocoder->set_from_postcode($this->data['txtPostcode']);
             if (!$success) {
                 $this->add_warning('Sorry, we couldn\'t locate that postcode');
                 $this->add_warn_control('txtPostcode');
             } else {
                 $this->lng = $geocoder->lng;
                 $this->lat = $geocoder->lat;
             }
         }
     }
     return count($this->warnings) == 0;
 }
 public function guess_search_type($query)
 {
     $return_type = "text";
     $return_value = null;
     $return_display = null;
     if (is_postcode($query)) {
         $return_type = "postcode";
         $return_display = clean_postcode($query);
     } else {
         if (is_partial_postcode($query)) {
             $return_type = "partial postcode";
             $return_display = strtoupper($query);
         } else {
             //party name
             $search = factory::create("search");
             $result = $search->search("party", array(array("name", "=", $query), array("country_id", "=", $this->country_id)));
             if (count($result) == 1) {
                 $return_type = "party";
                 $return_value = $result[0]->party_id;
                 $return_display = $result[0]->name;
             } else {
                 //TODO: match a place name
             }
         }
     }
     return array("type" => $return_type, "value" => $return_value, "display" => $return_display);
 }
Пример #9
0
			<?php 
// Check if the form is submitted
if (isset($_POST['submit'])) {
    // Initiate the warning
    $warning = "";
    // Check if all the desired fields are filled in
    if (empty(trim($_POST['firstname'])) || empty(trim($_POST['lastname'])) || empty(trim($_POST['birthday'])) || empty(trim($_POST['street'])) || empty(trim($_POST['number'])) || empty(trim($_POST['zipcode'])) || empty(trim($_POST['residence']))) {
        $warning .= "Alle verplichte velden moeten ingevuld zijn!<br>";
    }
    // Check if the number of the address is really a number
    if (!is_numeric($_POST['number'])) {
        $warning .= "Het huisnummer moet enkel een getal zijn!<br>";
    }
    // Check if a valid postal code was entered
    if (!is_postcode($_POST['zipcode'])) {
        $warning .= "Er is geen geldige postcode ingevoerd!<br>";
    }
    if (empty($warning)) {
        // Initiate all the variables
        $firstname = mysql_real_escape_string(trim($_POST['firstname']));
        $middlename = mysql_real_escape_string(trim($_POST['middlename']));
        $lastname = mysql_real_escape_string(trim($_POST['lastname']));
        $birthday = mysql_real_escape_string(trim($_POST['birthday']));
        if ($_POST['gender'] == 'male') {
            $gender = 0;
        } else {
            $gender = 1;
        }
        $street = mysql_real_escape_string(trim($_POST['street']));
        $number = mysql_real_escape_string(trim($_POST['number']));
Пример #10
0
 public static function get_location_type($search_term)
 {
     $search_type = "placename";
     //check if is postcode
     if (is_postcode($search_term)) {
         $search_type = "postcode";
     }
     //check if partial postcode
     if (is_partial_postcode($search_term)) {
         $search_type = "partialpostcode";
     }
     //check if is zipcode
     if (is_zipcode($search_term)) {
         $search_type = "zipcode";
     }
     //check if long lat
     if (is_longlat($search_term)) {
         $search_type = "longlat";
     }
     return $search_type;
 }
Пример #11
0
print "<head>\n";
print "<title>The Public Whip - Forty-Two Days</title>\n";
print "<link href=\"publicwhip.css\" type=\"text/css\" rel=\"stylesheet\"/>\n";
print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n";
print "<style type=\"text/css\">\n";
print "\nbody { width:800px; margin-left:auto; margin-right:auto; text-align:center; }\nh1#th1 { background:#003300; padding:0; margin:0 }\nh4#th4a { color: #399611; margin-top: 10px; font-size: 35px; margin-bottom: 5px; text-align: center }\nh4#th4b { color: #304030; margin-top: 7px; width: 650px; font-size: 20px; margin-bottom: 5px; font-style: italic; }\nh2 { color: #102010; margin-top: 4em; border-left: 10px #5050ff solid; padding-left: 10px; border-top: thin blue solid}\ninput { color: #303070 }\ndiv#content { text-align: left; width: 800px; }\ndiv#Zopform {  border: thin black solid; padding: 20px }\ndiv.quessec { text-align: left; border: thin black solid; width: 600px; margin-left: auto; margin-right: auto; padding: 10px; margin-top:10px; background-color: #beffbe;}\ndiv.oprad { margin-top:10px; padding:5px; font-size:120%; margin-left: 20px; }\ndiv#checkmpbutton { font-size: 200%; text-align:center; margin:20px;}\ndiv#footer { background-color:black; color:white;  border: thin black solid;  margin-top: 2em; }\ntable.votetab td { border: thin black solid; background-color: #e0e0e0; }\ntable.votetab { margin-left:auto; margin-right:auto }\ndiv#yourfav p { text-align: left; padding-left: 10px; background-color:#beffbe; width:80%; margin-left:auto; margin-right:auto; padding:10px; }\ndiv#foiparl { text-align: left; background-color:#fed9d8; width:80%; margin-left:auto; margin-right:auto; padding:5px; margin-bottom: 20px; border: thick red dotted; }\ntr.agree td { background-color:#90ff90; }\ntr.disagree td { background-color:#ff9090; }\n.agpe { background-color:#b0ffb0; }\ndiv.dethist { text-align: left; height:200px; margin-top:1em; overflow:auto; border: thin blue solid; background-color:#c9d9ff;}\ndiv.dethist li { margin-top:20px }\ntable.bars { border: thin black solid; margin-left: auto; margin-right:auto; }\ntr.bars td { padding-top: 20px; vertical-align:bottom; padding-left:50px; padding-right:50px; margin-left: auto; margin-right:auto; }\ntr.bars div { width:50px; vertical-align:bottom; text-align:center; margin-left: auto; margin-right:auto;}:\n";
print "</style>\n";
print "</head>\n";
print "<body class=\"fortytwodays\">\n";
#print "<script type=\"text/javascript\" src=\"quiz/election2008.js\"></script>\n";
print "<a href=\"/\"><h1 id=\"th1\"><a href=\"/\"><img src=\"/thepublicwhip.gif\" ></h1></a>\n";
print "<h4 id=\"th4a\">The Forty-two Days Question</h4>\n";
#print "<h1>The Public Whip - Forty-two days</h1>\n";
#print "<h4 id=\"th4\">The candidate calculator for <i>$constituency</i></h4>\n";
#print "<p></p>\n\n";
if (is_postcode($_GET["mppc"]) or $_GET["mpc"]) {
    $mpval = get_mpid_attr_decode($db, $db2, "");
}
$vterdet = db_scrub($_GET["vterdet"]);
$vpubemknow = db_scrub($_GET["vpubemknow"]);
$vpubemagg = db_scrub($_GET["vpubemagg"]);
$vpubem = "{$vpubemknow}-{$vpubemagg}";
$vrand = db_scrub($_GET["vrand"]);
if ($vrand) {
    $vrand = (int) $vrand;
} else {
    $vrand = rand(10, 10000000);
}
$vdash = mysql_real_escape_string(db_scrub($_GET["dash"]));
# used to tell if /by-election or /byelection was used
$vformfilled = ($vterdet and $vpubemknow and $vpubemagg);
Пример #12
0
 function validate()
 {
     if (!isset($this->data['txtTitle']) || $this->data['txtTitle'] == '') {
         $this->add_warning('Please add a title for this leaflet');
         $this->add_warn_control('txtTitle');
     }
     if (!isset($this->data['ddlPartyBy']) || $this->data['ddlPartyBy'] == '') {
         $this->add_warning('Please specify the party responsible for this leaflet');
         $this->add_warn_control('ddlPartyBy');
     }
     if (!isset($this->data['txtName']) || $this->data['txtName'] == '') {
         $this->add_warning('Please add your name');
         $this->add_warn_control('txtName');
     }
     if (!isset($this->data['txtEmail']) || $this->data['txtEmail'] == '' || !valid_email($this->data['txtEmail'])) {
         $this->add_warning('Please add a valid email address');
         $this->add_warn_control('txtEmail');
     }
     //TODO: handle non-UK postcodes
     if (!isset($this->data['txtPostcode']) || $this->data['txtPostcode'] == '') {
         $this->add_warning('Please add a post code for this leaflet');
         $this->add_warn_control('txtPostcode');
     } else {
         if (!is_postcode($this->data['txtPostcode'])) {
             $this->add_warning('Please enter a valid postcode');
             $this->add_warn_control('txtPostcode');
         } else {
             $geocoder = factory::create('geocoder');
             $postcode = trim($this->data['txtPostcode']);
             $success = $geocoder->set_from_postcode($postcode, COUNTRY_CODE_TLD);
             if (!$success) {
                 $this->add_warning('Sorry, we couldn\'t locate that postcode');
                 $this->add_warn_control('txtPostcode');
             } else {
                 $this->lng = $geocoder->lng;
                 $this->lat = $geocoder->lat;
             }
             //Convert postcode to electorate
             $australian_postcode = factory::create('australian_postcode');
             $names = $australian_postcode->lookup_constituency_names($postcode);
             if (isset($this->data['ddlConstituency'])) {
                 if (in_array($this->data['ddlConstituency'], $names)) {
                     $name = $this->data['ddlConstituency'];
                 } else {
                     $this->add_warning("The postcode and electorate don't match up. Are you sure you got them both correct?");
                     $this->add_warn_control('txtPostcode');
                     $this->add_warn_control('ddlConstituency');
                 }
             } else {
                 if (count($names) == 1) {
                     $name = $names[0];
                 } else {
                     $this->add_warning("The postcode is in more than one electorate. Please select the electorate. Hint: it's either " . join(" or ", $names));
                     $this->add_warn_control('ddlConstituency');
                 }
             }
             if ($name) {
                 $search = factory::create('search');
                 $result = $search->search("constituency", array(array("name", "=", $name)));
                 if (count($result) == 1) {
                     $this->constituency_id = $result[0]->constituency_id;
                 }
             }
         }
     }
     return count($this->warnings) == 0;
 }
    $person = "";
}
// a link was selected and notified by the javascript, mark it down and leave
if ($vrand && $vevent) {
    header("Content-Type: text/html; charset=UTF-8");
    //print "<H1>Hi there</h1>\n";
    //$db->query("drop table if exists pw_dyn_glenrothes_event");
    //$db->query("create table pw_dyn_glenrothes_event (ltime timestamp, vrand int, vevent VARCHAR(30))");
    $vconstituency = db_scrub($_GET["mpc"]);
    $db->query("INSERT INTO pw_dyn_glenrothes_event (ltime, vrand, vevent)\n                VALUES (NOW(), {$vrand}, '{$vevent}')");
    // case of just a img src sent out
    exit(0);
}
$vpostcode = db_scrub($_GET["mppc"]);
$vconstituency = db_scrub($_GET["mpc"]);
if (is_postcode($vpostcode) or $_GET["mpc"]) {
    // this function does its own _GETs.  Maybe it should
    $mpval = get_mpid_attr_decode($db, $db2, "");
}
# front page
if (!$vrand) {
    // generate the random number and note it down into the main user table
    $vrand = rand(10, 10000000);
    //$db->query("drop table if exists pw_dyn_glenrothes_use");
    //$db->query("create table pw_dyn_glenrothes_use (ltime timestamp, vrand int, vpostcode varchar(20), vconstituency varchar(40), referrer varchar(200), ipnumber varchar(25), vdash varchar(7))");
    if (!isrobot()) {
        //$hithere = "<h1>hithere $vrand</h1>";
        $db->query("INSERT INTO pw_dyn_glenrothes_use (ltime, vrand, vpostcode, vconstituency, referrer, ipnumber, vdash)\n                    VALUES (NOW(), {$vrand}, '', '', '{$referrer}', '{$ipnumber}', '{$vdash}')");
    }
} else {
    $vrand = (int) $vrand;
Пример #14
0
 function setup()
 {
     //get the call type
     $call = $_GET['call'];
     switch ($call) {
         case "postcode":
             if (!isset($_GET['area_size']) || !is_postcode($_GET['postcode'])) {
                 array_push($this->warnings, "No valid postcode specified");
             }
             if (!isset($_GET['area_size'])) {
                 array_push($this->warnings, "Area size specified");
             }
             //all good, get the data
             if (sizeof($this->warnings) == 0) {
                 $xy = postcode_to_location($_GET['postcode']);
                 $easting = $xy[0];
                 $northing = $xy[1];
                 $this->applications = Applications::query($easting, $northing, alert_size_to_meters($_GET['area_size']));
             }
             break;
         case "point":
             //validation
             if (!isset($_GET['lat']) || !isset($_GET['lng'])) {
                 array_push($this->warnings, "No longitude or latitude was specified");
             }
             if (!isset($_GET['area_size'])) {
                 array_push($this->warnings, "Area size specified");
             }
             //all good, get the data
             if (sizeof($this->warnings) == 0) {
                 $latlng = new LatLng($_GET['lat'], $_GET['lng']);
                 $xy = $latlng->toOSRef();
                 $easting = $xy->easting;
                 $northing = $xy->northing;
                 $this->applications = Applications::query($easting, $northing, alert_size_to_meters($_GET['area_size']));
             }
             break;
         case "pointos":
             //validation
             if (!isset($_GET['easting']) || !isset($_GET['northing'])) {
                 array_push($this->warnings, "No easting or northing was specified");
             }
             if (!isset($_GET['area_size'])) {
                 array_push($this->warnings, "Area size specified");
             }
             //all good, get the data
             if (sizeof($this->warnings) == 0) {
                 $this->applications = Applications::query($_GET['easting'], $_GET['northing'], alert_size_to_meters($_GET['area_size']));
             }
             break;
         case "authority":
             //validation
             if (!isset($_GET['authority'])) {
                 array_push($this->warnings, "No authority name specified");
             }
             //all good, get the data
             if (sizeof($this->warnings) == 0) {
                 $this->applications = Applications::query_authority($_GET['authority']);
             }
             break;
         case "area":
             //validation
             if (!isset($_GET['bottom_left_lat']) || !isset($_GET['bottom_left_lng']) || !isset($_GET['top_right_lat']) || !isset($_GET['top_right_lng'])) {
                 array_push($this->warnings, "Bounding box was not specified");
             }
             //all good, get the data
             if (sizeof($this->warnings) == 0) {
                 $bottom_left_latlng = new LatLng($_GET['bottom_left_lat'], $_GET['bottom_left_lng']);
                 $bottom_left_xy = $bottom_left_latlng->toOSRef();
                 $top_right_latlng = new LatLng($_GET['top_right_lat'], $_GET['top_right_lng']);
                 $top_right_xy = $top_right_latlng->toOSRef();
                 $this->applications = Applications::query_area($bottom_left_xy->easting, $bottom_left_xy->northing, $top_right_xy->easting, $top_right_xy->northing);
             }
             break;
         case "areaos":
             //validation
             if (!isset($_GET['bottom_left_easting']) || !isset($_GET['bottom_left_northing']) || !isset($_GET['top_right_easting']) || !isset($_GET['top_right_northing'])) {
                 array_push($this->warnings, "Bounding box was not specified");
             }
             //all good, get the data
             if (sizeof($this->warnings) == 0) {
                 $this->applications = Applications::query_area($_GET['bottom_left_easting'], $_GET['bottom_left_northing'], $_GET['top_right_easting'], $_GET['top_right_easting']);
             }
             break;
         case "latest":
             $this->applications = Applications::query_latest(500);
             break;
         default:
             $this->warnings = "No call type specified";
     }
 }
Пример #15
0
function scrape_applications_islington($search_url, $info_url_base, $comment_url_base)
{
    $applications = array();
    $application_pattern = '/<TR>([^<]*)<TD class="lg" valign="top" >([^<]*)<a href([^<]*)<a href=wphappcriteria.display>Search Criteria(.*)([^<]*)<(.*)>([^<]*)<TD class="lg" >([^<]*)<\\/TD>([^<]*)<TD class="lg" >([^<]*)<INPUT TYPE=HIDDEN NAME([^>]*)([^<]*)/';
    //grab the page
    $html = safe_scrape_page($search_url);
    preg_match_all($application_pattern, $html, $application_matches, PREG_PATTERN_ORDER);
    foreach ($application_matches[0] as $application_match) {
        $application_string = str_replace("\n", "", $application_match);
        $reference_pattern = '/Search Results<\\/a>">([^<]*)/';
        preg_match_all($reference_pattern, $application_string, $reference_matches, PREG_PATTERN_ORDER);
        $application = new Application();
        //match the applicaiton number
        $application->council_reference = str_replace('Search Results</a>">', "", $reference_matches[0][0]);
        //Comment and info urls
        $application->info_url = $info_url_base . $application->council_reference;
        $application->comment_url = $comment_url_base . $application->council_reference;
        //get full details
        $details_html = "";
        $details_html = safe_scrape_page($info_url_base . $application->council_reference);
        $details_html = str_replace("\r\n", "", $details_html);
        //Details
        $full_detail_pattern = '/Proposal:<\\/label><\\/td>([^<]*)<td colspan="3">([^<]*)/';
        preg_match($full_detail_pattern, $details_html, $full_detail_matches);
        if (isset($full_detail_matches[2])) {
            $application->description = $full_detail_matches[2];
        }
        //Address
        $address_pattern = '/Main location:<\\/label><\\/td>([^<]*)<td colspan="3">([^<]*)/';
        $address = "";
        preg_match($address_pattern, $details_html, $address_matches);
        if (isset($address_matches[2])) {
            $application->address = $address_matches[2];
        }
        //postcode
        $postcode_pattern = "/[A-Z][A-Z]?[0-9][A-Z0-9]? ?[0-9][ABDEFGHJLNPQRSTUWXYZ]{2}/";
        preg_match($postcode_pattern, $application->address, $postcode_matches);
        if (isset($postcode_matches[0])) {
            $application->postcode = $postcode_matches[0];
        }
        //only add it if we have a postcode (bit useless otherwise)
        if (is_postcode($application->postcode)) {
            array_push($applications, $application);
        }
    }
    //return
    return $applications;
}
Пример #16
0
    $prettyquery = "";
    $query = "";
}
$title = 'Search for ' . preg_replace('/[^A-Za-z0-9 \\.\\,]/', '', $prettyquery);
if ($prettyquery == "") {
    $onload = "givefocus('query')";
    $title = "Search";
}
require_once "parliaments.inc";
require_once "constituencies.inc";
require_once "links.inc";
require_once "postcode.inc";
require_once "wiki.inc";
require_once "tablemake.inc";
require_once "tablepeop.inc";
$postcode = is_postcode($query);
$header = false;
if ($postcode) {
    $escaped_postcode = htmlentities(strtoupper($query));
    $postcode_matches = postcode_to_constituencies($db, $query);
    if (!$postcode_matches or $postcode_matches['ERROR']) {
        $title = "Postcode Error";
        pw_header();
        print "<p>There was an error trying to look up the postcode";
        if ($postcode_matches) {
            print ": " . htmlentities($postcode_matches['ERROR']) . "</p>";
        }
        pw_footer();
        exit;
    }
    $number_of_matches = count($postcode_matches);