Changeset 545 for trunk


Ignore:
Timestamp:
May 7, 2007, 6:04:08 PM (13 years ago)
Author:
Nick Burch
Message:

Support IE postcodes

File:
1 edited

Legend:

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

    r313 r545  
    7575    }
    7676
     77        # Are they using the irish grid?
     78        my $ie = 0;
     79        if(defined $cgi->param('ie')) {
     80                $ie = 1;
     81        }
     82        if(defined $cgi->param('grid') && ($cgi->param('grid') eq 'osie')) {
     83                $ie = 1;
     84        }
     85
     86        # What column do we use for the postcode?
     87        my $easting_col = "easting";
     88        my $northing_col = "northing";
     89        if($ie) {
     90                $easting_col = "ie_easting";
     91                $northing_col = "ie_northing";
     92        }
     93
    7794    my $sth;
    7895
     
    115132    # corroboration factor; this just catches accidental double-submission
    116133    # really.
    117     $sth = $dbh->prepare('SELECT raw_postcode_outward FROM postcodes WHERE raw_postcode_outward = ? AND raw_postcode_inward = ? AND easting = ? AND northing = ? AND ip = ? AND NOT deleted');
     134    $sth = $dbh->prepare("SELECT raw_postcode_outward FROM postcodes WHERE raw_postcode_outward = ? AND raw_postcode_inward = ? AND $easting_col = ? AND $northing_col = ? AND ip = ? AND NOT deleted");
    118135    unless ($sth->execute($cgi->param('postcode1'), $cgi->param('postcode2'), $easting, $northing, $ENV{'REMOTE_ADDR'})) {
    119136        print_html_err('Database error when checking for duplicate data :(', $returnlink);
     
    126143    }
    127144
    128     $sth = $dbh->prepare('INSERT INTO postcodes (outward, inward, raw_postcode_outward, raw_postcode_inward, easting, northing, ip, source, user_agent) VALUES (?, ?, ?, ?, ?, ?, ?, 0, ?)');
     145    $sth = $dbh->prepare("INSERT INTO postcodes (outward, inward, raw_postcode_outward, raw_postcode_inward, $easting_col, $northing_col, ip, source, user_agent) VALUES (?, ?, ?, ?, ?, ?, ?, 0, ?)");
    129146    if ($sth->execute($outward, $inward, $cgi->param('postcode1'), $cgi->param('postcode2'), $easting, $northing, $ENV{'REMOTE_ADDR'}, $ENV{'HTTP_USER_AGENT'})) {
    130147        print "Content-type: text/html\n\n";
Note: See TracChangeset for help on using the changeset viewer.