Changeset 394 for branches/stable/cgi-bin
- Timestamp:
- 02/19/10 13:10:34 (15 years ago)
- Location:
- branches/stable/cgi-bin
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/cgi-bin/IPDB.pm
r387 r394 292 292 # Returns a success code and optional error message. 293 293 sub allocateBlock { 294 my ($dbh,undef,undef,$custid,$type,$city,$desc,$notes,$circid,$privdata ) = @_;294 my ($dbh,undef,undef,$custid,$type,$city,$desc,$notes,$circid,$privdata,$nodeid) = @_; 295 295 296 296 my $cidr = new NetAddr::IP $_[1]; … … 333 333 " where ip='$cidr'"); 334 334 $sth->execute; 335 # node hack 336 if ($nodeid && $nodeid ne '') { 337 $sth = $dbh->prepare("INSERT INTO noderef (block,node_id) VALUES (?,?)"); 338 $sth->execute("$cidr",$nodeid); 339 } 340 # end node hack 335 341 $dbh->commit; 336 342 }; … … 393 399 } # routing vs non-routing netblock 394 400 401 # node hack 402 if ($nodeid && $nodeid ne '') { 403 $sth = $dbh->prepare("INSERT INTO noderef (block,node_id) VALUES (?,?)"); 404 $sth->execute("$cidr",$nodeid); 405 } 406 # end node hack 395 407 $dbh->commit; 396 408 }; # end of eval … … 497 509 } # done with netblock alloctype != rm 498 510 511 # node hack 512 if ($nodeid && $nodeid ne '') { 513 $sth = $dbh->prepare("INSERT INTO noderef (block,node_id) VALUES (?,?)"); 514 $sth->execute("$cidr",$nodeid); 515 } 516 # end node hack 499 517 $dbh->commit; 500 518 }; # end eval -
branches/stable/cgi-bin/ipdb.psql
r377 r394 212 212 ); 213 213 214 -- Network nodes - allows finding customers affected by a broken <x> quickly 215 CREATE TABLE noderef ( 216 block inet NOT NULL PRIMARY KEY, 217 node_id integer 218 ); 219 220 CREATE TABLE nodes ( 221 node_id serial NOT NULL PRIMARY KEY, 222 node_type character varying(2), 223 node_name character varying(40), 224 node_ip inet 225 ); -
branches/stable/cgi-bin/main.cgi
r390 r394 614 614 } 615 615 $html =~ s|\$\$ALLCITIES\$\$|$cities|g; 616 617 ## node hack 618 $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id"); 619 $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n"; 620 my $nodes = ''; 621 while (my ($nid,$nname) = $sth->fetchrow_array()) { 622 $nodes .= "<option value='$nid'>$nname</option>\n"; 623 } 624 $html =~ s/\$\$NODELIST\$\$/$nodes/; 625 ## end node hack 616 626 617 627 my $i = 0; … … 780 790 close HTML; 781 791 792 ## node hack 793 if ($webvar{node} && $webvar{node} ne '-') { 794 $sth = $ip_dbh->prepare("SELECT node_name FROM nodes WHERE node_id=?"); 795 $sth->execute($webvar{node}); 796 my ($nodename) = $sth->fetchrow_array(); 797 $html =~ s/\$\$NODENAME\$\$/$nodename/; 798 $html =~ s/\$\$NODEID\$\$/$webvar{node}/; 799 } else { 800 $html =~ s/\$\$NODENAME\$\$//; 801 $html =~ s/\$\$NODEID\$\$//; 802 } 803 ## end node hack 804 782 805 ### gotta fix this in final 783 806 # Stick in customer info as necessary - if it's blank, it just ends … … 849 872 my ($code,$msg) = allocateBlock($ip_dbh, $webvar{fullcidr}, $webvar{alloc_from}, 850 873 $webvar{custid}, $webvar{alloctype}, $webvar{city}, $webvar{desc}, $webvar{notes}, 851 $webvar{circid}, $webvar{privdata} );874 $webvar{circid}, $webvar{privdata}, $webvar{node}); 852 875 853 876 if ($code eq 'OK') { … … 1031 1054 $html =~ s/\$\$TYPESELECT\$\$/$disp_alloctypes{$data[2]}<input type=hidden name=alloctype value="$data[2]">/g; 1032 1055 } 1056 ## node hack 1057 $sth = $ip_dbh->prepare("SELECT node_id FROM noderef WHERE block='$webvar{block}'"); 1058 $sth->execute; 1059 my ($nodeid) = $sth->fetchrow_array(); 1060 if ($nodeid) { 1061 $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id"); 1062 $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n"; 1063 my $nodes = "<select name=node>\n"; 1064 while (my ($nid,$nname) = $sth->fetchrow_array()) { 1065 $nodes .= "<option".($nodeid == $nid ? ' selected' : '')." value='$nid'>$nname</option>\n"; 1066 } 1067 $nodes .= "</select>\n"; 1068 $html =~ s/\$\$NODE\$\$/$nodes/; 1069 } else { 1070 if ($data[2] eq 'fr' || $data[2] eq 'bi') { 1071 $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id"); 1072 $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n"; 1073 my $nodes = "<select name=node>\n<option value=>--</option>\n"; 1074 while (my ($nid,$nname) = $sth->fetchrow_array()) { 1075 $nodes .= "<option value='$nid'>$nname</option>\n"; 1076 } 1077 $nodes .= "</select>\n"; 1078 $html =~ s/\$\$NODE\$\$/$nodes/; 1079 } else { 1080 $html =~ s|\$\$NODE\$\$|N/A|; 1081 } 1082 } 1083 ## end node hack 1033 1084 $html =~ s/\$\$OLDCUSTID\$\$/$data[9]/g; 1034 1085 $html =~ s/\$\$CITY\$\$/<input type=text name=city value="$data[3]">/g; … … 1037 1088 $html =~ s|\$\$NOTES\$\$|<textarea rows="8" cols="64" name="notes" class="regular">$data[6]</textarea>|g; 1038 1089 } else { 1090 ## node hack 1091 if ($data[2] eq 'fr' || $data[2] eq 'bi') { 1092 $sth = $ip_dbh->prepare("SELECT node_name FROM nodes INNER JOIN noderef". 1093 " ON nodes.node_id=noderef.node_id WHERE noderef.block='$webvar{block}'"); 1094 $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n"; 1095 my ($node) = $sth->fetchrow_array; 1096 $html =~ s/\$\$NODE\$\$/$node/; 1097 } else { 1098 $html =~ s|\$\$NODE\$\$|N/A|; 1099 } 1100 ## end node hack 1039 1101 $html =~ s/\$\$CUSTID\$\$/$data[1]/g; 1040 1102 $html =~ s/\$\$OLDCUSTID\$\$/$data[9]/g; … … 1135 1197 $sth = $ip_dbh->prepare($sql); 1136 1198 $sth->execute; 1199 ## node hack 1200 if ($webvar{node}) { 1201 $ip_dbh->do("DELETE FROM noderef WHERE block='$webvar{block}'"); 1202 $sth = $ip_dbh->prepare("INSERT INTO noderef (block,node_id) VALUES (?,?)"); 1203 $sth->execute($webvar{block},$webvar{node}); 1204 } 1205 ## end node hack 1137 1206 $ip_dbh->commit; 1138 1207 };
Note:
See TracChangeset
for help on using the changeset viewer.