Changeset 98 for branches


Ignore:
Timestamp:
12/02/04 16:02:23 (20 years ago)
Author:
Kris Deugau
Message:

/branches/stable

Move most storage of alloctypes int a database table.
Note that editing a block still uses hardcoded checks, and
many other internal checks rely on specific type checks -
some of which can't be easily databasified.

Location:
branches/stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/assign.html

    r91 r98  
    1212<tr class="color2">
    1313<td>Allocation type:</td><td>
    14 <select name="alloctype"><option value="cn" selected>Customer netblock</option>
    15 <option value="si">Static IP - Server pool</option>
    16 <option value="ci">Static IP - Cable</option>
    17 <option value="di">Static IP - DSL</option>
    18 <option value="mi">Static IP - Dialup</option>
    19 <option value="wi">Static IP - Wireless</option>
    20 <option value="sp">Static Pool - Servers</option>
    21 <option value="cp">Static Pool - Cable</option>
    22 <option value="dp">Static Pool - DSL</option>
    23 <option value="mp">Static Pool - Dialup</option>
    24 <option value="wp">Static Pool - Wireless</option>
    25 <option value="ee">End-use netblock</option>
    26 <option value="dn">Dialup netblock</option>
    27 <option value="dy">Dynamic DSL block</option>
    28 <option value="dc">Dynamic cable block</option>
    29 <option value="rr">Routing</option>
     14<select name="alloctype">
     15$$TYPELIST$$
    3016</select>
    3117<input type="button" value=" ? " onclick="helpAllocTypes()" class="regular">
  • branches/stable/cgi-bin/main.cgi

    r97 r98  
    7171my @citylist;
    7272my @poplist;
     73my %disp_alloctypes;
     74my %list_alloctypes;
    7375my %allocated;  # Count for allocated blocks in a master block
    7476my %free;       # Count for free blocks (routed and unrouted) in a master block
     
    104106  if ($data[1] eq 'y') {
    105107    $poplist[$j++] = $data[0];
     108  }
     109}
     110
     111# Initialize alloctypes hashes
     112$sth = $ip_dbh->prepare("select * from alloctypes order by listorder");
     113$sth->execute;
     114while (my @data = $sth->fetchrow_array) {
     115  $disp_alloctypes{$data[0]} = $data[2];
     116  if ($data[3] < 900) {
     117    $list_alloctypes{$data[0]} = $data[1];
    106118  }
    107119}
     
    375387    }
    376388    my @row = (qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>),
    377         $data[1], $full_alloc_types{$data[2]}, $data[3], $data[4]);
     389        $data[1], $disp_alloctypes{$data[2]}, $data[3], $data[4]);
    378390    # Allow listing of pool if desired/required.
    379391    if ($data[2] =~ /^[cdsmw]p$/) {
     
    664676
    665677    my @row = ("<a href=\"/ip/cgi-bin/main.cgi?action=edit&block=$data[0]\">$data[0]</a>",
    666         $data[3], $full_alloc_types{$data[2]}, $data[1], $data[4]);
     678        $data[3], $disp_alloctypes{$data[2]}, $data[1], $data[4]);
    667679    # If the allocation is a pool, allow listing of the IPs in the pool.
    668680    if ($data[2] =~ /^[cdsmw]p$/) {
     
    731743
    732744  print qq(<center><div class="heading">Listing pool IPs for $cidr<br>\n).
    733         qq(($full_alloc_types{$type} in $data[3])</div></center><br>\n);
     745        qq(($disp_alloctypes{$type} in $data[3])</div></center><br>\n);
    734746  print qq(<div class="indent"><b>Reserved IPs:</b><br>\n);
    735747  print qq(<div class="indent"><table><tr class=color1><td>Network IP:</td><td>).
     
    789801    $html =~ s|\$\$BLOCK\$\$|$block|g;
    790802    $html =~ s|\$\$MASKBITS\$\$|$block->masklen|;
     803    my $typelist = '';
     804    $sth = $ip_dbh->prepare("select type,listname from alloctypes where listorder < 500 and type not like '_i' order by listorder");
     805    $sth->execute;
     806    my @data = $sth->fetchrow_array;
     807    $typelist .= "<option value='$data[0]' selected>$data[1]</option>\n";
     808    while (my @data = $sth->fetchrow_array) {
     809      $typelist .= "<option value='$data[0]'>$data[1]</option>\n";
     810    }
     811    $html =~ s|\$\$TYPELIST\$\$|$typelist|g;
    791812  } else {
    792813    open HTML, "../assign.html"
     
    805826    }
    806827    $html =~ s|\$\$POPLIST\$\$|$pops|g;
     828    my $typelist = '';
     829    $sth = $ip_dbh->prepare("select type,listname from alloctypes where listorder < 900 order by listorder");
     830    $sth->execute;
     831    my @data = $sth->fetchrow_array;
     832    $typelist .= "<option value='$data[0]' selected>$data[1]</option>\n";
     833    while (my @data = $sth->fetchrow_array) {
     834      $typelist .= "<option value='$data[0]'>$data[1]</option>\n";
     835    }
     836    $html =~ s|\$\$TYPELIST\$\$|$typelist|g;
    807837  }
    808838  my $cities = '';
     
    956986  # Stick in the allocation data
    957987  $html =~ s|\$\$ALLOC_TYPE\$\$|$webvar{alloctype}|g;
    958   $html =~ s|\$\$TYPEFULL\$\$|$full_alloc_types{$webvar{alloctype}}|g;
     988  $html =~ s|\$\$TYPEFULL\$\$|$disp_alloctypes{$webvar{alloctype}}|g;
    959989  $html =~ s|\$\$ALLOC_FROM\$\$|$alloc_from|g;
    960990  $html =~ s|\$\$CIDR\$\$|$cidr|g;
     
    10191049    syslog "notice", "$authuser allocated $cidr to $webvar{custid}";
    10201050# Notify tech@example.com
    1021     mailNotify('tech@example.com',"$full_alloc_types{$webvar{alloctype}} allocation",
    1022         "$full_alloc_types{$webvar{alloctype}} $cidr allocated to customer $webvar{custid}");
     1051    mailNotify('tech@example.com',"$disp_alloctypes{$webvar{alloctype}} allocation",
     1052        "$disp_alloctypes{$webvar{alloctype}} $cidr allocated to customer $webvar{custid}");
    10231053
    10241054  } else { # end IP-from-pool allocation
     
    10701100        syslog "err", "Allocation of '$webvar{fullcidr}' to '$webvar{custid}' as ".
    10711101                "'$webvar{alloctype}' by $authuser failed: '$@'";
    1072         printAndExit("Allocation of $cidr as $full_alloc_types{$webvar{alloctype}} failed.\n");
     1102        printAndExit("Allocation of $cidr as $disp_alloctypes{$webvar{alloctype}} failed.\n");
    10731103      }
    10741104
     
    11361166        syslog "err", "Allocation of '$webvar{fullcidr}' to '$webvar{custid}' as ".
    11371167                "'$webvar{alloctype}' by $authuser failed: '$@'";
    1138         printAndExit("Allocation of $cidr as $full_alloc_types{$webvar{alloctype}} failed.\n");
     1168        printAndExit("Allocation of $cidr as $disp_alloctypes{$webvar{alloctype}} failed.\n");
    11391169      }
    11401170      syslog "notice", "$authuser allocated '$webvar{fullcidr}' to '$webvar{custid}' as '$webvar{alloctype}'";
     
    11611191      eval { $ip_dbh->rollback; };
    11621192      syslog "err", "Initialization of pool '$webvar{fullcidr}' by $authuser failed: '$@'";
    1163       printAndExit("$full_alloc_types{$webvar{alloctype}} $webvar{fullcidr} not completely initialized.");
    1164     }
    1165     syslog "notice", "$full_alloc_types{$webvar{alloctype}} '$webvar{fullcidr}' successfully initialized by $authuser";
    1166 
    1167     print qq(<div class="center"><div class="heading">The block $webvar{fullcidr} was sucessfully added as type '$webvar{alloctype}' ($full_alloc_types{$webvar{alloctype}})</div></div>);
     1193      printAndExit("$disp_alloctypes{$webvar{alloctype}} $webvar{fullcidr} not completely initialized.");
     1194    }
     1195    syslog "notice", "$disp_alloctypes{$webvar{alloctype}} '$webvar{fullcidr}' successfully initialized by $authuser";
     1196
     1197    print qq(<div class="center"><div class="heading">The block $webvar{fullcidr} was sucessfully added as type '$webvar{alloctype}' ($disp_alloctypes{$webvar{alloctype}})</div></div>);
    11681198
    11691199  } # end static-IP vs netblock allocation
     
    12841314    $html =~ s/\$\$TYPESELECT\$\$/$blockoptions/g;
    12851315  } else {
    1286     $html =~ s/\$\$TYPESELECT\$\$/$full_alloc_types{$data[2]}<input type=hidden name=alloctype value="$data[2]">/g;
     1316    $html =~ s/\$\$TYPESELECT\$\$/$disp_alloctypes{$data[2]}<input type=hidden name=alloctype value="$data[2]">/g;
    12871317  }
    12881318
     
    13431373  $html =~ s/\$\$CITY\$\$/$webvar{city}/g;
    13441374  $html =~ s/\$\$ALLOCTYPE\$\$/$webvar{alloctype}/g;
    1345   $html =~ s/\$\$TYPEFULL\$\$/$full_alloc_types{$webvar{alloctype}}/g;
     1375  $html =~ s/\$\$TYPEFULL\$\$/$disp_alloctypes{$webvar{alloctype}}/g;
    13461376  $html =~ s/\$\$CUSTID\$\$/$webvar{custid}/g;
    13471377  $webvar{circid} = desanitize($webvar{circid});
     
    14261456  $html =~ s|Please confirm|Please confirm <b>removal</b> of|;
    14271457  $html =~ s|\$\$BLOCK\$\$|$cidr|g;
    1428   $html =~ s|\$\$TYPEFULL\$\$|$full_alloc_types{$alloctype}|g;
     1458  $html =~ s|\$\$TYPEFULL\$\$|$disp_alloctypes{$alloctype}|g;
    14291459  $html =~ s|\$\$ALLOCTYPE\$\$|$alloctype|g;
    14301460  $html =~ s|\$\$CITY\$\$|$city|g;
  • branches/stable/fb-assign.html

    r91 r98  
    1313<tr class="color1">
    1414<td>Allocation type:</td><td>
    15 <select name="alloctype"><option value="cn" selected>Customer netblock</option>
    16 <option value="sp">Static Pool - Servers</option>
    17 <option value="cp">Static Pool - Cable</option>
    18 <option value="dp">Static Pool - DSL</option>
    19 <option value="mp">Static Pool - Dialup</option>
    20 <option value="wp">Static Pool - Wireless</option>
    21 <option value="ee">End-use netblock</option>
    22 <option value="dn">Dialup netblock</option>
    23 <option value="dy">Dynamic DSL block</option>
    24 <option value="dc">Dynamic cable block</option>
     15<select name="alloctype">
     16$$TYPELIST$$
    2517</select>
    2618<input type="button" value=" ? " onclick="helpAllocTypes()" class="regular">
Note: See TracChangeset for help on using the changeset viewer.