diff options
m--------- | commonlib | 0 | ||||
-rw-r--r-- | perllib/CrossSell.pm | 5 | ||||
-rw-r--r-- | perllib/Page.pm | 19 | ||||
-rw-r--r-- | perllib/Problems.pm | 40 | ||||
-rwxr-xr-x | templates/website/faq.html | 10 | ||||
-rwxr-xr-x | web-admin/index.cgi | 17 |
6 files changed, 57 insertions, 34 deletions
diff --git a/commonlib b/commonlib -Subproject b1db274c894f3ddce98632dc21f1d5649d749d8 +Subproject f000f0ae278047e632cb7fac995a9e4a1544328 diff --git a/perllib/CrossSell.pm b/perllib/CrossSell.pm index a533ecfc7..e40f2166f 100644 --- a/perllib/CrossSell.pm +++ b/perllib/CrossSell.pm @@ -218,9 +218,8 @@ sub display_advert ($$;$%) { # } #} - # ALWAYS return democracy club advert for the mo - $q->{scratch} = 'advert=demclub0'; - return display_democracyclub(); + #$q->{scratch} = 'advert=demclub0'; + #return display_democracyclub(); #unless (defined $data{done_tms} && $data{done_tms}==1) { $q->{scratch} = 'advert=news'; diff --git a/perllib/Page.pm b/perllib/Page.pm index fcf11f7f7..cafd9ba91 100644 --- a/perllib/Page.pm +++ b/perllib/Page.pm @@ -339,17 +339,14 @@ sub footer { <script type="text/javascript"> var pkBaseURL = (("https:" == document.location.protocol) ? "https://piwik.mysociety.org/" : "http://piwik.mysociety.org/"); document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E")); -</script> -<script type="text/javascript"> -<!-- -piwik_action_name = ''; -piwik_idsite = 8; -piwik_url = pkBaseURL + "piwik.php"; -piwik_log(piwik_action_name, piwik_idsite, piwik_url); -//--> -</script> -<noscript><img width=1 height=1 src="http://piwik.mysociety.org/piwik.php?idsite=8" style="border:0" alt=""></noscript> -<!-- /Piwik --> +</script><script type="text/javascript"> +try { +var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 8); +piwikTracker.trackPageView(); +piwikTracker.enableLinkTracking(); +} catch( err ) {} +</script><noscript><p><img src="http://piwik.mysociety.org/piwik.php?idsite=8" style="border:0" alt=""/></p></noscript> +<!-- End Piwik Tag --> EOF } diff --git a/perllib/Problems.pm b/perllib/Problems.pm index 69293e162..7ce082129 100644 --- a/perllib/Problems.pm +++ b/perllib/Problems.pm @@ -34,6 +34,11 @@ sub set_site_restriction { } } +sub current_timestamp { + my $current_timestamp = dbh()->selectrow_array('select ms_current_timestamp()'); + return "'$current_timestamp'::timestamp"; +} + # Front page statistics sub recent_fixed { @@ -41,7 +46,7 @@ sub recent_fixed { my $result = Memcached::get($key); unless ($result) { $result = dbh()->selectrow_array("select count(*) from problem - where state='fixed' and lastupdate>ms_current_timestamp()-'1 month'::interval + where state='fixed' and lastupdate>" . current_timestamp() . "-'1 month'::interval $site_restriction"); Memcached::set($key, $result, 3600); } @@ -72,7 +77,7 @@ sub recent_new { my $result = Memcached::get($key); unless ($result) { $result = dbh()->selectrow_array("select count(*) from problem - where state in ('confirmed','fixed') and confirmed>ms_current_timestamp()-'$interval'::interval + where state in ('confirmed','fixed') and confirmed>" . current_timestamp() . "-'$interval'::interval $site_restriction"); Memcached::set($key, $result, 3600); } @@ -209,7 +214,7 @@ sub fixed_nearby { sub fetch_problem { my $id = shift; - dbh()->selectrow_hashref( + my $p = dbh()->selectrow_hashref( "select id, easting, northing, council, category, title, detail, photo, used_map, name, anonymous, extract(epoch from confirmed) as time, state, extract(epoch from whensent-confirmed) as whensent, @@ -218,7 +223,10 @@ sub fetch_problem { from problem where id=? and state in ('confirmed','fixed', 'hidden') $site_restriction", {}, $id ); + $p->{service} =~ s/_/ /g; + return $p; } + # API functions sub problems_matching_criteria { @@ -301,10 +309,11 @@ sub council_problems { push @params, $one_council; $where_extra = "and areas like '%,'||?||',%'"; } + my $current_timestamp = current_timestamp(); my $problems = select_all( "select id, title, detail, council, state, areas, - extract(epoch from ms_current_timestamp()-lastupdate) as duration, - extract(epoch from ms_current_timestamp()-confirmed) as age + extract(epoch from $current_timestamp-lastupdate) as duration, + extract(epoch from $current_timestamp-confirmed) as age from problem where state in ('confirmed', 'fixed') $where_extra @@ -471,14 +480,14 @@ Return a reference to an array of problems suitable for display in the admin tim Uses any site_restriction defined by a cobrand. =cut sub timeline_problems { - + my $current_timestamp = current_timestamp(); my $problems = select_all("select state,id,name,email,title,council,category,service,cobrand,cobrand_data, extract(epoch from created) as created, extract(epoch from confirmed) as confirmed, extract(epoch from whensent) as whensent - from problem where (created>=ms_current_timestamp()-'7 days'::interval - or confirmed>=ms_current_timestamp()-'7 days'::interval - or whensent>=ms_current_timestamp()-'7 days'::interval) + from problem where (created>=$current_timestamp-'7 days'::interval + or confirmed>=$current_timestamp-'7 days'::interval + or whensent>=$current_timestamp-'7 days'::interval) $site_restriction"); return $problems; @@ -498,7 +507,7 @@ sub timeline_updates { from comment, problem where comment.problem_id = problem.id and comment.state='confirmed' - and comment.created>=ms_current_timestamp()-'7 days'::interval + and comment.created>=" . current_timestamp() . "-'7 days'::interval $site_restriction"); return $updates; } @@ -515,10 +524,9 @@ sub timeline_alerts { if ($cobrand) { $cobrand_clause = " and cobrand = '$cobrand'"; } - my $current_time = dbh()->selectrow_array('select ms_current_timestamp()'); my $alerts = select_all("select *, extract(epoch from whensubscribed) as whensubscribed - from alert where whensubscribed>='$current_time'-'7 days'::interval + from alert where whensubscribed>=" . current_timestamp() . "-'7 days'::interval and confirmed=1 $cobrand_clause"); return $alerts; @@ -538,11 +546,10 @@ sub timeline_deleted_alerts { $cobrand_clause = " and cobrand = '$cobrand'"; } - my $current_time = dbh()->selectrow_array('select ms_current_timestamp()'); my $alerts = select_all("select *, extract(epoch from whensubscribed) as whensubscribed, extract(epoch from whendisabled) as whendisabled - from alert where whendisabled>='$current_time'-'7 days'::interval + from alert where whendisabled>=" . current_timestamp() . "-'7 days'::interval $cobrand_clause"); return $alerts; @@ -561,13 +568,14 @@ sub timeline_questionnaires { if ($cobrand) { $cobrand_clause = " and cobrand = '$cobrand'"; } + my $current_timestamp = current_timestamp(); my $questionnaire = select_all("select questionnaire.*, extract(epoch from questionnaire.whensent) as whensent, extract(epoch from questionnaire.whenanswered) as whenanswered from questionnaire, problem where questionnaire.problem_id = problem.id - and (questionnaire.whensent>=ms_current_timestamp()-'7 days'::interval - or questionnaire.whenanswered>=ms_current_timestamp()-'7 days'::interval) + and (questionnaire.whensent>=$current_timestamp-'7 days'::interval + or questionnaire.whenanswered>=$current_timestamp-'7 days'::interval) $cobrand_clause"); } diff --git a/templates/website/faq.html b/templates/website/faq.html index 62cb72def..c9a59dea6 100755 --- a/templates/website/faq.html +++ b/templates/website/faq.html @@ -56,9 +56,11 @@ by a registered charity, though, so if you want to make a contribution, <a href="https://secure.mysociety.org/donate/">please do</a>.</dd> <dt>Can I use FixMyStreet on my mobile?</dt> - <dd>There is an iPhone app for FixMyStreet, written by us and - <a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=297456545&mt=8">available for download on the App Store</a> - (link opens the App Store in iTunes). + <dd>There are two iPhone apps for FixMyStreet, one written by us in 2008 and + another much more recently by a volunteer, Martin Stephenson. Both are available for + download on the App Store: + <a href="http://itunes.apple.com/gb/app/fixmystreet/id297456545">FixMyStreet</a>, + <a href="http://itunes.apple.com/gb/app/streetreport/id371891859">StreetReport</a>. There is an Android app written by a volunteer, Anna Powell-Smith, available from the Android Market. </dd> @@ -163,7 +165,7 @@ Neighbourhood Fix-It was a bit of a mouthful, hard to spell, and hard to publici <dd>Yes, we can use help in all sorts of ways, technical or non-technical. Please see our <a href="http://www.mysociety.org/helpus/">Get Involved page</a>.</dd> - <dt>I’d like a site this for my own location/ where’s the "source code" to this site?</dt> + <dt>I’d like a site like this for my own location/ where’s the "source code" to this site?</dt> <dd> <p>The software behind this site is open source, and available to you mainly under the GNU Affero GPL software license. You can <a diff --git a/web-admin/index.cgi b/web-admin/index.cgi index 936054fe5..8ac3eb132 100755 --- a/web-admin/index.cgi +++ b/web-admin/index.cgi @@ -865,6 +865,23 @@ sub not_found { sub main { my $q = shift; + + my $logout = $q->param('logout'); + my $timeout = $q->param('timeout'); + if ($logout) { + if (!$timeout) { + print $q->redirect(-location => '?logout=1;timeout=' . (time() + 7)); + return; + } + if (time() < $timeout) { + print $q->header( + -status => '401 Unauthorized', + -www_authenticate => 'Basic realm="www.fixmystreet.com admin pages"' + ); + return; + } + } + my $page = $q->param('page'); $page = "summary" if !$page; |