28,11 → 28,18 |
class WINNT extends OS |
{ |
/** |
* holds codepage for chcp |
* |
* @var int |
*/ |
private static $_cp = null; |
|
/** |
* holds the data from WMI Win32_OperatingSystem |
* |
* @var array |
*/ |
private $_Win32_OperatingSystem = null; |
private static $_Win32_OperatingSystem = null; |
|
/** |
* holds the data from WMI Win32_ComputerSystem |
46,9 → 53,16 |
* |
* @var array |
*/ |
private $_Win32_Processor = null; |
private static $_Win32_Processor = null; |
|
/** |
* holds the data from WMI Win32_PhysicalMemory |
* |
* @var array |
*/ |
private static $_Win32_PhysicalMemory = null; |
|
/** |
* holds the data from WMI Win32_PerfFormattedData_PerfOS_Processor |
* |
* @var array |
67,7 → 81,7 |
* |
* @var Object |
*/ |
private $_wmi = null; |
private static $_wmi = null; |
|
/** |
* holds the COM object that we pull all the EnumKey and RegRead data from |
84,11 → 98,25 |
private $_ver = ""; |
|
/** |
* holds system manufacturer |
* |
* @var string |
*/ |
private $_Manufacturer = ""; |
|
/** |
* holds system model |
* |
* @var string |
*/ |
private $_Model = ""; |
|
/** |
* holds all devices, which are in the system |
* |
* @var array |
*/ |
private $_wmidevices = array(); |
private $_wmidevices = null; |
|
/** |
* holds all disks, which are in the system |
112,14 → 140,41 |
private $_syslang = null; |
|
/** |
* value of checking run as administrator |
* |
* @var boolean |
*/ |
private static $_asadmin = null; |
|
/** |
* returns codepage for chcp |
* |
* @return int |
*/ |
public static function getcp() |
{ |
return self::$_cp; |
} |
|
/** |
* returns the COM object that we pull WMI root\CIMv2 data from |
* |
* @return Object |
*/ |
public static function getcimv2wmi() |
{ |
return self::$_wmi; |
} |
|
/** |
* reads the data from WMI Win32_OperatingSystem |
* |
* @return array |
*/ |
private function _get_Win32_OperatingSystem() |
public static function _get_Win32_OperatingSystem() |
{ |
if ($this->_Win32_OperatingSystem === null) $this->_Win32_OperatingSystem = CommonFunctions::getWMI($this->_wmi, 'Win32_OperatingSystem', array('CodeSet', 'Locale', 'LastBootUpTime', 'LocalDateTime', 'Version', 'ServicePackMajorVersion', 'Caption', 'OSArchitecture', 'TotalVisibleMemorySize', 'FreePhysicalMemory')); |
return $this->_Win32_OperatingSystem; |
if (self::$_Win32_OperatingSystem === null) self::$_Win32_OperatingSystem = self::getWMI(self::$_wmi, 'Win32_OperatingSystem', array('CodeSet', 'Locale', 'LastBootUpTime', 'LocalDateTime', 'Version', 'ServicePackMajorVersion', 'Caption', 'TotalVisibleMemorySize', 'FreePhysicalMemory')); |
return self::$_Win32_OperatingSystem; |
} |
|
/** |
129,7 → 184,7 |
*/ |
private function _get_Win32_ComputerSystem() |
{ |
if ($this->_Win32_ComputerSystem === null) $this->_Win32_ComputerSystem = CommonFunctions::getWMI($this->_wmi, 'Win32_ComputerSystem', array('Name', 'Manufacturer', 'Model', 'SystemFamily')); |
if ($this->_Win32_ComputerSystem === null) $this->_Win32_ComputerSystem = self::getWMI(self::$_wmi, 'Win32_ComputerSystem', array('Name', 'Manufacturer', 'Model', 'SystemFamily')); |
return $this->_Win32_ComputerSystem; |
} |
|
138,13 → 193,24 |
* |
* @return array |
*/ |
private function _get_Win32_Processor() |
public static function _get_Win32_Processor() |
{ |
if ($this->_Win32_Processor === null) $this->_Win32_Processor = CommonFunctions::getWMI($this->_wmi, 'Win32_Processor', array('LoadPercentage', 'AddressWidth', 'Name', 'L2CacheSize', 'L3CacheSize', 'CurrentClockSpeed', 'ExtClock', 'NumberOfCores', 'NumberOfLogicalProcessors', 'MaxClockSpeed', 'Manufacturer')); |
return $this->_Win32_Processor; |
if (self::$_Win32_Processor === null) self::$_Win32_Processor = self::getWMI(self::$_wmi, 'Win32_Processor', array('DeviceID', 'LoadPercentage', 'AddressWidth', 'Name', 'L2CacheSize', 'L3CacheSize', 'CurrentClockSpeed', 'ExtClock', 'NumberOfCores', 'NumberOfLogicalProcessors', 'MaxClockSpeed', 'Manufacturer', 'Architecture', 'Caption', 'CurrentVoltage')); |
return self::$_Win32_Processor; |
} |
|
/** |
* reads the data from WMI Win32_PhysicalMemory |
* |
* @return array |
*/ |
public static function _get_Win32_PhysicalMemory() |
{ |
if (self::$_Win32_PhysicalMemory === null) self::$_Win32_PhysicalMemory = self::getWMI(self::$_wmi, 'Win32_PhysicalMemory', array('PartNumber', 'DeviceLocator', 'Capacity', 'Manufacturer', 'SerialNumber', 'Speed', 'ConfiguredClockSpeed', 'ConfiguredVoltage', 'MemoryType', 'SMBIOSMemoryType', 'FormFactor', 'DataWidth', 'TotalWidth', 'BankLabel', 'MinVoltage', 'MaxVoltage')); |
return self::$_Win32_PhysicalMemory; |
} |
|
/** |
* reads the data from WMI Win32_PerfFormattedData_PerfOS_Processor |
* |
* @return array |
155,8 → 221,8 |
$this->_Win32_PerfFormattedData_PerfOS_Processor = array(); |
$buffer = $this->_get_Win32_OperatingSystem(); |
if ($buffer && isset($buffer[0]) && isset($buffer[0]['Version']) && version_compare($buffer[0]['Version'], "5.1", ">=")) { // minimal windows 2003 or windows XP |
$cpubuffer = CommonFunctions::getWMI($this->_wmi, 'Win32_PerfFormattedData_PerfOS_Processor', array('Name', 'PercentProcessorTime')); |
if ($cpubuffer) foreach ($cpubuffer as $cpu) { |
$cpubuffer = self::getWMI(self::$_wmi, 'Win32_PerfFormattedData_PerfOS_Processor', array('Name', 'PercentProcessorTime')); |
foreach ($cpubuffer as $cpu) { |
if (isset($cpu['Name']) && isset($cpu['PercentProcessorTime'])) { |
$this->_Win32_PerfFormattedData_PerfOS_Processor['cpu'.$cpu['Name']] = $cpu['PercentProcessorTime']; |
} |
183,6 → 249,320 |
} |
|
/** |
* checks WINNT and 'run as Administrator' mode |
* |
* @return boolean |
*/ |
public static function isAdmin() |
{ |
if (self::$_asadmin == null) { |
if (PSI_OS == 'WINNT') { |
$strBuf = ''; |
CommonFunctions::executeProgram('sfc', '2>&1', $strBuf, false); // 'net session' for detection does not work if "Server" (LanmanServer) service is stopped |
if (preg_match('/^\/SCANNOW\s/m', preg_replace('/(\x00)/', '', $strBuf))) { // SCANNOW checking - also if Unicode |
self::$_asadmin = true; |
} else { |
self::$_asadmin = false; |
} |
} else { |
self::$_asadmin = false; |
} |
} |
|
return self::$_asadmin; |
} |
|
/** |
* function for getting a list of values in the specified context |
* optionally filter this list, based on the list from third parameter |
* |
* @param $wmi object holds the COM object that we pull the WMI data from |
* @param string $strClass name of the class where the values are stored |
* @param array $strValue filter out only needed values, if not set all values of the class are returned |
* |
* @return array content of the class stored in an array |
*/ |
public static function getWMI($wmi, $strClass, $strValue = array()) |
{ |
$arrData = array(); |
if (gettype($wmi) === "object") { |
$value = ""; |
try { |
$objWEBM = $wmi->Get($strClass); |
$arrProp = $objWEBM->Properties_; |
$arrWEBMCol = $objWEBM->Instances_(); |
foreach ($arrWEBMCol as $objItem) { |
if (is_array($arrProp)) { |
reset($arrProp); |
} |
$arrInstance = array(); |
foreach ($arrProp as $propItem) { |
$value = $objItem->{$propItem->Name}; //instead exploitable eval("\$value = \$objItem->".$propItem->Name.";"); |
if (empty($strValue)) { |
if (is_string($value)) $arrInstance[$propItem->Name] = trim($value); |
else $arrInstance[$propItem->Name] = $value; |
} else { |
if (in_array($propItem->Name, $strValue)) { |
if (is_string($value)) $arrInstance[$propItem->Name] = trim($value); |
else $arrInstance[$propItem->Name] = $value; |
} |
} |
} |
$arrData[] = $arrInstance; |
} |
} catch (Exception $e) { |
if (PSI_DEBUG && (($message = trim($e->getMessage())) !== "<b>Source:</b> SWbemServicesEx<br/><b>Description:</b> Not found")) { |
$error = PSI_Error::singleton(); |
$error->addError("getWMI()", preg_replace('/<br\/>/', "\n", preg_replace('/<b>|<\/b>/', '', $message))); |
} |
} |
} elseif ((gettype($wmi) === "string") && (PSI_OS == 'Linux')) { |
$delimeter = '@@@DELIM@@@'; |
if (CommonFunctions::executeProgram('wmic', '--delimiter="'.$delimeter.'" '.$wmi.' '.$strClass.'" 2>/dev/null', $strBuf, true) && preg_match("/^CLASS:\s/", $strBuf)) { |
if (self::$_cp) { |
if (self::$_cp == 932) { |
$codename = ' (SJIS)'; |
} elseif (self::$_cp == 949) { |
$codename = ' (EUC-KR)'; |
} elseif (self::$_cp == 950) { |
$codename = ' (BIG-5)'; |
} else { |
$codename = ''; |
} |
self::convertCP($strBuf, 'windows-'.self::$_cp.$codename); |
} |
$lines = preg_split('/\n/', $strBuf, -1, PREG_SPLIT_NO_EMPTY); |
if (count($lines) >=3) { |
unset($lines[0]); |
$names = preg_split('/'.$delimeter.'/', $lines[1], -1, PREG_SPLIT_NO_EMPTY); |
$namesc = count($names); |
unset($lines[1]); |
foreach ($lines as $line) { |
$arrInstance = array(); |
$values = preg_split('/'.$delimeter.'/', $line, -1); |
if (count($values) == $namesc) { |
foreach ($values as $id=>$value) { |
if (empty($strValue)) { |
if ($value !== "(null)") $arrInstance[$names[$id]] = trim($value); |
else $arrInstance[$names[$id]] = null; |
} else { |
if (in_array($names[$id], $strValue)) { |
if ($value !== "(null)") $arrInstance[$names[$id]] = trim($value); |
else $arrInstance[$names[$id]] = null; |
} |
} |
} |
$arrData[] = $arrInstance; |
} |
} |
} |
} |
} |
|
return $arrData; |
} |
|
/** |
* readReg function |
* |
* @return boolean command successfull or not |
*/ |
public static function readReg($reg, $strName, &$strBuffer, $booErrorRep = true, $dword = false, $bits64 = false) |
{ |
$strBuffer = ''; |
|
if ($reg === false) { |
if (defined('PSI_EMU_HOSTNAME')) { |
return false; |
} |
$last = strrpos($strName, "\\"); |
$keyname = substr($strName, $last + 1); |
if ($bits64) { |
$param = ' /reg:64'; |
} else { |
$param = ''; |
} |
if ($dword) { |
$valtype = "DWORD"; |
} else { |
$valtype = "SZ|EXPAND_SZ"; |
} |
if (self::$_cp) { |
if (CommonFunctions::executeProgram('cmd', '/c chcp '.self::$_cp.' >nul & reg query "'.substr($strName, 0, $last).'" /v '.$keyname.$param.' 2>&1', $strBuf, $booErrorRep) && (strlen($strBuf) > 0) && preg_match("/^\s*".$keyname."\s+REG_(".$valtype.")\s+(.+)\s*$/mi", $strBuf, $buffer2)) { |
if ($dword) { |
$strBuffer = strval(hexdec($buffer2[2])); |
} else { |
$strBuffer = $buffer2[2]; |
} |
} else { |
return false; |
} |
} else { |
if (CommonFunctions::executeProgram('reg', 'query "'.substr($strName, 0, $last).'" /v '.$keyname.$param.' 2>&1', $strBuf, $booErrorRep) && (strlen($strBuf) > 0) && preg_match("/^\s*".$keyname."\s+REG_(".$valtype.")\s+(.+)\s*$/mi", $strBuf, $buffer2)) { |
if ($dword) { |
$strBuffer = strval(hexdec($buffer2[2])); |
} else { |
$strBuffer = $buffer2[2]; |
} |
} else { |
return false; |
} |
} |
} elseif (gettype($reg) === "object") { |
$_hkey = array('HKEY_CLASSES_ROOT'=>0x80000000, 'HKEY_CURRENT_USER'=>0x80000001, 'HKEY_LOCAL_MACHINE'=>0x80000002, 'HKEY_USERS'=>0x80000003, 'HKEY_PERFORMANCE_DATA'=>0x80000004, 'HKEY_PERFORMANCE_TEXT'=>0x80000050, 'HKEY_PERFORMANCE_NLSTEXT'=>0x80000060, 'HKEY_CURRENT_CONFIG'=>0x80000005, 'HKEY_DYN_DATA'=>0x80000006); |
$first = strpos($strName, "\\"); |
$last = strrpos($strName, "\\"); |
$hkey = substr($strName, 0, $first); |
if (isset($_hkey[$hkey])) { |
$sub_keys = new VARIANT(); |
try { |
if ($dword) { |
$reg->Get("StdRegProv")->GetDWORDValue(strval($_hkey[$hkey]), substr($strName, $first+1, $last-$first-1), substr($strName, $last+1), $sub_keys); |
} else { |
$reg->Get("StdRegProv")->GetStringValue(strval($_hkey[$hkey]), substr($strName, $first+1, $last-$first-1), substr($strName, $last+1), $sub_keys); |
} |
} catch (Exception $e) { |
if ($booErrorRep) { |
$error = PSI_Error::singleton(); |
$error->addError("GetStringValue()", preg_replace('/<br\/>/', "\n", preg_replace('/<b>|<\/b>/', '', $e->getMessage()))); |
} |
|
return false; |
} |
if (variant_get_type($sub_keys) !== VT_NULL) { |
$strBuffer = strval($sub_keys); |
} else { |
return false; |
} |
} else { |
return false; |
} |
} |
|
return true; |
} |
|
/** |
* enumKey function |
* |
* @return boolean command successfull or not |
*/ |
public static function enumKey($reg, $strName, &$arrBuffer, $booErrorRep = true) |
{ |
$arrBuffer = array(); |
|
if ($reg === false) { |
if (defined('PSI_EMU_HOSTNAME')) { |
return false; |
} |
if (self::$_cp) { |
if (CommonFunctions::executeProgram('cmd', '/c chcp '.self::$_cp.' >nul & reg query "'.$strName.'" 2>&1', $strBuf, $booErrorRep) && (strlen($strBuf) > 0) && preg_match_all("/^".preg_replace("/\\\\/", "\\\\\\\\", $strName)."\\\\(.*)/mi", $strBuf, $buffer2)) { |
foreach ($buffer2[1] as $sub_key) { |
$arrBuffer[] = trim($sub_key); |
} |
} else { |
return false; |
} |
} else { |
if (CommonFunctions::executeProgram('reg', 'query "'.$strName.'" 2>&1', $strBuf, $booErrorRep) && (strlen($strBuf) > 0) && preg_match_all("/^".preg_replace("/\\\\/", "\\\\\\\\", $strName)."\\\\(.*)/mi", $strBuf, $buffer2)) { |
foreach ($buffer2[1] as $sub_key) { |
$arrBuffer[] = trim($sub_key); |
} |
} else { |
return false; |
} |
} |
} elseif (gettype($reg) === "object") { |
$_hkey = array('HKEY_CLASSES_ROOT'=>0x80000000, 'HKEY_CURRENT_USER'=>0x80000001, 'HKEY_LOCAL_MACHINE'=>0x80000002, 'HKEY_USERS'=>0x80000003, 'HKEY_PERFORMANCE_DATA'=>0x80000004, 'HKEY_PERFORMANCE_TEXT'=>0x80000050, 'HKEY_PERFORMANCE_NLSTEXT'=>0x80000060, 'HKEY_CURRENT_CONFIG'=>0x80000005, 'HKEY_DYN_DATA'=>0x80000006); |
$first = strpos($strName, "\\"); |
$hkey = substr($strName, 0, $first); |
if (isset($_hkey[$hkey])) { |
$sub_keys = new VARIANT(); |
try { |
$reg->Get("StdRegProv")->EnumKey(strval($_hkey[$hkey]), substr($strName, $first+1), $sub_keys); |
} catch (Exception $e) { |
if ($booErrorRep) { |
$error = PSI_Error::singleton(); |
$error->addError("enumKey()", preg_replace('/<br\/>/', "\n", preg_replace('/<b>|<\/b>/', '', $e->getMessage())));; |
} |
|
return false; |
} |
if (variant_get_type($sub_keys) !== VT_NULL) { |
foreach ($sub_keys as $sub_key) { |
$arrBuffer[] = $sub_key; |
} |
} else { |
return false; |
} |
} else { |
return false; |
} |
} |
|
return true; |
} |
|
/** |
* initWMI function |
* |
* @return string, object or false |
*/ |
public static function initWMI($namespace, $booErrorRep = false) |
{ |
$wmi = false; |
if (self::$_wmi !== false) { // WMI not disabled |
try { |
if (PSI_OS == 'Linux') { |
if (defined('PSI_EMU_HOSTNAME')) |
$wmi = '--namespace="'.$namespace.'" -U '.PSI_EMU_USER.'%'.PSI_EMU_PASSWORD.' //'.PSI_EMU_HOSTNAME.' "select * from'; |
} elseif (PSI_OS == 'WINNT') { |
$objLocator = new COM('WbemScripting.SWbemLocator'); |
if (defined('PSI_EMU_HOSTNAME')) |
$wmi = $objLocator->ConnectServer(PSI_EMU_HOSTNAME, $namespace, PSI_EMU_USER, PSI_EMU_PASSWORD); |
else |
$wmi = $objLocator->ConnectServer('', $namespace); |
} |
} catch (Exception $e) { |
if ($booErrorRep) { |
$error = PSI_Error::singleton(); |
$error->addError("WMI connect ".$namespace." error", "PhpSysInfo can not connect to the WMI interface for security reasons.\nCheck an authentication mechanism for the directory where phpSysInfo is installed or credentials."); |
} |
} |
} |
|
return $wmi; |
} |
|
/** |
* convertCP function |
* |
* @return void |
*/ |
public static function convertCP(&$strBuf, $encoding) |
{ |
if (defined('PSI_SYSTEM_CODEPAGE') && (PSI_SYSTEM_CODEPAGE != null) && ($encoding != null) && ($encoding != PSI_SYSTEM_CODEPAGE)) { |
$systemcp = PSI_SYSTEM_CODEPAGE; |
if (preg_match("/^windows-\d+ \((.+)\)$/", $systemcp, $buf)) { |
$systemcp = $buf[1]; |
} |
if (preg_match("/^windows-\d+ \((.+)\)$/", $encoding, $buf)) { |
$encoding = $buf[1]; |
} |
$enclist = mb_list_encodings(); |
if (in_array($encoding, $enclist) && in_array($systemcp, $enclist)) { |
$strBuf = mb_convert_encoding($strBuf, $encoding, $systemcp); |
} elseif (function_exists("iconv")) { |
if (($iconvout=iconv($systemcp, $encoding.'//IGNORE', $strBuf))!==false) { |
$strBuf = $iconvout; |
} |
} elseif (function_exists("libiconv") && (($iconvout=libiconv($systemcp, $encoding, $strBuf))!==false)) { |
$strBuf = $iconvout; |
} |
} |
} |
|
/** |
* build the global Error object and create the WMI connection |
*/ |
public function __construct($blockname = false) |
192,7 → 572,7 |
$this->_ver = $ver_value; |
} |
if (($this->_ver !== "") && preg_match("/ReactOS\r?\n\S+\s+.+/", $this->_ver)) { |
$this->_wmi = false; // No WMI info on ReactOS yet |
self::$_wmi = false; // No WMI info on ReactOS yet |
$this->_reg = false; // No EnumKey and ReadReg on ReactOS yet |
} else { |
if (PSI_OS == 'WINNT') { |
200,15 → 580,14 |
try { |
$objLocator = new COM('WbemScripting.SWbemLocator'); |
$wmi = $objLocator->ConnectServer('', 'root\CIMv2'); |
$buffer = CommonFunctions::getWMI($wmi, 'Win32_OperatingSystem', array('CodeSet')); |
$buffer = self::getWMI($wmi, 'Win32_OperatingSystem', array('CodeSet')); |
if (!$buffer) { |
$reg = $objLocator->ConnectServer('', 'root\default'); |
if (CommonFunctions::readReg($reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage\\ACP", $strBuf, false)) { |
if (self::readReg($reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage\\ACP", $strBuf, false)) { |
$buffer[0]['CodeSet'] = $strBuf; |
} |
} |
if ($buffer && isset($buffer[0])) { |
if (isset($buffer[0]['CodeSet'])) { |
if ($buffer && isset($buffer[0]) && isset($buffer[0]['CodeSet'])) { |
$codeset = $buffer[0]['CodeSet']; |
if ($codeset == 932) { |
$codename = ' (SJIS)'; |
220,6 → 599,10 |
$codename = ''; |
} |
define('PSI_SYSTEM_CODEPAGE', 'windows-'.$codeset.$codename); |
} else { |
define('PSI_SYSTEM_CODEPAGE', null); |
if (PSI_DEBUG) { |
$this->error->addError("__construct()", "PhpSysInfo can not detect PSI_SYSTEM_CODEPAGE"); |
} |
} |
} catch (Exception $e) { |
232,9 → 615,9 |
define('PSI_SYSTEM_CODEPAGE', null); |
} |
} |
$this->_wmi = CommonFunctions::initWMI('root\CIMv2', true); |
self::$_wmi = self::initWMI('root\CIMv2', true); |
if (PSI_OS == 'WINNT') { |
$this->_reg = CommonFunctions::initWMI('root\default', PSI_DEBUG); |
$this->_reg = self::initWMI('root\default', PSI_DEBUG); |
if (gettype($this->_reg) === "object") { |
$this->_reg->Security_->ImpersonationLevel = 3; |
} |
255,10 → 638,10 |
{ |
$buffer = $this->_get_Win32_OperatingSystem(); |
if (!$buffer) { |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage\\ACP", $strBuf, false)) { |
if (self::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage\\ACP", $strBuf, false)) { |
$buffer[0]['CodeSet'] = $strBuf; |
} |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Nls\\Language\\Default", $strBuf, false)) { |
if (self::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Nls\\Language\\Default", $strBuf, false)) { |
$buffer[0]['Locale'] = $strBuf; |
} |
} |
274,7 → 657,7 |
} else { |
$codename = ''; |
} |
CommonFunctions::setcp($codeset); |
self::$_cp = $codeset; |
$this->_codepage = 'windows-'.$codeset.$codename; |
} |
if (isset($buffer[0]['Locale']) && (($locale = hexdec($buffer[0]['Locale']))>0)) { |
301,37 → 684,76 |
*/ |
private function _devicelist($strType) |
{ |
if (empty($this->_wmidevices)) { |
if ($this->_wmidevices === null) { |
$this->_wmidevices = array(); |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) { |
$this->_wmidevices = CommonFunctions::getWMI($this->_wmi, 'Win32_PnPEntity', array('Name', 'PNPDeviceID', 'Manufacturer', 'PNPClass')); |
$this->_wmidevices = self::getWMI(self::$_wmi, 'Win32_PnPEntity', array('Name', 'PNPDeviceID', 'Manufacturer', 'PNPClass')); |
if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) { |
$this->_wmidisks = CommonFunctions::getWMI($this->_wmi, 'Win32_DiskDrive', array('PNPDeviceID', 'Size', 'SerialNumber')); |
$this->_wmidisks = self::getWMI(self::$_wmi, 'Win32_DiskDrive', array('PNPDeviceID', 'Size', 'SerialNumber')); |
} else { |
$this->_wmidisks = CommonFunctions::getWMI($this->_wmi, 'Win32_DiskDrive', array('PNPDeviceID', 'Size')); |
$this->_wmidisks = self::getWMI(self::$_wmi, 'Win32_DiskDrive', array('PNPDeviceID', 'Size')); |
} |
} else { |
$this->_wmidevices = CommonFunctions::getWMI($this->_wmi, 'Win32_PnPEntity', array('Name', 'PNPDeviceID')); |
$this->_wmidevices = self::getWMI(self::$_wmi, 'Win32_PnPEntity', array('Name', 'PNPDeviceID')); |
} |
|
if (empty($this->_wmidevices)) { |
$lstdevs = array(); |
$services = array(); |
foreach (array('PCI', 'USB') as $type) { |
$hkey = "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\".$type; |
if (self::enumKey($this->_reg, $hkey, $vendevs, false)) { |
foreach ($vendevs as $vendev) if (self::enumKey($this->_reg, $hkey."\\".$vendev, $ids, false)) { |
foreach ($ids as $id) { |
if ($type === 'PCI') { // enumerate all PCI devices |
$lstdevs[$type."\\".$vendev."\\".$id] = true; |
} elseif (self::readReg($this->_reg, $hkey."\\".$vendev."\\".$id."\\Service", $service, false)) { |
$services[$service] = true; // ever used USB services |
break; |
} |
} |
} |
} |
} |
|
$hkey = "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services"; |
foreach ($services as $service=>$tmp) if (self::readReg($this->_reg, $hkey."\\".$service."\\Enum\\Count", $count, false, true) && ($count > 0)) { |
for ($i = 0; $i < $count; $i++) if (self::readReg($this->_reg, $hkey."\\".$service."\\Enum\\".$i, $id, false) && preg_match("/^USB/", $id)) { |
$lstdevs[$id] = true; // used USB devices |
} |
} |
|
$hkey = "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\"; |
foreach ($lstdevs as $lstdev=>$tmp) { |
if (self::readReg($this->_reg, $hkey.$lstdev."\\DeviceDesc", $nameBuf, false)) { |
$namesplit = preg_split('/;/', $nameBuf, -1, PREG_SPLIT_NO_EMPTY); |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS && self::readReg($this->_reg, $hkey.$lstdev."\\Mfg", $mfgBuf, false)) { |
$mfgsplit = preg_split('/;/', $mfgBuf, -1, PREG_SPLIT_NO_EMPTY); |
$this->_wmidevices[] = array('Name'=>$namesplit[count($namesplit)-1], 'PNPDeviceID'=>$lstdev, 'Manufacturer'=>$mfgsplit[count($mfgsplit)-1]); |
} else { |
$this->_wmidevices[] = array('Name'=>$namesplit[count($namesplit)-1], 'PNPDeviceID'=>$lstdev); |
} |
} |
} |
|
$hkey = "HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\Scsi"; |
$id = 0; |
if (CommonFunctions::enumKey($this->_reg, $hkey, $portBuf, false)) { |
if (self::enumKey($this->_reg, $hkey, $portBuf, false)) { |
foreach ($portBuf as $scsiport) { |
if (CommonFunctions::enumKey($this->_reg, $hkey."\\".$scsiport, $busBuf, false)) { |
if (self::enumKey($this->_reg, $hkey."\\".$scsiport, $busBuf, false)) { |
foreach ($busBuf as $scsibus) { |
if (CommonFunctions::enumKey($this->_reg, $hkey."\\".$scsiport."\\".$scsibus, $tarBuf, false)) { |
if (self::enumKey($this->_reg, $hkey."\\".$scsiport."\\".$scsibus, $tarBuf, false)) { |
foreach ($tarBuf as $scsitar) if (!strncasecmp($scsitar, "Target Id ", strlen("Target Id "))) { |
if (CommonFunctions::enumKey($this->_reg, $hkey."\\".$scsiport."\\".$scsibus."\\".$scsitar, $logBuf, false)) { |
if (self::enumKey($this->_reg, $hkey."\\".$scsiport."\\".$scsibus."\\".$scsitar, $logBuf, false)) { |
foreach ($logBuf as $scsilog) if (!strncasecmp($scsilog, "Logical Unit Id ", strlen("Logical Unit Id "))) { |
$hkey2 = $hkey."\\".$scsiport."\\".$scsibus."\\".$scsitar."\\".$scsilog."\\"; |
if ((CommonFunctions::readReg($this->_reg, $hkey2."DeviceType", $typeBuf, false) || CommonFunctions::readReg($this->_reg, $hkey2."Type", $typeBuf, false)) |
if ((self::readReg($this->_reg, $hkey2."DeviceType", $typeBuf, false) || self::readReg($this->_reg, $hkey2."Type", $typeBuf, false)) |
&& (($typeBuf=strtolower(trim($typeBuf))) !== "")) { |
if ((($typeBuf == 'diskperipheral') || ($typeBuf == 'cdromperipheral')) |
&& CommonFunctions::readReg($this->_reg, $hkey2."Identifier", $ideBuf, false)) { |
&& self::readReg($this->_reg, $hkey2."Identifier", $ideBuf, false)) { |
$this->_wmidevices[] = array('Name'=>$ideBuf, 'PNPDeviceID'=>'SCSI\\'.$id); |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS && defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL |
&& (CommonFunctions::readReg($this->_reg, $hkey2."SerialNumber", $serBuf, false)) |
&& self::readReg($this->_reg, $hkey2."SerialNumber", $serBuf, false) |
&& (($serBuf=trim($serBuf)) !== "")) { |
$this->_wmidisks[] = array('PNPDeviceID'=>'SCSI\\'.$id, 'SerialNumber'=>$serBuf); |
} |
371,6 → 793,7 |
$device['Serial'] = null; |
if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) { |
if ($strType==='USB') { |
// if (preg_match('/\\\\([^\\\\][^&\\\\][^\\\\]+)$/', $device['PNPDeviceID'], $buf)) { // second character !== & |
if (preg_match('/\\\\(\w+)$/', $device['PNPDeviceID'], $buf)) { |
$device['Serial'] = $buf[1]; |
} |
400,11 → 823,11 |
*/ |
private function _hostname() |
{ |
if ((PSI_USE_VHOST === true) && !defined('PSI_EMU_HOSTNAME')) { |
if (PSI_USE_VHOST && !defined('PSI_EMU_HOSTNAME')) { |
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm); |
} else { |
$buffer = $this->_get_Win32_ComputerSystem(); |
if (!$buffer && CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ActiveComputerName\\ComputerName", $strBuf, false) && (strlen($strBuf) > 0)) { |
if (!$buffer && self::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ActiveComputerName\\ComputerName", $strBuf, false) && (strlen($strBuf) > 0)) { |
$buffer[0]['Name'] = $strBuf; |
} |
if ($buffer) { |
437,6 → 860,44 |
} |
|
/** |
* Virtualizer info |
* |
* @return void |
*/ |
protected function _virtualizer() |
{ |
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) { |
$cpuvirt = $this->sys->getVirtualizer(); // previous info from _cpuinfo() |
|
$vendor_array = array(); |
if ($this->_Model != "") { |
$vendor_array[] = $this->_Model; |
} |
if ($this->_Manufacturer != "") { |
if ($this->_Model != "") { |
$vendor_array[] = $this->_Manufacturer." ".$this->_Model; |
} else { |
$vendor_array[] = $this->_Manufacturer; |
} |
} |
$novm = true; |
if (count($vendor_array)>0) { |
$virt = CommonFunctions::decodevirtualizer($vendor_array); |
if ($virt !== null) { |
$this->sys->setVirtualizer($virt); |
$novm = false; |
} |
} |
if ($novm) { |
// Detect QEMU cpu |
if (isset($cpuvirt["cpuid:QEMU"])) { |
$this->sys->setVirtualizer('qemu'); // QEMU |
} |
} |
} |
} |
|
/** |
* UpTime |
* time the system is running |
* |
477,7 → 938,7 |
$result = $localtime - $boottime; |
|
$this->sys->setUptime($result); |
} elseif (($this->sys->getDistribution()=="ReactOS") && CommonFunctions::executeProgram('uptime', '', $strBuf, false) && (strlen($strBuf) > 0) && preg_match("/^System Up Time:\s+(\d+) days, (\d+) Hours, (\d+) Minutes, (\d+) Seconds/", $strBuf, $ar_buf)) { |
} elseif (!defined('PSI_EMU_HOSTNAME') && (substr($this->sys->getDistribution(), 0, 7)=="ReactOS") && CommonFunctions::executeProgram('uptime', '', $strBuf, false) && (strlen($strBuf) > 0) && preg_match("/^System Up Time:\s+(\d+) days, (\d+) Hours, (\d+) Minutes, (\d+) Seconds/", $strBuf, $ar_buf)) { |
$sec = $ar_buf[4]; |
$min = $ar_buf[3]; |
$hours = $ar_buf[2]; |
498,7 → 959,7 |
$users = count($lines)-1; |
} else { |
$users = 0; |
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_Process', array('Caption')); |
$buffer = self::getWMI(self::$_wmi, 'Win32_Process', array('Caption')); |
foreach ($buffer as $process) { |
if (strtoupper($process['Caption']) == strtoupper('explorer.exe')) { |
$users++; |
518,19 → 979,50 |
$buffer = $this->_get_Win32_OperatingSystem(); |
if ($buffer) { |
$ver = $buffer[0]['Version']; |
if (($this->_ver !== "") && preg_match("/^Microsoft [^\[]*\s*\[\D*\s*(".$ver."\.\d+).*\]/", $this->_ver, $ar_temp)) { |
$kernel = $ar_temp[1]; |
} else { |
$kernel = $ver; |
} |
if ($buffer[0]['ServicePackMajorVersion'] > 0) { |
$kernel .= ' SP'.$buffer[0]['ServicePackMajorVersion']; |
} |
if (isset($buffer[0]['OSArchitecture']) && preg_match("/^(\d+)/", $buffer[0]['OSArchitecture'], $bits)) { |
$this->sys->setKernel($kernel.' ('.$bits[1].'-bit)'); |
} elseif (($allCpus = $this->_get_Win32_Processor()) && isset($allCpus[0]['AddressWidth'])) { |
$this->sys->setKernel($kernel.' ('.$allCpus[0]['AddressWidth'].'-bit)'); |
if ($allCpus = $this->_get_Win32_Processor()) { |
$addresswidth = 0; |
if (isset($allCpus[0]['AddressWidth']) && (($addresswidth = $allCpus[0]['AddressWidth']) > 0)) { |
$kernel .= ' ('.$addresswidth.'-bit)'; |
} |
if (isset($allCpus[0]['Architecture'])) { |
switch ($allCpus[0]['Architecture']) { |
case 0: $kernel .= ' x86'; break; |
case 1: $kernel .= ' MIPS'; break; |
case 2: $kernel .= ' Alpha'; break; |
case 3: $kernel .= ' PowerPC'; break; |
case 5: $kernel .= ' ARM'; break; |
case 6: $kernel .= ' ia64'; break; |
case 9: if ($addresswidth == 32) { |
$kernel .= ' x86'; |
} else { |
$kernel .= ' x64'; |
} |
break; |
case 12: if ($addresswidth == 32) { |
$kernel .= ' ARM'; |
} else { |
$kernel .= ' ARM64'; |
} |
} |
} |
} |
$this->sys->setKernel($kernel); |
$distribution = $buffer[0]['Caption']; |
if (version_compare($ver, "10.0", ">=") && !preg_match('/server/i', $buffer[0]['Caption']) && ($list = @parse_ini_file(PSI_APP_ROOT."/data/osnames.ini", true))) { |
$karray = preg_split('/\./', $ver); |
if (isset($karray[2]) && isset($list['win10'][$karray[2]])) { |
$distribution .= ' ('.$list['win10'][$karray[2]].')'; |
} |
$this->sys->setDistribution($buffer[0]['Caption']); |
|
} |
$this->sys->setDistribution($distribution); |
if (version_compare($ver, "5.1", "<")) |
$icon = 'Win2000.png'; |
elseif (version_compare($ver, "5.1", ">=") && version_compare($ver, "6.0", "<")) |
537,8 → 1029,10 |
$icon = 'WinXP.png'; |
elseif (version_compare($ver, "6.0", ">=") && version_compare($ver, "6.2", "<")) |
$icon = 'WinVista.png'; |
elseif (version_compare($ver, "6.2", ">=") && version_compare($ver, "10.0.21996", "<")) |
$icon = 'Win8.png'; |
else |
$icon = 'Win8.png'; |
$icon = 'Win11.png'; |
$this->sys->setDistributionIcon($icon); |
} elseif ($this->_ver !== "") { |
if (preg_match("/ReactOS\r?\n\S+\s+(.+)/", $this->_ver, $ar_temp)) { |
550,26 → 1044,48 |
$this->sys->setKernel($ar_temp[1]); |
} |
$this->sys->setDistributionIcon('ReactOS.png'); |
} elseif (preg_match("/^(Microsoft [^\[]*)\s*\[\D*\s*(.+)\]/", $this->_ver, $ar_temp)) { |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProductName", $strBuf, false) && (strlen($strBuf) > 0)) { |
} elseif (preg_match("/^(Microsoft [^\[]*)\s*\[\D*\s*([\.\d]+)\]/", $this->_ver, $ar_temp)) { |
$ver = $ar_temp[2]; |
$kernel = $ver; |
if (($this->_reg === false) && self::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProductName", $strBuf, false, false, true) && (strlen($strBuf) > 0)) { // only if reg query via cmd |
if (self::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows NT\\CurrentVersion\\ProductName", $tmpBuf, false)) { |
$kernel .= ' (64-bit)'; |
} |
if (preg_match("/^Microsoft /", $strBuf)) { |
$this->sys->setDistribution($strBuf); |
$distribution = $strBuf; |
} else { |
$this->sys->setDistribution("Microsoft ".$strBuf); |
$distribution = "Microsoft ".$strBuf; |
} |
} elseif (self::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProductName", $strBuf, false) && (strlen($strBuf) > 0)) { |
if (preg_match("/^Microsoft /", $strBuf)) { |
$distribution = $strBuf; |
} else { |
$this->sys->setDistribution($ar_temp[1]); |
$distribution = "Microsoft ".$strBuf; |
} |
$kernel = $ar_temp[2]; |
} else { |
$distribution = $ar_temp[1]; |
} |
$this->sys->setKernel($kernel); |
if ((($kernel[1] == '.') && ($kernel[0] <5)) || (substr($kernel, 0, 4) == '5.0.')) |
if (version_compare($ver, "10.0", ">=") && !preg_match('/server/i', $this->sys->getDistribution()) && ($list = @parse_ini_file(PSI_APP_ROOT."/data/osnames.ini", true))) { |
if (version_compare($ver, "10.0.21996", ">=") && version_compare($ver, "11.0", "<")) { |
$distribution = preg_replace("/Windows 10/", "Windows 11", $distribution); // fix Windows 11 detection |
} |
$karray = preg_split('/\./', $ver); |
if (isset($karray[2]) && isset($list['win10'][$karray[2]])) { |
$distribution .= ' ('.$list['win10'][$karray[2]].')'; |
} |
} |
$this->sys->setDistribution($distribution); |
if (version_compare($ver, "5.1", "<")) |
$icon = 'Win2000.png'; |
elseif ((substr($kernel, 0, 4) == '6.0.') || (substr($kernel, 0, 4) == '6.1.')) |
elseif (version_compare($ver, "5.1", ">=") && version_compare($ver, "6.0", "<")) |
$icon = 'WinXP.png'; |
elseif (version_compare($ver, "6.0", ">=") && version_compare($ver, "6.2", "<")) |
$icon = 'WinVista.png'; |
elseif ((substr($kernel, 0, 4) == '6.2.') || (substr($kernel, 0, 4) == '6.3.') || (substr($kernel, 0, 4) == '6.4.') || (substr($kernel, 0, 5) == '10.0.')) |
elseif (version_compare($ver, "6.2", ">=") && version_compare($ver, "10.0.21996", "<")) |
$icon = 'Win8.png'; |
else |
$icon = 'WinXP.png'; |
$icon = 'Win11.png'; |
$this->sys->setDistributionIcon($icon); |
} else { |
$this->sys->setDistribution("WINNT"); |
624,24 → 1140,27 |
private function _cpuinfo() |
{ |
$allCpus = $this->_get_Win32_Processor(); |
if (!$allCpus) { |
if (empty($allCpus)) { |
$hkey = "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor"; |
if (CommonFunctions::enumKey($this->_reg, $hkey, $arrBuf, false)) { |
if (self::enumKey($this->_reg, $hkey, $arrBuf, false)) { |
foreach ($arrBuf as $coreCount) { |
if (CommonFunctions::readReg($this->_reg, $hkey."\\".$coreCount."\\ProcessorNameString", $strBuf, false)) { |
if (self::readReg($this->_reg, $hkey."\\".$coreCount."\\ProcessorNameString", $strBuf, false)) { |
$allCpus[$coreCount]['Name'] = $strBuf; |
} |
if (CommonFunctions::readReg($this->_reg, $hkey."\\".$coreCount."\\~MHz", $strBuf, false)) { |
if (self::readReg($this->_reg, $hkey."\\".$coreCount."\\~MHz", $strBuf, false)) { |
if (preg_match("/^0x([0-9a-f]+)$/i", $strBuf, $hexvalue)) { |
$allCpus[$coreCount]['CurrentClockSpeed'] = hexdec($hexvalue[1]); |
} |
} |
if (CommonFunctions::readReg($this->_reg, $hkey."\\".$coreCount."\\VendorIdentifier", $strBuf, false)) { |
if (self::readReg($this->_reg, $hkey."\\".$coreCount."\\VendorIdentifier", $strBuf, false)) { |
$allCpus[$coreCount]['Manufacturer'] = $strBuf; |
} |
if (self::readReg($this->_reg, $hkey."\\".$coreCount."\\Identifier", $strBuf, false)) { |
$allCpus[$coreCount]['Caption'] = $strBuf; |
} |
} |
} |
} |
|
$globalcpus = 0; |
foreach ($allCpus as $oneCpu) { |
654,6 → 1173,7 |
$globalcpus+=$cpuCount; |
} |
|
$cpulist = null; |
foreach ($allCpus as $oneCpu) { |
$cpuCount = 1; |
if (isset($oneCpu['NumberOfLogicalProcessors'])) { |
666,15 → 1186,62 |
if (isset($oneCpu['Name'])) $cpu->setModel($oneCpu['Name']); |
if (isset($oneCpu['L3CacheSize']) && ($oneCpu['L3CacheSize'] > 0)) { |
$cpu->setCache($oneCpu['L3CacheSize'] * 1024); |
} elseif (isset($oneCpu['L2CacheSize'])) { |
} elseif (isset($oneCpu['L2CacheSize']) && ($oneCpu['L2CacheSize'] > 0)) { |
$cpu->setCache($oneCpu['L2CacheSize'] * 1024); |
} |
if (isset($oneCpu['CurrentClockSpeed'])) { |
if (isset($oneCpu['CurrentVoltage']) && ($oneCpu['CurrentVoltage'] > 0)) { |
$cpu->setVoltage($oneCpu['CurrentVoltage']/10); |
} |
if (isset($oneCpu['CurrentClockSpeed']) && ($oneCpu['CurrentClockSpeed'] > 0)) { |
$cpu->setCpuSpeed($oneCpu['CurrentClockSpeed']); |
if (isset($oneCpu['MaxClockSpeed']) && ($oneCpu['CurrentClockSpeed'] < $oneCpu['MaxClockSpeed'])) $cpu->setCpuSpeedMax($oneCpu['MaxClockSpeed']); |
if (isset($oneCpu['MaxClockSpeed']) && ($oneCpu['CurrentClockSpeed'] <= $oneCpu['MaxClockSpeed'])) $cpu->setCpuSpeedMax($oneCpu['MaxClockSpeed']); |
} |
if (isset($oneCpu['ExtClock'])) $cpu->setBusSpeed($oneCpu['ExtClock']); |
if (isset($oneCpu['Manufacturer'])) $cpu->setVendorId($oneCpu['Manufacturer']); |
if (isset($oneCpu['ExtClock']) && ($oneCpu['ExtClock'] > 0)) { |
$cpu->setBusSpeed($oneCpu['ExtClock']); |
} |
if (isset($oneCpu['Manufacturer'])) { |
$cpumanufacturer = $oneCpu['Manufacturer']; |
$cpu->setVendorId($cpumanufacturer); |
if ($cpumanufacturer === "QEMU") { |
if (isset($oneCpu['Caption'])) { |
$impl = ''; |
if (preg_match('/^ARMv8 \(64-bit\) Family 8 Model ([0-9a-fA-F]+) Revision[ ]+([0-9a-fA-F]+)$/', $oneCpu['Caption'], $partvar)) { |
switch (strtolower($partvar[1])) { |
case '51': |
$impl = '0x0'; break; // Qemu |
case 'd03': |
case 'd07': |
case 'd08': |
$impl = '0x41'; break; // ARM Limited |
case '1': |
$impl = '0x46'; // Fujitsu Ltd. |
} |
} elseif (preg_match('/^ARM Family 7 Model ([0-9a-fA-F]+) Revision[ ]+([0-9a-fA-F]+)$/', $oneCpu['Caption'], $partvar)) { |
switch (strtolower($partvar[1])) { |
case 'c07': |
case 'c0f': |
$impl = '0x41'; // ARM Limited |
} |
} |
if ($impl !== '') { |
if ($cpulist === null) $cpulist = @parse_ini_file(PSI_APP_ROOT."/data/cpus.ini", true); |
if ($cpulist) { |
if ((isset($cpulist['cpu'][$cpufromlist = strtolower($impl.',0x'.$partvar[1].',0x'.$partvar[2])])) |
|| isset($cpulist['cpu'][$cpufromlist = strtolower($impl.',0x'.$partvar[1])])) { |
if (($cpumodel = $cpu->getModel()) !== '') { |
$cpu->setModel($cpumodel.' - '.$cpulist['cpu'][$cpufromlist]); |
} else { |
$cpu->setModel($cpulist['cpu'][$cpufromlist]); |
} |
} |
} |
} |
} |
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) { |
$this->sys->setVirtualizer("cpuid:QEMU", false); |
} |
} |
} |
if (PSI_LOAD_BAR) { |
if (($cpubuffer = $this->_get_Win32_PerfFormattedData_PerfOS_Processor()) && (count($cpubuffer) == ($globalcpus+1)) && isset($cpubuffer['cpu'.$i])) { |
$cpu->setLoad($cpubuffer['cpu'.$i]); |
695,33 → 1262,43 |
private function _machine() |
{ |
$buffer = $this->_get_Win32_ComputerSystem(); |
$bufferp = CommonFunctions::getWMI($this->_wmi, 'Win32_BaseBoard', array('Product')); |
$bufferb = CommonFunctions::getWMI($this->_wmi, 'Win32_BIOS', array('SMBIOSBIOSVersion', 'ReleaseDate')); |
$bufferp = self::getWMI(self::$_wmi, 'Win32_BaseBoard', array('Product')); |
$bufferb = self::getWMI(self::$_wmi, 'Win32_BIOS', array('SMBIOSBIOSVersion', 'ReleaseDate')); |
|
if (!$buffer) { |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\systemManufacturer", $strBuf, false)) { |
if (self::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\systemManufacturer", $strBuf, false)) { |
$buffer[0]['Manufacturer'] = $strBuf; |
} |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\SystemProductName", $strBuf, false)) { |
if (self::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\SystemProductName", $strBuf, false)) { |
$buffer[0]['Model'] = $strBuf; |
} |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\SystemFamily", $strBuf, false)) { |
if (self::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\SystemFamily", $strBuf, false)) { |
$buffer[0]['SystemFamily'] = $strBuf; |
} |
} |
if (!$bufferp) { |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\BaseBoardProduct", $strBuf, false)) { |
if (self::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\BaseBoardProduct", $strBuf, false)) { |
$bufferp[0]['Product'] = $strBuf; |
} |
} |
if (!$bufferb) { |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\BIOSVersion", $strBuf, false)) { |
if (self::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\BIOSVersion", $strBuf, false)) { |
$bufferb[0]['SMBIOSBIOSVersion'] = $strBuf; |
} |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\BIOSReleaseDate", $strBuf, false)) { |
if (self::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\BIOSReleaseDate", $strBuf, false)) { |
$bufferb[0]['ReleaseDate'] = $strBuf; |
} |
} |
|
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) { |
if (isset($buffer[0]['Manufacturer'])) { |
$this->_Manufacturer = $buffer[0]['Manufacturer']; |
} |
if (isset($buffer[0]['Model'])) { |
$this->_Model = $buffer[0]['Model']; |
} |
} |
|
$buf = ""; |
$model = ""; |
if ($buffer && isset($buffer[0])) { |
832,25 → 1409,25 |
*/ |
private function _network() |
{ |
if ($this->_wmi) { |
if (self::$_wmi) { |
$buffer = $this->_get_Win32_OperatingSystem(); |
if ($buffer && isset($buffer[0]) && isset($buffer[0]['Version']) && version_compare($buffer[0]['Version'], "6.2", ">=")) { // minimal windows 2012 or windows 8 |
$allDevices = CommonFunctions::getWMI($this->_wmi, 'Win32_PerfRawData_Tcpip_NetworkAdapter', array('Name', 'BytesSentPersec', 'BytesTotalPersec', 'BytesReceivedPersec', 'PacketsReceivedErrors', 'PacketsReceivedDiscarded', 'CurrentBandwidth')); |
$allDevices = self::getWMI(self::$_wmi, 'Win32_PerfRawData_Tcpip_NetworkAdapter', array('Name', 'BytesSentPersec', 'BytesTotalPersec', 'BytesReceivedPersec', 'PacketsReceivedErrors', 'PacketsReceivedDiscarded', 'CurrentBandwidth')); |
} else { |
$allDevices = CommonFunctions::getWMI($this->_wmi, 'Win32_PerfRawData_Tcpip_NetworkInterface', array('Name', 'BytesSentPersec', 'BytesTotalPersec', 'BytesReceivedPersec', 'PacketsReceivedErrors', 'PacketsReceivedDiscarded', 'CurrentBandwidth')); |
$allDevices = self::getWMI(self::$_wmi, 'Win32_PerfRawData_Tcpip_NetworkInterface', array('Name', 'BytesSentPersec', 'BytesTotalPersec', 'BytesReceivedPersec', 'PacketsReceivedErrors', 'PacketsReceivedDiscarded', 'CurrentBandwidth')); |
} |
if ($allDevices) { |
$aliases = array(); |
$hkey = "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}"; |
if (CommonFunctions::enumKey($this->_reg, $hkey, $arrBuf, false)) { |
if (self::enumKey($this->_reg, $hkey, $arrBuf, false)) { |
foreach ($arrBuf as $netID) { |
if (CommonFunctions::readReg($this->_reg, $hkey."\\".$netID."\\Connection\\PnPInstanceId", $strInstanceID, false)) { |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\".$strInstanceID."\\FriendlyName", $strName, false)) { |
if (self::readReg($this->_reg, $hkey."\\".$netID."\\Connection\\PnPInstanceId", $strInstanceID, false)) { |
if (self::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\".$strInstanceID."\\FriendlyName", $strName, false)) { |
$cname = str_replace(array('(', ')', '#', '/'), array('[', ']', '_', '_'), $strName); //convert to canonical |
if (!isset($aliases[$cname])) { // duplicate checking |
$aliases[$cname]['id'] = $netID; |
$aliases[$cname]['name'] = $strName; |
if (CommonFunctions::readReg($this->_reg, $hkey."\\".$netID."\\Connection\\Name", $strCName, false) |
if (self::readReg($this->_reg, $hkey."\\".$netID."\\Connection\\Name", $strCName, false) |
&& (str_replace(array('(', ')', '#', '/'), array('[', ']', '_', '_'), $strCName) !== $cname)) { |
$aliases[$cname]['netname'] = $strCName; |
} |
864,10 → 1441,10 |
|
$aliases2 = array(); |
$hkey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards"; |
if (CommonFunctions::enumKey($this->_reg, $hkey, $arrBuf, false)) { |
if (self::enumKey($this->_reg, $hkey, $arrBuf, false)) { |
foreach ($arrBuf as $netCount) { |
if (CommonFunctions::readReg($this->_reg, $hkey."\\".$netCount."\\Description", $strName, false) |
&& CommonFunctions::readReg($this->_reg, $hkey."\\".$netCount."\\ServiceName", $strGUID, false)) { |
if (self::readReg($this->_reg, $hkey."\\".$netCount."\\Description", $strName, false) |
&& self::readReg($this->_reg, $hkey."\\".$netCount."\\ServiceName", $strGUID, false)) { |
$cname = str_replace(array('(', ')', '#', '/'), array('[', ']', '_', '_'), $strName); //convert to canonical |
if (!isset($aliases2[$cname])) { // duplicate checking |
$aliases2[$cname]['id'] = $strGUID; |
879,7 → 1456,7 |
} |
} |
|
$allNetworkAdapterConfigurations = CommonFunctions::getWMI($this->_wmi, 'Win32_NetworkAdapterConfiguration', array('SettingID', /*'Description',*/ 'MACAddress', 'IPAddress')); |
$allNetworkAdapterConfigurations = self::getWMI(self::$_wmi, 'Win32_NetworkAdapterConfiguration', array('SettingID', /*'Description',*/ 'MACAddress', 'IPAddress')); |
foreach ($allDevices as $device) if (!preg_match('/^WAN Miniport \[/', $device['Name'])) { |
$dev = new NetDevice(); |
$name = $device['Name']; |
903,11 → 1480,11 |
elseif (preg_match('/\s-\s([^-]*)$/', $mininame, $ar_name)) |
$name=substr($mininame, 0, strlen($mininame)-strlen($ar_name[0])); |
$dev->setName($mininame); |
if (trim($NetworkAdapterConfiguration['MACAddress']) !== "") $macexist = true; |
if (isset($NetworkAdapterConfiguration['MACAddress']) && trim($NetworkAdapterConfiguration['MACAddress']) !== "") $macexist = true; |
if (defined('PSI_SHOW_NETWORK_INFOS') && PSI_SHOW_NETWORK_INFOS) { |
if (isset($ali[$name]['netname'])) $dev->setInfo(str_replace(';', ':', $ali[$name]['netname'])); |
if ((!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) |
&& (trim($NetworkAdapterConfiguration['MACAddress']) !== "")) $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').str_replace(':', '-', strtoupper($NetworkAdapterConfiguration['MACAddress']))); |
&& $macexist) $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').str_replace(':', '-', strtoupper(trim($NetworkAdapterConfiguration['MACAddress'])))); |
if (isset($NetworkAdapterConfiguration['IPAddress'])) |
foreach ($NetworkAdapterConfiguration['IPAddress'] as $ipaddres) |
if (($ipaddres != "0.0.0.0") && ($ipaddres != "::") && !preg_match('/^fe80::/i', $ipaddres)) |
1005,7 → 1582,7 |
*/ |
private function _memory() |
{ |
if ($this->_wmi) { |
if (self::$_wmi) { |
$buffer = $this->_get_Win32_OperatingSystem(); |
if ($buffer) { |
$this->sys->setMemTotal($buffer[0]['TotalVisibleMemorySize'] * 1024); |
1012,7 → 1589,7 |
$this->sys->setMemFree($buffer[0]['FreePhysicalMemory'] * 1024); |
$this->sys->setMemUsed($this->sys->getMemTotal() - $this->sys->getMemFree()); |
} |
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_PageFileUsage'); |
$buffer = self::getWMI(self::$_wmi, 'Win32_PageFileUsage'); |
foreach ($buffer as $swapdevice) { |
$dev = new DiskDevice(); |
$dev->setName("SWAP"); |
1040,11 → 1617,13 |
{ |
$typearray = array('Unknown', 'No Root Directory', 'Removable Disk', 'Local Disk', 'Network Drive', 'Compact Disc', 'RAM Disk'); |
$floppyarray = array('Unknown', '5 1/4 in.', '3 1/2 in.', '3 1/2 in.', '3 1/2 in.', '3 1/2 in.', '5 1/4 in.', '5 1/4 in.', '5 1/4 in.', '5 1/4 in.', '5 1/4 in.', 'Other', 'HD', '3 1/2 in.', '3 1/2 in.', '5 1/4 in.', '5 1/4 in.', '3 1/2 in.', '3 1/2 in.', '5 1/4 in.', '3 1/2 in.', '3 1/2 in.', '8 in.'); |
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_LogicalDisk', array('Name', 'Size', 'FreeSpace', 'FileSystem', 'DriveType', 'MediaType')); |
$buffer = self::getWMI(self::$_wmi, 'Win32_LogicalDisk', array('Name', 'Size', 'FreeSpace', 'FileSystem', 'DriveType', 'MediaType')); |
foreach ($buffer as $filesystem) { |
$dev = new DiskDevice(); |
$dev->setMountPoint($filesystem['Name']); |
if (isset($filesystem['FileSystem'])) { |
$dev->setFsType($filesystem['FileSystem']); |
} |
if ($filesystem['Size'] > 0) { |
$dev->setTotal($filesystem['Size']); |
$dev->setFree($filesystem['FreeSpace']); |
1057,10 → 1636,19 |
} |
$this->sys->setDiskDevices($dev); |
} |
if (!$buffer && ($this->sys->getDistribution()=="ReactOS")) { |
// test for command 'free' on current disk |
if (CommonFunctions::executeProgram('cmd', '/c free 2>nul', $out_value, true)) { |
for ($letter='A'; $letter!='AA'; $letter++) if (CommonFunctions::executeProgram('cmd', '/c free '.$letter.': 2>nul', $out_value, false)) { |
if (!$buffer && !defined('PSI_EMU_HOSTNAME')) { |
$letters = array(); |
if (CommonFunctions::executeProgram('fsutil', 'fsinfo drives 2>nul', $out_value, false) && ($out_value !== '') && preg_match('/^Drives:\s*(.+)$/i', $out_value, $disks)) { |
$diskarr = preg_split('/ /', $disks[1], -1, PREG_SPLIT_NO_EMPTY); |
foreach ($diskarr as $disk) if (preg_match('/^(\w):\\\\$/', $disk, $diskletter)) { |
$letters[] = $diskletter[1]; |
} |
} |
if (count($letters) == 0) for ($letter='A'; $letter!='AA'; $letter++) { |
$letters[] = $letter; |
} |
if ((substr($this->sys->getDistribution(), 0, 7)=="ReactOS") && CommonFunctions::executeProgram('cmd', '/c free 2>nul', $out_value, false)) { |
foreach ($letters as $letter) if (CommonFunctions::executeProgram('cmd', '/c free '.$letter.': 2>nul', $out_value, false)) { |
$values = preg_replace('/[^\d\n]/', '', $out_value); |
if (preg_match('/\n(\d+)\n(\d+)\n(\d+)$/', $values, $out_dig)) { |
$size = $out_dig[1]; |
1069,7 → 1657,11 |
if ($used + $free == $size) { |
$dev = new DiskDevice(); |
$dev->setMountPoint($letter.":"); |
if (CommonFunctions::executeProgram('fsutil', 'fsinfo volumeinfo '.$letter.':\ 2>nul', $out_value, false) && ($out_value !== '') && preg_match('/\nFile System Name\s*:\s*(\S+)/im', $out_value, $fsname)) { |
$dev->setFsType($fsname[1]); |
} else { |
$dev->setFsType('Unknown'); |
} |
$dev->setName('Unknown'); |
$dev->setTotal($size); |
$dev->setUsed($used); |
1078,9 → 1670,33 |
} |
} |
} |
} else { |
if (substr($this->sys->getDistribution(), 0, 7)=="ReactOS") { |
$disksep = ':\\'; |
} else { |
$disksep = ':'; |
} |
foreach ($letters as $letter) { |
$size = disk_total_space($letter.':\\'); |
$free = disk_free_space($letter.':\\'); |
if (($size !== false) && ($free !== false) && ($size >= 0) && ($free >= 0) && ($size >= $free)) { |
$dev = new DiskDevice(); |
$dev->setMountPoint($letter.":"); |
if (CommonFunctions::executeProgram('fsutil', 'fsinfo volumeinfo '.$letter.$disksep.' 2>nul', $out_value, false) && ($out_value !== '') && preg_match('/\nFile System Name\s*:\s*(\S+)/im', $out_value, $fsname)) { |
$dev->setFsType($fsname[1]); |
} else { |
$dev->setFsType('Unknown'); |
} |
$dev->setName('Unknown'); |
$dev->setTotal($size); |
$dev->setUsed($size - $free); |
$dev->setFree($free); |
$this->sys->setDiskDevices($dev); |
} |
} |
} |
} |
} |
|
/** |
* get os specific encoding |
1114,7 → 1730,7 |
$processes['*'] = (count($lines)-1) - 3 ; //correction for process "qprocess *" |
} |
if ($processes['*'] <= 0) { |
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_Process', array('Caption')); |
$buffer = self::getWMI(self::$_wmi, 'Win32_Process', array('Caption')); |
$processes['*'] = count($buffer); |
} |
$processes[' '] = $processes['*']; |
1128,11 → 1744,11 |
*/ |
private function _meminfo() |
{ |
$allMems = CommonFunctions::getWMI($this->_wmi, 'Win32_PhysicalMemory', array('PartNumber', 'DeviceLocator', 'Capacity', 'Manufacturer', 'SerialNumber', 'Speed', 'ConfiguredClockSpeed', 'ConfiguredVoltage', 'MemoryType', 'SMBIOSMemoryType', 'FormFactor', 'DataWidth', 'TotalWidth', 'BankLabel', 'MinVoltage', 'MaxVoltage')); |
$allMems = self::_get_Win32_PhysicalMemory(); |
if ($allMems) { |
$reg = false; |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) { |
$arrMems = CommonFunctions::getWMI($this->_wmi, 'Win32_PhysicalMemoryArray', array('MemoryErrorCorrection')); |
$arrMems = self::getWMI(self::$_wmi, 'Win32_PhysicalMemoryArray', array('MemoryErrorCorrection')); |
$reg = (count($arrMems) == 1) && isset($arrMems[0]['MemoryErrorCorrection']) && ($arrMems[0]['MemoryErrorCorrection'] == 6); |
} |
foreach ($allMems as $mem) { |
1195,7 → 1811,7 |
case 22: $memtype = 'DDR2 FB-DIMM'; break; |
case 24: $memtype = 'DDR3'; break; |
case 25: $memtype = 'FBD2'; break; |
case 26: $memtype = 'DDR4'; break; |
case 26: $memtype = 'DDR4'; |
} |
} elseif (isset($mem['SMBIOSMemoryType'])) { |
switch ($mem['SMBIOSMemoryType']) { |
1231,7 → 1847,7 |
case 32: $memtype = 'Logical non-volatile device'; break; |
case 33: $memtype = 'HBM2'; break; |
case 34: $memtype = 'DDR5'; break; |
case 35: $memtype = 'LPDDR5'; break; |
case 35: $memtype = 'LPDDR5'; |
} |
} |
if (isset($mem['Speed']) && (($speed = $mem['Speed']) > 0) && (preg_match('/^(DDR\d*)(.*)/', $memtype, $dr) || preg_match('/^(SDR)AM(.*)/', $memtype, $dr))) { |
1271,7 → 1887,7 |
case 20: $memtype .= ' PLCC'; break; |
case 21: $memtype .= ' BGA'; break; |
case 22: $memtype .= ' FPBGA'; break; |
case 23: $memtype .= ' LGA'; break; |
case 23: $memtype .= ' LGA'; |
} |
} |
if (isset($mem['DataWidth']) && isset($mem['TotalWidth']) && (($dataw = $mem['DataWidth']) > 0) && (($totalw = $mem['TotalWidth']) > 0) && ($dataw < $totalw)) { |
1304,13 → 1920,13 |
* |
* @see PSI_Interface_OS::build() |
* |
* @return Void |
* @return void |
*/ |
public function build() |
{ |
$this->_distro(); //share getDistribution() |
if ($this->sys->getDistribution()=="ReactOS") { |
$this->error->addError("WARN", "The ReactOS version of phpSysInfo is a work in progress, some things currently don't work"); |
if (substr($this->sys->getDistribution(), 0, 7)=="ReactOS") { |
$this->error->addWarning("The ReactOS version of phpSysInfo is a work in progress, some things currently don't work"); |
} |
if (!$this->blockname || $this->blockname==='vitals') { |
$this->_hostname(); |
1319,20 → 1935,21 |
$this->_loadavg(); |
$this->_processes(); |
} |
if (!$this->blockname || $this->blockname==='network') { |
$this->_network(); |
} |
if (!$this->blockname || $this->blockname==='hardware') { |
$this->_machine(); |
$this->_cpuinfo(); |
$this->_virtualizer(); |
$this->_meminfo(); |
$this->_hardware(); |
} |
if (!$this->blockname || $this->blockname==='memory') { |
$this->_memory(); |
} |
if (!$this->blockname || $this->blockname==='filesystem') { |
$this->_filesystems(); |
} |
if (!$this->blockname || $this->blockname==='memory') { |
$this->_memory(); |
if (!$this->blockname || $this->blockname==='network') { |
$this->_network(); |
} |
} |
} |