function show_vpop_quota ($imp) { $quota_html = ''; $imapuser = $imp['user']; // $percent = trim(`sudo /var/vpopmail/bin/vuserinfo -Q $imapuser`); $percent = quota_calc($imapuser); if (strcmp ($percent, "NOQUOTA")) { $class = 'control'; $quota_html = '
' . '
' . sprintf("Quota: %s used", $percent) . '
'; } return $quota_html; } function quota_calc ($imapuser) { $userquota = trim(`sudo /var/vpopmail/bin/vuserinfo -q $imapuser`); if ($userquota == 'NOQUOTA') { return ('NOQUOTA'); } $userdir = trim(`sudo /var/vpopmail/bin/vuserinfo -d $imapuser`); $userdisk = trim(`sudo /usr/bin/du -sb $userdir`); if (preg_match('|(\d+)([kKmMgG])|', $userquota, $matches)) { $pf = strtolower($matches[2]); if ($pf == 'k') { $userquota = $matches[1] * 1024; } elseif ($pf == 'm') { $userquota = $matches[1] * 1048576; } else { $userquota = $matches[1] * 1073741824; } } return (sprintf('%.1f%%', (($userdisk * 100.0) / $userquota))); }