Control Web Panel

Developers => New Modules => Topic started by: become on August 23, 2017, 03:43:15 PM

Title: Real User Used Quota
Post by: become 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
Title: Re: Real User Used Quota
Post by: darkness 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:
(http://i.imgur.com/map932S.png)
Hope you like it.
Title: Re: Real User Used Quota
Post by: johnny09 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
Title: Re: Real User Used Quota
Post by: darkness 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.
Title: Re: Real User Used Quota
Post by: become on November 04, 2017, 08:36:25 PM
I updated module today.
Title: Re: Real User Used Quota
Post by: become on December 05, 2017, 07:24:15 PM
Updated today:
* add sum for all accounts

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