note 100886 added to class.com
| From: | sparrowstail at googlemail dot com | Date: | Fri, 12 Nov 2010 19:35:29 +0000 |
| Subject: | note 100886 added to class.com | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-173984@lists.php.net to get a copy of this message | ||
This script reports all Windows drives, drive type, status (if not available), free space and total
drive size:
<?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';
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 85.211.218.128
----
Manual Page -- http://www.php.net/manual/en/class.com.php
Edit -- https://master.php.net/note/edit/100886
Del: integrated -- https://master.php.net/note/delete/100886/integrated
Del: useless -- https://master.php.net/note/delete/100886/useless
Del: bad code -- https://master.php.net/note/delete/100886/bad+code
Del: spam -- https://master.php.net/note/delete/100886/spam
Del: non-english -- https://master.php.net/note/delete/100886/non-english
Del: in docs -- https://master.php.net/note/delete/100886/in+docs
Del: other reasons-- https://master.php.net/note/delete/100886
Reject -- https://master.php.net/note/reject/100886
Search -- https://master.php.net/manage/user-notes.php