source: trunk/cgi-bin/newcity.cgi@ 415

Last change on this file since 415 was 415, checked in by Kris Deugau, 14 years ago

/trunk

Genericize and comment a lurking mailNotify() call. See #2.
Remove a couple of stale, legacy, irrelvant comments.
Genericize another email address reference. See #2 (sort of).
Remove a legacy sub that's never been used, from a module due
to be removed itself. See #15.

  • Property svn:executable set to *
  • Property svn:keywords set to Date Rev Author
File size: 1.5 KB
Line 
1#!/usr/bin/perl
2# ipdb/cgi-bin/newcity.cgi
3# Add new city to database
4###
5# SVN revision info
6# $Date: 2010-05-14 20:00:26 +0000 (Fri, 14 May 2010) $
7# SVN revision $Rev: 415 $
8# Last update by $Author: kdeugau $
9###
10# Copyright (C) 2004,2005 - Kris Deugau
11
12use strict;
13use warnings;
14#use CGI::Carp qw(fatalsToBrowser);
15use DBI;
16use CommonWeb qw(:ALL);
17use MyIPDB;
18#use POSIX qw(ceil);
19use NetAddr::IP;
20
21use Sys::Syslog;
22
23openlog "IPDB","pid","local2";
24
25# Collect the username from HTTP auth. If undefined, we're in a test environment.
26my $authuser;
27if (!defined($ENV{'REMOTE_USER'})) {
28 $authuser = '__temptest';
29} else {
30 $authuser = $ENV{'REMOTE_USER'};
31}
32
33my %webvar = parse_post();
34cleanInput(\%webvar);
35
36my ($dbh,$errstr) = connectDB_My;
37my $sth;
38
39print "Content-type: text/html\n\n";
40
41if ($webvar{pop} eq 'on') {
42 $sth = $dbh->prepare("insert into cities (city,routing) values ('$webvar{city}','y')");
43} else {
44 $sth = $dbh->prepare("insert into cities (city,routing) values ('$webvar{city}','n')");
45}
46$sth->execute;
47
48if ($sth->err) {
49 print "Error adding city to database: ".$sth->errstr;
50# mailNotify('ipdbadmin@example.com',"IPDB city add failure",
51# "$authuser could not add city '$webvar{city}' to database: ".$sth->errstr);
52 syslog "err", "$authuser could not add city '$webvar{city}' to database: ".$sth->errstr;
53} else {
54 print "City added. Closing this window should refresh the page.";
55 syslog "notice", "$authuser added city/location '$webvar{pop}'".
56 (($webvar{pop} eq 'on') ? ' as POP location' : '');
57}
58
59finish($dbh);
Note: See TracBrowser for help on using the repository browser.