diff options
-rwxr-xr-x | web/contact.cgi | 29 | ||||
-rw-r--r-- | web/css.css | 3 | ||||
-rwxr-xr-x | web/index.cgi | 29 |
3 files changed, 46 insertions, 15 deletions
diff --git a/web/contact.cgi b/web/contact.cgi index 1b5d620ec..f108b50e5 100755 --- a/web/contact.cgi +++ b/web/contact.cgi @@ -6,7 +6,7 @@ # Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: contact.cgi,v 1.3 2006-09-26 16:11:51 matthew Exp $ +# $Id: contact.cgi,v 1.4 2006-09-26 17:20:19 matthew Exp $ use strict; require 5.8.0; @@ -16,6 +16,13 @@ use FindBin; use lib "$FindBin::Bin/../perllib"; use lib "$FindBin::Bin/../../perllib"; use Page; +use mySociety::Config; +use mySociety::Email; +use mySociety::Util; + +BEGIN { + mySociety::Config::set_file("$FindBin::Bin/../conf/general"); +} # Main code for index.cgi sub main { @@ -41,7 +48,25 @@ sub contact_submit { push(@errors, 'Please give your name') unless $input{email}; push(@errors, 'Please write a message') unless $input{message}; return contact_page($q, @errors) if @errors; - print '<p>Submit form!</p>'; + + my $message = str_replace("\r\n", "\n", $input{message}); + my $postfix = '[ Sent by contact.cgi on ' . + $ENV{'HTTP_HOST'} . '. ' . + "IP address " . $ENV{'REMOTE_ADDR'} . + ($ENV{'HTTP_X_FORWARDED_FOR'} ? ' (forwarded from '.$ENV{'HTTP_X_FORWARDED_FOR'}.')' : '') . '. ' . + ' ]'; + my $email = mySociety::Email::construct_email({ + _body_ => "$message\n\n$postfix", + From => [$input{email}, $input{name}], + To => [[mySociety::Config::get('CONTACT_EMAIL'), 'Neighbourhood Fix-It']], + Subject => 'Message from Neighbourhood Fix-It' + }); + my $result = mySociety::Util::send_email($email, $input{email}, mySociety::Config::get('CONTACT_EMAIL')); + if ($result == mySociety::Util::EMAIL_SUCCESS) { + return '<p>Thanks for your feedback. We\'ll get back to you as soon as we can!</p>'; + } else { + return '<p>Failed to send message. Please try again, or <a href="' . mySociety::Config::get('CONTACT_EMAIL') . '">email us</a>.</p>'; + } } sub contact_page { diff --git a/web/css.css b/web/css.css index aacd85b60..f145d3520 100644 --- a/web/css.css +++ b/web/css.css @@ -53,9 +53,10 @@ fieldset { ul#error { color: #cc0000; background-color: #ffeeee; - margin:0; + margin: 0; padding: 0 0 0 1.5em; border: solid 1px #cc0000; + text-align: left; } /* Site-wide layout */ diff --git a/web/index.cgi b/web/index.cgi index e8d7fecdb..6cbe7f81c 100755 --- a/web/index.cgi +++ b/web/index.cgi @@ -6,7 +6,7 @@ # Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: index.cgi,v 1.26 2006-09-26 16:11:51 matthew Exp $ +# $Id: index.cgi,v 1.27 2006-09-26 17:20:19 matthew Exp $ # TODO # Nothing is done about the update checkboxes - not stored anywhere on anything! @@ -146,11 +146,7 @@ sub submit_comment { }); my $result = mySociety::Util::send_email($email, mySociety::Config::get('CONTACT_EMAIL'), $input{email}); if ($result == mySociety::Util::EMAIL_SUCCESS) { - } elsif ($result == mySociety::Util::EMAIL_SOFT_ERROR) { - } else { - } - - my $out = <<EOF; + my $out = <<EOF; <h1>Nearly Done! Now check your email...</h1> <p>The confirmation email <strong>may</strong> take a few minutes to arrive — <em>please</em> be patient.</p> <p>If you use web-based email or have 'junk mail' filters, you may wish to check your bulk/spam mail folders: sometimes, our messages are marked that way.</p> @@ -158,6 +154,12 @@ sub submit_comment { <br>if you do not, your comment will not be posted.</p> <p>(Don't worry - we'll hang on to your comment while you're checking your email.)</p> EOF + } else { + my $out = <<EOF; +<p>I'm afraid something went wrong when we tried to send your email. Please click Back, check your details, and try again.</p> +EOF + } + return $out; } @@ -197,11 +199,7 @@ sub submit_problem { }); my $result = mySociety::Util::send_email($email, mySociety::Config::get('CONTACT_EMAIL'), $input{email}); if ($result == mySociety::Util::EMAIL_SUCCESS) { - } elsif ($result == mySociety::Util::EMAIL_SOFT_ERROR) { - } else { - } - - my $out = <<EOF; + my $out = <<EOF; <h1>Nearly Done! Now check your email...</h1> <p>The confirmation email <strong>may</strong> take a few minutes to arrive — <em>please</em> be patient.</p> <p>If you use web-based email or have 'junk mail' filters, you may wish to check your bulk/spam mail folders: sometimes, our messages are marked that way.</p> @@ -209,6 +207,12 @@ sub submit_problem { <br>if you do not, your problem will not be posted on the site.</p> <p>(Don't worry - we'll hang on to your information while you're checking your email.)</p> EOF + } else { + my $out = <<EOF; +<p>I'm afraid something went wrong when we tried to send your email. Please click Back, check your details, and try again.</p> +EOF + } + return $out; } @@ -234,7 +238,8 @@ sub display_form { <input type="hidden" name="map" value="1"> <input type="hidden" name="pc" value="$input_h{pc}"> <h1>Reporting a problem</h1> -<p>Please fill in the form below with details of the problem:</p> +<p>Please fill in the form below with details of the problem, and +describe the location in the details box.</p> EOF } else { my ($px, $py, $easting, $northing); |