Changeset 262
- Timestamp:
- 06/17/05 16:42:45 (20 years ago)
- Location:
- branches/dns
- Files:
-
- 1 deleted
- 12 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/dns/alloctypes.html
r38 r262 14 14 <tr class="color1"> 15 15 <td>Customer netblock (default)</td><td>A direct allocation /30 or larger to a 16 customer. </td>16 customer. Note that this does NOT include RADIUS-routed "netblocks".</td> 17 17 </tr> 18 18 … … 65 65 </tr><tr class="color1"> 66 66 <td>Dynamic cable block</td><td>Netblock for (mostly residential) DHCP cable.</td> 67 </tr><tr class="color2"> 68 <td>Dynamic WiFi block</td><td>Netblock for (mostly residential) (mostly) PPPoE wireless.</td> 67 69 70 </tr><tr class="color1"> 71 <td>Reserve for WAN blocks</td><td>Reserve a chunk of IP space for core routers/etc.</td> 68 72 </tr><tr class="color2"> 73 <td>Reserve for dynamic-route DSL netblocks</td><td>Reserve a chunk of IP space for 74 RADIUS-assigned "netblocks" from a PPPoE pool. Note that this is similar to the static DSL 75 pool, but IP space is to be allocated as /30 and larger netblocks, not single static IPs.</td> 76 </tr><tr class="color1"> 77 <td>WAN block</td><td>Individual netblock assignment for a core router. Always taken from a 78 block which has previously been reserved for such assignments.</td> 79 </tr><tr class="color2"> 80 <td>Dynamic-route DSL netblock</td><td>Customer assignment for a RADIUS-assigned PPPoE 81 "netblock".</td> 82 83 </tr><tr class="color1"> 69 84 <td>Routing</td><td>Blocks not actually assigned to a service on their own, but which 70 85 have been routed to individual POPs- typically /24, /23, /22</td> 71 86 72 </tr><tr class="color 1">87 </tr><tr class="color2"> 73 88 <td>Master block</td><td>Our allocations from ARIN</td> 74 89 </tr> -
branches/dns/cgi-bin/CommonWeb.pm
r105 r262 53 53 } 54 54 55 sub printHeader($) #(cgiurl) 56 { 57 my $cgiURL = $_[0]; 58 print "Content-type: text/html\n\n"; 59 open(FILE, "../header.inc") || die $!; 60 while (<FILE>) 61 { 62 $_ =~ s/\$\$CGIURL\$\$/$cgiURL/g; 63 print $_; 64 } 65 close(FILE); 55 56 sub printHeader { 57 my $title = shift; 58 print "Content-type: text/html\n\n"; 59 # This doesn't work well. Must investigate. 60 # my $realm = shift; 61 # print qq(WWW-Authenticate: Basic realm="$realm"\n) if $realm; 62 open FILE, "../header.inc" 63 or carp $!; 64 my $html = join('',<FILE>); 65 close FILE; 66 67 $html =~ s/\$\$TITLE\$\$/$title/; 68 # Necessary for mangling arbitrary bits of the header 69 my $i=0; 70 while (defined(my $param = shift)) { 71 $html =~ s/\$\$EXTRA$i\$\$/$param/g; 72 $i++; 73 } 74 print $html; 66 75 } 67 76 -
branches/dns/cgi-bin/IPDB.pm
r189 r262 23 23 @EXPORT_OK = qw( 24 24 %disp_alloctypes %list_alloctypes %def_custids @citylist @poplist @masterblocks 25 %allocated %free %routed %bigfree 25 %allocated %free %routed %bigfree %IPDBacl 26 26 &initIPDBGlobals &connectDB &finish &checkDBSanity &allocateBlock &deleteBlock 27 27 &mailNotify … … 31 31 %EXPORT_TAGS = ( ALL => [qw( 32 32 %disp_alloctypes %list_alloctypes %def_custids @citylist @poplist 33 @masterblocks %allocated %free %routed %bigfree 33 @masterblocks %allocated %free %routed %bigfree %IPDBacl 34 34 &initIPDBGlobals &connectDB &finish &checkDBSanity &allocateBlock 35 35 &deleteBlock &mailNotify … … 50 50 our %routed; 51 51 our %bigfree; 52 our %IPDBacl; 52 53 53 54 # Let's initialize the globals. … … 83 84 $sth = $dbh->prepare("select cidr from masterblocks order by cidr"); 84 85 $sth->execute; 86 return (undef,$sth->errstr) if $sth->err; 85 87 for (my $i=0; my @data = $sth->fetchrow_array(); $i++) { 86 88 $masterblocks[$i] = new NetAddr::IP $data[0]; … … 91 93 $routed{"$masterblocks[$i]"} = 0; 92 94 } 95 96 # Load ACL data. Specific username checks are done at a different level. 97 $sth = $dbh->prepare("select username,acl from users"); 98 $sth->execute; 93 99 return (undef,$sth->errstr) if $sth->err; 100 while (my @data = $sth->fetchrow_array) { 101 $IPDBacl{$data[0]} = $data[1]; 102 } 94 103 95 104 return (1,"OK"); … … 375 384 }; # end eval 376 385 if ($@) { 386 $msg .= ": ".$@; 377 387 eval { $dbh->rollback; }; 378 388 return ('FAIL',$msg); … … 416 426 my @poolip_list = $pool->hostenum; 417 427 if ($class eq 'all') { # (DSL-ish block - *all* IPs available 418 $sth->execute($pool->addr); 428 if ($pool->addr !~ /\.0$/) { # .0 causes weirdness. 429 $sth->execute($pool->addr); 430 } 419 431 for (my $i=0; $i<=$#poolip_list; $i++) { 420 432 $sth->execute($poolip_list[$i]->addr); 421 433 } 422 434 $pool--; 423 $sth->execute($pool->addr); 435 if ($pool->addr !~ /\.255$/) { # .255 can cause weirdness. 436 $sth->execute($pool->addr); 437 } 424 438 } else { # (real netblock) 425 439 for (my $i=1; $i<=$#poolip_list; $i++) { -
branches/dns/cgi-bin/admin.cgi
r214 r262 33 33 } 34 34 35 if ($authuser !~ /^(kdeugau|jodyh|jipp)$/) {36 print "Content-Type: text/html\n\n".37 "<html><head><title>Access denied</title></head><body>\n".38 'Access to this tool is restricted. Contact <a href="mailto:kdeugau@vianet.ca">Kris</a> '.39 "for more information.</body></html>\n";40 exit;41 }42 43 35 syslog "debug", "$authuser active"; 44 36 … … 53 45 } 54 46 initIPDBGlobals($ip_dbh); 47 48 if ($IPDBacl{$authuser} !~ /A/) { 49 print "Content-Type: text/html\n\n". 50 "<html><head><title>Access denied</title></head><body>\n". 51 'Access to this tool is restricted. Contact <a href="mailto:kdeugau@vianet.ca">Kris</a> '. 52 "for more information.</body></html>\n"; 53 exit; 54 } 55 55 56 56 my %webvar = parse_post(); … … 90 90 </form> 91 91 <hr><a href="admin.cgi?action=showpools">List IP Pools</a> for manual tweaking and updates 92 <hr><a href="admin.cgi?action=showusers">Manage users</a> (add/remove users; change 93 internal access controls - note that this does NOT include IP-based limits) 92 94 ); 93 95 } else { … … 123 125 printAndExit("Can't allocate from outside a free block!!\n") 124 126 if !$data[0]; 127 } elsif ($webvar{alloctype} =~ /^(.)i$/) { 128 $sth = $ip_dbh->prepare("select cidr from allocations where cidr >>='$cidr' and (type like '_d' or type like '_p')"); 129 $sth->execute; 130 @data = $sth->fetchrow_array; 131 # User deserves errors if user can't be bothered to find the pool and a free IP first. 132 printAndExit("Can't allocate static IP from outside a pool!!\n") 133 if !$data[0]; 125 134 } else { 126 135 $sth = $ip_dbh->prepare("select cidr from freeblocks where cidr >>='$cidr' and not (routed='n')"); … … 202 211 print "Allocation failed! IPDB::allocateBlock said:\n$msg\n"; 203 212 syslog "err", "($authuser) Allocation of '$webvar{cidr}' to '$webvar{custid}' as ". 204 "'$webvar{ type}' failed: '$msg'";213 "'$webvar{alloctype}' failed: '$msg'"; 205 214 } 206 215 } # done city check … … 267 276 syslog "notice", "$authuser updated pool IP $webvar{ip}"; 268 277 } 269 # showPool("$data[0]"); 270 #} else { 271 # print "webvar{action} check failed: $webvar{action}"; 278 } elsif ($webvar{action} eq 'showusers') { 279 print "Notes:<br>\n". 280 "<li>Admin users automatically get all other priviledges.\n". 281 "<hr>Add new user:<form action=admin.cgi method=POST>\n". 282 "Username: <input name=username><br>\n". 283 "Password: <input name=password> <input type=checkbox name=preenc>Password is pre-encrypted (MUST be crypt() encrypted)<br>\n". 284 "<input type=submit value='Add user'><input type=hidden name=action value=newuser></form>\n"; 285 286 print "<hr>Users with access:\n<table border=1>\n"; 287 print "<tr><td>Username</td><td>Add new</td><td>Change</td>". 288 "<td>Delete</td><td>Admin user</td></tr>\n". 289 "<form action=admin.cgi method=POST>\n"; 290 $sth = $ip_dbh->prepare("select username,acl from users order by username"); 291 $sth->execute; 292 while (my @data = $sth->fetchrow_array) { 293 print "<form action=admin.cgi method=POST><input type=hidden name=action value=updacl>". 294 qq(<tr><td>$data[0]<input type=hidden name=username value="$data[0]"></td><td>). 295 # Now for the fun bit. We have to pull apart the ACL field and 296 # output a bunch of checkboxes. 297 "<input type=checkbox name=add".($data[1] =~ /a/ ? ' checked=y' : ''). 298 "></td><td><input type=checkbox name=change".($data[1] =~ /c/ ? ' checked=y' : ''). 299 "></td><td><input type=checkbox name=del".($data[1] =~ /d/ ? ' checked=y' : ''). 300 "></td><td><input type=checkbox name=admin".($data[1] =~ /A/ ? ' checked=y' : ''). 301 qq(></td><td><input type=submit value="Update"></td></form>\n). 302 "<form action=admin.cgi method=POST><td><input type=hidden name=action value=deluser>". 303 "<input type=hidden name=username value=$data[0]>". 304 qq(<input type=submit value="Delete user"></tr></form>\n); 305 306 } 307 print "</table>\n"; 308 } elsif ($webvar{action} eq 'updacl') { 309 print "Updating ACL for $webvar{username}:<br>\n"; 310 my $acl = 'b'; 311 if ($webvar{admin} eq 'on') { 312 $acl .= "acdA"; 313 } else { 314 $acl .= ($webvar{add} eq 'on' ? 'a' : ''). 315 ($webvar{change} eq 'on' ? 'c' : ''). 316 ($webvar{del} eq 'on' ? 'd' : ''); 317 } 318 print "New ACL: $acl<br>\n"; 319 320 $sth = $ip_dbh->prepare("update users set acl='$acl' where username='$webvar{username}'"); 321 $sth->execute; 322 print "OK\n" if !$sth->err; 323 324 print qq(<hr><a href="admin.cgi?action=showusers">Back</a> to user listing\n); 325 326 } elsif ($webvar{action} eq 'newuser') { 327 print "Adding user $webvar{username}...\n"; 328 my $cr_pass = ($webvar{preenc} ? $webvar{password} : 329 crypt $webvar{password}, join('',('.','/',0..9,'A'..'Z','a'..'z')[rand 64, rand 64])); 330 $sth = $ip_dbh->prepare("insert into users (username,password,acl) values ". 331 "('$webvar{username}','$cr_pass','b')"); 332 $sth->execute; 333 if ($sth->err) { 334 print "<br>Error adding user: ".$sth->errstr; 335 } else { 336 print "OK\n"; 337 } 338 339 print qq(<hr><a href="admin.cgi?action=showusers">Back</a> to user listing\n); 340 341 } elsif ($webvar{action} eq 'deluser') { 342 print "Deleting user $webvar{username}.<br>\n"; 343 $sth = $ip_dbh->prepare("delete from users where username='$webvar{username}'"); 344 $sth->execute; 345 print "OK\n" if !$sth->err; 346 347 print qq(<hr><a href="admin.cgi?action=showusers">Back</a> to user listing\n); 348 349 } elsif ($webvar{action} ne '<NULL>') { 350 print "webvar{action} check failed: Don't know how to $webvar{action}"; 272 351 } 273 352 -
branches/dns/cgi-bin/extras/db2rwhois.pl
r146 r262 17 17 use NetAddr::IP; 18 18 use MyIPDB; 19 use Digest::MD5 qw(md5_hex); 19 20 20 21 $ENV{"PATH"} = "/bin;/usr/bin"; … … 41 42 # Note that this ASS-U-MEs that we do not add master IP blocks- 42 43 # there should probably be a separate system for doing that. 43 my $sth = $dbh->prepare("select *from masterblocks;");44 my $sth = $dbh->prepare("select cidr,ctime from masterblocks;"); 44 45 $sth->execute; 45 46 my $i=0; 46 47 GETMASTERS: while (my @data = $sth->fetchrow_array()) { 47 48 48 if ($data[0] =~ /^(192.168.0.0|172.16.0.0|10.0.0.0)/) {49 next GETMASTERS;50 }49 # if ($data[0] =~ /^(192.168.0.0|172.16.0.0|10.0.0.0)/) { 50 # next GETMASTERS; 51 # } 51 52 $masterblocks[$i] = new NetAddr::IP $data[0]; 52 53 … … 55 56 my $date; 56 57 chomp ($date = `/bin/date +"%Y%m%d"`); 58 my ($ctime,undef) = split /\s+/, $data[1]; 57 59 58 60 # Whew! Ugly little varmint. … … 73 75 "Admin-Contact: ISP-ARIN-HANDLE\n". 74 76 "Abuse-Contact: abuse\@example.com\n". 75 "Created: 20040308\n".77 "Created: $ctime\n". 76 78 "Updated: $date\n". 77 79 "Updated-By: noc\@example.com\n"; … … 87 89 # Make sure to remove the private netblocks from this. 88 90 # No use or point in broadcasting our use of them. 89 $sth = $dbh->prepare("select * from allocations where not (cidr <<= '192.168.0.0/16') and not (cidr <<= '172.16.0.0/12') and not (cidr <<= '10.0.0.0/8') and custid='6750400'"); 91 #$sth = $dbh->prepare("select * from allocations where not (cidr <<= '192.168.0.0/16') and not (cidr <<= '172.16.0.0/12') and not (cidr <<= '10.0.0.0/8')"); 92 # cidr,custid,type,city,description,notes,maskbits,circuitid,createstamp,modifystamp,newcustid 93 94 $sth = $dbh->prepare("select cidr,custid,type,city,description,createstamp,modifystamp from allocations"); 90 95 $sth->execute; 91 96 92 while (my @data= $sth->fetchrow_array()) {97 while (my ($cidr,$custid,$type,$city,$description,$ctime,$mtime) = $sth->fetchrow_array()) { 93 98 94 99 # We get master block info from @masterblocks. … … 105 110 # Updated-By: noc@example.com 106 111 107 # Get the "full" network number 108 my $net = new NetAddr::IP $ data[0];112 # Get the "full" network number - just in case. 113 my $net = new NetAddr::IP $cidr; 109 114 110 115 # Assumptions: All data in ipdb is public … … 121 126 or print "File open error: '$!' on '$rwhoisDataPath/$masterfilename'\n"; 122 127 123 # cidr custid type city description notes maskbits124 125 # Creation date in record to eventually be "correct"; near-term will126 # be master's creation date; immediate is today's date.127 my $date;128 chomp ($date = `/bin/date +"%Y%m%d"`);129 128 if ($data[4] =~ /^\s*$/) { $data[4] = 'Friendly ISP'; } 129 print "$type-type $net for $custid, created $ctime, modified $mtime\n"; 130 130 print MASTERFILE "---\nID: NETBLK-ISP.$master\n". 131 131 "Auth-Area: $master\n". … … 133 133 "IP-Network: $net\n". 134 134 "IP-Network-Block: ".$net->range."\n". 135 "Organization: $d ata[4]\n".135 "Organization: $description\n". 136 136 # "Tech-Contact: $data[9]\n". 137 137 "Tech-Contact: abuse\@example.com\n". 138 138 "Admin-Contact: ISP-ARIN-HANDLE\n". 139 "Created: $ date\n".140 "Updated: $ date\n".139 "Created: $ctime\n". 140 "Updated: $mtime\n". 141 141 "Updated-By: noc\@example.com\n"; 142 142 } … … 154 154 155 155 $dbh->disconnect; 156 157 # This doesn't work, with a vengeance. 158 #print qx{ /usr/bin/rwhois_indexer -c /etc/rwhoisd/rwhoisd.conf -i -v -s txt }; -
branches/dns/cgi-bin/ipdb.psql
r189 r262 23 23 24 24 CREATE TABLE "masterblocks" ( 25 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY 25 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY, 26 "ctime" timestamp DEFAULT now() 26 27 ); 27 28 … … 33 34 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY, 34 35 "maskbits" integer DEFAULT 128, 35 "city" character varying(30) DEFAULT '' 36 "city" character varying(30) DEFAULT '', 37 "ctime" timestamp DEFAULT now() 36 38 ); 37 39 … … 70 72 "circuitid" character varying(128) DEFAULT '' NOT NULL, 71 73 "newcustid" integer, 74 "createstamp" timestamp DEFAULT now(), 75 "modifystamp" timestamp DEFAULT now(), 72 76 CHECK (((available = 'y'::bpchar) OR (available = 'n'::bpchar))) 73 77 ); … … 86 90 "maskbits" integer DEFAULT 128, 87 91 "circuitid" character varying(128) DEFAULT '', 92 "createstamp" timestamp DEFAULT now(), 93 "modifystamp" timestamp DEFAULT now(), 88 94 "newcustid" integer 89 95 ); … … 112 118 113 119 CREATE TABLE "cities" ( 114 "city" character varying(30) DEFAULT '' NOT NULL PRIMARY KEY, 120 "id" serial NOT NULL PRIMARY KEY, 121 "city" character varying(30) DEFAULT '' NOT NULL, 115 122 "routing" character(1) DEFAULT 'n' NOT NULL 116 123 ); … … 119 126 GRANT ALL on "cities" to "kdeugau"; 120 127 GRANT ALL on "cities" to "ipdb"; 121 122 --123 -- Selected TOC Entries:124 --125 \connect - ipdb126 127 --128 -- TOC Entry ID 2 (OID 92809)129 --130 -- Name: alloctypes Type: TABLE Owner: ipdb131 --132 128 133 129 CREATE TABLE "alloctypes" ( … … 140 136 ); 141 137 142 --143 -- TOC Entry ID 3 (OID 92809)144 --145 -- Name: alloctypes Type: ACL Owner:146 --147 148 138 REVOKE ALL on "alloctypes" from PUBLIC; 149 139 GRANT ALL on "alloctypes" to "kdeugau"; 150 140 GRANT ALL on "alloctypes" to "ipdb"; 151 152 --153 -- Data for TOC Entry ID 4 (OID 92809)154 --155 -- Name: alloctypes Type: TABLE DATA Owner: ipdb156 --157 158 141 159 142 COPY "alloctypes" FROM stdin; … … 172 155 si Static IP - Server pool Server pool IP 20 6750400 173 156 wc Reserve for WAN blocks WAN IP blocks 200 6750400 174 wr Internal WAN block Internal WAN block 201 6750400175 pc Reserve for dynamic-route DSL netblocks Dynamic-route netblocks 202 6750400176 157 en End-use netblock End-use netblock 100 6750400 177 158 me Dialup netblock Dialup netblock 101 DIAL-RES … … 180 161 we Dynamic WiFi block Dynamic WiFi block 104 WL-RES 181 162 rm Routing Routed netblock 500 6750400 182 pr Dynamic-route DSL netblock Dynamic-route DSL 203 163 pc Reserve for dynamic-route DSL netblocks Dynamic-route netblocks 201 6750400 164 pr Dynamic-route DSL netblock Dynamic-route DSL 221 165 wr WAN block WAN block 220 6750400 183 166 \. 167 168 -- 169 -- Trigger and matching function to update modifystamp on allocations, poolips 170 -- 171 CREATE FUNCTION up_modtime () RETURNS OPAQUE AS ' 172 BEGIN 173 NEW.modifystamp := ''now''; 174 RETURN NEW; 175 END; 176 ' LANGUAGE 'plpgsql'; 177 178 CREATE TRIGGER up_modtime BEFORE UPDATE ON allocations 179 FOR EACH ROW EXECUTE PROCEDURE up_modtime(); 180 181 CREATE TRIGGER up_modtime BEFORE UPDATE ON poolips 182 FOR EACH ROW EXECUTE PROCEDURE up_modtime(); 183 184 -- 185 -- User data table - required for proper ACLs 186 -- 187 188 CREATE TABLE "users" ( 189 "username" varchar(16) NOT NULL PRIMARY KEY, 190 "password" varchar(16) DEFAULT '', 191 "acl" varchar(16) DEFAULT 'b' 192 ); 193 194 CREATE TABLE "dns" ( 195 "ip" inet NOT NULL PRIMARY KEY, 196 "hostname" character varying(128), 197 "auto" character(1) DEFAULT 'y' 198 ); -
branches/dns/cgi-bin/main.cgi
r214 r262 22 22 openlog "IPDB","pid","local2"; 23 23 24 # Collect the username from HTTP auth. If undefined, we're in a test environment. 24 # Collect the username from HTTP auth. If undefined, we're in 25 # a test environment, or called without a username. 25 26 my $authuser; 26 27 if (!defined($ENV{'REMOTE_USER'})) { … … 39 40 ($ip_dbh,$errstr) = connectDB_My; 40 41 if (!$ip_dbh) { 41 printAndExit("Database error: $errstr\n");42 exitError("Database error: $errstr\n"); 42 43 } 43 44 initIPDBGlobals($ip_dbh); 44 45 45 #prototypes 46 sub viewBy($$); # feed it the category and query 47 sub queryResults($$$); # args is the sql, the page# and the rowCount 48 # Needs rewrite/rename 49 sub countRows($); # returns first element of first row of passed SQL 50 # Only usage passes "select count(*) ..." 46 # Headerize! Make sure we replace the $$EXTRA0$$ bit as needed. 47 printHeader('', ($IPDBacl{$authuser} =~ /a/ ? 48 '<td align=right><a href="/ip/cgi-bin/main.cgi?action=assign">Add new assignment</a>' : '' 49 )); 50 51 51 52 52 # Global variables 53 my $RESULTS_PER_PAGE = 50;54 53 my %webvar = parse_post(); 55 54 cleanInput(\%webvar); … … 64 63 if($webvar{action} eq 'index') { 65 64 showSummary(); 65 } elsif ($webvar{action} eq 'addmaster') { 66 if ($IPDBacl{$authuser} !~ /a/) { 67 printError("You shouldn't have been able to get here. Access denied."); 68 } else { 69 open HTML, "<../addmaster.html"; 70 print while <HTML>; 71 } 66 72 } elsif ($webvar{action} eq 'newmaster') { 67 printHeader(''); 68 69 my $cidr = new NetAddr::IP $webvar{cidr}; 70 71 print "<div type=heading align=center>Adding $cidr as master block....</div>\n"; 72 73 # Allow transactions, and raise an exception on errors so we can catch it later. 74 # Use local to make sure these get "reset" properly on exiting this block 75 local $ip_dbh->{AutoCommit} = 0; 76 local $ip_dbh->{RaiseError} = 1; 77 78 # Wrap the SQL in a transaction 79 eval { 80 $sth = $ip_dbh->prepare("insert into masterblocks values ('$webvar{cidr}')"); 81 $sth->execute; 73 74 if ($IPDBacl{$authuser} !~ /a/) { 75 printError("You shouldn't have been able to get here. Access denied."); 76 } else { 77 78 my $cidr = new NetAddr::IP $webvar{cidr}; 79 80 print "<div type=heading align=center>Adding $cidr as master block....</div>\n"; 81 82 # Allow transactions, and raise an exception on errors so we can catch it later. 83 # Use local to make sure these get "reset" properly on exiting this block 84 local $ip_dbh->{AutoCommit} = 0; 85 local $ip_dbh->{RaiseError} = 1; 86 87 # Wrap the SQL in a transaction 88 eval { 89 $sth = $ip_dbh->prepare("insert into masterblocks values ('$webvar{cidr}')"); 90 $sth->execute; 82 91 83 92 # Unrouted blocks aren't associated with a city (yet). We don't rely on this … … 85 94 # Thus the "routed" flag. 86 95 87 $sth = $ip_dbh->prepare("insert into freeblocks (cidr,maskbits,city,routed)".96 $sth = $ip_dbh->prepare("insert into freeblocks (cidr,maskbits,city,routed)". 88 97 " values ('$webvar{cidr}',".$cidr->masklen.",'<NULL>','n')"); 89 $sth->execute; 90 91 # If we get here, everything is happy. Commit changes. 92 $ip_dbh->commit; 93 }; # end eval 94 95 if ($@) { 96 carp "Transaction aborted because $@"; 97 eval { $ip_dbh->rollback; }; 98 syslog "err", "Could not add master block '$webvar{cidr}' to database: '$@'"; 99 printError("Could not add master block $webvar{cidr} to database: $@"); 100 } else { 101 print "<div type=heading align=center>Success!</div>\n"; 102 syslog "info", "$authuser added master block $webvar{cidr}"; 103 } 98 $sth->execute; 99 100 # If we get here, everything is happy. Commit changes. 101 $ip_dbh->commit; 102 }; # end eval 103 104 if ($@) { 105 carp "Transaction aborted because $@"; 106 eval { $ip_dbh->rollback; }; 107 syslog "err", "Could not add master block '$webvar{cidr}' to database: '$@'"; 108 printError("Could not add master block $webvar{cidr} to database: $@"); 109 } else { 110 print "<div type=heading align=center>Success!</div>\n"; 111 syslog "info", "$authuser added master block $webvar{cidr}"; 112 } 113 114 } # ACL check 104 115 105 116 } # end add new master … … 113 124 elsif($webvar{action} eq 'listpool') { 114 125 listPool(); 115 }116 elsif($webvar{action} eq 'search') {117 printHeader('');118 if (!$webvar{input}) {119 # No search term. Display everything.120 viewBy('all', '');121 } else {122 # Search term entered. Display matches.123 # We should really sanitize $webvar{input}, no?124 viewBy($webvar{searchfor}, $webvar{input});125 }126 126 } 127 127 … … 153 153 # which is not in any way guaranteed to provide anything useful. 154 154 else { 155 printHeader('');156 155 my $rnd = rand 500; 157 156 my $boing = sprintf("%.2f", rand 500); … … 171 170 print qq(<div align=right style="position: absolute; right: 30px;">). 172 171 qq(<a href="/ip/cgi-bin/admin.cgi">Admin tools</a></div><br>\n) 173 if $ authuser =~ /kdeugau|jodyh|jipp/;172 if $IPDBacl{$authuser} =~ /A/; 174 173 175 174 # We print the footer here, so we don't have to do it elsewhere. … … 181 180 182 181 183 sub viewBy($$) {184 my ($category,$query) = @_;185 186 # Local variables187 my $sql;188 189 #print "<pre>\n";190 191 #print "start querysub: query '$query'\n";192 # this may happen with more than one subcategory. Unlikely, but possible.193 194 # Calculate start point for LIMIT clause195 my $offset = ($webvar{page}-1)*$RESULTS_PER_PAGE;196 197 # Possible cases:198 # 1) Partial IP/subnet. Treated as "first-three-octets-match" in old IPDB,199 # I should be able to handle it similarly here.200 # 2a) CIDR subnet. Treated more or less as such in old IPDB.201 # 2b) CIDR netmask. Not sure how it's treated.202 # 3) Customer ID. Not handled in old IPDB203 # 4) Description.204 # 5) Invalid data which might be interpretable as an IP or something, but205 # which probably shouldn't be for reasons of sanity.206 207 if ($category eq 'all') {208 209 print qq(<div class="heading">Showing all netblock and static-IP allocations</div><br>\n);210 211 # Need to assemble SQL query in this order to avoid breaking things.212 $sql = "select cidr,custid,type,city,description from searchme";213 my $count = countRows("select count(*) from ($sql) foo");214 $sql .= " order by cidr limit $RESULTS_PER_PAGE offset $offset";215 queryResults($sql, $webvar{page}, $count);216 217 } elsif ($category eq 'cust') {218 219 print qq(<div class="heading">Searching for Customer IDs containing '$query'</div><br>\n);220 221 # Query for a customer ID. Note that we can't restrict to "numeric-only"222 # as we have non-numeric custIDs in the legacy data. :/223 $sql = "select cidr,custid,type,city,description from searchme where custid ilike '%$query%'";224 my $count = countRows("select count(*) from ($sql) foo");225 $sql .= " order by cidr limit $RESULTS_PER_PAGE offset $offset";226 queryResults($sql, $webvar{page}, $count);227 228 } elsif ($category eq 'desc') {229 230 print qq(<div class="heading">Searching for descriptions containing '$query'</div><br>\n);231 # Query based on description (includes "name" from old DB).232 $sql = "select cidr,custid,type,city,description from searchme where description ilike '%$query%'";233 my $count = countRows("select count(*) from ($sql) foo");234 $sql .= " order by cidr limit $RESULTS_PER_PAGE offset $offset";235 queryResults($sql, $webvar{page}, $count);236 237 } elsif ($category =~ /ipblock/) {238 239 # Query is for a partial IP, a CIDR block in some form, or a flat IP.240 print qq(<div class="heading">Searching for IP-based matches on '$query'</div><br>\n);241 242 $query =~ s/\s+//g;243 if ($query =~ /\//) {244 # 209.91.179/26 should show all /26 subnets in 209.91.179245 my ($net,$maskbits) = split /\//, $query;246 if ($query =~ /^(\d{1,3}\.){3}\d{1,3}\/\d{2}$/) {247 # /0->/9 are silly to worry about right now. I don't think248 # we'll be getting a class A anytime soon. <g>249 $sql = "select cidr,custid,type,city,description from searchme where cidr='$query'";250 queryResults($sql, $webvar{page}, 1);251 } else {252 print "Finding all blocks with netmask /$maskbits, leading octet(s) $net<br>\n";253 # Partial match; beginning of subnet and maskbits are provided254 $sql = "select cidr,custid,type,city,description from searchme where ".255 "text(cidr) like '$net%' and text(cidr) like '%$maskbits'";256 my $count = countRows("select count(*) from ($sql) foo");257 $sql .= " order by cidr limit $RESULTS_PER_PAGE offset $offset";258 queryResults($sql, $webvar{page}, $count);259 }260 } elsif ($query =~ /^(\d{1,3}\.){3}\d{1,3}$/) {261 # Specific IP address match262 my $sfor = new NetAddr::IP $query;263 # We do this convoluted roundabout way of finding things in order264 # to bring up matches for single IPs that are within a static block;265 # we want to show both the "container" block and the static IP itself.266 $sth = $ip_dbh->prepare("select cidr from searchme where cidr >>= '$sfor'");267 $sth->execute;268 while (my @data = $sth->fetchrow_array()) {269 my $cidr = new NetAddr::IP $data[0];270 queryResults("select cidr,custid,type,city,description from searchme where ".271 "cidr='$cidr'", $webvar{page}, 1);272 }273 } elsif ($query =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.?$/) {274 print "Finding matches where the first three octets are $query<br>\n";275 $sql = "select cidr,custid,type,city,description from searchme where ".276 "text(cidr) like '$query%'";277 my $count = countRows("select count(*) from ($sql) foo");278 $sql .= " order by cidr limit $RESULTS_PER_PAGE offset $offset";279 queryResults($sql, $webvar{page}, $count);280 } else {281 # This shouldn't happen, but if it does, whoever gets it deserves what they get...282 printError("Invalid query.");283 }284 } else {285 # This shouldn't happen, but if it does, whoever gets it deserves what they get...286 printError("Invalid searchfor.");287 }288 } # viewBy289 290 291 182 # args are: a reference to an array with the row to be printed and the 292 183 # class(stylesheet) to use for formatting. … … 313 204 314 205 315 # Display certain types of search query. Note that this can't be316 # cleanly reused much of anywhere else as the data isn't neatly tabulated.317 # This is tied to the search sub tightly enough I may just gut it and provide318 # more appropriate tables directly as needed.319 sub queryResults($$$) {320 my ($sql, $pageNo, $rowCount) = @_;321 my $offset = 0;322 $offset = $1 if($sql =~ m/.*limit\s+(.*),.*/);323 324 my $sth = $ip_dbh->prepare($sql);325 $sth->execute();326 327 startTable('Allocation','CustID','Type','City','Description/Name');328 my $count = 0;329 330 while (my @data = $sth->fetchrow_array) {331 # cidr,custid,type,city,description332 # Prefix subblocks with "Sub "333 my @row = ( (($data[2] =~ /^.r$/) ? 'Sub ' : '').334 qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>),335 $data[1], $disp_alloctypes{$data[2]}, $data[3], $data[4]);336 # Allow listing of pool if desired/required.337 if ($data[2] =~ /^.[pd]$/) {338 $row[0] .= ' <a href="/ip/cgi-bin/main.cgi?action=listpool'.339 "&pool=$data[0]\">List IPs</a>";340 }341 printRow(\@row, 'color1', 1) if ($count%2==0);342 printRow(\@row, 'color2', 1) if ($count%2!=0);343 $count++;344 }345 346 # Have to think on this call, it's primarily to clean up unfetched rows from a select.347 # In this context it's probably a good idea.348 $sth->finish();349 350 my $upper = $offset+$count;351 print "<tr><td colspan=10 bgcolor=white class=regular>Records found: $rowCount<br><i>Displaying: $offset - $upper</i></td></tr>\n";352 print "</table></center>\n";353 354 # print the page thing..355 if ($rowCount > $RESULTS_PER_PAGE) {356 my $pages = ceil($rowCount/$RESULTS_PER_PAGE);357 print qq(<div class="center"> Page: );358 for (my $i = 1; $i <= $pages; $i++) {359 if ($i == $pageNo) {360 print "<b>$i </b>\n";361 } else {362 print qq(<a href="/ip/cgi-bin/main.cgi?page=$i&input=$webvar{input}&action=search&searchfor=$webvar{searchfor}">$i</a> \n);363 }364 }365 print "</div>";366 }367 } # queryResults368 369 370 206 # Prints table headings. Accepts any number of arguments; 371 207 # each argument is a table heading. … … 380 216 381 217 382 # Return first element of passed SQL query383 sub countRows($) {384 my $sth = $ip_dbh->prepare($_[0]);385 $sth->execute();386 my @a = $sth->fetchrow_array();387 $sth->finish();388 return $a[0];389 }390 391 392 218 # Initial display: Show master blocks with total allocated subnets, total free subnets 393 219 sub showSummary { 394 # this is horrible-ugly-bad and will Go Away real soon now(TM)395 print "Content-type: text/html\n\n";396 220 397 221 startTable('Master netblock', 'Routed netblocks', 'Allocated netblocks', … … 420 244 421 245 # Count the free blocks. 422 $sth = $ip_dbh->prepare("select count(*) from freeblocks where cidr <<= ?"); 246 $sth = $ip_dbh->prepare("select count(*) from freeblocks where cidr <<= ? and ". 247 "(routed='y' or routed='n')"); 423 248 foreach my $master (@masterblocks) { 424 249 $sth->execute("$master"); … … 428 253 429 254 # Find the largest free block in each master 430 $sth = $ip_dbh->prepare("select maskbits from freeblocks where cidr <<= ? order by maskbits limit 1"); 255 $sth = $ip_dbh->prepare("select maskbits from freeblocks where cidr <<= ? and ". 256 "(routed='y' or routed='n') order by maskbits limit 1"); 431 257 foreach my $master (@masterblocks) { 432 258 $sth->execute("$master"); … … 448 274 } 449 275 print "</table>\n"; 450 print qq(<a href="/ip/addmaster.shtml">Add new master block</a><br><br>\n); 276 if ($IPDBacl{$authuser} =~ /a/) { 277 print qq(<a href="/ip/cgi-bin/main.cgi?action=addmaster">Add new master block</a><br><br>\n); 278 } 451 279 print "Note: Free blocks noted here include both routed and unrouted blocks.\n"; 452 280 … … 460 288 # else should follow. YMMV.) 461 289 sub showMaster { 462 printHeader('');463 290 464 291 print qq(<center><div class="heading">Summarizing routed blocks for ). … … 502 329 503 330 # Count the free blocks. 504 $sth = $ip_dbh->prepare("select count(*) from freeblocks where cidr <<= ?"); 331 $sth = $ip_dbh->prepare("select count(*) from freeblocks where cidr <<= ? and ". 332 "(routed='y' or routed='n')"); 505 333 foreach my $master (@localmasters) { 506 334 $sth->execute("$master"); … … 510 338 511 339 # Get the size of the largest free block 512 $sth = $ip_dbh->prepare("select maskbits from freeblocks where cidr <<= ? order by maskbits limit 1"); 340 $sth = $ip_dbh->prepare("select maskbits from freeblocks where cidr <<= ? and ". 341 "(routed='y' or routed='n') order by maskbits limit 1"); 513 342 foreach my $master (@localmasters) { 514 343 $sth->execute("$master"); … … 534 363 print qq(<hr width="60%"><center><div class="heading">No allocations in ). 535 364 qq($master.</div>\n). 536 qq(<form action="/ip/cgi-bin/main.cgi" method=POST>\n). 537 qq(<input type=hidden name=action value="delete">\n). 538 qq(<input type=hidden name=block value="$master">\n). 539 qq(<input type=hidden name=alloctype value="mm">\n). 540 qq(<input type=submit value=" Remove this master ">\n). 541 qq(</form></center>\n); 365 ($IPDBacl{$authuser} =~ /d/ ? 366 qq(<form action="/ip/cgi-bin/main.cgi" method=POST>\n). 367 qq(<input type=hidden name=action value="delete">\n). 368 qq(<input type=hidden name=block value="$master">\n). 369 qq(<input type=hidden name=alloctype value="mm">\n). 370 qq(<input type=submit value=" Remove this master ">\n). 371 qq(</form></center>\n) : 372 ''); 542 373 543 374 } # end check for existence of routed blocks in master … … 573 404 # not have anything useful to spew. 574 405 sub showRBlock { 575 printHeader('');576 406 577 407 my $master = new NetAddr::IP $webvar{block}; … … 621 451 print qq(<hr width="60%"><center><div class="heading">No allocations in ). 622 452 qq($master.</div></center>\n). 623 qq(<form action="/ip/cgi-bin/main.cgi" method=POST>\n). 624 qq(<input type=hidden name=action value="delete">\n). 625 qq(<input type=hidden name=block value="$master">\n). 626 qq(<input type=hidden name=alloctype value="rm">\n). 627 qq(<input type=submit value=" Remove this block ">\n). 628 qq(</form>\n); 453 ($IPDBacl{$authuser} =~ /d/ ? 454 qq(<form action="/ip/cgi-bin/main.cgi" method=POST>\n). 455 qq(<input type=hidden name=action value="delete">\n). 456 qq(<input type=hidden name=block value="$master">\n). 457 qq(<input type=hidden name=alloctype value="rm">\n). 458 qq(<input type=submit value=" Remove this block ">\n). 459 qq(</form>\n) : 460 ''); 629 461 } 630 462 … … 645 477 # Include some HairyPerl(TM) to prefix subblocks with "Sub " 646 478 my @row = ((($data[1] ne 'y' && $data[1] ne 'n') ? 'Sub ' : ''). 647 qq(<a href="/ip/cgi-bin/main.cgi?action=assign&block=$cidr&fbtype=$data[1]">$cidr</a>),479 ($IPDBacl{$authuser} =~ /a/ ? qq(<a href="/ip/cgi-bin/main.cgi?action=assign&block=$cidr&fbtype=$data[1]">$cidr</a>) : $cidr), 648 480 $cidr->range); 649 481 printRow(\@row, 'color1') if ($count%2 == 0); … … 658 490 # List the IPs used in a pool 659 491 sub listPool { 660 printHeader('');661 492 662 493 my $cidr = new NetAddr::IP $webvar{pool}; … … 704 535 my @row = ( qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>), 705 536 $data[1],$data[2],$data[3], 706 ( ( $data[2] eq 'n') ?537 ( (($data[2] eq 'n') && ($IPDBacl{$authuser} =~ /d/)) ? 707 538 ("<a href=\"/ip/cgi-bin/main.cgi?action=delete&block=$data[0]&". 708 539 "alloctype=$data[4]\">Unassign this IP</a>") : … … 721 552 # be one of two templates, and the lists come from the database. 722 553 sub assignBlock { 723 printHeader(''); 554 555 if ($IPDBacl{$authuser} !~ /a/) { 556 printError("You shouldn't have been able to get here. Access denied."); 557 return; 558 } 724 559 725 560 my $html; … … 799 634 # Take info on requested IP assignment and see what we can provide. 800 635 sub confirmAssign { 801 printHeader(''); 636 if ($IPDBacl{$authuser} !~ /a/) { 637 printError("You shouldn't have been able to get here. Access denied."); 638 return; 639 } 802 640 803 641 my $cidr; … … 958 796 # Do the work of actually inserting a block in the database. 959 797 sub insertAssign { 798 if ($IPDBacl{$authuser} !~ /a/) { 799 printError("You shouldn't have been able to get here. Access denied."); 800 return; 801 } 960 802 # Some things are done more than once. 961 printHeader('');962 803 return if !validateInput(); 963 804 … … 973 814 print qq(<div class="center"><div class="heading">The IP $msg has been allocated to customer $webvar{custid}</div></div>); 974 815 # Notify tech@example.com 975 mailNotify('tech@example.com',"ADDED: $disp_alloctypes{$webvar{alloctype}} allocation",976 "$disp_alloctypes{$webvar{alloctype}} $msg allocated to customer $webvar{custid}\n".977 "Description: $webvar{desc}\n\nAllocated by: $authuser\n");816 # mailNotify('tech@example.com',"ADDED: $disp_alloctypes{$webvar{alloctype}} allocation", 817 # "$disp_alloctypes{$webvar{alloctype}} $msg allocated to customer $webvar{custid}\n". 818 # "Description: $webvar{desc}\n\nAllocated by: $authuser\n"); 978 819 } else { 979 820 print qq(<div class="center"><div class="heading">The block $webvar{fullcidr} was ). … … 981 822 } 982 823 syslog "notice", "$authuser allocated '$webvar{fullcidr}' to '$webvar{custid}' as ". 983 "'$webvar{alloctype}' ";824 "'$webvar{alloctype}' ($msg)"; 984 825 } else { 985 826 syslog "err", "Allocation of '$webvar{fullcidr}' to '$webvar{custid}' as ". … … 1057 898 # action=edit 1058 899 sub edit { 1059 printHeader('');1060 900 1061 901 my $sql; … … 1064 904 # because I'm lazy, we'll try to make the SELECT's bring out identical)ish) data 1065 905 if ($webvar{block} =~ /\/32$/) { 1066 $sql = "select ip,custid,type,city,circuitid,description,notes from poolips where ip='$webvar{block}'";906 $sql = "select ip,custid,type,city,circuitid,description,notes,modifystamp from poolips where ip='$webvar{block}'"; 1067 907 } else { 1068 $sql = "select cidr,custid,type,city,circuitid,description,notes from allocations where cidr='$webvar{block}'"908 $sql = "select cidr,custid,type,city,circuitid,description,notes,modifystamp from allocations where cidr='$webvar{block}'" 1069 909 } 1070 910 … … 1076 916 # Clean up extra whitespace on alloc type 1077 917 $data[2] =~ s/\s//; 1078 1079 ##fixme LEGACY CODE1080 # Postfix "i" on pool IP types1081 if ($data[2] =~ /^[cdsmw]$/) {1082 $data[2] .= "i";1083 }1084 918 1085 919 open (HTML, "../editDisplay.html") … … 1093 927 # Needs thinking. Have to allow changes to city to correct errors, no? 1094 928 $html =~ s/\$\$BLOCK\$\$/$webvar{block}/g; 1095 $html =~ s/\$\$CITY\$\$/$data[3]/g; 929 930 if ($IPDBacl{$authuser} =~ /c/) { 931 $html =~ s/\$\$CUSTID\$\$/<input type=text name=custid value="$data[1]" maxlength=15 class="regular">/; 1096 932 1097 933 # Screw it. Changing allocation types gets very ugly VERY quickly- especially … … 1102 938 1103 939 ##fixme The check here should be built from the database 1104 if ($data[2] =~ /^.[ne]$/) {1105 # Block that can be changed1106 my $blockoptions = "<select name=alloctype><option".940 if ($data[2] =~ /^.[ne]$/) { 941 # Block that can be changed 942 my $blockoptions = "<select name=alloctype><option". 1107 943 (($data[2] eq 'me') ? ' selected' : '') ." value='me'>Dialup netblock</option>\n<option". 1108 (($data[2] eq 'de') ? ' selected' : '') ." value='de'>Dynamic DSL netblock</option>\n<option". (($data[2] eq 'dc') ? ' selected' : '') ." value='dc'>Dynamic cable netblock</option>\n<option".1109 (($data[2] eq 'ce') ? ' selected' : '') ." value='ce'>Dynamic cable netblock</option>\n<option". (($data[2] eq 'dc') ? ' selected' : '') ." value='dc'>Dynamic cable netblock</option>\n<option".1110 (($data[2] eq 'we') ? ' selected' : '') ." value='we'>Dynamic wireless netblock</option>\n<option". (($data[2] eq 'dc') ? ' selected' : '') ." value='dc'>Dynamic cable netblock</option>\n<option".944 (($data[2] eq 'de') ? ' selected' : '') ." value='de'>Dynamic DSL netblock</option>\n<option". 945 (($data[2] eq 'ce') ? ' selected' : '') ." value='ce'>Dynamic cable netblock</option>\n<option". 946 (($data[2] eq 'we') ? ' selected' : '') ." value='we'>Dynamic wireless netblock</option>\n<option". 1111 947 (($data[2] eq 'cn') ? ' selected' : '') ." value='cn'>Customer netblock</option>\n<option". 1112 948 (($data[2] eq 'en') ? ' selected' : '') ." value='en'>End-use netblock</option>\n<option". 1113 949 (($data[2] eq 'in') ? ' selected' : '') ." value='in'>Internal netblock</option>\n". 1114 950 "</select>\n"; 1115 $html =~ s/\$\$TYPESELECT\$\$/$blockoptions/g; 951 $html =~ s/\$\$TYPESELECT\$\$/$blockoptions/g; 952 } else { 953 $html =~ s/\$\$TYPESELECT\$\$/$disp_alloctypes{$data[2]}<input type=hidden name=alloctype value="$data[2]">/g; 954 } 955 $html =~ s/\$\$CITY\$\$/<input type=text name=city value="$data[3]">/g; 956 $html =~ s/\$\$CIRCID\$\$/<input type="text" name="circid" value="$data[4]" maxlength=64 size=64 class="regular">/g; 957 $html =~ s/\$\$DESC\$\$/<input type="text" name="desc" value="$data[5]" maxlength=64 size=64 class="regular">/g; 958 $html =~ s|\$\$NOTES\$\$|<textarea rows="8" cols="64" name="notes" class="regular">$data[6]</textarea>|g; 1116 959 } else { 1117 $html =~ s/\$\$TYPESELECT\$\$/$disp_alloctypes{$data[2]}<input type=hidden name=alloctype value="$data[2]">/g; 1118 } 1119 1120 # These can be modified, although CustID changes may get ignored. 1121 $html =~ s/\$\$CUSTID\$\$/$data[1]/g; 1122 $html =~ s/\$\$TYPE\$\$/$data[2]/g; 1123 $html =~ s/\$\$CIRCID\$\$/$data[4]/g; 1124 $html =~ s/\$\$DESC\$\$/$data[5]/g; 1125 $html =~ s/\$\$NOTES\$\$/$data[6]/g; 960 $html =~ s/\$\$CUSTID\$\$/$data[1]/g; 961 $html =~ s/\$\$TYPESELECT\$\$/$disp_alloctypes{$data[2]}/g; 962 $html =~ s/\$\$CITY\$\$/$data[3]/g; 963 $html =~ s/\$\$CIRCID\$\$/$data[4]/g; 964 $html =~ s/\$\$DESC\$\$/$data[5]/g; 965 $html =~ s/\$\$NOTES\$\$/$data[6]/g; 966 } 967 my ($lastmod,undef) = split /\s+/, $data[7]; 968 $html =~ s/\$\$LASTMOD\$\$/$lastmod/g; 969 970 # Allows us to "correctly" colour backgrounds in table 971 my $i=1; 972 973 # More ACL trickery - we can live with forms that don't submit, 974 # but we can't leave the extra table rows there, and we *really* 975 # can't leave the submit buttons there. 976 my $updok = ''; 977 if ($IPDBacl{$authuser} =~ /c/) { 978 $updok = qq(<tr class="color$i"><td colspan=2><div class="center">). 979 qq(<input type="submit" value=" Update this block " class="regular">). 980 "</div></td></tr></form>\n"; 981 $i++; 982 } 983 $html =~ s/\$\$UPDOK\$\$/$updok/g; 984 985 my $delok = ''; 986 if ($IPDBacl{$authuser} =~ /d/) { 987 $delok = qq(<form method="POST" action="main.cgi"> 988 <tr class="color$i"><td colspan=2 class="regular"><div class=center> 989 <input type="hidden" name="action" value="delete"> 990 <input type="hidden" name="block" value="$webvar{block}"> 991 <input type="hidden" name="alloctype" value="$data[2]"> 992 <input type=submit value=" Delete this block "> 993 </div></td></tr>); 994 } 995 $html =~ s/\$\$DELOK\$\$/$delok/; 1126 996 1127 997 print $html; … … 1133 1003 # action=update 1134 1004 sub update { 1135 printHeader('');1136 1005 1137 1006 # Make sure incoming data is in correct format - custID among other things. 1138 validateInput;1007 return if !validateInput; 1139 1008 1140 1009 # SQL transaction wrapper … … 1143 1012 my $sql; 1144 1013 if (my $pooltype = ($webvar{alloctype} =~ /^(.)i$/) ) { 1145 # Note the hack ( available='n' ) to work around "update" additions1146 # to static IP space. Eww.1147 1014 $sql = "update poolips set custid='$webvar{custid}',notes='$webvar{notes}',". 1148 "circuitid='$webvar{circid}',description='$webvar{desc}', available='n' ".1015 "circuitid='$webvar{circid}',description='$webvar{desc}',city='$webvar{city}' ". 1149 1016 "where ip='$webvar{block}'"; 1150 1017 } else { … … 1194 1061 # Delete an allocation. 1195 1062 sub remove { 1196 printHeader(''); 1063 if ($IPDBacl{$authuser} !~ /d/) { 1064 printError("You shouldn't have been able to get here. Access denied."); 1065 return; 1066 } 1067 1197 1068 #show confirm screen. 1198 1069 open HTML, "../confirmRemove.html" … … 1284 1155 # Remove IPs from pool listing if necessary 1285 1156 sub finalDelete { 1286 printHeader(''); 1157 if ($IPDBacl{$authuser} !~ /d/) { 1158 printError("You shouldn't have been able to get here. Access denied."); 1159 return; 1160 } 1287 1161 1288 1162 my ($code,$msg) = deleteBlock($ip_dbh, $webvar{block}, $webvar{alloctype}); … … 1292 1166 syslog "notice", "$authuser deallocated '$webvar{alloctype}'-type netblock $webvar{block}"; 1293 1167 # Notify tech@ when a block/IP is deallocated 1294 mailNotify('tech@example.com',"REMOVED: $disp_alloctypes{$webvar{alloctype}} $webvar{block}",1295 "$disp_alloctypes{$webvar{alloctype}} $webvar{block} deallocated by $authuser\n");1168 # mailNotify('tech@example.com',"REMOVED: $disp_alloctypes{$webvar{alloctype}} $webvar{block}", 1169 # "$disp_alloctypes{$webvar{alloctype}} $webvar{block} deallocated by $authuser\n"); 1296 1170 } else { 1297 1171 if ($webvar{alloctype} =~ /^.i$/) { … … 1307 1181 1308 1182 1183 sub exitError { 1184 my $errStr = $_[0]; 1185 printHeader('',''); 1186 print qq(<center><p class="regular"> $errStr </p> 1187 <input type="button" value="Back" onclick="history.go(-1)"> 1188 </center> 1189 ); 1190 printFooter(); 1191 exit; 1192 } # errorExit 1193 1194 1309 1195 # Just in case we manage to get here. 1310 1196 exit 0; -
branches/dns/changes.html
r139 r262 12 12 <tr><td class="heading" colspan=2>Changes to the IPDB</td><tr> 13 13 14 <tr class="color2"> 15 <td valign=top>03/10/2005</td> 16 <td>Finally! Support for "container"/"reserve" netblocks to make tracking superblocks like 17 209.91.191.0/24 easier. Also supports "dynamically routed DSL netblocks"; ie, 18 netblock-aligned chunks of static DSL IPs with netblock-ish subnet masks such as 19 209.91.186.0/25. 20 </td></tr> 21 <tr class="color1"> 22 <td valign=top>02/09/2005</td> 23 <td>Pool handling has been cleaned up - all PPP-ish pools (modem, DSL, WiFi) now generate a 24 full list of IPs rather than reserving the network, gateway, and broadcast IPs necessary on 25 a "real" subnet. They will also not display this incorrect and useless information. 26 </td></tr> 14 27 <tr class="color2"> 15 28 <td valign=top>01/27/2005</td> -
branches/dns/editDisplay.html
r74 r262 8 8 <tr class="color1"><td class=heading>IP block:</td><td class="regular">$$BLOCK$$</td></tr> 9 9 10 <tr class="color2"><td class=heading>City:</td><td class="regular"> 11 <input type=text name=city value="$$CITY$$"></td></tr> 10 <tr class="color2"><td class=heading>City:</td><td class="regular">$$CITY$$</td></tr> 12 11 13 12 <tr class="color1"><td class=heading>Type:</td><td class=regular>$$TYPESELECT$$</td></tr> 14 13 15 <tr class="color2"><td class=heading>CustID:</td><td class="regular"> 16 <input type=text name=custid value="$$CUSTID$$" maxlength=15 class="regular"></td></tr> 14 <tr class="color2"><td class=heading>CustID:</td><td class="regular">$$CUSTID$$</td></tr> 17 15 18 <tr class="color1"><td class="heading">Circuit ID:</td><td class="regular"> 19 <input type="text" name="circid" value="$$CIRCID$$" maxlength=64 size=64 class="regular"></td></tr> 16 <tr class="color1"><td class=heading>Last modified:</td><td class=regular>$$LASTMOD$$</td></tr> 20 17 21 <tr class="color2"><td class="heading">Description/Name:</td><td class="regular"> 22 <input type="text" name="desc" value="$$DESC$$" maxlength=64 size=64 class="regular"></td></tr> 18 <tr class="color2"><td class="heading">Circuit ID:</td><td class="regular">$$CIRCID$$</td></tr> 23 19 24 <tr class="color1"><td class="heading" valign="top">Notes:</td><td class="regular"> 25 <textarea rows="8" cols="64" name="notes" class="regular">$$NOTES$$</textarea></td></tr> 20 <tr class="color1"><td class="heading">Description/Name:</td><td class="regular">$$DESC$$</td></tr> 26 21 27 <tr class="color2"><td colspan=2 class=regular><div class="center"> 28 <input type="submit" value=" Update this block " class="regular"> 29 </div></td></tr></form> 30 <form method="POST" action="main.cgi"> 31 <tr class="color1"><td colspan=2 class="regular"><div class=center> 32 <input type="hidden" name="action" value="delete"> 33 <input type="hidden" name="block" value="$$BLOCK$$"> 34 <input type="hidden" name="alloctype" value="$$TYPE$$"> 35 <input type=submit value=" Delete this block "> 36 </div></td></tr> 22 <tr class="color2"><td class="heading" valign="top">Notes:</td><td class="regular">$$NOTES$$</td></tr> 23 24 $$UPDOK$$ 25 $$DELOK$$ 37 26 </form> 38 27 -
branches/dns/header.inc
r87 r262 40 40 <tr class="color1"> 41 41 <td width=10></td> 42 <form method="POST" action="/ip/cgi-bin/ main.cgi">43 <td >Search:42 <form method="POST" action="/ip/cgi-bin/search.cgi"> 43 <td width=390>Quick Search: 44 44 <input type="text" name="input" size="20" maxlength="50" class="regular"> 45 <input type=radio name="searchfor" value="ipblock">IP/IP block46 <input type=radio name="searchfor" value="desc" checked=yes>Description47 <input type=radio name="searchfor" value="cust">Customer ID48 45 <input type=hidden name=page value="1"> 49 <input type=hidden name= action value="search">46 <input type=hidden name=stype value="q"> 50 47 <input type=submit value="Go!" class="heading"> 51 48 <input type="button" value=" Help? " onclick="openHelp()" class="regular"> 52 53 < a href="/ip/cgi-bin/main.cgi?action=assign">Add new assignment</a>54 </td> 49 </td><td width=10></td><td><a href="/ip/cgi-bin/search.cgi">Complex Search</a></td> 50 <td width=60></td> 51 $$EXTRA0$$ 55 52 </form> 56 53 </tr> -
branches/dns/help.html
r4 r262 11 11 <table class="regular"> 12 12 13 <tr><td class="heading"> Searches:</td><tr>13 <tr><td class="heading">Quick Searches:</td><tr> 14 14 15 15 <tr class="color1"> -
branches/dns/index.shtml
r111 r262 1 <!--#include file="header.inc"-->2 1 <!--#include virtual="/ip/cgi-bin/main.cgi?action=index" -->
Note:
See TracChangeset
for help on using the changeset viewer.