[Phpsysinfo-subversion] SF.net SVN: phpsysinfo:[203] includes
Brought to you by:
namiltd
From: <big...@us...> - 2009-05-04 07:22:26
|
Revision: 203 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=203&view=rev Author: bigmichi1 Date: 2009-05-04 07:22:18 +0000 (Mon, 04 May 2009) Log Message: ----------- fixing some ups bugs Modified Paths: -------------- includes/autoloader.inc.php includes/output/class.WebpageXML.inc.php includes/ups/class.Apcupsd.inc.php Modified: includes/autoloader.inc.php =================================================================== --- includes/autoloader.inc.php 2009-05-03 22:17:24 UTC (rev 202) +++ includes/autoloader.inc.php 2009-05-04 07:22:18 UTC (rev 203) @@ -1,4 +1,4 @@ -<?php +<?php /** * class autoloader * @@ -22,20 +22,23 @@ function __autoload($class_name) { $class_name = str_replace('-', '', $class_name); - $dirs = array ('/plugins/'.strtolower($class_name).'/', '/includes/', '/includes/interface/', '/includes/os/', '/includes/mb/', '/includes/plugin/', '/includes/xml/', '/includes/web/', '/includes/error/', '/includes/js/', '/includes/output/'); + $dirs = array('/plugins/'.strtolower($class_name).'/', '/includes/', '/includes/interface/', + '/includes/os/', '/includes/mb/', '/includes/plugin/', '/includes/xml/', + '/includes/web/', '/includes/error/', '/includes/js/', '/includes/output/', + '/includes/ups/'); $found = false; foreach ($dirs as $dir) { if (file_exists(APP_ROOT.$dir.'class.'.$class_name.'.inc.php')) { include_once APP_ROOT.$dir.'class.'.$class_name.'.inc.php'; $found = true; - } - } + } + } if (!$found) { $error = Error::singleton(); $error->addError("_autoload(\"".$class_name."\")", "autoloading of class file (class.".$class_name.".inc.php) failed!"); echo $error->errorsAsHTML(); - die (); - } + die(); + } } ?> Modified: includes/output/class.WebpageXML.inc.php =================================================================== --- includes/output/class.WebpageXML.inc.php 2009-05-03 22:17:24 UTC (rev 202) +++ includes/output/class.WebpageXML.inc.php 2009-05-04 07:22:18 UTC (rev 203) @@ -1,4 +1,4 @@ -<?php +<?php /** * XML Generator class * @@ -23,36 +23,35 @@ * @version Release: 3.0 * @link http://phpsysinfo.sourceforge.net */ -class WebpageXML extends Output implements PSI_Interface_Output -{ +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 * @@ -65,7 +64,7 @@ if (!file_exists(APP_ROOT.'/includes/os/class.'.PHP_OS.'.inc.php')) { $this->error->addError("file_exists(class.".PHP_OS.".php.inc)", PHP_OS." is not currently supported"); } - + // check if there is a valid sensor configuration in config.php $found = false; if (PSI_SENSOR_PROGRAM !== false) { @@ -74,27 +73,27 @@ $this->error->addError("file_exists(class.".htmlspecialchars(PSI_SENSOR_PROGRAM).".inc.php)", "specified sensor program is not supported"); } else { $found = true; - } - } + } + } /** * motherboard information available or not * * @var boolean */ define('PSI_MBINFO', $found); - + // check if there is a valid hddtemp configuration in config.php $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 config.php $found = false; if (PSI_UPS_PROGRAM !== false) { @@ -102,32 +101,32 @@ $found = false; $this->error->addError("file_exists(class.".htmlspecialchars(PSI_UPS_PROGRAM).".inc.php)", "specified UPS program is not supported"); } else { - $found = false; - } - } + $found = true; + } + } /** * ups information available or not * * @var boolean */ define('PSI_UPSINFO', $found); - + // if there are errors stop executing the script until they are fixed if ($this->error->errorsExist()) { header("Content-Type: text/xml\n\n"); echo $this->error->errorsAsXML(); - exit ; - } + exit; + } } - + // Create the XML if ($this->_pluginRequest) { $this->_xml = new XML(false, $this->_pluginName); } else { $this->_xml = new XML($this->_completeXML); - } + } } - + /** * render the output * @@ -139,9 +138,9 @@ header("Content-Type: text/xml\n\n"); $xml = $this->_xml->getXml(); echo $xml->asXML(); - die (); + die(); } - + /** * get XML as pure string * @@ -152,7 +151,7 @@ $xml = $this->_xml->getXml(); return $xml->asXML(); } - + /** * set parameters for the XML generation process * @@ -166,14 +165,14 @@ parent::__construct(); if ($completeXML) { $this->_completeXML = true; - } + } if ($plugin) { if (in_array($plugin, CommonFunctions::getPlugins())) { $this->_pluginName = $plugin; $this->_pluginRequest = true; - } - } + } + } $this->_prepare(); - } + } } ?> Modified: includes/ups/class.Apcupsd.inc.php =================================================================== --- includes/ups/class.Apcupsd.inc.php 2009-05-03 22:17:24 UTC (rev 202) +++ includes/ups/class.Apcupsd.inc.php 2009-05-04 07:22:18 UTC (rev 203) @@ -24,15 +24,14 @@ * @version Release: 3.0 * @link http://phpsysinfo.sourceforge.net */ -class Apcupsd implements PSI_Interface_UPS -{ +class Apcupsd implements PSI_Interface_UPS { /** * internal storage for all gathered data * * @var array */ - private $_output = array (); - + private $_output = array(); + /** * get all information from all configured ups in config.php and store output in internal array */ @@ -42,12 +41,12 @@ foreach ($upses as $ups) { $temp = ''; CommonFunctions::executeProgram('apcaccess', 'status '.trim($ups), $temp); - if ( isset ($temp) && ! empty($temp)) { - array_push($this->_output[$i], $temp); - } - } + if (isset($temp) && ! empty($temp)) { + $this->_output[] = $temp; + } + } } - + /** * parse the input and store data in resultset for xml generation * @@ -55,86 +54,86 @@ */ public function info() { - if ( isset ($this->_output) && count($this->_output) > 0) { - $results = array (); + if (isset($this->_output) && count($this->_output) > 0) { + $results = array(); for ($i = 0, $cnt_output = count($this->_output); $i < $cnt_output; $i++) { // General info if (preg_match('/^UPSNAME\s*:\s*(.*)$/m', $this->_output[$i], $data)) { $results[$i]['name'] = trim($data[1]); } else { $results[$i]['name'] = ''; - } + } if (preg_match('/^MODEL\s*:\s*(.*)$/m', $this->_output[$i], $data)) { $results[$i]['model'] = trim($data[1]); } else { $results[$i]['model'] = ''; - } + } if (preg_match('/^UPSMODE\s*:\s*(.*)$/m', $this->_output[$i], $data)) { $results[$i]['mode'] = trim($data[1]); } else { $results[$i]['mode'] = ''; - } + } if (preg_match('/^STARTTIME\s*:\s*(.*)$/m', $this->_output[$i], $data)) { $results[$i]['start_time'] = trim($data[1]); } else { $results[$i]['start_time'] = ''; - } + } if (preg_match('/^STATUS\s*:\s*(.*)$/m', $this->_output[$i], $data)) { $results[$i]['status'] = trim($data[1]); } else { $results[$i]['status'] = ''; - } + } if (preg_match('/^ITEMP\s*:\s*(.*)$/m', $this->_output[$i], $data)) { $results[$i]['temperature'] = trim($data[1]); } else { $results[$i]['temperature'] = ''; - } + } // Outages if (preg_match('/^NUMXFERS\s*:\s*(.*)$/m', $this->_output[$i], $data)) { $results[$i]['outages_count'] = trim($data[1]); } else { $results[$i]['outages_count'] = ''; - } + } if (preg_match('/^LASTXFER\s*:\s*(.*)$/m', $this->_output[$i], $data)) { $results[$i]['last_outage'] = trim($data[1]); } else { $results[$i]['last_outage'] = ''; - } + } if (preg_match('/^XOFFBATT\s*:\s*(.*)$/m', $this->_output[$i], $data)) { $results[$i]['last_outage_finish'] = trim($data[1]); } else { $results[$i]['last_outage_finish'] = ''; - } + } // Line if (preg_match('/^LINEV\s*:\s*(\d*\.\d*)(.*)$/m', $this->_output[$i], $data)) { $results[$i]['line_voltage'] = trim($data[1]); } else { $results[$i]['line_voltage'] = ''; - } + } if (preg_match('/^LOADPCT\s*:\s*(\d*\.\d*)(.*)$/m', $this->_output[$i], $data)) { $results[$i]['load_percent'] = trim($data[1]); } else { $results[$i]['load_percent'] = ''; - } + } // Battery if (preg_match('/^BATTV\s*:\s*(\d*\.\d*)(.*)$/m', $this->_output[$i], $data)) { $results[$i]['battery_voltage'] = trim($data[1]); } else { $results[$i]['battery_voltage'] = ''; - } + } if (preg_match('/^BCHARGE\s*:\s*(\d*\.\d*)(.*)$/m', $this->_output[$i], $data)) { $results[$i]['battery_charge_percent'] = trim($data[1]); } else { $results[$i]['battery_charge_percent'] = ''; - } + } if (preg_match('/^TIMELEFT\s*:\s*(\d*\.\d*)(.*)$/m', $this->_output[$i], $data)) { $results[$i]['time_left_minutes'] = trim($data[1]); } else { $results[$i]['time_left_minutes'] = ''; - } - } + } + } return $results; - } - } + } + } } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |