Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r61 r62 243 243 my $domid = shift; 244 244 245 return "FAIL", "whee!";246 245 # Allow transactions, and raise an exception on errors so we can catch it later. 247 246 # Use local to make sure these get "reset" properly on exiting this block … … 684 683 my $id = shift; 685 684 686 my $sql = "select record_id,host,type,val,distance,weight,port,ttl from ". 687 (($def eq 'def' or $def eq 'y') ? 'default_' : ''). 688 "records where record_id=$id"; 689 print "MDEBUG: $sql<br>\n"; 685 my $sql = "SELECT record_id,host,type,val,distance,weight,port,ttl". 686 (($def eq 'def' or $def eq 'y') ? ',group_id FROM default_' : ',domain_id FROM '). 687 "records WHERE record_id=?"; 690 688 my $sth = $dbh->prepare($sql); 691 $sth->execute ;692 693 my ($recid,$host,$rtype,$val,$distance,$weight,$port,$ttl ) = $sth->fetchrow_array();689 $sth->execute($id); 690 691 my ($recid,$host,$rtype,$val,$distance,$weight,$port,$ttl,$parid) = $sth->fetchrow_array(); 694 692 695 693 if ($sth->err) { … … 706 704 $ret{port} = $port; 707 705 $ret{ttl} = $ttl; 706 $ret{parid} = $parid; 708 707 709 708 return %ret; … … 728 727 my $order = shift || 'host'; 729 728 730 my $sql = " select record_id,host,type,val,distance,weight,port,ttl from";729 my $sql = "SELECT record_id,host,type,val,distance,weight,port,ttl FROM "; 731 730 if ($type eq 'def' or $type eq 'y') { 732 731 $sql .= " default_records where group_id=$id"; … … 861 860 my $id = shift; 862 861 863 my $sth = $dbh->prepare("delete from ".($defrec eq 'y' ? 'default_' : '')."records where record_id=?"); 862 return "FAIL", "wakka wakka"; 863 my $sth = $dbh->prepare("DELETE FROM ".($defrec eq 'y' ? 'default_' : '')."records WHERE record_id=?"); 864 864 $sth->execute($id); 865 865 -
trunk/dns.cgi
r61 r62 69 69 # per-page startwith, filter, searchsubs 70 70 $session->param($webvar{page}.'startwith', $webvar{startwith}) if $webvar{startwith}; 71 $session->param($webvar{page}.'filter', $webvar{filter}) if $webvar{filter};71 $session->param($webvar{page}.'filter', $webvar{filter}) if defined($webvar{filter}); 72 72 $webvar{searchsubs} =~ s/^n ?// if $webvar{searchsubs}; 73 73 $session->param($webvar{page}.'searchsubs', $webvar{searchsubs}) if defined($webvar{searchsubs}); … … 166 166 # this currently only handles "domain on", "domain off" 167 167 if (defined($webvar{action})) { 168 domStatus($dbh,$webvar{id},$webvar{action}); 168 my $stat = domStatus($dbh,$webvar{id},$webvar{action}); 169 logaction($webvar{id}, $session->param("username"), parentID($webvar{id}, 'dom', 'group'), 170 "Changed ".domainName($dbh, $webvar{id})." state to ".($stat ? 'active' : 'inactive')); 169 171 } 170 172 171 173 $page->param(curpage => $webvar{page}); 174 if ($webvar{del_failed}) { 175 $page->param(del_failed => 1); 176 $page->param(errmsg => $webvar{errmsg}); 177 } 172 178 173 179 listdomains(); … … 177 183 # hmm. nothing to do here? 178 184 # - group list is filled by the same bit that fills the group list in the menu 185 if ($webvar{add_failed}) { 186 $page->param(add_failed => 1); 187 $page->param(errmsg => $webvar{errmsg}); 188 $page->param(domain => $webvar{domain}); 189 } 179 190 180 191 } elsif ($webvar{page} eq 'adddomain') { … … 186 197 changepage(page => "reclist", id => $msg); 187 198 } else { 199 logaction(0, $session->param("username"), $webvar{group}, "Failed adding domain $webvar{domain} ($msg)"); 188 200 changepage(page => "newdomain", add_failed => 1, domain => $webvar{domain}, errmsg => $msg); 189 201 } … … 207 219 if ($code ne 'OK') { 208 220 # need to find failure mode 209 $page->param(del_failed => 1); 210 $page->param(errmsg => $msg); 211 logaction($webvar{id}, $session->param("username"), $pargroup, "Failed to delete domain $dom"); 212 listdomains($curgroup); 213 ##work 221 logaction($webvar{id}, $session->param("username"), $pargroup, "Failed to delete domain $dom ($msg)"); 222 changepage(page => "domlist", del_failed => 1, errmsg => $msg); 214 223 } else { 215 224 logaction($webvar{id}, $session->param("username"), $pargroup, "Deleted domain $dom"); … … 295 304 if ($webvar{defrec} eq 'y') { 296 305 logaction(0, $session->param("username"), $webvar{parentid}, 297 "Failed adding default record '$ typemap{$webvar{type}} $webvar{name} $webvar{address}', TTL $webvar{ttl}");306 "Failed adding default record '$webvar{name} $typemap{$webvar{type}} $webvar{address}', TTL $webvar{ttl}"); 298 307 } else { 299 308 logaction($webvar{parentid}, $session->param("username"), parentID($webvar{parentid}, 'dom', 'group'), 300 "Failed adding record '$ typemap{$webvar{type}} $webvar{name} $webvar{address}', TTL $webvar{ttl}");309 "Failed adding record '$webvar{name} $typemap{$webvar{type}} $webvar{address}', TTL $webvar{ttl}"); 301 310 } 302 311 } … … 384 393 $page->param(recval => $rec{val}); 385 394 } elsif ($webvar{del} eq 'ok') { 386 # get groupid of deleted recordbefore we try to delete it387 my $pargrp = parentID($webvar{id}, 'rec', 'group', $webvar{defrec});395 # get rec data before we try to delete it 396 my %rec = getRecLine($dbh,$webvar{defrec},$webvar{id}); 388 397 my ($code,$msg) = delRec($dbh,$webvar{defrec},$webvar{id}); 389 398 if ($code ne 'OK') { 390 399 ## need to find failure mode 391 #logaction( 400 if ($webvar{defrec} eq 'y') { 401 logaction(0, $session->param("username"), $rec{parid}, 402 "Failed deleting default record '$rec{host} $typemap{$rec{type}} $rec{val}', TTL $rec{ttl}"); 403 } else { 404 logaction($rec{parid}, $session->param("username"), parentID($rec{parid}, 'dom', 'group'), 405 "Failed deleting record '$rec{host} $typemap{$rec{type}} $rec{val}', TTL $rec{ttl}"); 406 } 392 407 $page->param(del_failed => 1); 393 408 $page->param(errmsg => $msg); 394 409 showdomain($webvar{defrec}, $webvar{parentid}); 395 410 } else { 396 ##log 411 if ($webvar{defrec} eq 'y') { 412 logaction(0, $session->param("username"), $rec{parid}, 413 "Deleted default record '$rec{host} $typemap{$rec{type}} $rec{val}', TTL $rec{ttl}"); 414 } else { 415 logaction($rec{parid}, $session->param("username"), parentID($rec{parid}, 'dom', 'group'), 416 "Deleted record '$rec{host} $typemap{$rec{type}} $rec{val}', TTL $rec{ttl}"); 417 } 397 418 changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec}); 398 419 } … … 907 928 $rec->{type} = $typemap{$rec->{type}}; 908 929 $rec->{row} = $row % 2; 909 $rec->{defrec} = $ webvar{defrec};930 $rec->{defrec} = $def; 910 931 $rec->{sid} = $webvar{sid}; 911 932 $rec->{id} = $id; … … 1008 1029 1009 1030 sub listdomains { 1031 1032 $startwith = $session->param($webvar{page}.'startwith'); 1033 $filter = $session->param($webvar{page}.'filter'); 1034 $searchsubs = $session->param($webvar{page}.'searchsubs'); 1010 1035 1011 1036 ##fixme: $logingroup or $curgroup?
Note:
See TracChangeset
for help on using the changeset viewer.