* Mon May 12 2025 Brian Read <brianr@koozali.org> 11.0.0-1.sme
- Adding SM2 panel [SME: 13004] - Upgrade to phpsysinfo 3.4.4 - Add code to delete inline styles and add css to make it look better. - version saved / built uses the static version, which means no drops downs and choices.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* @package PSI_XML
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version SVN: $Id: class.SimpleXMLExtended.inc.php 610 2012-07-11 19:12:12Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -19,7 +19,7 @@
|
||||
* @package PSI_XML
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @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
|
||||
*/
|
||||
@@ -28,7 +28,7 @@ class SimpleXMLExtended
|
||||
/**
|
||||
* store the encoding that is used for conversation to utf8
|
||||
*
|
||||
* @var String base encoding
|
||||
* @var string base encoding
|
||||
*/
|
||||
private $_encoding = null;
|
||||
|
||||
@@ -42,7 +42,7 @@ class SimpleXMLExtended
|
||||
/**
|
||||
* _CP437toUTF8Table for code page conversion for CP437
|
||||
*
|
||||
* @var _CP437toUTF8Table array
|
||||
* @var array _CP437toUTF8Table array
|
||||
*/
|
||||
private static $_CP437toUTF8Table = array(
|
||||
"\xC3\x87","\xC3\xBC","\xC3\xA9","\xC3\xA2",
|
||||
@@ -108,7 +108,7 @@ class SimpleXMLExtended
|
||||
if ($value == null) {
|
||||
return new SimpleXMLExtended($this->_SimpleXmlElement->addChild($nameUtf8), $this->_encoding);
|
||||
} else {
|
||||
$valueUtf8 = htmlspecialchars($this->_toUTF8($value));
|
||||
$valueUtf8 = htmlspecialchars($this->_toUTF8($value), ENT_COMPAT, "UTF-8");
|
||||
|
||||
return new SimpleXMLExtended($this->_SimpleXmlElement->addChild($nameUtf8, $valueUtf8), $this->_encoding);
|
||||
}
|
||||
@@ -139,13 +139,17 @@ class SimpleXMLExtended
|
||||
* @param String $name name of the attribute
|
||||
* @param String $value value of the attribute
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function addAttribute($name, $value)
|
||||
{
|
||||
$nameUtf8 = $this->_toUTF8($name);
|
||||
$valueUtf8 = htmlspecialchars($this->_toUTF8($value));
|
||||
$this->_SimpleXmlElement->addAttribute($nameUtf8, $valueUtf8);
|
||||
$valueUtf8 = htmlspecialchars($this->_toUTF8($value), ENT_COMPAT, "UTF-8");
|
||||
if (($valueUtf8 === "") && (version_compare("5.2.2", PHP_VERSION, ">"))) {
|
||||
$this->_SimpleXmlElement->addAttribute($nameUtf8, "\0"); // Fixing bug #41175 (addAttribute() fails to add an attribute with an empty value)
|
||||
} else {
|
||||
$this->_SimpleXmlElement->addAttribute($nameUtf8, $valueUtf8);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,7 +157,7 @@ class SimpleXMLExtended
|
||||
*
|
||||
* @param SimpleXMLElement $new_child child that should be appended
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function combinexml(SimpleXMLElement $new_child)
|
||||
{
|
||||
@@ -172,31 +176,46 @@ class SimpleXMLExtended
|
||||
*/
|
||||
private function _toUTF8($str)
|
||||
{
|
||||
$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 trim($str);
|
||||
return $str;
|
||||
} elseif (strcasecmp($this->_encoding, "CP437") == 0) {
|
||||
$str = trim($str);
|
||||
$strr = "";
|
||||
if (($strl = strlen($str)) > 0) for ($i = 0; $i < $strl; $i++) {
|
||||
$strc = substr($str, $i, 1);
|
||||
if ($strc < 128) $strr.=$strc;
|
||||
else $strr.=$_CP437toUTF8Table[$strc-128];
|
||||
else $strr.=self::$_CP437toUTF8Table[$strc-128];
|
||||
}
|
||||
|
||||
return $strr;
|
||||
} else {
|
||||
$enclist = mb_list_encodings();
|
||||
if (in_array($this->_encoding, $enclist)) {
|
||||
return mb_convert_encoding(trim($str), 'UTF-8', $this->_encoding);
|
||||
} elseif (function_exists("iconv")) {
|
||||
return iconv($this->_encoding, 'UTF-8', trim($str));
|
||||
if (preg_match("/^windows-\d+ \((.+)\)$/", $this->_encoding, $buf)) {
|
||||
$encoding = $buf[1];
|
||||
} else {
|
||||
return mb_convert_encoding(trim($str), 'UTF-8');
|
||||
$encoding = $this->_encoding;
|
||||
}
|
||||
}
|
||||
$enclist = mb_list_encodings();
|
||||
if (in_array($encoding, $enclist)) {
|
||||
return mb_convert_encoding($str, 'UTF-8', $encoding);
|
||||
} elseif (function_exists("iconv")) {
|
||||
if (($iconvout=iconv($encoding, 'UTF-8', $str))!==false) {
|
||||
return $iconvout;
|
||||
} else {
|
||||
return mb_convert_encoding($str, 'UTF-8');
|
||||
}
|
||||
} elseif (function_exists("libiconv") && (($iconvout=libiconv($encoding, 'UTF-8', $str))!==false)) {
|
||||
return $iconvout;
|
||||
} else {
|
||||
return mb_convert_encoding($str, 'UTF-8');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return mb_convert_encoding(trim($str), 'UTF-8');
|
||||
if (function_exists('mb_convert_encoding')) {
|
||||
return mb_convert_encoding($str, 'UTF-8');
|
||||
} else {
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -8,7 +8,7 @@
|
||||
* @package PSI_XML
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version SVN: $Id: class.XML.inc.php 699 2012-09-15 11:57:13Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -19,7 +19,7 @@
|
||||
* @package PSI_XML
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @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
|
||||
*/
|
||||
@@ -47,7 +47,7 @@ class XML
|
||||
/**
|
||||
* object for error handling
|
||||
*
|
||||
* @var Error
|
||||
* @var PSI_Error
|
||||
*/
|
||||
private $_errors;
|
||||
|
||||
@@ -65,13 +65,6 @@ class XML
|
||||
*/
|
||||
private $_plugin = '';
|
||||
|
||||
/**
|
||||
* generate a xml for a plugin or for the main app
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_plugin_request = false;
|
||||
|
||||
/**
|
||||
* generate the entire xml with all plugins or only a part of the xml (main or plugin)
|
||||
*
|
||||
@@ -90,23 +83,23 @@ class XML
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($complete = false, $pluginname = "")
|
||||
public function __construct($complete = false, $pluginname = "", $blockname = false)
|
||||
{
|
||||
$this->_errors = Error::singleton();
|
||||
if ($pluginname == "") {
|
||||
$this->_plugin_request = false;
|
||||
$this->_plugin = '';
|
||||
} else {
|
||||
$this->_plugin_request = true;
|
||||
$this->_plugin = $pluginname;
|
||||
}
|
||||
$this->_errors = PSI_Error::singleton();
|
||||
$this->_plugin = $pluginname;
|
||||
if ($complete) {
|
||||
$this->_complete_request = true;
|
||||
} else {
|
||||
$this->_complete_request = false;
|
||||
}
|
||||
$os = PSI_OS;
|
||||
$this->_sysinfo = new $os();
|
||||
if (defined('PSI_EMU_PORT')) {
|
||||
$os = 'SSH';
|
||||
} elseif (defined('PSI_EMU_HOSTNAME')) {
|
||||
$os = 'WINNT';
|
||||
} else {
|
||||
$os = PSI_OS;
|
||||
}
|
||||
$this->_sysinfo = new $os($blockname);
|
||||
$this->_plugins = CommonFunctions::getPlugins();
|
||||
$this->_xmlbody();
|
||||
}
|
||||
@@ -169,7 +162,14 @@ class XML
|
||||
}
|
||||
}
|
||||
}
|
||||
$vitals->addAttribute('OS', PSI_OS);
|
||||
|
||||
if (($os = $this->_sys->getOS()) == 'Android') {
|
||||
$vitals->addAttribute('OS', 'Linux');
|
||||
} elseif ($os == 'GNU') {
|
||||
$vitals->addAttribute('OS', 'Hurd');
|
||||
} else {
|
||||
$vitals->addAttribute('OS', $os);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,15 +193,50 @@ class XML
|
||||
}
|
||||
}
|
||||
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());
|
||||
$device->addAttribute('TxBytes', $dev->getTxBytes());
|
||||
$rxbytes = $dev->getRxBytes();
|
||||
$txbytes = $dev->getTxBytes();
|
||||
$device->addAttribute('RxBytes', $rxbytes);
|
||||
$device->addAttribute('TxBytes', $txbytes);
|
||||
if (defined('PSI_SHOW_NETWORK_ACTIVE_SPEED') && PSI_SHOW_NETWORK_ACTIVE_SPEED) {
|
||||
if (($rxbytes == 0) && ($txbytes == 0)) {
|
||||
$rxrate = $dev->getRxRate();
|
||||
$txrate = $dev->getTxRate();
|
||||
if (($rxrate !== null) || ($txrate !== null)) {
|
||||
if ($rxrate !== null) {
|
||||
$device->addAttribute('RxRate', $rxrate);
|
||||
} else {
|
||||
$device->addAttribute('RxRate', 0);
|
||||
}
|
||||
if ($txrate !== null) {
|
||||
$device->addAttribute('TxRate', $txrate);
|
||||
} else {
|
||||
$device->addAttribute('TxRate', 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$device->addAttribute('Err', $dev->getErrors());
|
||||
$device->addAttribute('Drops', $dev->getDrops());
|
||||
if (defined('PSI_SHOW_NETWORK_INFOS') && PSI_SHOW_NETWORK_INFOS && $dev->getInfo())
|
||||
if (defined('PSI_SHOW_NETWORK_BRIDGE') && PSI_SHOW_NETWORK_BRIDGE && $dev->getBridge()) {
|
||||
$device->addAttribute('Bridge', $dev->getBridge());
|
||||
}
|
||||
if (defined('PSI_SHOW_NETWORK_INFOS') && PSI_SHOW_NETWORK_INFOS && $dev->getInfo()) {
|
||||
$device->addAttribute('Info', $dev->getInfo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,77 +248,90 @@ class XML
|
||||
*/
|
||||
private function _buildHardware()
|
||||
{
|
||||
$dev = new HWDevice();
|
||||
$hardware = $this->_xml->addChild('Hardware');
|
||||
if ($this->_sys->getMachine() != "") {
|
||||
$hardware->addAttribute('Name', $this->_sys->getMachine());
|
||||
}
|
||||
$pci = null;
|
||||
foreach (System::removeDupsAndCount($this->_sys->getPciDevices()) as $dev) {
|
||||
if ($pci === null) $pci = $hardware->addChild('PCI');
|
||||
$tmp = $pci->addChild('Device');
|
||||
$tmp->addAttribute('Name', $dev->getName());
|
||||
$tmp->addAttribute('Count', $dev->getCount());
|
||||
}
|
||||
$usb = null;
|
||||
foreach (System::removeDupsAndCount($this->_sys->getUsbDevices()) as $dev) {
|
||||
if ($usb === null) $usb = $hardware->addChild('USB');
|
||||
$tmp = $usb->addChild('Device');
|
||||
$tmp->addAttribute('Name', $dev->getName());
|
||||
$tmp->addAttribute('Count', $dev->getCount());
|
||||
}
|
||||
$ide = null;
|
||||
foreach (System::removeDupsAndCount($this->_sys->getIdeDevices()) as $dev) {
|
||||
if ($ide === null) $ide = $hardware->addChild('IDE');
|
||||
$tmp = $ide->addChild('Device');
|
||||
$tmp->addAttribute('Name', $dev->getName());
|
||||
$tmp->addAttribute('Count', $dev->getCount());
|
||||
if ($dev->getCapacity() !== null) {
|
||||
$tmp->addAttribute('Capacity', $dev->getCapacity());
|
||||
if (($machine = $this->_sys->getMachine()) != "") {
|
||||
$machine = trim(preg_replace("/\s+/", " ", preg_replace("/^\s*[\/,]*/", "", preg_replace("/\/\s+,/", "/,", $machine)))); // remove leading slash or comma and unnecessary spaces
|
||||
if (preg_match('/, BIOS .*$/', $machine, $mbuf, PREG_OFFSET_CAPTURE)) {
|
||||
$comapos = $mbuf[0][1];
|
||||
$endstr = $mbuf[0][0];
|
||||
$offset = 0;
|
||||
while (($offset < $comapos)
|
||||
&& (($slashpos = strpos($machine, "/", $offset)) !== false)
|
||||
&& ($slashpos < $comapos)) {
|
||||
$len1 = $comapos - $slashpos - 1;
|
||||
$str1 = substr($machine, $slashpos + 1, $len1);
|
||||
$begstr = substr($machine, 0, $slashpos);
|
||||
if ($len1 > 0) { // no empty
|
||||
$str2 = substr($begstr, -$len1 - 1);
|
||||
} else {
|
||||
$str2 = " ";
|
||||
}
|
||||
if ((" ".$str1 === $str2) || ($str1 === $begstr)) { // duplicates
|
||||
$machine = $begstr.$endstr;
|
||||
break;
|
||||
}
|
||||
$offset = $slashpos + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($machine != "") {
|
||||
$hardware->addAttribute('Name', $machine);
|
||||
}
|
||||
}
|
||||
$scsi = null;
|
||||
foreach (System::removeDupsAndCount($this->_sys->getScsiDevices()) as $dev) {
|
||||
if ($scsi === null) $scsi = $hardware->addChild('SCSI');
|
||||
$tmp = $scsi->addChild('Device');
|
||||
$tmp->addAttribute('Name', $dev->getName());
|
||||
$tmp->addAttribute('Count', $dev->getCount());
|
||||
if ($dev->getCapacity() !== null) {
|
||||
$tmp->addAttribute('Capacity', $dev->getCapacity());
|
||||
|
||||
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
|
||||
$virt = $this->_sys->getVirtualizer();
|
||||
$virtstring = "";
|
||||
foreach ($virt as $virtkey=>$virtvalue) if ($virtvalue) {
|
||||
if ($virtstring !== "") {
|
||||
$virtstring .= ", ";
|
||||
}
|
||||
if ($virtkey === 'microsoft') {
|
||||
if (!isset($virt["wsl"]) || !$virt["wsl"]) {
|
||||
$virtstring .= 'hyper-v';
|
||||
}
|
||||
} elseif ($virtkey === 'kvm') {
|
||||
$virtstring .= 'qemu-kvm';
|
||||
} elseif ($virtkey === 'oracle') {
|
||||
$virtstring .= 'virtualbox';
|
||||
} elseif ($virtkey === 'zvm') {
|
||||
$virtstring .= 'z/vm';
|
||||
} elseif ($virtkey === 'sre') {
|
||||
$virtstring .= 'lmhs sre';
|
||||
} else {
|
||||
$virtstring .= $virtkey;
|
||||
}
|
||||
}
|
||||
if ($virtstring !== "") {
|
||||
$hardware->addAttribute('Virtualizer', $virtstring);
|
||||
}
|
||||
}
|
||||
$tb = null;
|
||||
foreach (System::removeDupsAndCount($this->_sys->getTbDevices()) as $dev) {
|
||||
if ($tb === null) $tb = $hardware->addChild('TB');
|
||||
$tmp = $tb->addChild('Device');
|
||||
$tmp->addAttribute('Name', $dev->getName());
|
||||
$tmp->addAttribute('Count', $dev->getCount());
|
||||
}
|
||||
$i2c = null;
|
||||
foreach (System::removeDupsAndCount($this->_sys->getI2cDevices()) as $dev) {
|
||||
if ($i2c === null) $i2c = $hardware->addChild('I2C');
|
||||
$tmp = $i2c->addChild('Device');
|
||||
$tmp->addAttribute('Name', $dev->getName());
|
||||
$tmp->addAttribute('Count', $dev->getCount());
|
||||
}
|
||||
|
||||
$cpu = null;
|
||||
$vendortab = null;
|
||||
foreach ($this->_sys->getCpus() as $oneCpu) {
|
||||
if ($cpu === null) $cpu = $hardware->addChild('CPU');
|
||||
$tmp = $cpu->addChild('CpuCore');
|
||||
$tmp->addAttribute('Model', $oneCpu->getModel());
|
||||
if ($oneCpu->getCpuSpeed() !== 0) {
|
||||
$tmp->addAttribute('CpuSpeed', $oneCpu->getCpuSpeed());
|
||||
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());
|
||||
}
|
||||
/*
|
||||
if ($oneCpu->getTemp() !== null) {
|
||||
$tmp->addAttribute('CpuTemp', $oneCpu->getTemp());
|
||||
}
|
||||
*/
|
||||
if ($oneCpu->getBusSpeed() !== null) {
|
||||
$tmp->addAttribute('BusSpeed', $oneCpu->getBusSpeed());
|
||||
}
|
||||
@@ -293,6 +341,13 @@ class XML
|
||||
if ($oneCpu->getVirt() !== null) {
|
||||
$tmp->addAttribute('Virt', $oneCpu->getVirt());
|
||||
}
|
||||
if ($oneCpu->getVendorId() !== null) {
|
||||
if ($vendortab === null) $vendortab = @parse_ini_file(PSI_APP_ROOT."/data/cpus.ini", true);
|
||||
$shortvendorid = $oneCpu->getVendorId();
|
||||
if ($vendortab && ($shortvendorid != "") && isset($vendortab['manufacturer'][$shortvendorid])) {
|
||||
$tmp->addAttribute('Manufacturer', $vendortab['manufacturer'][$shortvendorid]);
|
||||
}
|
||||
}
|
||||
if ($oneCpu->getBogomips() !== null) {
|
||||
$tmp->addAttribute('Bogomips', $oneCpu->getBogomips());
|
||||
}
|
||||
@@ -300,6 +355,144 @@ class XML
|
||||
$tmp->addAttribute('Load', $oneCpu->getLoad());
|
||||
}
|
||||
}
|
||||
$mem = null;
|
||||
foreach (System::removeDupsAndCount($this->_sys->getMemDevices()) as $dev) {
|
||||
if ($mem === null) $mem = $hardware->addChild('MEM');
|
||||
$tmp = $mem->addChild('Chip');
|
||||
$tmp->addAttribute('Name', $dev->getName());
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
||||
if ($dev->getCapacity() !== null) {
|
||||
$tmp->addAttribute('Capacity', $dev->getCapacity());
|
||||
}
|
||||
if ($dev->getManufacturer() !== null) {
|
||||
$tmp->addAttribute('Manufacturer', $dev->getManufacturer());
|
||||
}
|
||||
if ($dev->getProduct() !== null) {
|
||||
$tmp->addAttribute('Product', $dev->getProduct());
|
||||
}
|
||||
if ($dev->getSpeed() !== null) {
|
||||
$tmp->addAttribute('Speed', $dev->getSpeed());
|
||||
}
|
||||
if ($dev->getVoltage() !== null) {
|
||||
$tmp->addAttribute('Voltage', $dev->getVoltage());
|
||||
}
|
||||
if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL && ($dev->getSerial() !== null)) {
|
||||
$tmp->addAttribute('Serial', $dev->getSerial());
|
||||
}
|
||||
}
|
||||
if ($dev->getCount() > 1) {
|
||||
$tmp->addAttribute('Count', $dev->getCount());
|
||||
}
|
||||
}
|
||||
$pci = null;
|
||||
foreach (System::removeDupsAndCount($this->_sys->getPciDevices()) as $dev) {
|
||||
if ($pci === null) $pci = $hardware->addChild('PCI');
|
||||
$tmp = $pci->addChild('Device');
|
||||
$tmp->addAttribute('Name', $dev->getName());
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
||||
if ($dev->getManufacturer() !== null) {
|
||||
$tmp->addAttribute('Manufacturer', $dev->getManufacturer());
|
||||
}
|
||||
if ($dev->getProduct() !== null) {
|
||||
$tmp->addAttribute('Product', $dev->getProduct());
|
||||
}
|
||||
}
|
||||
if ($dev->getCount() > 1) {
|
||||
$tmp->addAttribute('Count', $dev->getCount());
|
||||
}
|
||||
}
|
||||
$ide = null;
|
||||
foreach (System::removeDupsAndCount($this->_sys->getIdeDevices()) as $dev) {
|
||||
if ($ide === null) $ide = $hardware->addChild('IDE');
|
||||
$tmp = $ide->addChild('Device');
|
||||
$tmp->addAttribute('Name', $dev->getName());
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
||||
if ($dev->getCapacity() !== null) {
|
||||
$tmp->addAttribute('Capacity', $dev->getCapacity());
|
||||
}
|
||||
if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL && ($dev->getSerial() !== null)) {
|
||||
$tmp->addAttribute('Serial', $dev->getSerial());
|
||||
}
|
||||
}
|
||||
if ($dev->getCount() > 1) {
|
||||
$tmp->addAttribute('Count', $dev->getCount());
|
||||
}
|
||||
}
|
||||
$scsi = null;
|
||||
foreach (System::removeDupsAndCount($this->_sys->getScsiDevices()) as $dev) {
|
||||
if ($scsi === null) $scsi = $hardware->addChild('SCSI');
|
||||
$tmp = $scsi->addChild('Device');
|
||||
$tmp->addAttribute('Name', $dev->getName());
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
||||
if ($dev->getCapacity() !== null) {
|
||||
$tmp->addAttribute('Capacity', $dev->getCapacity());
|
||||
}
|
||||
if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL && ($dev->getSerial() !== null)) {
|
||||
$tmp->addAttribute('Serial', $dev->getSerial());
|
||||
}
|
||||
}
|
||||
if ($dev->getCount() > 1) {
|
||||
$tmp->addAttribute('Count', $dev->getCount());
|
||||
}
|
||||
}
|
||||
$nvme = null;
|
||||
foreach (System::removeDupsAndCount($this->_sys->getNvmeDevices()) as $dev) {
|
||||
if ($nvme === null) $nvme = $hardware->addChild('NVMe');
|
||||
$tmp = $nvme->addChild('Device');
|
||||
$tmp->addAttribute('Name', $dev->getName());
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
||||
if ($dev->getCapacity() !== null) {
|
||||
$tmp->addAttribute('Capacity', $dev->getCapacity());
|
||||
}
|
||||
if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL && ($dev->getSerial() !== null)) {
|
||||
$tmp->addAttribute('Serial', $dev->getSerial());
|
||||
}
|
||||
}
|
||||
if ($dev->getCount() > 1) {
|
||||
$tmp->addAttribute('Count', $dev->getCount());
|
||||
}
|
||||
}
|
||||
$usb = null;
|
||||
foreach (System::removeDupsAndCount($this->_sys->getUsbDevices()) as $dev) {
|
||||
if ($usb === null) $usb = $hardware->addChild('USB');
|
||||
$tmp = $usb->addChild('Device');
|
||||
$tmp->addAttribute('Name', $dev->getName());
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
||||
if ($dev->getManufacturer() !== null) {
|
||||
$tmp->addAttribute('Manufacturer', $dev->getManufacturer());
|
||||
}
|
||||
if ($dev->getProduct() !== null) {
|
||||
$tmp->addAttribute('Product', $dev->getProduct());
|
||||
}
|
||||
if ($dev->getSpeed() !== null) {
|
||||
$tmp->addAttribute('Speed', $dev->getSpeed());
|
||||
}
|
||||
if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL && ($dev->getSerial() !== null)) {
|
||||
$tmp->addAttribute('Serial', $dev->getSerial());
|
||||
}
|
||||
}
|
||||
if ($dev->getCount() > 1) {
|
||||
$tmp->addAttribute('Count', $dev->getCount());
|
||||
}
|
||||
}
|
||||
$tb = null;
|
||||
foreach (System::removeDupsAndCount($this->_sys->getTbDevices()) as $dev) {
|
||||
if ($tb === null) $tb = $hardware->addChild('TB');
|
||||
$tmp = $tb->addChild('Device');
|
||||
$tmp->addAttribute('Name', $dev->getName());
|
||||
if ($dev->getCount() > 1) {
|
||||
$tmp->addAttribute('Count', $dev->getCount());
|
||||
}
|
||||
}
|
||||
$i2c = null;
|
||||
foreach (System::removeDupsAndCount($this->_sys->getI2cDevices()) as $dev) {
|
||||
if ($i2c === null) $i2c = $hardware->addChild('I2C');
|
||||
$tmp = $i2c->addChild('Device');
|
||||
$tmp->addAttribute('Name', $dev->getName());
|
||||
if ($dev->getCount() > 1) {
|
||||
$tmp->addAttribute('Count', $dev->getCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -348,28 +541,32 @@ class XML
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
$mount->addAttribute('MountPointID', $i);
|
||||
$mount->addAttribute('FSType', $dev->getFsType());
|
||||
if ($dev->getFsType()!=="") {
|
||||
$mount->addAttribute('FSType', $dev->getFsType());
|
||||
}
|
||||
$mount->addAttribute('Name', $dev->getName());
|
||||
$mount->addAttribute('Free', sprintf("%.0f", $dev->getFree()));
|
||||
$mount->addAttribute('Used', sprintf("%.0f", $dev->getUsed()));
|
||||
$mount->addAttribute('Total', sprintf("%.0f", $dev->getTotal()));
|
||||
$mount->addAttribute('Percent', $dev->getPercentUsed());
|
||||
if (PSI_SHOW_MOUNT_OPTION === true) {
|
||||
$percentUsed = $dev->getPercentUsed();
|
||||
$mount->addAttribute('Percent', $percentUsed);
|
||||
if ($dev->getPercentInodesUsed() !== null) {
|
||||
$mount->addAttribute('Inodes', $dev->getPercentInodesUsed());
|
||||
}
|
||||
if ($dev->getIgnore() > 0) $mount->addAttribute('Ignore', $dev->getIgnore());
|
||||
if (PSI_SHOW_MOUNT_OPTION) {
|
||||
if ($dev->getOptions() !== null) {
|
||||
$mount->addAttribute('MountOptions', preg_replace("/,/", ", ", $dev->getOptions()));
|
||||
}
|
||||
}
|
||||
if ($dev->getPercentInodesUsed() !== null) {
|
||||
$mount->addAttribute('Inodes', $dev->getPercentInodesUsed());
|
||||
}
|
||||
if (PSI_SHOW_MOUNT_POINT === true) {
|
||||
if (PSI_SHOW_MOUNT_POINT && ($dev->getMountPoint() !== null)) {
|
||||
$mount->addAttribute('MountPoint', $dev->getMountPoint());
|
||||
}
|
||||
}
|
||||
@@ -381,8 +578,7 @@ class XML
|
||||
*/
|
||||
private function _buildFilesystems()
|
||||
{
|
||||
$hideMounts = $hideFstypes = $hideDisks = array();
|
||||
$i = 1;
|
||||
$hideMounts = $hideFstypes = $hideDisks = $ignoreFree = $ignoreTotal = $ignoreUsage = $ignoreThreshold = array();
|
||||
if (defined('PSI_HIDE_MOUNTS') && is_string(PSI_HIDE_MOUNTS)) {
|
||||
if (preg_match(ARRAY_EXP, PSI_HIDE_MOUNTS)) {
|
||||
$hideMounts = eval(PSI_HIDE_MOUNTS);
|
||||
@@ -408,10 +604,48 @@ class XML
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (defined('PSI_IGNORE_FREE') && is_string(PSI_IGNORE_FREE)) {
|
||||
if (preg_match(ARRAY_EXP, PSI_IGNORE_FREE)) {
|
||||
$ignoreFree = eval(PSI_IGNORE_FREE);
|
||||
} else {
|
||||
$ignoreFree = array(PSI_IGNORE_FREE);
|
||||
}
|
||||
}
|
||||
if (defined('PSI_IGNORE_TOTAL') && is_string(PSI_IGNORE_TOTAL)) {
|
||||
if (preg_match(ARRAY_EXP, PSI_IGNORE_TOTAL)) {
|
||||
$ignoreTotal = eval(PSI_IGNORE_TOTAL);
|
||||
} else {
|
||||
$ignoreTotal = array(PSI_IGNORE_TOTAL);
|
||||
}
|
||||
}
|
||||
if (defined('PSI_IGNORE_USAGE') && is_string(PSI_IGNORE_USAGE)) {
|
||||
if (preg_match(ARRAY_EXP, PSI_IGNORE_USAGE)) {
|
||||
$ignoreUsage = eval(PSI_IGNORE_USAGE);
|
||||
} else {
|
||||
$ignoreUsage = array(PSI_IGNORE_USAGE);
|
||||
}
|
||||
}
|
||||
if (defined('PSI_IGNORE_THRESHOLD_FS_TYPES') && is_string(PSI_IGNORE_THRESHOLD_FS_TYPES)) {
|
||||
if (preg_match(ARRAY_EXP, PSI_IGNORE_THRESHOLD_FS_TYPES)) {
|
||||
$ignoreThreshold = eval(PSI_IGNORE_THRESHOLD_FS_TYPES);
|
||||
} else {
|
||||
$ignoreThreshold = array(PSI_IGNORE_THRESHOLD_FS_TYPES);
|
||||
}
|
||||
}
|
||||
$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');
|
||||
if (in_array($disk->getFsType(), $ignoreThreshold, true)) {
|
||||
$disk->setIgnore(4);
|
||||
} elseif (in_array($disk->getMountPoint(), $ignoreUsage, true)) {
|
||||
$disk->setIgnore(3);
|
||||
} elseif (in_array($disk->getMountPoint(), $ignoreTotal, true)) {
|
||||
$disk->setIgnore(2);
|
||||
} elseif (in_array($disk->getMountPoint(), $ignoreFree, true)) {
|
||||
$disk->setIgnore(1);
|
||||
}
|
||||
$this->_fillDevice($mount, $disk, $i++);
|
||||
}
|
||||
}
|
||||
@@ -425,105 +659,151 @@ class XML
|
||||
private function _buildMbinfo()
|
||||
{
|
||||
$mbinfo = $this->_xml->addChild('MBInfo');
|
||||
$temp = $fan = $volt = $power = $current = null;
|
||||
$temp = $fan = $volt = $power = $current = $other = null;
|
||||
$hideSensors = array();
|
||||
|
||||
if (sizeof(unserialize(PSI_MBINFO))>0) {
|
||||
if (defined('PSI_HIDE_SENSORS') && is_string(PSI_HIDE_SENSORS)) {
|
||||
if (preg_match(ARRAY_EXP, PSI_HIDE_SENSORS)) {
|
||||
$hideSensors = eval(PSI_HIDE_SENSORS);
|
||||
} else {
|
||||
$hideSensors = array(PSI_HIDE_SENSORS);
|
||||
}
|
||||
}
|
||||
foreach (unserialize(PSI_MBINFO) as $mbinfoclass) {
|
||||
$mbinfo_data = new $mbinfoclass();
|
||||
$mbinfo_detail = $mbinfo_data->getMBInfo();
|
||||
|
||||
foreach ($mbinfo_detail->getMbTemp() as $dev) {
|
||||
if ($temp == null) {
|
||||
$temp = $mbinfo->addChild('Temperature');
|
||||
}
|
||||
$item = $temp->addChild('Item');
|
||||
$item->addAttribute('Label', $dev->getName());
|
||||
$item->addAttribute('Value', $dev->getValue());
|
||||
if ($dev->getMax() !== null) {
|
||||
$item->addAttribute('Max', $dev->getMax());
|
||||
}
|
||||
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
|
||||
$item->addAttribute('Event', $dev->getEvent());
|
||||
if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='temperature' || $this->_sysinfo->getBlockName()==='mbinfo') foreach ($mbinfo_detail->getMbTemp() as $dev) {
|
||||
$mbinfo_name = $dev->getName();
|
||||
if (!in_array($mbinfo_name, $hideSensors, true)) {
|
||||
if ($temp == null) {
|
||||
$temp = $mbinfo->addChild('Temperature');
|
||||
}
|
||||
$item = $temp->addChild('Item');
|
||||
$item->addAttribute('Label', $mbinfo_name);
|
||||
$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() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) {
|
||||
$item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($mbinfo_detail->getMbFan() as $dev) {
|
||||
if ($fan == null) {
|
||||
$fan = $mbinfo->addChild('Fans');
|
||||
}
|
||||
$item = $fan->addChild('Item');
|
||||
$item->addAttribute('Label', $dev->getName());
|
||||
$item->addAttribute('Value', $dev->getValue());
|
||||
if ($dev->getMin() !== null) {
|
||||
$item->addAttribute('Min', $dev->getMin());
|
||||
}
|
||||
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
|
||||
$item->addAttribute('Event', $dev->getEvent());
|
||||
if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='fans' || $this->_sysinfo->getBlockName()==='mbinfo') foreach ($mbinfo_detail->getMbFan() as $dev) {
|
||||
$mbinfo_name = $dev->getName();
|
||||
if (!in_array($mbinfo_name, $hideSensors, true)) {
|
||||
if ($fan == null) {
|
||||
$fan = $mbinfo->addChild('Fans');
|
||||
}
|
||||
$item = $fan->addChild('Item');
|
||||
$item->addAttribute('Label', $mbinfo_name);
|
||||
$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() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) {
|
||||
$item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($mbinfo_detail->getMbVolt() as $dev) {
|
||||
if ($volt == null) {
|
||||
$volt = $mbinfo->addChild('Voltage');
|
||||
}
|
||||
$item = $volt->addChild('Item');
|
||||
$item->addAttribute('Label', $dev->getName());
|
||||
$item->addAttribute('Value', $dev->getValue());
|
||||
if ($dev->getMin() !== null) {
|
||||
$item->addAttribute('Min', $dev->getMin());
|
||||
}
|
||||
if ($dev->getMax() !== null) {
|
||||
$item->addAttribute('Max', $dev->getMax());
|
||||
}
|
||||
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
|
||||
$item->addAttribute('Event', $dev->getEvent());
|
||||
if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='voltage' || $this->_sysinfo->getBlockName()==='mbinfo') foreach ($mbinfo_detail->getMbVolt() as $dev) {
|
||||
$mbinfo_name = $dev->getName();
|
||||
if (!in_array($mbinfo_name, $hideSensors, true)) {
|
||||
if ($volt == null) {
|
||||
$volt = $mbinfo->addChild('Voltage');
|
||||
}
|
||||
$item = $volt->addChild('Item');
|
||||
$item->addAttribute('Label', $mbinfo_name);
|
||||
$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() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) {
|
||||
$item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($mbinfo_detail->getMbPower() as $dev) {
|
||||
if ($power == null) {
|
||||
$power = $mbinfo->addChild('Power');
|
||||
}
|
||||
$item = $power->addChild('Item');
|
||||
$item->addAttribute('Label', $dev->getName());
|
||||
$item->addAttribute('Value', $dev->getValue());
|
||||
if ($dev->getMax() !== null) {
|
||||
$item->addAttribute('Max', $dev->getMax());
|
||||
}
|
||||
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
|
||||
$item->addAttribute('Event', $dev->getEvent());
|
||||
if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='power' || $this->_sysinfo->getBlockName()==='mbinfo') foreach ($mbinfo_detail->getMbPower() as $dev) {
|
||||
$mbinfo_name = $dev->getName();
|
||||
if (!in_array($mbinfo_name, $hideSensors, true)) {
|
||||
if ($power == null) {
|
||||
$power = $mbinfo->addChild('Power');
|
||||
}
|
||||
$item = $power->addChild('Item');
|
||||
$item->addAttribute('Label', $mbinfo_name);
|
||||
$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() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) {
|
||||
$item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($mbinfo_detail->getMbCurrent() as $dev) {
|
||||
if ($current == null) {
|
||||
$current = $mbinfo->addChild('Current');
|
||||
}
|
||||
$item = $current->addChild('Item');
|
||||
$item->addAttribute('Label', $dev->getName());
|
||||
$item->addAttribute('Value', $dev->getValue());
|
||||
if ($dev->getMax() !== null) {
|
||||
$item->addAttribute('Max', $dev->getMax());
|
||||
}
|
||||
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
|
||||
$item->addAttribute('Event', $dev->getEvent());
|
||||
if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='current' || $this->_sysinfo->getBlockName()==='mbinfo') foreach ($mbinfo_detail->getMbCurrent() as $dev) {
|
||||
$mbinfo_name = $dev->getName();
|
||||
if (!in_array($mbinfo_name, $hideSensors, true)) {
|
||||
if ($current == null) {
|
||||
$current = $mbinfo->addChild('Current');
|
||||
}
|
||||
$item = $current->addChild('Item');
|
||||
$item->addAttribute('Label', $mbinfo_name);
|
||||
$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() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) {
|
||||
$item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (PSI_HDDTEMP) {
|
||||
$hddtemp = new HDDTemp();
|
||||
$hddtemp_data = $hddtemp->getMBInfo();
|
||||
foreach ($hddtemp_data->getMbTemp() as $dev) {
|
||||
if ($temp == null) {
|
||||
$temp = $mbinfo->addChild('Temperature');
|
||||
}
|
||||
$item = $temp->addChild('Item');
|
||||
$item->addAttribute('Label', $dev->getName());
|
||||
$item->addAttribute('Value', $dev->getValue());
|
||||
if ($dev->getMax() !== null) {
|
||||
$item->addAttribute('Max', $dev->getMax());
|
||||
if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='other' || $this->_sysinfo->getBlockName()==='mbinfo') foreach ($mbinfo_detail->getMbOther() as $dev) {
|
||||
$mbinfo_name = $dev->getName();
|
||||
if (!in_array($mbinfo_name, $hideSensors, true)) {
|
||||
if ($other == null) {
|
||||
$other = $mbinfo->addChild('Other');
|
||||
}
|
||||
$item = $other->addChild('Item');
|
||||
$item->addAttribute('Label', $mbinfo_name);
|
||||
$item->addAttribute('Value', $dev->getValue());
|
||||
if ($dev->getUnit() !== "") {
|
||||
$item->addAttribute('Unit', $dev->getUnit());
|
||||
}
|
||||
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
|
||||
$item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -537,7 +817,7 @@ class XML
|
||||
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) {
|
||||
@@ -550,11 +830,16 @@ class XML
|
||||
if ($ups->getModel() !== "") {
|
||||
$item->addAttribute('Model', $ups->getModel());
|
||||
}
|
||||
$item->addAttribute('Mode', $ups->getMode());
|
||||
if ($ups->getMode() !== "") {
|
||||
$item->addAttribute('Mode', $ups->getMode());
|
||||
}
|
||||
if ($ups->getStartTime() !== "") {
|
||||
$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());
|
||||
}
|
||||
@@ -600,9 +885,14 @@ class XML
|
||||
*/
|
||||
private function _buildXml()
|
||||
{
|
||||
if (!$this->_plugin_request || $this->_complete_request) {
|
||||
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->addWarning("This is an unstable version of phpSysInfo, some things may not work correctly");
|
||||
}
|
||||
|
||||
// Safe mode check
|
||||
$safe_mode = @ini_get("safe_mode") ? true : false;
|
||||
if ($safe_mode) {
|
||||
@@ -620,28 +910,28 @@ class XML
|
||||
$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");
|
||||
}
|
||||
}
|
||||
$this->_sys = $this->_sysinfo->getSys();
|
||||
}
|
||||
$this->_buildVitals();
|
||||
$this->_buildNetwork();
|
||||
$this->_buildHardware();
|
||||
$this->_buildMemory();
|
||||
$this->_buildFilesystems();
|
||||
$this->_buildMbinfo();
|
||||
$this->_buildUpsinfo();
|
||||
if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='vitals') $this->_buildVitals();
|
||||
if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='network') $this->_buildNetwork();
|
||||
if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='hardware') $this->_buildHardware();
|
||||
if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='memory') $this->_buildMemory();
|
||||
if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='filesystem') $this->_buildFilesystems();
|
||||
if (!$this->_sysinfo->getBlockName() || in_array($this->_sysinfo->getBlockName(), array('mbinfo','voltage','current','temperature','fans','power','other'))) $this->_buildMbinfo();
|
||||
if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='ups') $this->_buildUpsinfo();
|
||||
}
|
||||
$this->_buildPlugins();
|
||||
if (!$this->_sysinfo->getBlockName()) $this->_buildPlugins();
|
||||
$this->_xml->combinexml($this->_errors->errorsAddToXML($this->_sysinfo->getEncoding()));
|
||||
}
|
||||
|
||||
/**
|
||||
* get the xml object
|
||||
*
|
||||
* @return string
|
||||
* @return SimpleXmlElement
|
||||
*/
|
||||
public function getXml()
|
||||
{
|
||||
@@ -658,20 +948,25 @@ class XML
|
||||
private function _buildPlugins()
|
||||
{
|
||||
$pluginroot = $this->_xml->addChild("Plugins");
|
||||
if (($this->_plugin_request || $this->_complete_request) && count($this->_plugins) > 0) {
|
||||
if ((($this->_plugin != '') || $this->_complete_request) && count($this->_plugins) > 0) {
|
||||
$plugins = array();
|
||||
if ($this->_complete_request) {
|
||||
$plugins = $this->_plugins;
|
||||
}
|
||||
if ($this->_plugin_request) {
|
||||
if (($this->_plugin != '')) {
|
||||
$plugins = array($this->_plugin);
|
||||
}
|
||||
foreach ($plugins as $plugin) {
|
||||
$object = new $plugin($this->_sysinfo->getEncoding());
|
||||
$object->execute();
|
||||
$oxml = $object->xml();
|
||||
if (sizeof($oxml) > 0) {
|
||||
$pluginroot->combinexml($oxml);
|
||||
if (!$this->_complete_request ||
|
||||
(!defined('PSI_PLUGIN_'.strtoupper($plugin).'_SSH_HOSTNAME') && !defined('PSI_PLUGIN_'.strtoupper($plugin).'_WMI_HOSTNAME')) ||
|
||||
(defined('PSI_SSH_HOSTNAME') && (PSI_SSH_HOSTNAME == constant('PSI_PLUGIN_'.strtoupper($plugin).'_SSH_HOSTNAME'))) ||
|
||||
(defined('PSI_WMI_HOSTNAME') && (PSI_WMI_HOSTNAME == constant('PSI_PLUGIN_'.strtoupper($plugin).'_WMI_HOSTNAME')))) {
|
||||
$object = new $plugin($this->_sysinfo->getEncoding());
|
||||
$object->execute();
|
||||
$oxml = $object->xml();
|
||||
if (sizeof($oxml) > 0) {
|
||||
$pluginroot->combinexml($oxml);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -698,32 +993,21 @@ class XML
|
||||
$options = $this->_xml->addChild('Options');
|
||||
$options->addAttribute('tempFormat', defined('PSI_TEMP_FORMAT') ? strtolower(PSI_TEMP_FORMAT) : 'c');
|
||||
$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')) {
|
||||
if (PSI_REFRESH === false) {
|
||||
$options->addAttribute('refresh', 0);
|
||||
} elseif (PSI_REFRESH === true) {
|
||||
$options->addAttribute('refresh', 1);
|
||||
} else {
|
||||
$options->addAttribute('refresh', PSI_REFRESH);
|
||||
}
|
||||
$options->addAttribute('refresh', max(intval(PSI_REFRESH), 0));
|
||||
} else {
|
||||
$options->addAttribute('refresh', 60000);
|
||||
}
|
||||
if (defined('PSI_FS_USAGE_THRESHOLD')) {
|
||||
if (PSI_FS_USAGE_THRESHOLD === true) {
|
||||
$options->addAttribute('threshold', 1);
|
||||
} elseif ((PSI_FS_USAGE_THRESHOLD !== false) && (PSI_FS_USAGE_THRESHOLD >= 1) && (PSI_FS_USAGE_THRESHOLD <= 99)) {
|
||||
$options->addAttribute('threshold', PSI_FS_USAGE_THRESHOLD);
|
||||
if ((($fsut = intval(PSI_FS_USAGE_THRESHOLD)) >= 1) && ($fsut <= 99)) {
|
||||
$options->addAttribute('threshold', $fsut);
|
||||
}
|
||||
} else {
|
||||
$options->addAttribute('threshold', 90);
|
||||
}
|
||||
$options->addAttribute('showPickListTemplate', defined('PSI_SHOW_PICKLIST_TEMPLATE') ? (PSI_SHOW_PICKLIST_TEMPLATE ? 'true' : 'false') : 'false');
|
||||
$options->addAttribute('showPickListLang', defined('PSI_SHOW_PICKLIST_LANG') ? (PSI_SHOW_PICKLIST_LANG ? 'true' : 'false') : 'false');
|
||||
$options->addAttribute('showCPUListExpanded', defined('PSI_SHOW_CPULIST_EXPANDED') ? (PSI_SHOW_CPULIST_EXPANDED ? 'true' : 'false') : 'true');
|
||||
$options->addAttribute('showCPUInfoExpanded', defined('PSI_SHOW_CPUINFO_EXPANDED') ? (PSI_SHOW_CPUINFO_EXPANDED ? 'true' : 'false') : 'false');
|
||||
if (count($this->_plugins) > 0) {
|
||||
if ($this->_plugin_request) {
|
||||
if (($this->_plugin != '')) {
|
||||
$plug = $this->_xml->addChild('UsedPlugins');
|
||||
$plug->addChild('Plugin')->addAttribute('name', $this->_plugin);
|
||||
} elseif ($this->_complete_request) {
|
||||
@@ -731,11 +1015,13 @@ class XML
|
||||
foreach ($this->_plugins as $plugin) {
|
||||
$plug->addChild('Plugin')->addAttribute('name', $plugin);
|
||||
}
|
||||
/*
|
||||
} else {
|
||||
$plug = $this->_xml->addChild('UnusedPlugins');
|
||||
foreach ($this->_plugins as $plugin) {
|
||||
$plug->addChild('Plugin')->addAttribute('name', $plugin);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user