Changeset 16 for trunk/dns.cgi
- Timestamp:
- 09/15/09 17:52:13 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dns.cgi
r15 r16 177 177 178 178 } elsif ($webvar{page} eq 'record') { 179 179 180 if ($webvar{recact} eq 'new') { 181 180 182 $page->param(todo => "Add record to"); 181 183 $page->param(recact => "add"); 182 stdrecs(); 184 fill_rectypes(); 185 183 186 } elsif ($webvar{recact} eq 'add') { 184 187 … … 191 194 } 192 195 } 193 # wtf?194 # push @recargs,195 196 my ($code,$msg) = addRec(@recargs); 196 197 197 198 if ($code eq 'OK') { 198 199 changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec}); 199 # showdomain($webvar{defrec},$webvar{parentid});200 # NB: should **really** redirect here, in case of reload. >_< eyowch.201 200 } else { 202 $page->param( add_failed => 1);201 $page->param(failed => 1); 203 202 $page->param(errmsg => $msg); 204 stdrecs($webvar{type}); # populate the form... er, mostly. 205 $page->param(name => $webvar{name}); 206 $page->param(address => $webvar{address}); 207 $page->param(distance => $webvar{distance}) 208 if ($webvar{type} == $reverse_typemap{MX} or $webvar{type} == $reverse_typemap{SRV}); 209 $page->param(weight => $webvar{weight}) if $webvar{type} == $reverse_typemap{SRV}; 210 $page->param(port => $webvar{port}) if $webvar{type} == $reverse_typemap{SRV}; 211 } 212 213 $page->param(defrec => $webvar{defrec}); 203 fill_recdata(); # populate the form... er, mostly. 204 } 214 205 215 206 } elsif ($webvar{recact} eq 'edit') { 216 207 217 $page->param(todo => "Edit record in"); 208 $page->param(todo => "Update record"); 209 $page->param(recact => "update"); 210 $page->param(parentid => $webvar{parentid}); 211 $page->param(defrec => $webvar{defrec}); 218 212 my $sth = $dbh->prepare("SELECT host,type,val,distance,weight,port,ttl FROM ". 219 213 ($webvar{defrec} eq 'y' ? 'default_' : '')."records WHERE record_id=?"); … … 226 220 $page->param(port => $port); 227 221 $page->param(ttl => $ttl); 228 stdrecs($type); 229 } 222 fill_rectypes($type); 223 224 } elsif ($webvar{recact} eq 'update') { 225 226 my ($code,$msg) = updateRec($dbh,$webvar{defrec},$webvar{id}, 227 $webvar{name},$webvar{type},$webvar{address},$webvar{ttl}, 228 $webvar{distance},$webvar{weight},$webvar{port}); 229 230 if ($code eq 'OK') { 231 $page->param(failed => 1); 232 $page->param(errmsg => "testing"); 233 $page->param(wastrying => "updating"); 234 $page->param(todo => "Update record"); 235 $page->param(recact => "update"); 236 $page->param(parentid => $webvar{parentid}); 237 $page->param(defrec => $webvar{defrec}); 238 fill_recdata(); 239 # changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec}); 240 } else { 241 $page->param(failed => 1); 242 $page->param(errmsg => $msg); 243 $page->param(wastrying => "updating"); 244 $page->param(todo => "Update record"); 245 $page->param(recact => "update"); 246 $page->param(parentid => $webvar{parentid}); 247 $page->param(defrec => $webvar{defrec}); 248 fill_recdata(); 249 } 250 } 251 230 252 if ($webvar{defrec} eq 'y') { 231 $page->param(do main=> "group ".grpName($dbh,$webvar{parentid}));232 } else { 233 $page->param(do main=> domainName($dbh,$webvar{parentid}));253 $page->param(dohere => "group ".grpName($dbh,$webvar{parentid})); 254 } else { 255 $page->param(dohere => domainName($dbh,$webvar{parentid})); 234 256 } 235 257 … … 464 486 } 465 487 466 sub stdrecs { 488 # fill in record type list on add/update/edit record template 489 sub fill_rectypes { 467 490 my $type = shift || $reverse_typemap{A}; 468 491 469 492 my $sth = $dbh->prepare("select val,name from rectypes where stdflag=1 order by listorder"); 470 493 $sth->execute; 471 472 push @debugbits, "DEBUG: type $type\n"; 494 push @debugbits, "type $type"; 473 495 my @typelist; 474 496 while (my ($rval,$rname) = $sth->fetchrow_array()) { … … 478 500 } 479 501 $page->param(typelist => \@typelist); 480 $page->param(domain => domainName($dbh,$webvar{domainid})); 481 $page->param(defrec => $webvar{defrec}); 502 } 503 504 sub fill_recdata { 505 fill_rectypes($webvar{type}); 506 507 $page->param(name => $webvar{name}); 508 $page->param(address => $webvar{address}); 509 $page->param(distance => $webvar{distance}) 510 if ($webvar{type} == $reverse_typemap{MX} or $webvar{type} == $reverse_typemap{SRV}); 511 $page->param(weight => $webvar{weight}) if $webvar{type} == $reverse_typemap{SRV}; 512 $page->param(port => $webvar{port}) if $webvar{type} == $reverse_typemap{SRV}; 482 513 $page->param(ttl => ($webvar{ttl} ? $webvar{ttl} : $DNSDB::def{minttl})); 483 if ($webvar{defrec} eq 'y') {484 ##fixme - should be groupid485 $page->param(parentid => 1);486 } else {487 print "DEBUG: foobar: parentid $webvar{parentid}<br>\n";488 $page->param(parentid => $webvar{parentid});489 }490 514 } 491 515
Note:
See TracChangeset
for help on using the changeset viewer.