Author Topic: Real User Used Quota  (Read 610 times)

0 Members and 1 Guest are viewing this topic.

Offline
**
Real User Used Quota
« on: August 23, 2017, 03:43:15 PM »
I creted admin module to show real used quota for all users

https://github.com/betterapp/cwp-users-quota

Offline
***
Re: Real User Used Quota
« Reply #1 on: August 26, 2017, 04:30:01 AM »
Hello,
First of all - Great job.
Sorry but I never used github for something different than "git clone ..." and I have no idea how to make a "Pull request" so I will put it here. As I have my own users on the shell and for them I have created an Unlimited (Quota) package I noticed a small error. If the package is Unlimited the quota is 0 (zero) and I saw "Division by zero ... bla bla bla". I made a small fix which you might like:
Code: [Select]
<?php
                    $usedQuotaPercent 
null; <- Added for no warnings
                    $usedQuotaProgress 
null; <- Added for no warnings
                    $packageMaxQuotaBytes 
$result[$i]['disk_quota'] * 1024 1024;
                    if (
$packageMaxQuotaBytes == "0") { <- Added for "Division by zero" error
                        
echo "Unlimited";
                    } else {
                    
$usedQuotaPercent round($allQuota 100 $packageMaxQuotaBytes2);
                    
$usedQuotaProgress round($allQuota 100 $packageMaxQuotaBytes0);
                    }
                    echo 
"[$usedQuotaPercent %]";
                    
$progressBarClass 'progressBarGreen';
                    if (
$usedQuotaProgress 50) {
                        
$progressBarClass 'progressBarOrange';
                    }
                    if (
$usedQuotaProgress 90) {
                        
$progressBarClass 'progressBarRed';
                    }
                    
?>

Like this for users with package "Unlimited" you see "Unlimited [%]" and always a full green bar. For the other users with different packages you see "[3.01%]" and green bar (for example). Something like this:

Hope you like it.
Current uptime (FreeBSD 8.1-RELEASE-p17):
UNIX is a very simple OS, but you have to be a GENIUS to understand it ...

Offline
***
Re: Real User Used Quota
« Reply #2 on: September 06, 2017, 01:27:03 PM »
Something is wrong

Parse error: syntax error, unexpected '<' in /usr/local/cwpsrv/htdocs/resources/admin/modules/users_used_quota.php on line 268

Can you please add the full code here?

Thanks

Offline
***
Re: Real User Used Quota
« Reply #3 on: September 29, 2017, 04:57:45 AM »
Just replace:
Code: [Select]
<?php
                    $packageMaxQuotaBytes 
$result[$i]['disk_quota'] * 1024 1024;
                    
$usedQuotaPercent round($allQuota 100 $packageMaxQuotaBytes2);
                    
$usedQuotaProgress round($allQuota 100 $packageMaxQuotaBytes0);
                    echo 
"[$usedQuotaPercent %]";
                    
$progressBarClass 'progressBarGreen';
                    if (
$usedQuotaProgress 50) {
                        
$progressBarClass 'progressBarOrange';
                    }
                    if (
$usedQuotaProgress 90) {
                        
$progressBarClass 'progressBarRed';
                    }
                    
?>

With:
Code: [Select]
                <?php
                    $usedQuotaPercent 
null
                    
$usedQuotaProgress null
                    
$packageMaxQuotaBytes $result[$i]['disk_quota'] * 1024 1024;
                    if (
$packageMaxQuotaBytes == "0") {
                        echo 
"Unlimited";
                    } else {
                    
$usedQuotaPercent round($allQuota 100 $packageMaxQuotaBytes2);
                    
$usedQuotaProgress round($allQuota 100 $packageMaxQuotaBytes0);
                    }
                    echo 
"[$usedQuotaPercent %]";
                    
$progressBarClass 'progressBarGreen';
                    if (
$usedQuotaProgress 50) {
                        
$progressBarClass 'progressBarOrange';
                    }
                    if (
$usedQuotaProgress 90) {
                        
$progressBarClass 'progressBarRed';
                    }
                    
?>


Your error was coming from the comments I put here:
<- Added for no warnings
<- Added for no warnings
<- Added for "Division by zero" error
It was my bad assuming that people know that they need to remove that comments. Anyway, replace the code like I put it now and it will be ok.
Current uptime (FreeBSD 8.1-RELEASE-p17):
UNIX is a very simple OS, but you have to be a GENIUS to understand it ...

Offline
**
Re: Real User Used Quota
« Reply #4 on: November 04, 2017, 08:36:25 PM »
I updated module today.