Index: branches/stable/assign.html
===================================================================
--- branches/stable/assign.html	(revision 136)
+++ branches/stable/assign.html	(revision 140)
@@ -8,4 +8,5 @@
 $$ALLCITIES$$
 </select>
+&nbsp;<a href="javascript:popNotes('/ip/newcity.html')">Add new location</a>
 </td>
 </tr>
Index: branches/stable/cgi-bin/main.cgi
===================================================================
--- branches/stable/cgi-bin/main.cgi	(revision 136)
+++ branches/stable/cgi-bin/main.cgi	(revision 140)
@@ -988,7 +988,17 @@
     return;
   }
+
+  # Alloctype check.
   chomp $webvar{alloctype};
+  if (!grep /$webvar{alloctype}/, keys %disp_alloctypes) {
+    # Danger! Danger!  alloctype should ALWAYS be set by a dropdown.  Anyone
+    # managing to call things in such a way as to cause this deserves a cryptic error.
+    printError("Invalid alloctype");
+    return;
+  }
+
+  # CustID check
   # We have different handling for customer allocations and "internal" or "our" allocations
-  if ($webvar{alloctype} =~ /^(ci|di|cn|mi|wi)$/) {
+  if ($webvar{alloctype} =~ /^(cn|.i)$/) {
     if (!$webvar{custid}) {
       printError("Please enter a customer ID.");
@@ -1014,5 +1024,5 @@
     }
 #    print "<!-- [ In validateInput().  Insert customer ID cross-check here. ] -->\n";
-  } elsif ($webvar{alloctype} =~ /^([cdsmw]p|si|dn|dy|dc|dw|ee|rr|in)$/){
+  } else {
     # All non-customer allocations MUST be entered with "our" customer ID.
     # I have Defined this as 6750400 for consistency.
@@ -1021,9 +1031,4 @@
       $webvar{custid} = "6750400";
     }
-  } else {
-    # Danger! Danger!  alloctype should ALWAYS be set by a dropdown.  Anyone
-    # managing to call things in such a way as to cause this deserves a cryptic error.
-    printError("Invalid alloctype");
-    return;
   }
 
Index: branches/stable/cgi-bin/newcity.cgi
===================================================================
--- branches/stable/cgi-bin/newcity.cgi	(revision 140)
+++ branches/stable/cgi-bin/newcity.cgi	(revision 140)
@@ -0,0 +1,58 @@
+#!/usr/bin/perl
+# ipdb/cgi-bin/newcity.cgi
+# Add new city to database
+###
+# SVN revision info
+# $Date$
+# SVN revision $Rev$
+# Last update by $Author$
+###
+# Copyright (C) 2004,2005 - Kris Deugau
+
+use strict;
+use warnings;
+#use CGI::Carp qw(fatalsToBrowser);
+use DBI;
+use CommonWeb qw(:ALL);
+use IPDB 2.0 qw(:ALL);
+#use POSIX qw(ceil);
+use NetAddr::IP;
+
+use Sys::Syslog;
+
+openlog "IPDB","pid","local2";
+
+# Collect the username from HTTP auth.  If undefined, we're in a test environment.
+my $authuser;
+if (!defined($ENV{'REMOTE_USER'})) {
+  $authuser = '__temptest';
+} else {
+  $authuser = $ENV{'REMOTE_USER'};
+}
+
+my %webvar = parse_post();
+cleanInput(\%webvar);
+
+my ($dbh,$errstr) = connectDB("ipdb", "ipdb", "ipdbpwd");
+my $sth;
+
+print "Content-type: text/html\n\n";
+
+if ($webvar{pop} eq 'on') {
+  $sth = $dbh->prepare("insert into cities values ('$webvar{city}','y')");
+} else {
+  $sth = $dbh->prepare("insert into cities values ('$webvar{city}','n')");
+}
+$sth->execute;
+
+if ($sth->err) {
+  print "Error adding city to database: ".$sth->errstr;
+  mailNotify('kdeugau@vianet.ca',"IPDB city add failure",$sth->errstr);
+  syslog "err", "$authuser could not add city '$webvar{city}' to database: ".$sth->errstr;
+} else {
+  print "City added.  Closing this window should refresh the page.";
+  syslog "notice", "$authuser added city/location '$webvar{pop}'".
+	(($webvar{pop} eq 'on') ? ' as POP location' : '');
+}
+
+finish($dbh);
Index: branches/stable/changes.html
===================================================================
--- branches/stable/changes.html	(revision 136)
+++ branches/stable/changes.html	(revision 140)
@@ -12,4 +12,8 @@
 <tr><td class="heading" colspan=2>Changes to the IPDB</td><tr>
 
+<tr class="color2">
+<td valign=top>01/27/2005</td>
+<td>New cities/locations can now be added to the database here.
+</td></tr>
 <tr class="color1">
 <td valign=top>11/30/2004</td>
Index: branches/stable/newcity.html
===================================================================
--- branches/stable/newcity.html	(revision 140)
+++ branches/stable/newcity.html	(revision 140)
@@ -0,0 +1,26 @@
+<html>
+<head>
+	<title>IP Database - Add new city</title>
+	<link rel="stylesheet" type="text/css" href="/ip/ipdb.css" />
+
+	<SCRIPT language="JavaScript" type="text/javascript">
+	<!-- Hide From Non-Supporting Browsers
+	// snagged from http://www.webxpertz.net/forums/showthread.php?t=24650
+	function redoParent() {
+		opener.location.reload(true);
+	}
+
+	// Done Hiding -->
+	</script>
+
+</head>
+
+<body bgcolor="#ffffff" text="#000000" link="#000000" vlink="#000000" alink="#ff0000" leftmargin="0" topmargin="0" marginwidth="0" onUnload="redoParent()">
+<table>
+<form action="cgi-bin/newcity.cgi" method="POST">
+<tr class="color1"><td>Enter new city:</td><td><input name="city"></td></tr>
+<tr class="color2"><td>POP site?</td><td><input type=checkbox name="pop"></td></tr>
+<tr class="color1"><td colspan=2 align=center><input type=submit value="Add city"></td></tr>
+</table>
+</body>
+</html>
