X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=lib%2Fcontact.php;h=051f291b3daf017cdb63958909dd542bbf49c15d;hb=70bb5379c5ed6328da193eb87c23ab8a9606409b;hp=56327de6e736e6367f731eeb948c7d49917d2155;hpb=e72f4914ec908eb1af63129346d32d3cbd45b4e0;p=readifood.git diff --git a/lib/contact.php b/lib/contact.php index 56327de..051f291 100644 --- a/lib/contact.php +++ b/lib/contact.php @@ -280,7 +280,13 @@ /* Postcode. */ echo "\n"; echo " Postcode\n"; - echo " "; input("postcode", $address->getPostcode()); echo get_address_map_link($address); echo "\n"; + $postcode = $address->getPostcode(); + if (validate_postcode($postcode)) { + echo " "; input("postcode", $postcode); echo get_address_map_link($address); echo "\n"; + } + else { + echo " "; input("postcode", $address->getPostcode()); echo " (invalid)\n"; + } echo "\n"; /* Telephone. */ @@ -422,7 +428,11 @@ /* Get address. */ $area_id = $_POST['area_id']; $line = $_POST['address']; - $postcode = $_POST['postcode']; + $postcode = trim($_POST['postcode']); + if ($postcode) { + $postcode = format_postcode($_POST['postcode'], true); + if (! $postcode) return false; + } $q = new AddressQuery; /* XXX: Finding by area properly? */ $address = $q->filterByAreaId($area_id)->filterByLine($line)->filterByPostcode($postcode)->findOneOrCreate(); @@ -578,7 +588,7 @@ } } else if ($parameters[0] == "search") { - search_contacts(0, 10, $parameters[1]); + search_contacts(0, 10, urldecode($parameters[1])); } } list($name, $id, $args) = parse_parameters($parameters);