-
Notifications
You must be signed in to change notification settings - Fork 4
/
system_resources.class.php
50 lines (42 loc) · 1.33 KB
/
system_resources.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/** system_resources class include
*
*
*
* @author Rafael Martin Soto
* @author {@link http://www.inatica.com/ Inatica}
* @since July 2021
* @version 1.0
* @license GNU General Public License v3.0
*/
require_once( 'resources.class.php' );
/* system_resources class
*/
class system_resources
{
public $IsWindows;
public $Resources;
/**
* On create class, it get itself and set the values of Hardware that it can take from the system
* Works in GNU/Linux & Windows systems
*/
public function __construct( ) {
$this->IsWindows = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'); // This determine the type of OS Windows/Linux
if( $this->IsWindows ){
require_once( 'resources_windows.class.php' );
$this->Resources = new resources_windows();
} else {
require_once( 'resources_linux.class.php' );
$this->Resources = new resources_linux();
}
} // /__construct()
/**
* Returns a given value in bytes at its closest value in b, kb, mb, gb, tb, pb
* Original from https://www.programmersought.com/article/87232238278/
*/
public function convert($size){
$unit=array('b','kb','mb','gb','tb','pb');
return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
} // /convert()
} // /system_resources class
?>