* 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_Output
|
||||
* @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.Output.inc.php 569 2012-04-16 06:08:18Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -19,7 +19,7 @@
|
||||
* @package PSI_Output
|
||||
* @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 @@ abstract class Output
|
||||
/**
|
||||
* error object for logging errors
|
||||
*
|
||||
* @var Error
|
||||
* @var PSI_Error
|
||||
*/
|
||||
protected $error;
|
||||
|
||||
@@ -37,11 +37,9 @@ abstract class Output
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->error = Error::singleton();
|
||||
$this->error = PSI_Error::singleton();
|
||||
$this->_checkConfig();
|
||||
CommonFunctions::checkForExtensions();
|
||||
// $this->error = Error::singleton();
|
||||
// $this->_checkConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +49,7 @@ abstract class Output
|
||||
*/
|
||||
private function _checkConfig()
|
||||
{
|
||||
include_once APP_ROOT.'/read_config.php';
|
||||
include_once PSI_APP_ROOT.'/read_config.php';
|
||||
|
||||
if ($this->error->errorsExist()) {
|
||||
$this->error->errorsAsXML();
|
||||
|
@@ -8,7 +8,7 @@
|
||||
* @package PSI_Output
|
||||
* @author Damien Roth <iysaak@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.Output.inc.php 315 2009-09-02 15:48:31Z bigmichi1 $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -19,7 +19,7 @@
|
||||
* @package PSI_Output
|
||||
* @author Damien Roth <iysaak@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,14 +28,14 @@ class Template
|
||||
/**
|
||||
* Vars used in the template
|
||||
*
|
||||
* @Array
|
||||
* @var array
|
||||
*/
|
||||
private $_vars;
|
||||
|
||||
/**
|
||||
* Template file
|
||||
*
|
||||
* @String
|
||||
* @var string
|
||||
*/
|
||||
private $_file;
|
||||
|
||||
@@ -53,8 +53,8 @@ class Template
|
||||
/**
|
||||
* Set a template variable.
|
||||
*
|
||||
* @param string variable name
|
||||
* @param string variable value
|
||||
* @param string $name variable name
|
||||
* @param string|array|Template $value variable value
|
||||
*/
|
||||
public function set($name, $value)
|
||||
{
|
||||
@@ -80,7 +80,7 @@ class Template
|
||||
// Start output buffering
|
||||
ob_start();
|
||||
|
||||
include(APP_ROOT.$file);
|
||||
include(PSI_APP_ROOT.$file);
|
||||
|
||||
// Get the contents of the buffer
|
||||
$contents = ob_get_contents();
|
||||
|
@@ -8,7 +8,7 @@
|
||||
* @package PSI_Web
|
||||
* @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.Webpage.inc.php 661 2012-08-27 11:26:39Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -19,45 +19,82 @@
|
||||
* @package PSI_Web
|
||||
* @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
|
||||
*/
|
||||
class Webpage extends Output implements PSI_Interface_Output
|
||||
{
|
||||
/**
|
||||
* configured indexname
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_indexname;
|
||||
|
||||
/**
|
||||
* configured language
|
||||
*
|
||||
* @var String
|
||||
* @var string
|
||||
*/
|
||||
private $_language;
|
||||
|
||||
/**
|
||||
* configured template
|
||||
*
|
||||
* @var String
|
||||
* @var string
|
||||
*/
|
||||
private $_template;
|
||||
|
||||
/**
|
||||
* all available templates
|
||||
*
|
||||
* @var Array
|
||||
* @var array
|
||||
*/
|
||||
private $_templates = array();
|
||||
|
||||
/**
|
||||
* configured bootstrap template
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_bootstrap_template;
|
||||
|
||||
/**
|
||||
* all available bootstrap templates
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_bootstrap_templates = array();
|
||||
|
||||
/**
|
||||
* all available languages
|
||||
*
|
||||
* @var Array
|
||||
* @var array
|
||||
*/
|
||||
private $_languages = array();
|
||||
|
||||
/**
|
||||
* check for all extensions that are needed, initialize needed vars and read phpsysinfo.ini
|
||||
* configured show picklist language
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public function __construct()
|
||||
private $_pick_language;
|
||||
|
||||
/**
|
||||
* configured show picklist template
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_pick_template;
|
||||
|
||||
/**
|
||||
* check for all extensions that are needed, initialize needed vars and read phpsysinfo.ini
|
||||
* @param string $indexname
|
||||
*/
|
||||
public function __construct($indexname="dynamic")
|
||||
{
|
||||
$this->_indexname = $indexname;
|
||||
parent::__construct();
|
||||
$this->_getTemplateList();
|
||||
$this->_getLanguageList();
|
||||
@@ -71,15 +108,18 @@ class Webpage extends Output implements PSI_Interface_Output
|
||||
*/
|
||||
private function _checkTemplateLanguage()
|
||||
{
|
||||
$this->_template = trim(strtolower(PSI_DEFAULT_TEMPLATE));
|
||||
if (!file_exists(APP_ROOT.'/templates/'.$this->_template.".css")) {
|
||||
if (!defined("PSI_DEFAULT_TEMPLATE") || (($this->_template = strtolower(trim(PSI_DEFAULT_TEMPLATE))) == "") || !file_exists(PSI_APP_ROOT.'/templates/'.$this->_template.".css")) {
|
||||
$this->_template = 'phpsysinfo';
|
||||
}
|
||||
if (!defined("PSI_DEFAULT_BOOTSTRAP_TEMPLATE") || (($this->_bootstrap_template = strtolower(trim(PSI_DEFAULT_BOOTSTRAP_TEMPLATE))) == "") || !file_exists(PSI_APP_ROOT.'/templates/'.$this->_bootstrap_template."_bootstrap.css")) {
|
||||
$this->_bootstrap_template = 'phpsysinfo';
|
||||
}
|
||||
$this->_pick_template = !defined("PSI_SHOW_PICKLIST_TEMPLATE") || (PSI_SHOW_PICKLIST_TEMPLATE !== false);
|
||||
|
||||
$this->_language = trim(strtolower(PSI_DEFAULT_LANG));
|
||||
if (!file_exists(APP_ROOT.'/language/'.$this->_language.".xml")) {
|
||||
if (!defined("PSI_DEFAULT_LANG") || (($this->_language = strtolower(trim(PSI_DEFAULT_LANG))) == "") || !file_exists(PSI_APP_ROOT.'/language/'.$this->_language.".xml")) {
|
||||
$this->_language = 'en';
|
||||
}
|
||||
$this->_pick_language = !defined("PSI_SHOW_PICKLIST_LANG") || (PSI_SHOW_PICKLIST_LANG !== false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,13 +129,17 @@ class Webpage extends Output implements PSI_Interface_Output
|
||||
*/
|
||||
private function _getTemplateList()
|
||||
{
|
||||
$dirlist = CommonFunctions::gdc(APP_ROOT.'/templates/');
|
||||
$dirlist = CommonFunctions::gdc(PSI_APP_ROOT.'/templates/');
|
||||
sort($dirlist);
|
||||
foreach ($dirlist as $file) {
|
||||
$tpl_ext = substr($file, strlen($file) - 4);
|
||||
$tpl_name = substr($file, 0, strlen($file) - 4);
|
||||
if (($tpl_ext === ".css") && ($tpl_name !== "phpsysinfo_bootstrap")) {
|
||||
array_push($this->_templates, $tpl_name);
|
||||
if ($tpl_ext === ".css") {
|
||||
if (preg_match("/(\S+)_bootstrap$/", $tpl_name, $ar_buf)) {
|
||||
array_push($this->_bootstrap_templates, $ar_buf[1]);
|
||||
} else {
|
||||
array_push($this->_templates, $tpl_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,11 +151,11 @@ class Webpage extends Output implements PSI_Interface_Output
|
||||
*/
|
||||
private function _getLanguageList()
|
||||
{
|
||||
$dirlist = CommonFunctions::gdc(APP_ROOT.'/language/');
|
||||
$dirlist = CommonFunctions::gdc(PSI_APP_ROOT.'/language/');
|
||||
sort($dirlist);
|
||||
foreach ($dirlist as $file) {
|
||||
$lang_ext = substr($file, strlen($file) - 4);
|
||||
$lang_name = substr($file, 0, strlen($file) - 4);
|
||||
$lang_ext = strtolower(substr($file, strlen($file) - 4));
|
||||
$lang_name = strtolower(substr($file, 0, strlen($file) - 4));
|
||||
if ($lang_ext == ".xml") {
|
||||
array_push($this->_languages, $lang_name);
|
||||
}
|
||||
@@ -127,12 +171,52 @@ class Webpage extends Output implements PSI_Interface_Output
|
||||
{
|
||||
$this->_checkTemplateLanguage();
|
||||
|
||||
$tpl = new Template("/templates/html/index_dynamic.html");
|
||||
$tpl = new Template("/templates/html/index_".$this->_indexname.".html");
|
||||
|
||||
$tpl->set("template", $this->_template);
|
||||
$tpl->set("templates", $this->_templates);
|
||||
$tpl->set("bootstraptemplate", $this->_bootstrap_template);
|
||||
$tpl->set("bootstraptemplates", $this->_bootstrap_templates);
|
||||
$tpl->set("picktemplate", $this->_pick_template);
|
||||
$tpl->set("language", $this->_language);
|
||||
$tpl->set("languages", $this->_languages);
|
||||
$tpl->set("picklanguage", $this->_pick_language);
|
||||
$tpl->set("showCPUListExpanded", defined('PSI_SHOW_CPULIST_EXPANDED') ? (PSI_SHOW_CPULIST_EXPANDED ? 'true' : 'false') : 'true');
|
||||
$tpl->set("showCPUInfoExpanded", defined('PSI_SHOW_CPUINFO_EXPANDED') ? (PSI_SHOW_CPUINFO_EXPANDED ? 'true' : 'false') : 'false');
|
||||
$tpl->set("showNetworkInfosExpanded", defined('PSI_SHOW_NETWORK_INFOS_EXPANDED') ? (PSI_SHOW_NETWORK_INFOS_EXPANDED ? 'true' : 'false') : 'false');
|
||||
$tpl->set("showMemoryInfosExpanded", defined('PSI_SHOW_MEMORY_INFOS_EXPANDED') ? (PSI_SHOW_MEMORY_INFOS_EXPANDED ? 'true' : 'false') : 'false');
|
||||
$tpl->set("showNetworkActiveSpeed", defined('PSI_SHOW_NETWORK_ACTIVE_SPEED') ? (PSI_SHOW_NETWORK_ACTIVE_SPEED ? ((strtolower(PSI_SHOW_NETWORK_ACTIVE_SPEED) === 'bps') ? 'bps' :'true') : 'false') : 'false');
|
||||
$tpl->set("showCPULoadCompact", defined('PSI_LOAD_BAR') ? ((strtolower(PSI_LOAD_BAR) === 'compact') ? 'true' :'false') : 'false');
|
||||
$tpl->set("hideBootstrapLoader", defined('PSI_HIDE_BOOTSTRAP_LOADER') ? (PSI_HIDE_BOOTSTRAP_LOADER ? 'true' : 'false') : 'false');
|
||||
$tpl->set("increaseWidth", defined('PSI_INCREASE_WIDTH') ? ((intval(PSI_INCREASE_WIDTH)>0) ? intval(PSI_INCREASE_WIDTH) : 0) : 0);
|
||||
$tpl->set("hideTotals", defined('PSI_HIDE_TOTALS') ? (PSI_HIDE_TOTALS ? 'true' : 'false') : 'false');
|
||||
if (defined('PSI_BLOCKS')) {
|
||||
if (is_string(PSI_BLOCKS)) {
|
||||
if (preg_match(ARRAY_EXP, PSI_BLOCKS)) {
|
||||
$blocks = eval(strtolower(PSI_BLOCKS));
|
||||
} else {
|
||||
$blocks = array(strtolower(PSI_BLOCKS));
|
||||
}
|
||||
$blocklist = '';
|
||||
$validblocks = array('vitals','hardware','memory','filesystem','network','voltage','current','temperature','fans','power','other','ups');
|
||||
foreach ($blocks as $block) {
|
||||
if (in_array($block, $validblocks)) {
|
||||
if (empty($blocklist)) {
|
||||
$blocklist = $block;
|
||||
} else {
|
||||
$blocklist .= ','.$block;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($blocklist)) {
|
||||
$tpl->set("blocks", $blocklist);
|
||||
}
|
||||
} elseif (PSI_BLOCKS) {
|
||||
$tpl->set("blocks", 'true');
|
||||
}
|
||||
} else {
|
||||
$tpl->set("blocks", 'true');
|
||||
}
|
||||
|
||||
echo $tpl->fetch();
|
||||
}
|
||||
|
@@ -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.WebpageXML.inc.php 661 2012-08-27 11:26:39Z 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
|
||||
*/
|
||||
@@ -32,13 +32,6 @@ class WebpageXML extends Output implements PSI_Interface_Output
|
||||
*/
|
||||
private $_xml;
|
||||
|
||||
/**
|
||||
* only plugin xml
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_pluginRequest = false;
|
||||
|
||||
/**
|
||||
* complete xml
|
||||
*
|
||||
@@ -53,6 +46,13 @@ class WebpageXML extends Output implements PSI_Interface_Output
|
||||
*/
|
||||
private $_pluginName = null;
|
||||
|
||||
/**
|
||||
* name of the block
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_blockName = null;
|
||||
|
||||
/**
|
||||
* generate the output
|
||||
*
|
||||
@@ -60,82 +60,161 @@ class WebpageXML extends Output implements PSI_Interface_Output
|
||||
*/
|
||||
private function _prepare()
|
||||
{
|
||||
if (!$this->_pluginRequest) {
|
||||
// Figure out which OS we are running on, and detect support
|
||||
if (!file_exists(APP_ROOT.'/includes/os/class.'.PSI_OS.'.inc.php')) {
|
||||
$this->error->addError("file_exists(class.".PSI_OS.".inc.php)", PSI_OS." is not currently supported");
|
||||
if ($this->_pluginName === null) {
|
||||
if ((PSI_OS == 'Linux') && defined('PSI_SSH_HOSTNAME') && defined('PSI_SSH_USER') && defined('PSI_SSH_PASSWORD')) {
|
||||
$fgthost = preg_split("/:/", PSI_SSH_HOSTNAME, -1, PREG_SPLIT_NO_EMPTY);
|
||||
define('PSI_EMU_HOSTNAME', trim($fgthost[0]));
|
||||
if (isset($fgthost[1]) && (trim($fgthost[1] !== ''))) {
|
||||
define('PSI_EMU_PORT', trim($fgthost[1]));
|
||||
} else {
|
||||
define('PSI_EMU_PORT', 22);
|
||||
}
|
||||
define('PSI_EMU_USER', PSI_SSH_USER);
|
||||
define('PSI_EMU_PASSWORD', PSI_SSH_PASSWORD);
|
||||
if (defined('PSI_SSH_ADD_PATHS')) {
|
||||
define('PSI_EMU_ADD_PATHS', PSI_SSH_ADD_PATHS);
|
||||
}
|
||||
if (defined('PSI_SSH_ADD_OPTIONS')) {
|
||||
define('PSI_EMU_ADD_OPTIONS', PSI_SSH_ADD_OPTIONS);
|
||||
}
|
||||
if (!file_exists(PSI_APP_ROOT.'/includes/os/class.Linux.inc.php')) {
|
||||
$this->error->addError("file_exists(class.Linux.inc.php)", "Linux is not currently supported");
|
||||
}
|
||||
} elseif (((PSI_OS == 'WINNT') || (PSI_OS == 'Linux')) && defined('PSI_WMI_HOSTNAME')) {
|
||||
define('PSI_EMU_HOSTNAME', PSI_WMI_HOSTNAME);
|
||||
if (defined('PSI_WMI_USER') && defined('PSI_WMI_PASSWORD')) {
|
||||
define('PSI_EMU_USER', PSI_WMI_USER);
|
||||
define('PSI_EMU_PASSWORD', PSI_WMI_PASSWORD);
|
||||
} else {
|
||||
define('PSI_EMU_USER', null);
|
||||
define('PSI_EMU_PASSWORD', null);
|
||||
}
|
||||
if (!file_exists(PSI_APP_ROOT.'/includes/os/class.WINNT.inc.php')) {
|
||||
$this->error->addError("file_exists(class.WINNT.inc.php)", "WINNT is not currently supported");
|
||||
}
|
||||
} else {
|
||||
// Figure out which OS we are running on, and detect support
|
||||
if (!file_exists(PSI_APP_ROOT.'/includes/os/class.'.PSI_OS.'.inc.php')) {
|
||||
$this->error->addError("file_exists(class.".PSI_OS.".inc.php)", PSI_OS." is not currently supported");
|
||||
}
|
||||
}
|
||||
|
||||
// check if there is a valid sensor configuration in phpsysinfo.ini
|
||||
$foundsp = array();
|
||||
if (defined('PSI_SENSOR_PROGRAM') && is_string(PSI_SENSOR_PROGRAM)) {
|
||||
if (preg_match(ARRAY_EXP, PSI_SENSOR_PROGRAM)) {
|
||||
$sensorprograms = eval(strtolower(PSI_SENSOR_PROGRAM));
|
||||
} else {
|
||||
$sensorprograms = array(strtolower(PSI_SENSOR_PROGRAM));
|
||||
}
|
||||
foreach ($sensorprograms as $sensorprogram) {
|
||||
if (!file_exists(APP_ROOT.'/includes/mb/class.'.$sensorprogram.'.inc.php')) {
|
||||
$this->error->addError("file_exists(class.".htmlspecialchars($sensorprogram).".inc.php)", "specified sensor program is not supported");
|
||||
if (!defined('PSI_MBINFO') && (!$this->_blockName || in_array($this->_blockName, array('mbinfo','voltage','current','temperature','fans','power','other')))) {
|
||||
// check if there is a valid sensor configuration in phpsysinfo.ini
|
||||
$foundsp = array();
|
||||
if (defined('PSI_SENSOR_PROGRAM') && is_string(PSI_SENSOR_PROGRAM)) {
|
||||
if (preg_match(ARRAY_EXP, PSI_SENSOR_PROGRAM)) {
|
||||
$sensorprograms = eval(strtolower(PSI_SENSOR_PROGRAM));
|
||||
} else {
|
||||
$foundsp[] = $sensorprogram;
|
||||
$sensorprograms = array(strtolower(PSI_SENSOR_PROGRAM));
|
||||
}
|
||||
foreach ($sensorprograms as $sensorprogram) {
|
||||
if (!file_exists(PSI_APP_ROOT.'/includes/mb/class.'.$sensorprogram.'.inc.php')) {
|
||||
$this->error->addError("file_exists(class.".htmlspecialchars($sensorprogram).".inc.php)", "specified sensor program is not supported");
|
||||
} else {
|
||||
$foundsp[] = $sensorprogram;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* motherboard information
|
||||
*
|
||||
* @var string serialized array
|
||||
*/
|
||||
define('PSI_MBINFO', serialize($foundsp));
|
||||
}
|
||||
|
||||
/**
|
||||
* motherboard information
|
||||
*
|
||||
* @var serialized array
|
||||
*/
|
||||
define('PSI_MBINFO', serialize($foundsp));
|
||||
|
||||
// check if there is a valid hddtemp configuration in phpsysinfo.ini
|
||||
$found = false;
|
||||
if (PSI_HDD_TEMP !== false) {
|
||||
$found = true;
|
||||
}
|
||||
/**
|
||||
* hddtemp information available or not
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
define('PSI_HDDTEMP', $found);
|
||||
|
||||
// check if there is a valid ups configuration in phpsysinfo.ini
|
||||
$foundup = array();
|
||||
if (defined('PSI_UPS_PROGRAM') && is_string(PSI_UPS_PROGRAM)) {
|
||||
if (preg_match(ARRAY_EXP, PSI_UPS_PROGRAM)) {
|
||||
$upsprograms = eval(strtolower(PSI_UPS_PROGRAM));
|
||||
} else {
|
||||
$upsprograms = array(strtolower(PSI_UPS_PROGRAM));
|
||||
}
|
||||
foreach ($upsprograms as $upsprogram) {
|
||||
if (!file_exists(APP_ROOT.'/includes/ups/class.'.$upsprogram.'.inc.php')) {
|
||||
$this->error->addError("file_exists(class.".htmlspecialchars($upsprogram).".inc.php)", "specified UPS program is not supported");
|
||||
if (!defined('PSI_UPSINFO') && (!$this->_blockName || ($this->_blockName==='ups'))) {
|
||||
// check if there is a valid ups configuration in phpsysinfo.ini
|
||||
$foundup = array();
|
||||
if (defined('PSI_UPS_PROGRAM') && is_string(PSI_UPS_PROGRAM)) {
|
||||
if (preg_match(ARRAY_EXP, PSI_UPS_PROGRAM)) {
|
||||
$upsprograms = eval(strtolower(PSI_UPS_PROGRAM));
|
||||
} else {
|
||||
$foundup[] = $upsprogram;
|
||||
$upsprograms = array(strtolower(PSI_UPS_PROGRAM));
|
||||
}
|
||||
foreach ($upsprograms as $upsprogram) {
|
||||
if (!file_exists(PSI_APP_ROOT.'/includes/ups/class.'.$upsprogram.'.inc.php')) {
|
||||
$this->error->addError("file_exists(class.".htmlspecialchars($upsprogram).".inc.php)", "specified UPS program is not supported");
|
||||
} else {
|
||||
$foundup[] = $upsprogram;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* ups information
|
||||
*
|
||||
* @var string serialized array
|
||||
*/
|
||||
define('PSI_UPSINFO', serialize($foundup));
|
||||
}
|
||||
/**
|
||||
* ups information
|
||||
*
|
||||
* @var serialized array
|
||||
*/
|
||||
define('PSI_UPSINFO', serialize($foundup));
|
||||
|
||||
// if there are errors stop executing the script until they are fixed
|
||||
if ($this->error->errorsExist()) {
|
||||
$this->error->errorsAsXML();
|
||||
}
|
||||
}
|
||||
|
||||
// Create the XML
|
||||
if ($this->_pluginRequest) {
|
||||
$this->_xml = new XML(false, $this->_pluginName);
|
||||
// Create the XML
|
||||
$this->_xml = new XML($this->_completeXML, '', $this->_blockName);
|
||||
} else {
|
||||
$this->_xml = new XML($this->_completeXML);
|
||||
if ((PSI_OS == 'WINNT') || (PSI_OS == 'Linux')) {
|
||||
$plugname = strtoupper(trim($this->_pluginName));
|
||||
if ((PSI_OS == 'Linux') && defined('PSI_PLUGIN_'.$plugname.'_SSH_HOSTNAME') && defined('PSI_PLUGIN_'.$plugname.'_SSH_USER') && defined('PSI_PLUGIN_'.$plugname.'_SSH_PASSWORD')) {
|
||||
$fgthost = preg_split("/:/", constant('PSI_PLUGIN_'.$plugname.'_SSH_HOSTNAME'), -1, PREG_SPLIT_NO_EMPTY);
|
||||
define('PSI_EMU_HOSTNAME', trim($fgthost[0]));
|
||||
if (isset($fgthost[1]) && (trim($fgthost[1] !== ''))) {
|
||||
define('PSI_EMU_PORT', trim($fgthost[1]));
|
||||
} else {
|
||||
define('PSI_EMU_PORT', 22);
|
||||
}
|
||||
define('PSI_EMU_USER', constant('PSI_PLUGIN_'.$plugname.'_SSH_USER'));
|
||||
define('PSI_EMU_PASSWORD', constant('PSI_PLUGIN_'.$plugname.'_SSH_PASSWORD'));
|
||||
if (defined('PSI_PLUGIN_'.$plugname.'_SSH_ADD_PATHS')) {
|
||||
define('PSI_EMU_ADD_PATHS', constant('PSI_PLUGIN_'.$plugname.'_SSH_ADD_PATHS'));
|
||||
}
|
||||
if (defined('PSI_PLUGIN_'.$plugname.'_SSH_ADD_OPTIONS')) {
|
||||
define('PSI_EMU_ADD_OPTIONS', constant('PSI_PLUGIN_'.$plugname.'_SSH_ADD_OPTIONS'));
|
||||
}
|
||||
} elseif (defined('PSI_PLUGIN_'.$plugname.'_WMI_HOSTNAME')) {
|
||||
define('PSI_EMU_HOSTNAME', constant('PSI_PLUGIN_'.$plugname.'_WMI_HOSTNAME'));
|
||||
if (defined('PSI_PLUGIN_'.$plugname.'_WMI_USER') && defined('PSI_PLUGIN_'.$plugname.'_WMI_PASSWORD')) {
|
||||
define('PSI_EMU_USER', constant('PSI_PLUGIN_'.$plugname.'_WMI_USER'));
|
||||
define('PSI_EMU_PASSWORD', constant('PSI_PLUGIN_'.$plugname.'_WMI_PASSWORD'));
|
||||
} else {
|
||||
define('PSI_EMU_USER', null);
|
||||
define('PSI_EMU_PASSWORD', null);
|
||||
}
|
||||
} elseif ((PSI_OS == 'Linux') && defined('PSI_SSH_HOSTNAME') && defined('PSI_SSH_USER') && defined('PSI_SSH_PASSWORD')) {
|
||||
$fgthost = preg_split("/:/", PSI_SSH_HOSTNAME, -1, PREG_SPLIT_NO_EMPTY);
|
||||
define('PSI_EMU_HOSTNAME', trim($fgthost[0]));
|
||||
if (isset($fgthost[1]) && (trim($fgthost[1] !== ''))) {
|
||||
define('PSI_EMU_PORT', trim($fgthost[1]));
|
||||
} else {
|
||||
define('PSI_EMU_PORT', 22);
|
||||
}
|
||||
define('PSI_EMU_USER', PSI_SSH_USER);
|
||||
define('PSI_EMU_PASSWORD', PSI_SSH_PASSWORD);
|
||||
if (defined('PSI_SSH_ADD_PATHS')) {
|
||||
define('PSI_EMU_ADD_PATHS', PSI_SSH_ADD_PATHS);
|
||||
}
|
||||
if (defined('PSI_SSH_ADD_OPTIONS')) {
|
||||
define('PSI_EMU_ADD_OPTIONS', PSI_SSH_ADD_OPTIONS);
|
||||
}
|
||||
} elseif (defined('PSI_WMI_HOSTNAME')) {
|
||||
define('PSI_EMU_HOSTNAME', PSI_WMI_HOSTNAME);
|
||||
if (defined('PSI_WMI_USER') && defined('PSI_WMI_PASSWORD')) {
|
||||
define('PSI_EMU_USER', PSI_WMI_USER);
|
||||
define('PSI_EMU_PASSWORD', PSI_WMI_PASSWORD);
|
||||
} else {
|
||||
define('PSI_EMU_USER', null);
|
||||
define('PSI_EMU_PASSWORD', null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create the XML
|
||||
$this->_xml = new XML(false, $this->_pluginName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,8 +225,8 @@ class WebpageXML extends Output implements PSI_Interface_Output
|
||||
*/
|
||||
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();
|
||||
}
|
||||
@@ -164,24 +243,52 @@ class WebpageXML extends Output implements PSI_Interface_Output
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* get json string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getJsonString()
|
||||
{
|
||||
if (defined('PSI_JSON_ISSUE') && (PSI_JSON_ISSUE)) {
|
||||
return json_encode(simplexml_load_string(str_replace(">", ">\n", $this->getXMLString()))); // solving json_encode issue
|
||||
} else {
|
||||
return json_encode(simplexml_load_string($this->getXMLString()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getArray()
|
||||
{
|
||||
return json_decode($this->getJsonString());
|
||||
}
|
||||
|
||||
/**
|
||||
* set parameters for the XML generation process
|
||||
*
|
||||
* @param boolean $completeXML switch for complete xml with all plugins
|
||||
* @param string $plugin name of the plugin
|
||||
* @param string $plugin name of the plugin, block or 'complete' for all plugins
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($completeXML, $plugin = null)
|
||||
public function __construct($plugin = "")
|
||||
{
|
||||
parent::__construct();
|
||||
if ($completeXML) {
|
||||
$this->_completeXML = true;
|
||||
}
|
||||
if ($plugin) {
|
||||
if (in_array(strtolower($plugin), CommonFunctions::getPlugins())) {
|
||||
|
||||
if (is_string($plugin) && ($plugin !== "")) {
|
||||
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','mbinfo','voltage','current','temperature','fans','power','other','ups'))) {
|
||||
$this->_blockName = $plugin;
|
||||
} elseif (in_array($plugin, CommonFunctions::getPlugins())) {
|
||||
$this->_pluginName = $plugin;
|
||||
$this->_pluginRequest = true;
|
||||
} else {
|
||||
$this->_blockName = ' '; // disable all blocks
|
||||
}
|
||||
}
|
||||
$this->_prepare();
|
||||
|
@@ -8,7 +8,7 @@
|
||||
* @package PSI_Web
|
||||
* @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.WebpageXSLT.inc.php 569 2012-04-16 06:08:18Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -19,7 +19,7 @@
|
||||
* @package PSI_Web
|
||||
* @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
|
||||
*/
|
||||
@@ -30,7 +30,7 @@ class WebpageXSLT extends WebpageXML implements PSI_Interface_Output
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(false, null);
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,6 +49,7 @@ class WebpageXSLT extends WebpageXML implements PSI_Interface_Output
|
||||
$domxsl->load($xslfile);
|
||||
$xsltproc = new XSLTProcessor;
|
||||
$xsltproc->importStyleSheet($domxsl);
|
||||
header('Cache-Control: no-cache, must-revalidate');
|
||||
echo $xsltproc->transformToXML($domxml);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user