Changeset 238 for trunk/npemap.org.uk
- Timestamp:
- Oct 29, 2006, 7:35:19 PM (14 years ago)
- Location:
- trunk/npemap.org.uk/cgi
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/npemap.org.uk/cgi/bad-postcode.fcgi
r237 r238 9 9 use DBI; 10 10 use CGI::Fast qw/:standard -debug/; 11 12 use vars qw($dbname $dbhost $dbuser $dbpass);13 11 14 12 # Find our private perl libraries -
trunk/npemap.org.uk/cgi/get-distant-postcodes.fcgi
r222 r238 14 14 use DBI; 15 15 use CGI::Fast qw/:standard -debug/; 16 17 use vars qw($dbname $dbhost $dbuser $dbpass);18 16 19 17 # Find our private perl libraries -
trunk/npemap.org.uk/cgi/get-postcodes.fcgi
r222 r238 9 9 use DBI; 10 10 use CGI::Fast qw/:standard -debug/; 11 12 use vars qw($dbname $dbhost $dbuser $dbpass);13 11 14 12 # Find our private perl libraries -
trunk/npemap.org.uk/cgi/interest.fcgi
r222 r238 11 11 use Email::Valid; 12 12 13 use vars qw($dbname $dbhost $dbuser $dbpass);14 15 13 # Find our private perl libraries 16 14 use FindBin; 17 15 use lib "$FindBin::Bin/../perllib"; 18 16 use NPEMap; 19 20 sub print_err;21 17 22 18 my $returnlink='<a href="/">Go back</a>'; … … 34 30 # In case the database went away, make sure we have a connection 35 31 unless ($dbh = setup_dbh()) { 36 print_ err('Error setting up database connection', $returnlink);32 print_html_err('Error setting up database connection', $returnlink); 37 33 next REQUEST; 38 34 } … … 40 36 # Input validation 41 37 unless (defined $cgi->param('email')) { 42 print_ err ("Email address not supplied", $returnlink);38 print_html_err ("Email address not supplied", $returnlink); 43 39 next REQUEST; 44 40 } 45 41 46 42 unless(Email::Valid->address($cgi->param('email'))) { 47 print_ err ("Sorry, your email address doesn't seem to be valid", $returnlink);43 print_html_err ("Sorry, your email address doesn't seem to be valid", $returnlink); 48 44 next REQUEST; 49 45 } 50 46 51 47 unless (defined $cgi->param('scotland') or defined $cgi->param('northernireland')) { 52 print_ err ("Interest in neither Scotland nor Northern Ireland shown", $returnlink);48 print_html_err ("Interest in neither Scotland nor Northern Ireland shown", $returnlink); 53 49 next REQUEST; 54 50 } … … 57 53 my $sth = $dbh->prepare('SELECT email FROM interest WHERE email = ?'); 58 54 unless ($sth->execute($cgi->param('email'))) { 59 print_ err('Database error', $returnlink);55 print_html_err('Database error', $returnlink); 60 56 next REQUEST; 61 57 } 62 58 63 59 if ($sth->rows) { 64 print_ err('We already have a record of your interest. Please email us if you wish to change or remove this.', $returnlink);60 print_html_err('We already have a record of your interest. Please email us if you wish to change or remove this.', $returnlink); 65 61 next REQUEST; 66 62 } … … 84 80 next REQUEST; 85 81 } else { 86 print_ err("Database error when adding your data :(", $returnlink);82 print_html_err("Database error when adding your data :(", $returnlink); 87 83 next REQUEST; 88 84 } … … 91 87 # No more requests to serve, so tidy up 92 88 $dbh->disconnect; 93 94 # Helper routines95 sub print_err($$) {96 my $err = shift;97 my $returnlink = shift;98 print "Content-type: text/html\n\n";99 print "<html><head><title>Error submitting</title></head>\n";100 print "<body><p>The following error occurred whilst submitting data:\n";101 print CGI::escapeHTML($err);102 print "</p><p>$returnlink</p>\n";103 print "</body></html>\n";104 } -
trunk/npemap.org.uk/cgi/problem.fcgi
r222 r238 12 12 use CGI::Fast qw/:standard -debug/; 13 13 14 use vars qw($dbname $dbhost $dbuser $dbpass);15 16 14 # Find our private perl libraries 17 15 use FindBin; 18 16 use lib "$FindBin::Bin/../perllib"; 19 17 use NPEMap; 20 21 sub print_err;22 18 23 19 # Set up database handler to try and make sure it's ready for the first … … 39 35 # In case the database went away, make sure we have a connection 40 36 unless ($dbh = setup_dbh()) { 41 print_ err('Error setting up database connection', $returnlink);37 print_html_err('Error setting up database connection', $returnlink); 42 38 next REQUEST; 43 39 } … … 45 41 # Input validation 46 42 unless (defined $cgi->param('comment')) { 47 print_ err ("Please supply a comment");43 print_html_err ("Please supply a comment", $returnlink); 48 44 next REQUEST; 49 45 } 50 46 51 47 if (defined $cgi->param('email') and ($cgi->param('email') ne '') and !(Email::Valid->address($cgi->param('email')))) { 52 print_ err ("Invalid email address supplied");48 print_html_err ("Invalid email address supplied", $returnlink); 53 49 next REQUEST; 54 50 } … … 66 62 67 63 unless ($msg->send) { 68 print_ err ('Sorry, there was an error sending your message. Please email webmaster@npemap.org.uk instead.');64 print_html_err ('Sorry, there was an error sending your message. Please email webmaster@npemap.org.uk instead.', $returnlink); 69 65 next REQUEST; 70 66 } … … 80 76 # No more requests to serve, so tidy up 81 77 $dbh->disconnect; 82 83 # Helper routines84 sub print_err($$) {85 my $err = shift;86 my $returnlink = shift;87 print "Content-type: text/html\n\n";88 print "<html><head><title>Error submitting</title></head>\n";89 print "<body><p>The following error occurred whilst submitting data:\n";90 print CGI::escapeHTML($err);91 print "</body></html>\n";92 } -
trunk/npemap.org.uk/cgi/submit.fcgi
r234 r238 11 11 use Geo::Postcode; 12 12 13 use vars qw($dbname $dbhost $dbuser $dbpass);14 15 13 # Find our private perl libraries 16 14 use FindBin; … … 18 16 use NPEMap; 19 17 use NPEMap::Postcodes; 20 21 sub print_err;22 18 23 19 # Set up database handler to try and make sure it's ready for the first … … 47 43 # In case the database went away, make sure we have a connection 48 44 unless ($dbh = setup_dbh()) { 49 print_ err('Error setting up database connection', $returnlink);45 print_html_err('Error setting up database connection', $returnlink); 50 46 next REQUEST; 51 47 } … … 56 52 foreach my $field (@fields) { 57 53 unless (defined $cgi->param($field)) { 58 print_ err ("Parameter '$field' missing", $returnlink);54 print_html_err ("Parameter '$field' missing", $returnlink); 59 55 next REQUEST; 60 56 } … … 64 60 if (($cgi->param('easting') > 700000) or 65 61 ($cgi->param('easting') < 0)) { 66 print_ err ("Parameter 'easting' must be an integer between 0 and 700,000", $returnlink);62 print_html_err ("Parameter 'easting' must be an integer between 0 and 700,000", $returnlink); 67 63 next REQUEST; 68 64 } else { … … 73 69 if (($cgi->param('northing') > 1300000) or 74 70 ($cgi->param('northing') < 0)) { 75 print_ err("Parameter 'northing' must be an integer between 0 and 1,300,000", $returnlink);71 print_html_err("Parameter 'northing' must be an integer between 0 and 1,300,000", $returnlink); 76 72 next REQUEST; 77 73 } else { … … 91 87 92 88 unless ((length($trimmed_2)) == 1 or (length($trimmed_2) == 0) or (length($trimmed_2) == 3) or (!defined $trimmed_2)) { 93 print_ err("The postcode format is not valid", $returnlink);89 print_html_err("The postcode format is not valid", $returnlink); 94 90 next REQUEST; 95 91 } … … 111 107 $inward .= $fourth if defined $fourth; 112 108 } else { 113 print_ err("The postcode format is not valid", $returnlink);109 print_html_err("The postcode format is not valid", $returnlink); 114 110 next REQUEST; 115 111 } … … 121 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'); 122 118 unless ($sth->execute($cgi->param('postcode1'), $cgi->param('postcode2'), $easting, $northing, $ENV{'REMOTE_ADDR'})) { 123 print_ err('Database error when checking for duplicate data :(', $returnlink);119 print_html_err('Database error when checking for duplicate data :(', $returnlink); 124 120 next REQUEST; 125 121 } 126 122 127 123 if ($sth->rows) { 128 print_ err('You, or someone with the same IP address, have already submitted this postcode with these co-ordinates.', $returnlink);124 print_html_err('You, or someone with the same IP address, have already submitted this postcode with these co-ordinates.', $returnlink); 129 125 next REQUEST; 130 126 } … … 142 138 } else { 143 139 print STDERR "DB error: " . $dbh->errstr . "\n"; 144 print_ err("Database error when adding your data :(", $returnlink);140 print_html_err("Database error when adding your data :(", $returnlink); 145 141 next REQUEST; 146 142 } … … 152 148 # No more requests to serve, so tidy up 153 149 $dbh->disconnect; 154 155 # Helper routines156 sub print_err($$) {157 my $err = shift;158 my $returnlink = shift;159 print "Content-type: text/html\n\n";160 print "<html><head><title>Error submitting</title></head>\n";161 print "<body><p>The following error occurred whilst submitting data:\n";162 print CGI::escapeHTML($err);163 print "</p><p>Your input was:</p>\n<ul>";164 foreach my $field (@fields) {165 my $param = $cgi->param($field) || '';166 print "<li>$field: " . $param . "</li>\n";167 }168 print "</ul>\n";169 print "<p>$returnlink</p>\n";170 print "</body></html>\n";171 }
Note: See TracChangeset
for help on using the changeset viewer.