Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 2774 → Rev 2775

/web/acc/phpsysinfo/includes/output/class.Output.inc.php
0,0 → 1,58
<?php
/**
* basic output functions
*
* PHP version 5
*
* @category PHP
* @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 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
*/
/**
* basic output functions for all output formats
*
* @category PHP
* @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 version 2, or (at your option) any later version
* @version Release: 3.0
* @link http://phpsysinfo.sourceforge.net
*/
abstract class Output
{
/**
* error object for logging errors
*
* @var PSI_Error
*/
protected $error;
 
/**
* call the parent constructor and check for needed extensions
*/
public function __construct()
{
$this->error = PSI_Error::singleton();
$this->_checkConfig();
CommonFunctions::checkForExtensions();
}
 
/**
* read the config file and check for existence
*
* @return void
*/
private function _checkConfig()
{
include_once PSI_APP_ROOT.'/read_config.php';
 
if ($this->error->errorsExist()) {
$this->error->errorsAsXML();
}
}
}
/web/acc/phpsysinfo/includes/output/class.Template.inc.php
0,0 → 1,93
<?php
/**
* basic output functions
*
* PHP version 5
*
* @category PHP
* @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 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
*/
/**
* basic output functions for all output formats
*
* @category PHP
* @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 version 2, or (at your option) any later version
* @version Release: 3.0
* @link http://phpsysinfo.sourceforge.net
*/
class Template
{
/**
* Vars used in the template
*
* @var array
*/
private $_vars;
 
/**
* Template file
*
* @var string
*/
private $_file;
 
/**
* Constructor
*
* @param String $file the template file name
*/
public function __construct($file=null)
{
$this->_file = $file;
$this->_vars = array();
}
 
/**
* Set a template variable.
*
* @param string $name variable name
* @param string|array|Template $value variable value
*/
public function set($name, $value)
{
$this->_vars[$name] = is_object($value) ? $value->fetch() : $value;
}
 
/**
* Open, parse, and return the template file.
*
* @param string $file
*
* @return string
*/
public function fetch($file=null)
{
if (!$file) {
$file = $this->_file;
}
 
// Extract the vars to local namespace
extract($this->_vars);
 
// Start output buffering
ob_start();
 
include(PSI_APP_ROOT.$file);
 
// Get the contents of the buffer
$contents = ob_get_contents();
 
// End buffering and discard
ob_end_clean();
 
return $contents;
}
}
/web/acc/phpsysinfo/includes/output/class.Webpage.inc.php
0,0 → 1,221
<?php
/**
* start page for webaccess
*
* PHP version 5
*
* @category PHP
* @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 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
*/
/**
* generate the dynamic webpage
*
* @category PHP
* @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 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
*/
private $_language;
 
/**
* configured template
*
* @var String
*/
private $_template;
 
/**
* all available templates
*
* @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
*/
private $_languages = array();
 
/**
* configured show picklist language
*
* @var boolean
*/
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();
}
 
/**
* checking phpsysinfo.ini setting for template, if not supportet set phpsysinfo.css as default
* checking phpsysinfo.ini setting for language, if not supported set en as default
*
* @return void
*/
private function _checkTemplateLanguage()
{
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);
 
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);
}
 
/**
* get all available tamplates and store them in internal array
*
* @return void
*/
private function _getTemplateList()
{
$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") {
if (preg_match("/(\S+)_bootstrap$/", $tpl_name, $ar_buf)) {
array_push($this->_bootstrap_templates, $ar_buf[1]);
} else {
array_push($this->_templates, $tpl_name);
}
}
}
}
 
/**
* get all available translations and store them in internal array
*
* @return void
*/
private function _getLanguageList()
{
$dirlist = CommonFunctions::gdc(PSI_APP_ROOT.'/language/');
sort($dirlist);
foreach ($dirlist as $file) {
$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);
}
}
}
 
/**
* render the page
*
* @return void
*/
public function run()
{
$this->_checkTemplateLanguage();
 
$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');
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();
}
}
/web/acc/phpsysinfo/includes/output/class.WebpageXML.inc.php
0,0 → 1,210
<?php
/**
* XML Generator class
*
* PHP version 5
*
* @category PHP
* @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 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
*/
/**
* class for xml output
*
* @category PHP
* @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 version 2, or (at your option) any later version
* @version Release: 3.0
* @link http://phpsysinfo.sourceforge.net
*/
class WebpageXML extends Output implements PSI_Interface_Output
{
/**
* xml object that holds the generated xml
*
* @var XML
*/
private $_xml;
 
/**
* complete xml
*
* @var boolean
*/
private $_completeXML = false;
 
/**
* name of the plugin
*
* @var string
*/
private $_pluginName = null;
 
/**
* name of the block
*
* @var string
*/
private $_blockName = null;
 
/**
* generate the output
*
* @return void
*/
private function _prepare()
{
if ($this->_pluginName === null) {
// 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");
}
 
if (!defined('PSI_MBINFO') && (!$this->_blockName || in_array($this->_blockName, array('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 {
$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));
}
 
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 {
$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));
}
 
// if there are errors stop executing the script until they are fixed
if ($this->error->errorsExist()) {
$this->error->errorsAsXML();
}
 
// Create the XML
$this->_xml = new XML($this->_completeXML, '', $this->_blockName);
} else {
// Create the XML
$this->_xml = new XML(false, $this->_pluginName);
}
}
 
/**
* render the output
*
* @return void
*/
public function run()
{
header("Cache-Control: no-cache, must-revalidate\n");
header("Content-Type: text/xml\n\n");
$xml = $this->_xml->getXml();
echo $xml->asXML();
}
 
/**
* get XML as pure string
*
* @return string
*/
public function getXMLString()
{
$xml = $this->_xml->getXml();
 
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 string $plugin name of the plugin, block or 'complete' for all plugins
*
* @return void
*/
public function __construct($plugin = "")
{
parent::__construct();
 
if (is_string($plugin) && ($plugin !== "")) {
$plugin = strtolower($plugin);
if ($plugin === "complete") {
$this->_completeXML = true;
} else {
$validblocks = array('vitals','hardware','memory','filesystem','network','voltage','current','temperature','fans','power','other','ups');
if (in_array($plugin, $validblocks)) {
$this->_blockName = $plugin;
} elseif (in_array($plugin, CommonFunctions::getPlugins())) {
$this->_pluginName = $plugin;
} else {
$this->_blockName = ' '; //disable all blocks
}
}
}
$this->_prepare();
}
}
/web/acc/phpsysinfo/includes/output/class.WebpageXSLT.inc.php
0,0 → 1,55
<?php
/**
* start page for webaccess
*
* PHP version 5
*
* @category PHP
* @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 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
*/
/**
* generate a static webpage with xslt trasformation of the xml
*
* @category PHP
* @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 version 2, or (at your option) any later version
* @version Release: 3.0
* @link http://phpsysinfo.sourceforge.net
*/
class WebpageXSLT extends WebpageXML implements PSI_Interface_Output
{
/**
* call the parent constructor
*/
public function __construct()
{
parent::__construct();
}
 
/**
* generate the static page
*
* @return void
*/
public function run()
{
CommonFunctions::checkForExtensions(array('xsl'));
$xmlfile = $this->getXMLString();
$xslfile = "phpsysinfo.xslt";
$domxml = new DOMDocument();
$domxml->loadXML($xmlfile);
$domxsl = new DOMDocument();
$domxsl->load($xslfile);
$xsltproc = new XSLTProcessor;
$xsltproc->importStyleSheet($domxsl);
header("Cache-Control: no-cache, must-revalidate\n");
echo $xsltproc->transformToXML($domxml);
}
}