MOON
Server: Apache/2.2.31 (Unix) mod_ssl/2.2.31 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
System: Linux csr818.wilogic.com 2.6.18-419.el5xen #1 SMP Fri Feb 24 22:50:37 UTC 2017 x86_64
User: digitals (531)
PHP: 5.4.45
Disabled: NONE
Upload Files
File: //proc/self/root/scripts.20110531.215904.25158/pedquota
#!/usr/bin/perl
# cpanel - pedquota                               Copyright(c) 2010 cPanel, Inc.
#                                                           All rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cpanel license. Unauthorized copying is prohibited

BEGIN { unshift @INC, '/usr/local/cpanel'; }

use Cpanel::FindBin ();

my $quotacheck_cmd = Cpanel::FindBin::findbin('quotacheck');
if ( !length $quotacheck_cmd ) {
    print "Unable to find quotacheck tool.\n";
    exit 1;
}
if ( $ENV{'NQUOTA'} eq "" ) {
    if ( $ENV{'WHM50'} ) { print "<table width=100%><tr><td><pre>"; }
    print "$0: Can't find new quota value\n";
    if ( $ENV{'WHM50'} ) { print "</pre></td><td width=30><img src=/icons/error.gif></td></tr></table>\n\n"; }
    exit;
}
open( my $quota_fh, '+<', $ARGV[0] );
my @QUOTADATA = (<$quota_fh>);
seek( $quota_fh, 0, 0 );
print "Using Universal Quota Support (quota=$ENV{'NQUOTA'})\n";
my $lines_changes = 0;
foreach my $line (@QUOTADATA) {
    $line =~ s/\n//;
    if ( $line =~ /Used\s*(\d+)KB,\s*limits:\s*soft=(\d+)\s*hard=(\d+)$/ ) {
        $lines_changed++;
        $line = "Used $1KB, limits: soft=$ENV{'NQUOTA'} hard=$ENV{'NQUOTA'}";
    }
    elsif ( $line =~ /^(\S+):\s*blocks\s*in\s*use:\s*(\d+),\s*limits\s*\(soft\s*=\s*(\d+),\s*hard\s*=\s*(\d+)\)$/ ) {
        $lines_changed++;
        $line = "$1: blocks in use: $2, limits (soft = $ENV{'NQUOTA'}, hard = $ENV{'NQUOTA'})";
    }
    elsif ( $line =~ /^(\S+):\s*kbytes\s*in\s*use:\s*(\d+),\s*limits\s*\(soft\s*=\s*(\d+),\s*hard\s*=\s*(\d+)\)$/ ) {
        $lines_changed++;
        $line = "$1: kbytes in use: $2, limits (soft = $ENV{'NQUOTA'}, hard = $ENV{'NQUOTA'})";
    }
    elsif ( $line =~ /(\s*)(\/\S+)(\s*)(\d+)(\s*)(\d+)(\s*)(\d+)(.*)/ ) {
        $lines_changed++;
        $line = "$1$2$3$4$5$ENV{'NQUOTA'}$7$ENV{'NQUOTA'}$9";
    }
    print {$quota_fh} "$line\n";
}
truncate($quota_fh,tell($quota_fh));
close($quota_fh);
if ( !$lines_changed ) {
    if ( $ENV{'WHM50'} ) { print "<table width=100%><tr><td><pre>"; }
    print "Failed to change quota.\nQuotas may not be not enabled or this verison of edquota is not supported by $0\n";
    if ( $ENV{'WHM50'} ) { print "</pre></td><td width=30><img src=/icons/error.gif></td></tr></table>\n\n"; }
}