Changeset 463
- Timestamp:
- 08/05/10 17:34:29 (14 years ago)
- Location:
- branches/htmlform
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/htmlform/cgi-bin/main.cgi
r461 r463 56 56 57 57 my $header = HTML::Template->new(filename => "header.tmpl"); 58 my $footer = HTML::Template->new(filename => "footer.tmpl"); 59 58 60 $header->param(version => $IPDB::VERSION); 59 61 $header->param(addperm => $IPDBacl{$authuser} =~ /a/); … … 183 185 # if $IPDBacl{$authuser} =~ /A/; 184 186 187 ## Do all our printing here so we can generate errors and stick them into the slots in the templates. 188 189 # can't do this yet, too many blowups 190 #print "Content-type: text/html\n\n", $header->output; 191 185 192 print $page->output; 186 193 187 # We print the footer here, so we don't have to do it elsewhere.188 my $footer = HTML::Template->new(filename => "footer.tmpl");189 194 # include the admin tools link in the output? 190 195 $footer->param(adminlink => ($IPDBacl{$authuser} =~ /A/)); … … 639 644 # could arguably include routing (500) in the list, but ATM it doesn't 640 645 # make sense, and in any case that shouldn't be structurally possible here. 641 $sth = $ip_dbh->prepare("select type,listname from alloctypes where listorder < 500 order by listorder");646 $sth = $ip_dbh->prepare("select type,listname from alloctypes where listorder <= 500 order by listorder"); 642 647 $sth->execute; 643 648 my @typelist; … … 706 711 $sth->execute; 707 712 my $optionlist; 708 while (my @data = $sth->fetchrow_array) { 713 714 my @poollist; 715 while (my ($poolcit,$poolblock,$poolfree) = $sth->fetchrow_array) { 709 716 # city,pool cidr,free IP count 710 if ($data[2] > 0) { 711 $optionlist .= "<option value='$data[1]'>$data[1] [$data[2] free IP(s)] in $data[0]</option>\n"; 717 if ($poolfree > 0) { 718 my %row = (poolcit => $poolcit, poolblock => $poolblock, poolfree => $poolfree); 719 push (@poollist, \%row); 712 720 } 713 721 } 722 $page->param(staticip => 1); 723 $page->param(poollist => \@poollist); 714 724 $cidr = "Single static IP"; 715 $alloc_from = "<select name=alloc_from>".$optionlist."</select>\n"; 725 ##fixme: need to handle "no available pools" 716 726 717 727 } else { # end show pool options … … 723 733 724 734 if (!$webvar{maskbits}) { 725 printError("Please specify a CIDR mask length.");735 $page->param(err => "Please specify a CIDR mask length."); 726 736 return; 727 737 } … … 782 792 my @data = $sth->fetchrow_array(); 783 793 if ($data[0] eq "") { 784 printError($failmsg);794 $page->param(err => $failmsg); 785 795 return; 786 796 } … … 788 798 } # check for freeblocks assignment or IPDB-controlled assignment 789 799 790 ##fixme: HTML must be removed from script! 791 $alloc_from = qq($cidr<input type=hidden name=alloc_from value="$cidr">); 800 $alloc_from = "$cidr"; 792 801 793 802 # If the block to be allocated is smaller than the one we found, … … 860 869 # successful netblock allocation, the IP allocated for static 861 870 # IP, or the error message if an error occurred. 871 862 872 my ($code,$msg) = allocateBlock($ip_dbh, $webvar{fullcidr}, $webvar{alloc_from}, 863 873 $webvar{custid}, $webvar{alloctype}, $webvar{city}, $webvar{desc}, $webvar{notes}, … … 867 877 if ($webvar{alloctype} =~ /^.i$/) { 868 878 $msg =~ s|/32||; 869 print qq(<div class="center"><div class="heading">The IP $msg has been allocated to customer $webvar{custid}</div>). 870 ( ($webvar{alloctype} eq 'di' && $webvar{billinguser}) ? 871 qq(<div><a href="https://billing.example.com/radius.pl?). 872 "action=new_radius_user&custid=$webvar{custid}&userid=$webvar{billinguser}". 873 qq(&ipdb=1&ip=$msg">Add this IP to RADIUS user table</a></div>) 874 : "</div>"); 879 $page->param(staticip => $msg); 880 $page->param(custid => $webvar{custid}); 881 $page->param(billinguser => $webvar{billinguser}); 875 882 mailNotify($ip_dbh, "a$webvar{alloctype}", "ADDED: $disp_alloctypes{$webvar{alloctype}} allocation", 876 883 "$disp_alloctypes{$webvar{alloctype}} $msg allocated to customer $webvar{custid}\n". … … 878 885 } else { 879 886 my $netblock = new NetAddr::IP $webvar{fullcidr}; 880 print qq(<div class="center"><div class="heading">The block $webvar{fullcidr} was ).881 "sucessfully added as: $disp_alloctypes{$webvar{alloctype}}</div>". 882 ( ($webvar{alloctype} eq 'pr' && $webvar{billinguser}) ? 883 qq(<div><a href="https://billing.example.com/radius.pl?). 884 "action=new_radius_user&custid=$webvar{custid}&userid=$webvar{billinguser}".885 "&route_subnet=".$netblock->addr."&subnet_slash=".$netblock->masklen.886 "&include_routed_subnet=1&ipdb=1".887 qq(">Add this netblock to RADIUS user table</a></div>)888 : "</div>"); 887 $page->param(fullcidr => $webvar{fullcidr}); 888 $page->param(alloctype => $disp_alloctypes{$webvar{alloctype}}); 889 $page->param(custid => $webvar{custid}); 890 if ($webvar{alloctype} eq 'pr' && $webvar{billinguser}) { 891 $page->param(billinguser => $webvar{billinguser}); 892 $page->param(custid => $webvar{custid}); 893 $page->param(netaddr => $netblock->addr); 894 $page->param(masklen => $netblock->masklen); 895 } 889 896 mailNotify($ip_dbh, "a$webvar{alloctype}", "ADDED: $disp_alloctypes{$webvar{alloctype}} allocation", 890 897 "$disp_alloctypes{$webvar{alloctype}} $webvar{fullcidr} allocated to customer $webvar{custid}\n". … … 896 903 syslog "err", "Allocation of '$webvar{fullcidr}' to '$webvar{custid}' as ". 897 904 "'$webvar{alloctype}' by $authuser failed: '$msg'"; 898 printError("Allocation of $webvar{fullcidr} as '$disp_alloctypes{$webvar{alloctype}}'".905 $page->param(err => "Allocation of $webvar{fullcidr} as '$disp_alloctypes{$webvar{alloctype}}'". 899 906 " failed:<br>\n$msg\n"); 900 907 } … … 1407 1414 1408 1415 # We print the footer here, so we don't have to do it elsewhere. 1409 my $footer = HTML::Template->new(filename => "footer.tmpl");1410 1416 # include the admin tools link in the output? 1411 1417 $footer->param(adminlink => ($IPDBacl{$authuser} =~ /A/)); -
branches/htmlform/ipdb.css
r461 r463 4 4 padding: 0px; 5 5 margin: 0px; 6 } 7 8 #debug { 9 background-color: #990066; 10 padding: 2px; 6 11 } 7 12 … … 176 181 } 177 182 183 .err { 184 text-align: center; 185 font-size: 100%; 186 } 187 178 188 .red { 179 189 font-weight: bold; -
branches/htmlform/templates/assign.tmpl
r460 r463 37 37 <TMPL_VAR NAME=fbdisptype><input type="hidden" name="alloctype" value="<TMPL_VAR NAME=type>"> 38 38 <TMPL_ELSE> 39 <select >39 <select name="alloctype"> 40 40 <TMPL_LOOP name=typelist> 41 41 <option value="<TMPL_VAR NAME=tval>"<TMPL_VAR NAME=sel>><TMPL_VAR NAME=type></option></TMPL_LOOP> -
branches/htmlform/templates/confirm.tmpl
r461 r463 1 <TMPL_IF err> 2 <div class="err"> 3 <p><TMPL_VAR NAME=err></p> 4 <input type="button" value="Back" onclick="history.go(-1)"> 5 </div> 6 <TMPL_ELSE> 1 7 <div class="heading">Please confirm</div> 2 8 <div class="indent"> 9 10 <form method="POST" action="main.cgi" class="regular"> 11 <fieldset><legend></legend> 3 12 <table class="regular" cellspacing="1" cellpadding="1"> 4 13 … … 10 19 <tr class="row1"> 11 20 <td>Block allocation is taken from:</td> 21 <TMPL_IF staticip> 22 <td> 23 <select name="alloc_from"> 24 <TMPL_LOOP name=poollist> <option value="<TMPL_VAR NAME=poolblock>"><TMPL_VAR NAME=poolblock> [<TMPL_VAR NAME=poolfree>] free IP(s) in <TMPL_VAR NAME=poolcit></option> 25 </TMPL_LOOP></select> 26 </td> 27 <TMPL_ELSE> 12 28 <td><TMPL_VAR NAME=alloc_from></td> 29 </TMPL_IF> 13 30 </tr> 14 31 … … 58 75 <tr class="<TMPL_IF privdata>row0<TMPL_ELSE>row1</TMPL_IF>"> 59 76 <td class="center" colspan="2"> 60 <form method="POST" action="main.cgi" class="regular"> 61 <fieldset><legend></legend> 77 <TMPL_UNLESS poollist><input type="hidden" name="alloc_from" value="<TMPL_VAR NAME=alloc_from>"></TMPL_UNLESS> 62 78 <input type="hidden" name="fullcidr" value="<TMPL_VAR NAME=cidr>"> 63 79 <input type="hidden" name="city" value="<TMPL_VAR NAME=city>"> … … 76 92 <input type="hidden" name="action" value="<TMPL_VAR NAME=action>"> 77 93 <input type="button" value="Back" onclick="history.go(-1)"><input type="submit" value="Confirm"> 94 </td></tr> 95 </table> 78 96 </fieldset> 79 97 </form> 80 </td></tr>81 </table>82 98 </div> 99 </TMPL_IF>
Note:
See TracChangeset
for help on using the changeset viewer.