progetto201 API
Functions | Variables
diskinfo.php File Reference

DISKINFO: manages disk space information. More...

Functions

 HumanSize ($Bytes)
 This function changes the measurement unit of bytes. More...
 

Variables

 $response = array("errors" => array())
 Prepare default response array with no errors. More...
 

Detailed Description

DISKINFO: manages disk space information.

Client perspective:

The script identifies the OS to choose which is the main partition, uses built-in functions to get free and total space and calculates the occupied space.

After that it uses the HumanSize() function to convert free, total and occupied space in bytes to a human readable unit (for example MB, GB,...).

Finally the data is printed to the client.

Error codes:

Since
01_01
Author
Stefano Zenaro (https://github.com/mario33881)

Function Documentation

◆ HumanSize()

HumanSize (   $Bytes)

This function changes the measurement unit of bytes.

A loop divides the passed value by 1024 until it gets smaller than 1024. During the loop an index gets incremented to choose the correct measurement unit.

Finally the function rounds the value and returns an array with the value and the measurement unit.

Since
01_01
Parameters
int$Bytesbytes to convert in a new measurement unit
Returns
array $humanbytes array with new bytes value and human readable unit

Variable Documentation

◆ $response

$response = array("errors" => array())

Prepare default response array with no errors.