コード例 #1
0
ファイル: index.php プロジェクト: Hydrog3n/QB-dashboard
 } else {
     $cbodyerr .= "error locating start up script .. feel free to open a issue at the quick box repo";
 }
 if (file_exists('/usr/sbin/repquota')) {
     $dftotal = shell_exec("sudo /usr/sbin/repquota /|/bin/grep ^" . $username . "|/usr/bin/awk '{printf \$4/1024/1024}'");
     $dffree = shell_exec("sudo /usr/sbin/repquota /|/bin/grep ^" . $username . "|/usr/bin/awk '{printf (\$4-\$3)/1024/1024}'");
     $dfused = shell_exec("sudo /usr/sbin/repquota /|/bin/grep ^" . $username . "|/usr/bin/awk '{printf \$3/1024/1024}'");
     $perused = sprintf('%1.0f', $dfused / $dftotal * 100);
 } else {
     $bytesfree = disk_free_space('/home' . $username);
     $class = min((int) log($bytesfree, $base), count($si_prefix) - 1);
     $bytestotal = disk_total_space($location);
     $class = min((int) log($bytesfree, $base), count($si_prefix) - 1);
     $bytesused = $bytestotal - $bytesfree;
     try {
         $diskStatus = new DiskStatus('/home' . $username);
         $freeSpace = $diskStatus->freeSpace();
         $totalSpace = $diskStatus->totalSpace();
         $barWidth = $diskStatus->usedSpace() / 500 * 500;
     } catch (Exception $e) {
         $spacebodyerr .= 'Error (' . $e - getMessage() . ')';
         exit;
     }
     $dffree .= '' . sprintf('%1.2f', $bytesfree / pow($base, $class));
     $dfused .= '' . sprintf('%1.2f', $bytesused / pow($base, $class));
     $dftotal .= '' . sprintf('%1.2f', $bytestotal / pow($base, $class));
     $perused = sprintf('%1.0f', $bytesused / $bytestotal * 100);
 }
 if (file_exists('/home/' . $username . '/.sessions/rtorrent.lock')) {
     $rtorrents = shell_exec("ls /home/" . $username . "/.sessions/*.torrent|wc -l");
 }
コード例 #2
0
ファイル: functions.php プロジェクト: arckosfr/QB-dashboard
$si_prefix = array('B', 'KB', 'MB', 'GB', 'TB', 'EB', 'ZB', 'YB');
$torrents = shell_exec("ls /home/" . $username . "/.sessions/*.torrent|wc -l");
$php_self = $_SERVER['PHP_SELF'];
$web_path = substr($php_self, 0, strrpos($php_self, '/') + 1);
$time = microtime();
$time = explode(" ", $time);
$time = $time[1] + $time[0];
$start = $time;
if (file_exists('/usr/sbin/repquota')) {
    $dftotal = shell_exec("sudo /usr/sbin/repquota /|/bin/grep ^" . $username . "|/usr/bin/awk '{printf \$4/1024/1024}'");
    $dffree = shell_exec("sudo /usr/sbin/repquota /|/bin/grep ^" . $username . "|/usr/bin/awk '{printf (\$4-\$3)/1024/1024}'");
    $dfused = shell_exec("sudo /usr/sbin/repquota /|/bin/grep ^" . $username . "|/usr/bin/awk '{printf \$3/1024/1024}'");
    $perused = sprintf('%1.0f', $dfused / $dftotal * 100);
} else {
    try {
        $diskStatus = new DiskStatus('/home/' . $username);
        $freeSpace = $diskStatus->freeSpace();
        $totalSpace = $diskStatus->totalSpace();
        $usedSpace = $diskStatus->totalSpace() - $diskStatus->freeSpace();
    } catch (Exception $e) {
        $spacebodyerr .= 'Error (' . $e - getMessage() . ')';
        exit;
    }
    $dffree = $diskStatus->addUnits($freeSpace);
    //.'<b>'.$si_prefix[$class].'</b> Free<br/>'
    $dfused = $diskStatus->addUnits($usedSpace);
    //.'<b>'.$si_prefix[$class].'</b> Used<br/>'
    $dftotal = $diskStatus->addUnits($totalSpace);
    //.'<b>'.$si_prefix[$class].'</b> Total<br/>'
    $perused = sprintf('%1.0f', $usedSpace * 100 / $totalSpace);
}