Changeset 41


Ignore:
Timestamp:
Oct 15, 2006, 3:15:23 PM (13 years ago)
Author:
David Sheldon
Message:

Trim whitespace from submitted postcode.

Change default back link.

Change the DB link to connect to my DB sorry, we should probably extract this into a config file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/npemap.org.uk/cgi/submit.fcgi

    r40 r41  
    2929    # If we're given return URL parameters, basic sanity check to stop
    3030    # funny business
    31     my $returnlink = '<a href="'. $returnBaseURL . '/">Go back to the start</a>';   
     31   
     32    my $returnlink = '<a href="/tiles/map.html?' .int($cgi->param('easting')/1000). ",".int($cgi->param('northing')/1000)  . ',1">Go back</a>';   
    3233
    3334    if (defined $cgi->param('returnX') and ($cgi->param('returnX') =~ /\d+/) and
    34         defined $cgi->param('returnY') and ($cgi->param('returnY') =~ /\d+/) and
    35         defined $cgi->param('returnZoom') and ($cgi->param('returnZoom') =~ /\d+/)) {
    36         $returnlink = '<a href="' . $returnBaseURL . '/tiles/map.html?' . $cgi->param('returnX') . ',' . $cgi->param('returnY') . ',' . $cgi->param('returnZoom') . '">Go back to the map</a>';
     35        defined $cgi->param('returnY') and ($cgi->param('returnY') =~ /\d+/) ) {
     36        $returnlink = '<a href="' . $returnBaseURL . '/tiles/map.html?' . $cgi->param('returnX') . ',' . $cgi->param('returnY') . ',1">Go back to the map</a>';
    3737    }
    3838
     
    7676    # Now validate the postcode input format
    7777    my $raw_postcode = $cgi->param('postcode');
    78     my $postcode = Geo::Postcode->new($raw_postcode);
     78    my $trimmed_postcode = $raw_postcode;
     79    $trimmed_postcode =~ s/^\s+//;
     80    $trimmed_postcode =~ s/\s+$//;
     81    my $postcode = Geo::Postcode->new($trimmed_postcode);
    7982    my ($first, $second, $third, $fourth) = @{$postcode->fragments};
    8083    my ($outward, $inward);
     
    149152sub setup_dbh {
    150153    # $dbh is global
    151     return $dbh = DBI->connect_cached("dbi:Pg:dbname=npemaps","npemaps","");
     154    return $dbh = DBI->connect_cached("dbi:Pg:dbname=npemaps;host=127.0.0.1","npemaps","npemaps");
    152155}
Note: See TracChangeset for help on using the changeset viewer.