On Sun, 5 May 2002, Jonathan wrote: > If you really want a change-all nameservers feature, > that can be done readily by modifying > the manage.cgi code from your end.
I've written a bit of code specifically to fix nameservers. It doesn't handle locking yet, but since that's apparently broken at the moment, hopefully all of your domains are unlocked. sub fixns { my(%givendoms,$givendoms); if (scalar @_) { $givendoms = 1; %givendoms = map {($_,1)} @_; } my $sql = "select * from domain where opensrs=1 and dead=0"; my $sth = $dbh->prepare($sql) or die "bad << $sql >>"; $sth->execute or die; my %attr = %defattr; $attr{type} = 'nameservers'; my $row; while ($row = $sth->fetchrow_hashref) { my $domain = $row->{name}; my $nssetid = $row->{nssetid}; if ($givendoms) { next unless $givendoms{$domain}; } print "processing $domain: "; my @ns_shouldbe; $sql = "select * from nameserversetitem where nssetid=$nssetid order by lookorder "; my $sth2 = $dbh->prepare($sql) or die "bad << $sql >>"; $sth2->execute or die; if ($sth2->rows == 0) { print "no nssetitems\n"; next; } while (my $nsrow = $sth2->fetchrow_hashref) { push(@ns_shouldbe,$nsrow->{name}); } my $rv = $XCP->send({ action => 'set', object => 'cookie', attributes => { domain => $domain, reg_username => $defattr{reg_username}, reg_password => $defattr{reg_password} }, }); if ($rv->{is_success}) { print "login,"; } else { warn $rv->{response_text}; next; } $cookie = $rv->{attributes}{cookie}; %attr = %defattr; $attr{type} = 'nameservers'; $rv = $XCP->send({ action => 'get', object => 'domain', cookie => $cookie, attributes => \%attr, }); if ($rv->{is_success}) { print "got curr,"; } else { die $rv->{response_text}; } my @ns_is; foreach my $listent (@{$rv->{attributes}->{nameserver_list}}) { push(@ns_is,$listent->{name}); } #print Dumper(\@ns_is,\@ns_shouldbe),"\n";die; my $x = 0; foreach my $is (@ns_is) { my $sb = $ns_shouldbe[$x]; if ($is eq $sb) { $x++; next; } else { print "ns[$x] mismatch,"; #print "\n\t($is<>$sb),"; last; } } if ($x == scalar(@ns_shouldbe)) { print " good. :-)\n"; next; } print "fixing..."; my $nsremovelist; my $y=1; foreach my $is (@ns_is) { my $racedom = $UTIL->do_race($is); push(@$nsremovelist, { name => $racedom->{ConvertedDomain}, sortorder => $y, action => 'remove', }); $y++; } #print Dumper($nslist),"\n";die; %attr = (); $attr{data} = 'nameserver_list'; $attr{nameserver_list} = $nsremovelist; $rv = $XCP->send({ action => 'modify', object => 'domain', cookie => $cookie, attributes => \%attr, }); if ($rv->{is_success}) { print "removed," } else { die "\nOpenSRS: $rv->{response_text}\n" . Dumper($rv) . Dumper(\%attr) . ' '; } $y = 1; foreach my $sb (@ns_shouldbe) { my $racedom = $UTIL->do_race($sb); %attr = (); $attr{data} = 'nameserver_list'; $attr{nameserver_list} = [ { name => $racedom->{ConvertedDomain}, action => 'add', } ]; $rv = $XCP->send({ action => 'modify', object => 'domain', cookie => $cookie, attributes => \%attr, }); if ($rv->{is_success}) { print "$y," } else { die "\nOpenSRS: $rv->{response_text}\n" . Dumper($rv) . Dumper(\%attr) . ' '; } $y++; } print "done.\n"; } $sth->finish if defined($sth); } -- </chris> "The first rule of Perl club is you do not talk about Perl club." -- Chip Salzenberg