Subversion Repositories ALCASAR

Rev

Rev 2770 | Rev 3037 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2770 Rev 2976
Line 64... Line 64...
64
     * @var string
64
     * @var string
65
     */
65
     */
66
    private $_plugin = '';
66
    private $_plugin = '';
67
 
67
 
68
    /**
68
    /**
69
     * generate a xml for a plugin or for the main app
-
 
70
     *
-
 
71
     * @var boolean
-
 
72
     */
-
 
73
    private $_plugin_request = false;
-
 
74
 
-
 
75
    /**
-
 
76
     * generate the entire xml with all plugins or only a part of the xml (main or plugin)
69
     * generate the entire xml with all plugins or only a part of the xml (main or plugin)
77
     *
70
     *
78
     * @var boolean
71
     * @var boolean
79
     */
72
     */
80
    private $_complete_request = false;
73
    private $_complete_request = false;
Line 91... Line 84...
91
     * @return void
84
     * @return void
92
     */
85
     */
93
    public function __construct($complete = false, $pluginname = "", $blockname = false)
86
    public function __construct($complete = false, $pluginname = "", $blockname = false)
94
    {
87
    {
95
        $this->_errors = PSI_Error::singleton();
88
        $this->_errors = PSI_Error::singleton();
96
        if ($pluginname == "") {
-
 
97
            $this->_plugin_request = false;
-
 
98
            $this->_plugin = '';
-
 
99
        } else {
-
 
100
            $this->_plugin_request = true;
-
 
101
            $this->_plugin = $pluginname;
89
        $this->_plugin = $pluginname;
102
        }
-
 
103
        if ($complete) {
90
        if ($complete) {
104
            $this->_complete_request = true;
91
            $this->_complete_request = true;
105
        } else {
92
        } else {
106
            $this->_complete_request = false;
93
            $this->_complete_request = false;
107
        }
94
        }
-
 
95
        if (defined('PSI_EMU_HOSTNAME')) {
-
 
96
            $os = 'WINNT';
-
 
97
        } else {
108
        $os = PSI_OS;
98
            $os = PSI_OS;
-
 
99
        }
109
        $this->_sysinfo = new $os($blockname);
100
        $this->_sysinfo = new $os($blockname);
110
        $this->_plugins = CommonFunctions::getPlugins();
101
        $this->_plugins = CommonFunctions::getPlugins();
111
        $this->_xmlbody();
102
        $this->_xmlbody();
112
    }
103
    }
113
 
104
 
Line 167... Line 158...
167
                        $vitals->addAttribute('ProcessesOther', $proctmp);
158
                        $vitals->addAttribute('ProcessesOther', $proctmp);
168
                    }
159
                    }
169
                }
160
                }
170
            }
161
            }
171
        }
162
        }
-
 
163
 
-
 
164
        if (defined('PSI_EMU_HOSTNAME')) {
172
//        $vitals->addAttribute('OS', PSI_OS);
165
            $vitals->addAttribute('OS', 'WINNT');
-
 
166
        } else {
173
        $vitals->addAttribute('OS', (PSI_OS=='Android')?'Linux':PSI_OS);
167
            $vitals->addAttribute('OS', (PSI_OS=='Android')?'Linux':PSI_OS);
-
 
168
        }
174
    }
169
    }
175
 
170
 
176
    /**
171
    /**
177
     * generate the network information
172
     * generate the network information
178
     *
173
     *
Line 216... Line 211...
216
    {
211
    {
217
        $hardware = $this->_xml->addChild('Hardware');
212
        $hardware = $this->_xml->addChild('Hardware');
218
        if ($this->_sys->getMachine() != "") {
213
        if ($this->_sys->getMachine() != "") {
219
            $hardware->addAttribute('Name', $this->_sys->getMachine());
214
            $hardware->addAttribute('Name', $this->_sys->getMachine());
220
        }
215
        }
-
 
216
        $cpu = null;
-
 
217
        $vendortab = null;
-
 
218
        foreach ($this->_sys->getCpus() as $oneCpu) {
-
 
219
            if ($cpu === null) $cpu = $hardware->addChild('CPU');
-
 
220
            $tmp = $cpu->addChild('CpuCore');
-
 
221
            $tmp->addAttribute('Model', $oneCpu->getModel());
-
 
222
            if ($oneCpu->getCpuSpeed() !== 0) {
-
 
223
                $tmp->addAttribute('CpuSpeed', max($oneCpu->getCpuSpeed(), 0));
-
 
224
            }
-
 
225
            if ($oneCpu->getCpuSpeedMax() !== 0) {
-
 
226
                $tmp->addAttribute('CpuSpeedMax', $oneCpu->getCpuSpeedMax());
-
 
227
            }
-
 
228
            if ($oneCpu->getCpuSpeedMin() !== 0) {
-
 
229
                $tmp->addAttribute('CpuSpeedMin', $oneCpu->getCpuSpeedMin());
-
 
230
            }
-
 
231
/*
-
 
232
            if ($oneCpu->getTemp() !== null) {
-
 
233
                $tmp->addAttribute('CpuTemp', $oneCpu->getTemp());
-
 
234
            }
-
 
235
*/
-
 
236
            if ($oneCpu->getBusSpeed() !== null) {
-
 
237
                $tmp->addAttribute('BusSpeed', $oneCpu->getBusSpeed());
-
 
238
            }
-
 
239
            if ($oneCpu->getCache() !== null) {
-
 
240
                $tmp->addAttribute('Cache', $oneCpu->getCache());
-
 
241
            }
-
 
242
            if ($oneCpu->getVirt() !== null) {
-
 
243
                $tmp->addAttribute('Virt', $oneCpu->getVirt());
-
 
244
            }
-
 
245
            if ($oneCpu->getVendorId() !== null) {
-
 
246
                if ($vendortab === null) $vendortab = @parse_ini_file(PSI_APP_ROOT."/data/cpus.ini", true);
-
 
247
                $shortvendorid = preg_replace('/[\s!]/', '', $oneCpu->getVendorId());
-
 
248
                if ($vendortab && ($shortvendorid != "") && isset($vendortab['manufacturer'][$shortvendorid])) {
-
 
249
                    $tmp->addAttribute('Manufacturer', $vendortab['manufacturer'][$shortvendorid]);
-
 
250
                }
-
 
251
            }
-
 
252
            if ($oneCpu->getBogomips() !== null) {
-
 
253
                $tmp->addAttribute('Bogomips', $oneCpu->getBogomips());
-
 
254
            }
-
 
255
            if ($oneCpu->getLoad() !== null) {
-
 
256
                $tmp->addAttribute('Load', $oneCpu->getLoad());
-
 
257
            }
-
 
258
        }
221
        $pci = null;
259
        $mem = null;
222
        foreach (System::removeDupsAndCount($this->_sys->getPciDevices()) as $dev) {
260
        foreach (System::removeDupsAndCount($this->_sys->getMemDevices()) as $dev) {
223
            if ($pci === null) $pci = $hardware->addChild('PCI');
261
            if ($mem === null) $mem = $hardware->addChild('MEM');
224
            $tmp = $pci->addChild('Device');
262
            $tmp = $mem->addChild('Chip');
225
            $tmp->addAttribute('Name', $dev->getName());
263
            $tmp->addAttribute('Name', $dev->getName());
226
            if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
264
            if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
-
 
265
                if ($dev->getCapacity() !== null) {
-
 
266
                    $tmp->addAttribute('Capacity', $dev->getCapacity());
-
 
267
                }
227
                if ($dev->getManufacturer() !== null) {
268
                if ($dev->getManufacturer() !== null) {
228
                    $tmp->addAttribute('Manufacturer', $dev->getManufacturer());
269
                    $tmp->addAttribute('Manufacturer', $dev->getManufacturer());
229
                }
270
                }
230
                if ($dev->getProduct() !== null) {
271
                if ($dev->getProduct() !== null) {
231
                    $tmp->addAttribute('Product', $dev->getProduct());
272
                    $tmp->addAttribute('Product', $dev->getProduct());
232
                }
273
                }
-
 
274
                if ($dev->getSpeed() !== null) {
-
 
275
                    $tmp->addAttribute('Speed', $dev->getSpeed());
-
 
276
                }
-
 
277
                if ($dev->getVoltage() !== null) {
-
 
278
                    $tmp->addAttribute('Voltage', $dev->getVoltage());
-
 
279
                }
-
 
280
                if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL && ($dev->getSerial() !== null)) {
-
 
281
                    $tmp->addAttribute('Serial', $dev->getSerial());
-
 
282
                }
233
            }
283
            }
234
            if ($dev->getCount() > 1) {
284
            if ($dev->getCount() > 1) {
235
                $tmp->addAttribute('Count', $dev->getCount());
285
                $tmp->addAttribute('Count', $dev->getCount());
236
            }
286
            }
237
        }
287
        }
238
        $usb = null;
288
        $pci = null;
239
        foreach (System::removeDupsAndCount($this->_sys->getUsbDevices()) as $dev) {
289
        foreach (System::removeDupsAndCount($this->_sys->getPciDevices()) as $dev) {
240
            if ($usb === null) $usb = $hardware->addChild('USB');
290
            if ($pci === null) $pci = $hardware->addChild('PCI');
241
            $tmp = $usb->addChild('Device');
291
            $tmp = $pci->addChild('Device');
242
            $tmp->addAttribute('Name', $dev->getName());
292
            $tmp->addAttribute('Name', $dev->getName());
243
            if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
293
            if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
244
                if ($dev->getManufacturer() !== null) {
294
                if ($dev->getManufacturer() !== null) {
245
                    $tmp->addAttribute('Manufacturer', $dev->getManufacturer());
295
                    $tmp->addAttribute('Manufacturer', $dev->getManufacturer());
246
                }
296
                }
247
                if ($dev->getProduct() !== null) {
297
                if ($dev->getProduct() !== null) {
248
                    $tmp->addAttribute('Product', $dev->getProduct());
298
                    $tmp->addAttribute('Product', $dev->getProduct());
249
                }
299
                }
250
                if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL && ($dev->getSerial() !== null)) {
-
 
251
                    $tmp->addAttribute('Serial', $dev->getSerial());
-
 
252
                }
-
 
253
            }
300
            }
254
            if ($dev->getCount() > 1) {
301
            if ($dev->getCount() > 1) {
255
                $tmp->addAttribute('Count', $dev->getCount());
302
                $tmp->addAttribute('Count', $dev->getCount());
256
            }
303
            }
257
        }
304
        }
Line 304... Line 351...
304
            }
351
            }
305
            if ($dev->getCount() > 1) {
352
            if ($dev->getCount() > 1) {
306
                $tmp->addAttribute('Count', $dev->getCount());
353
                $tmp->addAttribute('Count', $dev->getCount());
307
            }
354
            }
308
        }
355
        }
-
 
356
        $usb = null;
-
 
357
        foreach (System::removeDupsAndCount($this->_sys->getUsbDevices()) as $dev) {
-
 
358
            if ($usb === null) $usb = $hardware->addChild('USB');
-
 
359
            $tmp = $usb->addChild('Device');
-
 
360
            $tmp->addAttribute('Name', $dev->getName());
-
 
361
            if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
-
 
362
                if ($dev->getManufacturer() !== null) {
-
 
363
                    $tmp->addAttribute('Manufacturer', $dev->getManufacturer());
-
 
364
                }
-
 
365
                if ($dev->getProduct() !== null) {
-
 
366
                    $tmp->addAttribute('Product', $dev->getProduct());
-
 
367
                }
-
 
368
                if ($dev->getSpeed() !== null) {
-
 
369
                    $tmp->addAttribute('Speed', $dev->getSpeed());
-
 
370
                }
-
 
371
                if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL && ($dev->getSerial() !== null)) {
-
 
372
                    $tmp->addAttribute('Serial', $dev->getSerial());
-
 
373
                }
-
 
374
            }
-
 
375
            if ($dev->getCount() > 1) {
-
 
376
                $tmp->addAttribute('Count', $dev->getCount());
-
 
377
            }
-
 
378
        }
309
        $tb = null;
379
        $tb = null;
310
        foreach (System::removeDupsAndCount($this->_sys->getTbDevices()) as $dev) {
380
        foreach (System::removeDupsAndCount($this->_sys->getTbDevices()) as $dev) {
311
            if ($tb === null) $tb = $hardware->addChild('TB');
381
            if ($tb === null) $tb = $hardware->addChild('TB');
312
            $tmp = $tb->addChild('Device');
382
            $tmp = $tb->addChild('Device');
313
            $tmp->addAttribute('Name', $dev->getName());
383
            $tmp->addAttribute('Name', $dev->getName());
Line 322... Line 392...
322
            $tmp->addAttribute('Name', $dev->getName());
392
            $tmp->addAttribute('Name', $dev->getName());
323
            if ($dev->getCount() > 1) {
393
            if ($dev->getCount() > 1) {
324
                $tmp->addAttribute('Count', $dev->getCount());
394
                $tmp->addAttribute('Count', $dev->getCount());
325
            }
395
            }
326
        }
396
        }
327
 
-
 
328
        $cpu = null;
-
 
329
        $vendortab = null;
-
 
330
        foreach ($this->_sys->getCpus() as $oneCpu) {
-
 
331
            if ($cpu === null) $cpu = $hardware->addChild('CPU');
-
 
332
            $tmp = $cpu->addChild('CpuCore');
-
 
333
            $tmp->addAttribute('Model', $oneCpu->getModel());
-
 
334
            if ($oneCpu->getCpuSpeed() !== 0) {
-
 
335
                $tmp->addAttribute('CpuSpeed', max($oneCpu->getCpuSpeed(), 0));
-
 
336
            }
-
 
337
            if ($oneCpu->getCpuSpeedMax() !== 0) {
-
 
338
                $tmp->addAttribute('CpuSpeedMax', $oneCpu->getCpuSpeedMax());
-
 
339
            }
-
 
340
            if ($oneCpu->getCpuSpeedMin() !== 0) {
-
 
341
                $tmp->addAttribute('CpuSpeedMin', $oneCpu->getCpuSpeedMin());
-
 
342
            }
-
 
343
/*
-
 
344
            if ($oneCpu->getTemp() !== null) {
-
 
345
                $tmp->addAttribute('CpuTemp', $oneCpu->getTemp());
-
 
346
            }
-
 
347
*/
-
 
348
            if ($oneCpu->getBusSpeed() !== null) {
-
 
349
                $tmp->addAttribute('BusSpeed', $oneCpu->getBusSpeed());
-
 
350
            }
-
 
351
            if ($oneCpu->getCache() !== null) {
-
 
352
                $tmp->addAttribute('Cache', $oneCpu->getCache());
-
 
353
            }
-
 
354
            if ($oneCpu->getVirt() !== null) {
-
 
355
                $tmp->addAttribute('Virt', $oneCpu->getVirt());
-
 
356
            }
-
 
357
            if ($oneCpu->getVendorId() !== null) {
-
 
358
                if ($vendortab === null) $vendortab = @parse_ini_file(PSI_APP_ROOT."/data/cpus.ini", true);
-
 
359
                $shortvendorid = preg_replace('/[\s!]/', '', $oneCpu->getVendorId());
-
 
360
                if ($vendortab && ($shortvendorid != "") && isset($vendortab['manufacturer'][$shortvendorid])) {
-
 
361
                    $tmp->addAttribute('Manufacturer', $vendortab['manufacturer'][$shortvendorid]);
-
 
362
                }
-
 
363
            }
-
 
364
            if ($oneCpu->getBogomips() !== null) {
-
 
365
                $tmp->addAttribute('Bogomips', $oneCpu->getBogomips());
-
 
366
            }
-
 
367
            if ($oneCpu->getLoad() !== null) {
-
 
368
                $tmp->addAttribute('Load', $oneCpu->getLoad());
-
 
369
            }
-
 
370
        }
-
 
371
    }
397
    }
372
 
398
 
373
    /**
399
    /**
374
     * generate the memory information
400
     * generate the memory information
375
     *
401
     *
Line 421... Line 447...
421
     * @return Void
447
     * @return Void
422
     */
448
     */
423
    private function _fillDevice(SimpleXMLExtended $mount, DiskDevice $dev, $i)
449
    private function _fillDevice(SimpleXMLExtended $mount, DiskDevice $dev, $i)
424
    {
450
    {
425
        $mount->addAttribute('MountPointID', $i);
451
        $mount->addAttribute('MountPointID', $i);
-
 
452
        if ($dev->getFsType()!=="") {
426
        if ($dev->getFsType()!=="") $mount->addAttribute('FSType', $dev->getFsType());
453
            $mount->addAttribute('FSType', $dev->getFsType());
-
 
454
        }
427
        $mount->addAttribute('Name', $dev->getName());
455
        $mount->addAttribute('Name', $dev->getName());
428
        $mount->addAttribute('Free', sprintf("%.0f", $dev->getFree()));
456
        $mount->addAttribute('Free', sprintf("%.0f", $dev->getFree()));
429
        $mount->addAttribute('Used', sprintf("%.0f", $dev->getUsed()));
457
        $mount->addAttribute('Used', sprintf("%.0f", $dev->getUsed()));
430
        $mount->addAttribute('Total', sprintf("%.0f", $dev->getTotal()));
458
        $mount->addAttribute('Total', sprintf("%.0f", $dev->getTotal()));
-
 
459
        $percentUsed = $dev->getPercentUsed();
431
        $mount->addAttribute('Percent', $dev->getPercentUsed());
460
        $mount->addAttribute('Percent', $percentUsed);
-
 
461
        if ($dev->getPercentInodesUsed() !== null) {
-
 
462
            $mount->addAttribute('Inodes', $dev->getPercentInodesUsed());
-
 
463
        }
432
        if ($dev->getIgnore() > 0) $mount->addAttribute('Ignore', $dev->getIgnore());
464
        if ($dev->getIgnore() > 0) $mount->addAttribute('Ignore', $dev->getIgnore());
433
        if (PSI_SHOW_MOUNT_OPTION === true) {
465
        if (PSI_SHOW_MOUNT_OPTION === true) {
434
            if ($dev->getOptions() !== null) {
466
            if ($dev->getOptions() !== null) {
435
                $mount->addAttribute('MountOptions', preg_replace("/,/", ", ", $dev->getOptions()));
467
                $mount->addAttribute('MountOptions', preg_replace("/,/", ", ", $dev->getOptions()));
436
            }
468
            }
437
        }
469
        }
438
        if ($dev->getPercentInodesUsed() !== null) {
-
 
439
            $mount->addAttribute('Inodes', $dev->getPercentInodesUsed());
-
 
440
        }
-
 
441
        if (PSI_SHOW_MOUNT_POINT === true) {
470
        if (PSI_SHOW_MOUNT_POINT === true) {
442
            $mount->addAttribute('MountPoint', $dev->getMountPoint());
471
            $mount->addAttribute('MountPoint', $dev->getMountPoint());
443
        }
472
        }
444
    }
473
    }
445
 
474
 
Line 448... Line 477...
448
     *
477
     *
449
     * @return void
478
     * @return void
450
     */
479
     */
451
    private function _buildFilesystems()
480
    private function _buildFilesystems()
452
    {
481
    {
453
        $hideMounts = $hideFstypes = $hideDisks = $ignoreFree = $ignoreUsage = $ignoreThreshold = array();
482
        $hideMounts = $hideFstypes = $hideDisks = $ignoreFree = $ignoreTotal = $ignoreUsage = $ignoreThreshold = array();
454
        $i = 1;
483
        $i = 1;
455
        if (defined('PSI_HIDE_MOUNTS') && is_string(PSI_HIDE_MOUNTS)) {
484
        if (defined('PSI_HIDE_MOUNTS') && is_string(PSI_HIDE_MOUNTS)) {
456
            if (preg_match(ARRAY_EXP, PSI_HIDE_MOUNTS)) {
485
            if (preg_match(ARRAY_EXP, PSI_HIDE_MOUNTS)) {
457
                $hideMounts = eval(PSI_HIDE_MOUNTS);
486
                $hideMounts = eval(PSI_HIDE_MOUNTS);
458
            } else {
487
            } else {
Line 482... Line 511...
482
                $ignoreFree = eval(PSI_IGNORE_FREE);
511
                $ignoreFree = eval(PSI_IGNORE_FREE);
483
            } else {
512
            } else {
484
                $ignoreFree = array(PSI_IGNORE_FREE);
513
                $ignoreFree = array(PSI_IGNORE_FREE);
485
            }
514
            }
486
        }
515
        }
-
 
516
        if (defined('PSI_IGNORE_TOTAL') && is_string(PSI_IGNORE_TOTAL)) {
-
 
517
            if (preg_match(ARRAY_EXP, PSI_IGNORE_TOTAL)) {
-
 
518
                $ignoreTotal = eval(PSI_IGNORE_TOTAL);
-
 
519
            } else {
-
 
520
                $ignoreTotal = array(PSI_IGNORE_TOTAL);
-
 
521
            }
-
 
522
        }
487
        if (defined('PSI_IGNORE_USAGE') && is_string(PSI_IGNORE_USAGE)) {
523
        if (defined('PSI_IGNORE_USAGE') && is_string(PSI_IGNORE_USAGE)) {
488
            if (preg_match(ARRAY_EXP, PSI_IGNORE_USAGE)) {
524
            if (preg_match(ARRAY_EXP, PSI_IGNORE_USAGE)) {
489
                $ignoreUsage = eval(PSI_IGNORE_USAGE);
525
                $ignoreUsage = eval(PSI_IGNORE_USAGE);
490
            } else {
526
            } else {
491
                $ignoreUsage = array(PSI_IGNORE_USAGE);
527
                $ignoreUsage = array(PSI_IGNORE_USAGE);
Line 501... Line 537...
501
        $fs = $this->_xml->addChild('FileSystem');
537
        $fs = $this->_xml->addChild('FileSystem');
502
        foreach ($this->_sys->getDiskDevices() as $disk) {
538
        foreach ($this->_sys->getDiskDevices() as $disk) {
503
            if (!in_array($disk->getMountPoint(), $hideMounts, true) && !in_array($disk->getFsType(), $hideFstypes, true) && !in_array($disk->getName(), $hideDisks, true)) {
539
            if (!in_array($disk->getMountPoint(), $hideMounts, true) && !in_array($disk->getFsType(), $hideFstypes, true) && !in_array($disk->getName(), $hideDisks, true)) {
504
                $mount = $fs->addChild('Mount');
540
                $mount = $fs->addChild('Mount');
505
                if (in_array($disk->getFsType(), $ignoreThreshold, true)) {
541
                if (in_array($disk->getFsType(), $ignoreThreshold, true)) {
506
                    $disk->setIgnore(3);
542
                    $disk->setIgnore(4);
507
                } elseif (in_array($disk->getMountPoint(), $ignoreUsage, true)) {
543
                } elseif (in_array($disk->getMountPoint(), $ignoreUsage, true)) {
-
 
544
                    $disk->setIgnore(3);
-
 
545
                } elseif (in_array($disk->getMountPoint(), $ignoreTotal, true)) {
508
                    $disk->setIgnore(2);
546
                    $disk->setIgnore(2);
509
                } elseif (in_array($disk->getMountPoint(), $ignoreFree, true)) {
547
                } elseif (in_array($disk->getMountPoint(), $ignoreFree, true)) {
510
                    $disk->setIgnore(1);
548
                    $disk->setIgnore(1);
511
                }
549
                }
512
                $this->_fillDevice($mount, $disk, $i++);
550
                $this->_fillDevice($mount, $disk, $i++);
Line 552... Line 590...
552
                    $item->addAttribute('Label', $dev->getName());
590
                    $item->addAttribute('Label', $dev->getName());
553
                    $item->addAttribute('Value', $dev->getValue());
591
                    $item->addAttribute('Value', $dev->getValue());
554
                    if ($dev->getMin() !== null) {
592
                    if ($dev->getMin() !== null) {
555
                        $item->addAttribute('Min', $dev->getMin());
593
                        $item->addAttribute('Min', $dev->getMin());
556
                    }
594
                    }
-
 
595
                    if ($dev->getUnit() !== "") {
-
 
596
                        $item->addAttribute('Unit', $dev->getUnit());
-
 
597
                    }
557
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
598
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
558
                        $item->addAttribute('Event', $dev->getEvent());
599
                        $item->addAttribute('Event', $dev->getEvent());
559
                    }
600
                    }
560
                }
601
                }
561
 
602
 
Line 564... Line 605...
564
                        $volt = $mbinfo->addChild('Voltage');
605
                        $volt = $mbinfo->addChild('Voltage');
565
                    }
606
                    }
566
                    $item = $volt->addChild('Item');
607
                    $item = $volt->addChild('Item');
567
                    $item->addAttribute('Label', $dev->getName());
608
                    $item->addAttribute('Label', $dev->getName());
568
                    $item->addAttribute('Value', $dev->getValue());
609
                    $item->addAttribute('Value', $dev->getValue());
-
 
610
                    if (($dev->getMin() === null) || ($dev->getMin() != 0) || ($dev->getMax() === null) || ($dev->getMax() != 0)) {
569
                    if ($dev->getMin() !== null) {
611
                        if ($dev->getMin() !== null) {
570
                        $item->addAttribute('Min', $dev->getMin());
612
                            $item->addAttribute('Min', $dev->getMin());
571
                    }
613
                        }
572
                    if ($dev->getMax() !== null) {
614
                        if ($dev->getMax() !== null) {
573
                        $item->addAttribute('Max', $dev->getMax());
615
                            $item->addAttribute('Max', $dev->getMax());
-
 
616
                        }
574
                    }
617
                    }
575
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
618
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
576
                        $item->addAttribute('Event', $dev->getEvent());
619
                        $item->addAttribute('Event', $dev->getEvent());
577
                    }
620
                    }
578
                }
621
                }
Line 597... Line 640...
597
                        $current = $mbinfo->addChild('Current');
640
                        $current = $mbinfo->addChild('Current');
598
                    }
641
                    }
599
                    $item = $current->addChild('Item');
642
                    $item = $current->addChild('Item');
600
                    $item->addAttribute('Label', $dev->getName());
643
                    $item->addAttribute('Label', $dev->getName());
601
                    $item->addAttribute('Value', $dev->getValue());
644
                    $item->addAttribute('Value', $dev->getValue());
-
 
645
                    if (($dev->getMin() === null) || ($dev->getMin() != 0) || ($dev->getMax() === null) || ($dev->getMax() != 0)) {
602
                    if ($dev->getMin() !== null) {
646
                        if ($dev->getMin() !== null) {
603
                        $item->addAttribute('Min', $dev->getMin());
647
                            $item->addAttribute('Min', $dev->getMin());
604
                    }
648
                        }
605
                    if ($dev->getMax() !== null) {
649
                        if ($dev->getMax() !== null) {
606
                        $item->addAttribute('Max', $dev->getMax());
650
                            $item->addAttribute('Max', $dev->getMax());
-
 
651
                        }
607
                    }
652
                    }
608
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
653
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
609
                        $item->addAttribute('Event', $dev->getEvent());
654
                        $item->addAttribute('Event', $dev->getEvent());
610
                    }
655
                    }
611
                }
656
                }
Line 615... Line 660...
615
                        $other = $mbinfo->addChild('Other');
660
                        $other = $mbinfo->addChild('Other');
616
                    }
661
                    }
617
                    $item = $other->addChild('Item');
662
                    $item = $other->addChild('Item');
618
                    $item->addAttribute('Label', $dev->getName());
663
                    $item->addAttribute('Label', $dev->getName());
619
                    $item->addAttribute('Value', $dev->getValue());
664
                    $item->addAttribute('Value', $dev->getValue());
-
 
665
                    if ($dev->getUnit() !== "") {
-
 
666
                        $item->addAttribute('Unit', $dev->getUnit());
-
 
667
                    }
620
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
668
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
621
                        $item->addAttribute('Event', $dev->getEvent());
669
                        $item->addAttribute('Event', $dev->getEvent());
622
                    }
670
                    }
623
                }
671
                }
624
            }
672
            }
Line 696... Line 744...
696
     *
744
     *
697
     * @return void
745
     * @return void
698
     */
746
     */
699
    private function _buildXml()
747
    private function _buildXml()
700
    {
748
    {
701
        if (!$this->_plugin_request || $this->_complete_request) {
749
        if (($this->_plugin == '') || $this->_complete_request) {
702
            if ($this->_sys === null) {
750
            if ($this->_sys === null) {
703
                if (PSI_DEBUG === true) {
751
                if (PSI_DEBUG === true) {
704
                    // unstable version check
752
                    // unstable version check
705
                    if (!is_numeric(substr(PSI_VERSION, -1))) {
753
                    if (!is_numeric(substr(PSI_VERSION, -1))) {
706
                        $this->_errors->addError("WARN", "This is an unstable version of phpSysInfo, some things may not work correctly");
754
                        $this->_errors->addError("WARN", "This is an unstable version of phpSysInfo, some things may not work correctly");
Line 759... Line 807...
759
     * @return void
807
     * @return void
760
     */
808
     */
761
    private function _buildPlugins()
809
    private function _buildPlugins()
762
    {
810
    {
763
        $pluginroot = $this->_xml->addChild("Plugins");
811
        $pluginroot = $this->_xml->addChild("Plugins");
764
        if (($this->_plugin_request || $this->_complete_request) && count($this->_plugins) > 0) {
812
        if ((($this->_plugin != '') || $this->_complete_request) && count($this->_plugins) > 0) {
765
            $plugins = array();
813
            $plugins = array();
766
            if ($this->_complete_request) {
814
            if ($this->_complete_request) {
767
                $plugins = $this->_plugins;
815
                $plugins = $this->_plugins;
768
            }
816
            }
769
            if ($this->_plugin_request) {
817
            if (($this->_plugin != '')) {
770
                $plugins = array($this->_plugin);
818
                $plugins = array($this->_plugin);
771
            }
819
            }
772
            foreach ($plugins as $plugin) {
820
            foreach ($plugins as $plugin) {
-
 
821
                if (!$this->_complete_request || !defined('PSI_PLUGIN_'.strtoupper($plugin).'_WMI_HOSTNAME') ||
-
 
822
                   (defined('PSI_WMI_HOSTNAME') && (PSI_WMI_HOSTNAME == constant('PSI_PLUGIN_'.strtoupper($plugin).'_WMI_HOSTNAME')))) {
773
                $object = new $plugin($this->_sysinfo->getEncoding());
823
                    $object = new $plugin($this->_sysinfo->getEncoding());
774
                $object->execute();
824
                    $object->execute();
775
                $oxml = $object->xml();
825
                    $oxml = $object->xml();
776
                if (sizeof($oxml) > 0) {
826
                    if (sizeof($oxml) > 0) {
777
                    $pluginroot->combinexml($oxml);
827
                        $pluginroot->combinexml($oxml);
-
 
828
                    }
778
                }
829
                }
779
            }
830
            }
780
        }
831
        }
781
    }
832
    }
782
 
833
 
Line 813... Line 864...
813
            }
864
            }
814
        } else {
865
        } else {
815
            $options->addAttribute('threshold', 90);
866
            $options->addAttribute('threshold', 90);
816
        }
867
        }
817
        if (count($this->_plugins) > 0) {
868
        if (count($this->_plugins) > 0) {
818
            if ($this->_plugin_request) {
869
            if (($this->_plugin != '')) {
819
                $plug = $this->_xml->addChild('UsedPlugins');
870
                $plug = $this->_xml->addChild('UsedPlugins');
820
                $plug->addChild('Plugin')->addAttribute('name', $this->_plugin);
871
                $plug->addChild('Plugin')->addAttribute('name', $this->_plugin);
821
            } elseif ($this->_complete_request) {
872
            } elseif ($this->_complete_request) {
822
                $plug = $this->_xml->addChild('UsedPlugins');
873
                $plug = $this->_xml->addChild('UsedPlugins');
823
                foreach ($this->_plugins as $plugin) {
874
                foreach ($this->_plugins as $plugin) {