source: branches/rpc/cgi-bin/admin.cgi@ 309

Last change on this file since 309 was 295, checked in by Kris Deugau, 19 years ago

/trunk

Bugfix for the bugfix in r292. (merge)

  • Property svn:executable set to *
  • Property svn:keywords set to Date Rev Author
File size: 20.2 KB
Line 
1#!/usr/bin/perl
2# ipdb/cgi-bin/admin.cgi
3# Hack interface to make specific changes to IPDB that (for one reason
4# or another) can't be made through the main interface.
5#
6###
7# SVN revision info
8# $Date: 2005-10-14 15:20:02 +0000 (Fri, 14 Oct 2005) $
9# SVN revision $Rev: 295 $
10# Last update by $Author: kdeugau $
11###
12# Copyright (C) 2004,2005 - Kris Deugau
13
14use strict;
15use warnings;
16use CGI::Carp qw(fatalsToBrowser);
17use DBI;
18use CommonWeb qw(:ALL);
19use MyIPDB;
20#use POSIX qw(ceil);
21use NetAddr::IP;
22
23use Sys::Syslog;
24
25openlog "IPDB-admin","pid","local2";
26
27# Collect the username from HTTP auth. If undefined, we're in a test environment.
28my $authuser;
29if (!defined($ENV{'REMOTE_USER'})) {
30 $authuser = '__temptest';
31} else {
32 $authuser = $ENV{'REMOTE_USER'};
33}
34
35syslog "debug", "$authuser active";
36
37# Why not a global DB handle? (And a global statement handle, as well...)
38# Use the connectDB function, otherwise we end up confusing ourselves
39my $ip_dbh;
40my $sth;
41my $errstr;
42($ip_dbh,$errstr) = connectDB_My;
43if (!$ip_dbh) {
44 printAndExit("Database error: $errstr\n");
45}
46initIPDBGlobals($ip_dbh);
47
48if ($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
56my %webvar = parse_post();
57cleanInput(\%webvar);
58
59print "Content-type: text/html\n\n".
60 "<html>\n<head>\n\t<title>TEST [IPDB admin tools] TEST</title>\n".
61 qq(\t<link rel="stylesheet" type="text/css" href="/ip/ipdb.css">\n).
62 "</head>\n<body>\n".
63 "<h2>IPDB - Administrative Tools</h2>\n<hr>\n";
64
65if(!defined($webvar{action})) {
66 $webvar{action} = "<NULL>"; #shuts up the warnings.
67
68 my $typelist = '';
69 $sth = $ip_dbh->prepare("select type,listname from alloctypes where listorder < 900 order by listorder");
70 $sth->execute;
71 my @data = $sth->fetchrow_array;
72 $typelist .= "<option value='$data[0]' selected>$data[1]</option>\n";
73 while (my @data = $sth->fetchrow_array) {
74 $typelist .= "<option value='$data[0]'>$data[1]</option>\n";
75 }
76
77 print qq(WARNING: There are FAR fewer controls on what you can do here. Use the
78main interface if at all possible.
79<hr>
80<a href="admin.cgi?action=newalloc">Add allocation</a>
81<hr>
82<form action="admin.cgi" method="POST">
83<input type=hidden name=action value=alloc>
84Allocate block/IP: <input name=cidr> as <select name=alloctype>$typelist</select> to <input name=custid>
85<input type=submit value=" GIMME!! "></form>
86<hr><form action="admin.cgi" method="POST">
87<input type=hidden name=action value=alloctweak>
88Manually update allocation data in this /24: <input name=allocfrom>
89<input type=submit value="Show allocations">
90</form>
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
93internal access controls - note that this does NOT include IP-based limits)
94);
95} else {
96 print '<a href="/ip/cgi-bin/admin.cgi">Back</a> to main<hr>';
97}
98
99
100## Possible actions.
101if ($webvar{action} eq 'alloc') {
102 # OK, we know what we're allocating.
103
104 if ($webvar{cidr} !~ /^\s*(\d{1,3}\.){3}\d{1,3}(\/\d{2})?\s*$/) {
105 printAndExit("Can't allocate something that's not a netblock/ip");
106 }
107
108 $sth = $ip_dbh->prepare("select def_custid from alloctypes where type='$webvar{alloctype}'");
109 $sth->execute;
110 my @data = $sth->fetchrow_array;
111 my $custid = $data[0];
112 if ($custid eq '') {
113 # Type that doesn't have a default custid
114 $custid = $webvar{custid};
115 }
116##fixme Check billing DB here
117
118 my $cidr = new NetAddr::IP $webvar{cidr};
119 my @data;
120 if ($webvar{alloctype} eq 'rm') {
121 $sth = $ip_dbh->prepare("select cidr from freeblocks where cidr >>='$cidr' and routed='n'");
122 $sth->execute;
123 @data = $sth->fetchrow_array;
124# User deserves errors if user can't be bothered to find the free block first.
125 printAndExit("Can't allocate from outside a free block!!\n")
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];
134 } else {
135 $sth = $ip_dbh->prepare("select cidr from freeblocks where cidr >>='$cidr' and not (routed='n')");
136 $sth->execute;
137 @data = $sth->fetchrow_array;
138# User deserves errors if user can't be bothered to find the free block first.
139 printAndExit("Can't allocate from outside a routed block!!\n")
140 if !$data[0];
141 }
142
143 my $alloc_from = new NetAddr::IP $data[0];
144 $sth->finish;
145
146 my $cities = '';
147 foreach my $city (@citylist) {
148 $cities .= "<option>$city</option>\n";
149 }
150
151 print qq(<table class=regular>
152<form method=POST action=admin.cgi>
153<tr class=color1>
154<td>Allocating:</td>
155<td>$cidr<input type=hidden name=cidr value="$cidr"></td>
156</tr><tr class=color2>
157<td>Type:</td><td>$disp_alloctypes{$webvar{alloctype}}
158<input type=hidden name=alloctype value="$webvar{alloctype}"></td>
159</tr><tr class=color1>
160<td>Allocated from:</td>
161<td>$alloc_from<input type=hidden name=alloc_from value="$alloc_from"></td>
162</tr><tr class="color2">
163<td>Customer ID:</td><td>$custid<input type=hidden name=custid value="$custid"></td>
164</tr><tr class=color1>
165<td>Customer location:</td><td>
166<select name="city"><option selected>-</option>
167$cities
168</select>
169&nbsp;<a href="javascript:popNotes('/ip/newcity.html')">Add new location</a>
170</td>
171</tr>
172<tr class="color2">
173<td>Circuit ID:</td><td><input name=circid size=40></td>
174</tr><tr class="color1">
175<td>Description/Name:</td><td><input name="desc" size=40></td>
176</tr><tr class="color2">
177<td>Notes:</td><td><textarea name="notes" rows="3" cols="40"></textarea></td>
178</tr><tr class="warning">
179<td colspan=2><center>WARNING: This will IMMEDIATELY assign this block!!</center></td>
180</tr><tr class="color2">
181<td class="center" colspan="2"><input type="submit" value=" Assign "></td>
182<input type="hidden" name="action" value="confirm">
183</form>
184</tr>
185</table>
186);
187
188
189} elsif ($webvar{action} eq 'confirm') {
190
191 print "Assigning $webvar{cidr} to $webvar{custid} (\"$webvar{desc}\") as ".
192 "$disp_alloctypes{$webvar{alloctype}}...<br>\n";
193 # Only need to check city here.
194 if ($webvar{city} eq '-') {
195 printError("Invalid customer location! Go back and select customer's location.");
196 } else {
197 if ($webvar{alloctype} =~ /^.i$/) {
198 $sth = $ip_dbh->prepare("update poolips set available='n', custid='$webvar{custid}', ".
199 "city='$webvar{city}', description='$webvar{desc}', notes='$webvar{notes}' ".
200 "where ip='$webvar{cidr}'");
201 $sth->execute;
202 if ($sth->err) {
203 print "Allocation failed! DBI said:\n".$sth->errstr."\n";
204 syslog "err", "($authuser) Allocation of '$webvar{cidr}' to '$webvar{custid}' as ".
205 "'$webvar{alloctype}' failed: '".$sth->errstr."'";
206 } else {
207 print "Allocation OK!\n";
208 syslog "notice", "$authuser allocated '$webvar{cidr}' to '$webvar{custid}' as ".
209 "'$webvar{alloctype}'";
210 # Notify tech@example.com
211 mailNotify('tech@example.com',"$disp_alloctypes{$webvar{alloctype}} allocation",
212 "$disp_alloctypes{$webvar{alloctype}} $webvar{cidr} allocated to customer".
213 " $webvar{custid}\n".
214 "Description: $webvar{desc}\n\nAllocated by: $authuser\n");
215 }
216 } else {
217 my ($retcode,$msg) = allocateBlock($ip_dbh, $webvar{cidr}, $webvar{alloc_from},
218 $webvar{custid}, $webvar{alloctype}, $webvar{city}, $webvar{desc}, $webvar{notes},
219 $webvar{circid});
220 if ($retcode eq 'OK') {
221 print "Allocation OK!\n";
222 syslog "notice", "$authuser allocated '$webvar{cidr}' to '$webvar{custid}' as ".
223 "'$webvar{alloctype}'";
224 } else {
225 print "Allocation failed! IPDB::allocateBlock said:\n$msg\n";
226 syslog "err", "($authuser) Allocation of '$webvar{cidr}' to '$webvar{custid}' as ".
227 "'$webvar{alloctype}' failed: '$msg'";
228 }
229 } # static IP vs netblock
230
231 } # done city check
232
233} elsif ($webvar{action} eq 'alloctweak') {
234 fix_allocfrom();
235 showAllocs($webvar{allocfrom});
236} elsif ($webvar{action} eq 'update') {
237 update();
238} elsif ($webvar{action} eq 'assign') {
239 # Display a list of possible blocks within the requested block.
240 open (HTML, "../admin_alloc.html")
241 or croak "Could not open admin_alloc.html :$!";
242 my $html = join('', <HTML>);
243 $html =~ s/\$\$MASK\$\$/$webvar{masklen}/g;
244 $html =~ s/\$\$ALLOCFROM\$\$/$webvar{allocfrom}/g;
245
246 my $from = new NetAddr::IP $webvar{allocfrom};
247 my @blocklist = $from->split($webvar{masklen});
248 my $availblocks;
249 foreach (@blocklist) {
250 $availblocks .= qq(<tr><td colspan=2 align=center><input type=radio name=block value="$_">$_</td></tr>\n);
251 }
252 $html =~ s/\$\$BLOCKLIST\$\$/$availblocks/g;
253
254 print $html;
255} elsif ($webvar{action} eq 'showpools') {
256 print "IP Pools currently allocated:\n".
257 "<table border=1>\n<tr><td>Pool</td><td># of free IPs</td></tr>\n";
258 $sth = $ip_dbh->prepare("select cidr from allocations where type like '%p' or type like '%d' order by cidr");
259 $sth->execute;
260 my %poolfree;
261 while (my @data = $sth->fetchrow_array) {
262 $poolfree{$data[0]} = 0;
263 }
264 $sth = $ip_dbh->prepare("select pool,ip from poolips where available='y' order by ip");
265 $sth->execute;
266 while (my @data = $sth->fetchrow_array) {
267 $poolfree{$data[0]}++;
268 }
269 foreach my $key (keys %poolfree) {
270 print qq(<tr><td><a href="admin.cgi?action=tweakpool&pool=$key">$key</a></td>).
271 "<td>$poolfree{$key}</td></tr>\n";
272 }
273 print "</table>\n";
274} elsif ($webvar{action} eq 'tweakpool') {
275 showPool($webvar{pool});
276} elsif ($webvar{action} eq 'updatepool') {
277
278 $sth = $ip_dbh->prepare("update poolips set custid='$webvar{custid}', ".
279 "city='$webvar{city}', type='$webvar{type}', available='".
280 (($webvar{available} eq 'y') ? 'y' : 'n').
281 "', notes='$webvar{notes}', description='$webvar{desc}' ".
282 "where ip='$webvar{ip}'");
283 $sth->execute;
284 if ($sth->err) {
285 print "Error updating pool IP $webvar{ip}: $@<hr>\n";
286 syslog "err", "$authuser could not update pool IP $webvar{ip}: $@";
287 } else {
288 $sth = $ip_dbh->prepare("select pool from poolips where ip='$webvar{ip}'");
289 $sth->execute;
290 my @data = $sth->fetchrow_array;
291 print "$webvar{ip} in $data[0] updated\n<hr>\n";
292 syslog "notice", "$authuser updated pool IP $webvar{ip}";
293 }
294} elsif ($webvar{action} eq 'showusers') {
295 print "Notes:<br>\n".
296 "<li>Admin users automatically get all other priviledges.\n".
297 "<hr>Add new user:<form action=admin.cgi method=POST>\n".
298 "Username: <input name=username><br>\n".
299 "Password: <input name=password> <input type=checkbox name=preenc>Password is pre-encrypted (MUST be crypt() encrypted)<br>\n".
300 "<input type=submit value='Add user'><input type=hidden name=action value=newuser></form>\n";
301
302 print "<hr>Users with access:\n<table border=1>\n";
303 print "<tr><td></td><td align=center colspan=3>General access</td></tr>\n";
304 print "<tr><td>Username</td><td>Add new</td><td>Change</td>".
305 "<td>Delete</td><td>Systems/Networking</td><td>Admin user</td></tr>\n".
306 "<form action=admin.cgi method=POST>\n";
307 $sth = $ip_dbh->prepare("select username,acl from users order by username");
308 $sth->execute;
309 while (my @data = $sth->fetchrow_array) {
310 print "<form action=admin.cgi method=POST><input type=hidden name=action value=updacl>".
311 qq(<tr><td>$data[0]<input type=hidden name=username value="$data[0]"></td><td>).
312 # Now for the fun bit. We have to pull apart the ACL field and
313 # output a bunch of checkboxes.
314 "<input type=checkbox name=add".($data[1] =~ /a/ ? ' checked=y' : '').
315 "></td><td><input type=checkbox name=change".($data[1] =~ /c/ ? ' checked=y' : '').
316 "></td><td><input type=checkbox name=del".($data[1] =~ /d/ ? ' checked=y' : '').
317 "></td><td><input type=checkbox name=sysnet".($data[1] =~ /s/ ? ' checked=y' : '').
318 "></td><td><input type=checkbox name=admin".($data[1] =~ /A/ ? ' checked=y' : '').
319 qq(></td><td><input type=submit value="Update"></td></form>\n).
320 "<form action=admin.cgi method=POST><td><input type=hidden name=action value=deluser>".
321 "<input type=hidden name=username value=$data[0]>".
322 qq(<input type=submit value="Delete user"></tr></form>\n);
323
324 }
325 print "</table>\n";
326} elsif ($webvar{action} eq 'updacl') {
327 print "Updating ACL for $webvar{username}:<br>\n";
328 my $acl = 'b';
329 if ($webvar{admin} eq 'on') {
330 $acl .= "acdsA";
331 } else {
332 $acl .= ($webvar{add} eq 'on' ? 'a' : '').
333 ($webvar{change} eq 'on' ? 'c' : '').
334 ($webvar{del} eq 'on' ? 'd' : '').
335 ($webvar{sysnet} eq 'on' ? 's' : '');
336 }
337 print "New ACL: $acl<br>\n";
338
339 $sth = $ip_dbh->prepare("update users set acl='$acl' where username='$webvar{username}'");
340 $sth->execute;
341 print "OK\n" if !$sth->err;
342
343 print qq(<hr><a href="admin.cgi?action=showusers">Back</a> to user listing\n);
344
345} elsif ($webvar{action} eq 'newuser') {
346 print "Adding user $webvar{username}...\n";
347 my $cr_pass = ($webvar{preenc} ? $webvar{password} :
348 crypt $webvar{password}, join('',('.','/',0..9,'A'..'Z','a'..'z')[rand 64, rand 64]));
349 $sth = $ip_dbh->prepare("insert into users (username,password,acl) values ".
350 "('$webvar{username}','$cr_pass','b')");
351 $sth->execute;
352 if ($sth->err) {
353 print "<br>Error adding user: ".$sth->errstr;
354 } else {
355 print "OK\n";
356 }
357
358 print qq(<hr><a href="admin.cgi?action=showusers">Back</a> to user listing\n);
359
360} elsif ($webvar{action} eq 'deluser') {
361 print "Deleting user $webvar{username}.<br>\n";
362 $sth = $ip_dbh->prepare("delete from users where username='$webvar{username}'");
363 $sth->execute;
364 print "OK\n" if !$sth->err;
365
366 print qq(<hr><a href="admin.cgi?action=showusers">Back</a> to user listing\n);
367
368} elsif ($webvar{action} ne '<NULL>') {
369 print "webvar{action} check failed: Don't know how to $webvar{action}";
370}
371
372# Hokay. This is a little different. We have a few specific functions here:
373# -> Assign arbitrary subnet from arbitrary free space
374# -> Tweak individual DB fields
375#
376
377
378printFooter;
379
380$ip_dbh->disconnect;
381
382exit;
383
384
385# Tweak allocfrom into shape.
386sub fix_allocfrom {
387 if ($webvar{allocfrom} =~ /^(\d+\.){2}\d+$/) {
388 # 3-octet class C specified
389 $webvar{allocfrom} .= ".0/24";
390 } elsif ($webvar{allocfrom} =~ /^(\d+\.){3}\d+$/) {
391 # 4-octet IP specified;
392 $webvar{allocfrom} .= "/24";
393 }
394}
395
396
397# List free blocks in a /24 for arbitrary manual allocation
398sub showfree($) {
399 my $cidr = new NetAddr::IP $_[0];
400 print "Showing free blocks in $cidr<br>\n".
401 "<table border=1>\n";
402 $sth = $ip_dbh->prepare("select * from freeblocks where cidr <<= '$cidr' order by cidr");
403 $sth->execute;
404 while (my @data = $sth->fetchrow_array) {
405 my $temp = new NetAddr::IP $data[0];
406 print "<tr><form action=admin.cgi method=POST><input type=hidden name=action value=assign>\n".
407 qq(<td>$temp<input type=hidden name=allocfrom value="$temp"></td>\n).
408 "<td>".
409 (($temp->masklen == 30) ? '<input type=hidden name=masklen value=30>30'
410 : "<select name=masklen><option>30</option>\n<option>29</option>\n") .
411 (($temp->masklen < 29) ? "<option>28</option>\n" : '') .
412 (($temp->masklen < 28) ? "<option>27</option>\n" : '') .
413 (($temp->masklen < 27) ? "<option>26</option>\n" : '') .
414 (($temp->masklen < 26) ? "<option>25</option>\n" : '') .
415 (($temp->masklen < 25) ? "<option>24</option>\n" : '') .
416 "</td>".
417 qq(<td>$data[2]</td><td><input type=submit value="Allocate from here"></td>).
418 "\n</form></tr>\n";
419 }
420 print "</table>\n";
421}
422
423
424# Show allocations to allow editing.
425sub showAllocs($) {
426 my $cidr = new NetAddr::IP $_[0];
427 print "Edit custID, allocation type, city for allocations in ".
428 "$cidr:\n<table border=1>";
429 $sth = $ip_dbh->prepare("select * from allocations where cidr <<= '$cidr' order by cidr");
430 $sth->execute;
431 while (my @data = $sth->fetchrow_array) {
432 print "<tr><form action=admin.cgi method=POST><input type=hidden name=action value=update>\n".
433 qq(<td>$data[0]<input type=hidden value="$data[0]" name=block></td>\n).
434 qq(<td><input name=custid value="$data[1]"></td>\n);
435
436 print "<td><select name=alloctype><option".
437 (($data[2] eq 'cn') ? ' selected' : '') ." value='cn'>Customer netblock</option>\n<option".
438 (($data[2] eq 'si') ? ' selected' : '') ." value='si'>Static IP - Server pool</option>\n<option".
439 (($data[2] eq 'ci') ? ' selected' : '') ." value='ci'>Static IP - Cable</option>\n<option".
440 (($data[2] eq 'di') ? ' selected' : '') ." value='di'>Static IP - DSL</option>\n<option".
441 (($data[2] eq 'mi') ? ' selected' : '') ." value='mi'>Static IP - Dialup</option>\n<option".
442 (($data[2] eq 'wi') ? ' selected' : '') ." value='wi'>Static IP - Wireless</option>\n<option".
443 (($data[2] eq 'sd') ? ' selected' : '') ." value='sd'>Static Pool - Server pool</option>\n<option".
444 (($data[2] eq 'cd') ? ' selected' : '') ." value='cd'>Static Pool - Cable</option>\n<option".
445 (($data[2] eq 'dp') ? ' selected' : '') ." value='dp'>Static Pool - DSL</option>\n<option".
446 (($data[2] eq 'mp') ? ' selected' : '') ." value='mp'>Static Pool - Dialup</option>\n<option".
447 (($data[2] eq 'wp') ? ' selected' : '') ." value='wp'>Static Pool - Wireless</option>\n<option".
448 (($data[2] eq 'en') ? ' selected' : '') ." value='en'>End-use netblock</option>\n<option".
449 (($data[2] eq 'me') ? ' selected' : '') ." value='me'>Dialup netblock</option>\n<option".
450 (($data[2] eq 'de') ? ' selected' : '') ." value='de'>Dynamic DSL netblock</option>\n<option".
451 (($data[2] eq 'ce') ? ' selected' : '') ." value='ce'>Dynamic cable netblock</option>\n<option".
452 (($data[2] eq 'we') ? ' selected' : '') ." value='we'>Dynamic WiFi netblock</option>\n<option".
453 (($data[2] eq 'in') ? ' selected' : '') ." value='in'>Internal netblock</option>\n".
454 "</select></td>\n";
455 print qq(<td><input name=city value="$data[3]"></td>\n).
456 "<td>$data[4]</td><td>$data[5]</td>".
457 qq(<td><input type=submit value="Update"></td></form></tr>\n);
458 }
459 print "</table>\n";
460
461 # notes
462 print "<hr><b>Notes:</b>\n".
463 "<ul>\n<li>Use the main interface to update description and notes fields\n".
464 "<li>Changing the allocation type here will NOT affect IP pool data.\n".
465 "</ul>\n";
466}
467
468
469# Stuff updates into DB
470sub update {
471 eval {
472 # Relatively simple SQL transaction here. Note that we're deliberately NOT
473 # updating notes/desc here as it's available through the main interface.
474 $sth = $ip_dbh->prepare("update allocations set custid='$webvar{custid}',".
475 "city='$webvar{city}',type='$webvar{alloctype}' where cidr='$webvar{block}'");
476 $sth->execute;
477 $ip_dbh->commit;
478 };
479 if ($@) {
480 carp "Transaction aborted because $@";
481 eval { $ip_dbh->rollback; };
482 syslog "err", "$authuser could not update block '$webvar{block}': '$@'";
483 } else {
484 # If we get here, the operation succeeded.
485 syslog "notice", "$authuser updated $webvar{block}";
486 print "Allocation $webvar{block} updated<hr>\n";
487 }
488 # need to get /24 that block is part of
489 my @bits = split /\./, $webvar{block};
490 $bits[3] = "0/24";
491 showAllocs((join ".", @bits));
492}
493
494
495# showPool()
496# List all IPs in a pool, and allow arbitrary admin changes to each
497# Allow changes to ALL fields
498sub showPool($) {
499 my $pool = new NetAddr::IP $_[0];
500 print qq(Listing pool $pool:\n<table border=1>
501<form action=admin.cgi method=POST>
502<input type=hidden name=action value=updatepool>
503<tr><td align=right>Customer ID:</td><td><input name=custid></td></tr>
504<tr><td align=right>Customer location:</td><td><input name=city></td></tr>
505<tr><td align=right>Type:</td><td><select name=type><option selected>-</option>
506<option value="si">Static IP - Server pool</option>
507<option value="ci">Static IP - Cable</option>
508<option value="di">Static IP - DSL</option>
509<option value="mi">Static IP - Dialup</option>
510<option value="wi">Static IP - Wireless</option>
511</select></td></tr>
512<tr><td align=right>Available?</td><td><input type=checkbox value=y></td></tr>
513<tr><td align=right>Description/name:</td><td><input name=desc size=40></td></tr>
514<tr><td align=right>Notes:</td><td><textarea name=notes rows=3 cols=40></textarea></td></tr>
515<tr><td colspan=2 align=center><input type=submit value="Update"></td></tr>
516).
517 "</table>Update the following record:<table border=1>\n";
518 $sth = $ip_dbh->prepare("select pool,ip,custid,city,type,available,description,notes from poolips where pool='$pool' order by ip");
519 $sth->execute;
520 while (my @data = $sth->fetchrow_array) {
521 print qq(<tr><td><input type=radio name=ip value="$data[1]">$data[1]</td>).
522 "<td>$data[2]</td><td>$data[3]</td><td>$data[4]</td>".
523 "<td>$data[5]</td><td>$data[6]</td><td>$data[7]</td></tr>\n";
524 }
525 print "</form></table>\n";
526}
Note: See TracBrowser for help on using the repository browser.