2780 |
rexy |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* StableBit Plugin, which displays disks state
|
|
|
4 |
*
|
|
|
5 |
* @category PHP
|
|
|
6 |
* @package PSI_Plugin_StableBit
|
|
|
7 |
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
|
|
|
8 |
* @copyright 2017 phpSysInfo
|
|
|
9 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
|
|
10 |
* @version $Id: class.stablebit.inc.php 661 2012-08-27 11:26:39Z namiltd $
|
|
|
11 |
* @link http://phpsysinfo.sourceforge.net
|
|
|
12 |
*/
|
|
|
13 |
class StableBit extends PSI_Plugin
|
|
|
14 |
{
|
|
|
15 |
/**
|
|
|
16 |
* variable, which holds the result before the xml is generated out of this array
|
|
|
17 |
* @var array
|
|
|
18 |
*/
|
|
|
19 |
private $_result;
|
|
|
20 |
|
|
|
21 |
/**
|
|
|
22 |
* read the data into an internal array and also call the parent constructor
|
|
|
23 |
*
|
|
|
24 |
* @param String $enc encoding
|
|
|
25 |
*/
|
|
|
26 |
public function __construct($enc)
|
|
|
27 |
{
|
|
|
28 |
parent::__construct(__CLASS__, $enc);
|
|
|
29 |
|
|
|
30 |
$this->_result = array();
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
private $stablebit_items = array('Name', 'Firmware', 'Size', 'TemperatureC', 'PowerState', 'IsHot', 'IsSmartWarning', 'IsSmartPastThresholds', 'IsSmartPastAdvisoryThresholds', 'IsSmartFailurePredicted', 'IsDamaged', 'SerialNumber');
|
|
|
34 |
|
|
|
35 |
/**
|
|
|
36 |
* doing all tasks to get the required informations that the plugin needs
|
|
|
37 |
* result is stored in an internal array
|
|
|
38 |
*
|
|
|
39 |
* @return void
|
|
|
40 |
*/
|
|
|
41 |
public function execute()
|
|
|
42 |
{
|
|
|
43 |
if (PSI_OS == 'WINNT') {
|
|
|
44 |
try {
|
|
|
45 |
$objLocator = new COM('WbemScripting.SWbemLocator');
|
|
|
46 |
$wmi = $objLocator->ConnectServer('', 'root\StableBit\Scanner');
|
|
|
47 |
$this->_result = CommonFunctions::getWMI($wmi, 'Disks', $this->stablebit_items);
|
|
|
48 |
} catch (Exception $e) {
|
|
|
49 |
}
|
|
|
50 |
}
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
/**
|
|
|
54 |
* generates the XML content for the plugin
|
|
|
55 |
*
|
|
|
56 |
* @return SimpleXMLElement entire XML content for the plugin
|
|
|
57 |
*/
|
|
|
58 |
public function xml()
|
|
|
59 |
{
|
|
|
60 |
foreach ($this->_result as $disk_items) {
|
|
|
61 |
if (isset($disk_items['Name']) && (trim($disk_items['Name']) !== '')) {
|
|
|
62 |
$xmlstablebit_disk = $this->xml->addChild("Disk");
|
|
|
63 |
foreach ($this->stablebit_items as $item) {
|
|
|
64 |
if (isset($disk_items[$item]) && (($itemvalue=$disk_items[$item]) !== '') &&
|
|
|
65 |
(($item !== 'SerialNumber') || (defined('PSI_PLUGIN_STABLEBIT_SHOW_SERIAL') && (PSI_PLUGIN_STABLEBIT_SHOW_SERIAL === true)))) {
|
|
|
66 |
$xmlstablebit_disk ->addAttribute($item, $itemvalue);
|
|
|
67 |
}
|
|
|
68 |
}
|
|
|
69 |
}
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
return $this->xml->getSimpleXmlElement();
|
|
|
73 |
}
|
|
|
74 |
}
|