Crew algemeen |
|
Parse error: parse error in C:\servers\xampp\htdocs\classes\diskspace.class.php on line 34
<?php
class diskspace {
// set all var's to FALSE!
var $drive = false;
var $freespace = false;
var $usedspace = false;
var $totalspace = false;
var $entity = false;
function diskspace ($drive="/") { // php4
$this->setdrive ($drive);
}
function __construct ($drive="/") { // php5
$this->diskspace($drive);
}
function setDrive ($drive="/") {
$this->drive = $drive;
return $this->drive;
}
function setEntity ($entity="MB") {
$entities = array("B", "KB", "MB", "GB", "TB");
if(in_array($entity, $entities)) {
$this->entity = $entity;
return true;
}
else
return false;
}
function getTotalSpace ($entity=$this->entity) {
$this->totalspace = $this->calculate(disk_total_space($this->drive), $entity)
return $this->totalspace;
}
function getFreeSpace ($entity=$this->entity) {
$this->freespace = $this->calculate(disk_free_space($this->drive), $entity);
return $this->freespace;
}
function getUsedSpace ($entity=$this->entity) {
$usedspace = disk_total_space($this->drive)-disk_free_space($this->drive);
return $this->calculate($usedspace, $entity);
}
function calculate ($space=$this->totalspace, $entity=false) {
$freespace['B'] = $space;
$freespace['KB'] = $freespace['B']/1024;
$freespace['MB'] = $freespace['KB']/1024;
$freespace['GB'] = $freespace['MB']/1024;
$freespace['TB'] = $freespace['GB']/1024;
if($entity)
$freespace = $freespace[$entity];
elseif($freespace['B'] < 1024)
$freespace = $freespace['B']." B";
elseif($freespace['KB'] < 1024)
$freespace = $freespace['KB']." KB";
elseif($freespace['MB'] < 1024)
$freespace = $freespace['MB']." MB";
elseif($freespace['GB'] < 1024)
$freespace = $freespace['GB']." GB";
elseif($freespace['TB'] < 1024)
$freespace = $freespace['TB']." TB";
else
$freespace = "UNLIMITED!"; // imposible... more as 1023 TB in one pc...
return $freespace;
}
}
?>
<?php class diskspace { // set all var's to FALSE! var $drive = false; var $freespace = false; var $usedspace = false; var $totalspace = false; var $entity = false; function diskspace ($drive="/") { // php4 $this->setdrive ($drive); } function __construct ($drive="/") { // php5 $this->diskspace($drive); } function setDrive ($drive="/") { $this->drive = $drive; return $this->drive; } function setEntity ($entity="MB") { $entities = array("B", "KB", "MB", "GB", "TB"); $this->entity = $entity; return true; } else return false; } function getTotalSpace ($entity=$this->entity) { return $this->totalspace; } function getFreeSpace ($entity=$this->entity) { $this->freespace = $this->calculate(disk_free_space($this->drive), $entity); return $this->freespace; } function getUsedSpace ($entity=$this->entity) { return $this->calculate($usedspace, $entity); } function calculate ($space=$this->totalspace, $entity=false) { $freespace['B'] = $space; $freespace['KB'] = $freespace['B']/1024; $freespace['MB'] = $freespace['KB']/1024; $freespace['GB'] = $freespace['MB']/1024; $freespace['TB'] = $freespace['GB']/1024; if($entity) $freespace = $freespace[$entity]; elseif($freespace['B'] < 1024) $freespace = $freespace['B']." B"; elseif($freespace['KB'] < 1024) $freespace = $freespace['KB']." KB"; elseif($freespace['MB'] < 1024) $freespace = $freespace['MB']." MB"; elseif($freespace['GB'] < 1024) $freespace = $freespace['GB']." GB"; elseif($freespace['TB'] < 1024) $freespace = $freespace['TB']." TB"; else $freespace = "UNLIMITED!"; // imposible... more as 1023 TB in one pc... return $freespace; } } ?>
Zelf zie ik niet direct een foutje...
|