tbrehm
2010-10-27 9eb7b343b2db5bb757e07c84322b2fe30bea9229
Fixed: FS#1365 - hard disk quota in the frontend wrong
3 files modified
70 ■■■■ changed files
interface/web/sites/templates/user_quota_stats_list.htm 12 ●●●● patch | view | raw | blame | history
interface/web/sites/user_quota_stats.php 26 ●●●●● patch | view | raw | blame | history
server/mods-available/monitor_core_module.inc.php 32 ●●●● patch | view | raw | blame | history
interface/web/sites/templates/user_quota_stats_list.htm
@@ -9,9 +9,9 @@
          <tr>
            <th class="tbl_col_domain" scope="col"><tmpl_var name="domain_txt"></th>
            <th class="tbl_col_system_user" scope="col"><tmpl_var name="system_user_txt"></th>
            <th class="tbl_col_system_user" scope="col"><tmpl_var name="used_txt"></th>
            <th class="tbl_col_system_user" scope="col"><tmpl_var name="soft_txt"></th>
            <th class="tbl_col_system_user" scope="col"><tmpl_var name="hard_txt"></th>
            <th class="tbl_col_system_user" scope="col" style="text-align:right;"><tmpl_var name="used_txt"></th>
            <th class="tbl_col_system_user" scope="col" style="text-align:right;"><tmpl_var name="soft_txt"></th>
            <th class="tbl_col_system_user" scope="col" style="text-align:right;"><tmpl_var name="hard_txt"></th>
            <th class="tbl_col_buttons" scope="col">&nbsp;</th>
          </tr>
          <tr>
@@ -28,9 +28,9 @@
          <tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
            <td class="tbl_col_domain"><a href="#" onClick="loadContent('sites/web_domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="domain"}</a></td>
            <td class="tbl_col_system_user"><a href="#" onClick="loadContent('sites/web_domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="system_user"}</a></td>
            <td class="tbl_col_used"><a href="#" onClick="loadContent('sites/web_domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="used"}</a></td>
            <td class="tbl_col_soft"><a href="#" onClick="loadContent('sites/web_domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="soft"}</a></td>
            <td class="tbl_col_hard"><a href="#" onClick="loadContent('sites/web_domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="hard"}</a></td>
            <td class="tbl_col_used" style="text-align:right;"><a href="#" onClick="loadContent('sites/web_domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="used"}</a></td>
            <td class="tbl_col_soft" style="text-align:right;"><a href="#" onClick="loadContent('sites/web_domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="soft"}</a></td>
            <td class="tbl_col_hard" style="text-align:right;"><a href="#" onClick="loadContent('sites/web_domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="hard"}</a></td>
            <td class="tbl_col_buttons">
              <div class="buttons icons16">    
                &nbsp;
interface/web/sites/user_quota_stats.php
@@ -45,12 +45,34 @@
        $rec['soft'] = $monitor_data['user'][$username]['soft'];
        $rec['hard'] = $monitor_data['user'][$username]['hard'];
        
        if($rec['used'] > 1024) {
            $rec['used'] = round($rec['used'] / 1024,2).' MB';
        } else {
            $rec['used'] .= ' KB';
        }
        if($rec['soft'] > 1024) {
            $rec['soft'] = round($rec['soft'] / 1024,2).' MB';
        } else {
            $rec['soft'] .= ' KB';
        }
        if($rec['hard'] > 1024) {
            $rec['hard'] = round($rec['hard'] / 1024,2).' MB';
        } else {
            $rec['hard'] .= ' KB';
        }
        /*
        if(!strstr($rec['used'],'M') && !strstr($rec['used'],'K')) $rec['used'].= ' B';
        if(!strstr($rec['soft'],'M') && !strstr($rec['soft'],'K')) $rec['soft'].= ' B';
        if(!strstr($rec['hard'],'M') && !strstr($rec['hard'],'K')) $rec['hard'].= ' B';
        */
        
        if($rec['soft'] == '0 B' || $rec['soft'] == '0K' || $rec['soft'] == '0') $rec['soft'] = $app->lng('unlimited');
        if($rec['hard'] == '0 B' || $rec['hard'] == '0K' || $rec['hard'] == '0') $rec['hard'] = $app->lng('unlimited');
        if($rec['soft'] == '0 B' || $rec['soft'] == '0 KB' || $rec['soft'] == '0') $rec['soft'] = $app->lng('unlimited');
        if($rec['hard'] == '0 B' || $rec['hard'] == '0 KB' || $rec['hard'] == '0') $rec['hard'] = $app->lng('unlimited');
        
        //* The variable "id" contains always the index variable
        $rec['id'] = $rec[$this->idx_key];
server/mods-available/monitor_core_module.inc.php
@@ -238,7 +238,7 @@
        $state = 'ok';
        
        /** Fetch the data for all users*/
        $dfData = shell_exec('repquota -asu');
        $dfData = shell_exec('repquota -au');
        // split into array
        $df = explode("\n", $dfData);
@@ -253,14 +253,22 @@
                */
                $s = preg_split ('/[\s]+/', $df[$i]);
                $username = $s[0];
                $data['user'][$username]['used'] = $s[2];
                $data['user'][$username]['soft'] = $s[3];
                $data['user'][$username]['hard'] = $s[4];
                if(substr($username,0,3) == 'web') {
                if(isset($data['user'][$username])) {
                    $data['user'][$username]['used'] += $s[2];
                    $data['user'][$username]['soft'] += $s[3];
                    $data['user'][$username]['hard'] += $s[4];
                } else {
                    $data['user'][$username]['used'] = $s[2];
                    $data['user'][$username]['soft'] = $s[3];
                    $data['user'][$username]['hard'] = $s[4];
                }
                }
            }
        }
        
        /** Fetch the data for all users*/
        $dfData = shell_exec('repquota -asg');
        $dfData = shell_exec('repquota -ag');
        // split into array
        $df = explode("\n", $dfData);
@@ -275,9 +283,17 @@
                */
                $s = preg_split ('/[\s]+/', $df[$i]);
                $groupname = $s[0];
                $data['group'][$groupname]['used'] = $s[1];
                $data['group'][$groupname]['soft'] = $s[2];
                $data['group'][$groupname]['hard'] = $s[3];
                if(substr($groupname,0,6) == 'client') {
                if(isset($data['group'][$groupname])) {
                    $data['group'][$groupname]['used'] += $s[1];
                    $data['group'][$groupname]['soft'] += $s[2];
                    $data['group'][$groupname]['hard'] += $s[3];
                } else {
                    $data['group'][$groupname]['used'] = $s[1];
                    $data['group'][$groupname]['soft'] = $s[2];
                    $data['group'][$groupname]['hard'] = $s[3];
                }
                }
            }
        }