Changeset 138 for trunk/cgi-bin/main.cgi


Ignore:
Timestamp:
01/26/05 17:31:33 (19 years ago)
Author:
Kris Deugau
Message:

/trunk

Redesign alloctype check so that it checks alloctypes that have
been loaded from the DB, rather than relying on hardcoded (and
therefore easy-to-forget-when-updating) entries.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/main.cgi

    r137 r138  
    987987    return;
    988988  }
     989
     990  # Alloctype check.
    989991  chomp $webvar{alloctype};
    990   # We have different handling for customer allocations and "internal" or "our" allocations
    991   if ($webvar{alloctype} =~ /^(ci|di|cn|mi|wi)$/) {
    992     if (!$webvar{custid}) {
    993       printError("Please enter a customer ID.");
    994       return;
    995     }
    996     if ($webvar{custid} !~ /^(?:\d{10}|\d{7}|STAFF|TEMP)(?:-\d\d?)?$/) {
    997       printError("Please enter a valid customer ID- this must be a 7- or 10-digit number, or STAFF for static IPs for staff.");
    998       return;
    999     }
    1000     print "<!-- [ In validateInput().  Insert customer ID cross-check here. ] -->\n";
    1001   } elsif ($webvar{alloctype} =~ /^([cdsmw]p|si|dn|dy|dc|dw|ee|rr|in)$/){
    1002     # All non-customer allocations MUST be entered with "our" customer ID.
    1003     # I have Defined this as 6750400 for consistency.
    1004     $webvar{custid} = "6750400";
    1005   } else {
     992  if (!grep /$webvar{alloctype}/, keys %disp_alloctypes) {
    1006993    # Danger! Danger!  alloctype should ALWAYS be set by a dropdown.  Anyone
    1007994    # managing to call things in such a way as to cause this deserves a cryptic error.
    1008995    printError("Invalid alloctype");
    1009996    return;
     997  }
     998
     999  # CustID check
     1000  # We have different handling for customer allocations and "internal" or "our" allocations
     1001  if ($webvar{alloctype} =~ /^(cn|.i)$/) {
     1002    if (!$webvar{custid}) {
     1003      printError("Please enter a customer ID.");
     1004      return;
     1005    }
     1006    if ($webvar{custid} !~ /^(?:\d{10}|\d{7}|STAFF|TEMP)(?:-\d\d?)?$/) {
     1007      printError("Please enter a valid customer ID- this must be a 7- or 10-digit number, or STAFF for static IPs for staff.");
     1008      return;
     1009    }
     1010    print "<!-- [ In validateInput().  Insert customer ID cross-check here. ] -->\n";
     1011  } else {
     1012    # All non-customer allocations MUST be entered with "our" customer ID.
     1013    # I have Defined this as 6750400 for consistency.
     1014    $webvar{custid} = "6750400";
    10101015  }
    10111016
Note: See TracChangeset for help on using the changeset viewer.