initial commit of file from CVS for smeserver-phpsysinfo on Sat Sep 7 20:53:46 AEST 2024

This commit is contained in:
Trevor Batley
2024-09-07 20:53:46 +10:00
parent 8f9c36d1f5
commit 9552652292
693 changed files with 86806 additions and 2 deletions

View File

@@ -0,0 +1,60 @@
<?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 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 Release: 3.0
* @link http://phpsysinfo.sourceforge.net
*/
abstract class Output
{
/**
* error object for logging errors
*
* @var Error
*/
protected $error;
/**
* call the parent constructor and check for needed extensions
*/
public function __construct()
{
$this->error = Error::singleton();
$this->_checkConfig();
CommonFunctions::checkForExtensions();
// $this->error = Error::singleton();
// $this->_checkConfig();
}
/**
* read the config file and check for existence
*
* @return void
*/
private function _checkConfig()
{
include_once APP_ROOT.'/read_config.php';
if ($this->error->errorsExist()) {
$this->error->errorsAsXML();
}
}
}

View File

@@ -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 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 Release: 3.0
* @link http://phpsysinfo.sourceforge.net
*/
class Template
{
/**
* Vars used in the template
*
* @Array
*/
private $_vars;
/**
* Template file
*
* @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 variable name
* @param string 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(APP_ROOT.$file);
// Get the contents of the buffer
$contents = ob_get_contents();
// End buffering and discard
ob_end_clean();
return $contents;
}
}

View File

@@ -0,0 +1,139 @@
<?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 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 Release: 3.0
* @link http://phpsysinfo.sourceforge.net
*/
class Webpage extends Output implements PSI_Interface_Output
{
/**
* configured language
*
* @var String
*/
private $_language;
/**
* configured template
*
* @var String
*/
private $_template;
/**
* all available templates
*
* @var Array
*/
private $_templates = array();
/**
* all available languages
*
* @var Array
*/
private $_languages = array();
/**
* check for all extensions that are needed, initialize needed vars and read phpsysinfo.ini
*/
public function __construct()
{
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()
{
$this->_template = trim(strtolower(PSI_DEFAULT_TEMPLATE));
if (!file_exists(APP_ROOT.'/templates/'.$this->_template.".css")) {
$this->_template = 'phpsysinfo';
}
$this->_language = trim(strtolower(PSI_DEFAULT_LANG));
if (!file_exists(APP_ROOT.'/language/'.$this->_language.".xml")) {
$this->_language = 'en';
}
}
/**
* get all available tamplates and store them in internal array
*
* @return void
*/
private function _getTemplateList()
{
$dirlist = CommonFunctions::gdc(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);
}
}
}
/**
* get all available translations and store them in internal array
*
* @return void
*/
private function _getLanguageList()
{
$dirlist = CommonFunctions::gdc(APP_ROOT.'/language/');
sort($dirlist);
foreach ($dirlist as $file) {
$lang_ext = substr($file, strlen($file) - 4);
$lang_name = 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_dynamic.html");
$tpl->set("template", $this->_template);
$tpl->set("templates", $this->_templates);
$tpl->set("language", $this->_language);
$tpl->set("languages", $this->_languages);
echo $tpl->fetch();
}
}

View File

@@ -0,0 +1,189 @@
<?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 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 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;
/**
* only plugin xml
*
* @var boolean
*/
private $_pluginRequest = false;
/**
* complete xml
*
* @var boolean
*/
private $_completeXML = false;
/**
* name of the plugin
*
* @var string
*/
private $_pluginName = null;
/**
* generate the output
*
* @return void
*/
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");
}
// 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");
} else {
$foundsp[] = $sensorprogram;
}
}
}
/**
* 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");
} else {
$foundup[] = $upsprogram;
}
}
}
/**
* 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);
} else {
$this->_xml = new XML($this->_completeXML);
}
}
/**
* 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();
}
/**
* set parameters for the XML generation process
*
* @param boolean $completeXML switch for complete xml with all plugins
* @param string $plugin name of the plugin
*
* @return void
*/
public function __construct($completeXML, $plugin = null)
{
parent::__construct();
if ($completeXML) {
$this->_completeXML = true;
}
if ($plugin) {
if (in_array(strtolower($plugin), CommonFunctions::getPlugins())) {
$this->_pluginName = $plugin;
$this->_pluginRequest = true;
}
}
$this->_prepare();
}
}

View File

@@ -0,0 +1,54 @@
<?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 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 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(false, null);
}
/**
* 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);
echo $xsltproc->transformToXML($domxml);
}
}