Changeset 230 for trunk/npemap.org.uk
- Timestamp:
- Oct 29, 2006, 6:10:20 PM (14 years ago)
- Location:
- trunk/npemap.org.uk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/npemap.org.uk/perllib/NPEMap/Config.pm
r226 r230 1 1 package NPEMap::Config; 2 2 3 use vars qw(@ISA @EXPORT $tt_config $rootdir $dbname);3 use vars qw(@ISA @EXPORT $tt_config $rootdir); 4 4 use warnings; 5 5 use strict; … … 9 9 require Exporter; 10 10 @ISA = qw(Exporter); 11 @EXPORT = qw($tt_config $dbname $dbhost $dbuser $dbpass );11 @EXPORT = qw($tt_config $dbname $dbhost $dbuser $dbpass $staticdir); 12 12 13 13 # Read in site config -
trunk/npemap.org.uk/perllib/NPEMap/Postcodes.pm
r219 r230 68 68 datestats => $dateStats 69 69 }; 70 $template->process('home_stats.tt', $vars) or die $template->error(); 70 71 $template->process('home_stats.tt', $vars, $staticdir . '/stats.html') 72 or warn $template->error(); 71 73 } 72 74 -
trunk/npemap.org.uk/scripts/content/update_stats.pl
r220 r230 13 13 use lib "$FindBin::Bin/../../perllib"; 14 14 use NPEMap::Postcodes; 15 16 use vars qw($dbname $dbhost $dbuser $dbpass); 15 use NPEMap; 17 16 18 17 sub print_err; 19 18 sub setup_dbh; 20 19 21 # Read in database config22 my $config = 'npemap.conf';23 do $config or die "Can't read $config!\n";24 25 26 # No point in handling errors here since they'll get handled by the request27 # handler28 20 my $dbh; 29 21 30 31 22 # In case the database went away, make sure we have a connection 32 unless ( setup_dbh()) {23 unless ($dbh = setup_dbh()) { 33 24 print_internal_err('Error setting up database connection'); 34 25 } … … 36 27 build_home_stats($dbh); 37 28 38 39 # No more requests to serve, so tidy up40 29 $dbh->disconnect; 41 30 … … 52 41 print "Error: $err\n"; 53 42 } 54 55 sub setup_dbh {56 # $dbh is global57 my $data_source = "dbi:Pg:dbname=$dbname";58 $data_source .= ";host=$dbhost" if $dbhost;59 return $dbh = DBI->connect_cached($data_source, $dbuser, $dbpass);60 } -
trunk/npemap.org.uk/templates/home_stats.tt
r219 r230 1 Total postcodes collected by us: [% allstats.us %] 2 Outward parts collected by us: [% allstats.us_out %] 3 1 <ul> 2 <li>Total postcodes collected: [% allstats.us %]</li> 3 <li>Outward parts collected: [% allstats.us_out %]</li> 4 </ul>
Note: See TracChangeset
for help on using the changeset viewer.