コード例 #1
0
ファイル: tiki-admin_system.php プロジェクト: noikiy/owaspbwa
function du($path, $begin = null)
{
    if (!$path or !is_dir($path)) {
        return array('total' => 0, 'cant' => 0);
    }
    $total = 0;
    $cant = 0;
    $back = array();
    $all = opendir($path);
    while ($file = readdir($all)) {
        if (is_dir($path . '/' . $file) and $file != ".." and $file != "." and $file != "CVS") {
            $du = du($path . '/' . $file);
            $total += $du['total'];
            $cant += $du['cant'];
            unset($file);
        } elseif (!is_dir($path . '/' . $file)) {
            if (isset($begin) && substr($file, 0, strlen($begin)) != $begin) {
                continue;
            }
            // the file name doesn't begin with the good beginning
            $stats = @stat($path . '/' . $file);
            // avoid the warning if safe mode on
            $total += $stats['size'];
            $cant++;
            unset($file);
        }
    }
    closedir($all);
    unset($all);
    $back['total'] = $total;
    $back['cant'] = $cant;
    return $back;
}
コード例 #2
0
function UsageInfo($object, $usr = 0)
{
    global $DB, $settings, $user;
    if ($usr == 0) {
        $usr = $user['username'];
    }
    // MySQL Usage
    if ($object == 'mysql') {
        if (isset($settings['db_super_user'])) {
            $dbuser = $settings['db_super_user'];
            $dbpass = $settings['db_super_user'];
            $dbhost = $settings['db_external_host'];
        } else {
            $dbuser = $settings['zp_user'];
            $dbpass = $settings['zp_pass'];
            $dbhost = $settings['zp_host'];
        }
        $ADMDB = NewADOConnection("mysqli://{$dbuser}:{$dbpass}@{$dbhost}/mysql");
        return $ADMDB->GetOne("SELECT COUNT(*) FROM db WHERE User = '******'");
    }
    // FTP Usage
    if ($object == 'ftp') {
        return $DB->GetOne("SELECT COUNT(*) FROM accounts_ftp WHERE owner='" . $usr . "'");
    }
    // Domains
    if ($object == 'domains') {
        return $DB->GetOne("SELECT COUNT(*) FROM domains WHERE parked!=1 AND masterdomain='' AND user='******'");
    }
    // Subdomains
    if ($object == 'subdomains') {
        return $DB->GetOne("SELECT COUNT(*) FROM domains WHERE parked!=1 AND masterdomain!='' AND user='******'");
    }
    // Parked Domains
    if ($object == 'parkeddomains') {
        return $DB->GetOne("SELECT COUNT(*) FROM domains WHERE parked=1 AND masterdomain='' AND user='******'");
    }
    // Space (only available for current user)
    if ($object == 'space') {
        $homedir = str_replace('/public_html', '', $user['homedir']);
        $bytes = array("B", "KB", "MB", "GB", "TB", "PB");
        $size = du($homedir);
        $i = 0;
        while ($size >= 1024) {
            $size = $size / 1024;
            $i++;
        }
        if ($i > 1) {
            $friendly = round($size, 1) . " " . $bytes[$i];
        } else {
            $friendly = round($size, 0) . " " . $bytes[$i];
        }
        return $friendly;
    }
}
コード例 #3
0
ファイル: diskused.php プロジェクト: nperezg/pumilio
    $run = FALSE;
}
if ($run) {
    set_time_limit(0);
    function du($dir)
    {
        $res = `du -sb {$dir}`;
        // Unix command
        $B = explode('sounds/', $res);
        // Parse result
        return $B[0];
    }
    $sounds_size = formatsize(du("../sounds/sounds/"));
    $previewsounds_size = formatsize(du("../sounds/previewsounds/"));
    $images_size = formatsize(du("../sounds/images/"));
    $total_size = formatsize(du("../sounds/images/") + du("../sounds/previewsounds/") + du("../sounds/sounds/"));
    echo "<h2>Disk usage: {$total_size}</h2>\n\t\t<ul>\n\t\t\t<li>Sound files: {$sounds_size}\n\t\t\t<li>Sound preview files (mp3): {$previewsounds_size}\n\t\t\t<li>Image files (spectrograms and waveforms): {$images_size}\n\t\t</ul>";
    #Disk free space check
    $dir_to_check = $absolute_dir . "/tmp";
    $df = disk_free_space($dir_to_check);
    $dfh = formatsize($df);
    echo "<p>";
    if ($df < 5000000000.0) {
        echo "<div class=\"alert alert-warning\"><strong>Warning</strong>: ";
    } else {
        echo "<div class=\"alert alert-success\">";
    }
    echo "<h3>Disk free space: {$dfh}</h3></div>";
    echo "<br><p><a href=\"#\" onClick=\"window.close();\">Close window</a>";
} else {
    echo "<meta http-equiv=\"refresh\" content=\"1;url=diskused.php?run=TRUE\">\n\n\t</head>\n\t<body>\n\n\t<div style=\"padding: 10px;\">\n\n\t\t<br><br><br>\n\t\t<h3>Working... \n\t\t<br>Please wait... <i class=\"fa fa-cog fa-spin\"></i>\n\t\t</h3>\n\n\t\t<br><br><br>\n\t<br><p><a href=\"#\" onClick=\"window.close();\">Cancel and close window</a>";
コード例 #4
0
ファイル: admin_system.php プロジェクト: bitweaver/kernel
/**
 * du 
 * 
 * @param array $pPath 
 * @access public
 * @return boolean TRUE on success, FALSE on failure - $this->mErrors will contain reason for failure
 */
function du($pPath)
{
    $size = $count = 0;
    if (!$pPath or !is_dir($pPath)) {
        $ret['size'] = $size;
        $ret['count'] = $count;
        return $ret;
    }
    $all = opendir($pPath);
    while (FALSE !== ($file = readdir($all))) {
        if ($file != ".." and $file != "." and $file != "CVS") {
            if (is_file($pPath . '/' . $file)) {
                $size += filesize($pPath . '/' . $file);
                $count++;
                unset($file);
            } elseif (is_dir($pPath . '/' . $file)) {
                $du = du($pPath . '/' . $file);
                $size += $du['size'];
                $count += $du['count'];
                unset($file);
            }
        }
    }
    closedir($all);
    unset($all);
    $ret['size'] = $size;
    $ret['count'] = $count;
    return $ret;
}
コード例 #5
0
 public function hao()
 {
     du(session('SMS_CODE'));
     phpinfo();
 }