- Timestamp:
- 08/17/10 15:32:16 (14 years ago)
- Location:
- branches/htmlform
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/htmlform/cgi-bin/main.cgi
r469 r470 959 959 # Two cases: block is a netblock, or block is a static IP from a pool 960 960 # because I'm lazy, we'll try to make the SELECT's bring out identical)ish) data 961 ##fixme: allow "SWIP" (publication to rWHOIS) of static IP data 961 962 if ($webvar{block} =~ /\/32$/) { 962 963 $sql = "select ip,custid,type,city,circuitid,description,notes,modifystamp,privdata from poolips where ip='$webvar{block}'"; … … 972 973 # Clean up extra whitespace on alloc type 973 974 $data[2] =~ s/\s//; 974 975 open (HTML, "../editDisplay.html")976 or croak "Could not open editDisplay.html :$!";977 my $html = join('', <HTML>);978 975 979 976 # We can't let the city be changed here; this block is a part of … … 983 980 # Needs thinking. Have to allow changes to city to correct errors, no? 984 981 # Also have areas where a routed block at a POP serves "many" cities/towns/named crossroads 985 $html =~ s/\$\$BLOCK\$\$/$webvar{block}/g; 986 987 # cidr,custid,type,city,circuitid,description,notes,modifystamp,privdata,swip 988 989 $page->param(block => $webvar{block}); 990 991 $page->param(custid => $data[1]); 992 $page->param(city => $data[3]); 993 $page->param(circid => $data[4]); 994 $page->param(desc => $data[5]); 995 $page->param(notes => $data[6]); 996 997 if ($IPDBacl{$authuser} =~ /c/) { 998 $html =~ s/\$\$CUSTID\$\$/<input type=text name=custid value="$data[1]" maxlength=15 class="regular">/; 982 983 # @data: cidr,custid,type,city,circuitid,description,notes,modifystamp,privdata,swip 984 985 $page->param(block => $webvar{block}); 986 987 $page->param(custid => $data[1]); 988 $page->param(city => $data[3]); 989 $page->param(circid => $data[4]); 990 $page->param(desc => $data[5]); 991 $page->param(notes => $data[6]); 992 999 993 ##fixme The check here should be built from the database 1000 994 # Need to expand to support pool types too 1001 if ($data[2] =~ /^.[ne]$/) {1002 $page->param(changetype => $IPDBacl{$authuser} =~ /c/);1003 $page->param(alloctype => [995 if ($data[2] =~ /^.[ne]$/ && $IPDBacl{$authuser} =~ /c/) { 996 $page->param(changetype => 1); 997 $page->param(alloctype => [ 1004 998 { selme => ($data[2] eq 'me'), type => "me", disptype => "Dialup netblock" }, 1005 999 { selme => ($data[2] eq 'de'), type => "de", disptype => "Dynamic DSL netblock" }, … … 1011 1005 ] 1012 1006 ); 1013 1014 # Block that can be changed 1015 my $blockoptions = "<select name=alloctype><option". 1016 (($data[2] eq 'me') ? ' selected' : '') ." value='me'>Dialup netblock</option>\n<option". 1017 (($data[2] eq 'de') ? ' selected' : '') ." value='de'>Dynamic DSL netblock</option>\n<option". 1018 (($data[2] eq 'ce') ? ' selected' : '') ." value='ce'>Dynamic cable netblock</option>\n<option". 1019 (($data[2] eq 'we') ? ' selected' : '') ." value='we'>Dynamic wireless netblock</option>\n<option". 1020 (($data[2] eq 'cn') ? ' selected' : '') ." value='cn'>Customer netblock</option>\n<option". 1021 (($data[2] eq 'en') ? ' selected' : '') ." value='en'>End-use netblock</option>\n<option". 1022 (($data[2] eq 'in') ? ' selected' : '') ." value='in'>Internal netblock</option>\n". 1023 "</select>\n"; 1024 $html =~ s/\$\$TYPESELECT\$\$/$blockoptions/g; 1025 } else { 1026 $html =~ s/\$\$TYPESELECT\$\$/$disp_alloctypes{$data[2]}<input type=hidden name=alloctype value="$data[2]">/g; 1027 } 1007 } else { 1008 $page->param(disptype => $disp_alloctypes{$data[2]}); 1009 $page->param(type => $data[2]); 1010 } 1011 1028 1012 ## node hack 1013 $sth = $ip_dbh->prepare("SELECT nodes.node_id,node_name FROM nodes INNER JOIN noderef". 1014 " ON nodes.node_id=noderef.node_id WHERE noderef.block='$webvar{block}'"); 1015 $sth->execute; 1016 my ($nodeid,$nodename) = $sth->fetchrow_array(); 1017 $page->param(havenodeid => $nodeid); 1018 1019 if ($data[2] eq 'fr' || $data[2] eq 'bi') { 1020 $page->param(typesupportsnodes => 1); 1021 $page->param(nodename => $nodename); 1022 1029 1023 ##fixme: this whole hack needs cleanup and generalization for all alloctypes 1030 $sth = $ip_dbh->prepare("SELECT node_id FROM noderef WHERE block='$webvar{block}'"); 1031 $sth->execute; 1032 my ($nodeid) = $sth->fetchrow_array(); 1033 $page->param(havenodeid => $nodeid); 1034 $page->param(typesupportsnodes => ($data[2] eq 'fr' || $data[2] eq 'bi')); 1035 if ($nodeid) { 1036 $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id"); 1037 $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n"; 1038 my $nodes = "<select name=node>\n"; 1039 my @nodelist; 1040 while (my ($nid,$nname) = $sth->fetchrow_array()) { 1041 $nodes .= "<option".($nodeid == $nid ? ' selected' : '')." value='$nid'>$nname</option>\n"; 1042 my %row = ( 1043 selme => ($nodeid == $nid), 1044 nodeid => $nid, 1045 nodename => $nname, 1046 ); 1047 push (@nodelist, \%row); 1048 } 1049 $page->param(nodelist => \@nodelist); 1050 $nodes .= "</select>\n"; 1051 $html =~ s/\$\$NODE\$\$/$nodes/; 1052 } else { 1053 if ($data[2] eq 'fr' || $data[2] eq 'bi') { 1024 ##fixme: arguably a bug that presence of a nodeid implies it can be changed.. 1025 # but except for manual database changes, only the two types fr and bi can 1026 # (currently) have a nodeid set in the first place. 1027 if ($IPDBacl{$authuser} =~ /c/) { 1054 1028 $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id"); 1055 $sth->execute () or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n";1056 my $nodes = "<select name=node>\n<option value=>--</option>\n";1029 $sth->execute; 1030 my @nodelist; 1057 1031 while (my ($nid,$nname) = $sth->fetchrow_array()) { 1058 $nodes .= "<option value='$nid'>$nname</option>\n"; 1032 my %row = ( 1033 selme => ($nodeid == $nid), 1034 nodeid => $nid, 1035 nodename => $nname, 1036 ); 1037 push (@nodelist, \%row); 1059 1038 } 1060 $nodes .= "</select>\n"; 1061 $html =~ s/\$\$NODE\$\$/$nodes/; 1062 } else { 1063 $html =~ s|\$\$NODE\$\$|N/A|; 1039 $page->param(nodelist => \@nodelist); 1064 1040 } 1065 1041 } 1066 1042 ## end node hack 1067 $html =~ s/\$\$CITY\$\$/<input type=text name=city value="$data[3]">/g; 1068 $html =~ s/\$\$CIRCID\$\$/<input type="text" name="circid" value="$data[4]" maxlength=64 size=64 class="regular">/g; 1069 $html =~ s/\$\$DESC\$\$/<input type="text" name="desc" value="$data[5]" maxlength=64 size=64 class="regular">/g; 1070 $html =~ s|\$\$NOTES\$\$|<textarea rows="8" cols="64" name="notes" class="regular">$data[6]</textarea>|g; 1071 } else { 1072 ## node hack 1073 if ($data[2] eq 'fr' || $data[2] eq 'bi') { 1074 $sth = $ip_dbh->prepare("SELECT node_name FROM nodes INNER JOIN noderef". 1075 " ON nodes.node_id=noderef.node_id WHERE noderef.block='$webvar{block}'"); 1076 $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n"; 1077 my ($node) = $sth->fetchrow_array; 1078 $html =~ s/\$\$NODE\$\$/$node/; 1079 } else { 1080 $html =~ s|\$\$NODE\$\$|N/A|; 1081 } 1082 ## end node hack 1083 $html =~ s/\$\$CUSTID\$\$/$data[1]/g; 1084 $html =~ s/\$\$TYPESELECT\$\$/$disp_alloctypes{$data[2]}/g; 1085 $html =~ s/\$\$CITY\$\$/$data[3]/g; 1086 $html =~ s/\$\$CIRCID\$\$/$data[4]/g; 1087 $html =~ s/\$\$DESC\$\$/$data[5]/g; 1088 $html =~ s/\$\$NOTES\$\$/$data[6]/g; 1089 } 1043 1090 1044 my ($lastmod,undef) = split /\s+/, $data[7]; 1091 1045 $page->param(lastmod => $lastmod); 1092 1046 1093 ## Hack time! SWIP isn't going to stay, so I'm not going to integrate it with ACLs. 1094 if ($data[2] =~ /.i/) { 1095 $html =~ s/\$\$SWIP\$\$/N\/A/; 1096 } else { 1097 my $tmp = (($data[10] eq 'n') ? '<input type=checkbox name=swip>' : 1098 '<input type=checkbox name=swip checked=yes>'); 1099 $html =~ s/\$\$SWIP\$\$/$tmp/; 1100 } 1101 1102 # Allows us to "correctly" colour backgrounds in table 1103 my $i=1; 1047 # not happy with the upside-down logic, but... 1048 $page->param(swipable => $data[2] !~ /.i/); 1049 $page->param(swip => $data[10] ne 'n'); 1104 1050 1105 1051 # Check to see if we can display sensitive data 1106 my $privdata = ''; 1107 $page->param(nocling => $IPDBacl{$authuser} =~ /s/); 1108 $page->param(privdata => $data[8]); 1109 1110 if ($IPDBacl{$authuser} =~ /s/) { 1111 $privdata = qq(<tr class="color).($i%2).qq("><td class=heading>Restricted data:</td>). 1112 qq(<td class=regular><textarea rows="3" cols="64" name="privdata" class="regular">). 1113 qq($data[8]</textarea></td></tr>\n); 1114 $i++; 1115 } 1116 $html =~ s/\$\$PRIVDATA\$\$/$privdata/g; 1117 1118 # More ACL trickery - we can live with forms that don't submit, 1119 # but we can't leave the extra table rows there, and we *really* 1120 # can't leave the submit buttons there. 1121 my $updok = ''; 1122 $page->param(maychange => $IPDBacl{$authuser} =~ /c/); 1123 if ($IPDBacl{$authuser} =~ /c/) { 1124 $updok = qq(<tr class="color).($i%2).qq("><td colspan=2><div class="center">). 1125 qq(<input type="submit" value=" Update this block " class="regular">). 1126 "</div></td></tr></form>\n"; 1127 $i++; 1128 } 1129 $html =~ s/\$\$UPDOK\$\$/$updok/g; 1130 1131 my $delok = ''; 1132 $page->param(maydel => $IPDBacl{$authuser} =~ /d/); 1133 if ($IPDBacl{$authuser} =~ /d/) { 1134 $delok = qq(<form method="POST" action="main.cgi"> 1135 <tr class="color).($i%2).qq("><td colspan=2 class="regular"><div class=center> 1136 <input type="hidden" name="action" value="delete"> 1137 <input type="hidden" name="block" value="$webvar{block}"> 1138 <input type="hidden" name="alloctype" value="$data[2]"> 1139 <input type=submit value=" Delete this block "> 1140 </div></td></tr>); 1141 } 1142 $html =~ s/\$\$DELOK\$\$/$delok/; 1143 1144 # print $html; 1052 $page->param(nocling => $IPDBacl{$authuser} =~ /s/); 1053 $page->param(privdata => $data[8]); 1054 1055 # ACL trickery - these two template booleans control the presence of all form/input tags 1056 $page->param(maychange => $IPDBacl{$authuser} =~ /c/); 1057 $page->param(maydel => $IPDBacl{$authuser} =~ /d/); 1145 1058 1146 1059 } # edit() -
branches/htmlform/templates/edit.tmpl
r469 r470 2 2 <div class="heading">Edit the information below</div> 3 3 4 <!-- table class="indent" size="33%" cellspacing=1 bgcolor="black" --> 5 6 <table> 4 <table cellpadding="0" cellspacing="0"> 7 5 <tr> 8 6 <td> … … 15 13 </TMPL_IF> 16 14 17 <table cellspacing= 1>15 <table cellspacing="1"> 18 16 19 17 <tr class="row0"> … … 43 41 <TMPL_ELSE> 44 42 <TMPL_VAR NAME=disptype> 43 <input type="hidden" name="alloctype" value="<TMPL_VAR NAME=type>"> 45 44 </TMPL_IF> 46 45 </td> … … 58 57 </select> 59 58 <TMPL_ELSE> 60 <TMPL_ VAR NAME=nodename>59 <TMPL_IF nodename><TMPL_VAR NAME=nodename><TMPL_ELSE>N/A</TMPL_IF> 61 60 </TMPL_IF> 62 61 <TMPL_ELSE> … … 80 79 <td class=heading>SWIPed?:</td> 81 80 <td class=regular> 81 <TMPL_IF swipable> 82 82 <TMPL_IF maychange> 83 <input type= checkbox name=swip <TMPL_IF swip>checked=yes</TMPL_IF>>83 <input type="checkbox" name="swip" <TMPL_IF swip>checked="checked"</TMPL_IF>> 84 84 <TMPL_ELSE> 85 85 <TMPL_IF swip>Yes<TMPL_ELSE>No</TMPL_IF> 86 </TMPL_IF> 87 <TMPL_ELSE> 88 N/A 86 89 </TMPL_IF> 87 90 </td> … … 127 130 <TMPL_IF nocling> 128 131 <tr class="row0"> 129 <td class= heading>Restricted data:</td>130 <td class= regular>132 <td class="heading" valign="top">Restricted data:</td> 133 <td class="regular"> 131 134 <TMPL_IF maychange> 132 135 <textarea rows="3" cols="64" name="privdata" class="regular"><TMPL_VAR NAME=privdata></textarea> … … 137 140 </tr> 138 141 </TMPL_IF> 139 </table>140 142 141 143 <TMPL_IF maychange> 142 <div class="row0"><input type="submit" value=" Update this block " class="regular"></div> 144 <tr class="row<TMPL_IF nocling>1<TMPL_ELSE>0</TMPL_IF>"> 145 <td colspan="2" class="center"> 146 <input type="submit" value=" Update this block " class="regular"> 147 </td> 148 </tr> 149 </TMPL_IF> 150 </table> 151 <TMPL_IF maychange> 143 152 </fieldset> 144 153 </form> … … 146 155 147 156 <TMPL_IF maydel> 157 </td></tr> 158 <tr><td class="center"> 148 159 <form method="POST" action="main.cgi"> 149 <div class="row1"> 160 <fieldset><legend></legend> 161 <div class="row<TMPL_IF nocling><TMPL_IF maychange>0<TMPL_ELSE>1</TMPL_IF><TMPL_ELSE><TMPL_IF maychange>1<TMPL_ELSE>0</TMPL_IF></TMPL_IF>"> 150 162 <input type="hidden" name="action" value="delete"> 151 <input type="hidden" name="block" value=" 1.2.14.24/29">152 <input type="hidden" name="alloctype" value=" me">163 <input type="hidden" name="block" value="<TMPL_VAR NAME=block>"> 164 <input type="hidden" name="alloctype" value="<TMPL_VAR NAME=type>"> 153 165 <input type=submit value=" Delete this block "> 154 166 </div> 167 </fieldset> 155 168 </form> 156 169 </TMPL_IF> 170 157 171 </td> 158 172 </tr>
Note:
See TracChangeset
for help on using the changeset viewer.