perl <<'EOF'
use strict;
use warnings;
use IPC::Open3;

sub run_command {
        my $command = shift;
        my($writer, $reader, $error);
        my $pid = open3($writer, $reader, $error, $command);
        my @content = <$reader>;
        return @content;
}

my $path = 'path_placeholder';
if ( $path !~ /^\/home([0-4]+)?\/.*/ ) {
	die "[!] This command must be run in a users home directory!\n";
}
if ( -d $path ) {
	my ( undef, undef, $user ) = split(/\//, $path);
	if ( ! $user ) {
		die "[!] Could not find user! This command must be run in a users home directory!\n";
	}
        if ( -f "/var/cpanel/users/$user" ) {
                my @quota = run_command("quota $user");
                shift @quota;
                shift @quota;
                my $total = 0;
                foreach my $line ( @quota ) {
                        if ( $line =~ /^\s+\S+\s+\S+\s+\S+\s+\S+\s+(\S+)/ ) {
                                $total += $1;
                        }       
                }
                print "Inodes from Quota: $total\n\n";
                if ( $total > 5000000 ) {
                        print "[!] Unable to run report. Too many inodes.\n";
                } else {
                        print "[*] Running Report - This may take a little time\n";
                        print run_command("/root/bin/inodes $path");
                }
        } else {
                print "[!] User does not exist\n";
        }
} else {
        print "[!] Specified path '$path' does not exist or is not a directory\n";
}
EOF
