Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 2976 → Rev 3037

/web/acc/phpsysinfo/includes/class.CommonFunctions.inc.php
26,48 → 26,12
class CommonFunctions
{
/**
* holds codepage for chcp
* holds dmi memory data
*
* @var integer
* @var array
*/
private static $_cp = null;
private static $_dmimd = null;
 
/**
* value of checking run as administrator
*
* @var boolean
*/
private static $_asadmin = null;
 
public static function setcp($cp)
{
self::$_cp = $cp;
}
 
public static function getcp()
{
return self::$_cp;
}
 
public static function isAdmin()
{
if (self::$_asadmin == null) {
if (PSI_OS == 'WINNT') {
$strBuf = '';
self::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;
}
 
private static function _parse_log_file($string)
{
if (defined('PSI_LOG') && is_string(PSI_LOG) && (strlen(PSI_LOG)>0) && ((substr(PSI_LOG, 0, 1)=="-") || (substr(PSI_LOG, 0, 1)=="+"))) {
177,7 → 141,7
continue;
}
$strProgrammpath = $strPathS.$strProgram;
if (is_executable($strProgrammpath) || ((PSI_OS == 'WINNT') && (strtolower($path_parts['extension']) == 'py'))) {
if (is_executable($strProgrammpath) || ((PSI_OS == 'WINNT') && (strtolower($path_parts['extension']) == 'py') && is_file($strProgrammpath))) {
return $strProgrammpath;
}
}
195,7 → 159,7
* @param string $strArgs arguments to the program
* @param string &$strBuffer output of the command
* @param boolean $booErrorRep en- or disables the reporting of errors which should be logged
* @param integer $timeout timeout value in seconds (default value is PSI_EXEC_TIMEOUT_INT)
* @param int $timeout timeout value in seconds (default value is PSI_EXEC_TIMEOUT_INT)
*
* @return boolean command successfull or not
*/
216,6 → 180,11
}
}
 
if (PSI_ROOT_FILESYSTEM !== '') { // disabled if ROOTFS defined
 
return false;
}
 
if ((PSI_OS != 'WINNT') && preg_match('/^([^=]+=[^ \t]+)[ \t]+(.*)$/', $strProgramname, $strmatch)) {
$strSet = $strmatch[1].' ';
$strProgramname = $strmatch[2];
281,7 → 250,7
$strError = '';
$pipes = array();
$descriptorspec = array(0=>array("pipe", "r"), 1=>array("pipe", "w"), 2=>array("pipe", "w"));
if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN === true) {
if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN) {
if (PSI_OS == 'WINNT') {
$process = $pipes[1] = popen($strSet.$strProgram.$strArgs." 2>nul", "r");
} else {
292,7 → 261,7
}
if (is_resource($process)) {
$te = self::_timeoutfgets($pipes, $strBuffer, $strError, $timeout);
if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN === true) {
if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN) {
$return_value = pclose($pipes[1]);
} else {
fclose($pipes[0]);
382,8 → 351,8
*
* @param string $strFileName name of the file which should be read
* @param string &$strRet content of the file (reference)
* @param integer $intLines control how many lines should be read
* @param integer $intBytes control how many bytes of each line should be read
* @param int $intLines control how many lines should be read
* @param int $intBytes control how many bytes of each line should be read
* @param boolean $booErrorRep en- or disables the reporting of errors which should be logged
*
* @return boolean command successfull or not
405,12 → 374,18
}
}
 
if (PSI_ROOT_FILESYSTEM !== '') {
$rfsinfo = "[".PSI_ROOT_FILESYSTEM."]";
} else {
$rfsinfo = '';
}
 
$strFile = "";
$intCurLine = 1;
$error = PSI_Error::singleton();
if (file_exists($strFileName)) {
if (is_readable($strFileName)) {
if ($fd = fopen($strFileName, 'r')) {
if (file_exists(PSI_ROOT_FILESYSTEM.$strFileName)) {
if (is_readable(PSI_ROOT_FILESYSTEM.$strFileName)) {
if ($fd = fopen(PSI_ROOT_FILESYSTEM.$strFileName, 'r')) {
while (!feof($fd)) {
$strFile .= fgets($fd, $intBytes);
if ($intLines <= $intCurLine && $intLines != 0) {
430,7 → 405,7
}
} else {
if ($booErrorRep) {
$error->addError('fopen('.$strFileName.')', 'file can not read by phpsysinfo');
$error->addError('fopen('.$rfsinfo.$strFileName.')', 'file can not read by phpsysinfo');
}
 
return false;
437,7 → 412,7
}
} else {
if ($booErrorRep) {
$error->addError('fopen('.$strFileName.')', 'file permission error');
$error->addError('fopen('.$rfsinfo.$strFileName.')', 'file permission error');
}
 
return false;
444,7 → 419,7
}
} else {
if ($booErrorRep) {
$error->addError('file_exists('.$strFileName.')', 'the file does not exist on your machine');
$error->addError('file_exists('.$rfsinfo.$strFileName.')', 'the file does not exist on your machine');
}
 
return false;
454,6 → 429,72
}
 
/**
* read a data file and return the content as a string
*
* @param string $strDataFileName name of the data file which should be read
* @param string &$strRet content of the data file (reference)
*
* @return boolean command successfull or not
*/
public static function rftsdata($strDataFileName, &$strRet)
{
$strFile = "";
$strFileName = PSI_APP_ROOT."/data/".$strDataFileName;
$error = PSI_Error::singleton();
if (file_exists($strFileName)) {
if (is_readable($strFileName)) {
if ($fd = fopen($strFileName, 'r')) {
while (!feof($fd)) {
$strFile .= fgets($fd, 4096);
}
fclose($fd);
$strRet = $strFile;
} else {
$error->addError('fopen('.$strFileName.')', 'file can not read by phpsysinfo');
 
return false;
}
} else {
$error->addError('fopen('.$strFileName.')', 'file permission error');
 
return false;
}
} else {
$error->addError('file_exists('.$strFileName.')', 'the file does not exist on your machine');
 
return false;
}
 
return true;
}
 
/**
* Find pathnames matching a pattern
*
* @param string $pattern the pattern. No tilde expansion or parameter substitution is done.
* @param int $flags
*
* @return an array containing the matched files/directories, an empty array if no file matched or false on error
*/
public static function findglob($pattern, $flags = 0)
{
$outarr = glob(PSI_ROOT_FILESYSTEM.$pattern, $flags);
if (PSI_ROOT_FILESYSTEM == '') {
return $outarr;
} elseif ($outarr === false) {
return false;
} else {
$len = strlen(PSI_ROOT_FILESYSTEM);
$newoutarr = array();
foreach ($outarr as $out) {
$newoutarr[] = substr($out, $len); // path without ROOTFS
}
 
return $newoutarr;
}
}
 
/**
* file exists
*
* @param string $strFileName name of the file which should be check
475,7 → 516,7
}
}
 
$exists = file_exists($strFileName);
$exists = file_exists(PSI_ROOT_FILESYSTEM.$strFileName);
if (defined('PSI_LOG') && is_string(PSI_LOG) && (strlen(PSI_LOG)>0) && (substr(PSI_LOG, 0, 1)!="-") && (substr(PSI_LOG, 0, 1)!="+")) {
if ((substr($strFileName, 0, 5) === "/dev/") && $exists) {
error_log("---".gmdate('r T')."--- Reading: ".$strFileName."\ndevice exists\n", 3, PSI_LOG);
534,7 → 575,7
*/
public static function checkForExtensions($arrExt = array())
{
if (defined('PSI_SYSTEM_CODEPAGE') && ((strcasecmp(PSI_SYSTEM_CODEPAGE, "UTF-8") == 0) || (strcasecmp(PSI_SYSTEM_CODEPAGE, "CP437") == 0)))
if (defined('PSI_SYSTEM_CODEPAGE') && (PSI_SYSTEM_CODEPAGE !== null) && ((strcasecmp(PSI_SYSTEM_CODEPAGE, "UTF-8") == 0) || (strcasecmp(PSI_SYSTEM_CODEPAGE, "CP437") == 0)))
$arrReq = array('simplexml', 'pcre', 'xml', 'dom');
elseif (PSI_OS == 'WINNT')
$arrReq = array('simplexml', 'pcre', 'xml', 'dom', 'mbstring', 'com_dotnet');
556,7 → 597,7
$text .= " </Error>\n";
$text .= "</phpsysinfo>";
if ($error) {
header("Content-Type: text/xml\n\n");
header('Content-Type: text/xml');
echo $text;
die();
}
565,10 → 606,10
/**
* get the content of stdout/stderr with the option to set a timeout for reading
*
* @param array $pipes array of file pointers for stdin, stdout, stderr (proc_open())
* @param string &$out target string for the output message (reference)
* @param string &$err target string for the error message (reference)
* @param integer $timeout timeout value in seconds
* @param array $pipes array of file pointers for stdin, stdout, stderr (proc_open())
* @param string &$out target string for the output message (reference)
* @param string &$err target string for the error message (reference)
* @param int $timeout timeout value in seconds
*
* @return boolean timeout expired or not
*/
578,7 → 619,7
$e = null;
$te = false;
 
if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN === true) {
if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN) {
$pipe2 = false;
} else {
$pipe2 = true;
614,96 → 655,6
}
 
/**
* 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) {
$error = PSI_Error::singleton();
$error->addError("getWMI()", preg_replace('/<br\/>/', "\n", preg_replace('/<b>|<\/b>/', '', $e->getMessage())));
}
}
} elseif ((gettype($wmi) === "string") && (PSI_OS == 'Linux')) {
$delimeter = '@@@DELIM@@@';
if (self::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;
}
 
/**
* get all configured plugins from phpsysinfo.ini (file must be included and processed before calling this function)
*
* @return array
732,177 → 683,94
}
 
/**
* readReg function
* get virtualizer from dmi data
*
* @return boolean command successfull or not
* @return string|null
*/
public static function readReg($reg, $strName, &$strBuffer, $booErrorRep = true)
public static function decodevirtualizer($vendor_data)
{
$arrBuffer = array();
$_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);
 
if ($reg === false) {
if (defined('PSI_EMU_HOSTNAME')) {
return false;
}
$last = strrpos($strName, "\\");
$keyname = substr($strName, $last + 1);
if (self::$_cp) {
if (self::executeProgram('cmd', '/c chcp '.self::$_cp.' >nul & reg query "'.substr($strName, 0, $last).'" /v '.$keyname.' 2>&1', $strBuf, $booErrorRep) && (strlen($strBuf) > 0) && preg_match("/^\s*".$keyname."\s+REG_\S+\s+(.+)\s*$/mi", $strBuf, $buffer2)) {
$strBuffer = $buffer2[1];
} else {
return false;
}
} else {
if (self::executeProgram('reg', 'query "'.substr($strName, 0, $last).'" /v '.$keyname.' 2>&1', $strBuf, $booErrorRep) && (strlen($strBuf) > 0) && preg_match("/^\s*".$keyname."\s+REG_\S+\s+(.+)\s*$/mi", $strBuf, $buffer2)) {
$strBuffer = $buffer2[1];
} else {
return false;
}
}
} elseif (gettype($reg) === "object") {
$first = strpos($strName, "\\");
$last = strrpos($strName, "\\");
$hkey = substr($strName, 0, $first);
if (isset($_hkey[$hkey])) {
$sub_keys = new VARIANT();
try {
$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())));
if (gettype($vendor_data) === "array") {
$vendarray = array(
'KVM' => 'kvm', // KVM
'Amazon EC2' => 'amazon', // Amazon EC2 Nitro using Linux KVM
'QEMU' => 'qemu', // QEMU
'VMware' => 'vmware', // VMware https://kb.vmware.com/s/article/1009458
'VMW' => 'vmware',
'innotek GmbH' => 'oracle', // Oracle VM VirtualBox
'VirtualBox' => 'oracle',
'Xen' => 'xen', // Xen hypervisor
'Bochs' => 'bochs', // Bochs
'Parallels' => 'parallels', // Parallels
// https://wiki.freebsd.org/bhyve
'BHYVE' => 'bhyve', // bhyve
'Hyper-V' => 'microsoft', // Hyper-V
'Microsoft Corporation Virtual Machine' => 'microsoft' // Hyper-V
);
for ($i = 0; $i < count($vendor_data); $i++) {
foreach ($vendarray as $vend=>$virt) {
if (preg_match('/^'.$vend.'/', $vendor_data[$i])) {
return $virt;
}
 
return false;
}
if (variant_get_type($sub_keys) !== VT_NULL) {
$strBuffer = strval($sub_keys);
} else {
return false;
}
} else {
return false;
}
} elseif (gettype($vendor_data) === "string") {
$vidarray = array(
'bhyvebhyve' => 'bhyve', // bhyve
'KVMKVMKVM' => 'kvm', // KVM
'MicrosoftHv' => 'microsoft', // Hyper-V
'lrpepyhvr' => 'parallels', // Parallels
'UnisysSpar64' => 'spar', // Unisys sPar
'VMwareVMware' => 'vmware', // VMware
'XenVMMXenVMM' => 'xen', // Xen hypervisor
'ACRNACRNACRN' => 'acrn', // ACRN hypervisor
'TCGTCGTCGTCG' => 'qemu', // QEMU
'QNXQVMBSQG' => 'qnx', // QNX hypervisor
'VBoxVBoxVBox' => 'oracle' // Oracle VM VirtualBox
);
$shortvendorid = trim(preg_replace('/[\s!\.]/', '', $vendor_data));
if (($shortvendorid !== "") && isset($vidarray[$shortvendorid])) {
return $vidarray[$shortvendorid];
}
}
 
return true;
return null;
}
 
 
/**
* enumKey function
* readdmimemdata function
*
* @return boolean command successfull or not
* @return array
*/
public static function enumKey($reg, $strName, &$arrBuffer, $booErrorRep = true)
public static function readdmimemdata()
{
$arrBuffer = array();
$_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);
 
if ($reg === false) {
if (defined('PSI_EMU_HOSTNAME')) {
return false;
if ((PSI_OS != 'WINNT') && !defined('PSI_EMU_HOSTNAME') && (self::$_dmimd === null)) {
self::$_dmimd = array();
$buffer = '';
if (defined('PSI_DMIDECODE_ACCESS') && (strtolower(PSI_DMIDECODE_ACCESS)==='data')) {
self::rftsdata('dmidecode.tmp', $buffer);
} elseif (self::_findProgram('dmidecode')) {
self::executeProgram('dmidecode', '-t 17', $buffer, PSI_DEBUG);
}
if (self::$_cp) {
if (self::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);
if (!empty($buffer)) {
$banks = preg_split('/^(?=Handle\s)/m', $buffer, -1, PREG_SPLIT_NO_EMPTY);
foreach ($banks as $bank) if (preg_match('/^Handle\s/', $bank)) {
$lines = preg_split("/\n/", $bank, -1, PREG_SPLIT_NO_EMPTY);
$mem = array();
foreach ($lines as $line) if (preg_match('/^\s+([^:]+):(.+)/', $line, $params)) {
if (preg_match('/^0x([A-F\d]+)/', $params2 = trim($params[2]), $buff)) {
$mem[trim($params[1])] = trim($buff[1]);
} elseif ($params2 != '') {
$mem[trim($params[1])] = $params2;
}
}
} else {
return false;
}
} else {
if (self::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);
if (!empty($mem)) {
self::$_dmimd[] = $mem;
}
} else {
return false;
}
}
} elseif (gettype($reg) === "object") {
$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;
return self::$_dmimd;
}
 
 
/**
* initWMI function
*
* @return string, object or false
*/
public static function initWMI($namespace, $booErrorRep = false)
{
$wmi = false;
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') && ($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;
}
}
}
}
/web/acc/phpsysinfo/includes/class.Parser.inc.php
40,7 → 40,7
$dev = new HWDevice();
$arrParams = preg_split('/(\"? ")|(\" (?=-))/', trim($strLine));
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS && ($cp = count($arrParams)) >= 6) {
$arrParams[$cp-1] = trim($arrParams[$cp-1],'"'); // remove last "
$arrParams[$cp-1] = trim($arrParams[$cp-1], '"'); // remove last "
$dev->setName($arrParams[1].': '.$arrParams[2].' '.$arrParams[3]);
if (preg_match('/^-/', $arrParams[4])) {
if (($arrParams[5] !== "") && !preg_match('/^Unknown vendor/', $arrParams[5])) {
117,7 → 117,7
$mount_parm[] = $parm;
}
}
} elseif (CommonFunctions::rfts("/etc/mtab", $mount)) {
} elseif (CommonFunctions::rfts(((PSI_ROOT_FILESYSTEM === '')||(PHP_OS !== 'Linux'))?"/etc/mtab":"/proc/1/mounts", $mount)) {
$mount = preg_split("/\n/", $mount, -1, PREG_SPLIT_NO_EMPTY);
foreach ($mount as $mount_line) {
if (preg_match("/(\S+) (\S+) (\S+) (\S+) ([0-9]+) ([0-9]+)/", $mount_line, $mount_buf)) {
/web/acc/phpsysinfo/includes/error/class.PSI_Error.inc.php
171,8 → 171,8
$error->addAttribute('Message', $arrLine['message']);
$error->addAttribute('Function', $arrLine['command']);
}
header("Cache-Control: no-cache, must-revalidate\n");
header("Content-Type: text/xml\n\n");
header('Cache-Control: no-cache, must-revalidate');
header('Content-Type: text/xml');
echo $xml->getSimpleXmlElement()->asXML();
exit();
}
/web/acc/phpsysinfo/includes/js/class.JavaScriptPacker.inc.php
159,8 → 159,9
{
$parser = new ParseMaster();
// replace: $name -> n, $$name -> na
$parser->add('/((\\x24+)([a-zA-Z$_]+))(\\d*)/',
array('fn' => '_replace_name')
$parser->add(
'/((\\x24+)([a-zA-Z$_]+))(\\d*)/',
array('fn' => '_replace_name')
);
// replace: _name -> _0, double-underscore (__name) is ignored
$regexp = '/\\b_[A-Za-z\\d]\\w*/';
169,7 → 170,8
// quick ref
$encoded = $keywords['encoded'];
 
$parser->add($regexp,
$parser->add(
$regexp,
array(
'fn' => '_replace_encoded',
'data' => $encoded
194,7 → 196,8
$encoded = $keywords['encoded'];
 
// encode
$parser->add($regexp,
$parser->add(
$regexp,
array(
'fn' => '_replace_encoded',
'data' => $encoded
/web/acc/phpsysinfo/includes/mb/class.coretemp.inc.php
File deleted
/web/acc/phpsysinfo/includes/mb/class.cpumem.inc.php
0,0 → 1,96
<?php
/**
* cpumem sensor class, getting hardware sensors information of CPU and memory
*
* PHP version 5
*
* @category PHP
* @package PSI_Sensor
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
* @author William Johansson <radar@radhuset.org>
* @copyright 2009 phpSysInfo
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
* @version Release: 3.0
* @link http://phpsysinfo.sourceforge.net
*/
class CpuMem extends Hwmon
{
/**
* get the information
*
* @see PSI_Interface_Sensor::build()
*
* @return void
*/
public function build()
{
if ((PSI_OS == 'Linux') && !defined('PSI_EMU_HOSTNAME')) {
$hwpaths = CommonFunctions::findglob("/sys/devices/platform/coretemp.*/", GLOB_NOSORT);
if (is_array($hwpaths) && (count($hwpaths) > 0)) {
$hwpaths2 = CommonFunctions::findglob("/sys/devices/platform/coretemp.*/hwmon/hwmon*/", GLOB_NOSORT);
if (is_array($hwpaths2) && (count($hwpaths2) > 0)) {
$hwpaths = array_merge($hwpaths, $hwpaths2);
}
$totalh = count($hwpaths);
for ($h = 0; $h < $totalh; $h++) {
$this->_temperature($hwpaths[$h]);
}
}
} elseif (PSI_OS == 'FreeBSD') {
$smp = 1;
CommonFunctions::executeProgram('sysctl', '-n kern.smp.cpus', $smp);
for ($i = 0; $i < $smp; $i++) {
$temp = 0;
if (CommonFunctions::executeProgram('sysctl', '-n dev.cpu.'.$i.'.temperature', $temp)) {
$temp = preg_replace('/,/', '.', preg_replace('/C/', '', $temp));
$dev = new SensorDevice();
$dev->setName("CPU ".($i + 1));
$dev->setValue($temp);
// $dev->setMax(70);
$this->mbinfo->setMbTemp($dev);
}
}
} elseif ((PSI_OS == 'WINNT') || defined('PSI_EMU_HOSTNAME')) {
$allCpus = WINNT::_get_Win32_Processor();
foreach ($allCpus as $oneCpu) if (isset($oneCpu['CurrentVoltage']) && ($oneCpu['CurrentVoltage'] > 0)) {
$dev = new SensorDevice();
$dev->setName($oneCpu['DeviceID']);
$dev->setValue($oneCpu['CurrentVoltage']/10);
$this->mbinfo->setMbVolt($dev);
}
$allMems = WINNT::_get_Win32_PhysicalMemory();
$counter = 0;
foreach ($allMems as $oneMem) if (isset($oneMem['ConfiguredVoltage']) && ($oneMem['ConfiguredVoltage'] > 0)) {
$dev = new SensorDevice();
$dev->setName('Mem'.($counter++));
$dev->setValue($oneMem['ConfiguredVoltage']/1000);
if (isset($oneMem['MaxVoltage']) && ($oneMem['MaxVoltage'] > 0)) {
$dev->setMax($oneMem['MaxVoltage']/1000);
}
if (isset($oneMem['MinVoltage']) && ($oneMem['MinVoltage'] > 0)) {
$dev->setMin($oneMem['MinVoltage']/1000);
}
$this->mbinfo->setMbVolt($dev);
}
}
if ((PSI_OS != 'WINNT') && !defined('PSI_EMU_HOSTNAME')) {
$dmimd = CommonFunctions::readdmimemdata();
$counter = 0;
foreach ($dmimd as $mem) {
if (isset($mem['Size']) && preg_match('/^(\d+)\s(M|G)B$/', $mem['Size'], $size) && ($size[1] > 0)
&& isset($mem['Configured Voltage']) && preg_match('/^([\d\.]+)\sV$/', $mem['Configured Voltage'], $voltage) && ($voltage[1] > 0)) {
$dev = new SensorDevice();
$dev->setName('Mem'.($counter++));
$dev->setValue($voltage[1]);
if (isset($mem['Minimum Voltage']) && preg_match('/^([\d\.]+)\sV$/', $mem['Minimum Voltage'], $minv) && ($minv[1] > 0)) {
$dev->setMin($minv[1]);
}
if (isset($mem['Maximum Voltage']) && preg_match('/^([\d\.]+)\sV$/', $mem['Maximum Voltage'], $maxv) && ($maxv[1] > 0)) {
$dev->setMax($maxv[1]);
}
$this->mbinfo->setMbVolt($dev);
}
}
}
}
}
/web/acc/phpsysinfo/includes/mb/class.freeipmi.inc.php
33,13 → 33,12
$this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
break;
case 'data':
if (CommonFunctions::rfts(PSI_APP_ROOT.'/data/freeipmi.txt', $lines)) {
if (CommonFunctions::rftsdata('freeipmi.tmp', $lines)) {
$this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
}
break;
default:
$this->error->addConfigError('__construct()', '[sensor_freeipmi] ACCESS');
break;
}
}
 
173,7 → 172,7
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
* @return void
*/
public function build()
{
/web/acc/phpsysinfo/includes/mb/class.hddtemp.inc.php
90,7 → 90,6
break;
default:
$this->error->addConfigError("temperature()", "[sensor_hddtemp] ACCESS");
break;
}
// Timo van Roermund: parse the info from the hddtemp daemon.
foreach ($ar_buf as $line) {
115,7 → 114,7
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
* @return void
*/
public function build()
{
/web/acc/phpsysinfo/includes/mb/class.healthd.inc.php
37,7 → 37,7
}
break;
case 'data':
if (CommonFunctions::rfts(PSI_APP_ROOT.'/data/healthd.txt', $lines)) {
if (CommonFunctions::rftsdata('healthd.tmp', $lines)) {
$lines0 = preg_split("/\n/", $lines, 1, PREG_SPLIT_NO_EMPTY);
if (count($lines0) == 1) {
$this->_values = preg_split("/\t+/", $lines0[0]);
46,7 → 46,6
break;
default:
$this->error->addConfigError('__construct()', '[sensor_healthd] ACCESS');
break;
}
}
 
146,7 → 145,7
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
* @return void
*/
public function build()
{
/web/acc/phpsysinfo/includes/mb/class.hwmon.inc.php
22,7 → 22,7
*/
protected function _temperature($hwpath)
{
$sensor = glob($hwpath."temp*_input", GLOB_NOSORT);
$sensor = CommonFunctions::findglob($hwpath."temp*_input", GLOB_NOSORT);
if (is_array($sensor) && (($total = count($sensor)) > 0)) {
$buf = "";
for ($i = 0; $i < $total; $i++) if (($buf = CommonFunctions::rolv($sensor[$i]))!==null) {
71,7 → 71,7
*/
private function _voltage($hwpath)
{
$sensor = glob($hwpath."in*_input", GLOB_NOSORT);
$sensor = CommonFunctions::findglob($hwpath."in*_input", GLOB_NOSORT);
if (is_array($sensor) && (($total = count($sensor)) > 0)) {
$buf = "";
for ($i = 0; $i < $total; $i++) if (($buf = CommonFunctions::rolv($sensor[$i]))!==null) {
114,7 → 114,7
*/
protected function _fans($hwpath)
{
$sensor = glob($hwpath."fan*_input", GLOB_NOSORT);
$sensor = CommonFunctions::findglob($hwpath."fan*_input", GLOB_NOSORT);
if (is_array($sensor) && (($total = count($sensor)) > 0)) {
$buf = "";
for ($i = 0; $i < $total; $i++) if (($buf = CommonFunctions::rolv($sensor[$i]))!==null) {
159,7 → 159,7
*/
private function _power($hwpath)
{
$sensor = glob($hwpath."power*_input", GLOB_NOSORT);
$sensor = CommonFunctions::findglob($hwpath."power*_input", GLOB_NOSORT);
if (is_array($sensor) && (($total = count($sensor)) > 0)) {
$buf = "";
for ($i = 0; $i < $total; $i++) if (($buf = CommonFunctions::rolv($sensor[$i]))!==null) {
202,7 → 202,7
*/
private function _current($hwpath)
{
$sensor = glob($hwpath."curr*_input", GLOB_NOSORT);
$sensor = CommonFunctions::findglob($hwpath."curr*_input", GLOB_NOSORT);
if (is_array($sensor) && (($total = count($sensor)) > 0)) {
$buf = "";
for ($i = 0; $i < $total; $i++) if (($buf = CommonFunctions::rolv($sensor[$i]))!==null) {
242,14 → 242,14
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
* @return void
*/
public function build()
{
if ((PSI_OS == 'Linux') && !defined('PSI_EMU_HOSTNAME')) {
$hwpaths = glob("/sys/class/hwmon/hwmon*/", GLOB_NOSORT);
$hwpaths = CommonFunctions::findglob("/sys/class/hwmon/hwmon*/", GLOB_NOSORT);
if (is_array($hwpaths) && (count($hwpaths) > 0)) {
$hwpaths2 = glob("/sys/class/hwmon/hwmon*/device/", GLOB_NOSORT);
$hwpaths2 = CommonFunctions::findglob("/sys/class/hwmon/hwmon*/device/", GLOB_NOSORT);
if (is_array($hwpaths2) && (count($hwpaths2) > 0)) {
$hwpaths = array_merge($hwpaths, $hwpaths2);
}
/web/acc/phpsysinfo/includes/mb/class.hwsensors.inc.php
136,7 → 136,7
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
* @return void
*/
public function build()
{
/web/acc/phpsysinfo/includes/mb/class.ipmicfg.inc.php
40,13 → 40,12
$this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
break;
case 'data':
if (CommonFunctions::rfts(PSI_APP_ROOT.'/data/ipmicfg.txt', $lines)) {
if (CommonFunctions::rftsdata('ipmicfg.tmp', $lines)) {
$this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
}
break;
default:
$this->error->addConfigError('__construct()', '[sensor_ipmicfg] ACCESS');
break;
}
}
 
60,15 → 59,15
foreach ($this->_lines as $line) {
$buffer = preg_split("/\s*\|\s*/", $line);
if ((!defined('PSI_SENSOR_IPMICFG_PSFRUINFO') || (strtolower(PSI_SENSOR_IPMICFG_PSFRUINFO)!=="only")) &&
(count($buffer)==6) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*([-\d]+)C\/[-\d]+F\s*$/",$buffer[2], $valbuff)) {
(count($buffer)==6) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*([-\d]+)C\/[-\d]+F\s*$/", $buffer[2], $valbuff)) {
$dev = new SensorDevice();
$dev->setName($namebuff[1]);
if ($valbuff[1]<-128) $valbuff[1]+=256; //+256 correction
$dev->setValue($valbuff[1]);
if (preg_match("/^\s*([-\d]+)C\/[-\d]+F\s*$/",$buffer[3], $valbuffmin)) {
if (preg_match("/^\s*([-\d]+)C\/[-\d]+F\s*$/", $buffer[3], $valbuffmin)) {
if ($valbuffmin[1]<-128) $valbuffmin[1]+=256; //+256 correction
}
if (preg_match("/^\s*([-\d]+)C\/[-\d]+F\s*$/",$buffer[4], $valbuffmax)) {
if (preg_match("/^\s*([-\d]+)C\/[-\d]+F\s*$/", $buffer[4], $valbuffmax)) {
if ($valbuffmax[1]<-128) $valbuffmax[1]+=256; //+256 correction
$dev->setMax($valbuffmax[1]);
}
96,14 → 95,14
foreach ($this->_lines as $line) {
$buffer = preg_split("/\s*\|\s*/", $line);
if ((!defined('PSI_SENSOR_IPMICFG_PSFRUINFO') || (strtolower(PSI_SENSOR_IPMICFG_PSFRUINFO)!=="only")) &&
(count($buffer)==6) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*([\d\.]+)\sV\s*$/",$buffer[2], $valbuff)) {
(count($buffer)==6) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*([\d\.]+)\sV\s*$/", $buffer[2], $valbuff)) {
$dev = new SensorDevice();
$dev->setName($namebuff[1]);
$dev->setValue($valbuff[1]);
if (preg_match("/^\s*([\d\.].+)\sV\s*$/",$buffer[3], $valbuffmin)) {
if (preg_match("/^\s*([\d\.].+)\sV\s*$/", $buffer[3], $valbuffmin)) {
$dev->setMin($valbuffmin[1]);
}
if (preg_match("/^\s*([\d\.].+)\sV\s*$/",$buffer[4], $valbuffmax)) {
if (preg_match("/^\s*([\d\.].+)\sV\s*$/", $buffer[4], $valbuffmax)) {
$dev->setMax($valbuffmax[1]);
}
if (trim($buffer[0]) != "OK") $dev->setEvent(trim($buffer[0]));
122,11 → 121,11
foreach ($this->_lines as $line) {
$buffer = preg_split("/\s*\|\s*/", $line);
if ((!defined('PSI_SENSOR_IPMICFG_PSFRUINFO') || (strtolower(PSI_SENSOR_IPMICFG_PSFRUINFO)!=="only")) &&
(count($buffer)==6) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*(\d+)\sRPM\s*$/",$buffer[2], $valbuff)) {
(count($buffer)==6) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*(\d+)\sRPM\s*$/", $buffer[2], $valbuff)) {
$dev = new SensorDevice();
$dev->setName($namebuff[1]);
$dev->setValue($valbuff[1]);
if (preg_match("/^\s*(\d+)\sRPM\s*$/",$buffer[3], $valbuffmin)) {
if (preg_match("/^\s*(\d+)\sRPM\s*$/", $buffer[3], $valbuffmin)) {
$dev->setMin($valbuffmin[1]);
}
if ((trim($buffer[0]) != "OK") && isset($valbuffmin[1])) {
153,11 → 152,11
foreach ($this->_lines as $line) {
$buffer = preg_split("/\s*\|\s*/", $line);
if ((!defined('PSI_SENSOR_IPMICFG_PSFRUINFO') || (strtolower(PSI_SENSOR_IPMICFG_PSFRUINFO)!=="only")) &&
(count($buffer)==6) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*(\d+)\sWatts\s*$/",$buffer[2], $valbuff)) {
(count($buffer)==6) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*(\d+)\sWatts\s*$/", $buffer[2], $valbuff)) {
$dev = new SensorDevice();
$dev->setName($namebuff[1]);
$dev->setValue($valbuff[1]);
if (preg_match("/^\s*(\d+)\sWatts\s*$/",$buffer[4], $valbuffmax)) {
if (preg_match("/^\s*(\d+)\sWatts\s*$/", $buffer[4], $valbuffmax)) {
$dev->setMax($valbuffmax[1]);
}
if (trim($buffer[0]) != "OK") $dev->setEvent(trim($buffer[0]));
176,14 → 175,14
foreach ($this->_lines as $line) {
$buffer = preg_split("/\s*\|\s*/", $line);
if ((!defined('PSI_SENSOR_IPMICFG_PSFRUINFO') || (strtolower(PSI_SENSOR_IPMICFG_PSFRUINFO)!=="only")) &&
(count($buffer)==6) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*([\d\.]+)\sAmps\s*$/",$buffer[2], $valbuff)) {
(count($buffer)==6) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*([\d\.]+)\sAmps\s*$/", $buffer[2], $valbuff)) {
$dev = new SensorDevice();
$dev->setName($namebuff[1]);
$dev->setValue($valbuff[1]);
if (preg_match("/^\s*([\d\.].+)\sAmps\s*$/",$buffer[3], $valbuffmin)) {
if (preg_match("/^\s*([\d\.].+)\sAmps\s*$/", $buffer[3], $valbuffmin)) {
$dev->setMin($valbuffmin[1]);
}
if (preg_match("/^\s*([\d\.].+)\sAmps\s*$/",$buffer[4], $valbuffmax)) {
if (preg_match("/^\s*([\d\.].+)\sAmps\s*$/", $buffer[4], $valbuffmax)) {
$dev->setMax($valbuffmax[1]);
}
if (trim($buffer[0]) != "OK") $dev->setEvent(trim($buffer[0]));
225,7 → 224,7
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
* @return void
*/
public function build()
{
/web/acc/phpsysinfo/includes/mb/class.ipmitool.inc.php
33,11 → 33,10
CommonFunctions::executeProgram('ipmitool', 'sensor -v', $lines);
break;
case 'data':
CommonFunctions::rfts(PSI_APP_ROOT.'/data/ipmitool.txt', $lines);
CommonFunctions::rftsdata('ipmitool.tmp', $lines);
break;
default:
$this->error->addConfigError('__construct()', '[sensor_ipmitool] ACCESS');
break;
}
if (trim($lines) !== "") {
if (preg_match("/^Sensor ID\s+/", $lines)) { //new data format ('ipmitool sensor -v')
126,7 → 125,6
$sens['Sensor Type (Discrete)'] = '';
$sens['State'] = $buffer[1];
}
break;
}
$this->_buf[] = $sens;
}
306,7 → 304,7
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
* @return void
*/
public function build()
{
/web/acc/phpsysinfo/includes/mb/class.ipmiutil.inc.php
33,13 → 33,12
$this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
break;
case 'data':
if (CommonFunctions::rfts(PSI_APP_ROOT.'/data/ipmiutil.txt', $lines)) {
if (CommonFunctions::rftsdata('ipmiutil.tmp', $lines)) {
$this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
}
break;
default:
$this->error->addConfigError('__construct()', '[sensor_ipmiutil] ACCESS');
break;
}
}
 
230,11 → 229,15
 
$buffer5s = preg_split("/\s+/", $buffer5 = $buffer[5]);
if (isset($buffer5s[1])) {
$value = hexdec($buffer5s[0]) & 0xff;
if ($buffer5s[1] === 'DiscreteEvt') {
$dev->setValue('0x'.dechex($value));
} elseif (($buffer5s[1] === 'DiscreteUnit') && ($value > 0)) {
$dev->setValue('0x'.dechex($value - 1));
if (preg_match('/^[0-9A-Fa-f]+$/', $buffer5s[0])) {
$value = hexdec($buffer5s[0]) & 0xff;
if ($buffer5s[1] === 'DiscreteEvt') {
$dev->setValue('0x'.dechex($value));
} elseif (($buffer5s[1] === 'DiscreteUnit') && ($value > 0)) {
$dev->setValue('0x'.dechex($value - 1));
} else {
$dev->setValue($buffer5);
}
} else {
$dev->setValue($buffer5);
}
251,7 → 254,7
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
* @return void
*/
public function build()
{
/web/acc/phpsysinfo/includes/mb/class.k8temp.inc.php
34,13 → 34,12
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
break;
case 'data':
if (CommonFunctions::rfts(PSI_APP_ROOT.'/data/k8temp.txt', $lines)) {
if (CommonFunctions::rftsdata('k8temp.tmp', $lines)) {
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
}
break;
default:
$this->error->addConfigError('__construct()', '[sensor_k8temp] ACCESS');
break;
}
}
 
71,7 → 70,7
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
* @return void
*/
public function build()
{
/web/acc/phpsysinfo/includes/mb/class.lmsensors.inc.php
33,11 → 33,10
CommonFunctions::executeProgram("sensors", "", $lines);
break;
case 'data':
CommonFunctions::rfts(PSI_APP_ROOT.'/data/lmsensors.txt', $lines);
CommonFunctions::rftsdata('lmsensors.tmp', $lines);
break;
default:
$this->error->addConfigError('__construct()', '[sensor_lmsensors] ACCESS');
break;
}
 
if (trim($lines) !== "") {
74,15 → 73,23
;
} elseif (preg_match("/^(.+):(.+).C\s*\((.+)=(.+).C\)(.*)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):\s*(FAULT)\s*\((.+)=(.+).C,(.+)=(.+).C\)(.*)\)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):\s*(FAULT)\s*\((.+)=(.+).C,(.+)=(.+).C\)(.*)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):\s*(FAULT)\s*\((.+)=(.+).C\)(.*)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+).C\s*\(/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+).C\s+\D+/", $line, $data)) {
;
} else {
preg_match("/^(.+):(.+).C$/", $line, $data);
preg_match("/^(.+):(.+).C\r?$/", $line, $data);
}
if (count($data)>2) {
foreach ($data as $key=>$value) {
if (preg_match("/^\+?(-?[0-9\.]+).?$/", trim($value), $newvalue)) {
$data[$key] = 0+trim($newvalue[1]);
$data[$key] = floatval($newvalue[1]);
} else {
$data[$key] = trim($value);
}
139,8 → 146,8
} elseif (isset($data[4]) && $data[2] <= $data[4]) {
$dev->setMax($data[4]);
}
if (preg_match("/\sALARM\s*$/", $line) || preg_match("/\sALARM\s+sensor\s+=/", $line)) {
$dev->setEvent("Alarm");
if (preg_match("/\s(ALARM)\s*$/", $line, $evbuf) || preg_match("/\s(ALARM)\s+sensor\s+=/", $line, $evbuf) || (($evbuf[1] = $dev->getValue()) === 'FAULT')) {
$dev->setEvent($evbuf[1]);
}
$this->mbinfo->setMbTemp($dev);
}
171,15 → 178,23
;
} elseif (preg_match("/^(.+):(.+) RPM\s*\((.+)=(.+) RPM\)(.*)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):\s*(FAULT)\s*\((.+)=(.+) RPM,(.+)=(.+)\)(.*)\)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):\s*(FAULT)\s*\((.+)=(.+) RPM,(.+)=(.+)\)(.*)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):\s*(FAULT)\s*\((.+)=(.+) RPM\)(.*)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+) RPM\s*\(/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+) RPM\s+\D+/", $line, $data)) {
;
} else {
preg_match("/^(.+):(.+) RPM$/", $line, $data);
preg_match("/^(.+):(.+) RPM\r?$/", $line, $data);
}
if (count($data)>2) {
foreach ($data as $key=>$value) {
if (preg_match("/^\+?(-?[0-9\.]+).?$/", trim($value), $newvalue)) {
$data[$key] = 0+trim($newvalue[1]);
$data[$key] = floatval($newvalue[1]);
} else {
$data[$key] = trim($value);
}
190,8 → 205,8
if (isset($data[4])) {
$dev->setMin(trim($data[4]));
}
if (preg_match("/\sALARM\s*$/", $line)) {
$dev->setEvent("Alarm");
if (preg_match("/\s(ALARM)\s*$/", $line, $evbuf) || (($evbuf[1] = $dev->getValue()) === 'FAULT')) {
$dev->setEvent($evbuf[1]);
}
$this->mbinfo->setMbFan($dev);
}
220,16 → 235,22
;
} elseif (preg_match("/^(.+):(.+) V\s*\((.+)=(.+) V,(.+)=(.+) V\)(.*)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):\s*(FAULT)\s*\((.+)=(.+) V,(.+)=(.+) V\)(.*)\)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):\s*(FAULT)\s*\((.+)=(.+) V,(.+)=(.+) V\)(.*)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+) V\s*\(/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+) V\s+\D+/", $line, $data)) {
;
} else {
preg_match("/^(.+):(.+) V$/", $line, $data);
preg_match("/^(.+):(.+) V\r?$/", $line, $data);
}
 
if (count($data)>2) {
foreach ($data as $key=>$value) {
if (preg_match("/^\+?(-?[0-9\.]+)$/", trim($value), $newvalue)) {
$data[$key] = 0+trim($newvalue[1]);
$data[$key] = floatval($newvalue[1]);
} else {
$data[$key] = trim($value);
}
243,8 → 264,8
if (isset($data[6])) {
$dev->setMax($data[6]);
}
if (preg_match("/\sALARM\s*$/", $line)) {
$dev->setEvent("Alarm");
if (preg_match("/\s(ALARM)\s*$/", $line, $evbuf) || (($evbuf[1] = $dev->getValue()) === 'FAULT')) {
$dev->setEvent($evbuf[1]);
}
$this->mbinfo->setMbVolt($dev);
}
274,19 → 295,27
;
} elseif (preg_match("/^(.+):(.+) W\s*\((.+)=(.+) W,(.+)=(.+) W\)(.*)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):\s*(FAULT)\s*\((.+)=(.+) W,(.+)=(.+) W\)(.*)\)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):\s*(FAULT)\s*\((.+)=(.+) W,(.+)=(.+) W\)(.*)/", $line, $data)) {
;
} else
*/
if (preg_match("/^(.+):(.+) W\s*\((.+)=(.+) W\)(.*)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):\s*(FAULT)\s*\((.+)=(.+) W\)(.*)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+) W\s*\(/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+) W\s+\D+/", $line, $data)) {
;
} else {
preg_match("/^(.+):(.+) W$/", $line, $data);
preg_match("/^(.+):(.+) W\r?$/", $line, $data);
}
if (count($data)>2) {
foreach ($data as $key=>$value) {
if (preg_match("/^\+?(-?[0-9\.]+).?$/", trim($value), $newvalue)) {
$data[$key] = 0+trim($newvalue[1]);
$data[$key] = floatval($newvalue[1]);
} else {
$data[$key] = trim($value);
}
303,8 → 332,8
if (isset($data[4]) && $data[2] <= $data[4]) {
$dev->setMax($data[4]);
}
if (preg_match("/\sALARM\s*$/", $line)) {
$dev->setEvent("Alarm");
if (preg_match("/\s(ALARM)\s*$/", $line, $evbuf) || (($evbuf[1] = $dev->getValue()) === 'FAULT')) {
$dev->setEvent($evbuf[1]);
}
$this->mbinfo->setMbPower($dev);
}
333,10 → 362,16
;
} elseif (preg_match("/^(.+):(.+) A\s*\((.+)=(.+) A,(.+)=(.+) A\)(.*)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):\s*(FAULT)\s*\((.+)=(.+) A,(.+)=(.+) A\)(.*)\)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):\s*(FAULT)\s*\((.+)=(.+) A,(.+)=(.+) A\)(.*)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+) A\s*\(/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+) A\s+\D+/", $line, $data)) {
;
} else {
preg_match("/^(.+):(.+) A$/", $line, $data);
preg_match("/^(.+):(.+) A\r?$/", $line, $data);
}
if (count($data)>2) {
foreach ($data as $key=>$value) {
355,8 → 390,8
if (isset($data[6])) {
$dev->setMax($data[6]);
}
if (preg_match("/\sALARM\s*$/", $line)) {
$dev->setEvent("Alarm");
if (preg_match("/\s(ALARM)\s*$/", $line, $evbuf) || (($evbuf[1] = $dev->getValue()) === 'FAULT')) {
$dev->setEvent($evbuf[1]);
}
$this->mbinfo->setMbCurrent($dev);
}
381,8 → 416,8
}
}
$data = array();
preg_match("/^(.+):\s*([^\-\+\d\s].+)$/", $line, $data);
if ((count($data)>2) && ($data[1]!=="Adapter")) {
preg_match("/^(.+):\s*([^\-\+\d\s].+)\r?$/", $line, $data);
if ((count($data)>2) && ($data[1]!=="Adapter") && !preg_match("/^FAULT/", $data[2])) {
$dev = new SensorDevice();
$dev->setName($data[1].$sname);
if (preg_match("/(.*\s*)ALARM\s*$/", $data[2], $aldata)) {
405,7 → 440,7
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
* @return void
*/
public function build()
{
/web/acc/phpsysinfo/includes/mb/class.mbm5.inc.php
36,7 → 36,7
parent::__construct();
if ((PSI_OS == 'WINNT') && !defined('PSI_EMU_HOSTNAME')) {
$delim = "/;/";
CommonFunctions::rfts(PSI_APP_ROOT."/data/MBM5.csv", $buffer);
CommonFunctions::rftsdata("MBM5.csv", $buffer);
if (strpos($buffer, ";") === false) {
$delim = "/,/";
}
110,7 → 110,7
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
* @return void
*/
public function build()
{
/web/acc/phpsysinfo/includes/mb/class.mbmon.inc.php
45,13 → 45,12
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
break;
case 'data':
if (CommonFunctions::rfts(PSI_APP_ROOT.'/data/mbmon.txt', $lines)) {
if (CommonFunctions::rftsdata('mbmon.tmp', $lines)) {
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
}
break;
default:
$this->error->addConfigError('__construct()', '[sensor_mbmon] ACCESS');
break;
}
}
 
/web/acc/phpsysinfo/includes/mb/class.nvidiasmi.inc.php
43,13 → 43,12
$this->_gpus = preg_split("/^(?=GPU )/m", $lines, -1, PREG_SPLIT_NO_EMPTY);
break;
case 'data':
if (CommonFunctions::rfts(PSI_APP_ROOT.'/data/nvidiasmi.txt', $lines)) {
if (CommonFunctions::rftsdata('nvidiasmi.tmp', $lines)) {
$this->_gpus = preg_split("/^(?=GPU )/m", $lines, -1, PREG_SPLIT_NO_EMPTY);
}
break;
default:
$this->error->addConfigError('__construct()', '[sensor_nvidiasmi] ACCESS');
break;
}
}
 
58,81 → 57,80
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
* @return void
*/
public function build()
{
$gpuc=count($this->_gpus);
switch ($gpuc) {
case 0:
$this->error->addError("nvidia-smi", "No values");
break;
case 1:
$this->error->addError("nvidia-smi", "Error: ".$this->_gpus[0]);
break;
default:
for ($c = 0; $c < $gpuc; $c++) {
if (preg_match("/^\s+GPU Current Temp\s+:\s*(\d+)\s*C\s*$/m", $this->_gpus[$c], $out)) {
$dev = new SensorDevice();
$dev->setName("GPU ".($c)." (nvidiasmi)");
$dev->setValue($out[1]);
if (preg_match("/^\s+GPU Shutdown Temp\s+:\s*(\d+)\s*C\s*$/m", $this->_gpus[$c], $out)) {
$dev->setMax($out[1]);
}
$this->mbinfo->setMbTemp($dev);
case 0:
$this->error->addError("nvidia-smi", "No values");
break;
case 1:
$this->error->addError("nvidia-smi", "Error: ".$this->_gpus[0]);
break;
default:
for ($c = 0; $c < $gpuc; $c++) {
if (preg_match("/^\s+GPU Current Temp\s+:\s*(\d+)\s*C\s*$/m", $this->_gpus[$c], $out)) {
$dev = new SensorDevice();
$dev->setName("GPU ".($c)." (nvidiasmi)");
$dev->setValue($out[1]);
if (preg_match("/^\s+GPU Shutdown Temp\s+:\s*(\d+)\s*C\s*$/m", $this->_gpus[$c], $out)) {
$dev->setMax($out[1]);
}
if (preg_match("/^\s+Power Draw\s+:\s*([\d\.]+)\s*W\s*$/m", $this->_gpus[$c], $out)) {
$dev = new SensorDevice();
$dev->setName("GPU ".($c)." (nvidiasmi)");
$dev->setValue($out[1]);
if (preg_match("/^\s+Power Limit\s+:\s*([\d\.]+)\s*W\s*$/m", $this->_gpus[$c], $out)) {
$dev->setMax($out[1]);
}
$this->mbinfo->setMbPower($dev);
$this->mbinfo->setMbTemp($dev);
}
if (preg_match("/^\s+Power Draw\s+:\s*([\d\.]+)\s*W\s*$/m", $this->_gpus[$c], $out)) {
$dev = new SensorDevice();
$dev->setName("GPU ".($c)." (nvidiasmi)");
$dev->setValue($out[1]);
if (preg_match("/^\s+Power Limit\s+:\s*([\d\.]+)\s*W\s*$/m", $this->_gpus[$c], $out)) {
$dev->setMax($out[1]);
}
if (preg_match("/^\s+Fan Speed\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
$dev = new SensorDevice();
$dev->setName("GPU ".($c)." (nvidiasmi)");
$dev->setValue($out[1]);
$dev->setUnit("%");
$this->mbinfo->setMbFan($dev);
}
if (preg_match("/^\s+Performance State\s+:\s*(\S+)\s*$/m", $this->_gpus[$c], $out)) {
$dev = new SensorDevice();
$dev->setName("GPU ".($c)." Performance State (nvidiasmi)");
$dev->setValue($out[1]);
$this->mbinfo->setMbOther($dev);
}
if (preg_match("/^\s+Gpu\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
$dev = new SensorDevice();
$dev->setName("GPU ".($c)." Utilization (nvidiasmi)");
$dev->setValue($out[1]);
$dev->setUnit("%");
$this->mbinfo->setMbOther($dev);
}
if (preg_match("/^\s+Memory\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
$dev = new SensorDevice();
$dev->setName("GPU ".($c)." Memory Utilization (nvidiasmi)");
$dev->setValue($out[1]);
$dev->setUnit("%");
$this->mbinfo->setMbOther($dev);
}
if (preg_match("/^\s+Encoder\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
$dev = new SensorDevice();
$dev->setName("GPU ".($c)." Encoder Utilization (nvidiasmi)");
$dev->setValue($out[1]);
$dev->setUnit("%");
$this->mbinfo->setMbOther($dev);
}
if (preg_match("/^\s+Decoder\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
$dev = new SensorDevice();
$dev->setName("GPU ".($c)." Decoder Utilization (nvidiasmi)");
$dev->setValue($out[1]);
$dev->setUnit("%");
$this->mbinfo->setMbOther($dev);
}
$this->mbinfo->setMbPower($dev);
}
break;
if (preg_match("/^\s+Fan Speed\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
$dev = new SensorDevice();
$dev->setName("GPU ".($c)." (nvidiasmi)");
$dev->setValue($out[1]);
$dev->setUnit("%");
$this->mbinfo->setMbFan($dev);
}
if (preg_match("/^\s+Performance State\s+:\s*(\S+)\s*$/m", $this->_gpus[$c], $out)) {
$dev = new SensorDevice();
$dev->setName("GPU ".($c)." Performance State (nvidiasmi)");
$dev->setValue($out[1]);
$this->mbinfo->setMbOther($dev);
}
if (preg_match("/^\s+Gpu\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
$dev = new SensorDevice();
$dev->setName("GPU ".($c)." Utilization (nvidiasmi)");
$dev->setValue($out[1]);
$dev->setUnit("%");
$this->mbinfo->setMbOther($dev);
}
if (preg_match("/^\s+Memory\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
$dev = new SensorDevice();
$dev->setName("GPU ".($c)." Memory Utilization (nvidiasmi)");
$dev->setValue($out[1]);
$dev->setUnit("%");
$this->mbinfo->setMbOther($dev);
}
if (preg_match("/^\s+Encoder\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
$dev = new SensorDevice();
$dev->setName("GPU ".($c)." Encoder Utilization (nvidiasmi)");
$dev->setValue($out[1]);
$dev->setUnit("%");
$this->mbinfo->setMbOther($dev);
}
if (preg_match("/^\s+Decoder\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
$dev = new SensorDevice();
$dev->setName("GPU ".($c)." Decoder Utilization (nvidiasmi)");
$dev->setValue($out[1]);
$dev->setUnit("%");
$this->mbinfo->setMbOther($dev);
}
}
}
}
}
/web/acc/phpsysinfo/includes/mb/class.ohm.inc.php
28,9 → 28,9
{
parent::__construct();
if ((PSI_OS == 'WINNT') || defined('PSI_EMU_HOSTNAME')) {
$_wmi = CommonFunctions::initWMI('root\OpenHardwareMonitor', true);
$_wmi = WINNT::initWMI('root\OpenHardwareMonitor', true);
if ($_wmi) {
$tmpbuf = CommonFunctions::getWMI($_wmi, 'Sensor', array('Parent', 'Name', 'SensorType', 'Value'));
$tmpbuf = WINNT::getWMI($_wmi, 'Sensor', array('Parent', 'Name', 'SensorType', 'Value'));
if ($tmpbuf) foreach ($tmpbuf as $buffer) {
if (!isset($this->_buf[$buffer['SensorType']]) || !isset($this->_buf[$buffer['SensorType']][$buffer['Parent'].' '.$buffer['Name']])) { // avoid duplicates
$this->_buf[$buffer['SensorType']][$buffer['Parent'].' '.$buffer['Name']] = $buffer['Value'];
105,7 → 105,7
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
* @return void
*/
public function build()
{
/web/acc/phpsysinfo/includes/mb/class.pitemp.inc.php
22,11 → 22,11
CommonFunctions::rfts('/sys/class/thermal/thermal_zone0/temp', $temp, 1);
CommonFunctions::rfts('/sys/class/thermal/thermal_zone0/trip_point_0_temp', $temp_max, 1, 4096, PSI_DEBUG);
}
if (!is_null($temp) && (($temp = trim($temp)) != "")) {
if (($temp !== null) && (($temp = trim($temp)) != "")) {
$dev = new SensorDevice();
$dev->setName("CPU 1");
$dev->setValue($temp / 1000);
if (!is_null($temp_max) && (($temp_max = trim($temp_max)) != "") && ($temp_max > 0)) {
if (($temp_max !== null) && (($temp_max = trim($temp_max)) != "") && ($temp_max > 0)) {
$dev->setMax($temp_max / 1000);
}
$this->mbinfo->setMbTemp($dev);
36,7 → 36,7
private function _voltage()
{
$volt = null;
if (CommonFunctions::rfts('/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/voltage_now', $volt, 1, 4096, false) && !is_null($volt) && (($volt = trim($volt)) != "")) { // Banana Pi
if (CommonFunctions::rfts('/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/voltage_now', $volt, 1, 4096, false) && ($volt !== null) && (($volt = trim($volt)) != "")) { // Banana Pi
$dev = new SensorDevice();
$dev->setName("Voltage 1");
$dev->setValue($volt / 1000000);
47,7 → 47,7
private function _current()
{
$current = null;
if (CommonFunctions::rfts('/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/current_now', $current, 1, 4096, false) && !is_null($current) && (($current = trim($current)) != "")) { // Banana Pi
if (CommonFunctions::rfts('/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/current_now', $current, 1, 4096, false) && ($current !== null) && (($current = trim($current)) != "")) { // Banana Pi
$dev = new SensorDevice();
$dev->setName("Current 1");
$dev->setValue($current / 1000000);
/web/acc/phpsysinfo/includes/mb/class.qtssnmp.inc.php
71,7 → 71,7
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
* @return void
*/
public function build()
{
/web/acc/phpsysinfo/includes/mb/class.speedfan.inc.php
38,7 → 38,7
}
break;
case 'data':
if (CommonFunctions::rfts(PSI_APP_ROOT.'/data/speedfan.txt', $buffer) && (strlen($buffer) > 0)) {
if (CommonFunctions::rftsdata('speedfan.tmp', $buffer) && (strlen($buffer) > 0)) {
if (preg_match("/^Temperatures:\s+(.+)$/m", $buffer, $out)) {
$this->_filecontent["temp"] = $out[1];
}
52,7 → 52,6
break;
default:
$this->error->addConfigError('__construct()', '[sensor_speedfan] ACCESS');
break;
}
}
 
115,7 → 114,7
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
* @return void
*/
public function build()
{
/web/acc/phpsysinfo/includes/mb/class.thermalzone.inc.php
30,18 → 30,24
switch (defined('PSI_SENSOR_THERMALZONE_ACCESS')?strtolower(PSI_SENSOR_THERMALZONE_ACCESS):'command') {
case 'command':
if ((PSI_OS == 'WINNT') || defined('PSI_EMU_HOSTNAME')) {
if (defined('PSI_EMU_HOSTNAME') || CommonFunctions::isAdmin()) {
$_wmi = CommonFunctions::initWMI('root\WMI', true);
if (defined('PSI_EMU_HOSTNAME') || WINNT::isAdmin()) {
$_wmi = WINNT::initWMI('root\WMI', true);
if ($_wmi) {
$this->_buf = CommonFunctions::getWMI($_wmi, 'MSAcpi_ThermalZoneTemperature', array('InstanceName', 'CriticalTripPoint', 'CurrentTemperature'));
$this->_buf = WINNT::getWMI($_wmi, 'MSAcpi_ThermalZoneTemperature', array('InstanceName', 'CriticalTripPoint', 'CurrentTemperature'));
}
} else {
$this->error->addError("Error reading data from thermalzone sensor", "Allowed only for systems with administrator privileges (run as administrator)");
$_wmi = WINNT::getcimv2wmi();
if ($_wmi) {
$this->_buf = WINNT::getWMI($_wmi, 'Win32_PerfFormattedData_Counters_ThermalZoneInformation', array('Name', 'HighPrecisionTemperature', 'Temperature'));
}
if (!$this->_buf || PSI_DEBUG) {
$this->error->addError("Error reading data from thermalzone sensor", "Allowed only for systems with administrator privileges (run as administrator)");
}
}
}
break;
case 'data':
if (!defined('PSI_EMU_HOSTNAME') && CommonFunctions::rfts(PSI_APP_ROOT.'/data/thermalzone.txt', $lines, 0, 4096, false)) { //output of "wmic /namespace:\\root\wmi PATH MSAcpi_ThermalZoneTemperature get CriticalTripPoint,CurrentTemperature,InstanceName"
if (!defined('PSI_EMU_HOSTNAME') && CommonFunctions::rftsdata('thermalzone.tmp', $lines)) { //output of "wmic /namespace:\\root\wmi PATH MSAcpi_ThermalZoneTemperature get CriticalTripPoint,CurrentTemperature,InstanceName"
$lines = trim(preg_replace('/[\x00-\x09\x0b-\x1F]/', '', $lines));
$lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
if ((($clines=count($lines)) > 1) && preg_match("/CriticalTripPoint\s+CurrentTemperature\s+InstanceName/i", $lines[0])) for ($i = 1; $i < $clines; $i++) {
54,7 → 60,6
break;
default:
$this->error->addConfigError('__construct()', '[sensor_thermalzone] ACCESS');
break;
}
}
 
81,15 → 86,27
$dev->setMax($maxvalue);
}
$this->mbinfo->setMbTemp($dev);
} else {
if ((isset($buffer['HighPrecisionTemperature']) && (($value = ($buffer['HighPrecisionTemperature'] - 2732)/10) > -100))
|| (isset($buffer['Temperature']) && (($value = ($buffer['Temperature'] - 273)) > -100))) {
$dev = new SensorDevice();
if (isset($buffer['Name']) && preg_match("/([^\\\\\. ]+)$/", $buffer['Name'], $outbuf)) {
$dev->setName('ThermalZone '.$outbuf[1]);
} else {
$dev->setName('ThermalZone THM0');
}
$dev->setValue($value);
$this->mbinfo->setMbTemp($dev);
}
}
}
} elseif (($mode == 'command') && (PSI_OS != 'WINNT') && !defined('PSI_EMU_HOSTNAME')) {
$notwas = true;
$thermalzones = glob('/sys/class/thermal/thermal_zone*/');
$thermalzones = CommonFunctions::findglob('/sys/class/thermal/thermal_zone*/');
if (is_array($thermalzones) && (count($thermalzones) > 0)) foreach ($thermalzones as $thermalzone) {
$thermalzonetemp = $thermalzone.'temp';
$temp = null;
if (CommonFunctions::rfts($thermalzonetemp, $temp, 1, 4096, false) && !is_null($temp) && (($temp = trim($temp)) != "")) {
if (CommonFunctions::rfts($thermalzonetemp, $temp, 1, 4096, false) && ($temp !== null) && (($temp = trim($temp)) != "")) {
if ($temp >= 1000) {
$div = 1000;
} elseif ($temp >= 200) {
104,7 → 121,7
$dev->setValue($temp);
 
$temp_type = null;
if (CommonFunctions::rfts($thermalzone.'type', $temp_type, 1, 4096, false) && !is_null($temp_type) && (($temp_type = trim($temp_type)) != "")) {
if (CommonFunctions::rfts($thermalzone.'type', $temp_type, 1, 4096, false) && ($temp_type !== null) && (($temp_type = trim($temp_type)) != "")) {
$dev->setName($temp_type);
} else {
$dev->setName("ThermalZone");
111,7 → 128,7
}
 
$temp_max = null;
if (CommonFunctions::rfts($thermalzone.'trip_point_0_temp', $temp_max, 1, 4096, false) && !is_null($temp_max) && (($temp_max = trim($temp_max)) != "") && ($temp_max > -40)) {
if (CommonFunctions::rfts($thermalzone.'trip_point_0_temp', $temp_max, 1, 4096, false) && ($temp_max !== null) && (($temp_max = trim($temp_max)) != "") && ($temp_max > -40)) {
$temp_max = $temp_max / $div;
if (($temp_max != 0) || ($temp != 0)) { // if non-zero values
$dev->setMax($temp_max);
125,10 → 142,10
}
}
if ($notwas) {
$thermalzones = glob('/proc/acpi/thermal_zone/TH*/temperature');
$thermalzones = (PSI_ROOT_FILESYSTEM.'/proc/acpi/thermal_zone/TH*/temperature');
if (is_array($thermalzones) && (count($thermalzones) > 0)) foreach ($thermalzones as $thermalzone) {
$temp = null;
if (CommonFunctions::rfts($thermalzone, $temp, 1, 4096, false) && !is_null($temp) && (($temp = trim($temp)) != "")) {
if (CommonFunctions::rfts($thermalzone, $temp, 1, 4096, false) && ($temp !== null) && (($temp = trim($temp)) != "")) {
$dev = new SensorDevice();
if (preg_match("/^\/proc\/acpi\/thermal_zone\/(.+)\/temperature$/", $thermalzone, $name)) {
$dev->setName("ThermalZone ".$name[1]);
148,7 → 165,7
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
* @return void
*/
public function build()
{
/web/acc/phpsysinfo/includes/mb/class.thinkpad.inc.php
19,14 → 19,14
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
* @return void
*/
public function build()
{
if ((PSI_OS == 'Linux') && !defined('PSI_EMU_HOSTNAME')) {
$hwpaths = glob("/sys/devices/platform/thinkpad_hwmon/", GLOB_NOSORT);
$hwpaths = CommonFunctions::findglob("/sys/devices/platform/thinkpad_hwmon/", GLOB_NOSORT);
if (is_array($hwpaths) && (count($hwpaths) == 1)) {
$hwpaths2 = glob("/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon*/", GLOB_NOSORT);
$hwpaths2 = CommonFunctions::findglob("/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon*/", GLOB_NOSORT);
if (is_array($hwpaths2) && (count($hwpaths2) > 0)) {
$hwpaths = array_merge($hwpaths, $hwpaths2);
}
/web/acc/phpsysinfo/includes/os/class.AIX.inc.php
26,7 → 26,14
*/
class AIX extends OS
{
/**
* uptime command result.
*/
private $_uptime = null;
 
/**
* prtconf command result.
*/
private $_aixdata = array();
 
/**
35,7 → 42,7
*/
private function _hostname()
{
/* if (PSI_USE_VHOST === true) {
/* if (PSI_USE_VHOST) {
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
} else {
if (CommonFunctions::executeProgram('hostname', '', $ret)) {
64,8 → 71,8
*/
private function _uptime()
{
if (CommonFunctions::executeProgram('uptime', '', $buf)) {
if (preg_match("/up (\d+) day[s]?,\s*(\d+):(\d+),/", $buf, $ar_buf)) {
if (($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) {
if (preg_match("/up (\d+) day[s]?,\s*(\d+):(\d+),/", $this->_uptime, $ar_buf)) {
$min = $ar_buf[3];
$hours = $ar_buf[2];
$days = $ar_buf[1];
81,8 → 88,8
*/
private function _loadavg()
{
if (CommonFunctions::executeProgram('uptime', '', $buf)) {
if (preg_match("/average: (.*), (.*), (.*)$/", $buf, $ar_buf)) {
if (($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) {
if (preg_match("/average: (.*), (.*), (.*)$/", $this->_uptime, $ar_buf)) {
$this->sys->setLoad($ar_buf[1].' '.$ar_buf[2].' '.$ar_buf[3]);
}
}
329,11 → 336,11
*
* @see PSI_Interface_OS::build()
*
* @return Void
* @return void
*/
public function build()
{
$this->error->addError("WARN", "The AIX version of phpSysInfo is a work in progress, some things currently don't work");
$this->error->addWarning("The AIX version of phpSysInfo is a work in progress, some things currently don't work");
if (!$this->blockname || $this->blockname==='vitals') {
$this->_distro();
$this->_hostname();
349,9 → 356,6
$this->_scsi();
$this->_usb();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memory();
}
358,5 → 362,8
if (!$this->blockname || $this->blockname==='filesystem') {
$this->_filesystems();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
}
}
/web/acc/phpsysinfo/includes/os/class.Android.inc.php
179,7 → 179,7
if (($lines = $this->_get_buildprop()) && preg_match('/^ro\.build\.version\.release=([^\n]+)/m', $lines, $ar_buf)) {
$buf = trim($ar_buf[1]);
}
if (is_null($buf) || ($buf == "")) {
if (($buf === null) || ($buf == "")) {
$this->sys->setDistribution('Android');
} else {
if (preg_match('/^(\d+\.\d+)/', $buf, $ver)
241,7 → 241,7
*
* @see PSI_Interface_OS::build()
*
* @return Void
* @return void
*/
public function build()
{
257,13 → 257,11
if (!$this->blockname || $this->blockname==='hardware') {
$this->_machine();
$this->_cpuinfo();
$this->_virtualizer();
$this->_pci();
$this->_usb();
$this->_i2c();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memory();
}
270,5 → 268,8
if (!$this->blockname || $this->blockname==='filesystem') {
$this->_filesystems();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
}
}
/web/acc/phpsysinfo/includes/os/class.BSDCommon.inc.php
28,6 → 28,11
abstract class BSDCommon extends OS
{
/**
* Assoc array of all CPUs loads.
*/
private $_cpu_loads = null;
 
/**
* content of the syslog
*
* @var array
210,7 → 215,7
*/
protected function hostname()
{
if (PSI_USE_VHOST === true) {
if (PSI_USE_VHOST) {
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
} else {
if (CommonFunctions::executeProgram('hostname', '', $buf, PSI_DEBUG)) {
236,18 → 241,40
}
 
/**
* Processor Load
* optionally create a loadbar
* Virtualizer info
*
* @return void
*/
protected function loadavg()
private function virtualizer()
{
$s = $this->grabkey('vm.loadavg');
$s = preg_replace('/{ /', '', $s);
$s = preg_replace('/ }/', '', $s);
$this->sys->setLoad($s);
if (PSI_LOAD_BAR) {
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
$testvirt = $this->sys->getVirtualizer();
$novm = true;
foreach ($testvirt as $virtkey=>$virtvalue) if ($virtvalue) {
$novm = false;
break;
}
// Detect QEMU cpu
if ($novm && isset($testvirt["cpuid:QEMU"])) {
$this->sys->setVirtualizer('qemu'); // QEMU
$novm = false;
}
 
if ($novm && isset($testvirt["hypervisor"])) {
$this->sys->setVirtualizer('unknown');
}
}
}
 
/**
* CPU usage
*
* @return void
*/
protected function cpuusage()
{
if (($this->_cpu_loads === null)) {
$this->_cpu_loads = array();
if (PSI_OS != 'Darwin') {
if ($fd = $this->grabkey('kern.cp_time')) {
// Find out the CPU load
262,13 → 289,17
if (preg_match($this->_CPURegExp2, $fd, $res) && (sizeof($res) > 4)) {
$load2 = $res[2] + $res[3] + $res[4];
$total2 = $res[2] + $res[3] + $res[4] + $res[5];
$this->sys->setLoadPercent((100 * ($load2 - $load)) / ($total2 - $total));
if ($total2 != $total) {
$this->_cpu_loads['cpu'] = (100 * ($load2 - $load)) / ($total2 - $total);
} else {
$this->_cpu_loads['cpu'] = 0;
}
}
}
}
} else {
$ncpu = $this->grabkey('hw.ncpu');
if (!is_null($ncpu) && (trim($ncpu) != "") && ($ncpu >= 1) && CommonFunctions::executeProgram('ps', "-A -o %cpu", $pstable, false) && !empty($pstable)) {
if (($ncpu !== "") && ($ncpu >= 1) && CommonFunctions::executeProgram('ps', "-A -o %cpu", $pstable, false) && !empty($pstable)) {
$pslines = preg_split("/\n/", $pstable, -1, PREG_SPLIT_NO_EMPTY);
if (!empty($pslines) && (count($pslines)>1) && (trim($pslines[0])==="%CPU")) {
array_shift($pslines);
276,14 → 307,38
foreach ($pslines as $psline) {
$sum+=trim($psline);
}
$this->sys->setLoadPercent(min($sum/$ncpu, 100));
$this->_cpu_loads['cpu'] = min($sum/$ncpu, 100);
}
}
}
}
 
if (isset($this->_cpu_loads['cpu'])) {
return $this->_cpu_loads['cpu'];
} else {
return null;
}
}
 
/**
* Processor Load
* optionally create a loadbar
*
* @return void
*/
protected function loadavg()
{
$s = $this->grabkey('vm.loadavg');
$s = preg_replace('/{ /', '', $s);
$s = preg_replace('/ }/', '', $s);
$this->sys->setLoad($s);
 
if (PSI_LOAD_BAR) {
$this->sys->setLoadPercent($this->cpuusage());
}
}
 
/**
* CPU information
*
* @return void
291,39 → 346,43
protected function cpuinfo()
{
$dev = new CpuDevice();
 
if (PSI_OS == 'NetBSD') {
if ($model = $this->grabkey('machdep.cpu_brand')) {
$dev->setModel($model);
}
if ($cpuspeed = $this->grabkey('machdep.tsc_freq')) {
$dev->setCpuSpeed(round($cpuspeed / 1000000));
}
$cpumodel = $this->grabkey('hw.model');
$dev->setModel($cpumodel);
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && preg_match('/^QEMU Virtual CPU version /', $cpumodel)) {
$this->sys->setVirtualizer("cpuid:QEMU", false);
}
 
if ($dev->getModel() === "") {
$dev->setModel($this->grabkey('hw.model'));
}
$notwas = true;
foreach ($this->readdmesg() as $line) {
if ($notwas) {
if (preg_match($this->_CPURegExp1, $line, $ar_buf) && (sizeof($ar_buf) > 2)) {
if ($dev->getCpuSpeed() === 0) {
$dev->setCpuSpeed(round($ar_buf[2]));
$regexps = preg_split("/\n/", $this->_CPURegExp1, -1, PREG_SPLIT_NO_EMPTY); // multiple regexp separated by \n
foreach ($regexps as $regexp) {
if (preg_match($regexp, $line, $ar_buf) && (sizeof($ar_buf) > 2)) {
if ($dev->getCpuSpeed() === 0) {
$dev->setCpuSpeed(round($ar_buf[2]));
}
$notwas = false;
break;
}
$notwas = false;
}
} else {
if (preg_match("/ Origin| Features/", $line, $ar_buf)) {
if (preg_match("/ Features2[ ]*=.*<(.*)>/", $line, $ar_buf)) {
if (preg_match("/^\s+Origin| Features/", $line, $ar_buf)) {
if (preg_match("/^\s+Origin[ ]*=[ ]*\"(.+)\"/", $line, $ar_buf)) {
$dev->setVendorId($ar_buf[1]);
} elseif (preg_match("/ Features2[ ]*=.*<(.+)>/", $line, $ar_buf)) {
$feats = preg_split("/,/", strtolower(trim($ar_buf[1])), -1, PREG_SPLIT_NO_EMPTY);
foreach ($feats as $feat) {
if (($feat=="vmx") || ($feat=="svm")) {
$dev->setVirt($feat);
break 2;
} elseif ($feat=="hv") {
if ($dev->getVirt() === null) {
$dev->setVirt('hypervisor');
}
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
$this->sys->setVirtualizer("hypervisor", false);
}
}
}
break;
}
} else break;
}
330,8 → 389,12
}
 
$ncpu = $this->grabkey('hw.ncpu');
if (is_null($ncpu) || (trim($ncpu) == "") || (!($ncpu >= 1)))
if (($ncpu === "") || !($ncpu >= 1)) {
$ncpu = 1;
}
if (($ncpu == 1) && PSI_LOAD_BAR) {
$dev->setLoad($this->cpuusage());
}
for ($ncpu ; $ncpu > 0 ; $ncpu--) {
$this->sys->setCpus($dev);
}
338,6 → 401,99
}
 
/**
* Machine information
*
* @return void
*/
private function machine()
{
if ((PSI_OS == 'NetBSD') || (PSI_OS == 'OpenBSD')) {
$buffer = array();
if (PSI_OS == 'NetBSD') { // NetBSD
$buffer['Manufacturer'] = $this->grabkey('machdep.dmi.system-vendor');
$buffer['Model'] = $this->grabkey('machdep.dmi.system-product');
$buffer['Product'] = $this->grabkey('machdep.dmi.board-product');
$buffer['SMBIOSBIOSVersion'] = $this->grabkey('machdep.dmi.bios-version');
$buffer['ReleaseDate'] = $this->grabkey('machdep.dmi.bios-date');
} else { // OpenBSD
$buffer['Manufacturer'] = $this->grabkey('hw.vendor');
$buffer['Model'] = $this->grabkey('hw.product');
$buffer['Product'] = "";
$buffer['SMBIOSBIOSVersion'] = "";
$buffer['ReleaseDate'] = "";
}
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
$vendor_array = array();
$vendor_array[] = $buffer['Model'];
$vendor_array[] = trim($buffer['Manufacturer']." ".$buffer['Model']);
if (PSI_OS == 'NetBSD') { // NetBSD
$vendor_array[] = $this->grabkey('machdep.dmi.board-vendor');
$vendor_array[] = $this->grabkey('machdep.dmi.bios-vendor');
}
$virt = CommonFunctions::decodevirtualizer($vendor_array);
if ($virt !== null) {
$this->sys->setVirtualizer($virt);
}
}
 
$buf = "";
if (($buffer['Manufacturer'] !== "") && !preg_match("/^To be filled by O\.E\.M\.$|^System manufacturer$|^Not Specified$/i", $buf2=trim($buffer['Manufacturer'])) && ($buf2 !== "")) {
$buf .= ' '.$buf2;
}
 
if (($buffer['Model'] !== "") && !preg_match("/^To be filled by O\.E\.M\.$|^System Product Name$|^Not Specified$/i", $buf2=trim($buffer['Model'])) && ($buf2 !== "")) {
$model = $buf2;
$buf .= ' '.$buf2;
}
if (($buffer['Product'] !== "") && !preg_match("/^To be filled by O\.E\.M\.$|^BaseBoard Product Name$|^Not Specified$|^Default string$/i", $buf2=trim($buffer['Product'])) && ($buf2 !== "")) {
if ($buf2 !== $model) {
$buf .= '/'.$buf2;
} elseif (isset($buffer['SystemFamily']) && !preg_match("/^To be filled by O\.E\.M\.$|^System Family$|^Not Specified$/i", $buf2=trim($buffer['SystemFamily'])) && ($buf2 !== "")) {
$buf .= '/'.$buf2;
}
}
 
$bver = "";
$brel = "";
if (($buf2=trim($buffer['SMBIOSBIOSVersion'])) !== "") {
$bver .= ' '.$buf2;
}
if ($buffer['ReleaseDate'] !== "") {
if (preg_match("/^(\d{4})(\d{2})(\d{2})$/", $buffer['ReleaseDate'], $dateout)) {
$brel .= ' '.$dateout[2].'/'.$dateout[3].'/'.$dateout[1];
} elseif (preg_match("/^\d{2}\/\d{2}\/\d{4}$/", $buffer['ReleaseDate'])) {
$brel .= ' '.$buffer['ReleaseDate'];
}
}
if ((trim($bver) !== "") || (trim($brel) !== "")) {
$buf .= ', BIOS'.$bver.$brel;
}
 
if (trim($buf) !== "") {
$this->sys->setMachine(trim($buf));
}
} elseif ((PSI_OS == 'FreeBSD') && defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
$vendorid = $this->grabkey('hw.hv_vendor');
if (trim($vendorid) === "") {
foreach ($this->readdmesg() as $line) if (preg_match("/^Hypervisor: Origin = \"(.+)\"/", $line, $ar_buf)) {
if (trim($ar_buf[1]) !== "") {
$vendorid = $ar_buf[1];
}
break;
}
}
if (trim($vendorid) !== "") {
$virt = CommonFunctions::decodevirtualizer($vendorid);
if ($virt !== null) {
$this->sys->setVirtualizer($virt);
} else {
$this->sys->setVirtualizer('unknown');
}
}
}
}
 
/**
* SCSI devices
* get the scsi device information out of dmesg
*
404,8 → 560,8
}
/* cleaning */
foreach ($this->sys->getScsiDevices() as $finddev) {
if (strpos($finddev->getName(), ': ') !== false)
$finddev->setName(substr(strstr($finddev->getName(), ': '), 2));
if (strpos($finddev->getName(), ': ') !== false)
$finddev->setName(substr(strstr($finddev->getName(), ': '), 2));
}
}
 
658,11 → 814,34
}
 
/**
* UpTime
* time the system is running
*
* @return void
*/
private function uptime()
{
if ($kb = $this->grabkey('kern.boottime')) {
if (preg_match("/sec = ([0-9]+)/", $kb, $buf)) { // format like: { sec = 1096732600, usec = 885425 } Sat Oct 2 10:56:40 2004
$this->sys->setUptime(time() - $buf[1]);
} else {
date_default_timezone_set('UTC');
$kbt = strtotime($kb);
if (($kbt !== false) && ($kbt != -1)) {
$this->sys->setUptime(time() - $kbt); // format like: Sat Oct 2 10:56:40 2004
} else {
$this->sys->setUptime(time() - $kb); // format like: 1096732600
}
}
}
}
 
/**
* get the information
*
* @see PSI_Interface_OS::build()
*
* @return Void
* @return void
*/
public function build()
{
672,9 → 851,12
$this->kernel();
$this->_users();
$this->loadavg();
$this->uptime();
}
if (!$this->blockname || $this->blockname==='hardware') {
$this->machine();
$this->cpuinfo();
$this->virtualizer();
$this->pci();
$this->ide();
$this->scsi();
/web/acc/phpsysinfo/includes/os/class.Darwin.inc.php
90,25 → 90,6
}
 
/**
* UpTime
* time the system is running
*
* @return void
*/
private function _uptime()
{
if (CommonFunctions::executeProgram('sysctl', '-n kern.boottime', $a, PSI_DEBUG)) {
$tmp = explode(" ", $a);
if ($tmp[0]=="{") { /* kern.boottime= { sec = 1096732600, usec = 885425 } Sat Oct 2 10:56:40 2004 */
$data = trim($tmp[3], ",");
$this->sys->setUptime(time() - $data);
} else { /* kern.boottime= 1096732600 */
$this->sys->setUptime(time() - $a);
}
}
}
 
/**
* get CPU information
*
* @return void
119,9 → 100,9
if (CommonFunctions::executeProgram('hostinfo', '| grep "Processor type"', $buf, PSI_DEBUG)) {
$dev->setModel(preg_replace('/Processor type: /', '', $buf));
$buf=$this->grabkey('hw.model');
if (!is_null($buf) && (trim($buf) != "")) {
if (($buf !== null) && (trim($buf) != "")) {
$this->sys->setMachine(trim($buf));
if (CommonFunctions::rfts(PSI_APP_ROOT.'/data/ModelTranslation.txt', $buffer)) {
if (CommonFunctions::rftsdata('ModelTranslation.txt', $buffer)) {
$buffer = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
foreach ($buffer as $line) {
$ar_buf = preg_split("/:/", $line, 3);
134,12 → 115,12
}
}
$buf=$this->grabkey('machdep.cpu.brand_string');
if (!is_null($buf) && (trim($buf) != "") &&
if (($buf !== null) && (trim($buf) != "") &&
((trim($buf) != "i486 (Intel 80486)") || ($dev->getModel() == ""))) {
$dev->setModel(trim($buf));
}
$buf=$this->grabkey('machdep.cpu.features');
if (!is_null($buf) && (trim($buf) != "")) {
if (($buf !== null) && (trim($buf) != "")) {
if (preg_match("/ VMX/", $buf)) {
$dev->setVirt("vmx");
} elseif (preg_match("/ SVM/", $buf)) {
151,17 → 132,21
$dev->setBusSpeed(round($this->grabkey('hw.busfrequency') / 1000000));
$bufn=$this->grabkey('hw.cpufrequency_min');
$bufx=$this->grabkey('hw.cpufrequency_max');
if (!is_null($bufn) && (trim($bufn) != "") && !is_null($bufx) && (trim($bufx) != "") && ($bufn != $bufx)) {
if (($bufn !== null) && (trim($bufn) != "") && ($bufx !== null) && (trim($bufx) != "") && ($bufn != $bufx)) {
$dev->setCpuSpeedMin(round($bufn / 1000000));
$dev->setCpuSpeedMax(round($bufx / 1000000));
}
$buf=$this->grabkey('hw.l2cachesize');
if (!is_null($buf) && (trim($buf) != "")) {
if ($buf !== "") {
$dev->setCache(round($buf));
}
$ncpu = $this->grabkey('hw.ncpu');
if (is_null($ncpu) || (trim($ncpu) == "") || (!($ncpu >= 1)))
if (($ncpu === "") || !($ncpu >= 1)) {
$ncpu = 1;
}
if (($ncpu == 1) && PSI_LOAD_BAR) {
$dev->setLoad($this->cpuusage());
}
for ($ncpu ; $ncpu > 0 ; $ncpu--) {
$this->sys->setCpus($dev);
}
422,8 → 407,8
$distro_tmp = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
foreach ($distro_tmp as $info) {
$info_tmp = preg_split('/:/', $info, 2);
if (isset($distro_tmp[0]) && !is_null($distro_tmp[0]) && (trim($distro_tmp[0]) != "") &&
isset($distro_tmp[1]) && !is_null($distro_tmp[1]) && (trim($distro_tmp[1]) != "")) {
if (isset($distro_tmp[0]) && ($distro_tmp[0] !== null) && (trim($distro_tmp[0]) != "") &&
isset($distro_tmp[1]) && ($distro_tmp[1] !== null) && (trim($distro_tmp[1]) != "")) {
$distro_arr[trim($info_tmp[0])] = trim($info_tmp[1]);
}
}
485,13 → 470,12
*
* @see PSI_Interface_OS::build()
*
* @return Void
* @return void
*/
public function build()
{
parent::build();
if (!$this->blockname || $this->blockname==='vitals') {
$this->_uptime();
$this->_processes();
}
if (!$this->blockname || $this->blockname==='hardware') {
/web/acc/phpsysinfo/includes/os/class.DragonFly.inc.php
32,7 → 32,7
public function __construct($blockname = false)
{
parent::__construct($blockname);
$this->setCPURegExp1("/^cpu(.*)\, (.*) MHz/");
$this->setCPURegExp1("/^cpu(.*)\, (.*) MHz/\n/^CPU: (.*) \((.*)-MHz (.*)\)/"); // multiple regexp separated by \n
$this->setCPURegExp2("/^(.*) at scsibus.*: <(.*)> .*/");
$this->setSCSIRegExp2("/^(da[0-9]+): (.*)MB /");
$this->setPCIRegExp1("/(.*): <(.*)>(.*) (pci|legacypci)[0-9]+$/");
40,19 → 40,6
}
 
/**
* UpTime
* time the system is running
*
* @return void
*/
private function _uptime()
{
$a = $this->grabkey('kern.boottime');
preg_match("/sec = ([0-9]+)/", $a, $buf);
$this->sys->setUptime(time() - $buf[1]);
}
 
/**
* get network information
*
* @return void
140,7 → 127,7
*
* @see BSDCommon::build()
*
* @return Void
* @return void
*/
public function build()
{
147,7 → 134,6
parent::build();
if (!$this->blockname || $this->blockname==='vitals') {
$this->_distroicon();
$this->_uptime();
$this->_processes();
}
if (!$this->blockname || $this->blockname==='network') {
/web/acc/phpsysinfo/includes/os/class.FreeBSD.inc.php
42,19 → 42,6
}
 
/**
* UpTime
* time the system is running
*
* @return void
*/
private function _uptime()
{
$s = preg_split('/ /', $this->grabkey('kern.boottime'));
$a = preg_replace('/,/', '', $s[3]);
$this->sys->setUptime(time() - $a);
}
 
/**
* get network information
*
* @return void
195,7 → 182,7
*
* @see BSDCommon::build()
*
* @return Void
* @return void
*/
public function build()
{
202,14 → 189,13
parent::build();
if (!$this->blockname || $this->blockname==='vitals') {
$this->_distroicon();
$this->_uptime();
$this->_processes();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memoryadditional();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memoryadditional();
}
}
}
/web/acc/phpsysinfo/includes/os/class.HPUX.inc.php
27,6 → 27,11
class HPUX extends OS
{
/**
* uptime command result.
*/
private $_uptime = null;
 
/**
* Virtual Host Name
*
* @return void
33,7 → 38,7
*/
private function _hostname()
{
if (PSI_USE_VHOST === true) {
if (PSI_USE_VHOST) {
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
} else {
if (CommonFunctions::executeProgram('hostname', '', $ret)) {
62,8 → 67,8
*/
private function _uptime()
{
if (CommonFunctions::executeProgram('uptime', '', $buf)) {
if (preg_match("/up (\d+) days,\s*(\d+):(\d+),/", $buf, $ar_buf)) {
if (($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) {
if (preg_match("/up (\d+) days,\s*(\d+):(\d+),/", $this->_uptime, $ar_buf)) {
$min = $ar_buf[3];
$hours = $ar_buf[2];
$days = $ar_buf[1];
80,8 → 85,8
*/
private function _loadavg()
{
if (CommonFunctions::executeProgram('uptime', '', $buf)) {
if (preg_match("/average: (.*), (.*), (.*)$/", $buf, $ar_buf)) {
if (($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) {
if (preg_match("/average: (.*), (.*), (.*)$/", $this->_uptime, $ar_buf)) {
$this->sys->setLoad($ar_buf[1].' '.$ar_buf[2].' '.$ar_buf[3]);
}
}
125,7 → 130,6
case 'bogomips':
case 'cpu0bogo':
$dev->setBogomips($arrBuff[1]);
break;
}
}
}
358,7 → 362,7
*
* @see PSI_Interface_OS::build()
*
* @return Void
* @return void
*/
public function build()
{
377,9 → 381,6
$this->_scsi();
$this->_usb();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memory();
}
386,5 → 387,8
if (!$this->blockname || $this->blockname==='filesystem') {
$this->_filesystems();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
}
}
/web/acc/phpsysinfo/includes/os/class.Haiku.inc.php
217,7 → 217,7
*/
private function _hostname()
{
if (PSI_USE_VHOST === true) {
if (PSI_USE_VHOST) {
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
} else {
if (CommonFunctions::executeProgram('uname', '-n', $result, PSI_DEBUG)) {
368,11 → 368,11
/**
* get the information
*
* @return Void
* @return void
*/
public function build()
{
$this->error->addError("WARN", "The Haiku version of phpSysInfo is a work in progress, some things currently don't work");
$this->error->addWarning("The Haiku version of phpSysInfo is a work in progress, some things currently don't work");
if (!$this->blockname || $this->blockname==='vitals') {
$this->_distro();
$this->_hostname();
387,9 → 387,6
$this->_pci();
$this->_usb();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memory();
}
396,5 → 393,8
if (!$this->blockname || $this->blockname==='filesystem') {
$this->_filesystems();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
}
}
/web/acc/phpsysinfo/includes/os/class.Linux.inc.php
27,55 → 27,231
class Linux extends OS
{
/**
* Uptime command result.
*/
private $_uptime = null;
 
/**
* Assoc array of all CPUs loads.
*/
private $_cpu_loads = null;
 
/**
* Machine
*
* @return void
* Version string.
*/
private function _machine()
private $_kernel_string = null;
 
/**
* Array of info from Bios.
*/
private $_machine_info = null;
 
/**
* Array of info from dmesg.
*/
private $_dmesg_info = null;
 
/**
* Result of systemd-detect-virt.
*/
private $system_detect_virt = null;
 
/**
* Get info from dmesg
*
* @return array
*/
private function _get_dmesg_info()
{
$machine = "";
if ((CommonFunctions::rfts('/var/log/dmesg', $result, 0, 4096, false)
&& preg_match('/^[\s\[\]\.\d]*DMI:\s*(.*)/m', $result, $ar_buf))
||(CommonFunctions::executeProgram('dmesg', '', $result, false)
&& preg_match('/^[\s\[\]\.\d]*DMI:\s*(.*)/m', $result, $ar_buf))) {
$machine = trim($ar_buf[1]);
} else { //data from /sys/devices/virtual/dmi/id/
$product = "";
$board = "";
$bios = "";
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/board_vendor', $buf, 1, 4096, false) && (trim($buf)!="")) {
$machine = trim($buf);
if ($this->_dmesg_info === null) {
$this->_dmesg_info = array();
if (CommonFunctions::rfts('/var/log/dmesg', $result, 0, 4096, false)) {
if (preg_match('/^[\s\[\]\.\d]*DMI:\s*(.+)/m', $result, $ar_buf)) {
$this->_dmesg_info['dmi'] = trim($ar_buf[1]);
}
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null) && preg_match('/^[\s\[\]\.\d]*Hypervisor detected:\s*(.+)/m', $result, $ar_buf)) {
$this->_dmesg_info['hypervisor'] = trim($ar_buf[1]);
}
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/product_name', $buf, 1, 4096, false) && (trim($buf)!="")) {
$product = trim($buf);
if ((count($this->_dmesg_info) < ((defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null))?2:1)) && CommonFunctions::executeProgram('dmesg', '', $result, false)) {
if (!isset($this->_dmesg_info['dmi']) && preg_match('/^[\s\[\]\.\d]*DMI:\s*(.+)/m', $result, $ar_buf)) {
$this->_dmesg_info['dmi'] = trim($ar_buf[1]);
}
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null) && !isset($this->_dmesg_info['hypervisor']) && preg_match('/^[\s\[\]\.\d]*Hypervisor detected:\s*(.+)/m', $result, $ar_buf)) {
$this->_dmesg_info['hypervisor'] = trim($ar_buf[1]);
}
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/board_name', $buf, 1, 4096, false) && (trim($buf)!="")) {
$board = trim($buf);
}
 
return $this->_dmesg_info;
}
 
/**
* Get machine info
*
* @return string
*/
private function _get_machine_info()
{
if ($this->_machine_info === null) {
$this->_machine_info = array();
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
if (CommonFunctions::executeProgram('systemd-detect-virt', '-v', $resultv, false)) {
$this->system_detect_virt = $resultv;
}
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/bios_version', $buf, 1, 4096, false) && (trim($buf)!="")) {
$bios = trim($buf);
$vendor_array = array();
if ((($dmesg = $this->_get_dmesg_info()) !== null) && isset($dmesg['dmi'])) {
$this->_machine_info['machine'] = $dmesg['dmi'];
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null)) {
/* Test this before sys_vendor to detect KVM over QEMU */
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/product_name', $buf, 1, 4096, false) && (trim($buf)!="")) {
$vendor_array[] = $product_name = trim($buf);
} else {
$product_name = '';
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/sys_vendor', $buf, 1, 4096, false) && (trim($buf)!="")) {
$vendor_array[] = trim($buf);
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/board_vendor', $buf, 1, 4096, false) && (trim($buf)!="")) {
if ($product_name != "") {
$vendor_array[] = trim($buf)." ".$product_name;
} else {
$vendor_array[] = trim($buf);
}
} else {
$vendor_array[] = $dmesg['dmi'];
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/bios_vendor', $buf, 1, 4096, false) && (trim($buf)!="")) {
$vendor_array[] = trim($buf);
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/product_version', $buf, 1, 4096, false) && (trim($buf)!="")) {
$vendor_array[] = trim($buf);
}
}
} else { // 'machine' data from /sys/devices/virtual/dmi/id/
$bios = "";
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null)) {
// Test this before sys_vendor to detect KVM over QEMU
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/product_name', $buf, 1, 4096, false) && (trim($buf)!="")) {
$vendor_array[] = $product_name = trim($buf);
} else {
$product_name = '';
}
 
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/sys_vendor', $buf, 1, 4096, false) && (trim($buf)!="")) {
$vendor_array[] = trim($buf);
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/board_vendor', $buf, 1, 4096, false) && (trim($buf)!="")) {
if ($product_name != "") {
$this->_machine_info['machine'] = trim($buf)." ".$product_name;
} else {
$this->_machine_info['machine'] = trim($buf);
}
$vendor_array[] = $this->_machine_info["machine"];
} elseif ($product_name != "") {
$this->_machine_info['machine'] = $product_name;
}
 
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/bios_vendor', $buf, 1, 4096, false) && (trim($buf)!="")) {
$vendor_array[] = trim($buf);
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/product_version', $buf, 1, 4096, false) && (trim($buf)!="")) {
$vendor_array[] = trim($buf);
}
} else {
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/board_vendor', $buf, 1, 4096, false) && (trim($buf)!="")) {
$this->_machine_info['machine'] = trim($buf);
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/product_name', $buf, 1, 4096, false) && (trim($buf)!="")) {
if (isset($this->_machine_info['machine'])) {
$this->_machine_info['machine'] .= " ".trim($buf);
} else {
$this->_machine_info['machine'] = trim($buf);
}
}
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/board_name', $buf, 1, 4096, false) && (trim($buf)!="")) {
if (isset($this->_machine_info['machine'])) {
$this->_machine_info['machine'] .= "/".trim($buf);
} else {
$this->_machine_info['machine'] = trim($buf);
}
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/bios_version', $buf, 1, 4096, false) && (trim($buf)!="")) {
$bios = trim($buf);
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/bios_date', $buf, 1, 4096, false) && (trim($buf)!="")) {
$bios = trim($bios." ".trim($buf));
}
if ($bios != "") {
if (isset($this->_machine_info['machine'])) {
$this->_machine_info['machine'] .= ", BIOS ".$bios;
} else {
$this->_machine_info['machine'] = "BIOS ".$bios;
}
}
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/bios_date', $buf, 1, 4096, false) && (trim($buf)!="")) {
$bios = trim($bios." ".trim($buf));
if (isset($this->_machine_info['machine'])) {
$this->_machine_info['machine'] = trim(preg_replace("/^\/,?/", "", preg_replace("/ ?(To be filled by O\.E\.M\.|System manufacturer|System Product Name|Not Specified|Default string) ?/i", "", $this->_machine_info['machine'])));
}
if ($product != "") {
$machine .= " ".$product;
 
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null) && count($vendor_array)>0) {
$virt = CommonFunctions::decodevirtualizer($vendor_array);
if ($virt !== null) {
$this->_machine_info['hypervisor'] = $virt;
}
}
if ($board != "") {
$machine .= "/".$board;
}
 
return $this->_machine_info;
}
 
/**
* Get kernel string
*
* @return string
*/
private function _get_kernel_string()
{
if ($this->_kernel_string === null) {
$this->_kernel_string = "";
if (CommonFunctions::executeProgram($uname="uptrack-uname", '-r', $strBuf, false) || // show effective kernel if ksplice uptrack is installed
CommonFunctions::executeProgram($uname="uname", '-r', $strBuf, PSI_DEBUG)) {
$this->_kernel_string = $strBuf;
if (CommonFunctions::executeProgram($uname, '-v', $strBuf, PSI_DEBUG)) {
if (preg_match('/ SMP /', $strBuf)) {
$this->_kernel_string .= ' (SMP)';
}
}
if (CommonFunctions::executeProgram($uname, '-m', $strBuf, PSI_DEBUG)) {
$this->_kernel_string .= ' '.$strBuf;
}
} elseif (CommonFunctions::rfts('/proc/version', $strBuf, 1)) {
if (preg_match('/version\s+(\S+)/', $strBuf, $ar_buf)) {
$this->_kernel_string = $ar_buf[1];
if (preg_match('/ SMP /', $strBuf)) {
$this->_kernel_string .= ' (SMP)';
}
}
}
if ($bios != "") {
$machine .= ", BIOS ".$bios;
}
}
 
if ($machine != "") {
$machine = trim(preg_replace("/^\/,?/", "", preg_replace("/ ?(To be filled by O\.E\.M\.|System manufacturer|System Product Name|Not Specified|Default string) ?/i", "", $machine)));
return $this->_kernel_string;
}
 
/**
* Machine
*
* @return void
*/
private function _machine()
{
$machine_info = $this->_get_machine_info();
if (isset($machine_info['machine'])) {
$machine = $machine_info['machine'];
} else {
$machine = "";
}
 
if (CommonFunctions::fileexists($filename="/etc/config/uLinux.conf") // QNAP detection
84,7 → 260,7
&& CommonFunctions::fileexists($filename="/etc/platform.conf") // Platform detection
&& CommonFunctions::rfts($filename, $buf, 0, 4096, false)
&& preg_match("/^DISPLAY_NAME\s*=\s*(\S+)/m", $buf, $mach_buf) && ($mach_buf[1]!=="")) {
if ($machine != "") {
if ($machine !== "") {
$machine = "QNAP ".$mach_buf[1].' - '.$machine;
} else {
$machine = "QNAP ".$mach_buf[1];
91,7 → 267,7
}
}
 
if ($machine != "") {
if ($machine !== "") {
$this->sys->setMachine($machine);
}
}
103,7 → 279,7
*/
protected function _hostname()
{
if (PSI_USE_VHOST === true) {
if (PSI_USE_VHOST) {
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
} else {
if (CommonFunctions::rfts('/proc/sys/kernel/hostname', $result, 1, 4096, PSI_DEBUG && (PSI_OS != 'Android'))) {
115,7 → 291,6
} elseif (CommonFunctions::executeProgram('hostname', '', $ret)) {
$this->sys->setHostname($ret);
}
 
}
}
 
126,42 → 301,216
*/
private function _kernel()
{
$result = "";
if (CommonFunctions::executeProgram($uname="uptrack-uname", '-r', $strBuf, false) || // show effective kernel if ksplice uptrack is installed
CommonFunctions::executeProgram($uname="uname", '-r', $strBuf, PSI_DEBUG)) {
$result = $strBuf;
if (CommonFunctions::executeProgram($uname, '-v', $strBuf, PSI_DEBUG)) {
if (preg_match('/SMP/', $strBuf)) {
$result .= ' (SMP)';
if (($verBuf = $this->_get_kernel_string()) != "") {
$this->sys->setKernel($verBuf);
}
}
 
/**
* Virtualizer info
*
* @return void
*/
protected function _virtualizer()
{
if (!defined('PSI_SHOW_VIRTUALIZER_INFO') || !PSI_SHOW_VIRTUALIZER_INFO) {
return;
}
if ($this->system_detect_virt !== null) {
if (($this->system_detect_virt !== "") && ($this->system_detect_virt !== "none")) {
$this->sys->setVirtualizer($this->system_detect_virt);
}
if (($verBuf = $this->_get_kernel_string()) !== "") {
if (preg_match('/^[\d\.-]+-microsoft-standard/', $verBuf)) {
$this->sys->setVirtualizer('wsl2', 'wsl'); // Windows Subsystem for Linux 2
}
}
if (CommonFunctions::executeProgram($uname, '-m', $strBuf, PSI_DEBUG)) {
$result .= ' '.$strBuf;
if (CommonFunctions::executeProgram('systemd-detect-virt', '-c', $resultc, false) && ($resultc !== "") && ($resultc !== "none")) {
$this->sys->setVirtualizer($resultc);
}
} elseif (CommonFunctions::rfts('/proc/version', $strBuf, 1) && preg_match('/version\s+(\S+)/', $strBuf, $ar_buf)) {
$result = $ar_buf[1];
if (preg_match('/SMP/', $strBuf)) {
$result .= ' (SMP)';
} else {
$cpuvirt = $this->sys->getVirtualizer(); // previous info from _cpuinfo()
 
$novm = true;
// code based on src/basic/virt.c from systemd-detect-virt source code (https://github.com/systemd/systemd)
 
// First, try to detect Oracle Virtualbox and Amazon EC2 Nitro, even if they use KVM, as well as Xen even if
// it cloaks as Microsoft Hyper-V. Attempt to detect uml at this stage also since it runs as a user-process
// nested inside other VMs. Also check for Xen now, because Xen PV mode does not override CPUID when nested
// inside another hypervisor.
$machine_info = $this->_get_machine_info();
if (isset($machine_info['hypervisor'])) {
$hypervisor = $machine_info['hypervisor'];
if (($hypervisor === 'oracle') || ($hypervisor === 'amazon') || ($hypervisor === 'xen')) {
$this->sys->setVirtualizer($hypervisor);
$novm = false;
}
}
}
if ($result != "") {
 
// Detect UML
if ($novm) {
if (isset($cpuvirt["cpuid:UserModeLinux"])) {
$this->sys->setVirtualizer('uml'); // User-mode Linux
$novm = false;
}
}
 
// Detect Xen
if ($novm && is_dir('/proc/xen')) {
// xen Dom0 is detected as XEN in hypervisor and maybe others.
// In order to detect the Dom0 as not virtualization we need to
// double-check it
if (CommonFunctions::rfts('/sys/hypervisor/properties/features', $features, 1, 4096, false)) {
if ((hexdec($features) & 2048) == 0) { // XENFEAT_dom0 is not set
$this->sys->setVirtualizer('xen'); // Xen hypervisor (only domU, not dom0)
$novm = false;
}
} elseif (CommonFunctions::rfts('/proc/xen/capabilities', $capabilities, 1, 4096, false) && !preg_match('/control_d/', $capabilities)) { // control_d not in capabilities
$this->sys->setVirtualizer('xen'); // Xen hypervisor (only domU, not dom0)
$novm = false;
}
}
 
// Second, try to detect from CPUID, this will report KVM for whatever software is used even if info in DMI is overwritten.
// Since the vendor_id in /proc/cpuinfo is overwritten on virtualization we use values from msr-cpuid.
if ($novm && CommonFunctions::executeProgram('msr-cpuid', '', $bufr, false)
&& (preg_match('/^40000000 00000000: [0-9a-f]{8} \S{4} [0-9a-f]{8} ([A-Za-z0-9\.]{4}) [0-9a-f]{8} ([A-Za-z0-9\.]{4}) [0-9a-f]{8} ([A-Za-z0-9\.]{4})/m', $bufr, $cpuid))) {
$virt = CommonFunctions::decodevirtualizer($cpuid[1].$cpuid[2].$cpuid[3]);
if ($virt !== null) {
$this->sys->setVirtualizer($virt);
}
}
 
// Third, try to detect from DMI.
if ($novm && isset($hypervisor)) {
$this->sys->setVirtualizer($hypervisor);
$novm = false;
}
 
// Check high-level hypervisor sysfs file
if ($novm && CommonFunctions::rfts('/sys/hypervisor/type', $type, 1, 4096, false) && ($type === "xen")) {
$this->sys->setVirtualizer('xen'); // Xen hypervisor
$novm = false;
}
 
if ($novm) {
if (CommonFunctions::rfts('/proc/device-tree/hypervisor/compatible', $compatible, 1, 4096, false)) {
switch ($compatible) {
case 'linux,kvm':
$this->sys->setVirtualizer('kvm'); // KVM
$novm = false;
break;
case 'vmware':
$this->sys->setVirtualizer('vmware'); // VMware
$novm = false;
break;
case 'xen':
$this->sys->setVirtualizer('xen'); // Xen hypervisor
$novm = false;
}
} else {
if (CommonFunctions::fileexists('/proc/device-tree/ibm,partition-name')
&& CommonFunctions::fileexists('/proc/device-tree/hmc-managed?')
&& CommonFunctions::fileexists('/proc/device-tree/chosen/qemu,graphic-width')) {
$this->sys->setVirtualizer('powervm'); // IBM PowerVM hypervisor
$novm = false;
} else {
$names = CommonFunctions::findglob('/proc/device-tree', GLOB_NOSORT);
if (is_array($names) && (($total = count($names)) > 0)) {
for ($i = 0; $i < $total; $i++) {
if (preg_match('/fw-cfg/', $names[$i])) {
$this->sys->setVirtualizer('qemu'); // QEMU
$novm = false;
break;
}
}
}
}
}
}
 
if ($novm && CommonFunctions::rfts('/proc/sysinfo', $sysinfo, 0, 4096, false) && preg_match('//VM00 Control Program:\s*(\S+)/m', $sysinfo, $vcp)) {
if ($vcp[1] === 'z/VM') {
$this->sys->setVirtualizer('zvm'); // s390 z/VM
} else {
$this->sys->setVirtualizer('kvm'); // KVM
}
$novm = false;
}
 
// Additional tests outside of the systemd-detect-virt source code
if ($novm && (($dmesg = $this->_get_dmesg_info()) !== null) && isset($dmesg['hypervisor'])) {
switch ($dmesg['hypervisor']) {
case 'VMware':
$this->sys->setVirtualizer('vmware'); // VMware
$novm = false;
break;
case 'KVM':
$this->sys->setVirtualizer('kvm'); // KVM
$novm = false;
break;
case 'Microsoft HyperV':
case 'Microsoft Hyper-V':
$this->sys->setVirtualizer('microsoft'); // Hyper-V
$novm = false;
break;
case 'ACRN':
$this->sys->setVirtualizer('acrn'); // ACRN hypervisor
$novm = false;
break;
case 'Jailhouse':
$this->sys->setVirtualizer('jailhouse'); // Jailhouse
$novm = false;
break;
case 'Xen':
case 'Xen PV':
case 'Xen HVM':
// xen Dom0 is detected as XEN in hypervisor and maybe others.
// In order to detect the Dom0 as not virtualization we need to
// double-check it
if (CommonFunctions::rfts('/sys/hypervisor/properties/features', $features, 1, 4096, false)) {
if ((hexdec($features) & 2048) == 0) { // XENFEAT_dom0 is not set
$this->sys->setVirtualizer('xen'); // Xen hypervisor (only domU, not dom0)
$novm = false;
}
} elseif (CommonFunctions::rfts('/proc/xen/capabilities', $capabilities, 1, 4096, false) && !preg_match('/control_d/', $capabilities)) { // control_d not in capabilities
$this->sys->setVirtualizer('xen'); // Xen hypervisor (only domU, not dom0)
$novm = false;
}
}
}
 
// Detect QEMU cpu
if ($novm && isset($cpuvirt["cpuid:QEMU"])) {
$this->sys->setVirtualizer('qemu'); // QEMU
$novm = false;
}
 
if ($novm && isset($cpuvirt["hypervisor"])) {
$this->sys->setVirtualizer('unknown');
}
 
if ((count(CommonFunctions::gdc('/proc/vz', false)) == 0) && (count(CommonFunctions::gdc('/proc/bc', false)) > 0)) {
$this->sys->setVirtualizer('openvz'); // OpenVZ/Virtuozzo
}
 
if (($verBuf = $this->_get_kernel_string()) !== "") {
if (preg_match('/^[\d\.-]+-Microsoft/', $verBuf)) {
$this->sys->setVirtualizer('wsl'); // Windows Subsystem for Linux
} elseif (preg_match('/^[\d\.-]+-microsoft-standard/', $verBuf)) {
$this->sys->setVirtualizer('wsl2'); // Windows Subsystem for Linux 2
}
}
 
if (CommonFunctions::rfts('/proc/self/cgroup', $strBuf2, 0, 4096, false)) {
if (preg_match('/:\/lxc\//m', $strBuf2)) {
$result .= ' [lxc]';
if (preg_match('/:\/lxc\//m', $strBuf2)) {
$this->sys->setVirtualizer('lxc'); // Linux container
} elseif (preg_match('/:\/docker\//m', $strBuf2)) {
$result .= ' [docker]';
$this->sys->setVirtualizer('docker'); // Docker
} elseif (preg_match('/:\/system\.slice\/docker\-/m', $strBuf2)) {
$result .= ' [docker]';
$this->sys->setVirtualizer('docker'); // Docker
}
}
if (CommonFunctions::rfts('/proc/version', $strBuf2, 1, 4096, false)) {
if (preg_match('/^Linux version [\d\.-]+-Microsoft/', $strBuf2)) {
$result .= ' [wsl]';
} elseif (preg_match('/^Linux version [\d\.-]+-microsoft-standard/', $strBuf2)) {
$result .= ' [wsl2]';
}
}
$this->sys->setKernel($result);
}
}
 
176,21 → 525,21
if (CommonFunctions::rfts('/proc/uptime', $buf, 1, 4096, PSI_OS != 'Android')) {
$ar_buf = preg_split('/ /', $buf);
$this->sys->setUptime(trim($ar_buf[0]));
} elseif (CommonFunctions::executeProgram('uptime', '', $buf)) {
if (preg_match("/up (\d+) day[s]?,[ ]+(\d+):(\d+),/", $buf, $ar_buf)) {
} elseif (($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) {
if (preg_match("/up (\d+) day[s]?,[ ]+(\d+):(\d+),/", $this->_uptime, $ar_buf)) {
$min = $ar_buf[3];
$hours = $ar_buf[2];
$days = $ar_buf[1];
$this->sys->setUptime($days * 86400 + $hours * 3600 + $min * 60);
} elseif (preg_match("/up (\d+) day[s]?,[ ]+(\d+) min,/", $buf, $ar_buf)) {
} elseif (preg_match("/up (\d+) day[s]?,[ ]+(\d+) min,/", $this->_uptime, $ar_buf)) {
$min = $ar_buf[2];
$days = $ar_buf[1];
$this->sys->setUptime($days * 86400 + $min * 60);
} elseif (preg_match("/up[ ]+(\d+):(\d+),/", $buf, $ar_buf)) {
} elseif (preg_match("/up[ ]+(\d+):(\d+),/", $this->_uptime, $ar_buf)) {
$min = $ar_buf[2];
$hours = $ar_buf[1];
$this->sys->setUptime($hours * 3600 + $min * 60);
} elseif (preg_match("/up[ ]+(\d+) min,/", $buf, $ar_buf)) {
} elseif (preg_match("/up[ ]+(\d+) min,/", $this->_uptime, $ar_buf)) {
$min = $ar_buf[1];
$this->sys->setUptime($min * 60);
}
210,7 → 559,7
// don't need the extra values, only first three
unset($result[3]);
$this->sys->setLoad(implode(' ', $result));
} elseif (CommonFunctions::executeProgram('uptime', '', $buf) && preg_match("/load average: (.*), (.*), (.*)$/", $buf, $ar_buf)) {
} elseif ((($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) && preg_match("/load average: (.*), (.*), (.*)$/", $this->_uptime, $ar_buf)) {
$this->sys->setLoad($ar_buf[1].' '.$ar_buf[2].' '.$ar_buf[3]);
}
if (PSI_LOAD_BAR) {
223,11 → 572,11
*
* @param String $cpuline cpu for which load should be meassured
*
* @return Integer
* @return int
*/
protected function _parseProcStat($cpuline)
{
if (is_null($this->_cpu_loads)) {
if ($this->_cpu_loads === null) {
$this->_cpu_loads = array();
 
$cpu_tmp = array();
295,6 → 644,7
protected function _cpuinfo()
{
if (CommonFunctions::rfts('/proc/cpuinfo', $bufr)) {
 
$cpulist = null;
$raslist = null;
 
318,6 → 668,7
$_arch = null;
$_impl = null;
$_part = null;
$_vari = null;
$_hard = null;
$_revi = null;
$_cpus = null;
340,6 → 691,9
case 'cpu part':
$_part = $arrBuff1;
break;
case 'cpu variant':
$_vari = $arrBuff1;
break;
case 'hardware':
$_hard = $arrBuff1;
break;
361,9 → 715,9
break;
case 'vendor_id':
$_vend = $arrBuff1;
break;
case 'cpu':
$procname = $arrBuff1;
break;
}
}
}
377,6 → 731,7
$arch = null;
$impl = null;
$part = null;
$vari = null;
$dev = new CpuDevice();
$details = preg_split("/\n/", $processor, -1, PREG_SPLIT_NO_EMPTY);
foreach ($details as $detail) {
386,7 → 741,7
case 'processor':
$proc = $arrBuff1;
if (is_numeric($proc)) {
if (strlen($procname)>0) {
if (($procname !== null) && (strlen($procname)>0)) {
$dev->setModel($procname);
}
} else {
402,13 → 757,13
break;
case 'cpu mhz':
case 'clock':
if ($arrBuff1 > 0) { //openSUSE fix
if ($arrBuff1 > 0) { // openSUSE fix
$dev->setCpuSpeed($arrBuff1);
$speedset = true;
}
break;
case 'cpu mhz static':
if ($arrBuff1 > 0) { //openSUSE fix
if ($arrBuff1 > 0) { // openSUSE fix
$dev->setCpuSpeedMax($arrBuff1);
}
break;
434,9 → 789,15
$dev->setVirt("vmx");
} elseif (preg_match("/ svm/", $arrBuff1)) {
$dev->setVirt("svm");
} elseif (preg_match("/ hypervisor/", $arrBuff1)) {
$dev->setVirt("hypervisor");
}
if (preg_match("/ hypervisor/", $arrBuff1)) {
if ($dev->getVirt() === null) {
$dev->setVirt("hypervisor");
}
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null)) {
$this->sys->setVirtualizer("hypervisor", false);
}
}
break;
case 'i size':
case 'd size':
455,9 → 816,14
case 'cpu part':
$part = $arrBuff1;
break;
case 'cpu variant':
$vari = $arrBuff1;
break;
case 'vendor_id':
$dev->setVendorId($arrBuff1);
break;
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && preg_match('/^User Mode Linux/', $arrBuff1)) {
$this->sys->setVirtualizer("cpuid:UserModeLinux", false);
}
}
}
}
464,6 → 830,7
if ($arch === null) $arch = $_arch;
if ($impl === null) $impl = $_impl;
if ($part === null) $part = $_part;
if ($vari === null) $vari = $_vari;
 
// sparc64 specific code follows
// This adds the ability to display the cache that a CPU has
478,8 → 845,8
// sparc64 specific code ends
 
// XScale detection code
if (($arch === "5TE") && ($dev->getBogomips() != null)) {
$dev->setCpuSpeed($dev->getBogomips()); //BogoMIPS are not BogoMIPS on this CPU, it's the speed
if (($arch === "5TE") && ($dev->getBogomips() !== null)) {
$dev->setCpuSpeed($dev->getBogomips()); // BogoMIPS are not BogoMIPS on this CPU, it's the speed
$speedset = true;
$dev->setBogomips(null); // no BogoMIPS available, unset previously set BogoMIPS
}
496,9 → 863,12
}
if (($dev->getVendorId() === null) && ($_vend !== null)) {
$dev->setVendorId($_vend);
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && preg_match('/^User Mode Linux/', $_vend)) {
$this->sys->setVirtualizer("cpuid:UserModeLinux", false);
}
}
 
if ($proc != null) {
if ($proc !== null) {
if (!is_numeric($proc)) {
$proc = 0;
}
561,11 → 931,12
$this->sys->setMachine($_hard);
}
if ($cpulist === null) $cpulist = @parse_ini_file(PSI_APP_ROOT."/data/cpus.ini", true);
if ($cpulist && (isset($cpulist['cpu'][$cpuimplpart = strtolower($impl.','.$part)]))) {
if ($cpulist && (((($vari !== null) && isset($cpulist['cpu'][$cpufromlist = strtolower($impl.','.$part.','.$vari)]))
|| isset($cpulist['cpu'][$cpufromlist = strtolower($impl.','.$part)])))) {
if (($cpumodel = $dev->getModel()) !== '') {
$dev->setModel($cpumodel.' - '.$cpulist['cpu'][$cpuimplpart]);
$dev->setModel($cpumodel.' - '.$cpulist['cpu'][$cpufromlist]);
} else {
$dev->setModel($cpulist['cpu'][$cpuimplpart]);
$dev->setModel($cpulist['cpu'][$cpufromlist]);
}
}
} elseif (($_hard !== null) && ($this->sys->getMachine() === '')) { // other hardware
572,15 → 943,23
$this->sys->setMachine($_hard);
}
 
if ($dev->getModel() === "") {
$dev->setModel("unknown");
$cpumodel = $dev->getModel();
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null) && preg_match('/^QEMU Virtual CPU version /', $cpumodel)) {
$this->sys->setVirtualizer("cpuid:QEMU", false);
}
if ($cpumodel === "") {
if (($vendid = $dev->getVendorId()) !== "") {
$dev->setModel($vendid);
} else {
$dev->setModel("unknown");
}
}
$cpucount++;
$this->sys->setCpus($dev);
}
}
 
$cpudevices = glob('/sys/devices/system/cpu/cpu*/uevent', GLOB_NOSORT);
$cpudevices = CommonFunctions::findglob('/sys/devices/system/cpu/cpu*/uevent', GLOB_NOSORT);
if (is_array($cpudevices) && (($cpustopped = count($cpudevices)-$cpucount) > 0)) {
for (; $cpustopped > 0; $cpustopped--) {
$dev = new CpuDevice();
629,7 → 1008,7
}
}
} else {
$pcidevices = glob('/sys/bus/pci/devices/*/uevent', GLOB_NOSORT);
$pcidevices = CommonFunctions::findglob('/sys/bus/pci/devices/*/uevent', GLOB_NOSORT);
if (is_array($pcidevices) && (($total = count($pcidevices)) > 0)) {
$buf = "";
for ($i = 0; $i < $total; $i++) {
717,7 → 1096,7
 
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
&& ($dev_type[1]==='Direct-Access')) {
$sizelist = glob('/sys/bus/scsi/devices/'.intval($scsiid[1]).':'.intval($scsiid[2]).':'.intval($scsiid[3]).':'.intval($scsiid[4]).'/*/*/size', GLOB_NOSORT);
$sizelist = CommonFunctions::findglob('/sys/bus/scsi/devices/'.intval($scsiid[1]).':'.intval($scsiid[2]).':'.intval($scsiid[3]).':'.intval($scsiid[4]).'/*/*/size', GLOB_NOSORT);
if (is_array($sizelist) && (($total = count($sizelist)) > 0)) {
$buf = "";
for ($i = 0; $i < $total; $i++) {
749,7 → 1128,7
$device = preg_split("/ /", $buf, 7);
if (((isset($device[6]) && trim($device[6]) != "")) ||
((isset($device[5]) && trim($device[5]) != ""))) {
$usbid = intval($device[1]).'-'.intval(trim($device[3],':')).' '.$device[5];
$usbid = intval($device[1]).'-'.intval(trim($device[3], ':')).' '.$device[5];
if ((isset($device[6]) && trim($device[6]) != "")) {
$usbarray[$usbid]['name'] = trim($device[6]);
} else {
759,10 → 1138,10
}
}
 
$usbdevices = glob('/sys/bus/usb/devices/*/idProduct', GLOB_NOSORT);
$usbdevices = CommonFunctions::findglob('/sys/bus/usb/devices/*/idProduct', GLOB_NOSORT);
if (is_array($usbdevices) && (($total = count($usbdevices)) > 0)) {
for ($i = 0; $i < $total; $i++) {
if (CommonFunctions::rfts($usbdevices[$i], $idproduct, 1, 4096, false) && (($idproduct=trim($idproduct)) != "")) { //is readable
if (CommonFunctions::rfts($usbdevices[$i], $idproduct, 1, 4096, false) && (($idproduct=trim($idproduct)) != "")) { // is readable
$busnum = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/busnum');
$devnum = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/devnum');
$idvendor = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/idVendor');
792,7 → 1171,7
}
}
 
if ((count($usbarray) == 0) && CommonFunctions::rfts('/proc/bus/usb/devices', $bufr, 0, 4096, false)) { //usb-devices
if ((count($usbarray) == 0) && CommonFunctions::rfts('/proc/bus/usb/devices', $bufr, 0, 4096, false)) { // usb-devices
$devnum = -1;
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
foreach ($bufe as $buf) {
817,8 → 1196,7
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL
&& !preg_match('/\W/', trim($value2))) {
$usbarray[$devnum]['serial'] = trim($value2);
}
break;
}
}
}
}
901,7 → 1279,7
*/
protected function _i2c()
{
$i2cdevices = glob('/sys/bus/i2c/devices/*/name', GLOB_NOSORT);
$i2cdevices = CommonFunctions::findglob('/sys/bus/i2c/devices/*/name', GLOB_NOSORT);
if (is_array($i2cdevices) && (($total = count($i2cdevices)) > 0)) {
$buf = "";
for ($i = 0; $i < $total; $i++) {
957,24 → 1335,23
if (isset($nlocate[4]) && isset($nsize[4])) {
if (preg_match('/\/\s*([0-9\.]+)\s*(B|KB|MB|GB|TB|PB)$/', str_replace(',', '.', trim(substr($buf, $nlocate[4], $nsize[4]))), $tmpbuf)) {
switch ($tmpbuf[2]) {
case 'B':
$dev->setCapacity($tmpbuf[1]);
break;
case 'KB':
$dev->setCapacity(1000*$tmpbuf[1]);
break;
case 'MB':
$dev->setCapacity(1000*1000*$tmpbuf[1]);
break;
case 'GB':
$dev->setCapacity(1000*1000*1000*$tmpbuf[1]);
break;
case 'TB':
$dev->setCapacity(1000*1000*1000*1000*$tmpbuf[1]);
break;
case 'PB':
$dev->setCapacity(1000*1000*1000*1000*1000*$tmpbuf[1]);
break;
case 'B':
$dev->setCapacity($tmpbuf[1]);
break;
case 'KB':
$dev->setCapacity(1000*$tmpbuf[1]);
break;
case 'MB':
$dev->setCapacity(1000*1000*$tmpbuf[1]);
break;
case 'GB':
$dev->setCapacity(1000*1000*1000*$tmpbuf[1]);
break;
case 'TB':
$dev->setCapacity(1000*1000*1000*1000*$tmpbuf[1]);
break;
case 'PB':
$dev->setCapacity(1000*1000*1000*1000*1000*$tmpbuf[1]);
}
}
}
1026,7 → 1403,7
|| preg_match('/^\s+link\/\S+\s+(\S+)$/i', $buf2, $ar_buf2)) {
if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) {
$macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1]));
if ($macaddr === '00-00-00-00-00-00') { // empty
if (($macaddr === '00-00-00-00-00-00') || ($macaddr === '00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00') || ($macaddr === '--') || ($macaddr === '0.0.0.0')) { // empty
$macaddr = "";
}
}
1120,7 → 1497,12
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
if (preg_match('/^\s+link\/\S+\s+(\S+)\s+brd/i', $line, $ar_buf2)
|| preg_match('/^\s+link\/\S+\s+(\S+)$/i', $line, $ar_buf2)) {
if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) $macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1]));
if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) {
$macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1]));
if (($macaddr === '00-00-00-00-00-00') || ($macaddr === '00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00') || ($macaddr === '--') || ($macaddr === '0.0.0.0')) { // empty
$macaddr = "";
}
}
} elseif (preg_match('/^\s+inet\s+([^\/\s]+).*peer\s+([^\/\s]+).*\s+scope\s((global)|(host))/i', $line, $ar_buf2)) {
if ($ar_buf2[1] != $ar_buf2[2]) {
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1].";:".$ar_buf2[2]);
1265,6 → 1647,8
protected function _memory()
{
if (CommonFunctions::rfts('/proc/meminfo', $mbuf)) {
$swaptotal = null;
$swapfree = null;
$bufe = preg_split("/\n/", $mbuf, -1, PREG_SPLIT_NO_EMPTY);
foreach ($bufe as $buf) {
if (preg_match('/^MemTotal:\s+(\d+)\s*kB/i', $buf, $ar_buf)) {
1275,11 → 1659,15
$this->sys->setMemCache($ar_buf[1] * 1024);
} elseif (preg_match('/^Buffers:\s+(\d+)\s*kB/i', $buf, $ar_buf)) {
$this->sys->setMemBuffer($ar_buf[1] * 1024);
} elseif (preg_match('/^SwapTotal:\s+(\d+)\s*kB/i', $buf, $ar_buf)) {
$swaptotal = $ar_buf[1] * 1024;
} elseif (preg_match('/^SwapFree:\s+(\d+)\s*kB/i', $buf, $ar_buf)) {
$swapfree = $ar_buf[1] * 1024;
}
}
$this->sys->setMemUsed($this->sys->getMemTotal() - $this->sys->getMemFree());
// values for splitting memory usage
if ($this->sys->getMemCache() !== null && $this->sys->getMemBuffer() !== null) {
if (($this->sys->getMemCache() !== null) && ($this->sys->getMemBuffer() !== null)) {
$this->sys->setMemApplication($this->sys->getMemUsed() - $this->sys->getMemCache() - $this->sys->getMemBuffer());
}
if (CommonFunctions::rfts('/proc/swaps', $sbuf, 0, 4096, false)) {
1295,6 → 1683,13
$dev->setFree($dev->getTotal() - $dev->getUsed());
$this->sys->setSwapDevices($dev);
}
} elseif (($swaptotal !== null) && ($swapfree !== null) && ($swaptotal > 0)) {
$dev = new DiskDevice();
$dev->setName("SWAP");
$dev->setTotal($swaptotal);
$dev->setFree($swapfree);
$dev->setUsed($dev->getTotal() - $dev->getFree());
$this->sys->setSwapDevices($dev);
}
}
}
1319,7 → 1714,7
$df_args .= "-x $Fstype ";
}
if ($df_args !== "") {
$df_args = trim($df_args); //trim spaces
$df_args = trim($df_args); // trim spaces
$arrResult = Parser::df("-P $df_args 2>/dev/null");
} else {
$arrResult = Parser::df("-P 2>/dev/null");
1342,17 → 1737,17
return;
}
// We have the '2>/dev/null' because Ubuntu gives an error on this command which causes the distro to be unknown
if (CommonFunctions::executeProgram('lsb_release', '-a 2>/dev/null', $distro_info, PSI_DEBUG) && (strlen($distro_info) > 0)) {
$distro_tmp = preg_split("/\n/", $distro_info, -1, PREG_SPLIT_NO_EMPTY);
if (CommonFunctions::executeProgram('lsb_release', '-a 2>/dev/null', $distro_info, PSI_DEBUG) && strlen($distro_info) > 0) {
$distro_tmp = preg_split("/\r?\n/", $distro_info, -1, PREG_SPLIT_NO_EMPTY);
foreach ($distro_tmp as $info) {
$info_tmp = preg_split('/:/', $info, 2);
if (isset($distro_tmp[0]) && !is_null($distro_tmp[0]) && (trim($distro_tmp[0]) != "") &&
isset($distro_tmp[1]) && !is_null($distro_tmp[1]) && (trim($distro_tmp[1]) != "")) {
if (isset($distro_tmp[0]) && ($distro_tmp[0] !== null) && (trim($distro_tmp[0]) != "") &&
isset($distro_tmp[1]) && ($distro_tmp[1] !== null) && (trim($distro_tmp[1]) != "")) {
$distro[trim($info_tmp[0])] = trim($info_tmp[1]);
}
}
if (!isset($distro['Distributor ID']) && !isset($distro['Description'])) { // Systems like StartOS
if (isset($distro_tmp[0]) && !is_null($distro_tmp[0]) && (trim($distro_tmp[0]) != "")) {
if (isset($distro_tmp[0]) && ($distro_tmp[0] !== null) && (trim($distro_tmp[0]) != "")) {
$this->sys->setDistribution(trim($distro_tmp[0]));
if (preg_match('/^(\S+)\s*/', $distro_tmp[0], $id_buf)
&& isset($list[trim($id_buf[1])]['Image'])) {
1360,9 → 1755,13
}
}
} else {
if (isset($distro['Description']) && ($distro['Description'] != "n/a") && isset($distro['Distributor ID']) && $distro['Distributor ID']=="Neon") { // Neon systems
$distro_tmp = preg_split("/\s/", $distro['Description'], -1, PREG_SPLIT_NO_EMPTY);
$distro['Distributor ID'] = $distro_tmp[0];
}
if (isset($distro['Description'])
&& preg_match('/^NAME=\s*"?([^"\n]+)"?\s*$/', $distro['Description'], $name_tmp)) {
$distro['Description'] = $name_tmp[1];
&& preg_match('/^NAME=\s*"?([^"\r\n]+)"?\s*$/', $distro['Description'], $name_tmp)) {
$distro['Description'] = trim($name_tmp[1]);
}
if (isset($distro['Description'])
&& ($distro['Description'] != "n/a")
1381,22 → 1780,36
$this->sys->setDistribution($this->sys->getDistribution()." ".$distro['Release']);
}
}
} elseif (isset($distro['Distributor ID']) && ($distro['Distributor ID'] != "n/a")) {
$this->sys->setDistribution($distro['Distributor ID']);
if (isset($distro['Release']) && ($distro['Release'] != "n/a")) {
$this->sys->setDistribution($this->sys->getDistribution()." ".$distro['Release']);
} elseif (isset($distro['Distributor ID'])) {
if ($distro['Distributor ID'] != "n/a") {
$this->sys->setDistribution($distro['Distributor ID']);
if (isset($distro['Release']) && ($distro['Release'] != "n/a")) {
$this->sys->setDistribution($this->sys->getDistribution()." ".$distro['Release']);
}
if (isset($distro['Codename']) && ($distro['Codename'] != "n/a")) {
$this->sys->setDistribution($this->sys->getDistribution()." (".$distro['Codename'].")");
}
} elseif (isset($distro['Description']) && ($distro['Description'] != "n/a")) {
$this->sys->setDistribution($distro['Description']);
}
if (isset($distro['Codename']) && ($distro['Codename'] != "n/a")) {
$this->sys->setDistribution($this->sys->getDistribution()." (".$distro['Codename'].")");
}
}
if (isset($distro['Distributor ID']) && ($distro['Distributor ID'] != "n/a") && isset($list[$distro['Distributor ID']]['Image'])) {
$this->sys->setDistributionIcon($list[$distro['Distributor ID']]['Image']);
} elseif (isset($distro['Description']) && ($distro['Description'] != "n/a")) {
$this->sys->setDistribution($distro['Description']);
if (isset($list[$distro['Description']]['Image'])) {
$this->sys->setDistributionIcon($list[$distro['Description']]['Image']);
if (isset($distro['Distributor ID'])) {
$distrib = $distro['Distributor ID'];
if (isset($distro['Description'])) {
$distarr = preg_split("/\s/", $distro['Description'], -1, PREG_SPLIT_NO_EMPTY);
if (isset($distarr[0])) {
if ($distrib != "n/a") {
$distrib .= ' '.$distarr[0];
} else {
$distrib = $distarr[0];
}
}
}
if (isset($list[$distrib]['Image'])) {
$this->sys->setDistributionIcon($list[$distrib]['Image']);
} elseif (($distro['Distributor ID'] != "n/a") && isset($list[$distro['Distributor ID']]['Image'])) {
$this->sys->setDistributionIcon($list[$distro['Distributor ID']]['Image']);
}
}
}
} else {
1411,11 → 1824,11
// Fall back in case 'lsb_release' does not exist but exist /etc/lsb-release
if (CommonFunctions::fileexists($filename="/etc/lsb-release")
&& CommonFunctions::rfts($filename, $buf, 0, 4096, false)
&& preg_match('/^DISTRIB_ID="?([^"\n]+)"?/m', $buf, $id_buf)) {
if (preg_match('/^DISTRIB_DESCRIPTION="?([^"\n]+)"?/m', $buf, $desc_buf)
&& preg_match('/^DISTRIB_ID="?([^"\r\n]+)/m', $buf, $id_buf)) {
if (preg_match('/^DISTRIB_DESCRIPTION="?([^"\r\n]+)/m', $buf, $desc_buf)
&& (trim($desc_buf[1])!=trim($id_buf[1]))) {
$this->sys->setDistribution(trim($desc_buf[1]));
if (preg_match('/^DISTRIB_RELEASE="?([^"\n]+)"?/m', $buf, $vers_buf)
if (preg_match('/^DISTRIB_RELEASE="?([^"\r\n]+)/m', $buf, $vers_buf)
&& (trim($vers_buf[1])!=trim($desc_buf[1])) && strstr($vers_buf[1], ".")){
if (preg_match("/^(\d+)\.[0]+$/", trim($vers_buf[1]), $match_buf)) {
$tofind = $match_buf[1];
1432,10 → 1845,10
} else {
$this->sys->setDistribution(trim($id_buf[1]));
}
if (preg_match('/^DISTRIB_RELEASE="?([^"\n]+)"?/m', $buf, $vers_buf)) {
if (preg_match('/^DISTRIB_RELEASE="?([^"\r\n]+)/m', $buf, $vers_buf)) {
$this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
}
if (preg_match('/^DISTRIB_CODENAME="?([^"\n]+)"?/m', $buf, $vers_buf)) {
if (preg_match('/^DISTRIB_CODENAME="?([^"\r\n]+)/m', $buf, $vers_buf)) {
$this->sys->setDistribution($this->sys->getDistribution()." (".trim($vers_buf[1]).")");
}
}
1470,13 → 1883,13
$this->sys->setDistributionIcon($distro['Image']);
}
if (isset($distribution['Name'])) {
if (is_null($buf) || (trim($buf) == "")) {
if (($buf === null) || (trim($buf) == "")) {
$this->sys->setDistribution($distribution['Name']);
} else {
$this->sys->setDistribution($distribution['Name']." ".trim($buf));
}
} else {
if (is_null($buf) || (trim($buf) == "")) {
if (($buf === null) || (trim($buf) == "")) {
$this->sys->setDistribution($section);
} else {
$this->sys->setDistribution(trim($buf));
1485,22 → 1898,22
if (isset($distribution['Files2'])) {
foreach (preg_split("/;/", $distribution['Files2'], -1, PREG_SPLIT_NO_EMPTY) as $filename2) {
if (CommonFunctions::fileexists($filename2) && CommonFunctions::rfts($filename2, $buf, 0, 4096, false)) {
if (preg_match('/^majorversion="?([^"\n]+)"?/m', $buf, $maj_buf)
&& preg_match('/^minorversion="?([^"\n]+)"?/m', $buf, $min_buf)) {
if (preg_match('/^majorversion="?([^"\r\n]+)/m', $buf, $maj_buf)
&& preg_match('/^minorversion="?([^"\r\n]+)/m', $buf, $min_buf)) {
$distr2=$maj_buf[1].'.'.$min_buf[1];
if (preg_match('/^buildphase="?([^"\n]+)"?/m', $buf, $pha_buf) && ($pha_buf[1]!=="0")) {
if (preg_match('/^buildphase="?([^"\r\n]+)/m', $buf, $pha_buf) && ($pha_buf[1]!=="0")) {
$distr2.='.'.$pha_buf[1];
}
if (preg_match('/^buildnumber="?([^"\n]+)"?/m', $buf, $num_buf)) {
if (preg_match('/^buildnumber="?([^"\r\n]+)/m', $buf, $num_buf)) {
$distr2.='-'.$num_buf[1];
}
if (preg_match('/^builddate="?([^"\n]+)"?/m', $buf, $dat_buf)) {
if (preg_match('/^builddate="?([^"\r\n]+)/m', $buf, $dat_buf)) {
$distr2.=' ('.$dat_buf[1].')';
}
$this->sys->setDistribution($this->sys->getDistribution()." ".$distr2);
} else {
$distr2=trim(substr($buf, 0, strpos($buf, "\n")));
if (!is_null($distr2) && ($distr2 != "")) {
if (($distr2 !== null) && ($distr2 != "")) {
$this->sys->setDistribution($this->sys->getDistribution()." ".$distr2);
}
}
1538,10 → 1951,10
}
} elseif ((CommonFunctions::fileexists($filename="/etc/distro-release")
&& CommonFunctions::rfts($filename, $buf, 1, 4096, false)
&& !is_null($buf) && (trim($buf) != ""))
&& ($buf !== null) && (trim($buf) != ""))
|| (CommonFunctions::fileexists($filename="/etc/system-release")
&& CommonFunctions::rfts($filename, $buf, 1, 4096, false)
&& !is_null($buf) && (trim($buf) != ""))) {
&& ($buf !== null) && (trim($buf) != ""))) {
$this->sys->setDistribution(trim($buf));
if (preg_match('/^(\S+)\s*/', preg_replace('/^Red\s+/', 'Red', $buf), $id_buf)
&& isset($list[trim($id_buf[1])]['Image'])) {
1549,8 → 1962,8
}
} elseif (CommonFunctions::fileexists($filename="/etc/solydxk/info")
&& CommonFunctions::rfts($filename, $buf, 0, 4096, false)
&& preg_match('/^DISTRIB_ID="?([^"\n]+)"?/m', $buf, $id_buf)) {
if (preg_match('/^DESCRIPTION="?([^"\n]+)"?/m', $buf, $desc_buf)
&& preg_match('/^DISTRIB_ID="?([^"\r\n]+)/m', $buf, $id_buf)) {
if (preg_match('/^DESCRIPTION="?([^"\r\n]+)/m', $buf, $desc_buf)
&& (trim($desc_buf[1])!=trim($id_buf[1]))) {
$this->sys->setDistribution(trim($desc_buf[1]));
} else {
1559,10 → 1972,10
} else {
$this->sys->setDistribution(trim($id_buf[1]));
}
if (preg_match('/^RELEASE="?([^"\n]+)"?/m', $buf, $vers_buf)) {
if (preg_match('/^RELEASE="?([^"\r\n]+)/m', $buf, $vers_buf)) {
$this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
}
if (preg_match('/^CODENAME="?([^"\n]+)"?/m', $buf, $vers_buf)) {
if (preg_match('/^CODENAME="?([^"\r\n]+)/m', $buf, $vers_buf)) {
$this->sys->setDistribution($this->sys->getDistribution()." (".trim($vers_buf[1]).")");
}
}
1573,10 → 1986,10
}
} elseif (CommonFunctions::fileexists($filename="/etc/os-release")
&& CommonFunctions::rfts($filename, $buf, 0, 4096, false)
&& (preg_match('/^TAILS_VERSION_ID="?([^"\n]+)"?/m', $buf, $tid_buf)
|| preg_match('/^NAME="?([^"\n]+)"?/m', $buf, $id_buf))) {
if (preg_match('/^TAILS_VERSION_ID="?([^"\n]+)"?/m', $buf, $tid_buf)) {
if (preg_match('/^TAILS_PRODUCT_NAME="?([^"\n]+)"?/m', $buf, $desc_buf)) {
&& (preg_match('/^TAILS_VERSION_ID="?([^"\r\n]+)/m', $buf, $tid_buf)
|| preg_match('/^NAME=["\']?([^"\'\r\n]+)/m', $buf, $id_buf))) {
if (preg_match('/^TAILS_VERSION_ID="?([^"\r\n]+)/m', $buf, $tid_buf)) {
if (preg_match('/^TAILS_PRODUCT_NAME="?([^"\r\n]+)/m', $buf, $desc_buf)) {
$this->sys->setDistribution(trim($desc_buf[1])." ".trim($tid_buf[1]));
} else {
if (isset($list['Tails']['Name'])) {
1587,8 → 2000,8
}
$this->sys->setDistributionIcon($list['Tails']['Image']);
} else {
if (preg_match('/^PRETTY_NAME="?([^"\n]+)"?/m', $buf, $desc_buf)
&& !preg_match('/\$/', $desc_buf[1])) { //if is not defined by variable
if (preg_match('/^PRETTY_NAME=["\']?([^"\'\r\n]+)/m', $buf, $desc_buf)
&& !preg_match('/\$/', $desc_buf[1])) { // if is not defined by variable
$this->sys->setDistribution(trim($desc_buf[1]));
} else {
if (isset($list[trim($id_buf[1])]['Name'])) {
1596,9 → 2009,9
} else {
$this->sys->setDistribution(trim($id_buf[1]));
}
if (preg_match('/^VERSION="?([^"\n]+)"?/m', $buf, $vers_buf)) {
if (preg_match('/^VERSION=["\']?([^"\'\r\n]+)/m', $buf, $vers_buf)) {
$this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
} elseif (preg_match('/^VERSION_ID="?([^"\n]+)"?/m', $buf, $vers_buf)) {
} elseif (preg_match('/^VERSION_ID=["\']?([^"\'\r\n]+)/m', $buf, $vers_buf)) {
$this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
}
}
1614,13 → 2027,13
$this->sys->setDistributionIcon($list['Debian']['Image']);
}
if (isset($list['Debian']['Name'])) {
if (is_null($buf) || (trim($buf) == "")) {
if (($buf === null) || (trim($buf) == "")) {
$this->sys->setDistribution($list['Debian']['Name']);
} else {
$this->sys->setDistribution($list['Debian']['Name']." ".trim($buf));
}
} else {
if (is_null($buf) || (trim($buf) == "")) {
if (($buf === null) || (trim($buf) == "")) {
$this->sys->setDistribution('Debian');
} else {
$this->sys->setDistribution(trim($buf));
1657,13 → 2070,13
*/
protected function _processes()
{
$process = glob('/proc/*/status', GLOB_NOSORT);
$process = CommonFunctions::findglob('/proc/*/status', GLOB_NOSORT);
if (is_array($process) && (($total = count($process)) > 0)) {
$processes['*'] = 0;
$buf = "";
for ($i = 0; $i < $total; $i++) {
if (CommonFunctions::rfts($process[$i], $buf, 0, 4096, false)) {
$processes['*']++; //current total
$processes['*']++; // current total
if (preg_match('/^State:\s+(\w)/m', $buf, $state)) {
if (isset($processes[$state[1]])) {
$processes[$state[1]]++;
1674,7 → 2087,7
}
}
if (!($processes['*'] > 0)) {
$processes['*'] = $processes[' '] = $total; //all unknown
$processes['*'] = $processes[' '] = $total; // all unknown
}
$this->sys->setProcesses($processes);
}
1685,7 → 2098,7
*
* @see PSI_Interface_OS::build()
*
* @return Void
* @return void
*/
public function build()
{
1701,6 → 2114,7
if (!$this->blockname || $this->blockname==='hardware') {
$this->_machine();
$this->_cpuinfo();
$this->_virtualizer();
$this->_pci();
$this->_ide();
$this->_scsi();
1708,9 → 2122,6
$this->_usb();
$this->_i2c();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memory();
}
1717,5 → 2128,8
if (!$this->blockname || $this->blockname==='filesystem') {
$this->_filesystems();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
}
}
/web/acc/phpsysinfo/includes/os/class.Minix.inc.php
27,6 → 27,11
class Minix extends OS
{
/**
* uptime command result.
*/
private $_uptime = null;
 
/**
* content of the syslog
*
* @var array
94,7 → 99,6
break;
case 'vendor_id':
$dev->setVendorId($arrBuff[1]);
break;
}
}
}
194,13 → 198,13
*/
private function _uptime()
{
if (CommonFunctions::executeProgram('uptime', '', $buf)) {
if (preg_match("/up (\d+) day[s]?,\s*(\d+):(\d+),/", $buf, $ar_buf)) {
if (($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) {
if (preg_match("/up (\d+) day[s]?,\s*(\d+):(\d+),/", $this->_uptime, $ar_buf)) {
$min = $ar_buf[3];
$hours = $ar_buf[2];
$days = $ar_buf[1];
$this->sys->setUptime($days * 86400 + $hours * 3600 + $min * 60);
} elseif (preg_match("/up (\d+):(\d+),/", $buf, $ar_buf)) {
} elseif (preg_match("/up (\d+):(\d+),/", $this->_uptime, $ar_buf)) {
$min = $ar_buf[2];
$hours = $ar_buf[1];
$this->sys->setUptime($hours * 3600 + $min * 60);
216,8 → 220,8
*/
private function _loadavg()
{
if (CommonFunctions::executeProgram('uptime', '', $buf)) {
if (preg_match("/load averages: (.*), (.*), (.*)$/", $buf, $ar_buf)) {
if (($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) {
if (preg_match("/load averages: (.*), (.*), (.*)$/", $this->_uptime, $ar_buf)) {
$this->sys->setLoad($ar_buf[1].' '.$ar_buf[2].' '.$ar_buf[3]);
}
}
230,7 → 234,7
*/
private function _hostname()
{
if (PSI_USE_VHOST === true) {
if (PSI_USE_VHOST) {
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
} else {
if (CommonFunctions::executeProgram('uname', '-n', $result, PSI_DEBUG)) {
328,11 → 332,11
/**
* get the information
*
* @return Void
* @return void
*/
public function build()
{
$this->error->addError("WARN", "The Minix version of phpSysInfo is a work in progress, some things currently don't work");
$this->error->addWarning("The Minix version of phpSysInfo is a work in progress, some things currently don't work");
if (!$this->blockname || $this->blockname==='vitals') {
$this->_distro();
$this->_hostname();
346,9 → 350,6
$this->_pci();
$this->_cpuinfo();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memory();
}
355,5 → 356,8
if (!$this->blockname || $this->blockname==='filesystem') {
$this->_filesystems();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
}
}
/web/acc/phpsysinfo/includes/os/class.NetBSD.inc.php
32,7 → 32,7
public function __construct($blockname = false)
{
parent::__construct($blockname);
$this->setCPURegExp1("/^cpu(.*)\, (.*) MHz/");
//$this->setCPURegExp1("/^cpu(.*)\, (.*) MHz/");
$this->setCPURegExp2("/user = (.*), nice = (.*), sys = (.*), intr = (.*), idle = (.*)/");
$this->setSCSIRegExp1("/^(.*) at scsibus.*: <(.*)> .*/");
$this->setSCSIRegExp2("/^(sd[0-9]+): (.*)([MG])B,/");
41,18 → 41,6
}
 
/**
* UpTime
* time the system is running
*
* @return void
*/
private function _uptime()
{
$a = $this->grabkey('kern.boottime');
$this->sys->setUptime(time() - $a);
}
 
/**
* get network information
*
* @return void
148,6 → 136,77
}
 
/**
* CPU information
*
* @return void
*/
protected function cpuinfo()
{
$was = false;
$cpuarray = array();
foreach ($this->readdmesg() as $line) {
if (preg_match("/^cpu([0-9])+: (.*)/", $line, $ar_buf)) {
$was = true;
$ar_buf[2] = trim($ar_buf[2]);
if (preg_match("/^(.+), ([\d\.]+) MHz/", $ar_buf[2], $ar_buf2)) {
if (($model = trim($ar_buf2[1])) !== "") {
$cpuarray[$ar_buf[1]]['model'] = $model;
}
if (($speed = trim($ar_buf2[2])) > 0) {
$cpuarray[$ar_buf[1]]['speed'] = $speed;
}
} elseif (preg_match("/^L2 cache (\d+) ([KM])B /", $ar_buf[2], $ar_buf2)) {
if ($ar_buf2[2]=="M") {
$cpuarray[$ar_buf[1]]['cache'] = $ar_buf2[1]*1024*1024;
} elseif ($ar_buf2[2]=="K") {
$cpuarray[$ar_buf[1]]['cache'] = $ar_buf2[1]*1024;
}
}
} elseif (!preg_match("/^cpu[0-9]+ /", $line) && $was) {
break;
}
}
 
$ncpu = $this->grabkey('hw.ncpu');
if (($ncpu === "") || !($ncpu >= 1)) {
$ncpu = 1;
}
$ncpu = max($ncpu, count($cpuarray));
 
$model = $this->grabkey('machdep.cpu_brand');
$model2 = $this->grabkey('hw.model');
if ($cpuspeed = $this->grabkey('machdep.tsc_freq')) {
$speed = round($cpuspeed / 1000000);
} else {
$speed = "";
}
 
for ($cpu = 0 ; $cpu < $ncpu ; $cpu++) {
$dev = new CpuDevice();
 
if (isset($cpuarray[$cpu]['model'])) {
$dev->setModel($cpuarray[$cpu]['model']);
} elseif ($model !== "") {
$dev->setModel($model);
} elseif ($model2 !== "") {
$dev->setModel($model2);
}
if (isset($cpuarray[$cpu]['speed'])) {
$dev->setCpuSpeed($cpuarray[$cpu]['speed']);
} elseif ($speed !== "") {
$dev->setCpuSpeed($speed);
}
if (isset($cpuarray[$cpu]['cache'])) {
$dev->setCache($cpuarray[$cpu]['cache']);
}
if (($ncpu == 1) && PSI_LOAD_BAR) {
$dev->setLoad($this->cpuusage());
}
$this->sys->setCpus($dev);
}
}
 
/**
* get icon name
*
* @return void
191,7 → 250,7
*
* @see BSDCommon::build()
*
* @return Void
* @return void
*/
public function build()
{
198,7 → 257,6
parent::build();
if (!$this->blockname || $this->blockname==='vitals') {
$this->_distroicon();
$this->_uptime();
$this->_processes();
}
if (!$this->blockname || $this->blockname==='network') {
/web/acc/phpsysinfo/includes/os/class.OS.inc.php
106,7 → 106,7
//} elseif (CommonFunctions::executeProgram('uptime', '', $buf) && preg_match("/,\s+(\d+)\s+user[s]?,\s+load average[s]?:\s+(.*),\s+(.*),\s+(.*)$/", $buf, $ar_buf)) {
$this->sys->setUsers($ar_buf[1]);
} else {
$processlist = glob('/proc/*/cmdline', GLOB_NOSORT);
$processlist = CommonFunctions::findglob('/proc/*/cmdline', GLOB_NOSORT);
if (is_array($processlist) && (($total = count($processlist)) > 0)) {
$count = 0;
$buf = "";
132,7 → 132,7
*/
protected function _ip()
{
if ((PSI_USE_VHOST === true) && !defined('PSI_EMU_HOSTNAME')) {
if (PSI_USE_VHOST && !defined('PSI_EMU_HOSTNAME')) {
if ((CommonFunctions::readenv('SERVER_ADDR', $result) || CommonFunctions::readenv('LOCAL_ADDR', $result)) //is server address defined
&& !strstr($result, '.') && strstr($result, ':')) { //is IPv6, quick version of preg_match('/\(([[0-9A-Fa-f\:]+)\)/', $result)
$dnsrec = dns_get_record($this->sys->getHostname(), DNS_AAAA);
165,25 → 165,9
*/
protected function _dmimeminfo()
{
$banks = array();
$buffer = '';
if (defined('PSI_DMIDECODE_ACCESS') && (strtolower(PSI_DMIDECODE_ACCESS)=="data")) {
CommonFunctions::rfts(PSI_APP_ROOT.'/data/dmidecode.txt', $buffer);
} elseif (CommonFunctions::_findProgram('dmidecode')) {
CommonFunctions::executeProgram('dmidecode', '-t 17', $buffer, PSI_DEBUG);
}
if (!empty($buffer)) {
$banks = preg_split('/^(?=Handle\s)/m', $buffer, -1, PREG_SPLIT_NO_EMPTY);
foreach ($banks as $bank) if (preg_match('/^Handle\s/', $bank)) {
$lines = preg_split("/\n/", $bank, -1, PREG_SPLIT_NO_EMPTY);
$mem = array();
foreach ($lines as $line) if (preg_match('/^\s+([^:]+):(.+)/' ,$line, $params)) {
if (preg_match('/^0x([A-F\d]+)/', $params2 = trim($params[2]), $buff)) {
$mem[trim($params[1])] = trim($buff[1]);
} elseif ($params2 != '') {
$mem[trim($params[1])] = $params2;
}
}
$dmimd = CommonFunctions::readdmimemdata();
if (!empty($dmimd)) {
foreach ($dmimd as $mem) {
if (isset($mem['Size']) && preg_match('/^(\d+)\s(M|G)B$/', $mem['Size'], $size) && ($size[1] > 0)) {
$dev = new HWDevice();
$name = '';
221,7 → 205,7
$memtype = '';
if (isset($mem['Type']) && (($type = $mem['Type']) != 'None') && ($type != 'N/A') && ($type != 'Not Specified') && ($type != 'Other') && ($type != 'Unknown') && ($type != '<OUT OF SPEC>')) {
if (isset($mem['Speed']) && preg_match('/^(\d+)\s(MHz|MT\/s)/', $mem['Speed'], $speed) && ($speed[1] > 0) && (preg_match('/^(DDR\d*)(.*)/', $type, $dr) || preg_match('/^(SDR)AM(.*)/', $type, $dr))) {
if (isset($mem['Minimum Voltage']) && isset($mem['Total Width']) &&
if (isset($mem['Minimum Voltage']) && isset($mem['Maximum Voltage']) &&
preg_match('/^([\d\.]+)\sV$/', $mem['Minimum Voltage'], $minv) && preg_match('/^([\d\.]+)\sV$/', $mem['Maximum Voltage'], $maxv) &&
($minv[1] > 0) && ($maxv[1] >0) && ($minv[1] < $maxv[1])) {
$lv = 'L';
/web/acc/phpsysinfo/includes/os/class.OpenBSD.inc.php
41,18 → 41,6
}
 
/**
* UpTime
* time the system is running
*
* @return void
*/
private function _uptime()
{
$a = $this->grabkey('kern.boottime');
$this->sys->setUptime(time() - $a);
}
 
/**
* get network information
*
* @return void
140,35 → 128,81
*/
protected function cpuinfo()
{
$dev = new CpuDevice();
$dev->setModel($this->grabkey('hw.model'));
$dev->setCpuSpeed($this->grabkey('hw.cpuspeed'));
$was = false;
$cpuarray = array();
foreach ($this->readdmesg() as $line) {
if (preg_match("/^cpu[0-9]+: (.*)/", $line, $ar_buf)) {
if (preg_match("/^cpu([0-9])+: (.*)/", $line, $ar_buf)) {
$was = true;
if (preg_match("/^cpu[0-9]+: (\d+)([KM])B (.*) L2 cache/", $line, $ar_buf2)) {
$ar_buf[2] = trim($ar_buf[2]);
if (preg_match("/^(.+), ([\d\.]+) MHz/", $ar_buf[2], $ar_buf2)) {
if (($model = trim($ar_buf2[1])) !== "") {
$cpuarray[$ar_buf[1]]['model'] = $model;
}
if (($speed = trim($ar_buf2[2])) > 0) {
$cpuarray[$ar_buf[1]]['speed'] = $speed;
}
} elseif (preg_match("/(\d+)([KM])B \S+ \S+ L[23] cache$/", $ar_buf[2], $ar_buf2)) {
if ($ar_buf2[2]=="M") {
$dev->setCache($ar_buf2[1]*1024*1024);
$cpuarray[$ar_buf[1]]['cache'] = $ar_buf2[1]*1024*1024;
} elseif ($ar_buf2[2]=="K") {
$dev->setCache($ar_buf2[1]*1024);
$cpuarray[$ar_buf[1]]['cache'] = $ar_buf2[1]*1024;
}
} else {
$feats = preg_split("/,/", strtolower(trim($ar_buf[1])), -1, PREG_SPLIT_NO_EMPTY);
$feats = preg_split("/,/", strtolower($ar_buf[2]), -1, PREG_SPLIT_NO_EMPTY);
foreach ($feats as $feat) {
if (($feat=="vmx") || ($feat=="svm")) {
$dev->setVirt($feat);
$cpuarray[$ar_buf[1]]['virt'] = $feat;
} elseif ($feat=="hv") {
if (!isset($cpuarray[$ar_buf[1]]['virt'])) {
$cpuarray[$ar_buf[1]]['virt'] = 'hypervisor';
}
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
$this->sys->setVirtualizer("hypervisor", false);
}
}
}
}
} elseif ($was) {
} elseif (!preg_match("/^cpu[0-9]+|^mtrr: |^acpitimer[0-9]+: /", $line) && $was) {
break;
}
}
 
$ncpu = $this->grabkey('hw.ncpu');
if (is_null($ncpu) || (trim($ncpu) == "") || (!($ncpu >= 1)))
if (($ncpu === "") || !($ncpu >= 1)) {
$ncpu = 1;
for ($ncpu ; $ncpu > 0 ; $ncpu--) {
}
$ncpu = max($ncpu, count($cpuarray));
 
$model = $this->grabkey('hw.model');
$speed = $this->grabkey('hw.cpuspeed');
$vendor = $this->grabkey('machdep.cpuvendor');
 
for ($cpu = 0 ; $cpu < $ncpu ; $cpu++) {
$dev = new CpuDevice();
 
if (isset($cpuarray[$cpu]['model'])) {
$dev->setModel($cpuarray[$cpu]['model']);
} elseif ($model !== "") {
$dev->setModel($model);
}
if (isset($cpuarray[$cpu]['speed'])) {
$dev->setCpuSpeed($cpuarray[$cpu]['speed']);
} elseif ($speed !== "") {
$dev->setCpuSpeed($speed);
}
if (isset($cpuarray[$cpu]['cache'])) {
$dev->setCache($cpuarray[$cpu]['cache']);
}
if (isset($cpuarray[$cpu]['virt'])) {
$dev->setVirt($cpuarray[$cpu]['virt']);
}
if ($vendor !== "") {
$dev->setVendorId($vendor);
}
if (($ncpu == 1) && PSI_LOAD_BAR) {
$dev->setLoad($this->cpuusage());
}
 
$this->sys->setCpus($dev);
}
}
216,7 → 250,7
*
* @see BSDCommon::build()
*
* @return Void
* @return void
*/
public function build()
{
223,7 → 257,6
parent::build();
if (!$this->blockname || $this->blockname==='vitals') {
$this->_distroicon();
$this->_uptime();
$this->_processes();
}
if (!$this->blockname || $this->blockname==='network') {
/web/acc/phpsysinfo/includes/os/class.QNX.inc.php
88,23 → 88,9
if (CommonFunctions::executeProgram('pidin', 'info', $buf)
&& preg_match('/^.* BootTime:(.*)/', $buf, $bstart)
&& CommonFunctions::executeProgram('date', '', $bstop)) {
/* default error handler */
if (function_exists('errorHandlerPsi')) {
restore_error_handler();
}
/* fatal errors only */
$old_err_rep = error_reporting();
error_reporting(E_ERROR);
 
date_default_timezone_set('UTC');
$uptime = strtotime($bstop)-strtotime($bstart[1]);
if ($uptime > 0) $this->sys->setUptime($uptime);
 
/* restore error level */
error_reporting($old_err_rep);
/* restore error handler */
if (function_exists('errorHandlerPsi')) {
set_error_handler('errorHandlerPsi');
}
}
}
 
125,7 → 111,7
*/
private function _hostname()
{
if (PSI_USE_VHOST === true) {
if (PSI_USE_VHOST) {
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
} else {
if (CommonFunctions::executeProgram('uname', '-n', $result, PSI_DEBUG)) {
205,11 → 191,11
/**
* get the information
*
* @return Void
* @return void
*/
public function build()
{
$this->error->addError("WARN", "The QNX version of phpSysInfo is a work in progress, some things currently don't work");
$this->error->addWarning("The QNX version of phpSysInfo is a work in progress, some things currently don't work");
if (!$this->blockname || $this->blockname==='vitals') {
$this->_distro();
$this->_hostname();
220,9 → 206,6
if (!$this->blockname || $this->blockname==='hardware') {
$this->_cpuinfo();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memory();
}
229,5 → 212,8
if (!$this->blockname || $this->blockname==='filesystem') {
$this->_filesystems();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
}
}
/web/acc/phpsysinfo/includes/os/class.SunOS.inc.php
44,34 → 44,34
if ($this->_prtconf === null) {
$this->_prtconf = array();
if (CommonFunctions::executeProgram('prtconf', '-v', $buf, PSI_DEBUG) && ($buf!="")) {
$blocks = preg_split( '/\n(?= \S)/', $buf, -1, PREG_SPLIT_NO_EMPTY);
$blocks = preg_split('/\n(?= \S)/', $buf, -1, PREG_SPLIT_NO_EMPTY);
if (!empty($blocks) && (count($blocks)>2)) {
array_shift($blocks);
foreach ($blocks as $block) {
if (preg_match('/^ (\S+) /',$block, $ar_buf)) {
if (preg_match('/^ (\S+) /', $block, $ar_buf)) {
$group = trim($ar_buf[1], ',');
$grouparr = array();
$blocks1 = preg_split( '/\n(?= \S)/', $block, -1, PREG_SPLIT_NO_EMPTY);
$blocks1 = preg_split('/\n(?= \S)/', $block, -1, PREG_SPLIT_NO_EMPTY);
if (!empty($blocks1) && count($blocks1)) {
array_shift($blocks1);
foreach ($blocks1 as $block1) {
if (!preg_match('/^ name=\'([^\']+)\'/',$block1)
&& preg_match('/^ (\S+) /',$block1, $ar_buf)) {
if (!preg_match('/^ name=\'([^\']+)\'/', $block1)
&& preg_match('/^ (\S+) /', $block1, $ar_buf)) {
$device = trim($ar_buf[1], ',');
$devicearr = array();
$blocks2 = preg_split( '/\n(?= \S)/', $block1, -1, PREG_SPLIT_NO_EMPTY);
$blocks2 = preg_split('/\n(?= \S)/', $block1, -1, PREG_SPLIT_NO_EMPTY);
if (!empty($blocks2) && count($blocks2)) {
array_shift($blocks2);
foreach ($blocks2 as $block2) {
if (!preg_match('/^ name=\'([^\']+)\'/',$block2)
&& preg_match('/^ (\S+) /',$block2, $ar_buf)) {
if (!preg_match('/^ name=\'([^\']+)\'/', $block2)
&& preg_match('/^ (\S+) /', $block2, $ar_buf)) {
$subdev = trim($ar_buf[1], ',');
$subdevarr = array();
$blocks3 = preg_split( '/\n(?= \S)/', $block2, -1, PREG_SPLIT_NO_EMPTY);
$blocks3 = preg_split('/\n(?= \S)/', $block2, -1, PREG_SPLIT_NO_EMPTY);
if (!empty($blocks3) && count($blocks3)) {
array_shift($blocks3);
foreach ($blocks3 as $block3) {
if (preg_match('/^ name=\'([^\']+)\' [\s\S]+ value=\'?([^\']+)\'?/m',$block3, $ar_buf)) {
if (preg_match('/^ name=\'([^\']+)\' [\s\S]+ value=\'?([^\']+)\'?/m', $block3, $ar_buf)) {
if ($subdev==='Hardware') {
$subdevarr[$ar_buf[1]] = $ar_buf[2];
$subdevarr['device'] = $device;
128,7 → 128,7
*/
private function _hostname()
{
if (PSI_USE_VHOST === true) {
if (PSI_USE_VHOST) {
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
} else {
if (CommonFunctions::executeProgram('uname', '-n', $result, PSI_DEBUG)) {
454,11 → 454,11
*
* @see PSI_Interface_OS::build()
*
* @return Void
* @return void
*/
public function build()
{
$this->error->addError("WARN", "The SunOS version of phpSysInfo is a work in progress, some things currently don't work");
$this->error->addWarning("The SunOS version of phpSysInfo is a work in progress, some things currently don't work");
if (!$this->blockname || $this->blockname==='vitals') {
$this->_distro();
$this->_hostname();
472,9 → 472,6
$this->_cpuinfo();
$this->_pci();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memory();
}
481,5 → 478,8
if (!$this->blockname || $this->blockname==='filesystem') {
$this->_filesystems();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
}
}
/web/acc/phpsysinfo/includes/os/class.WINNT.inc.php
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,8 → 53,15
*
* @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
*
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,27 → 580,30
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'])) {
$codeset = $buffer[0]['CodeSet'];
if ($codeset == 932) {
$codename = ' (SJIS)';
} elseif ($codeset == 949) {
$codename = ' (EUC-KR)';
} elseif ($codeset == 950) {
$codename = ' (BIG-5)';
} else {
$codename = '';
}
define('PSI_SYSTEM_CODEPAGE', 'windows-'.$codeset.$codename);
if ($buffer && isset($buffer[0]) && isset($buffer[0]['CodeSet'])) {
$codeset = $buffer[0]['CodeSet'];
if ($codeset == 932) {
$codename = ' (SJIS)';
} elseif ($codeset == 949) {
$codename = ' (EUC-KR)';
} elseif ($codeset == 950) {
$codename = ' (BIG-5)';
} else {
$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) {
define('PSI_SYSTEM_CODEPAGE', null);
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'];
$kernel = $ver;
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)');
} else {
$this->sys->setKernel($kernel);
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->setDistribution($buffer[0]['Caption']);
 
$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($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 {
$distribution = "Microsoft ".$strBuf;
}
} else {
$this->sys->setDistribution($ar_temp[1]);
$distribution = $ar_temp[1];
}
$kernel = $ar_temp[2];
$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,21 → 1140,24
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;
}
}
}
}
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']);
$dev->setFsType($filesystem['FileSystem']);
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.":");
$dev->setFsType('Unknown');
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,6 → 1670,30
}
}
}
} 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);
}
}
}
}
}
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) {
1170,68 → 1786,68
$memtype = '';
if (isset($mem['MemoryType']) && (($memval = $mem['MemoryType']) != 0)) {
switch ($memval) {
// case 0: $memtype = 'Unknown'; break;
// case 1: $memtype = 'Other'; break;
case 2: $memtype = 'DRAM'; break;
case 3: $memtype = 'Synchronous DRAM'; break;
case 4: $memtype = 'Cache DRAM'; break;
case 5: $memtype = 'EDO'; break;
case 6: $memtype = 'EDRAM'; break;
case 7: $memtype = 'VRAM'; break;
case 8: $memtype = 'SRAM'; break;
case 9: $memtype = 'RAM'; break;
case 10: $memtype = 'ROM'; break;
case 11: $memtype = 'Flash'; break;
case 12: $memtype = 'EEPROM'; break;
case 13: $memtype = 'FEPROM'; break;
case 14: $memtype = 'EPROM'; break;
case 15: $memtype = 'CDRAM'; break;
case 16: $memtype = '3DRAM'; break;
case 17: $memtype = 'SDRAM'; break;
case 18: $memtype = 'SGRAM'; break;
case 19: $memtype = 'RDRAM'; break;
case 20: $memtype = 'DDR'; break;
case 21: $memtype = 'DDR2'; break;
case 22: $memtype = 'DDR2 FB-DIMM'; break;
case 24: $memtype = 'DDR3'; break;
case 25: $memtype = 'FBD2'; break;
case 26: $memtype = 'DDR4'; break;
// case 0: $memtype = 'Unknown'; break;
// case 1: $memtype = 'Other'; break;
case 2: $memtype = 'DRAM'; break;
case 3: $memtype = 'Synchronous DRAM'; break;
case 4: $memtype = 'Cache DRAM'; break;
case 5: $memtype = 'EDO'; break;
case 6: $memtype = 'EDRAM'; break;
case 7: $memtype = 'VRAM'; break;
case 8: $memtype = 'SRAM'; break;
case 9: $memtype = 'RAM'; break;
case 10: $memtype = 'ROM'; break;
case 11: $memtype = 'Flash'; break;
case 12: $memtype = 'EEPROM'; break;
case 13: $memtype = 'FEPROM'; break;
case 14: $memtype = 'EPROM'; break;
case 15: $memtype = 'CDRAM'; break;
case 16: $memtype = '3DRAM'; break;
case 17: $memtype = 'SDRAM'; break;
case 18: $memtype = 'SGRAM'; break;
case 19: $memtype = 'RDRAM'; break;
case 20: $memtype = 'DDR'; break;
case 21: $memtype = 'DDR2'; break;
case 22: $memtype = 'DDR2 FB-DIMM'; break;
case 24: $memtype = 'DDR3'; break;
case 25: $memtype = 'FBD2'; break;
case 26: $memtype = 'DDR4';
}
} elseif (isset($mem['SMBIOSMemoryType'])) {
switch ($mem['SMBIOSMemoryType']) {
// case 0: $memtype = 'Invalid'; break;
// case 1: $memtype = 'Other'; break;
// case 2: $memtype = 'Unknown'; break;
case 3: $memtype = 'DRAM'; break;
case 4: $memtype = 'EDRAM'; break;
case 5: $memtype = 'VRAM'; break;
case 6: $memtype = 'SRAM'; break;
case 7: $memtype = 'RAM'; break;
case 8: $memtype = 'ROM'; break;
case 9: $memtype = 'FLASH'; break;
case 10: $memtype = 'EEPROM'; break;
case 11: $memtype = 'FEPROM'; break;
case 12: $memtype = 'EPROM'; break;
case 13: $memtype = 'CDRAM'; break;
case 14: $memtype = '3DRAM'; break;
case 15: $memtype = 'SDRAM'; break;
case 16: $memtype = 'SGRAM'; break;
case 17: $memtype = 'RDRAM'; break;
case 18: $memtype = 'DDR'; break;
case 19: $memtype = 'DDR2'; break;
case 20: $memtype = 'DDR2 FB-DIMM'; break;
case 24: $memtype = 'DDR3'; break;
case 25: $memtype = 'FBD2'; break;
case 26: $memtype = 'DDR4'; break;
case 27: $memtype = 'LPDDR'; break;
case 28: $memtype = 'LPDDR2'; break;
case 29: $memtype = 'LPDDR3'; break;
case 30: $memtype = 'DDR3'; break;
case 31: $memtype = 'FBD2'; break;
case 32: $memtype = 'Logical non-volatile device'; break;
case 33: $memtype = 'HBM2'; break;
case 34: $memtype = 'DDR5'; break;
case 35: $memtype = 'LPDDR5'; break;
// case 0: $memtype = 'Invalid'; break;
// case 1: $memtype = 'Other'; break;
// case 2: $memtype = 'Unknown'; break;
case 3: $memtype = 'DRAM'; break;
case 4: $memtype = 'EDRAM'; break;
case 5: $memtype = 'VRAM'; break;
case 6: $memtype = 'SRAM'; break;
case 7: $memtype = 'RAM'; break;
case 8: $memtype = 'ROM'; break;
case 9: $memtype = 'FLASH'; break;
case 10: $memtype = 'EEPROM'; break;
case 11: $memtype = 'FEPROM'; break;
case 12: $memtype = 'EPROM'; break;
case 13: $memtype = 'CDRAM'; break;
case 14: $memtype = '3DRAM'; break;
case 15: $memtype = 'SDRAM'; break;
case 16: $memtype = 'SGRAM'; break;
case 17: $memtype = 'RDRAM'; break;
case 18: $memtype = 'DDR'; break;
case 19: $memtype = 'DDR2'; break;
case 20: $memtype = 'DDR2 FB-DIMM'; break;
case 24: $memtype = 'DDR3'; break;
case 25: $memtype = 'FBD2'; break;
case 26: $memtype = 'DDR4'; break;
case 27: $memtype = 'LPDDR'; break;
case 28: $memtype = 'LPDDR2'; break;
case 29: $memtype = 'LPDDR3'; break;
case 30: $memtype = 'DDR3'; break;
case 31: $memtype = 'FBD2'; break;
case 32: $memtype = 'Logical non-volatile device'; break;
case 33: $memtype = 'HBM2'; break;
case 34: $memtype = 'DDR5'; 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))) {
1248,30 → 1864,30
}
if (isset($mem['FormFactor'])) {
switch ($mem['FormFactor']) {
// case 0: $memtype .= ' Unknown'; break;
// case 1: $memtype .= ' Other'; break;
case 2: $memtype .= ' SIP'; break;
case 3: $memtype .= ' DIP'; break;
case 4: $memtype .= ' ZIP'; break;
case 5: $memtype .= ' SOJ'; break;
case 6: $memtype .= ' Proprietary'; break;
case 7: $memtype .= ' SIMM'; break;
case 8: $memtype .= ' DIMM'; break;
case 9: $memtype .= ' TSOPO'; break;
case 10: $memtype .= ' PGA'; break;
case 11: $memtype .= ' RIM'; break;
case 12: $memtype .= ' SODIMM'; break;
case 13: $memtype .= ' SRIMM'; break;
case 14: $memtype .= ' SMD'; break;
case 15: $memtype .= ' SSMP'; break;
case 16: $memtype .= ' QFP'; break;
case 17: $memtype .= ' TQFP'; break;
case 18: $memtype .= ' SOIC'; break;
case 19: $memtype .= ' LCC'; break;
case 20: $memtype .= ' PLCC'; break;
case 21: $memtype .= ' BGA'; break;
case 22: $memtype .= ' FPBGA'; break;
case 23: $memtype .= ' LGA'; break;
// case 0: $memtype .= ' Unknown'; break;
// case 1: $memtype .= ' Other'; break;
case 2: $memtype .= ' SIP'; break;
case 3: $memtype .= ' DIP'; break;
case 4: $memtype .= ' ZIP'; break;
case 5: $memtype .= ' SOJ'; break;
case 6: $memtype .= ' Proprietary'; break;
case 7: $memtype .= ' SIMM'; break;
case 8: $memtype .= ' DIMM'; break;
case 9: $memtype .= ' TSOPO'; break;
case 10: $memtype .= ' PGA'; break;
case 11: $memtype .= ' RIM'; break;
case 12: $memtype .= ' SODIMM'; break;
case 13: $memtype .= ' SRIMM'; break;
case 14: $memtype .= ' SMD'; break;
case 15: $memtype .= ' SSMP'; break;
case 16: $memtype .= ' QFP'; break;
case 17: $memtype .= ' TQFP'; break;
case 18: $memtype .= ' SOIC'; break;
case 19: $memtype .= ' LCC'; break;
case 20: $memtype .= ' PLCC'; break;
case 21: $memtype .= ' BGA'; break;
case 22: $memtype .= ' FPBGA'; 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");
$this->_distro(); // share getDistribution()
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();
}
}
}
/web/acc/phpsysinfo/includes/output/class.Webpage.inc.php
28,7 → 28,7
/**
* configured indexname
*
* @var String
* @var string
*/
private $_indexname;
 
35,7 → 35,7
/**
* configured language
*
* @var String
* @var string
*/
private $_language;
 
42,7 → 42,7
/**
* configured template
*
* @var String
* @var string
*/
private $_template;
 
56,7 → 56,7
/**
* configured bootstrap template
*
* @var String
* @var string
*/
private $_bootstrap_template;
 
/web/acc/phpsysinfo/includes/output/class.WebpageXML.inc.php
174,8 → 174,8
*/
public function run()
{
header("Cache-Control: no-cache, must-revalidate\n");
header("Content-Type: text/xml\n\n");
header('Cache-Control: no-cache, must-revalidate');
header('Content-Type: text/xml');
$xml = $this->_xml->getXml();
echo $xml->asXML();
}
228,18 → 228,16
parent::__construct();
 
if (is_string($plugin) && ($plugin !== "")) {
$plugin = strtolower($plugin);
if ($plugin === "complete") {
if (preg_match('/[^A-Za-z]/', $plugin)) {
$this->_blockName = ' '; // mask wrong plugin name
} elseif (($plugin = strtolower($plugin)) === "complete") {
$this->_completeXML = true;
} elseif (in_array($plugin, array('vitals','hardware','memory','filesystem','network','voltage','current','temperature','fans','power','other','ups'))) {
$this->_blockName = $plugin;
} elseif (in_array($plugin, CommonFunctions::getPlugins())) {
$this->_pluginName = $plugin;
} else {
$validblocks = array('vitals','hardware','memory','filesystem','network','voltage','current','temperature','fans','power','other','ups');
if (in_array($plugin, $validblocks)) {
$this->_blockName = $plugin;
} elseif (in_array($plugin, CommonFunctions::getPlugins())) {
$this->_pluginName = $plugin;
} else {
$this->_blockName = ' '; //disable all blocks
}
$this->_blockName = ' '; // disable all blocks
}
}
$this->_prepare();
/web/acc/phpsysinfo/includes/output/class.WebpageXSLT.inc.php
49,7 → 49,7
$domxsl->load($xslfile);
$xsltproc = new XSLTProcessor;
$xsltproc->importStyleSheet($domxsl);
header("Cache-Control: no-cache, must-revalidate\n");
header('Cache-Control: no-cache, must-revalidate');
echo $xsltproc->transformToXML($domxml);
}
}
/web/acc/phpsysinfo/includes/to/class.System.inc.php
28,7 → 28,7
/**
* name of the host where phpSysInfo runs
*
* @var String
* @var string
*/
private $_hostname = "localhost";
 
35,14 → 35,14
/**
* ip of the host where phpSysInfo runs
*
* @var String
* @var string
*/
private $_ip = "127.0.0.1";
 
/**
* detailed Information about the kernel
* detailed information about the kernel
*
* @var String
* @var string
*/
private $_kernel = "Unknown";
 
49,7 → 49,7
/**
* name of the distribution
*
* @var String
* @var string
*/
private $_distribution = "Unknown";
 
56,7 → 56,7
/**
* icon of the distribution (must be available in phpSysInfo)
*
* @var String
* @var string
*/
private $_distributionIcon = "unknown.png";
 
63,7 → 63,7
/**
* detailed Information about the machine name
*
* @var String
* @var string
*/
private $_machine = "";
 
70,7 → 70,7
/**
* time in sec how long the system is running
*
* @var Integer
* @var int
*/
private $_uptime = 0;
 
77,7 → 77,7
/**
* count of users that are currently logged in
*
* @var Integer
* @var int
*/
private $_users = 0;
 
84,7 → 84,7
/**
* load of the system
*
* @var String
* @var string
*/
private $_load = "";
 
91,7 → 91,7
/**
* load of the system in percent (all cpus, if more than one)
*
* @var Integer
* @var int
*/
private $_loadPercent = null;
 
197,7 → 197,7
/**
* free memory in bytes
*
* @var Integer
* @var int
*/
private $_memFree = 0;
 
204,7 → 204,7
/**
* total memory in bytes
*
* @var Integer
* @var int
*/
private $_memTotal = 0;
 
211,7 → 211,7
/**
* used memory in bytes
*
* @var Integer
* @var int
*/
private $_memUsed = 0;
 
218,7 → 218,7
/**
* used memory by applications in bytes
*
* @var Integer
* @var int
*/
private $_memApplication = null;
 
225,7 → 225,7
/**
* used memory for buffers in bytes
*
* @var Integer
* @var int
*/
private $_memBuffer = null;
 
232,7 → 232,7
/**
* used memory for cache in bytes
*
* @var Integer
* @var int
*/
private $_memCache = null;
 
253,6 → 253,13
private $_processes = array();
 
/**
* array with Virtualizer information
*
* @var array
*/
private $_virtualizer = array();
 
/**
* remove duplicate Entries and Count
*
* @param array $arrDev list of HWDevices
291,7 → 298,7
* @see System::_memUsed
* @see System::_memTotal
*
* @return Integer
* @return int
*/
public function getMemPercentUsed()
{
308,7 → 315,7
* @see System::_memApplication
* @see System::_memTotal
*
* @return Integer
* @return int
*/
public function getMemPercentApplication()
{
329,7 → 336,7
* @see System::_memCache
* @see System::_memTotal
*
* @return Integer
* @return int
*/
public function getMemPercentCache()
{
354,7 → 361,7
* @see System::_memBuffer
* @see System::_memTotal
*
* @return Integer
* @return int
*/
public function getMemPercentBuffer()
{
385,7 → 392,7
* @see System::_swapDevices
* @see DiskDevice::getFree()
*
* @return Integer
* @return int
*/
public function getSwapFree()
{
407,7 → 414,7
* @see System::_swapDevices
* @see DiskDevice::getTotal()
*
* @return Integer
* @return int
*/
public function getSwapTotal()
{
429,7 → 436,7
* @see System::_swapDevices
* @see DiskDevice::getUsed()
*
* @return Integer
* @return int
*/
public function getSwapUsed()
{
451,7 → 458,7
* @see System::getSwapUsed()
* @see System::getSwapTotal()
*
* @return Integer
* @return int
*/
public function getSwapPercentUsed()
{
485,7 → 492,7
*
* @see System::$_distribution
*
* @return Void
* @return void
*/
public function setDistribution($distribution)
{
511,7 → 518,7
*
* @see System::$_distributionIcon
*
* @return Void
* @return void
*/
public function setDistributionIcon($distributionIcon)
{
537,7 → 544,7
*
* @see System::$_hostname
*
* @return Void
* @return void
*/
public function setHostname($hostname)
{
563,7 → 570,7
*
* @see System::$_ip
*
* @return Void
* @return void
*/
public function setIp($ip)
{
589,7 → 596,7
*
* @see System::$_kernel
*
* @return Void
* @return void
*/
public function setKernel($kernel)
{
615,7 → 622,7
*
* @see System::$_load
*
* @return Void
* @return void
*/
public function setLoad($load)
{
627,7 → 634,7
*
* @see System::$_loadPercent
*
* @return Integer
* @return int
*/
public function getLoadPercent()
{
637,11 → 644,11
/**
* Sets $_loadPercent.
*
* @param Integer $loadPercent load percent
* @param int $loadPercent load percent
*
* @see System::$_loadPercent
*
* @return Void
* @return void
*/
public function setLoadPercent($loadPercent)
{
667,7 → 674,7
*
* @see System::$_machine
*
* @return Void
* @return void
*/
public function setMachine($machine)
{
679,7 → 686,7
*
* @see System::$_uptime
*
* @return Integer
* @return int
*/
public function getUptime()
{
693,7 → 700,7
*
* @see System::$_uptime
*
* @return Void
* @return void
*/
public function setUptime($uptime)
{
705,7 → 712,7
*
* @see System::$_users
*
* @return Integer
* @return int
*/
public function getUsers()
{
715,11 → 722,11
/**
* Sets $_users.
*
* @param Integer $users user count
* @param int $users user count
*
* @see System::$_users
*
* @return Void
* @return void
*/
public function setUsers($users)
{
746,7 → 753,7
* @see System::$_cpus
* @see CpuDevice
*
* @return Void
* @return void
*/
public function setCpus($cpus)
{
777,7 → 784,7
* @see System::$_netDevices
* @see NetDevice
*
* @return Void
* @return void
*/
public function setNetDevices($netDevices)
{
804,7 → 811,7
* @see System::$_pciDevices
* @see HWDevice
*
* @return Void
* @return void
*/
public function setPciDevices($pciDevices)
{
831,7 → 838,7
* @see System::$_ideDevices
* @see HWDevice
*
* @return Void
* @return void
*/
public function setIdeDevices($ideDevices)
{
858,7 → 865,7
* @see System::$_scsiDevices
* @see HWDevice
*
* @return Void
* @return void
*/
public function setScsiDevices($scsiDevices)
{
885,7 → 892,7
* @see System::$_usbDevices
* @see HWDevice
*
* @return Void
* @return void
*/
public function setUsbDevices($usbDevices)
{
912,7 → 919,7
* @see System::$_tbDevices
* @see HWDevice
*
* @return Void
* @return void
*/
public function setTbDevices($tbDevices)
{
939,7 → 946,7
* @see System::$_i2cDevices
* @see HWDevice
*
* @return Void
* @return void
*/
public function setI2cDevices($i2cDevices)
{
966,7 → 973,7
* @see System::$_nvmeDevices
* @see HWDevice
*
* @return Void
* @return void
*/
public function setNvmeDevices($nvmeDevices)
{
993,7 → 1000,7
* @see System::$_memDevices
* @see HWDevice
*
* @return Void
* @return void
*/
public function setMemDevices($memDevices)
{
1032,7 → 1039,7
*
* @see System::$_memApplication
*
* @return Integer
* @return int
*/
public function getMemApplication()
{
1042,11 → 1049,11
/**
* Sets $_memApplication.
*
* @param Integer $memApplication application memory
* @param int $memApplication application memory
*
* @see System::$_memApplication
*
* @return Void
* @return void
*/
public function setMemApplication($memApplication)
{
1058,7 → 1065,7
*
* @see System::$_memBuffer
*
* @return Integer
* @return int
*/
public function getMemBuffer()
{
1068,11 → 1075,11
/**
* Sets $_memBuffer.
*
* @param Integer $memBuffer buffer memory
* @param int $memBuffer buffer memory
*
* @see System::$_memBuffer
*
* @return Void
* @return void
*/
public function setMemBuffer($memBuffer)
{
1084,7 → 1091,7
*
* @see System::$_memCache
*
* @return Integer
* @return int
*/
public function getMemCache()
{
1094,11 → 1101,11
/**
* Sets $_memCache.
*
* @param Integer $memCache cache memory
* @param int $memCache cache memory
*
* @see System::$_memCache
*
* @return Void
* @return void
*/
public function setMemCache($memCache)
{
1110,7 → 1117,7
*
* @see System::$_memFree
*
* @return Integer
* @return int
*/
public function getMemFree()
{
1120,11 → 1127,11
/**
* Sets $_memFree.
*
* @param Integer $memFree free memory
* @param int $memFree free memory
*
* @see System::$_memFree
*
* @return Void
* @return void
*/
public function setMemFree($memFree)
{
1136,7 → 1143,7
*
* @see System::$_memTotal
*
* @return Integer
* @return int
*/
public function getMemTotal()
{
1146,11 → 1153,11
/**
* Sets $_memTotal.
*
* @param Integer $memTotal total memory
* @param int $memTotal total memory
*
* @see System::$_memTotal
*
* @return Void
* @return void
*/
public function setMemTotal($memTotal)
{
1162,7 → 1169,7
*
* @see System::$_memUsed
*
* @return Integer
* @return int
*/
public function getMemUsed()
{
1172,11 → 1179,11
/**
* Sets $_memUsed.
*
* @param Integer $memUsed used memory
* @param int $memUsed used memory
*
* @see System::$_memUsed
*
* @return Void
* @return void
*/
public function setMemUsed($memUsed)
{
1203,7 → 1210,7
* @see System::$_swapDevices
* @see DiskDevice
*
* @return Void
* @return void
*/
public function setSwapDevices($swapDevices)
{
1229,7 → 1236,7
*
* @see System::$_processes
*
* @return Void
* @return void
*/
public function setProcesses($processes)
{
1240,4 → 1247,38
}
*/
}
 
/**
* Returns $_virtualizer.
*
* @see System::$_virtualizer
*
* @return array
*/
public function getVirtualizer()
{
return $this->_virtualizer;
}
 
/**
* Sets $_virtualizer.
*
* @param String $virtualizer virtualizername
* @param Bool|String $value true, false or virtualizername to replace
*
* @see System::$_virtualizer
*
* @return void
*/
public function setVirtualizer($virtualizer, $value = true)
{
if (!isset($this->_virtualizer[$virtualizer])) {
if (is_bool($value)) {
$this->_virtualizer[$virtualizer] = $value;
} else { // replace the virtualizer with another
$this->_virtualizer[$virtualizer] = true;
$this->_virtualizer[$value] = false;
}
}
}
}
/web/acc/phpsysinfo/includes/to/device/class.CpuDevice.inc.php
28,14 → 28,21
/**
* model of the cpu
*
* @var String
* @var string
*/
private $_model = "";
 
/**
* cpu voltage
*
* @var Float
*/
private $_voltage = 0;
 
/**
* speed of the cpu in hertz
*
* @var Integer
* @var int
*/
private $_cpuSpeed = 0;
 
42,7 → 49,7
/**
* max speed of the cpu in hertz
*
* @var Integer
* @var int
*/
private $_cpuSpeedMax = 0;
 
49,7 → 56,7
/**
* min speed of the cpu in hertz
*
* @var Integer
* @var int
*/
private $_cpuSpeedMin = 0;
 
56,7 → 63,7
/**
* cache size in bytes, if available
*
* @var Integer
* @var int
*/
private $_cache = null;
 
63,7 → 70,7
/**
* virtualization, if available
*
* @var String
* @var string
*/
private $_virt = null;
 
70,7 → 77,7
/**
* busspeed in hertz, if available
*
* @var Integer
* @var int
*/
private $_busSpeed = null;
 
77,7 → 84,7
/**
* bogomips of the cpu, if available
*
* @var Integer
* @var int
*/
private $_bogomips = null;
 
84,7 → 91,7
/**
* temperature of the cpu, if available
*
* @var Integer
* @var int
*/
private $_temp = null;
 
91,7 → 98,7
/**
* vendorid, if available
*
* @var String
* @var string
*/
private $_vendorid = null;
 
98,7 → 105,7
/**
* current load in percent of the cpu, if available
*
* @var Integer
* @var int
*/
private $_load = null;
 
121,7 → 128,7
*
* @see Cpu::$_model
*
* @return Void
* @return void
*/
public function setModel($model)
{
129,11 → 136,37
}
 
/**
* Returns $_voltage.
*
* @see Cpu::$_voltage
*
* @return Float
*/
public function getVoltage()
{
return $this->_voltage;
}
 
/**
* Sets $_voltage.
*
* @param int $voltage voltage
*
* @see Cpu::$_voltage
*
* @return void
*/
public function setVoltage($voltage)
{
$this->_voltage = $voltage;
}
 
/**
* Returns $_cpuSpeed.
*
* @see Cpu::$_cpuSpeed
*
* @return Integer
* @return int
*/
public function getCpuSpeed()
{
143,11 → 176,11
/**
* Sets $_cpuSpeed.
*
* @param Integer $cpuSpeed cpuspeed
* @param int $cpuSpeed cpuspeed
*
* @see Cpu::$_cpuSpeed
*
* @return Void
* @return void
*/
public function setCpuSpeed($cpuSpeed)
{
159,7 → 192,7
*
* @see Cpu::$_cpuSpeedMAx
*
* @return Integer
* @return int
*/
public function getCpuSpeedMax()
{
169,11 → 202,11
/**
* Sets $_cpuSpeedMax.
*
* @param Integer $cpuSpeedMax cpuspeedmax
* @param int $cpuSpeedMax cpuspeedmax
*
* @see Cpu::$_cpuSpeedMax
*
* @return Void
* @return void
*/
public function setCpuSpeedMax($cpuSpeedMax)
{
185,7 → 218,7
*
* @see Cpu::$_cpuSpeedMin
*
* @return Integer
* @return int
*/
public function getCpuSpeedMin()
{
195,11 → 228,11
/**
* Sets $_cpuSpeedMin.
*
* @param Integer $cpuSpeedMin cpuspeedmin
* @param int $cpuSpeedMin cpuspeedmin
*
* @see Cpu::$_cpuSpeedMin
*
* @return Void
* @return void
*/
public function setCpuSpeedMin($cpuSpeedMin)
{
211,7 → 244,7
*
* @see Cpu::$_cache
*
* @return Integer
* @return int
*/
public function getCache()
{
221,11 → 254,11
/**
* Sets $_cache.
*
* @param Integer $cache cache size
* @param int $cache cache size
*
* @see Cpu::$_cache
*
* @return Void
* @return void
*/
public function setCache($cache)
{
251,7 → 284,7
*
* @see Cpu::$_virt
*
* @return Void
* @return void
*/
public function setVirt($virt)
{
263,7 → 296,7
*
* @see Cpu::$_busSpeed
*
* @return Integer
* @return int
*/
public function getBusSpeed()
{
273,11 → 306,11
/**
* Sets $_busSpeed.
*
* @param Integer $busSpeed busspeed
* @param int $busSpeed busspeed
*
* @see Cpu::$_busSpeed
*
* @return Void
* @return void
*/
public function setBusSpeed($busSpeed)
{
289,7 → 322,7
*
* @see Cpu::$_bogomips
*
* @return Integer
* @return int
*/
public function getBogomips()
{
299,11 → 332,11
/**
* Sets $_bogomips.
*
* @param Integer $bogomips bogompis
* @param int $bogomips bogompis
*
* @see Cpu::$_bogomips
*
* @return Void
* @return void
*/
public function setBogomips($bogomips)
{
315,7 → 348,7
*
* @see Cpu::$_temp
*
* @return Integer
* @return int
*/
/*
public function getTemp()
327,11 → 360,11
/**
* Sets $_temp.
*
* @param Integer $temp temperature
* @param int $temp temperature
*
* @see Cpu::$_temp
*
* @return Void
* @return void
*/
/*
public function setTemp($temp)
359,11 → 392,11
*
* @see Cpu::$_vendorid
*
* @return Void
* @return void
*/
public function setVendorId($vendorid)
{
$this->_vendorid = $vendorid;
$this->_vendorid = trim(preg_replace('/[\s!]/', '', $vendorid));
}
 
/**
371,7 → 404,7
*
* @see CpuDevice::$_load
*
* @return Integer
* @return int
*/
public function getLoad()
{
381,11 → 414,11
/**
* Sets $_load.
*
* @param Integer $load load percent
* @param int $load load percent
*
* @see CpuDevice::$_load
*
* @return Void
* @return void
*/
public function setLoad($load)
{
/web/acc/phpsysinfo/includes/to/device/class.DiskDevice.inc.php
28,7 → 28,7
/**
* name of the disk device
*
* @var String
* @var string
*/
private $_name = "";
 
35,7 → 35,7
/**
* type of the filesystem on the disk device
*
* @var String
* @var string
*/
private $_fsType = "";
 
42,7 → 42,7
/**
* diskspace that is free in bytes
*
* @var Integer
* @var int
*/
private $_free = 0;
 
49,7 → 49,7
/**
* diskspace that is used in bytes
*
* @var Integer
* @var int
*/
private $_used = 0;
 
56,7 → 56,7
/**
* total diskspace
*
* @var Integer
* @var int
*/
private $_total = 0;
 
63,7 → 63,7
/**
* mount point of the disk device if available
*
* @var String
* @var string
*/
private $_mountPoint = null;
 
70,7 → 70,7
/**
* additional options of the device, like mount options
*
* @var String
* @var string
*/
private $_options = null;
 
77,7 → 77,7
/**
* inodes usage in percent if available
*
* @var Integer
* @var int
*/
private $_percentInodesUsed = null;
 
84,7 → 84,7
/**
* ignore mode
*
* @var Integer
* @var int
*/
private $_ignore = 0;
 
94,7 → 94,7
* @see DiskDevice::$_total
* @see DiskDevice::$_used
*
* @return Integer
* @return int
*/
public function getPercentUsed()
{
110,7 → 110,7
*
* @see DiskDevice::$_PercentInodesUsed
*
* @return Integer
* @return int
*/
public function getPercentInodesUsed()
{
120,11 → 120,11
/**
* Sets $_PercentInodesUsed.
*
* @param Integer $percentInodesUsed inodes percent
* @param int $percentInodesUsed inodes percent
*
* @see DiskDevice::$_PercentInodesUsed
*
* @return Void
* @return void
*/
public function setPercentInodesUsed($percentInodesUsed)
{
136,7 → 136,7
*
* @see DiskDevice::$_free
*
* @return Integer
* @return int
*/
public function getFree()
{
146,11 → 146,11
/**
* Sets $_free.
*
* @param Integer $free free bytes
* @param int $free free bytes
*
* @see DiskDevice::$_free
*
* @return Void
* @return void
*/
public function setFree($free)
{
162,7 → 162,7
*
* @see DiskDevice::$_fsType
*
* @return String
* @return string
*/
public function getFsType()
{
176,7 → 176,7
*
* @see DiskDevice::$_fsType
*
* @return Void
* @return void
*/
public function setFsType($fsType)
{
188,7 → 188,7
*
* @see DiskDevice::$_mountPoint
*
* @return String
* @return string
*/
public function getMountPoint()
{
198,11 → 198,11
/**
* Sets $_mountPoint.
*
* @param String $mountPoint mountpoint
* @param string $mountPoint mountpoint
*
* @see DiskDevice::$_mountPoint
*
* @return Void
* @return void
*/
public function setMountPoint($mountPoint)
{
214,7 → 214,7
*
* @see DiskDevice::$_name
*
* @return String
* @return string
*/
public function getName()
{
224,11 → 224,11
/**
* Sets $_name.
*
* @param String $name device name
* @param string $name device name
*
* @see DiskDevice::$_name
*
* @return Void
* @return void
*/
public function setName($name)
{
240,7 → 240,7
*
* @see DiskDevice::$_options
*
* @return String
* @return string
*/
public function getOptions()
{
250,11 → 250,11
/**
* Sets $_options.
*
* @param String $options additional options
* @param string $options additional options
*
* @see DiskDevice::$_options
*
* @return Void
* @return void
*/
public function setOptions($options)
{
266,7 → 266,7
*
* @see DiskDevice::$_total
*
* @return Integer
* @return int
*/
public function getTotal()
{
276,11 → 276,11
/**
* Sets $_total.
*
* @param Integer $total total bytes
* @param int $total total bytes
*
* @see DiskDevice::$_total
*
* @return Void
* @return void
*/
public function setTotal($total)
{
292,7 → 292,7
*
* @see DiskDevice::$_used
*
* @return Integer
* @return int
*/
public function getUsed()
{
302,11 → 302,11
/**
* Sets $_used.
*
* @param Integer $used used bytes
* @param int $used used bytes
*
* @see DiskDevice::$_used
*
* @return Void
* @return void
*/
public function setUsed($used)
{
318,7 → 318,7
*
* @see DiskDevice::$_ignore
*
* @return Integer
* @return int
*/
public function getIgnore()
{
330,7 → 330,7
*
* @see DiskDevice::$_ignore
*
* @return Void
* @return void
*/
public function setIgnore($ignore)
{
/web/acc/phpsysinfo/includes/to/device/class.HWDevice.inc.php
28,7 → 28,7
/**
* name of the device
*
* @var String
* @var string
*/
private $_name = "";
 
35,7 → 35,7
/**
* capacity of the device, if not available it will be null
*
* @var Integer
* @var int
*/
private $_capacity = null;
 
42,7 → 42,7
/**
* manufacturer of the device, if not available it will be null
*
* @var Integer
* @var int
*/
private $_manufacturer = null;
 
49,7 → 49,7
/**
* product of the device, if not available it will be null
*
* @var Integer
* @var int
*/
private $_product = null;
 
56,7 → 56,7
/**
* serial number of the device, if not available it will be null
*
* @var String
* @var string
*/
private $_serial = null;
 
77,7 → 77,7
/**
* count of the device
*
* @var Integer
* @var int
*/
private $_count = 1;
 
121,7 → 121,7
*
* @see HWDevice::$_name
*
* @return Void
* @return void
*/
public function setName($name)
{
147,7 → 147,7
*
* @see HWDevice::$_manufacturer
*
* @return Void
* @return void
*/
public function setManufacturer($manufacturer)
{
173,7 → 173,7
*
* @see HWDevice::$_product
*
* @return Void
* @return void
*/
public function setProduct($product)
{
199,7 → 199,7
*
* @see HWDevice::$_serial
*
* @return Void
* @return void
*/
public function setSerial($serial)
{
225,7 → 225,7
*
* @see HWDevice::$_speed
*
* @return Void
* @return void
*/
public function setSpeed($speed)
{
251,7 → 251,7
*
* @see HWDevice::$_voltage
*
* @return Void
* @return void
*/
public function setVoltage($voltage)
{
263,7 → 263,7
*
* @see HWDevice::$_capacity
*
* @return Integer
* @return int
*/
public function getCapacity()
{
273,11 → 273,11
/**
* Sets $_capacity.
*
* @param Integer $capacity device capacity
* @param int $capacity device capacity
*
* @see HWDevice::$_capacity
*
* @return Void
* @return void
*/
public function setCapacity($capacity)
{
289,7 → 289,7
*
* @see HWDevice::$_count
*
* @return Integer
* @return int
*/
public function getCount()
{
299,11 → 299,11
/**
* Sets $_count.
*
* @param Integer $count device count
* @param int $count device count
*
* @see HWDevice::$_count
*
* @return Void
* @return void
*/
public function setCount($count)
{
/web/acc/phpsysinfo/includes/to/device/class.NetDevice.inc.php
28,7 → 28,7
/**
* name of the device
*
* @var String
* @var string
*/
private $_name = "";
 
35,7 → 35,7
/**
* transmitted bytes
*
* @var Integer
* @var int
*/
private $_txBytes = 0;
 
42,7 → 42,7
/**
* received bytes
*
* @var Integer
* @var int
*/
private $_rxBytes = 0;
 
49,7 → 49,7
/**
* counted error packages
*
* @var Integer
* @var int
*/
private $_errors = 0;
 
56,7 → 56,7
/**
* counted droped packages
*
* @var Integer
* @var int
*/
private $_drops = 0;
 
63,7 → 63,7
/**
* string with info
*
* @var String
* @var string
*/
private $_info = null;
 
72,7 → 72,7
*
* @see NetDevice::$_drops
*
* @return Integer
* @return int
*/
public function getDrops()
{
82,11 → 82,11
/**
* Sets $_drops.
*
* @param Integer $drops dropped packages
* @param int $drops dropped packages
*
* @see NetDevice::$_drops
*
* @return Void
* @return void
*/
public function setDrops($drops)
{
98,7 → 98,7
*
* @see NetDevice::$_errors
*
* @return Integer
* @return int
*/
public function getErrors()
{
108,11 → 108,11
/**
* Sets $_errors.
*
* @param Integer $errors error packages
* @param int $errors error packages
*
* @see NetDevice::$_errors
*
* @return Void
* @return void
*/
public function setErrors($errors)
{
138,7 → 138,7
*
* @see NetDevice::$_name
*
* @return Void
* @return void
*/
public function setName($name)
{
150,7 → 150,7
*
* @see NetDevice::$_rxBytes
*
* @return Integer
* @return int
*/
public function getRxBytes()
{
160,11 → 160,11
/**
* Sets $_rxBytes.
*
* @param Integer $rxBytes received bytes
* @param int $rxBytes received bytes
*
* @see NetDevice::$_rxBytes
*
* @return Void
* @return void
*/
public function setRxBytes($rxBytes)
{
176,7 → 176,7
*
* @see NetDevice::$_txBytes
*
* @return Integer
* @return int
*/
public function getTxBytes()
{
186,11 → 186,11
/**
* Sets $_txBytes.
*
* @param Integer $txBytes transmitted bytes
* @param int $txBytes transmitted bytes
*
* @see NetDevice::$_txBytes
*
* @return Void
* @return void
*/
public function setTxBytes($txBytes)
{
216,7 → 216,7
*
* @see NetDevice::$_info
*
* @return Void
* @return void
*/
public function setInfo($info)
{
/web/acc/phpsysinfo/includes/to/device/class.SensorDevice.inc.php
28,7 → 28,7
/**
* name of the sensor
*
* @var String
* @var string
*/
private $_name = "";
 
35,7 → 35,7
/**
* current value of the sensor
*
* @var Integer
* @var int
*/
private $_value = 0;
 
42,7 → 42,7
/**
* maximum value of the sensor
*
* @var Integer
* @var int
*/
private $_max = null;
 
49,7 → 49,7
/**
* minimum value of the sensor
*
* @var Integer
* @var int
*/
private $_min = null;
 
56,7 → 56,7
/**
* event of the sensor
*
* @var String
* @var string
*/
private $_event = "";
 
63,7 → 63,7
/**
* unit of values of the sensor
*
* @var String
* @var string
*/
private $_unit = "";
 
72,7 → 72,7
*
* @see Sensor::$_max
*
* @return Integer
* @return int
*/
public function getMax()
{
82,11 → 82,11
/**
* Sets $_max.
*
* @param Integer $max maximum value
* @param int $max maximum value
*
* @see Sensor::$_max
*
* @return Void
* @return void
*/
public function setMax($max)
{
98,7 → 98,7
*
* @see Sensor::$_min
*
* @return Integer
* @return int
*/
public function getMin()
{
108,11 → 108,11
/**
* Sets $_min.
*
* @param Integer $min minimum value
* @param int $min minimum value
*
* @see Sensor::$_min
*
* @return Void
* @return void
*/
public function setMin($min)
{
138,7 → 138,7
*
* @see Sensor::$_name
*
* @return Void
* @return void
*/
public function setName($name)
{
150,7 → 150,7
*
* @see Sensor::$_value
*
* @return Integer
* @return int
*/
public function getValue()
{
160,11 → 160,11
/**
* Sets $_value.
*
* @param Integer $value current value
* @param int $value current value
*
* @see Sensor::$_value
*
* @return Void
* @return void
*/
public function setValue($value)
{
190,7 → 190,7
*
* @see Sensor::$_event
*
* @return Void
* @return void
*/
public function setEvent($event)
{
216,7 → 216,7
*
* @see Sensor::$_unit
*
* @return Void
* @return void
*/
public function setUnit($unit)
{
/web/acc/phpsysinfo/includes/to/device/class.UPSDevice.inc.php
28,7 → 28,7
/**
* name of the ups
*
* @var String
* @var string
*/
private $_name = "";
 
35,7 → 35,7
/**
* model of the ups
*
* @var String
* @var string
*/
private $_model = "";
 
42,7 → 42,7
/**
* mode of the ups
*
* @var String
* @var string
*/
private $_mode = "";
 
49,7 → 49,7
/**
* last start time
*
* @var String
* @var string
*/
private $_startTime = "";
 
56,7 → 56,7
/**
* status of the ups
*
* @var String
* @var string
*/
private $_status = "";
 
63,7 → 63,7
/**
* temperature of the ups
*
* @var Integer
* @var int
*/
private $_temperatur = null;
 
70,7 → 70,7
/**
* outages count
*
* @var Integer
* @var int
*/
private $_outages = null;
 
77,7 → 77,7
/**
* date of last outtage
*
* @var String
* @var string
*/
private $_lastOutage = null;
 
84,7 → 84,7
/**
* date of last outage finish
*
* @var String
* @var string
*/
private $_lastOutageFinish = null;
 
91,7 → 91,7
/**
* line volt
*
* @var Integer
* @var int
*/
private $_lineVoltage = null;
 
98,7 → 98,7
/**
* line freq
*
* @var Integer
* @var int
*/
private $_lineFrequency = null;
 
105,7 → 105,7
/**
* current load of the ups in percent
*
* @var Integer
* @var int
*/
private $_load = null;
 
112,7 → 112,7
/**
* battery installation date
*
* @var String
* @var string
*/
private $_batteryDate = null;
 
119,7 → 119,7
/**
* current battery volt
*
* @var Integer
* @var int
*/
private $_batteryVoltage = null;
 
126,7 → 126,7
/**
* current charge in percent of the battery
*
* @var Integer
* @var int
*/
private $_batterCharge = null;
 
133,11 → 133,18
/**
* time left
*
* @var String
* @var string
*/
private $_timeLeft = null;
 
/**
* beeper enabled or disabled
*
* @var string
*/
private $_beeperStatus = null;
 
/**
* Returns $_batterCharge.
*
* @see UPSDevice::$_batterCharge
152,7 → 159,7
/**
* Sets $_batterCharge.
*
* @param Integer $batterCharge battery charge
* @param int $batterCharge battery charge
*
* @see UPSDevice::$_batterCharge
*
182,7 → 189,7
*
* @see UPSDevice::$_batteryDate
*
* @return Void
* @return void
*/
public function setBatteryDate($batteryDate)
{
194,7 → 201,7
*
* @see UPSDevice::$_batteryVoltage
*
* @return Integer
* @return int
*/
public function getBatteryVoltage()
{
204,11 → 211,11
/**
* Sets $_batteryVoltage.
*
* @param Integer $batteryVoltage battery volt
* @param int $batteryVoltage battery volt
*
* @see UPSDevice::$_batteryVoltage
*
* @return Void
* @return void
*/
public function setBatteryVoltage($batteryVoltage)
{
234,7 → 241,7
*
* @see UPSDevice::$lastOutage
*
* @return Void
* @return void
*/
public function setLastOutage($lastOutage)
{
260,7 → 267,7
*
* @see UPSDevice::$_lastOutageFinish
*
* @return Void
* @return void
*/
public function setLastOutageFinish($lastOutageFinish)
{
272,7 → 279,7
*
* @see UPSDevice::$_lineVoltage
*
* @return Integer
* @return int
*/
public function getLineVoltage()
{
282,11 → 289,11
/**
* Sets $_lineVoltage.
*
* @param Integer $lineVoltage line voltage
* @param int $lineVoltage line voltage
*
* @see UPSDevice::$_lineVoltage
*
* @return Void
* @return void
*/
public function setLineVoltage($lineVoltage)
{
298,7 → 305,7
*
* @see UPSDevice::$_lineFrequency
*
* @return Integer
* @return int
*/
public function getLineFrequency()
{
308,11 → 315,11
/**
* Sets $_lineFrequency.
*
* @param Integer $lineFrequency line frequency
* @param int $lineFrequency line frequency
*
* @see UPSDevice::$_lineFrequency
*
* @return Void
* @return void
*/
public function setLineFrequency($lineFrequency)
{
324,7 → 331,7
*
* @see UPSDevice::$_load
*
* @return Integer
* @return int
*/
public function getLoad()
{
334,11 → 341,11
/**
* Sets $_load.
*
* @param Integer $load current load
* @param int $load current load
*
* @see UPSDevice::$_load
*
* @return Void
* @return void
*/
public function setLoad($load)
{
364,7 → 371,7
*
* @see UPSDevice::$_mode
*
* @return Void
* @return void
*/
public function setMode($mode)
{
390,7 → 397,7
*
* @see UPSDevice::$_model
*
* @return Void
* @return void
*/
public function setModel($model)
{
416,7 → 423,7
*
* @see UPSDevice::$_name
*
* @return Void
* @return void
*/
public function setName($name)
{
428,7 → 435,7
*
* @see UPSDevice::$_outages
*
* @return Integer
* @return int
*/
public function getOutages()
{
438,11 → 445,11
/**
* Sets $_outages.
*
* @param Integer $outages outages count
* @param int $outages outages count
*
* @see UPSDevice::$_outages
*
* @return Void
* @return void
*/
public function setOutages($outages)
{
468,7 → 475,7
*
* @see UPSDevice::$_startTime
*
* @return Void
* @return void
*/
public function setStartTime($startTime)
{
494,7 → 501,7
*
* @see UPSDevice::$_status
*
* @return Void
* @return void
*/
public function setStatus($status)
{
506,7 → 513,7
*
* @see UPSDevice::$_temperatur
*
* @return Integer
* @return int
*/
public function getTemperatur()
{
516,11 → 523,11
/**
* Sets $_temperatur.
*
* @param Integer $temperatur temperature
* @param int $temperatur temperature
*
* @see UPSDevice::$_temperatur
*
* @return Void
* @return void
*/
public function setTemperatur($temperatur)
{
546,10 → 553,36
*
* @see UPSDevice::$_timeLeft
*
* @return Void
* @return void
*/
public function setTimeLeft($timeLeft)
{
$this->_timeLeft = $timeLeft;
}
 
/**
* Returns $_beeperStatus.
*
* @see UPSDevice::$_beeperStatus
*
* @return String
*/
public function getBeeperStatus()
{
return $this->_beeperStatus;
}
 
/**
* Sets $_beeperStatus.
*
* @param String $beeperStatus beeper status
*
* @see UPSDevice::$_beeperStatus
*
* @return void
*/
public function setBeeperStatus($beeperStatus)
{
$this->_beeperStatus = $beeperStatus;
}
}
/web/acc/phpsysinfo/includes/ups/class.apcupsd.inc.php
39,27 → 39,54
public function __construct()
{
parent::__construct();
if (defined('PSI_UPS_APCUPSD_LIST') && is_string(PSI_UPS_APCUPSD_LIST)) {
if (preg_match(ARRAY_EXP, PSI_UPS_APCUPSD_LIST)) {
$upses = eval(PSI_UPS_APCUPSD_LIST);
if (!defined('PSI_UPS_APCUPSD_ACCESS')) {
define('PSI_UPS_APCUPSD_ACCESS', false);
}
switch (strtolower(PSI_UPS_APCUPSD_ACCESS)) {
case 'data':
if (defined('PSI_UPS_APCUPSD_LIST') && is_string(PSI_UPS_APCUPSD_LIST)) {
if (preg_match(ARRAY_EXP, PSI_UPS_APCUPSD_LIST)) {
$upss = eval(PSI_UPS_APCUPSD_LIST);
} else {
$upss = array(PSI_UPS_APCUPSD_LIST);
}
} else {
$upses = array(PSI_UPS_APCUPSD_LIST);
$upss = array('UPS');
}
foreach ($upses as $ups) {
CommonFunctions::executeProgram('apcaccess', 'status '.trim($ups), $temp);
$un = 0;
foreach ($upss as $ups) {
$temp = "";
CommonFunctions::rftsdata("upsapcupsd{$un}.tmp", $temp);
if (! empty($temp)) {
$this->_output[] = $temp;
}
$un++;
}
} else { //use default if address and port not defined
if (!defined('PSI_EMU_HOSTNAME')) {
CommonFunctions::executeProgram('apcaccess', 'status', $temp);
} else {
CommonFunctions::executeProgram('apcaccess', 'status '.PSI_EMU_HOSTNAME, $temp);
break;
default:
if (defined('PSI_UPS_APCUPSD_LIST') && is_string(PSI_UPS_APCUPSD_LIST)) {
if (preg_match(ARRAY_EXP, PSI_UPS_APCUPSD_LIST)) {
$upses = eval(PSI_UPS_APCUPSD_LIST);
} else {
$upses = array(PSI_UPS_APCUPSD_LIST);
}
foreach ($upses as $ups) {
$temp = "";
CommonFunctions::executeProgram('apcaccess', 'status '.trim($ups), $temp);
if (! empty($temp)) {
$this->_output[] = $temp;
}
}
} else { //use default if address and port not defined
if (!defined('PSI_EMU_HOSTNAME')) {
CommonFunctions::executeProgram('apcaccess', 'status', $temp);
} else {
CommonFunctions::executeProgram('apcaccess', 'status '.PSI_EMU_HOSTNAME, $temp);
}
if (! empty($temp)) {
$this->_output[] = $temp;
}
}
if (! empty($temp)) {
$this->_output[] = $temp;
}
}
}
 
66,7 → 93,7
/**
* parse the input and store data in resultset for xml generation
*
* @return Void
* @return void
*/
private function _info()
{
143,7 → 170,7
*
* @see PSI_Interface_UPS::build()
*
* @return Void
* @return void
*/
public function build()
{
/web/acc/phpsysinfo/includes/ups/class.nut.inc.php
40,35 → 40,64
public function __construct()
{
parent::__construct();
if (defined('PSI_UPS_NUT_LIST') && is_string(PSI_UPS_NUT_LIST)) {
if (preg_match(ARRAY_EXP, PSI_UPS_NUT_LIST)) {
$upses = eval(PSI_UPS_NUT_LIST);
if (!defined('PSI_UPS_NUT_ACCESS')) {
define('PSI_UPS_NUT_ACCESS', false);
}
switch (strtolower(PSI_UPS_NUT_ACCESS)) {
case 'data':
if (defined('PSI_UPS_NUT_LIST') && is_string(PSI_UPS_NUT_LIST)) {
if (preg_match(ARRAY_EXP, PSI_UPS_NUT_LIST)) {
$upss = eval(PSI_UPS_NUT_LIST);
} else {
$upss = array(PSI_UPS_NUT_LIST);
}
} else {
$upses = array(PSI_UPS_NUT_LIST);
$upss = array('UPS');
}
foreach ($upses as $ups) {
CommonFunctions::executeProgram('upsc', '-l '.trim($ups), $output, PSI_DEBUG);
$un = 0;
foreach ($upss as $ups) {
$temp = "";
CommonFunctions::rftsdata("upsnut{$un}.tmp", $temp);
if (! empty($temp)) {
$this->_output[$ups] = $temp;
}
$un++;
}
break;
default:
if (defined('PSI_UPS_NUT_LIST') && is_string(PSI_UPS_NUT_LIST)) {
if (preg_match(ARRAY_EXP, PSI_UPS_NUT_LIST)) {
$upses = eval(PSI_UPS_NUT_LIST);
} else {
$upses = array(PSI_UPS_NUT_LIST);
}
foreach ($upses as $ups) {
CommonFunctions::executeProgram('upsc', '-l '.trim($ups), $output, PSI_DEBUG);
$ups_names = preg_split("/\n/", $output, -1, PREG_SPLIT_NO_EMPTY);
foreach ($ups_names as $ups_name) {
$upsname = trim($ups_name).'@'.trim($ups);
$temp = "";
CommonFunctions::executeProgram('upsc', $upsname, $temp, PSI_DEBUG);
if (! empty($temp)) {
$this->_output[$upsname] = $temp;
}
}
}
} else { //use default if address and port not defined
if (!defined('PSI_EMU_HOSTNAME')) {
CommonFunctions::executeProgram('upsc', '-l', $output, PSI_DEBUG);
} else {
CommonFunctions::executeProgram('upsc', '-l '.PSI_EMU_HOSTNAME, $output, PSI_DEBUG);
}
$ups_names = preg_split("/\n/", $output, -1, PREG_SPLIT_NO_EMPTY);
foreach ($ups_names as $ups_name) {
CommonFunctions::executeProgram('upsc', trim($ups_name).'@'.trim($ups), $temp, PSI_DEBUG);
$temp = "";
CommonFunctions::executeProgram('upsc', trim($ups_name), $temp, PSI_DEBUG);
if (! empty($temp)) {
$this->_output[trim($ups_name).'@'.trim($ups)] = $temp;
$this->_output[trim($ups_name)] = $temp;
}
}
}
} else { //use default if address and port not defined
if (!defined('PSI_EMU_HOSTNAME')) {
CommonFunctions::executeProgram('upsc', '-l', $output, PSI_DEBUG);
} else {
CommonFunctions::executeProgram('upsc', '-l '.PSI_EMU_HOSTNAME, $output, PSI_DEBUG);
}
$ups_names = preg_split("/\n/", $output, -1, PREG_SPLIT_NO_EMPTY);
foreach ($ups_names as $ups_name) {
CommonFunctions::executeProgram('upsc', trim($ups_name), $temp, PSI_DEBUG);
if (! empty($temp)) {
$this->_output[trim($ups_name)] = $temp;
}
}
}
}
 
99,6 → 128,9
if (isset($ups_data['ups.status'])) {
$dev->setStatus($ups_data['ups.status']);
}
if (isset($ups_data['ups.beeper.status'])) {
$dev->setBeeperStatus($ups_data['ups.beeper.status']);
}
 
//Line
if (isset($ups_data['input.voltage'])) {
137,7 → 169,7
*
* @see PSI_Interface_UPS::build()
*
* @return Void
* @return void
*/
public function build()
{
/web/acc/phpsysinfo/includes/ups/class.pmset.inc.php
38,8 → 38,11
public function __construct()
{
parent::__construct();
if (PSI_OS == 'Darwin') {
$temp = "";
if (defined('PSI_UPS_PMSET_ACCESS') && (strtolower(trim(PSI_UPS_PMSET_ACCESS))==='data')) {
if (CommonFunctions::rftsdata('upspmset.tmp', $temp)) {
$this->_output[] = $temp;
}
} elseif (PSI_OS == 'Darwin') {
if (CommonFunctions::executeProgram('pmset', '-g batt', $temp) && !empty($temp)) {
$this->_output[] = $temp;
}
89,7 → 92,7
*
* @see PSI_Interface_UPS::build()
*
* @return Void
* @return void
*/
public function build()
{
/web/acc/phpsysinfo/includes/ups/class.powersoftplus.inc.php
38,7 → 38,12
public function __construct()
{
parent::__construct();
if (PSI_OS == 'Linux') {
if (defined('PSI_UPS_POWERSOFTPLUS_ACCESS') && (strtolower(trim(PSI_UPS_POWERSOFTPLUS_ACCESS))==='data')) {
CommonFunctions::rftsdata('upspowersoftplus.tmp', $temp);
if (! empty($temp)) {
$this->_output[] = $temp;
}
} elseif (PSI_OS == 'Linux') {
CommonFunctions::executeProgram('powersoftplus', '-p', $temp);
if (! empty($temp)) {
$this->_output[] = $temp;
49,7 → 54,7
/**
* parse the input and store data in resultset for xml generation
*
* @return Void
* @return void
*/
private function _info()
{
71,11 → 76,11
if (preg_match('/^Current UPS state\s*:\s*(.*)$/m', $ups, $data)) {
$dev->setStatus(trim($data[1]));
}
if (preg_match('/^Output load\s*:\s*(.*)\s\[\%\]$/m', $ups, $data)) {
if (preg_match('/^Output load\s*:\s*(.*)\s\[\%\]\r?$/m', $ups, $data)) {
$load = trim($data[1]);
}
//wrong Output load issue
if (($load == 0) && ($maxpwr != 0) && preg_match('/^Effective power\s*:\s*(.*)\s\[W\]$/m', $ups, $data)) {
if (($load == 0) && ($maxpwr != 0) && preg_match('/^Effective power\s*:\s*(.*)\s\[W\]\r?$/m', $ups, $data)) {
$load = 100.0*trim($data[1])/$maxpwr;
}
if ($load != null) {
82,7 → 87,7
$dev->setLoad($load);
}
// Battery
if (preg_match('/^Battery voltage\s*:\s*(.*)\s\[Volt\]$/m', $ups, $data)) {
if (preg_match('/^Battery voltage\s*:\s*(.*)\s\[Volt\]\r?$/m', $ups, $data)) {
$dev->setBatteryVoltage(trim($data[1]));
}
if (preg_match('/^Battery state\s*:\s*(.*)$/m', $ups, $data)) {
93,10 → 98,10
}
}
// Line
if (preg_match('/^Input voltage\s*:\s*(.*)\s\[Volt\]$/m', $ups, $data)) {
if (preg_match('/^Input voltage\s*:\s*(.*)\s\[Volt\]\r?$/m', $ups, $data)) {
$dev->setLineVoltage(trim($data[1]));
}
if (preg_match('/^Input frequency\s*:\s*(.*)\s\[Hz\]$/m', $ups, $data)) {
if (preg_match('/^Input frequency\s*:\s*(.*)\s\[Hz\]\r?$/m', $ups, $data)) {
$dev->setLineFrequency(trim($data[1]));
}
$this->upsinfo->setUpsDevices($dev);
108,7 → 113,7
*
* @see PSI_Interface_UPS::build()
*
* @return Void
* @return void
*/
public function build()
{
/web/acc/phpsysinfo/includes/ups/class.snmpups.inc.php
39,7 → 39,30
public function __construct()
{
parent::__construct();
if (!defined('PSI_UPS_SNMPUPS_ACCESS')) {
define('PSI_UPS_SNMPUPS_ACCESS', 'php-snmp');
}
switch (strtolower(PSI_UPS_SNMPUPS_ACCESS)) {
case 'data':
if (defined('PSI_UPS_SNMPUPS_LIST') && is_string(PSI_UPS_SNMPUPS_LIST)) {
if (preg_match(ARRAY_EXP, PSI_UPS_SNMPUPS_LIST)) {
$upss = eval(PSI_UPS_SNMPUPS_LIST);
} else {
$upss = array(PSI_UPS_SNMPUPS_LIST);
}
} else {
$upss = array('UPS');
}
$un = 0;
foreach ($upss as $ups) {
$temp = "";
CommonFunctions::rftsdata("upssnmpups{$un}.tmp", $temp);
if (! empty($temp)) {
$this->_output[] = $temp;
}
$un++;
}
break;
case 'command':
if (defined('PSI_UPS_SNMPUPS_LIST') && is_string(PSI_UPS_SNMPUPS_LIST)) {
if (preg_match(ARRAY_EXP, PSI_UPS_SNMPUPS_LIST)) {
48,6 → 71,7
$upss = array(PSI_UPS_SNMPUPS_LIST);
}
foreach ($upss as $ups) {
$buffer = "";
CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$ups." .1.3.6.1.4.1.318.1.1.1.1", $buffer, PSI_DEBUG);
if (strlen($buffer) > 0) {
$this->_output[$ups] = $buffer;
116,11 → 140,12
foreach ($bufferarr2 as $id=>$string) {
$buffer .= $id." = ".$string."\n";
}
}
if (! empty($bufferarr3)) {
foreach ($bufferarr3 as $id=>$string) {
$buffer .= $id." = ".$string."\n";
}
} }
}
if (! empty($bufferarr4)) {
foreach ($bufferarr4 as $id=>$string) {
$buffer .= $id." = ".$string."\n";
135,7 → 160,6
break;
default:
$this->error->addError("switch(PSI_UPS_SNMPUPS_ACCESS)", "Bad SNMPups configuration in phpsysinfo.ini");
break;
}
}
 
142,7 → 166,7
/**
* parse the input and store data in resultset for xml generation
*
* @return Void
* @return void
*/
private function _info()
{
163,44 → 187,28
}
if (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.4\.1\.1\.0 = INTEGER:\s(.*)/m', $result, $data)) {
switch (trim($data[1])) {
case 1: $status = "Unknown";
break;
case 2: $status = "On Line";
break;
case 3: $status = "On Battery";
break;
case 4: $status = "On Smart Boost";
break;
case 5: $status = "Timed Sleeping";
break;
case 6: $status = "Software Bypass";
break;
case 7: $status = "Off";
break;
case 8: $status = "Rebooting";
break;
case 9: $status = "Switched Bypass";
break;
case 10:$status = "Hardware Failure Bypass";
break;
case 11:$status = "Sleeping Until Power Returns";
break;
case 12:$status = "On Smart Trim";
break;
default: $status = "Unknown state (".trim($data[1]).")";
break;
case 1: $status = "Unknown"; break;
case 2: $status = "On Line"; break;
case 3: $status = "On Battery"; break;
case 4: $status = "On Smart Boost"; break;
case 5: $status = "Timed Sleeping"; break;
case 6: $status = "Software Bypass"; break;
case 7: $status = "Off"; break;
case 8: $status = "Rebooting"; break;
case 9: $status = "Switched Bypass"; break;
case 10:$status = "Hardware Failure Bypass"; break;
case 11:$status = "Sleeping Until Power Returns"; break;
case 12:$status = "On Smart Trim"; break;
default: $status = "Unknown state (".trim($data[1]).")";
}
}
if (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.2\.1\.1\.0 = INTEGER:\s(.*)/m', $result, $data)) {
$batstat = "";
switch (trim($data[1])) {
case 1: $batstat = "Battery Unknown";
break;
case 2: break;
case 3: $batstat = "Battery Low";
break;
default: $batstat = "Battery Unknown (".trim($data[1]).")";
break;
case 1: $batstat = "Battery Unknown"; break;
case 2: break;
case 3: $batstat = "Battery Low"; break;
default: $batstat = "Battery Unknown (".trim($data[1]).")";
}
if ($batstat !== "") {
if ($status !== "") {
213,11 → 221,9
if (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.2\.2\.4\.0 = INTEGER:\s(.*)/m', $result, $data)) {
$batstat = "";
switch (trim($data[1])) {
case 1: break;
case 2: $batstat = "Replace Battery";
break;
default: $batstat = "Replace Battery (".trim($data[1]).")";
break;
case 1: break;
case 2: $batstat = "Replace Battery"; break;
default: $batstat = "Replace Battery (".trim($data[1]).")";
}
if ($batstat !== "") {
if ($status !== "") {
277,7 → 283,7
*
* @see PSI_Interface_UPS::build()
*
* @return Void
* @return void
*/
public function build()
{
/web/acc/phpsysinfo/includes/xml/class.SimpleXMLExtended.inc.php
28,7 → 28,7
/**
* store the encoding that is used for conversation to utf8
*
* @var String base encoding
* @var string base encoding
*/
private $_encoding = null;
 
139,7 → 139,7
* @param String $name name of the attribute
* @param String $value value of the attribute
*
* @return Void
* @return void
*/
public function addAttribute($name, $value)
{
157,7 → 157,7
*
* @param SimpleXMLElement $new_child child that should be appended
*
* @return Void
* @return void
*/
public function combinexml(SimpleXMLElement $new_child)
{
176,7 → 176,7
*/
private function _toUTF8($str)
{
$str = trim(preg_replace('/[\x00-\x09\x0b-\x1F]/', ' ', $str)); //remove nonprintable characters
$str = trim(preg_replace('/[\x00-\x09\x0b-\x1F]/', ' ', strval($str))); //remove nonprintable characters
if ($this->_encoding != null) {
if (strcasecmp($this->_encoding, "UTF-8") == 0) {
return $str;
/web/acc/phpsysinfo/includes/xml/class.XML.inc.php
189,7 → 189,18
}
}
foreach ($this->_sys->getNetDevices() as $dev) {
if (!in_array(trim($dev->getName()), $hideDevices)) {
if (defined('PSI_HIDE_NETWORK_INTERFACE_REGEX') && PSI_HIDE_NETWORK_INTERFACE_REGEX) {
$hide = false;
foreach ($hideDevices as $hidedev) {
if (preg_match('/^'.$hidedev.'$/', trim($dev->getName()))) {
$hide = true;
break;
}
}
} else {
$hide =in_array(trim($dev->getName()), $hideDevices);
}
if (!$hide) {
$device = $network->addChild('NetDevice');
$device->addAttribute('Name', $dev->getName());
$device->addAttribute('RxBytes', $dev->getRxBytes());
210,9 → 221,50
private function _buildHardware()
{
$hardware = $this->_xml->addChild('Hardware');
if ($this->_sys->getMachine() != "") {
$hardware->addAttribute('Name', $this->_sys->getMachine());
if (($machine = $this->_sys->getMachine()) != "") {
if ((preg_match('/^(.* (.*\/.*\/.*))\/(.*\/.*\/.*)(, BIOS .*)$/', $machine, $mbuf)
|| preg_match('/^(.* (.*\/.*))\/(.*\/.*)(, BIOS .*)$/', $machine, $mbuf)
|| preg_match('/^(.* (.*))\/(.*)(, BIOS .*)$/', $machine, $mbuf)
|| preg_match('/^((.*\/.*\/.*))\/(.*\/.*\/.*)(, BIOS .*)$/', $machine, $mbuf)
|| preg_match('/^((.*\/.*))\/(.*\/.*)(, BIOS .*)$/', $machine, $mbuf)
|| preg_match('/^((.*))\/(.*)(, BIOS .*)$/', $machine, $mbuf))
&& ($mbuf[2] === $mbuf[3])) { // find duplicates
$machine = $mbuf[1].$mbuf[4]; // minimized machine name
}
$machine = trim(preg_replace("/^\s*\/?,?/", "", $machine)); // remove leading slash and comma
 
if ($machine != "") {
$hardware->addAttribute('Name', $machine);
}
}
 
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
$virt = $this->_sys->getVirtualizer();
$first = true;
$virtstring = "";
foreach ($virt as $virtkey=>$virtvalue) if ($virtvalue) {
if ($first) {
$first = false;
} else {
$virtstring .= ", ";
}
if ($virtkey === 'microsoft') {
$virtstring .= 'hyper-v';
} elseif ($virtkey === 'kvm') {
$virtstring .= 'qemu-kvm';
} elseif ($virtkey === 'oracle') {
$virtstring .= 'virtualbox';
} elseif ($virtkey === 'zvm') {
$virtstring .= 'z/vm';
} else {
$virtstring .= $virtkey;
}
}
if ($virtstring !== "") {
$hardware->addAttribute('Virtualizer', $virtstring);
}
}
 
$cpu = null;
$vendortab = null;
foreach ($this->_sys->getCpus() as $oneCpu) {
219,13 → 271,18
if ($cpu === null) $cpu = $hardware->addChild('CPU');
$tmp = $cpu->addChild('CpuCore');
$tmp->addAttribute('Model', $oneCpu->getModel());
if ($oneCpu->getCpuSpeed() !== 0) {
$tmp->addAttribute('CpuSpeed', max($oneCpu->getCpuSpeed(), 0));
if ($oneCpu->getVoltage() > 0) {
$tmp->addAttribute('Voltage', $oneCpu->getVoltage());
}
if ($oneCpu->getCpuSpeedMax() !== 0) {
if ($oneCpu->getCpuSpeed() > 0) {
$tmp->addAttribute('CpuSpeed', $oneCpu->getCpuSpeed());
} elseif ($oneCpu->getCpuSpeed() == -1) {
$tmp->addAttribute('CpuSpeed', 0); // core stopped
}
if ($oneCpu->getCpuSpeedMax() > 0) {
$tmp->addAttribute('CpuSpeedMax', $oneCpu->getCpuSpeedMax());
}
if ($oneCpu->getCpuSpeedMin() !== 0) {
if ($oneCpu->getCpuSpeedMin() > 0) {
$tmp->addAttribute('CpuSpeedMin', $oneCpu->getCpuSpeedMin());
}
/*
244,7 → 301,7
}
if ($oneCpu->getVendorId() !== null) {
if ($vendortab === null) $vendortab = @parse_ini_file(PSI_APP_ROOT."/data/cpus.ini", true);
$shortvendorid = preg_replace('/[\s!]/', '', $oneCpu->getVendorId());
$shortvendorid = $oneCpu->getVendorId();
if ($vendortab && ($shortvendorid != "") && isset($vendortab['manufacturer'][$shortvendorid])) {
$tmp->addAttribute('Manufacturer', $vendortab['manufacturer'][$shortvendorid]);
}
442,9 → 499,9
*
* @param SimpleXmlExtended $mount Xml-Element
* @param DiskDevice $dev DiskDevice
* @param Integer $i counter
* @param int $i counter
*
* @return Void
* @return void
*/
private function _fillDevice(SimpleXMLExtended $mount, DiskDevice $dev, $i)
{
462,12 → 519,12
$mount->addAttribute('Inodes', $dev->getPercentInodesUsed());
}
if ($dev->getIgnore() > 0) $mount->addAttribute('Ignore', $dev->getIgnore());
if (PSI_SHOW_MOUNT_OPTION === true) {
if (PSI_SHOW_MOUNT_OPTION) {
if ($dev->getOptions() !== null) {
$mount->addAttribute('MountOptions', preg_replace("/,/", ", ", $dev->getOptions()));
}
}
if (PSI_SHOW_MOUNT_POINT === true) {
if (PSI_SHOW_MOUNT_POINT && ($dev->getMountPoint() !== null)) {
$mount->addAttribute('MountPoint', $dev->getMountPoint());
}
}
480,7 → 537,6
private function _buildFilesystems()
{
$hideMounts = $hideFstypes = $hideDisks = $ignoreFree = $ignoreTotal = $ignoreUsage = $ignoreThreshold = array();
$i = 1;
if (defined('PSI_HIDE_MOUNTS') && is_string(PSI_HIDE_MOUNTS)) {
if (preg_match(ARRAY_EXP, PSI_HIDE_MOUNTS)) {
$hideMounts = eval(PSI_HIDE_MOUNTS);
535,6 → 591,7
}
}
$fs = $this->_xml->addChild('FileSystem');
$i = 1;
foreach ($this->_sys->getDiskDevices() as $disk) {
if (!in_array($disk->getMountPoint(), $hideMounts, true) && !in_array($disk->getFsType(), $hideFstypes, true) && !in_array($disk->getName(), $hideDisks, true)) {
$mount = $fs->addChild('Mount');
574,11 → 631,13
$item = $temp->addChild('Item');
$item->addAttribute('Label', $dev->getName());
$item->addAttribute('Value', $dev->getValue());
$alarm = false;
if ($dev->getMax() !== null) {
$item->addAttribute('Max', $dev->getMax());
$alarm = true;
}
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
$item->addAttribute('Event', $dev->getEvent());
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && ($dev->getEvent() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) {
$item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
}
}
 
589,14 → 648,16
$item = $fan->addChild('Item');
$item->addAttribute('Label', $dev->getName());
$item->addAttribute('Value', $dev->getValue());
$alarm = false;
if ($dev->getMin() !== null) {
$item->addAttribute('Min', $dev->getMin());
$alarm = true;
}
if ($dev->getUnit() !== "") {
$item->addAttribute('Unit', $dev->getUnit());
}
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
$item->addAttribute('Event', $dev->getEvent());
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && ($dev->getEvent() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) {
$item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
}
}
 
607,16 → 668,19
$item = $volt->addChild('Item');
$item->addAttribute('Label', $dev->getName());
$item->addAttribute('Value', $dev->getValue());
$alarm = false;
if (($dev->getMin() === null) || ($dev->getMin() != 0) || ($dev->getMax() === null) || ($dev->getMax() != 0)) {
if ($dev->getMin() !== null) {
$item->addAttribute('Min', $dev->getMin());
$alarm = true;
}
if ($dev->getMax() !== null) {
$item->addAttribute('Max', $dev->getMax());
$alarm = true;
}
}
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
$item->addAttribute('Event', $dev->getEvent());
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && ($dev->getEvent() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) {
$item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
}
}
 
627,11 → 691,13
$item = $power->addChild('Item');
$item->addAttribute('Label', $dev->getName());
$item->addAttribute('Value', $dev->getValue());
$alarm = false;
if ($dev->getMax() !== null) {
$item->addAttribute('Max', $dev->getMax());
$alarm = true;
}
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
$item->addAttribute('Event', $dev->getEvent());
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && ($dev->getEvent() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) {
$item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
}
}
 
642,16 → 708,19
$item = $current->addChild('Item');
$item->addAttribute('Label', $dev->getName());
$item->addAttribute('Value', $dev->getValue());
$alarm = false;
if (($dev->getMin() === null) || ($dev->getMin() != 0) || ($dev->getMax() === null) || ($dev->getMax() != 0)) {
if ($dev->getMin() !== null) {
$item->addAttribute('Min', $dev->getMin());
$alarm = true;
}
if ($dev->getMax() !== null) {
$item->addAttribute('Max', $dev->getMax());
$alarm = true;
}
}
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
$item->addAttribute('Event', $dev->getEvent());
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && ($dev->getEvent() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) {
$item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
}
}
 
666,7 → 735,7
$item->addAttribute('Unit', $dev->getUnit());
}
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
$item->addAttribute('Event', $dev->getEvent());
$item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
}
}
}
681,7 → 750,7
private function _buildUpsinfo()
{
$upsinfo = $this->_xml->addChild('UPSInfo');
if (defined('PSI_UPS_APCUPSD_CGI_ENABLE') && PSI_UPS_APCUPSD_CGI_ENABLE) {
if (!defined('PSI_EMU_HOSTNAME') && defined('PSI_UPS_APCUPSD_CGI_ENABLE') && PSI_UPS_APCUPSD_CGI_ENABLE) {
$upsinfo->addAttribute('ApcupsdCgiLinks', true);
}
if (sizeof(unserialize(PSI_UPSINFO))>0) {
701,6 → 770,9
$item->addAttribute('StartTime', $ups->getStartTime());
}
$item->addAttribute('Status', $ups->getStatus());
if ($ups->getBeeperStatus() !== null) {
$item->addAttribute('BeeperStatus', $ups->getBeeperStatus());
}
if ($ups->getTemperatur() !== null) {
$item->addAttribute('Temperature', $ups->getTemperatur());
}
748,10 → 820,10
{
if (($this->_plugin == '') || $this->_complete_request) {
if ($this->_sys === null) {
if (PSI_DEBUG === true) {
if (PSI_DEBUG) {
// unstable version check
if (!is_numeric(substr(PSI_VERSION, -1))) {
$this->_errors->addError("WARN", "This is an unstable version of phpSysInfo, some things may not work correctly");
$this->_errors->addWarning("This is an unstable version of phpSysInfo, some things may not work correctly");
}
 
// Safe mode check
771,7 → 843,7
$this->_errors->addError("WARN", "PhpSysInfo requires '.' inside the 'include_path' in php.ini");
}
// popen mode check
if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN === true) {
if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN) {
$this->_errors->addError("WARN", "Installed version of PHP does not support proc_open() function, popen() is used");
}
}
854,7 → 926,7
$options->addAttribute('byteFormat', defined('PSI_BYTE_FORMAT') ? strtolower(PSI_BYTE_FORMAT) : 'auto_binary');
$options->addAttribute('datetimeFormat', defined('PSI_DATETIME_FORMAT') ? strtolower(PSI_DATETIME_FORMAT) : 'utc');
if (defined('PSI_REFRESH')) {
$options->addAttribute('refresh', max(intval(PSI_REFRESH), 0));
$options->addAttribute('refresh', max(intval(PSI_REFRESH), 0));
} else {
$options->addAttribute('refresh', 60000);
}