The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

chkcpaccts script - Need a little help

Discussion in 'General Discussion' started by eglwolf, Mar 13, 2005.

  1. eglwolf

    eglwolf Well-Known Member

    Joined:
    Jan 1, 2004
    Messages:
    168
    Likes Received:
    0
    Trophy Points:
    16
    I came across this script: chkcpaccts at http://www.cplicensing.net/scripts.php

    And I want to actually see if it might be able to be used to check all reseller accounts. Without me having to modify the script for each and every reseller account. I am not a perl coder, so I wonder if someone might be able to help with this, the code is below. Any help you can provide me with this is greatly appreicated.


    Code:
    #!/usr/bin/perl
    # cPlicensing.net - scripts			Copyright(c) 2003 cPlicensing.net.
    #						All rights Reserved.
    # support@cPlicensing.net			http://cPlicensing.net
    # Unauthorized copying is prohibited
    #Version: 0.02
    #
    #+CHANGE LOG
    #-v0.2 :: 2004-22-02 :: Now will show a catagory for domains that point to the correct ip as well. 
    
    use Socket;
    
    $|++;
    $ENV{'REMOTE_USER'} = 'root';
    
    $acctsdb = '/var/cpanel/root.accts';
    $chkuser = 'root';
    
    if (!-e "/usr/local/cpanel") {
    	print "CPanel not found, Are you sure this is a CPanel box?\n";
    	exit;
    }
    
    print "Checking /etc/resolv.conf...";
    open(RESOLVCONF,"/etc/resolv.conf") or die("Failed, Where is your resolv.conf?\n");
    while(<RESOLVCONF>) {
            chomp;
            if((/127.0.0.1/) and ($ARGV[0] ne "--allowlocalhost")) {
                    print "Found 127.0.0.1 in the resolv.conf, this is a no no!  Change it to the base ip of the server\n";
                    exit;
            }
    }
    close(RESOLVCONF);
    print "Check Complete\n";
    
    print "Rebuilding $acctsdb...";
    system("/usr/local/cpanel/whostmgr/bin/whostmgr fetchcsv > /dev/null");
    if (!-e "$acctsdb") {
    	print "$acctsdb Not found\n";
    	exit;
    }
    print "Done\n";
    
    print "Opening $acctsdb...";
    open(DATA,"$acctsdb") or die("failed\n");
    print "done\nScanning Domains....";
    while(<DATA>) {
    	print "."; 
    	$totaldom++;
    	($UNDEF,$domain,$ip,$UNDEF,$UNDEF,$UNDEF,$UNDEF,$UNDEF,$UNDEF,$UNDEF,$UNDEF,$UNDEF,$owner) = split(/,/, $_, 28);
    	chomp($domain,$ip,$owner);
    	$ip=~ s/:443//;
    	if ($owner ne $chkuser) { next; }
    	$iaddr = gethostbyname($domain);
    	if (!$iaddr){ push @failedresolve, "$domain"; next; }
    	$domainip = inet_ntoa($iaddr);
    	if ($domainip ne $ip) {
    		push @wrongip, "$domain($ip) ---Resolves-to--> $domainip";
    	} else {
    		push @rightip, "$domain($ip) ---Resolves-to--> $domainip";
    	}
    }
    close(DATA);
    print "done\n\n";
    
    print "\n\n";
    print "-------------------------------------\n";
    print "- LIST OF DOMAINS THAT POINT RIGHT  -\n";
    print "=====================================\n";
    foreach (@rightip) {
            print "-->$_\n";
    }
    print "-------------------------------------\n";
    print "- LIST OF DOMAINS THAT DONT RESOLVE -\n";
    print "=====================================\n";
    foreach (@failedresolve) {
    	print "-->$_\n";
    }
    print "\n\n";
    print "-------------------------------------\n";
    print "- LIST OF DOMAINS THAT POINT WRONG  -\n";
    print "=====================================\n";
    foreach (@wrongip) {
    	print "-->$_\n";
    }
    print "\n\n";
    print "-------------------------------------\n";
    print "-               SUMMERY             -\n";
    print "=====================================\n";
    print "-->TOTAL DOMAINS IN THE DB FILE...................$totaldom\n";
    print "-->TOTAL DOMAINS THAT RESOLVE TO THE CORRECT IP...".@rightip."\n";
    print "-->TOTAL DOMAINS THAT DONT RESOLVE................".@failedresolve."\n";
    print "-->TOTAL DOMAINS THAT POINT ELSE WHERE............".@wrongip."\n";
    print "\n\n";
    
    
     
  2. dgbaker

    dgbaker Well-Known Member
    PartnerNOC

    Joined:
    Sep 20, 2002
    Messages:
    2,578
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    Toronto, Ontario Canada
    cPanel Access Level:
    DataCenter Provider
    I'll refer you to these lines in the code.

    Copyright(c) 2003 cPlicensing.net.
    #All rights Reserved.
    # support@cPlicensing.net http://cPlicensing.net
    # Unauthorized copying is prohibited
    #Version: 0.02

    I suggest you contact them for help.
     
  3. eglwolf

    eglwolf Well-Known Member

    Joined:
    Jan 1, 2004
    Messages:
    168
    Likes Received:
    0
    Trophy Points:
    16
    opps, sorry I will contact them.
     
Loading...

Share This Page