aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatthew <matthew>2007-03-23 14:44:31 +0000
committermatthew <matthew>2007-03-23 14:44:31 +0000
commitba7a3aa7fabdd71eeca419110f88a6b8a1824293 (patch)
treeeecb9d5098bba8ec744f4c16026647209bf5e74b
parentcff27032a2f174f0963fa7b5bd6f0ce66c2046a8 (diff)
Add abuse reporting.
-rw-r--r--perllib/Page.pm20
-rwxr-xr-xweb/contact.cgi46
-rw-r--r--web/css.css8
-rwxr-xr-xweb/index.cgi28
4 files changed, 74 insertions, 28 deletions
diff --git a/perllib/Page.pm b/perllib/Page.pm
index 349defcc8..26d1b8806 100644
--- a/perllib/Page.pm
+++ b/perllib/Page.pm
@@ -6,7 +6,7 @@
# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: Page.pm,v 1.37 2007-03-21 11:58:13 matthew Exp $
+# $Id: Page.pm,v 1.38 2007-03-23 14:44:31 matthew Exp $
#
package Page;
@@ -16,6 +16,7 @@ use Carp;
use CGI::Fast qw(-no_xhtml);
use Error qw(:try);
use File::Slurp;
+use POSIX qw(strftime);
use mySociety::Config;
use mySociety::Email;
use mySociety::Util;
@@ -191,4 +192,21 @@ EOF
return $out;
}
+sub prettify_epoch {
+ my $s = shift;
+ my @s = localtime($s);
+ my $tt = strftime('%H:%M', @s);
+ my @t = localtime();
+ if (strftime('%Y%m%d', @s) eq strftime('%Y%m%d', @t)) {
+ $tt = "$tt " . 'today';
+ } elsif (strftime('%U', @s) eq strftime('%U', @t)) {
+ $tt = "$tt, " . strftime('%A', @s);
+ } elsif (strftime('%Y', @s) eq strftime('%Y', @t)) {
+ $tt = "$tt, " . strftime('%A %e %B', @s);
+ } else {
+ $tt = "$tt, " . strftime('%a %e %B %Y', @s);
+ }
+ return $tt;
+}
+
1;
diff --git a/web/contact.cgi b/web/contact.cgi
index c25935aab..eaeeb35d3 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.10 2007-03-12 16:42:20 matthew Exp $
+# $Id: contact.cgi,v 1.11 2007-03-23 14:44:31 matthew Exp $
use strict;
require 5.8.0;
@@ -17,6 +17,7 @@ use lib "$FindBin::Bin/../perllib";
use lib "$FindBin::Bin/../../perllib";
use Page;
use mySociety::Config;
+use mySociety::DBHandle qw(dbh);
use mySociety::Email;
use mySociety::Util;
use mySociety::Web qw(ent);
@@ -42,7 +43,7 @@ Page::do_fastcgi(\&main);
sub contact_submit {
my $q = shift;
- my @vars = qw(name email subject message);
+ my @vars = qw(name email subject message id);
my %input = map { $_ => $q->param($_) || '' } @vars;
my @errors;
push(@errors, 'Please give your name') unless $input{name} =~ /\S/;
@@ -53,10 +54,14 @@ sub contact_submit {
}
push(@errors, 'Please give a subject') unless $input{subject} =~ /\S/;
push(@errors, 'Please write a message') unless $input{message} =~ /\S/;
+ push(@errors, 'Illegal ID') if $input{id} && $input{id} !~ /^[1-9]\d*$/;
return contact_page($q, @errors) if @errors;
(my $message = $input{message}) =~ s/\r\n/\n/g;
(my $subject = $input{subject}) =~ s/\r|\n/ /g;
+ $message .= "\n\n[ Complaint about report $input{id} - "
+ . mySociety::Config::get('BASE_URL') . "/?id=$input{id} ]"
+ if $input{id};
my $postfix = '[ Sent by contact.cgi on ' .
$ENV{'HTTP_HOST'} . '. ' .
"IP address " . $ENV{'REMOTE_ADDR'} .
@@ -86,14 +91,43 @@ sub contact_page {
if (@errors) {
$out .= '<ul id="error"><li>' . join('</li><li>', @errors) . '</li></ul>';
}
- $out .= <<EOF;
+ $out .= '<form method="post">';
+
+ my $id = $q->param('id');
+ $id = undef unless $id =~ /^[1-9]\d*$/;
+ if ($id) {
+ mySociety::DBHandle::configure(
+ Name => mySociety::Config::get('BCI_DB_NAME'),
+ User => mySociety::Config::get('BCI_DB_USER'),
+ Password => mySociety::Config::get('BCI_DB_PASS'),
+ Host => mySociety::Config::get('BCI_DB_HOST', undef),
+ Port => mySociety::Config::get('BCI_DB_PORT', undef)
+ );
+ my $p = dbh()->selectrow_hashref(
+ 'select title,detail,name,anonymous,extract(epoch from created) as created
+ from problem where id=?', {}, $id);
+ $out .= $q->p('You are reporting the following problem report for being abusive, containing personal information, or similar:');
+ $out .= $q->blockquote(
+ $q->h2(ent($p->{title})),
+ $q->p($q->em(
+ 'Reported ',
+ ($p->{anonymous}) ? 'anonymously' : "by " . ent($p->{name}),
+ ' at ' . Page::prettify_epoch($p->{created}),
+ )),
+ $q->p(ent($p->{detail}))
+ );
+ $out .= '<input type="hidden" name="id" value="' . $id . '">';
+ } else {
+ $out .= <<EOF;
<p>We'd love to hear what you think about this site. Just fill in the form:</p>
-<form method="post">
+EOF
+ }
+ $out .= <<EOF;
<fieldset>
<input type="hidden" name="submit_form" value="1">
-<div><label for="form_name">Name:</label>
+<div><label for="form_name">Your name:</label>
<input type="text" name="name" id="form_name" value="$input_h{name}" size="30"></div>
-<div><label for="form_email">Email:</label>
+<div><label for="form_email">Your email:</label>
<input type="text" name="email" id="form_email" value="$input_h{email}" size="30"></div>
<div><label for="form_subject">Subject:</label>
<input type="text" name="subject" id="form_subject" value="$input_h{subject}" size="30"></div>
diff --git a/web/css.css b/web/css.css
index e9d4ac068..3b5e506dd 100644
--- a/web/css.css
+++ b/web/css.css
@@ -25,6 +25,14 @@ a:hover, a:active {
color: #ff0000;
}
+blockquote {
+ border-left: solid 4px #5e552b;
+ padding-left: 0.5em;
+}
+blockquote h2, blockquote p {
+ margin: 0;
+}
+
form {
margin: 0;
}
diff --git a/web/index.cgi b/web/index.cgi
index 88df9f551..30d91e9cd 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.99 2007-03-21 21:59:35 matthew Exp $
+# $Id: index.cgi,v 1.100 2007-03-23 14:44:31 matthew Exp $
# TODO
# Nothing is done about the update checkboxes - not stored anywhere on anything!
@@ -23,7 +23,6 @@ use File::Slurp;
use Image::Magick;
use LWP::Simple;
use RABX;
-use POSIX qw(strftime);
use CGI::Carp;
use Digest::MD5 qw(md5_hex);
use URI::Escape;
@@ -570,8 +569,8 @@ EOF
# Display information about problem
$out .= '<p><em>Reported ';
- $out .= ($anonymous) ? 'anonymously' : "by $name";
- $out .= ' at ' . prettify_epoch($time);
+ $out .= ($anonymous) ? 'anonymously' : "by " . ent($name);
+ $out .= ' at ' . Page::prettify_epoch($time);
$out .= '</em></p> <p>';
$out .= ent($desc);
$out .= '</p>';
@@ -580,6 +579,9 @@ EOF
$out .= '<p align="center"><img src="/photo?id=' . $input{id} . '"></p>';
}
+ $out .= $q->p({align=>'right'},
+ $q->a({href => '/contact?id=' . $input{id}}, $q->small('Offensive? Unsuitable? Tell us'))
+ );
my $back = NewURL($q, id=>undef, x=>$x_tile, y=>$y_tile);
$out .= '<p style="padding-bottom: 0.5em; border-bottom: dotted 1px #999999;" align="right"><a href="' . $back . '">Back to listings</a></p>';
@@ -605,7 +607,7 @@ EOF
$out .= '<div id="updates">';
$out .= '<h2>Updates</h2>';
foreach my $row (@$updates) {
- $out .= "<div><a name=\"update_$row->{id}\"></a><em>Posted by $row->{name} at " . prettify_epoch($row->{created});
+ $out .= "<div><a name=\"update_$row->{id}\"></a><em>Posted by $row->{name} at " . Page::prettify_epoch($row->{created});
$out .= ', marked fixed' if ($row->{mark_fixed});
$out .= ', reopened' if ($row->{mark_open});
$out .= '</em>';
@@ -899,20 +901,4 @@ sub click_to_tile {
return $pin_tile + $pin / 254;
}
-sub prettify_epoch {
- my $s = shift;
- my @s = localtime($s);
- my $tt = strftime('%H:%M', @s);
- my @t = localtime();
- if (strftime('%Y%m%d', @s) eq strftime('%Y%m%d', @t)) {
- $tt = "$tt " . 'today';
- } elsif (strftime('%U', @s) eq strftime('%U', @t)) {
- $tt = "$tt, " . strftime('%A', @s);
- } elsif (strftime('%Y', @s) eq strftime('%Y', @t)) {
- $tt = "$tt, " . strftime('%A %e %B', @s);
- } else {
- $tt = "$tt, " . strftime('%a %e %B %Y', @s);
- }
- return $tt;
-}