source: trunk/npemap.org.uk/perllib/NPEMap.pm @ 635

Last change on this file since 635 was 635, checked in by Dominic Hargreaves, 12 years ago

licence tastic

File size: 1.8 KB
Line 
1# Copyright (c) 2006 Dominic Hargreaves
2# Permission is hereby granted, free of charge, to any person obtaining a
3# copy of this software and associated documentation files (the "Software"),
4# to deal in the Software without restriction, including without limitation
5# the rights to use, copy, modify, merge, publish, distribute, sublicense,
6# and/or sell copies of the Software, and to permit persons to whom the
7# Software is furnished to do so, subject to the following conditions:
8#
9# The above copyright notice and this permission notice shall be included in
10# all copies or substantial portions of the Software.
11#
12# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
18# IN THE SOFTWARE.
19#
20
21package NPEMap;
22
23use vars qw(@ISA @EXPORT);
24use warnings;
25use strict;
26
27use vars qw($dbname $dbhost $dbuser $dbpass);
28
29use NPEMap::Config;
30use DBI;
31
32require Exporter;
33@ISA    = qw(Exporter);
34@EXPORT = qw(setup_dbh print_html_err);
35
36sub setup_dbh {
37    my $data_source = "dbi:Pg:dbname=$dbname";
38    $data_source .= ";host=$dbhost" if $dbhost;
39    return DBI->connect_cached($data_source, $dbuser, $dbpass);
40}
41
42sub print_html_err($$) {
43    my $err = shift;
44    my $returnlink = shift;
45    print "Content-type: text/html\n\n";
46    print "<html><head><title>Error submitting</title></head>\n";
47    print "<body><p>The following error occurred whilst submitting data:\n";
48    print CGI::escapeHTML($err);
49    print "</p><p>$returnlink</p>\n";
50    print "</body></html>\n";
51}
52
531;
Note: See TracBrowser for help on using the repository browser.