Changeset 111 for trunk/cgi-bin
- Timestamp:
- 12/24/04 15:10:56 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/main.cgi
r106 r111 127 127 } 128 128 129 printFooter;130 129 } # end add new master 131 130 … … 149 148 viewBy($webvar{searchfor}, $webvar{input}); 150 149 } 151 printFooter();152 150 } 153 151 … … 188 186 printAndExit("Error $boing: ".$excuses[$rnd/30.0]); 189 187 } 188 ## Finally! Done with that NASTY "case" emulation! 190 189 191 190 192 191 193 192 # Clean up IPDB globals, DB handle, etc. 194 finish; 193 finish($ip_dbh); 194 # We print the footer here, so we don't have to do it elsewhere. 195 printFooter; 195 196 # Just in case something waaaayyy down isn't in place 196 197 # properly... we exit explicitly. 197 198 exit; 199 198 200 199 201 … … 294 296 } else { 295 297 # This shouldn't happen, but if it does, whoever gets it deserves what they get... 296 print AndExit("Invalid query.");298 printError("Invalid query."); 297 299 } 298 300 } else { 299 301 # This shouldn't happen, but if it does, whoever gets it deserves what they get... 300 print AndExit("Invalid searchfor.");302 printError("Invalid searchfor."); 301 303 } 302 304 } # viewBy … … 477 479 print "Note: Free blocks noted here include both routed and unrouted blocks.\n"; 478 480 479 # Because of the way this sub gets called, we don't need to print the footer here.480 # (index.shtml makes an SSI #include call to cgi-bin/main.cgi?action=index)481 # If we do, the footer comes in twice...482 #printFooter;483 481 } # showSummary 484 482 … … 608 606 609 607 print "</table>\n"; 610 printFooter;611 608 } # showMaster 612 609 … … 696 693 697 694 print "</table>\n"; 698 printFooter;699 695 } # showRBlock 700 696 … … 752 748 print "</table>\n"; 753 749 754 printFooter;755 750 } # end listPool 756 751 … … 815 810 print $html; 816 811 817 printFooter();818 812 } # assignBlock 819 813 … … 828 822 # Going to manually validate some items. 829 823 # custid and city are automagic. 830 validateInput(); 831 832 # This isn't always useful. 833 # if (!$webvar{maskbits}) { 834 # printAndExit("Please enter a CIDR block length."); 835 # } 824 return if !validateInput(); 836 825 837 826 # Several different cases here. … … 882 871 883 872 if (!$webvar{maskbits}) { 884 printAndExit("Please specify a CIDR mask length."); 873 printError("Please specify a CIDR mask length."); 874 return; 885 875 } 886 876 my $sql; … … 901 891 if ($webvar{alloctype} =~ /^[cdsmw]p$/) { 902 892 if (($webvar{city} !~ /^(Sudbury|North Bay)$/) && ($webvar{alloctype} eq 'dp')) { 903 printAndExit("You must chose Sudbury or North Bay for DSL pools."); } 893 printError("You must chose Sudbury or North Bay for DSL pools."); 894 return; 895 } 904 896 $city = $webvar{city}; 905 897 $failmsg = "No suitable free block found.<br>\nYou will have to route another". … … 924 916 my @data = $sth->fetchrow_array(); 925 917 if ($data[0] eq "") { 926 printAndExit($failmsg); 918 printError($failmsg); 919 return; 927 920 } 928 921 $cidr = new NetAddr::IP $data[0]; … … 973 966 print $html; 974 967 975 printFooter;976 968 } # end confirmAssign 977 969 … … 981 973 # Some things are done more than once. 982 974 printHeader(''); 983 validateInput();975 return if !validateInput(); 984 976 985 977 # $code is "success" vs "failure", $msg contains OK for a … … 990 982 $webvar{circid}); 991 983 992 if ($code) { 993 syslog "err", "Allocation of '$webvar{fullcidr}' to '$webvar{custid}' as ". 994 "'$webvar{alloctype}' by $authuser failed: '$msg'"; 995 printAndExit("Allocation of $webvar{fullcidr} as $disp_alloctypes{$webvar{alloctype}}". 996 " failed: $msg\n"); 997 } else { 984 if ($code eq 'OK') { 998 985 if ($webvar{alloctype} =~ /^.i$/) { 999 986 print qq(<div class="center"><div class="heading">The IP $msg has been allocated to customer $webvar{custid}</div></div>); 1000 987 # Notify tech@example.com 1001 988 mailNotify('tech@example.com',"$disp_alloctypes{$webvar{alloctype}} allocation", 1002 "$disp_alloctypes{$webvar{alloctype}} $msg allocated to customer $webvar{custid}"); 989 "$disp_alloctypes{$webvar{alloctype}} $msg allocated to customer $webvar{custid}\n". 990 "Description: $webvar{desc}\n\nAllocated by: $authuser\n"); 1003 991 } else { 1004 992 print qq(<div class="center"><div class="heading">The block $webvar{fullcidr} was ). … … 1008 996 syslog "notice", "$authuser allocated '$webvar{fullcidr}' to '$webvar{custid}' as ". 1009 997 "'$webvar{alloctype}'"; 1010 } 1011 1012 printFooter(); 998 } else { 999 syslog "err", "Allocation of '$webvar{fullcidr}' to '$webvar{custid}' as ". 1000 "'$webvar{alloctype}' by $authuser failed: '$msg'"; 1001 printError("Allocation of $webvar{fullcidr} as $disp_alloctypes{$webvar{alloctype}}". 1002 " failed: $msg\n"); 1003 } 1004 1013 1005 } # end insertAssign() 1014 1006 … … 1019 1011 sub validateInput { 1020 1012 if ($webvar{city} eq '-') { 1021 printAndExit("Please choose a city."); 1013 printError("Please choose a city."); 1014 return; 1022 1015 } 1023 1016 chomp $webvar{alloctype}; … … 1025 1018 if ($webvar{alloctype} =~ /^(ci|di|cn|mi|wi)$/) { 1026 1019 if (!$webvar{custid}) { 1027 printAndExit("Please enter a customer ID."); 1020 printError("Please enter a customer ID."); 1021 return; 1028 1022 } 1029 1023 if ($webvar{custid} !~ /^(?:\d{10}|\d{7}|STAFF|TEMP)(?:-\d\d?)?$/) { 1030 printAndExit("Please enter a valid customer ID- this must be a 7- or 10-digit number, or STAFF for static IPs for staff."); 1024 printError("Please enter a valid customer ID- this must be a 7- or 10-digit number, or STAFF for static IPs for staff."); 1025 return; 1031 1026 } 1032 1027 print "<!-- [ In validateInput(). Insert customer ID cross-check here. ] -->\n"; 1033 } elsif ($webvar{alloctype} =~ /^([cdsmw]p|si|dn|dy|dc|ee|rr|i i)$/){1028 } elsif ($webvar{alloctype} =~ /^([cdsmw]p|si|dn|dy|dc|ee|rr|in)$/){ 1034 1029 # All non-customer allocations MUST be entered with "our" customer ID. 1035 1030 # I have Defined this as 6750400 for consistency. 1036 1031 $webvar{custid} = "6750400"; 1037 if ($webvar{alloctype} eq 'rr') {1038 my $flag;1039 foreach (@poplist) {1040 if (/^$webvar{city}$/) {1041 $flag = 'y'; last;1042 }1043 }1044 if (!$flag) {1045 printAndExit("Please choose a valid POP location for a routed netblock. Valid ".1046 "POP locations are currently:<br>\n".join (" - ", @poplist));1047 }1048 }1049 1032 } else { 1050 print "$webvar{alloctype}";1051 1033 # Danger! Danger! alloctype should ALWAYS be set by a dropdown. Anyone 1052 1034 # managing to call things in such a way as to cause this deserves a cryptic error. 1053 printAndExit("Invalid alloctype"); 1054 } 1055 return 0; 1035 printError("Invalid alloctype"); 1036 return; 1037 } 1038 1039 # Check POP location 1040 my $flag; 1041 if ($webvar{alloctype} eq 'rr') { 1042 $flag = 'for a routed netblock'; 1043 foreach (@poplist) { 1044 if (/^$webvar{city}$/) { 1045 $flag = 'n'; 1046 last; 1047 } 1048 } 1049 } else { 1050 $flag = 'n'; 1051 if ($webvar{pop} =~ /^-$/) { 1052 $flag = 'to route the block from/through'; 1053 } 1054 } 1055 if ($flag ne 'n') { 1056 printError("Please choose a valid POP location $flag. Valid ". 1057 "POP locations are currently:<br>\n".join (" - ", @poplist)); 1058 return; 1059 } 1060 1061 return 'OK'; 1056 1062 } # end validateInput 1057 1063 … … 1128 1134 print $html; 1129 1135 1130 printFooter();1131 1136 } # edit() 1132 1137 … … 1164 1169 eval { $ip_dbh->rollback; }; 1165 1170 syslog "err", "$authuser could not update block/IP '$webvar{block}': '$@'"; 1166 printAndExit("Could not update block/IP $webvar{block}: $@"); 1171 printError("Could not update block/IP $webvar{block}: $@"); 1172 return; 1167 1173 } 1168 1174 … … 1170 1176 syslog "notice", "$authuser updated $webvar{block}"; 1171 1177 open (HTML, "../updated.html") 1172 1178 or croak "Could not open updated.html :$!"; 1173 1179 my $html = join('', <HTML>); 1174 1180 … … 1188 1194 print $html; 1189 1195 1190 printFooter;1191 1196 } # update() 1192 1197 … … 1203 1208 # Serves'em right for getting here... 1204 1209 if (!defined($webvar{block})) { 1205 printAndExit("Error 332"); 1210 printError("Error 332"); 1211 return; 1206 1212 } 1207 1213 … … 1277 1283 1278 1284 print $html; 1279 printFooter;1280 1285 } # end edit() 1281 1286 … … 1296 1301 if ($webvar{alloctype} =~ /^.i$/) { 1297 1302 syslog "err", "$authuser could not deallocate static IP '$webvar{block}': '$msg'"; 1298 print AndExit("Could not deallocate static IP $webvar{block}: $msg");1303 printError("Could not deallocate static IP $webvar{block}: $msg"); 1299 1304 } else { 1300 1305 syslog "err", "$authuser could not deallocate netblock '$webvar{block}': '$msg'"; 1301 printAndExit("Could not deallocate netblock $webvar{block}: $msg"); 1302 } 1303 } 1304 1305 printFooter; 1306 printError("Could not deallocate netblock $webvar{block}: $msg"); 1307 } 1308 } 1309 1306 1310 } # finalDelete 1307 1311
Note:
See TracChangeset
for help on using the changeset viewer.