Revize c1bdc1c4
Přidáno uživatelem Michal Kliment před více než 9 roky(ů)
application/helpers/network.php | ||
---|---|---|
return ($size) ? $size . ' ' . $unit : '0 ' . $unit;
|
||
}
|
||
|
||
/**
|
||
* Formats speed
|
||
*
|
||
* @author Michal Kliment
|
||
* @param integer $speed In B/s
|
||
* @return string
|
||
*/
|
||
public static function speed($speed)
|
||
{
|
||
// default unit is nothing
|
||
$unit = '';
|
||
|
||
if ($speed >= 1024)
|
||
{
|
||
$unit = 'k';
|
||
$speed = round($speed / 1024, 2);
|
||
|
||
// size is too big
|
||
if ($speed >= 1024)
|
||
{
|
||
// transforms to Mega
|
||
$unit = 'M';
|
||
$speed = round($speed / 1024, 2);
|
||
|
||
// size is still too big
|
||
if ($speed >= 1024)
|
||
{
|
||
// transforms to Giga
|
||
$unit = 'G';
|
||
$speed = round($speed / 1024, 2);
|
||
|
||
// size is still too big
|
||
if ($speed >= 1024)
|
||
{
|
||
// transforms to Giga
|
||
$unit = 'T';
|
||
$speed = round($speed / 1024, 2);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
return ($speed) ? $speed . $unit : '0' . $unit;
|
||
}
|
||
|
||
/**
|
||
* Checks whether ip address belongs to default address ranges
|
||
*
|
||
... | ... | |
return true;
|
||
}
|
||
return false;
|
||
;
|
||
}
|
||
|
||
/**
|
||
* Converts speed string to integer
|
||
* Converts speed string to integer (bytes)
|
||
*
|
||
* @author Michal Kliment
|
||
* @param string $str
|
||
... | ... | |
}
|
||
|
||
/**
|
||
* Converts integer to speed string
|
||
* Converts integer (bytes) to speed string
|
||
*
|
||
* @author Michal Kliment
|
||
* @param type $bytes
|
Také k dispozici: Unified diff
Release 1.1.0