Created
April 11, 2018 21:02
-
-
Save seanvree/23d1198048b69ac31697a7034d45bed4 to your computer and use it in GitHub Desktop.
drives.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$fso = new COM('Scripting.FileSystemObject'); | |
$D = $fso->Drives; | |
$type = array("Unknown","Removable","Fixed","Network","CD-ROM","RAM Disk"); | |
foreach($D as $d ){ | |
$dO = $fso->GetDrive($d); | |
$s = ""; | |
if($dO->DriveType == 3){ | |
$n = $dO->Sharename; | |
}else if($dO->IsReady){ | |
$n = $dO->VolumeName; | |
$s = file_size($dO->FreeSpace) . " free of: " . file_size($dO->TotalSize); | |
}else{ | |
$n = "[Drive not ready]"; | |
} | |
echo "Drive " . $dO->DriveLetter . ": - " . $type[$dO->DriveType] . " - " . $n . " - " . $s . "<br>"; | |
} | |
function file_size($size) | |
{ | |
$filesizename = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB"); | |
return $size ? round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $filesizename[$i] : '0 Bytes'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment