@@ -59,6 +59,7 @@ public function onRunJob() {
5959
6060 //* Initialize data array
6161 $ data = array ();
62+ $ df = array ();
6263
6364 //* the id of the server as int
6465 $ server_id = intval ($ conf ['server_id ' ]);
@@ -72,20 +73,22 @@ public function onRunJob() {
7273 if (!$ app ->system ->is_installed ('setquota ' )) {
7374 //* No Quota on this System ...
7475
75- //** Fetch the data for all users
76- $ dfData = shell_exec ('du -s /var/www/clients/client*/web[0-9]* ' );
77-
78- //* split into array
79- $ df = explode ("\n" , $ dfData );
80-
8176 //* Get Limits for Calculation
8277 $ records = $ app ->db ->queryAllRecords ('SELECT hd_quota, system_user, system_group FROM `web_domain` WHERE `server_id` = ? ' , $ conf ['server_id ' ]);
8378 foreach ($ records as $ record ) {
8479 $ options ['group ' ][$ record ['system_group ' ]] = $ record ['hd_quota ' ]*1024 ;
8580 $ options ['user ' ][$ record ['system_user ' ]] = $ record ['hd_quota ' ]*1024 ;
8681 }
8782
88- //* ignore the first 5 lines, process the rest
83+ if (!empty ($ records )) {
84+ //** Fetch the data for all users
85+ $ dfData = shell_exec ('du -s /var/www/clients/client*/web[0-9]* ' );
86+
87+ //* split into array
88+ $ df = explode ("\n" , $ dfData );
89+ }
90+
91+ //* Loop over all the output lines, for groups.
8992 for ($ i = 0 ; $ i <= sizeof ($ df ); $ i ++) {
9093 if (isset ($ df [$ i ]) && $ df [$ i ] != '' ) {
9194 //* Make a array of the data
@@ -106,14 +109,14 @@ public function onRunJob() {
106109 }
107110 }
108111
109- //* ignore the first 5 lines, process the rest
112+ //* Loop over all the output lines, for users.
110113 for ($ i = 0 ; $ i <= sizeof ($ df ); $ i ++) {
111114 if (isset ($ df [$ i ]) && $ df [$ i ] != '' ) {
112115 //* Make a array of the data
113116 $ s1 = preg_split ('/[\s]+/ ' , $ df [$ i ]);
114117 $ s2 = preg_split ('/\// ' , $ s1 [1 ]);
115118 $ username = $ s2 [5 ];
116- if (substr ( $ username , 0 , 3 ) == ' web ' ) {
119+ if (preg_match ( ' /^web\d+$/ ' , $ username ) ) {
117120 if (isset ($ data ['user ' ][$ username ])) {
118121 $ data ['user ' ][$ username ]['used ' ] += $ s1 [0 ];
119122 $ data ['user ' ][$ username ]['soft ' ] = $ options ['user ' ][$ username ];
0 commit comments