Changeset 798 for trunk/cgi-bin/main.cgi
- Timestamp:
- 12/23/15 15:46:13 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/main.cgi
r793 r798 676 676 $page->param(bkepass => $q->escapeHTML($webvar{bkepass})); 677 677 $page->param(bkport => $webvar{bkport}); 678 $page->param(bkip => $webvar{bkip}); 678 679 } 679 680 … … 739 740 if ($webvar{backupfields}) { 740 741 $insert_args{backup} = 1; 741 $insert_args{bkbrand} = $webvar{bkbrand}; 742 $insert_args{bkmodel} = $webvar{bkmodel}; 743 for my $bkfield (qw(type src user vpass epass port)) { 742 for my $bkfield (@IPDB::backupfields) { 744 743 $insert_args{"bk$bkfield"} = ($webvar{"bk$bkfield"} ? $webvar{"bk$bkfield"} : ''); 745 744 } … … 908 907 # Backup fields. Minimal sanity checks. 909 908 for my $bkfield (qw(brand model)) { 910 if ($webvar{"bk$bkfield"} && $webvar{"bk$bkfield"} !~ /^[a-zA-Z0-9\s_.-]+$/) { 909 if (!$webvar{"bk$bkfield"}) { 910 $page->param(err => "Backup $bkfield must be filled in if IP/netblock is flagged for backup"); 911 return; 912 } 913 if ($webvar{"bk$bkfield"} !~ /^[a-zA-Z0-9\s_.-]+$/) { 911 914 $page->param(err => "Invalid characters in backup $bkfield"); 912 915 return; … … 924 927 if ($webvar{bkport} !~ /^\d+$/) { 925 928 $page->param(err => "Backup port must be numeric"); 929 return; 930 } 931 } 932 ##fixme: code review: should normalize $webvar{cidr} variants so we can 933 # check for non-/32 allocations having the backup IP field filled in here, 934 # instead of failing on the allocation or update attempt 935 if ($webvar{bkip}) { 936 $webvar{bkip} =~ s/^\s+//g; 937 $webvar{bkip} =~ s/\s+$//g; 938 if ($webvar{bkip} !~ /^[\da-fA-F:.]+$/) { 939 $page->param(err => "Backup IP must be an IP"); 926 940 return; 927 941 } … … 990 1004 if ($blockinfo->{hasbk}) { 991 1005 $page->param(hasbackup => $blockinfo->{hasbk}); 992 for my $bkfield ( qw(brand model src user vpass epass port)) {1006 for my $bkfield (@IPDB::backupfields) { 993 1007 $page->param("bk$bkfield" => $blockinfo->{"bk$bkfield"}); 994 1008 } … … 1125 1139 if ($IPDBacl{$authuser} =~ /s/) { 1126 1140 $updargs{privdata} = $webvar{privdata}; 1127 for my $bkfield ( qw(brand model type src user vpass epass port)) {1141 for my $bkfield (@IPDB::backupfields) { 1128 1142 $updargs{"bk$bkfield"} = $webvar{"bk$bkfield"}; 1129 1143 } 1130 $updargs{backup fields} = $webvar{backupfields};1144 $updargs{backup} = $webvar{backupfields}; 1131 1145 } else { 1132 1146 # If the user doesn't have permissions to monkey with NOC-things, pass … … 1203 1217 $page->param(nocling => 1); 1204 1218 $page->param(privdata => $webvar{privdata}); 1205 if ($ binfo->{hasbk}) {1206 $page->param(hasbackup => $binfo->{hasbk});1207 for my $bkfield (qw( brand model type src user vpass epass port)) {1208 $page->param("bk$bkfield" => $ binfo->{"bk$bkfield"});1219 if ($webvar{backupfields} && $webvar{backupfields} eq 'on') { 1220 $page->param(hasbackup => 1); 1221 for my $bkfield (qw(@IPDB::backupfields) { 1222 $page->param("bk$bkfield" => $webvar{"bk$bkfield"}); 1209 1223 } 1210 1224 }
Note:
See TracChangeset
for help on using the changeset viewer.