Changeset 463 for branches/htmlform/cgi-bin
- Timestamp:
- 08/05/10 17:34:29 (14 years ago)
- File:
-
- 1 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/));
Note:
See TracChangeset
for help on using the changeset viewer.