Changeset 74 for trunk/cgi-bin
- Timestamp:
- 11/16/04 15:10:08 (20 years ago)
- Location:
- trunk/cgi-bin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/ipdb.psql
r57 r74 23 23 24 24 -- 25 -- TOC Entry ID 2 (OID 25848) 26 -- 27 -- Name: allocations Type: TABLE Owner: ipdb 28 -- 29 30 CREATE TABLE "allocations" ( 31 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL, 32 "custid" character varying(16) DEFAULT '', 33 "type" character(2) DEFAULT '', 34 "city" character varying(30) DEFAULT '', 35 "description" character varying(64) DEFAULT '', 36 "notes" text, 37 "maskbits" integer DEFAULT 128, 38 Constraint "allocations_pkey" Primary Key ("cidr") 39 ); 40 41 -- 42 -- TOC Entry ID 3 (OID 25848) 43 -- 44 -- Name: allocations Type: ACL Owner: 45 -- 46 47 REVOKE ALL on "allocations" from PUBLIC; 48 GRANT ALL on "allocations" to "kdeugau"; 49 GRANT ALL on "allocations" to "ipdb"; 50 51 -- 52 -- TOC Entry ID 4 (OID 25854) 25 -- TOC Entry ID 2 (OID 25854) 53 26 -- 54 27 -- Name: customers Type: TABLE Owner: ipdb … … 71 44 72 45 -- 73 -- TOC Entry ID 5(OID 25854)46 -- TOC Entry ID 3 (OID 25854) 74 47 -- 75 48 -- Name: customers Type: ACL Owner: … … 81 54 82 55 -- 83 -- TOC Entry ID 6 (OID 25866) 56 -- TOC Entry ID 4 (OID 25872) 57 -- 58 -- Name: masterblocks Type: TABLE Owner: ipdb 59 -- 60 61 CREATE TABLE "masterblocks" ( 62 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL, 63 Constraint "masterblocks_pkey" Primary Key ("cidr") 64 ); 65 66 -- 67 -- TOC Entry ID 5 (OID 25872) 68 -- 69 -- Name: masterblocks Type: ACL Owner: 70 -- 71 72 REVOKE ALL on "masterblocks" from PUBLIC; 73 GRANT ALL on "masterblocks" to "kdeugau"; 74 GRANT ALL on "masterblocks" to "ipdb"; 75 76 -- 77 -- TOC Entry ID 6 (OID 25875) 78 -- 79 -- Name: routed Type: TABLE Owner: ipdb 80 -- 81 82 CREATE TABLE "routed" ( 83 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL, 84 "maskbits" integer DEFAULT 128, 85 "city" character varying(30) DEFAULT '', 86 Constraint "routed_pkey" Primary Key ("cidr") 87 ); 88 89 -- 90 -- TOC Entry ID 7 (OID 25875) 91 -- 92 -- Name: routed Type: ACL Owner: 93 -- 94 95 REVOKE ALL on "routed" from PUBLIC; 96 GRANT ALL on "routed" to "kdeugau"; 97 GRANT ALL on "routed" to "ipdb"; 98 99 -- 100 -- TOC Entry ID 8 (OID 31131) 101 -- 102 -- Name: temp Type: TABLE Owner: ipdb 103 -- 104 105 CREATE TABLE "temp" ( 106 "ofs" integer 107 ); 108 109 -- 110 -- TOC Entry ID 9 (OID 31131) 111 -- 112 -- Name: temp Type: ACL Owner: 113 -- 114 115 REVOKE ALL on "temp" from PUBLIC; 116 GRANT ALL on "temp" to "kdeugau"; 117 GRANT ALL on "temp" to "ipdb"; 118 119 -- 120 -- TOC Entry ID 10 (OID 73917) 121 -- 122 -- Name: searchme Type: VIEW Owner: ipdb 123 -- 124 125 CREATE VIEW "searchme" as SELECT allocations.cidr, allocations.custid, allocations."type", allocations.city, allocations.description FROM allocations UNION SELECT poolips.ip, poolips.custid, poolips.ptype, poolips.city, poolips.description FROM poolips; 126 127 -- 128 -- TOC Entry ID 11 (OID 73917) 129 -- 130 -- Name: searchme Type: ACL Owner: 131 -- 132 133 REVOKE ALL on "searchme" from PUBLIC; 134 GRANT ALL on "searchme" to "kdeugau"; 135 GRANT ALL on "searchme" to "ipdb"; 136 137 -- 138 -- TOC Entry ID 12 (OID 91065) 139 -- 140 -- Name: freeblocks Type: TABLE Owner: ipdb 141 -- 142 143 CREATE TABLE "freeblocks" ( 144 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL, 145 "maskbits" integer DEFAULT 128, 146 "city" character varying(30) DEFAULT '', 147 "routed" character(1) DEFAULT 'n', 148 Constraint "freeblocks_pkey" Primary Key ("cidr") 149 ); 150 151 -- 152 -- TOC Entry ID 13 (OID 91065) 153 -- 154 -- Name: freeblocks Type: ACL Owner: 155 -- 156 157 REVOKE ALL on "freeblocks" from PUBLIC; 158 GRANT ALL on "freeblocks" to "kdeugau"; 159 GRANT ALL on "freeblocks" to "ipdb"; 160 161 -- 162 -- TOC Entry ID 14 (OID 92444) 84 163 -- 85 164 -- Name: poolips Type: TABLE Owner: ipdb … … 93 172 "ptype" character(1) DEFAULT 'c' NOT NULL, 94 173 "available" character(1) DEFAULT 'y', 95 "notes" text ,174 "notes" text DEFAULT '', 96 175 "description" character varying(64) DEFAULT '', 176 "circuitid" character varying(128) DEFAULT '', 97 177 CHECK (((available = 'y'::bpchar) OR (available = 'n'::bpchar))), 98 178 Constraint "poolips_pkey" Primary Key ("ip") … … 100 180 101 181 -- 102 -- TOC Entry ID 7 (OID 25866)182 -- TOC Entry ID 15 (OID 92444) 103 183 -- 104 184 -- Name: poolips Type: ACL Owner: … … 110 190 111 191 -- 112 -- TOC Entry ID 8 (OID 25872) 113 -- 114 -- Name: masterblocks Type: TABLE Owner: ipdb 115 -- 116 117 CREATE TABLE "masterblocks" ( 118 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL, 119 Constraint "masterblocks_pkey" Primary Key ("cidr") 120 ); 121 122 -- 123 -- TOC Entry ID 9 (OID 25872) 124 -- 125 -- Name: masterblocks Type: ACL Owner: 126 -- 127 128 REVOKE ALL on "masterblocks" from PUBLIC; 129 GRANT ALL on "masterblocks" to "kdeugau"; 130 GRANT ALL on "masterblocks" to "ipdb"; 131 132 -- 133 -- TOC Entry ID 10 (OID 25875) 134 -- 135 -- Name: routed Type: TABLE Owner: ipdb 136 -- 137 138 CREATE TABLE "routed" ( 139 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL, 192 -- TOC Entry ID 16 (OID 92725) 193 -- 194 -- Name: allocations Type: TABLE Owner: ipdb 195 -- 196 197 CREATE TABLE "allocations" ( 198 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL, 199 "custid" character varying(16) DEFAULT '', 200 "type" character(2) DEFAULT '', 201 "city" character varying(30) DEFAULT '', 202 "description" character varying(64) DEFAULT '', 203 "notes" text DEFAULT '', 140 204 "maskbits" integer DEFAULT 128, 141 "city" character varying(30) DEFAULT '', 142 Constraint "routed_pkey" Primary Key ("cidr") 143 ); 144 145 -- 146 -- TOC Entry ID 11 (OID 25875) 147 -- 148 -- Name: routed Type: ACL Owner: 149 -- 150 151 REVOKE ALL on "routed" from PUBLIC; 152 GRANT ALL on "routed" to "kdeugau"; 153 GRANT ALL on "routed" to "ipdb"; 154 155 -- 156 -- TOC Entry ID 12 (OID 31131) 157 -- 158 -- Name: temp Type: TABLE Owner: ipdb 159 -- 160 161 CREATE TABLE "temp" ( 162 "ofs" integer 163 ); 164 165 -- 166 -- TOC Entry ID 13 (OID 31131) 167 -- 168 -- Name: temp Type: ACL Owner: 169 -- 170 171 REVOKE ALL on "temp" from PUBLIC; 172 GRANT ALL on "temp" to "kdeugau"; 173 GRANT ALL on "temp" to "ipdb"; 174 175 -- 176 -- TOC Entry ID 14 (OID 73917) 177 -- 178 -- Name: searchme Type: VIEW Owner: ipdb 179 -- 180 181 CREATE VIEW "searchme" as SELECT allocations.cidr, allocations.custid, allocations."type", allocations.city, allocations.description FROM allocations UNION SELECT poolips.ip, poolips.custid, poolips.ptype, poolips.city, poolips.description FROM poolips; 182 183 -- 184 -- TOC Entry ID 15 (OID 73917) 185 -- 186 -- Name: searchme Type: ACL Owner: 187 -- 188 189 REVOKE ALL on "searchme" from PUBLIC; 190 GRANT ALL on "searchme" to "kdeugau"; 191 GRANT ALL on "searchme" to "ipdb"; 192 193 -- 194 -- TOC Entry ID 16 (OID 91065) 195 -- 196 -- Name: freeblocks Type: TABLE Owner: ipdb 197 -- 198 199 CREATE TABLE "freeblocks" ( 200 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL, 201 "maskbits" integer DEFAULT 128, 202 "city" character varying(30) DEFAULT '', 203 "routed" character(1) DEFAULT 'n', 204 Constraint "freeblocks_pkey" Primary Key ("cidr") 205 ); 206 207 -- 208 -- TOC Entry ID 17 (OID 91065) 209 -- 210 -- Name: freeblocks Type: ACL Owner: 211 -- 212 213 REVOKE ALL on "freeblocks" from PUBLIC; 214 GRANT ALL on "freeblocks" to "kdeugau"; 215 GRANT ALL on "freeblocks" to "ipdb"; 216 205 "circuitid" character varying(128) DEFAULT '', 206 Constraint "allocations_pkey" Primary Key ("cidr") 207 ); 208 209 -- 210 -- TOC Entry ID 17 (OID 92725) 211 -- 212 -- Name: allocations Type: ACL Owner: 213 -- 214 215 REVOKE ALL on "allocations" from PUBLIC; 216 GRANT ALL on "allocations" to "kdeugau"; 217 GRANT ALL on "allocations" to "ipdb"; 218 -
trunk/cgi-bin/main.cgi
r73 r74 734 734 my $count = 0; 735 735 while (my @data = $sth->fetchrow_array) { 736 # pool,ip,custid,city,ptype,available,notes,description 736 # pool,ip,custid,city,ptype,available,notes,description,circuitid 737 737 # If desc is null, make it not null. <g> 738 738 if ($data[7] eq '') { … … 933 933 $html =~ s|\$\$CITY\$\$|$webvar{city}|g; 934 934 $html =~ s|\$\$CUSTID\$\$|$webvar{custid}|g; 935 $html =~ s|\$\$CIRCID\$\$|$webvar{circid}|g; 935 936 $webvar{desc} = desanitize($webvar{desc}); 936 937 $webvar{notes} = desanitize($webvar{notes}); … … 976 977 977 978 $sth = $ip_dbh->prepare("update poolips set custid='$webvar{custid}',". 978 "city='$webvar{city}',available='n',description='$webvar{desc}'". 979 "city='$webvar{city}',available='n',description='$webvar{desc}',". 980 "circuitid='$webvar{circid}'". 979 981 " where ip='$cidr'"); 980 982 $sth->execute; … … 1028 1030 $sth = $ip_dbh->prepare("insert into allocations values ('$webvar{fullcidr}',". 1029 1031 "'$webvar{custid}','$webvar{alloctype}','$webvar{city}','$webvar{desc}',". 1030 "'$webvar{notes}',".$cidr->masklen." )");1032 "'$webvar{notes}',".$cidr->masklen.",'$webvar{circid}')"); 1031 1033 $sth->execute; 1032 1034 } # routing vs non-routing netblock … … 1094 1096 $sth = $ip_dbh->prepare("insert into allocations values ('$webvar{fullcidr}',". 1095 1097 "'$webvar{custid}','$webvar{alloctype}','$webvar{city}',". 1096 "'$webvar{desc}','$webvar{notes}',".$cidr->masklen." )");1098 "'$webvar{desc}','$webvar{notes}',".$cidr->masklen.",'$webvar{circid}')"); 1097 1099 $sth->execute; 1098 1100 } # done with netblock alloctype != rr … … 1117 1119 # have to insert all pool IPs into poolips table as "unallocated". 1118 1120 $sth = $ip_dbh->prepare("insert into poolips values ('$webvar{fullcidr}',". 1119 " ?, '6750400', '$webvar{city}', '$pooltype', 'y', '' )");1121 " ?, '6750400', '$webvar{city}', '$pooltype', 'y', '', '', '')"); 1120 1122 my @poolip_list = $cidr->hostenum; 1121 1123 for (my $i=1; $i<=$#poolip_list; $i++) { … … 1190 1192 # because I'm lazy, we'll try to make the SELECT's bring out identical)ish) data 1191 1193 if ($webvar{block} =~ /\/32$/) { 1192 $sql = "select ip,custid,ptype,city, description,notes from poolips where ip='$webvar{block}'";1194 $sql = "select ip,custid,ptype,city,circuitid,description,notes from poolips where ip='$webvar{block}'"; 1193 1195 } else { 1194 $sql = "select cidr,custid,type,city, description,notes from allocations where cidr='$webvar{block}'"1196 $sql = "select cidr,custid,type,city,circuitid,description,notes from allocations where cidr='$webvar{block}'" 1195 1197 } 1196 1198 … … 1243 1245 # These can be modified, although CustID changes may get ignored. 1244 1246 $html =~ s/\$\$CUSTID\$\$/$data[1]/g; 1245 $html =~ s/\$\$DESC\$\$/$data[4]/g; 1246 $html =~ s/\$\$NOTES\$\$/$data[5]/g; 1247 $html =~ s/\$\$TYPE\$\$/$data[2]/g; 1248 $html =~ s/\$\$CIRCID\$\$/$data[4]/g; 1249 $html =~ s/\$\$DESC\$\$/$data[5]/g; 1250 $html =~ s/\$\$NOTES\$\$/$data[6]/g; 1247 1251 1248 1252 print $html; … … 1267 1271 # Note the hack ( available='n' ) to work around "update" additions 1268 1272 # to static IP space. Eww. 1269 $sql = "update poolips set custid='$webvar{custid}', ".1270 " notes='$webvar{notes}',description='$webvar{desc}',available='n' ".1273 $sql = "update poolips set custid='$webvar{custid}',notes='$webvar{notes}',". 1274 "circuitid='$webvar{circid}',description='$webvar{desc}',available='n' ". 1271 1275 "where ip='$webvar{block}'"; 1272 1276 } else { 1273 1277 $sql = "update allocations set custid='$webvar{custid}',". 1274 1278 "description='$webvar{desc}',notes='$webvar{notes}',city='$webvar{city}',". 1275 "type='$webvar{alloctype}' where cidr='$webvar{block}'";1279 "type='$webvar{alloctype}',circuitid='$webvar{circid}' where cidr='$webvar{block}'"; 1276 1280 } 1277 1281 syslog "debug", $sql; … … 1298 1302 $html =~ s/\$\$TYPEFULL\$\$/$full_alloc_types{$webvar{alloctype}}/g; 1299 1303 $html =~ s/\$\$CUSTID\$\$/$webvar{custid}/g; 1304 $html =~ s/\$\$CIRCID\$\$/$webvar{circid}/g; 1300 1305 $html =~ s/\$\$DESC\$\$/$webvar{desc}/g; 1301 1306 $html =~ s/\$\$NOTES\$\$/$webvar{notes}/g; … … 1322 1327 } 1323 1328 1324 my ($cidr, $custid, $type, $city, $ desc, $notes, $alloctype);1329 my ($cidr, $custid, $type, $city, $circid, $desc, $notes, $alloctype); 1325 1330 1326 1331 if ($webvar{alloctype} eq 'rr') { … … 1336 1341 $custid = "N/A"; 1337 1342 $alloctype = $webvar{alloctype}; 1343 $circid = "N/A"; 1338 1344 $desc = "N/A"; 1339 1345 $notes = "N/A"; … … 1344 1350 $custid = "N/A"; 1345 1351 $alloctype = $webvar{alloctype}; 1352 $circid = "N/A"; 1346 1353 $desc = "N/A"; 1347 1354 $notes = "N/A"; … … 1349 1356 1350 1357 # Unassigning a static IP 1351 my $sth = $ip_dbh->prepare("select ip,custid,city,ptype,notes from poolips".1358 my $sth = $ip_dbh->prepare("select ip,custid,city,ptype,notes,circuitid from poolips". 1352 1359 " where ip='$webvar{block}'"); 1353 1360 $sth->execute(); 1354 1361 # croak $sth->errstr() if($sth->errstr()); 1355 1362 1356 $sth->bind_columns(\$cidr, \$custid, \$city, \$alloctype, \$notes );1363 $sth->bind_columns(\$cidr, \$custid, \$city, \$alloctype, \$notes, \$circid); 1357 1364 $sth->fetch() || croak $sth->errstr; 1358 1365 … … 1361 1368 } else { # done with alloctype=[cdsmw]i 1362 1369 1363 my $sth = $ip_dbh->prepare("select cidr,custid,type,city, description,notes from ".1370 my $sth = $ip_dbh->prepare("select cidr,custid,type,city,circuitid,description,notes from ". 1364 1371 "allocations where cidr='$webvar{block}'"); 1365 1372 $sth->execute(); 1366 1373 # croak $sth->errstr() if($sth->errstr()); 1367 1374 1368 $sth->bind_columns(\$cidr, \$custid, \$alloctype, \$city, \$ desc, \$notes);1369 $sth->fetch() || c roak$sth->errstr;1375 $sth->bind_columns(\$cidr, \$custid, \$alloctype, \$city, \$circid, \$desc, \$notes); 1376 $sth->fetch() || carp $sth->errstr; 1370 1377 } # end cases for different alloctypes 1371 1378 … … 1377 1384 $html =~ s|\$\$CITY\$\$|$city|g; 1378 1385 $html =~ s|\$\$CUSTID\$\$|$custid|g; 1386 $html =~ s|\$\$CIRCID\$\$|$circid|g; 1379 1387 $html =~ s|\$\$DESC\$\$|$desc|g; 1380 1388 $html =~ s|\$\$NOTES\$\$|$notes|g;
Note:
See TracChangeset
for help on using the changeset viewer.