|
| 1 | +SystemProfile Class: 'support/system_profile.php' |
| 2 | +================================================== |
| 3 | + |
| 4 | +The SystemProfile class generates an array of internal device hardware information for the current device and also calculates a unique device fingerprint. Works for Windows, Mac OSX, various Linux distros (primarily Debian, RedHat, and Arch), FreeBSD, and perhaps other OSes. |
| 5 | + |
| 6 | +Example usage: |
| 7 | + |
| 8 | +```php |
| 9 | +<?php |
| 10 | + require_once "support/system_profile.php"; |
| 11 | + |
| 12 | + $result = SystemProfile::GetProfile(); |
| 13 | + |
| 14 | + var_dump($result); |
| 15 | +?> |
| 16 | +``` |
| 17 | + |
| 18 | +SystemProfile::GetHostname() |
| 19 | +---------------------------- |
| 20 | + |
| 21 | +Access: public static |
| 22 | + |
| 23 | +Parameters: None. |
| 24 | + |
| 25 | +Returns: A string containing the hostname on success, a boolean of false otherwise. |
| 26 | + |
| 27 | +This static function returns the hostname of the current device. |
| 28 | + |
| 29 | +SystemProfile::GetMachineID() |
| 30 | +----------------------------- |
| 31 | + |
| 32 | +Access: public static |
| 33 | + |
| 34 | +Parameters: None. |
| 35 | + |
| 36 | +Returns: A string containing the unique machine ID on success, a boolean of false otherwise. |
| 37 | + |
| 38 | +This static function returns the unique machine ID of the current device. |
| 39 | + |
| 40 | +SystemProfile::GetMotherboardInfo() |
| 41 | +----------------------------------- |
| 42 | + |
| 43 | +Access: public static |
| 44 | + |
| 45 | +Parameters: None. |
| 46 | + |
| 47 | +Returns: An array containing information about the motherboard on success, a boolean of false otherwise. |
| 48 | + |
| 49 | +This static function returns information about the motherboard for the current device. Not all OSes have the ability to retrieve this information. |
| 50 | + |
| 51 | +SystemProfile::GetCPUInfo() |
| 52 | +--------------------------- |
| 53 | + |
| 54 | +Access: public static |
| 55 | + |
| 56 | +Parameters: None. |
| 57 | + |
| 58 | +Returns: An array containing information about the CPU(s) on success, a boolean of false otherwise. |
| 59 | + |
| 60 | +This static function returns information about the CPU(s) for the current device. |
| 61 | + |
| 62 | +SystemProfile::GetRAMInfo() |
| 63 | +--------------------------- |
| 64 | + |
| 65 | +Access: public static |
| 66 | + |
| 67 | +Parameters: None. |
| 68 | + |
| 69 | +Returns: An array containing information about the RAM on success, a boolean of false otherwise. |
| 70 | + |
| 71 | +This static function returns information about the RAM for the current device. Most OSes just return the total capacity. Windows returns information about each individual stick/chip. |
| 72 | + |
| 73 | +SystemProfile::GetGPUInfo() |
| 74 | +--------------------------- |
| 75 | + |
| 76 | +Access: public static |
| 77 | + |
| 78 | +Parameters: None. |
| 79 | + |
| 80 | +Returns: An array containing information about the GPU on success, a boolean of false otherwise. |
| 81 | + |
| 82 | +This static function returns information about the GPU for the current device. |
| 83 | + |
| 84 | +SystemProfile::GetNICInfo() |
| 85 | +--------------------------- |
| 86 | + |
| 87 | +Access: public static |
| 88 | + |
| 89 | +Parameters: None. |
| 90 | + |
| 91 | +Returns: An array containing information about the network interfaces on success, a boolean of false otherwise. |
| 92 | + |
| 93 | +This static function returns information about the network interfaces for the current device. Where possible, physical controllers are included. |
| 94 | + |
| 95 | +SystemProfile::GetDiskInfo() |
| 96 | +---------------------------- |
| 97 | + |
| 98 | +Access: public static |
| 99 | + |
| 100 | +Parameters: None. |
| 101 | + |
| 102 | +Returns: An array containing information about the internal storage on success, a boolean of false otherwise. |
| 103 | + |
| 104 | +This static function returns information about the internal storage for the current device. |
| 105 | + |
| 106 | +SystemProfile::GetOSInfo() |
| 107 | +-------------------------- |
| 108 | + |
| 109 | +Access: public static |
| 110 | + |
| 111 | +Parameters: None. |
| 112 | + |
| 113 | +Returns: An array containing information about the current OS on success, a boolean of false otherwise. |
| 114 | + |
| 115 | +This static function returns information about the current OS for the current device. |
| 116 | + |
| 117 | +SystemProfile::GetProfile() |
| 118 | +--------------------------- |
| 119 | + |
| 120 | +Access: public static |
| 121 | + |
| 122 | +Parameters: None. |
| 123 | + |
| 124 | +Returns: An array containing information about the device. |
| 125 | + |
| 126 | +This static function returns information about the current device and calculates a unique device fingerprint. Depending on the OS, this function can take upwards of several seconds to run. |
| 127 | + |
| 128 | +SystemProfile::ExtractWMICResults($data, $expectedheader) |
| 129 | +--------------------------------------------------------- |
| 130 | + |
| 131 | +Access: protected static |
| 132 | + |
| 133 | +Parameters: |
| 134 | + |
| 135 | +* $data - A string containing the output from `wmic.exe`. |
| 136 | +* $expectedheader - A string containing an expected header to exist. |
| 137 | + |
| 138 | +Returns: An array containing the extracted data on success, a boolean of false otherwise. |
| 139 | + |
| 140 | +This internal static function extracts columnar data from `wmic.exe` output. |
| 141 | + |
| 142 | +SystemProfile::GetPCIConfBSD() |
| 143 | +------------------------------ |
| 144 | + |
| 145 | +Access: protected static |
| 146 | + |
| 147 | +Parameters: None. |
| 148 | + |
| 149 | +Returns: An array of information from `pciconf` on FreeBSD and similar systems on success, a boolean of false otherwise. |
| 150 | + |
| 151 | +This internal static function extracts data from `pciconf` on FreeBSD and similar systems. |
| 152 | + |
| 153 | +SystemProfile::GetIORegPlatformDeviceOSX() |
| 154 | +------------------------------------------ |
| 155 | + |
| 156 | +Access: protected static |
| 157 | + |
| 158 | +Parameters: None. |
| 159 | + |
| 160 | +Returns: An array of information from `IOPlatformExpertDevice` data via `ioreg` on Mac OSX on success, a boolean of false otherwise. |
| 161 | + |
| 162 | +This internal static function extracts `IOPlatformExpertDevice` data via `ioreg` on Mac OSX and similar systems. |
| 163 | + |
| 164 | +SystemProfile::FindExecutable($file, $path = false) |
| 165 | +--------------------------------------------------- |
| 166 | + |
| 167 | +Access: protected static |
| 168 | + |
| 169 | +Parameters: |
| 170 | + |
| 171 | +* $file - A string containing an executable filename to locate on the system. |
| 172 | +* $path - A boolean of false or a string containing the initial path to look in (Default is false). |
| 173 | + |
| 174 | +Returns: A string containing the full path and filename to the executable on success, a boolean of false otherwise. |
| 175 | + |
| 176 | +This internal static function attempts to locate a matching executable file. When $path is not supplied or the file is not found in the specified path, the environment PATH variable is processed. Identical to `ProcessHelper::FindExecutable()`. |
| 177 | + |
| 178 | +SystemProfile::RunCommand($cmd) |
| 179 | +------------------------------- |
| 180 | + |
| 181 | +Access: protected static |
| 182 | + |
| 183 | +Parameters: |
| 184 | + |
| 185 | +* $cmd - A string containing the command line to execute. |
| 186 | + |
| 187 | +Returns: A string containing the `stdout` output from the process on success, a boolean of false otherwise. |
| 188 | + |
| 189 | +This internal static function runs an executable and gathers output. On Windows, this function can optionally utilize the `ProcessHelper` class to avoid flashing console windows via `createprocess-win.exe`. |
0 commit comments