aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/import-flickr112
-rw-r--r--conf/crontab.ugly1
-rw-r--r--conf/general-example2
-rw-r--r--conf/httpd.conf2
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm8
-rw-r--r--templates/emails/flickr-confirm14
-rw-r--r--templates/emails/flickr-submit14
-rwxr-xr-xweb/flickr.cgi101
8 files changed, 4 insertions, 250 deletions
diff --git a/bin/import-flickr b/bin/import-flickr
deleted file mode 100755
index f4a838547..000000000
--- a/bin/import-flickr
+++ /dev/null
@@ -1,112 +0,0 @@
-#!/usr/bin/perl -w
-
-# import-flickr:
-# Get new Flickr photos (uploaded from cameras, hopefully!)
-#
-# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
-#
-# $Id: import-flickr,v 1.9 2008-10-09 17:18:02 matthew Exp $
-
-use strict;
-require 5.8.0;
-
-# Horrible boilerplate to set up appropriate library paths.
-use FindBin;
-use lib "$FindBin::Bin/../perllib";
-use lib "$FindBin::Bin/../commonlib/perllib";
-use File::Slurp;
-use LWP::Simple;
-
-use Utils;
-use mySociety::AuthToken;
-use mySociety::Config;
-use mySociety::DBHandle qw(dbh select_all);
-use mySociety::EmailUtil;
-use mySociety::Email;
-
-BEGIN {
- mySociety::Config::set_file("$FindBin::Bin/../conf/general");
- 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 $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 partial_user where service='flickr'");
-my $result = '';
-foreach (@$ids) {
- my $api_lookup = get($url . $_->{nsid});
- next unless $api_lookup;
- $result .= $api_lookup;
-}
-
-my %ids;
-my $st = select_all('select id from flickr_imported');
-foreach (@$st) {
- $ids{$_->{id}} = 1;
-}
-
-# XXX: Hmm... Use format=perl now Cal has added it for me! :)
-while ($result =~ /<photo id="([^"]*)" owner="([^"]*)" secret="([^"]*)" server="([^"]*)" farm="([^"]*)" title="([^"]*)".*?latitude="([^"]*)" longitude="([^"]*)".*?machine_tags="([^"]*)"/g) {
- my ($id, $owner, $secret, $server, $farm, $title, $latitude, $longitude, $machine) = ($1, $2, $3, $4, $5, $6, $7, $8, $9);
- next if $ids{$id};
- if ($machine =~ /geo:/ && !$latitude && !$longitude) {
- # Have to fetch raw tags, as otherwise can't tell if it's negative, or how many decimal places
- my $url = 'http://api.flickr.com/services/rest/?method=flickr.tags.getListPhoto&api_key=' . $key . '&photo_id=' . $id;
- my $tags = get($url);
- ($longitude) = $tags =~ /raw="geo:lon=([^"]*)"/i;
- ($latitude) = $tags =~ /raw="geo:lat=([^"]*)"/i;
- }
- my $url = "http://farm$farm.static.flickr.com/$server/".$id.'_'.$secret.'_m.jpg';
- my $image = get($url);
- problem_create($id, $owner, $title, $latitude, $longitude, $image);
-}
-
-sub problem_create {
- my ($photo_id, $owner, $title, $latitude, $longitude, $image) = @_;
- my ($name, $email) = dbh()->selectrow_array("select name, email from partial_user where service='flickr' and nsid=?", {}, $owner);
-
- # set some defaults
- $name ||= '';
- $latitude ||= 0;
- $longitude ||= 0;
-
- my $id = dbh()->selectrow_array("select nextval('problem_id_seq')");
- Utils::workaround_pg_bytea("insert into problem
- (id, postcode, latitude, longitude, title, detail, name,
- email, phone, photo, state, used_map, anonymous, category, areas)
- values
- (?, '', ?, ?, ?, '', ?, ?, '', ?, 'partial', 't', 'f', '', '')", 7,
- $id, $latitude, $longitude, $title, $name, $email, $image
- );
-
- 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('partial', $id);
- $h{name} = $name;
- $h{url} = mySociety::Config::get('BASE_URL') . '/L/' . $token;
-
- my $body = mySociety::Email::construct_email({
- _template_ => $template,
- _parameters_ => \%h,
- To => $name ? [ [ $email, $name ] ] : $email,
- From => [ mySociety::Config::get('CONTACT_EMAIL'), 'FixMyStreet' ],
- });
-
- my $result = mySociety::EmailUtil::send_email($body, mySociety::Config::get('CONTACT_EMAIL'), $email);
- if ($result == mySociety::EmailUtil::EMAIL_SUCCESS) {
- dbh()->commit();
- } else {
- dbh()->rollback();
- }
-}
-
diff --git a/conf/crontab.ugly b/conf/crontab.ugly
index 48a46da9c..3b0077fb3 100644
--- a/conf/crontab.ugly
+++ b/conf/crontab.ugly
@@ -27,7 +27,6 @@ MAILTO=cron-!!(*= $site *)!!@mysociety.org
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 *)!!/fixmystreet/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 *)!!/fixmystreet/bin/send-reports || echo "stalled?"
0 9,12,15,18 * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-reports.lock "/data/vhost/!!(*= $vhost *)!!/fixmystreet/bin/send-reports --verbose" || echo "stalled?"
-15,45 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/import-flickr.lock /data/vhost/!!(*= $vhost *)!!/fixmystreet/bin/import-flickr || echo "stalled?"
2 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-alerts.lock /data/vhost/!!(*= $vhost *)!!/fixmystreet/bin/send-alerts || echo "stalled?"
0,30 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-questionnaires.lock /data/vhost/!!(*= $vhost *)!!/fixmystreet/bin/send-questionnaires || echo "stalled?"
diff --git a/conf/general-example b/conf/general-example
index 510557e46..a61f2b0b9 100644
--- a/conf/general-example
+++ b/conf/general-example
@@ -64,8 +64,6 @@ define('OPTION_HEARFROMYOURMP_BASE_URL', '');
define('OPTION_SMTP_SMARTHOST', 'localhost');
-define('OPTION_FLICKR_API', '');
-
define('OPTION_IPHONE_URL', '');
// Log file (used in test harness, and later in admin scripts)
diff --git a/conf/httpd.conf b/conf/httpd.conf
index ab35e29cf..78bb6b598 100644
--- a/conf/httpd.conf
+++ b/conf/httpd.conf
@@ -52,7 +52,6 @@ RewriteRule ^(.+)/$ $1 [R=permanent]
# RewriteRule ^/[Aa]/([0-9A-Za-z]{16,18}).*$ /alert.cgi?token=$1 [QSA,L]
# RewriteRule ^/[Cc]/([0-9A-Za-z]{16,18}).*$ /confirm.cgi?type=update;token=$1 [QSA,L]
# RewriteRule ^/[Qq]/([0-9A-Za-z]{16,18}).*$ /questionnaire.cgi?token=$1 [QSA,L]
-RewriteRule ^/[Ff]/([0-9A-Za-z]{16,18}).*$ /flickr.cgi?token=$1 [L]
# RSS feeds for updates on a problem
#RewriteRule ^/rss/([0-9]+)$ /rss.cgi?type=new_updates;id=$1 [QSA,L]
@@ -101,7 +100,6 @@ RewriteRule /(.+) /$1 [L]
# Explicitly capture all cgi files so that we can remove them one by one
# RewriteRule ^/confirm(.*) /confirm.cgi$1 [L]
-RewriteRule ^/flickr(.*) /flickr.cgi$1 [L]
# RewriteRule ^/questionnaire(.*) /questionnaire.cgi$1 [L]
# RewriteRule ^/reports(.*) /reports.cgi$1 [L]
# RewriteRule ^/rss(.*) /rss.cgi$1 [L]
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 4916107aa..1d08de29d 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -272,10 +272,10 @@ sub report_import : Path('/import') {
Create the report and set up some basics in it. If there is a partial report
requested then use that .
-Partial reports are created when people submit to us via mobile apps or by
-specially tagging photos on Flickr. They are in the database but are not
-completed yet. Users reach us by following a link we email them that contains a
-token link. This action looks for the token and if found retrieves the report in it.
+Partial reports are created when people submit to us e.g. via mobile apps.
+They are in the database but are not completed yet. Users reach us by following
+a link we email them that contains a token link. This action looks for the
+token and if found retrieves the report in it.
=cut
diff --git a/templates/emails/flickr-confirm b/templates/emails/flickr-confirm
deleted file mode 100644
index 45d11a28a..000000000
--- a/templates/emails/flickr-confirm
+++ /dev/null
@@ -1,14 +0,0 @@
-Subject: Confirm your email address on FixMyStreet
-
-Hi,
-
-Please click on the link below to confirm the email address
-you just gave to FixMyStreet:
-
-<?=$values['url']?>
-
-This is so we can look up the photos you tag with FixMyStreet,
-and send you an email letting you know about your new problems.
-
-Yours,
-The FixMyStreet team
diff --git a/templates/emails/flickr-submit b/templates/emails/flickr-submit
deleted file mode 100644
index f7eb1e99b..000000000
--- a/templates/emails/flickr-submit
+++ /dev/null
@@ -1,14 +0,0 @@
-Subject: New photo pulled from Flickr to FixMyStreet
-
-Hi <?=$values['name']?>,
-
-We've fetched a photo you uploaded to Flickr and tagged with
-FixMyStreet. To check the details we have, and to add any more,
-please visit the following URL:
-
-<?=$values['url']?>
-
-Then we can send your photo to the council. Thanks!
-
-Yours,
-The FixMyStreet team
diff --git a/web/flickr.cgi b/web/flickr.cgi
deleted file mode 100755
index 0ccce316c..000000000
--- a/web/flickr.cgi
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/usr/bin/perl -w -I../perllib
-
-# flickr.cgi:
-# Register for Flickr usage, and update photos
-#
-# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
-#
-# $Id: flickr.cgi,v 1.9 2008-10-09 14:20:54 matthew Exp $
-
-use strict;
-use Standard;
-use LWP::Simple;
-use URI::Escape;
-use mySociety::AuthToken;
-use mySociety::Email;
-use mySociety::EmailUtil;
-use mySociety::Random qw(random_bytes);
-
-sub main {
- my $q = shift;
- print Page::header($q, title=>'Flickr photo upload');
- my $out = '';
- if (my $token = $q->param('token')) {
- my $email = mySociety::AuthToken::retrieve('flickr', $token);
- if ($email) {
- my $key = mySociety::Config::get('FLICKR_API');
- my $url = 'http://api.flickr.com/services/rest/?method=flickr.people.findByEmail&api_key='.$key.'&find_email=' . uri_escape($email);
- my $result = get($url);
- my ($nsid) = $result =~ /nsid="([^"]*)"/;
- $url = 'http://api.flickr.com/services/rest/?method=flickr.people.getInfo&api_key='.$key.'&user_id=' . uri_escape($nsid);
- $result = get($url);
- my ($name) = $result =~ /<realname>(.*?)<\/realname>/;
- $name ||= '';
-
- 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
-your photos with FixMyStreet (and geo-tag them if you want/can, automatically if possible!)
-for us to pick them up.');
- } 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
- }
- } elsif (my $email = $q->param('email')) {
- my $template = File::Slurp::read_file("$FindBin::Bin/../templates/emails/flickr-confirm");
- my %h = ();
- my $token = mySociety::AuthToken::store('flickr', $email);
- $h{url} = mySociety::Config::get('BASE_URL') . '/F/' . $token;
-
- my $body = mySociety::Email::construct_email({
- _template_ => $template,
- _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, 1))),
- });
-
- my $result;
- $result = mySociety::EmailUtil::send_email($body, mySociety::Config::get('CONTACT_EMAIL'), $email);
- if ($result == mySociety::EmailUtil::EMAIL_SUCCESS) {
- $out = 'Thanks, we\'ve sent you a confirmation email!';
- dbh()->commit();
- } else {
- $out = 'Sorry, something went wrong - very alpha!';
- dbh()->rollback();
- }
- } else {
- $out .= <<EOF;
-<p><strong>This feature was added for HackDay London 2007, and might not be of production quality.</strong>
-Please <a href="/contact">send bug reports to us</a>.</p>
-<p>Using the Flickr API, FixMyStreet can utilise all the methods of uploading photos to Flickr
-to report problems to your council:</p>
-<ol>
-<li>Register that you're going to be using Flickr here, so we know to check your photos.
-<li>Upload your photo to Flickr, for example via camera phone on location
-<li>Tag the photo with FixMyStreet when uploading, or afterwards
-<li>Locate the problem on Flickr's map (if you have GPS, this might be done automatically :) )
-<li>FixMyStreet will find the photo, and ask you to add/ check the details;
-<li>The report is then sent to the council.
-</ol>
-
-<form method="post">
-<p>To begin, please enter your Flickr email address, both so we know the account to watch and
-so we can email you when you upload FixMyStreet photos with a link to check and confirm
-the details: <input type="text" name="email" value="" size="30">
-<input type="submit" value="Go">
-</p></form>
-EOF
- }
-
- print $out;
- print Page::footer($q);
-}
-Page::do_fastcgi(\&main);
-