| Current File : //usr/local/scripts/doms.pl |
#!/usr/local/cpanel/3rdparty/bin/perl
use DBI;
$immed = shift;
sleep(rand(200)) if ($immed eq "");
$host = `hostname`;
chomp($host);
print "$host\n";
@lista = `cat /etc/userdatadomains| grep -v \"=sub=\" | grep -v \"=addon\" | grep -v \"=park\" | awk {'print \$1'}`;
my $db = 'domains';
my $sqlserver = '94.46.20.116';
my $user = 'remote';
my $pass = 'aiqu5Iah5EiD4deG1eenih';
my $dbh = DBI->connect("DBI:mysql:$db;host=$sqlserver",
$user, $pass, { RaiseError => 1 } ) or
die ( "Couldn't connect to database: " . DBI->errstr );
my $sql = "DELETE FROM dom WHERE host=?";
my $sth = $dbh->prepare($sql);
$sth->execute($host);
foreach $domain ( @lista ) {
chomp($domain);
$domain =~ s/://g;
$owner = `/scripts/whoowns $domain`;
chomp($owner);
@api = `/usr/local/cpanel/bin/whmapi1 listaccts search=$owner searchmethod=exact searchtype=user |grep -v outgoing_mail| egrep "suspended:|owner:|suspendreason:|suspendtime:"`;
$suspended = "Active";
$sreason ="";
$stime ="";
foreach $linha (@api) {
chomp($linha);
($var,$result) = split (/:/,$linha);
$var =~ tr/ //ds;
$result =~ tr/ //ds;
if ($var eq "owner"){
if (($result ne "ptispapi") and ($result ne "root")) {
$reseller = "Revenda ( $result )";
} else {
$reseller = "Own";
}
}
if ($var eq "suspended"){
$suspended = "SUSPENDED" if ($result eq "1");
}
if ($var eq "suspendreason"){
$sreason = $result;
}
if ($var eq "suspendtime"){
$stime = $result;
$stime =~ s/\'//g;
}
}
#print "$domain - $owner - $reseller - $suspended - $sreason - $stime \n";
$sql = "INSERT INTO dom(host,dominio,owner,reseller,status,sreason,stime) VALUES(?,?,?,?,?,?,?)";
$sth = $dbh->prepare($sql);
$sth->execute($host,$domain,$owner,$reseller,$suspended,$sreason,$stime);
}