aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatthew <matthew>2008-10-09 14:20:53 +0000
committermatthew <matthew>2008-10-09 14:20:53 +0000
commit60dc3b2ddad999f628b777be27ee41100eb883c3 (patch)
treea0346d3e2b1488bcd547840dd3f86533aaf6a004
parent75e9477815a8966b1ede2e4e5498575217d5ab27 (diff)
Switch flickr state to partial, tidy up code, so soon other things can use it too.
Few text tweaks also, and other bits and bobs.
-rwxr-xr-xbin/import-flickr25
-rwxr-xr-xbin/make_emptyhomes_po14
-rwxr-xr-xbin/problem-creation-graph6
-rw-r--r--conf/crontab.ugly12
-rw-r--r--conf/httpd.conf4
-rw-r--r--db/schema.sql14
-rw-r--r--perllib/Page.pm18
-rw-r--r--perllib/Standard.pm4
-rw-r--r--perllib/Utils.pm30
-rw-r--r--templates/emails/partial14
-rwxr-xr-xweb/ajax.cgi8
-rwxr-xr-xweb/confirm.cgi6
-rwxr-xr-xweb/contact.cgi6
-rwxr-xr-xweb/faq.cgi12
-rwxr-xr-xweb/flickr.cgi8
-rwxr-xr-xweb/flickr2.cgi50
-rwxr-xr-xweb/index.cgi169
-rwxr-xr-xweb/photo.cgi4
-rwxr-xr-xweb/posters/index.cgi4
-rwxr-xr-xweb/questionnaire.cgi4
-rwxr-xr-xweb/upload.cgi12
21 files changed, 218 insertions, 206 deletions
diff --git a/bin/import-flickr b/bin/import-flickr
index a6521fed5..10ccba7ed 100755
--- a/bin/import-flickr
+++ b/bin/import-flickr
@@ -6,7 +6,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: import-flickr,v 1.7 2008-05-06 14:21:43 matthew Exp $
+# $Id: import-flickr,v 1.8 2008-10-09 14:20:53 matthew Exp $
use strict;
require 5.8.0;
@@ -18,6 +18,7 @@ use lib "$FindBin::Bin/../../perllib";
use File::Slurp;
use LWP::Simple;
+use Utils;
use mySociety::AuthToken;
use mySociety::Config;
use mySociety::DBHandle qw(dbh select_all);
@@ -38,7 +39,7 @@ BEGIN {
my $key = mySociety::Config::get('FLICKR_API');
my $url = 'http://api.flickr.com/services/rest/?method=flickr.photos.search&tags=fixmystreet&extras=geo,machine_tags&api_key=' . $key . '&user_id=';
-my $ids = select_all('select nsid from flickr');
+my $ids = select_all("select nsid from partial_user where service='flickr'");
my $result = '';
foreach (@$ids) {
my $api_lookup = get($url . $_->{nsid});
@@ -70,7 +71,7 @@ while ($result =~ /<photo id="([^"]*)" owner="([^"]*)" secret="([^"]*)" server="
sub problem_create {
my ($photo_id, $owner, $title, $lat, $lon, $image) = @_;
- my ($name, $email) = dbh()->selectrow_array('select name, email from flickr where nsid=?', {}, $owner);
+ my ($name, $email) = dbh()->selectrow_array("select name, email from partial_user where service='flickr' and nsid=?", {}, $owner);
my ($easting, $northing) = (0,0);
$name ||= '';
my $areas = '';
@@ -84,28 +85,20 @@ sub problem_create {
$areas = ',' . join(',', sort keys %$areas) . ',';
}
my $id = dbh()->selectrow_array("select nextval('problem_id_seq')");
- # This is horrid
- my $s = dbh()->prepare("insert into problem
+ Utils::workaround_pg_bytea("insert into problem
(id, postcode, easting, northing, title, detail, name,
email, phone, photo, state, used_map, anonymous, category, areas)
values
- (?, '', ?, ?, ?, '', ?, ?, '', ?, 'flickr', 't', 'f', '', ?)");
- $s->bind_param(1, $id);
- $s->bind_param(2, $easting);
- $s->bind_param(3, $northing);
- $s->bind_param(4, $title);
- $s->bind_param(5, $name);
- $s->bind_param(6, $email);
- $s->bind_param(7, $image, { pg_type => DBD::Pg::PG_BYTEA });
- $s->bind_param(8, $areas);
- $s->execute();
+ (?, '', ?, ?, ?, '', ?, ?, '', ?, 'partial', 't', 'f', '', ?)", 7,
+ $id, $easting, $northing, $title, $name, $email, $image, $areas
+ );
dbh()->do('insert into flickr_imported (id, problem_id) values (?, ?)', {}, $photo_id, $id);
# XXX: Needs to only send email once to user per batch of photos, not one per photo?
my $template = File::Slurp::read_file("$FindBin::Bin/../templates/emails/flickr-submit");
my %h = ();
- my $token = mySociety::AuthToken::store('flickr', $id);
+ my $token = mySociety::AuthToken::store('partial', $id);
$h{name} = $name;
$h{url} = mySociety::Config::get('BASE_URL') . '/L/' . $token;
diff --git a/bin/make_emptyhomes_po b/bin/make_emptyhomes_po
index 462af7485..5df24928e 100755
--- a/bin/make_emptyhomes_po
+++ b/bin/make_emptyhomes_po
@@ -56,22 +56,22 @@ while(<MAINPO>) {
$buffer =~ s/^msgid "/msgstr "/;
}
- # Basics
+ # Basics
$buffer =~ s/FixMyStreet/Empty Homes Agency/g;
$buffer =~ s/\bproblem\b/empty property/g;
$buffer =~ s/\bProblem\b/Empty property/g;
$buffer =~ s/\bproblems\b/empty properties/g;
$buffer =~ s/\bProblems\b/Empty properties/g;
- $buffer =~ s/a empty/an empty/g;
- $buffer =~ s/fixed/returned to use/g;
+ $buffer =~ s/a empty/an empty/g;
+ $buffer =~ s/fixed/returned to use/g;
- $buffer =~ s/Recently put back into use empty properties/Recent empty properties put back into use/;
- $buffer =~ s/New empty properties/New empty property reports/;
- $buffer =~ s/Older empty properties/Older empty property reports/;
+ $buffer =~ s/Recently put back into use empty properties/Recent empty properties put back into use/;
+ $buffer =~ s/New empty properties/New empty property reports/;
+ $buffer =~ s/Older empty properties/Older empty property reports/;
$buffer =~ s/Report, view, or discuss local empty properties/Report and view empty properties/;
$buffer =~ s/\(like graffiti.*\)/ /;
- $buffer =~ s/(Please enter your full name).*? -/$1 -/;
+ $buffer =~ s/(Please enter your full name).*? -/$1 -/;
$buffer =~ s/We send it to the council on your behalf/The details will be sent directly to the right person in the local council for them to take action/;
$buffer =~ s/To find out what local alerts we have for you/To find out what local alerts we have in your area, council or ward/;
diff --git a/bin/problem-creation-graph b/bin/problem-creation-graph
index b039b4256..6aabdecbd 100755
--- a/bin/problem-creation-graph
+++ b/bin/problem-creation-graph
@@ -5,7 +5,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org. WWW: http://www.mysociety.org/
#
-# $Id: problem-creation-graph,v 1.3 2008-04-11 11:27:32 francis Exp $
+# $Id: problem-creation-graph,v 1.4 2008-10-09 14:20:53 matthew Exp $
GPLOT_OUTPUT="set terminal png font 'Vera.ttf' 9 size 1200,400"
EXTENSION=".png"
@@ -51,7 +51,7 @@ grab_data "where state not in ('unconfirmed', 'confirmed', 'fixed', 'hidden')" $
#or state = 'confirmed'
#or state = 'fixed'
#or state = 'hidden'
-#or state = 'flickr'
+#or state = 'partial'
cat >$GPSCRIPT <<END
@@ -82,7 +82,7 @@ cat >$GPSCRIPT <<END
"$SOURCEB" using 1:2 with impulses lt 4 lw 15 title "confirmed",\
"$SOURCEC" using 1:2 with impulses lt 5 lw 15 title "fixed",\
"$SOURCED" using 1:2 with impulses lt 6 lw 15 title "hidden",\
- "$SOURCEE" using 1:2 with impulses lt 7 lw 15 title "flickr (and any other types)",\
+ "$SOURCEE" using 1:2 with impulses lt 7 lw 15 title "partial (and any other types)",\
"< awk 'BEGIN { n = 0 } { n += \$2; print \$1, \$2, n; }' $SOURCEA" using 1:3 axes x1y2 with lines lt 2 title "cumulative total number of problems"
END
#echo "gpscript $GPSCRIPT"
diff --git a/conf/crontab.ugly b/conf/crontab.ugly
index ed93dda54..b140fbf26 100644
--- a/conf/crontab.ugly
+++ b/conf/crontab.ugly
@@ -4,7 +4,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org/
#
-# $Id: crontab.ugly,v 1.16 2008-10-06 17:02:22 root Exp $
+# $Id: crontab.ugly,v 1.17 2008-10-09 14:20:53 matthew Exp $
PATH=/usr/local/bin:/usr/bin:/bin
!!(* if ($vhost eq "matthew.fixmystreet.com") { *)!!
@@ -14,13 +14,21 @@ MAILTO=team@fixmystreet.com
!!(* } *)!!
# On only one server
-!!(* if ($hostname eq "cake") { *)!!
+!!(* if ($vhost eq 'reportemptyhomes.com') { *)!!
+
+*/5 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-reports.lock /data/vhost/!!(*= $vhost *)!!/mysociety/bci/bin/send-reports || echo "stalled?"
+2 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-alerts.lock /data/vhost/!!(*= $vhost *)!!/mysociety/bci/bin/send-alerts || echo "stalled?"
+0,30 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-questionnaires.lock /data/vhost/!!(*= $vhost *)!!/mysociety/bci/bin/send-questionnaires-eha || echo "stalled?"
+
+!!(* elsif (($hostname eq "cake" && !$staging) || ($staging && $vhost eq 'matthew.fixmystreet.com')) { *)!!
+
5,10,15,20,25,30,35,40,45,50,55 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-reports.lock /data/vhost/!!(*= $vhost *)!!/mysociety/bci/bin/send-reports || echo "stalled?"
0 0-8,10,11,13,14,16,17,19-23 * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-reports.lock /data/vhost/!!(*= $vhost *)!!/mysociety/bci/bin/send-reports || echo "stalled?"
0 9,12,15,18 * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-reports.lock "/data/vhost/!!(*= $vhost *)!!/mysociety/bci/bin/send-reports --verbose" || echo "stalled?"
15,45 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/import-flickr.lock /data/vhost/!!(*= $vhost *)!!/mysociety/bci/bin/import-flickr || echo "stalled?"
2 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-alerts.lock /data/vhost/!!(*= $vhost *)!!/mysociety/bci/bin/send-alerts || echo "stalled?"
0,30 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-questionnaires.lock /data/vhost/!!(*= $vhost *)!!/mysociety/bci/bin/send-questionnaires || echo "stalled?"
+
!!(* } *)!!
# Once a day on all servers
diff --git a/conf/httpd.conf b/conf/httpd.conf
index 5de6ee252..38b41229d 100644
--- a/conf/httpd.conf
+++ b/conf/httpd.conf
@@ -20,7 +20,7 @@
# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org
#
-# $Id: httpd.conf,v 1.34 2008-09-25 12:53:42 matthew Exp $
+# $Id: httpd.conf,v 1.35 2008-10-09 14:20:53 matthew Exp $
DirectoryIndex index.cgi
@@ -39,7 +39,7 @@ RewriteRule ^/[Cc]/([0-9A-Za-z]{16,18}).*$ /confirm.cgi?type=update;token=$1
RewriteRule ^/[Pp]/([0-9A-Za-z]{16,18}).*$ /confirm.cgi?type=problem;token=$1
RewriteRule ^/[Qq]/([0-9A-Za-z]{16,18}).*$ /questionnaire.cgi?token=$1
RewriteRule ^/[Ff]/([0-9A-Za-z]{16,18}).*$ /flickr.cgi?token=$1
-RewriteRule ^/[Ll]/([0-9A-Za-z]{16,18}).*$ /flickr2.cgi?token=$1
+RewriteRule ^/[Ll]/([0-9A-Za-z]{16,18}).*$ /index.cgi?partial_token=$1
RewriteRule ^/[Tt]/([0-9A-Za-z]{16,18}).*$ /tms-signup.cgi?token=$1
# RSS feeds for updates on a problem
diff --git a/db/schema.sql b/db/schema.sql
index 028eedd7d..28d347989 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -4,7 +4,7 @@
-- Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
-- Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
--
--- $Id: schema.sql,v 1.40 2008-09-10 18:06:30 matthew Exp $
+-- $Id: schema.sql,v 1.41 2008-10-09 14:20:53 matthew Exp $
--
-- secret
@@ -145,7 +145,7 @@ create table problem (
or state = 'confirmed'
or state = 'fixed'
or state = 'hidden'
- or state = 'flickr'
+ or state = 'partial'
),
lastupdate timestamp not null default ms_current_timestamp(),
whensent timestamp,
@@ -282,14 +282,18 @@ create table alert_sent (
whenqueued timestamp not null default ms_current_timestamp()
);
-create table flickr (
+-- To record details of people who submit via Flickr/ iPhone/ etc.
+create table partial_user (
id serial not null primary key,
+ service text not null,
nsid text not null,
name text not null,
- email text not null
+ email text not null,
+ phone text not null
);
-create unique index flickr_email_idx on flickr(email);
+create unique index partial_user_service_email_idx on partial_user(service, email);
+-- Record imported Flickr photos so we don't fetch them twice
create table flickr_imported (
id text not null,
problem_id integer not null references problem(id)
diff --git a/perllib/Page.pm b/perllib/Page.pm
index 587798630..4605c1c2e 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.114 2008-09-19 10:24:55 matthew Exp $
+# $Id: Page.pm,v 1.115 2008-10-09 14:20:54 matthew Exp $
#
package Page;
@@ -22,6 +22,7 @@ use Digest::MD5 qw(md5_hex);
use POSIX qw(strftime);
use URI::Escape;
use Problems;
+use Utils;
use mySociety::Config;
use mySociety::DBHandle qw/dbh select_all/;
use mySociety::EvEl;
@@ -292,7 +293,7 @@ sub display_map {
my $pc = $q->param('pc') || '';
my $pc_enc = ent($pc);
$out .= <<EOF;
-<form action="./" method="post" id="mapForm"$encoding>
+<form action="/" method="post" id="mapForm"$encoding>
<input type="hidden" name="submit_map" value="1">
<input type="hidden" name="x" id="formX" value="$x">
<input type="hidden" name="y" id="formY" value="$y">
@@ -793,19 +794,6 @@ sub process_photo {
return $photo;
}
-sub workaround_pg_bytea {
- my ($st, $img_idx, @elements) = @_;
- my $s = dbh()->prepare($st);
- for (my $i=1; $i<=@elements; $i++) {
- if ($i == $img_idx) {
- $s->bind_param($i, $elements[$i-1], { pg_type => DBD::Pg::PG_BYTEA });
- } else {
- $s->bind_param($i, $elements[$i-1]);
- }
- }
- $s->execute();
-}
-
sub scambs_categories {
return ('Abandoned vehicles', 'Discarded hypodermic needles',
'Dog fouling', 'Flytipping', 'Graffiti', 'Lighting (e.g. security lights)',
diff --git a/perllib/Standard.pm b/perllib/Standard.pm
index 8dc497b19..000b16169 100644
--- a/perllib/Standard.pm
+++ b/perllib/Standard.pm
@@ -7,7 +7,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: Standard.pm,v 1.1 2007-08-29 23:03:16 matthew Exp $
+# $Id: Standard.pm,v 1.2 2008-10-09 14:20:54 matthew Exp $
use strict;
use warnings;
@@ -37,6 +37,6 @@ sub import {
Host => mySociety::Config::get('BCI_DB_HOST', undef),
Port => mySociety::Config::get('BCI_DB_PORT', undef)
);
- *main::dbh = \&dbh;
+ *main::dbh = \&dbh;
}
}
diff --git a/perllib/Utils.pm b/perllib/Utils.pm
new file mode 100644
index 000000000..24f4a6f94
--- /dev/null
+++ b/perllib/Utils.pm
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+#
+# Utils.pm:
+# Various generic utilities for FixMyStreet.
+#
+# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
+# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
+#
+# $Id: Utils.pm,v 1.1 2008-10-09 14:20:54 matthew Exp $
+#
+
+package Utils;
+
+use strict;
+use mySociety::DBHandle qw(dbh);
+
+sub workaround_pg_bytea {
+ my ($st, $img_idx, @elements) = @_;
+ my $s = dbh()->prepare($st);
+ for (my $i=1; $i<=@elements; $i++) {
+ if ($i == $img_idx) {
+ $s->bind_param($i, $elements[$i-1], { pg_type => DBD::Pg::PG_BYTEA });
+ } else {
+ $s->bind_param($i, $elements[$i-1]);
+ }
+ }
+ $s->execute();
+}
+
+1;
diff --git a/templates/emails/partial b/templates/emails/partial
new file mode 100644
index 000000000..5f61d4abc
--- /dev/null
+++ b/templates/emails/partial
@@ -0,0 +1,14 @@
+Subject: Your new report on FixMyStreet
+
+Hi <?=$values['name']?>,
+
+We've stored the report you uploaded to FixMyStreet via
+<?=$values['service']?>. To check the details we have,
+and to add any more, please visit the following URL:
+
+<?=$values['url']?>
+
+Then we can send your report to the council. Thanks!
+
+Yours,
+The FixMyStreet team
diff --git a/web/ajax.cgi b/web/ajax.cgi
index d5cda6d0d..0a79fee6c 100755
--- a/web/ajax.cgi
+++ b/web/ajax.cgi
@@ -6,7 +6,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: ajax.cgi,v 1.3 2008-09-19 10:24:55 matthew Exp $
+# $Id: ajax.cgi,v 1.4 2008-10-09 14:20:54 matthew Exp $
use strict;
use Standard;
@@ -38,8 +38,8 @@ sub main {
$list .= '<li><a href="/report/' . $_->{id} . '">';
$list .= $_->{title};
$list .= '</a>';
- $list .= ' <small>(fixed)</small>' if $_->{state} eq 'fixed';
- $list .= '</li>';
+ $list .= ' <small>(fixed)</small>' if $_->{state} eq 'fixed';
+ $list .= '</li>';
}
my $om_list = $list;
@@ -48,7 +48,7 @@ sub main {
$list .= '<li><a href="/report/' . $_->{id} . '">';
$list .= $_->{title} . ' <small>(' . int($_->{distance}/100+.5)/10 . 'km)</small>';
$list .= '</a>';
- $list .= ' <small>(fixed)</small>' if $_->{state} eq 'fixed';
+ $list .= ' <small>(fixed)</small>' if $_->{state} eq 'fixed';
$list .= '</li>';
}
my $am_list = $list;
diff --git a/web/confirm.cgi b/web/confirm.cgi
index e3ec49242..8202ffa6c 100755
--- a/web/confirm.cgi
+++ b/web/confirm.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: confirm.cgi,v 1.45 2008-10-08 16:57:56 matthew Exp $
+# $Id: confirm.cgi,v 1.46 2008-10-09 14:20:54 matthew Exp $
use strict;
use Standard;
@@ -122,7 +122,7 @@ sub confirm_problem {
. sprintf(' <a href="%s">View the problem on this site</a>.', "/report/$id")
));
} elsif ($q->{site} eq 'emptyhomes') {
- $out = $q->p('Thank you for reporting an empty property on
+ $out = $q->p('Thank you for reporting an empty property on
ReportEmptyHomes.com. I have emailed the empty property officer in the council
responsible with the details and asked them to do whatever they can to get the
empty property back into use as soon as possible.') .
@@ -155,7 +155,7 @@ to resolve the UK&rsquo;s empty homes crisis.');
sub advertise_updates {
my ($q, $problem_id, $email) = @_;
- my $salt = unpack('h*', random_bytes(8));
+ my $salt = unpack('h*', random_bytes(8, 1));
my $secret = scalar(dbh()->selectrow_array('select secret from secret'));
my $signed_email = sha1_hex("$problem_id-$email-$salt-$secret");
my $signup = <<EOF;
diff --git a/web/contact.cgi b/web/contact.cgi
index 7947c333f..1c6840e2d 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.33 2008-10-08 14:38:29 matthew Exp $
+# $Id: contact.cgi,v 1.34 2008-10-09 14:20:54 matthew Exp $
use strict;
use Standard;
@@ -62,7 +62,7 @@ sub contact_submit {
From => [$input{em}, $input{name}],
To => [[mySociety::Config::get('CONTACT_EMAIL'), _('FixMyStreet')]],
Subject => 'FMS message: ' . $subject,
- 'Message-ID' => sprintf('<contact-%s-%s@mysociety.org>', time(), unpack('h*', random_bytes(5))),
+ 'Message-ID' => sprintf('<contact-%s-%s@mysociety.org>', time(), unpack('h*', random_bytes(5, 1))),
});
my $result = mySociety::EmailUtil::send_email($email, $input{em}, mySociety::Config::get('CONTACT_EMAIL'));
if ($result == mySociety::EmailUtil::EMAIL_SUCCESS) {
@@ -111,7 +111,7 @@ sub contact_page {
);
$out .= '<input type="hidden" name="id" value="' . $id . '">';
} elsif ($q->{site} eq 'emptyhomes') {
- $out .= $q->p('We&rsquo;d love to hear what you think about this
+ $out .= $q->p('We&rsquo;d love to hear what you think about this
website. Just fill in the form. Please don&rsquo;t contact us about individual empty
homes; use the box accessed from <a href="/">the front page</a>.');
} else {
diff --git a/web/faq.cgi b/web/faq.cgi
index 652a05f59..8afac06a6 100755
--- a/web/faq.cgi
+++ b/web/faq.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: faq.cgi,v 1.34 2008-10-08 14:38:29 matthew Exp $
+# $Id: faq.cgi,v 1.35 2008-10-09 14:20:54 matthew Exp $
use strict;
use Standard -db;
@@ -139,23 +139,23 @@ sub emptyhomes_faq {
my $out = $q->h1('Frequently Asked Questions');
$out .= $q->dl(
$q->dt('What is this site for?'),
- $q->dd('This site is to help make it as easy as possible for you to get
+ $q->dd('This site is to help make it as easy as possible for you to get
empty homes in your area put back into use. It allows you, to view empty homes
that have been reported and see what has been done about them. It makes
councils accountable for responding and dealing with the empty homes you
report.'),
$q->dt('How do I use the site?'),
- $q->dd('Enter a postcode or address in the box on the homepage and you
+ $q->dd('Enter a postcode or address in the box on the homepage and you
are presented with a map of that area. Click where the empty property is, fill
in the details, upload a photo if you have one and press submit. That&rsquo;s
it. You can also view other empty properties that have been reported and see
what has been done about them.'),
$q->dt('Is it free?'),
- $q->dd('Yes. The costs of developing and running this site have been
+ $q->dd('Yes. The costs of developing and running this site have been
paid for by The Empty Homes Agency and through the generosity of its funders.
The Empty Homes Agency is a charity, so if you believe in our aims and would
like to make a contribution, <a href="http://www.emptyhomes.com/donate.html">please do</a>.'),
- $q->dt('Do you remove silly or illegal content?'),
+ $q->dt('Do you remove silly or illegal content?'),
$q->dd('We reserve the right to remove any reports or updates
which we consider to be inappropriate.'),
$q->dt('How do councils bring empty properties back into use?'),
@@ -185,7 +185,7 @@ yourself using a PROD:
<a href="http://www.emptyhomes.com/usefulinformation/policy_docs/prods.html">http://www.emptyhomes.com/usefulinformation/policy_docs/prods.html</a>
')),
$q->dt('Will reporting an empty home make any difference?'),
- $q->dd($q->p('Yes. Councils can make a real difference, but they have lots of
+ $q->dd($q->p('Yes. Councils can make a real difference, but they have lots of
things to do. Many councils only deal with empty homes that are reported to
them. If people do not report empty homes, councils may well conclude that
other areas of work are more important.'), $q->p('
diff --git a/web/flickr.cgi b/web/flickr.cgi
index 29638ef25..0ccce316c 100755
--- a/web/flickr.cgi
+++ b/web/flickr.cgi
@@ -6,7 +6,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: flickr.cgi,v 1.8 2008-08-11 08:27:14 matthew Exp $
+# $Id: flickr.cgi,v 1.9 2008-10-09 14:20:54 matthew Exp $
use strict;
use Standard;
@@ -33,8 +33,8 @@ sub main {
my ($name) = $result =~ /<realname>(.*?)<\/realname>/;
$name ||= '';
- my $id = dbh()->selectrow_array("select nextval('flickr_id_seq');");
- dbh()->do("insert into flickr (id, nsid, name, email) values (?, ?, ?, ?)", {},
+ my $id = dbh()->selectrow_array("select nextval('partial_user_id_seq');");
+ dbh()->do("insert into partial_user (id, service, nsid, name, email, phone) values (?, 'flickr', ?, ?, ?, '')", {},
$id, $nsid, $name, $email);
dbh()->commit();
$out .= $q->p('Thanks for confirming your email address. Please now tag
@@ -58,7 +58,7 @@ EOF
_parameters_ => \%h,
To => $email,
From => [ mySociety::Config::get('CONTACT_EMAIL'), 'FixMyStreet' ],
- 'Message-ID' => sprintf('<flickr-%s-%s@mysociety.org>', time(), unpack('h*', random_bytes(5))),
+ 'Message-ID' => sprintf('<flickr-%s-%s@mysociety.org>', time(), unpack('h*', random_bytes(5, 1))),
});
my $result;
diff --git a/web/flickr2.cgi b/web/flickr2.cgi
deleted file mode 100755
index 8ba6982a1..000000000
--- a/web/flickr2.cgi
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/perl -w -I../perllib
-
-# flickr2.cgi:
-# Check photo details, and confirm for council
-#
-# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
-#
-# $Id: flickr2.cgi,v 1.4 2008-01-28 15:27:00 matthew Exp $
-
-use strict;
-use Standard;
-use URI::Escape;
-use mySociety::AuthToken;
-use mySociety::Email;
-use mySociety::EmailUtil;
-
-sub main {
- my $q = shift;
- my $out = '';
- if (my $token = $q->param('token')) {
- my $id = mySociety::AuthToken::retrieve('flickr', $token);
- if ($id) {
- my ($e, $n, $name, $email, $title) = dbh()->selectrow_array(
- "select easting,northing,name,email,title from problem where id=? and state='flickr'", {}, $id);
- if ($email) {
- $name = uri_escape($name);
- $email = uri_escape($email);
- $title = uri_escape($title);
- # XXX: Look up some of this stuff at the destination instead???
- print $q->redirect("/?flickr=$token;submit_map=1;easting=$e;northing=$n;name=$name;email=$email;title=$title;anonymous=1");
- return;
- }
- $out = $q->p("That report appears to have been checked already.");
- } else {
- $out = $q->p(_(<<EOF));
-Thank you for trying to register for your Flickr photos. We seem to have a
-problem ourselves though, so <a href="/contact">please let us know what went on</a>
-and we'll look into it.
-EOF
- }
- } else {
- $out .= $q->p('You need a token to get to this page!');
- }
-
- print Page::header($q, title=>'Flickr photo upload');
- print $out;
- print Page::footer($q);
-}
-Page::do_fastcgi(\&main);
diff --git a/web/index.cgi b/web/index.cgi
index 415eea669..2aef65028 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.211 2008-09-19 17:47:19 matthew Exp $
+# $Id: index.cgi,v 1.212 2008-10-09 14:20:54 matthew Exp $
use strict;
use Standard;
@@ -18,6 +18,7 @@ use RABX;
use CGI::Carp;
use URI::Escape;
+use CrossSell;
use mySociety::AuthToken;
use mySociety::Config;
use mySociety::DBHandle qw(select_all);
@@ -40,6 +41,25 @@ BEGIN {
sub main {
my $q = shift;
+ if (my $partial = $q->param('partial_token')) {
+ # We have a partial token, so fetch data from database and see where we're at.
+ my $id = mySociety::AuthToken::retrieve('partial', $partial);
+ if ($id) {
+ my @row = dbh()->selectrow_array(
+ "select easting, northing, name, email, title from problem where id=? and state='partial'", {}, $id);
+ if (@row) {
+ $q->param('anonymous', 1);
+ $q->param('submit_map', 1);
+ $q->param('easting', $row[0]);
+ $q->param('northing', $row[1]);
+ $q->param('name', $row[2]);
+ $q->param('email', $row[3]);
+ $q->param('title', $row[4]);
+ $q->param('partial', $partial);
+ }
+ }
+ }
+
my $out = '';
my %params;
if ($q->param('submit_problem') || ($q->param('submit_map') && $q->param('submit_map')==2)) {
@@ -88,22 +108,15 @@ sub front_page {
$new_text = 'recently';
}
$out .= '<form action="/" method="get" id="postcodeForm">';
- if (my $token = $q->param('flickr')) {
- my $id = mySociety::AuthToken::retrieve('flickr', $token);
+ if (my $token = $q->param('partial')) {
+ my $id = mySociety::AuthToken::retrieve('partial', $token);
if ($id) {
- my $name = ent($q->param('name'));
- my $email = ent($q->param('email'));
- my $title = ent($q->param('title'));
$out .= <<EOF;
-<p style="margin-top:0;color: #cc0000;">Thanks for uploading your photo via Flickr! We need to locate your problem,
-so please enter a nearby street name or postcode in the box below...</p>
-
-<input type="hidden" name="flickr" value="$token">
-<input type="hidden" name="submit_map" value="1">
-<input type="hidden" name="name" value="$name">
-<input type="hidden" name="email" value="$email">
-<input type="hidden" name="title" value="$title">
-<input type="hidden" name="anonymous" value="1">
+<p style="margin-top: 0; color: #cc0000;"><img align="right" src="/photo?id=$id" hspace="5">
+Thanks for uploading your photo. We now need to locate your problem,
+so please enter a nearby street name or postcode in the box below&nbsp;:</p>
+
+<input type="hidden" name="partial_token" value="$token">
EOF
}
}
@@ -117,7 +130,6 @@ EOF
EOF
$out .= $q->h2(_('How to report a problem'));
my $step4 = $q->li(_('We send it to the council on your behalf'));
- $step4 = '' if $q->{site} eq 'emptyhomes';
$step4 = $q->li('The council receives your report and acts upon it')
if $q->{site} eq 'scambs';
$out .= $q->ol(
@@ -194,7 +206,7 @@ sub submit_update {
return display_problem($q, @errors) if (@errors);
my $id = dbh()->selectrow_array("select nextval('comment_id_seq');");
- Page::workaround_pg_bytea("insert into comment
+ Utils::workaround_pg_bytea("insert into comment
(id, problem_id, name, email, website, text, state, mark_fixed, photo)
values (?, ?, ?, ?, '', ?, 'unconfirmed', ?, ?)", 7,
$id, $input{id}, $input{name}, $input{email}, $input{update},
@@ -215,7 +227,7 @@ sub submit_update {
sub submit_problem {
my $q = shift;
- my @vars = qw(council title detail name email phone pc easting northing skipped anonymous category flickr upload_fileid);
+ my @vars = qw(council title detail name email phone pc easting northing skipped anonymous category partial upload_fileid);
my %input = map { $_ => scalar $q->param($_) } @vars;
for (qw(title detail)) {
$input{$_} = lc $input{$_} if $input{$_} !~ /[a-z]/;
@@ -326,8 +338,8 @@ sub submit_problem {
$input{category} = _('Other') unless $input{category};
my ($id, $out);
- if (my $token = $input{flickr}) {
- my $id = mySociety::AuthToken::retrieve('flickr', $token);
+ if (my $token = $input{partial}) {
+ my $id = mySociety::AuthToken::retrieve('partial', $token);
if ($id) {
dbh()->do("update problem set postcode=?, easting=?, northing=?, title=?, detail=?,
name=?, email=?, phone=?, state='confirmed', council=?, used_map='t',
@@ -338,12 +350,14 @@ sub submit_problem {
$input{category}, $id);
dbh()->commit();
$out = $q->p(sprintf(_('You have successfully confirmed your report and you can now <a href="%s">view it on the site</a>.'), "/report/$id"));
+ $out .= CrossSell::display_advert($q, $input{email}, $input{name});
} else {
- $out = $q->p(_('There appears to have been a problem.'));
+ $out = $q->p('There appears to have been a problem updating the details of your report.
+Please <a href="/contact">let us know what went on</a> and we\'ll look into it.');
}
} else {
$id = dbh()->selectrow_array("select nextval('problem_id_seq');");
- Page::workaround_pg_bytea("insert into problem
+ Utils::workaround_pg_bytea("insert into problem
(id, postcode, easting, northing, title, detail, name,
email, phone, photo, state, council, used_map, anonymous, category, areas, send_questionnaire)
values
@@ -371,7 +385,7 @@ sub submit_problem {
sub display_form {
my ($q, @errors) = @_;
my ($pin_x, $pin_y, $pin_tile_x, $pin_tile_y) = (0,0,0,0);
- my @vars = qw(title detail name email phone pc easting northing x y skipped council anonymous flickr upload_fileid);
+ my @vars = qw(title detail name email phone pc easting northing x y skipped council anonymous partial upload_fileid);
my %input = map { $_ => $q->param($_) || '' } @vars;
my %input_h = map { $_ => $q->param($_) ? ent($q->param($_)) : '' } @vars;
my @ps = $q->param;
@@ -384,7 +398,7 @@ sub display_form {
|| ($input{easting} && $input{northing})
|| ($input{skipped} && $input{x} && $input{y})
|| ($input{skipped} && $input{pc})
- || ($input{flickr} && $input{pc});
+ || ($input{partial} && $input{pc});
my $out = '';
my ($px, $py, $easting, $northing);
@@ -407,7 +421,7 @@ sub display_form {
$py = Page::tile_to_px($pin_y, $input{y}, 1);
$easting = Page::tile_to_os($pin_x);
$northing = Page::tile_to_os($pin_y);
- } elsif ($input{flickr} && $input{pc} && !$input{easting} && !$input{northing}) {
+ } elsif ($input{partial} && $input{pc} && !$input{easting} && !$input{northing}) {
my ($x, $y, $e, $n, $error) = Page::geocode($input{pc});
$easting = $e; $northing = $n;
$input{x} = int(Page::os_to_tile($easting));
@@ -424,9 +438,12 @@ sub display_form {
$northing = $input_h{northing};
}
+ my $parent_types = $mySociety::VotingArea::council_parent_types;
+ $parent_types = [qw(DIS LBO MTD UTA LGD COI)] # No CTY
+ if $q->{site} eq 'emptyhomes';
my $all_councils = mySociety::MaPit::get_voting_areas_by_location(
{ easting => $easting, northing => $northing },
- 'polygon', $mySociety::VotingArea::council_parent_types);
+ 'polygon', $parent_types);
# Ipswich & St Edmundsbury are responsible for everything in their areas, no Suffolk
delete $all_councils->{2241} if $all_councils->{2446} || $all_councils->{2443};
@@ -442,7 +459,7 @@ sub display_form {
# Look up categories for this council or councils
my $category = '';
my %council_ok;
- if ($q->{site} ne 'emptyhomes') { # No category
+ if ($q->{site} ne 'emptyhomes') {
my $categories = select_all("select area_id, category from contacts
where deleted='f' and area_id in (" . join(',', @$all_councils) . ')');
@$categories = sort { $a->{category} cmp $b->{category} } @$categories;
@@ -462,6 +479,13 @@ sub display_form {
-attributes=>{id=>'form_category'})
);
}
+ } else {
+ my @categories = ('-- Pick a property type --', 'Empty house or bungalow', 'Empty flat or maisonette', 'Whole block of empty flats', 'Empty office or other commercial', 'Empty pub or bar', 'Empty public building - school, hospital, etc.');
+ $category = $q->div($q->label({'for'=>'form_category'}, _('Property type:')),
+ $q->popup_menu(-name=>'category', -values=>\@categories,
+ -attributes=>{id=>'form_category'})
+ );
+ $council_ok{$all_councils->[0]} = 1;
}
my @councils = keys %council_ok;
@@ -492,45 +516,44 @@ EOF
If this is not the correct location, simply click on the map again. '));
}
- if ($q->{site} ne 'emptyhomes') { # No "send to council" blurb
- if ($details eq 'all') {
- $out .= '<p>All the information you provide here will be sent to <strong>'
- . join('</strong> or <strong>', map { $areas_info->{$_}->{name} } @$all_councils)
- . '</strong>. On the site, we will show the subject and details of the problem,
- plus your name if you give us permission.';
- $out .= '<input type="hidden" name="council" value="' . join(',',@$all_councils) . '">';
- } elsif ($details eq 'some') {
- my $e = mySociety::Config::get('CONTACT_EMAIL');
- my %councils = map { $_ => 1 } @councils;
- my @missing;
- foreach (@$all_councils) {
- push @missing, $_ unless $councils{$_};
- }
- my $n = @missing;
- my $list = join(' or ', map { $areas_info->{$_}->{name} } @missing);
- $out .= '<p>All the information you provide here will be sent to <strong>'
- . join('</strong> or <strong>', map { $areas_info->{$_}->{name} } @councils)
- . '</strong>. On the site, we will show the subject and details of the problem,
- plus your name if you give us permission.';
- $out .= ' We do <strong>not</strong> yet have details for the other council';
- $out .= ($n>1) ? 's that cover' : ' that covers';
- $out .= " this location. You can help us by finding a contact email address for local
+ if ($details eq 'all') {
+ $out .= '<p>All the information you provide here will be sent to <strong>'
+ . join('</strong> or <strong>', map { $areas_info->{$_}->{name} } @$all_councils)
+ . '</strong>. On the site, we will show the subject and details of the problem,
+ plus your name if you give us permission.';
+ $out .= '<input type="hidden" name="council" value="' . join(',',@$all_councils) . '">';
+ } elsif ($details eq 'some') {
+ my $e = mySociety::Config::get('CONTACT_EMAIL');
+ my %councils = map { $_ => 1 } @councils;
+ my @missing;
+ foreach (@$all_councils) {
+ push @missing, $_ unless $councils{$_};
+ }
+ my $n = @missing;
+ my $list = join(' or ', map { $areas_info->{$_}->{name} } @missing);
+ $out .= '<p>All the information you provide here will be sent to <strong>'
+ . join('</strong> or <strong>', map { $areas_info->{$_}->{name} } @councils)
+ . '</strong>. On the site, we will show the subject and details of the problem,
+ plus your name if you give us permission.';
+ $out .= ' We do <strong>not</strong> yet have details for the other council';
+ $out .= ($n>1) ? 's that cover' : ' that covers';
+ $out .= " this location. You can help us by finding a contact email address for local
problems for $list and emailing it to us at <a href='mailto:$e'>$e</a>.";
- $out .= '<input type="hidden" name="council" value="' . join(',', @councils)
- . '|' . join(',', @missing) . '">';
- } else {
- my $e = mySociety::Config::get('CONTACT_EMAIL');
- my $list = join(' or ', map { $areas_info->{$_}->{name} } @$all_councils);
- my $n = @$all_councils;
- $out .= '<p>We do not yet have details for the council';
- $out .= ($n>1) ? 's that cover' : ' that covers';
- $out .= " this location. If you submit a problem here it will be
+ $out .= '<input type="hidden" name="council" value="' . join(',', @councils)
+ . '|' . join(',', @missing) . '">';
+ } else {
+ my $e = mySociety::Config::get('CONTACT_EMAIL');
+ my $list = join(' or ', map { $areas_info->{$_}->{name} } @$all_councils);
+ my $n = @$all_councils;
+ $out .= '<p>We do not yet have details for the council';
+ $out .= ($n>1) ? 's that cover' : ' that covers';
+ $out .= " this location. If you submit a problem here it will be
left on the site, but <strong>not</strong> reported to the council.
You can help us by finding a contact email address for local
problems for $list and emailing it to us at <a href='mailto:$e'>$e</a>.";
- $out .= '<input type="hidden" name="council" value="-1">';
- }
+ $out .= '<input type="hidden" name="council" value="-1">';
}
+
if ($input{skipped}) {
$out .= $q->p(_('Please fill in the form below with details of the problem,
and describe the location as precisely as possible in the details box.'));
@@ -539,18 +562,20 @@ and describe the location as precisely as possible in the details box.'));
to help unless you leave as much detail as you can, so please describe the exact location of
the problem (e.g. on a wall), what it is, how long it has been there, a description (and a
photo of the problem if you have one), etc.';
+ } elsif ($q->{site} eq 'emptyhomes') {
+ $out .= $q->p(<<EOF);
+Please fill in details of the empty property below, saying what type of
+property it is e.g. an empty home, block of flats, office etc. Tell us
+something about its condition and any other information you feel is relevant.
+There is no need for you to give the exact address. Please be polite, concise
+and to the point; writing your message entirely in block capitals makes it hard
+to read, as does a lack of punctuation.
+EOF
} elsif ($details ne 'none') {
$out .= '<p>Please fill in details of the problem below. The council won\'t be able
to help unless you leave as much detail as you can, so please describe the exact location of
the problem (e.g. on a wall), what it is, how long it has been there, a description (and a
photo of the problem if you have one), etc.';
- } elsif ($q->{site} eq 'emptyhomes') {
- $out .= <<EOF;
-<p>Please fill in details of the empty property below, giving the state of the
-property, what type of property is and any other information you feel is relevant.
-Please be polite, concise and to the point; writing your message entirely in
-block capitals makes it hard to read, as does a lack of punctuation.</p>
-EOF
} else {
$out .= $q->p(_('Please fill in details of the problem below.'));
}
@@ -576,11 +601,11 @@ EOF
<div><label for="form_detail">Details:</label>
<textarea name="detail" id="form_detail" rows="7" cols="26">$input_h{detail}</textarea></div>
EOF
- if (my $token = $input{flickr}) {
- my $id = mySociety::AuthToken::retrieve('flickr', $token);
+ if (my $token = $input{partial}) {
+ my $id = mySociety::AuthToken::retrieve('partial', $token);
if ($id) {
- $out .= '<p>The photo you uploaded was:</p> <input type="hidden" name="flickr" value="' . $token . '">';
- $out .= '<p align="center"><img src="/photo?id=' . $id . '"></p>';
+ $out .= '<p>The photo you uploaded was:</p> <input type="hidden" name="partial" value="' . $token . '">';
+ $out .= '<p><img src="/photo?id=' . $id . '"></p>';
}
} else {
$out .= <<EOF;
diff --git a/web/photo.cgi b/web/photo.cgi
index 543f1b31e..fc89fc0f7 100755
--- a/web/photo.cgi
+++ b/web/photo.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: photo.cgi,v 1.10 2008-05-15 16:15:32 matthew Exp $
+# $Id: photo.cgi,v 1.11 2008-10-09 14:20:54 matthew Exp $
use strict;
use Standard;
@@ -26,7 +26,7 @@ sub main {
id=? and state = 'confirmed' and photo is not null", {}, $c);
} else {
$photo = dbh()->selectrow_arrayref( "select photo from problem where
- id=? and state in ('confirmed', 'fixed', 'flickr') and photo is not
+ id=? and state in ('confirmed', 'fixed', 'partial') and photo is not
null", {}, $id);
}
return unless $photo;
diff --git a/web/posters/index.cgi b/web/posters/index.cgi
index e857810e3..54fb87bfa 100755
--- a/web/posters/index.cgi
+++ b/web/posters/index.cgi
@@ -6,7 +6,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: index.cgi,v 1.6 2008-01-28 15:27:01 matthew Exp $
+# $Id: index.cgi,v 1.7 2008-10-09 14:20:55 matthew Exp $
use strict;
use Standard -db;
@@ -28,7 +28,7 @@ Page::do_fastcgi(\&main);
sub body {
my $q = shift;
return $q->h1(_('Publicity Material')) .
- '<img align="right" hspace="5" src="poster.png" alt="Example poster">' .
+ '<img align="right" hspace="5" src="poster.png" alt="Example poster">' .
$q->p(_('Here are some posters you can use to publicise FixMyStreet.')) .
$q->h2(_('Posters')) .
$q->ul(
diff --git a/web/questionnaire.cgi b/web/questionnaire.cgi
index aa79f1313..43868ad8e 100755
--- a/web/questionnaire.cgi
+++ b/web/questionnaire.cgi
@@ -6,7 +6,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: questionnaire.cgi,v 1.31 2008-09-19 10:24:55 matthew Exp $
+# $Id: questionnaire.cgi,v 1.32 2008-10-09 14:20:54 matthew Exp $
use strict;
use Standard;
@@ -121,7 +121,7 @@ sub submit_questionnaire {
# Record an update if they've given one, or if there's a state change
my $name = $problem->{anonymous} ? undef : $problem->{name};
my $update = $input{update} ? $input{update} : 'Questionnaire filled in by problem reporter';
- Page::workaround_pg_bytea("insert into comment
+ Utils::workaround_pg_bytea("insert into comment
(problem_id, name, email, website, text, state, mark_fixed, mark_open, photo)
values (?, ?, ?, '', ?, 'confirmed', ?, ?, ?)", 7,
$problem->{id}, $name, $problem->{email}, $update,
diff --git a/web/upload.cgi b/web/upload.cgi
index bc42716f8..3114b7bb9 100755
--- a/web/upload.cgi
+++ b/web/upload.cgi
@@ -6,7 +6,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: upload.cgi,v 1.1 2008-03-29 03:03:35 matthew Exp $
+# $Id: upload.cgi,v 1.2 2008-10-09 14:20:54 matthew Exp $
use strict;
use Standard -db;
@@ -27,11 +27,11 @@ sub main {
if ($fh) {
$q->delete('photo'); # Can't check content/type when uploaded with Flash
$image = process_photo($fh);
- my $name = unpack('H*', random_bytes(12));
- open FP, '>/data/vhost/matthew.bci.mysociety.org/photos/' . $name or throw Error::Simple('could not open file');
- print FP $image;
- close FP;
- $out = $name;
+ my $name = unpack('H*', random_bytes(12, 1));
+ open FP, '>/data/vhost/matthew.bci.mysociety.org/photos/' . $name or throw Error::Simple('could not open file');
+ print FP $image;
+ close FP;
+ $out = $name;
};
} catch Error::Simple with {
my $e = shift;