Home » , » Melihat Space HDD dengan PHP

Melihat Space HDD dengan PHP

Written By Hary on Thursday, July 4, 2013 | 2:15 PM

jika kalian sudah menerapakan 3 step di bawah ini, kalian akan mendapatkan seperti gambar diatas.







Source Code Step 1: Silakan copy script dibawah ini dimana disini ada syntax untuk get space hard disk.

<?php
/* get disk space free (in bytes) */
$df = disk_free_space("C:");
/* and get disk space total (in bytes)  */
$dt = disk_total_space("C:");
/* now we calculate the disk space used (in bytes) */
$du = $dt - $df;
/* percentage of disk used - this will be used to also set the width % of the progress bar */
$dp = sprintf('%.2f',($du / $dt) * 100);

/* and we formate the size from bytes to MB, GB, etc. */
$df = formatSize($df);
$du = formatSize($du);
$dt = formatSize($dt);

function formatSize( $bytes )
{
        $types = array( 'B', 'KB', 'MB', 'GB', 'TB' );
        for( $i = 0; $bytes >= 1024 && $i < ( count( $types ) -1 ); $bytes /= 1024, $i++ );
                return( round( $bytes, 2 ) . " " . $types[$i] );
}

?>
Source Code Step 2: Silakan copy script css dibawah ini.
<style type='text/css'>
.progress {
        border: 2px solid #5E96E4;
        height: 32px;
        width: 540px;
        margin: 30px auto;
}
.progress .prgbar {
        background: #A7C6FF;
        width: %;
        position: relative;
        height: 32px;
        z-index: 999;
}
.progress .prgtext {
        color: #286692;
        text-align: center;
        font-size: 13px;
        padding: 9px 0 0;
        width: 540px;
        position: absolute;
        z-index: 1000;
}
.progress .prginfo {
        margin: 3px 0;
}
</style>
Source Code Step 3: Silakan copy script index dibawah ini:
</style>
</div class='progress'>
        </div class='prgtext'></?php echo $dp; ?>% Disk Used<//div>
        </div class='prgbar'><//div>
        </div class='prginfo'>
                </span style='float: left;'></?php echo "$du of $dt used"; ?><//span>
                </span style='float: right;'></?php echo "$df of $dt free"; ?><//span>
                </span style='clear: both;'><//span>
        <//div>
<//div>
Silakan gabung semua source code jadikan satu dengan nama index.html dan silakan jalankan di browser. jreng-jreng space hard disk kalian akan terlihat silakan modifikasi sesuka kalian.
Share this article :

0 komentar:

Post a Comment

Silahkan Memberikan Respond Anda Sebagai Pembaca :)