source: trunk/cgi-bin/edit-alloc.php@ 6

Last change on this file since 6 was 6, checked in by Kris Deugau, 20 years ago

Add intermediate development files for posterity

File size: 2.5 KB
Line 
1<html><head><title>Manual munging for allocated blocks</title></head><body>
2<?php
3/* edit-alloc.php
4** Quick hack to allow manual editing of data in postgres:ipdb:allocations table
5** 07/13/2004 kdeugau@vianet
6*/
7// include '../header.inc';
8
9 print "<a href=manual.htm>Manual munging</a><br>\n";
10
11 $dbh = pg_connect("dbname=ipdb user=ipdb password=ipdbpwd");
12
13/* Since there are so many records in this table, we'll only display 50 at a time.
14** We want to remember where we were without complex CGI variable-passing or other
15** headaches, so we just stuff it in the db. <g>
16*/
17
18 if (!isset($ofs)) {
19 $qu = pg_exec($dbh, "select * from temp");
20 if (pg_NumRows($qu) == 0) {
21 print "Using default limit";
22 $ofs = 0;
23 } else {
24 $data = pg_fetch_array($qu, 0);
25 $ofs = $data[0];
26 print "Limit $ofs found";
27 }
28 } else {
29 print "Passed limit $ofs in CGI<br>\n";
30 $qu = pg_exec("delete from temp");
31 $qu = pg_exec("insert into temp values ($ofs)");
32 }
33
34?>
35<table>
36<form action="add-alloc.php" method=POST>
37<tr><td>CIDR route:</td><td><input name=cidr></td></tr>
38<tr><td>CustID:</td><td><input name=custid></td></tr>
39<td>Alloc type:</td><td><input name=alloctype value=cn></td></tr>
40<td>City:</td><td><input name=city></td></tr>
41<td>Description:</td><td><input name=desc></td></tr>
42<td>Notes:</td><td><input name=notes></td></tr>
43<tr><td colspan=2><input type=submit value="Add entry"></td></tr>
44</form>
45</table>
46
47<?
48 $qu = pg_exec($dbh, "select count(*) from allocations");
49 $data = pg_fetch_array($qu,0);
50 $nrows = $data[0];
51
52 $ofnum = (integer) ($nrows / 50);
53 for ($i=0; $i<=$ofnum; $i++) {
54 print '<a href="edit-alloc.php?ofs='. ($i*50) .'">'."$i</a> - ";
55 }
56?>
57
58<table border=1 cellspacing=2>
59<tr><td>CIDR allocation</td><td>CustID</td><td>Alloc type</td><td>City</td><td>Description</td><td>Notes</td></tr>
60<?
61 $qu = pg_exec($dbh, "select * from allocations order by cidr limit 50 offset $ofs");
62
63 $row = 0;
64 for ($row=0; $row < pg_NumRows($qu); $row++) {
65 $data = pg_fetch_array($qu, $row);
66 print "<form action=upd-alloc.php method=POST>".
67 "<tr><td>$data[0]<input type=hidden name=cidr value='$data[0]'></td>".
68 "<td><input name=custid value='$data[1]' size=15></td>".
69 "<td><input name=alloctype value='$data[2]' size=5></td>".
70 "<td><input name=city value='$data[3]'></td>".
71 "<td><input name=desc value='$data[4]'></td>".
72 "<td><input name=notes value='$data[5]'></td>".
73 "<td><input type=submit value='Update'></td></tr></form>\n";
74 }
75?>
76</table>
77<?
78// include '../footer.inc';
79?>
80</body></html>
Note: See TracBrowser for help on using the repository browser.