/web/acc/phpsysinfo/includes/error/class.PSI_Error.inc.php |
---|
0,0 → 1,290 |
<?php |
/** |
* PSI_Error class |
* |
* PHP version 5 |
* |
* @category PHP |
* @package PSI_Error |
* @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.Error.inc.php 569 2012-04-16 06:08:18Z namiltd $ |
* @link http://phpsysinfo.sourceforge.net |
*/ |
/** |
* class for the error handling in phpsysinfo |
* |
* @category PHP |
* @package PSI_Error |
* @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 PSI_Error |
{ |
/** |
* holds the instance of this class |
* |
* @static |
* @var PSI_Error |
*/ |
private static $_instance; |
/** |
* holds the error messages |
* |
* @var array |
*/ |
private $_arrErrorList = array(); |
/** |
* current number ob errors |
* |
* @var integer |
*/ |
private $_errors = 0; |
/** |
* initalize some used vars |
*/ |
private function __construct() |
{ |
$this->_errors = 0; |
$this->_arrErrorList = array(); |
} |
/** |
* Singleton function |
* |
* @return PSI_Error instance of the class |
*/ |
public static function singleton() |
{ |
if (!isset(self::$_instance)) { |
$c = __CLASS__; |
self::$_instance = new $c; |
} |
return self::$_instance; |
} |
/** |
* triggers an error when somebody tries to clone the object |
* |
* @return void |
*/ |
public function __clone() |
{ |
trigger_error("Can't be cloned", E_USER_ERROR); |
} |
/** |
* adds an phpsysinfo error to the internal list |
* |
* @param string $strCommand Command, which cause the Error |
* @param string $strMessage additional Message, to describe the Error |
* |
* @return void |
*/ |
public function addError($strCommand, $strMessage) |
{ |
$this->_addError($strCommand, $this->_trace($strMessage)); |
} |
/** |
* adds an error to the internal list |
* |
* @param string $strCommand Command, which cause the Error |
* @param string $strMessage message, that describe the Error |
* |
* @return void |
*/ |
private function _addError($strCommand, $strMessage) |
{ |
$index = count($this->_arrErrorList) + 1; |
$this->_arrErrorList[$index]['command'] = $strCommand; |
$this->_arrErrorList[$index]['message'] = $strMessage; |
$this->_errors++; |
} |
/** |
* add a config error to the internal list |
* |
* @param string $strCommand Command, which cause the Error |
* @param string $strMessage additional Message, to describe the Error |
* |
* @return void |
*/ |
public function addConfigError($strCommand, $strMessage) |
{ |
$this->_addError($strCommand, "Wrong Value in phpsysinfo.ini for ".$strMessage); |
} |
/** |
* add a php error to the internal list |
* |
* @param string $strCommand Command, which cause the Error |
* @param string $strMessage additional Message, to describe the Error |
* |
* @return void |
*/ |
public function addPhpError($strCommand, $strMessage) |
{ |
$this->_addError($strCommand, "PHP throws a error\n".$strMessage); |
} |
/** |
* adds a waraning to the internal list |
* |
* @param string $strMessage Warning message to display |
* |
* @return void |
*/ |
public function addWarning($strMessage) |
{ |
$index = count($this->_arrErrorList) + 1; |
$this->_arrErrorList[$index]['command'] = "WARN"; |
$this->_arrErrorList[$index]['message'] = $strMessage; |
} |
/** |
* converts the internal error and warning list to a XML file |
* |
* @return void |
*/ |
public function errorsAsXML() |
{ |
$dom = new DOMDocument('1.0', 'UTF-8'); |
$root = $dom->createElement("phpsysinfo"); |
$dom->appendChild($root); |
$xml = new SimpleXMLExtended(simplexml_import_dom($dom), 'UTF-8'); |
$generation = $xml->addChild('Generation'); |
$generation->addAttribute('version', PSI_VERSION_STRING); |
$generation->addAttribute('timestamp', time()); |
$xmlerr = $xml->addChild("Errors"); |
foreach ($this->_arrErrorList as $arrLine) { |
// $error = $xmlerr->addCData('Error', $arrLine['message']); |
$error = $xmlerr->addChild('Error'); |
$error->addAttribute('Message', $arrLine['message']); |
$error->addAttribute('Function', $arrLine['command']); |
} |
header("Cache-Control: no-cache, must-revalidate\n"); |
header("Content-Type: text/xml\n\n"); |
echo $xml->getSimpleXmlElement()->asXML(); |
exit(); |
} |
/** |
* add the errors to an existing xml document |
* |
* @param String $encoding encoding |
* |
* @return SimpleXmlElement |
*/ |
public function errorsAddToXML($encoding) |
{ |
$dom = new DOMDocument('1.0', 'UTF-8'); |
$root = $dom->createElement("Errors"); |
$dom->appendChild($root); |
$xml = simplexml_import_dom($dom); |
$xmlerr = new SimpleXMLExtended($xml, $encoding); |
foreach ($this->_arrErrorList as $arrLine) { |
// $error = $xmlerr->addCData('Error', $arrLine['message']); |
$error = $xmlerr->addChild('Error'); |
$error->addAttribute('Message', $arrLine['message']); |
$error->addAttribute('Function', $arrLine['command']); |
} |
return $xmlerr->getSimpleXmlElement(); |
} |
/** |
* check if errors exists |
* |
* @return boolean true if are errors logged, false if not |
*/ |
public function errorsExist() |
{ |
if ($this->_errors > 0) { |
return true; |
} else { |
return false; |
} |
} |
/** |
* generate a function backtrace for error diagnostic, function is genearally based on code submitted in the php reference page |
* |
* @param string $strMessage additional message to display |
* |
* @return string formatted string of the backtrace |
*/ |
private function _trace($strMessage) |
{ |
$arrTrace = array_reverse(debug_backtrace()); |
$strFunc = ''; |
$strBacktrace = htmlspecialchars($strMessage)."\n\n"; |
foreach ($arrTrace as $val) { |
// avoid the last line, which says the error is from the error class |
if ($val == $arrTrace[count($arrTrace) - 1]) { |
break; |
} |
$strBacktrace .= str_replace(PSI_APP_ROOT, ".", $val['file']).' on line '.$val['line']; |
if ($strFunc) { |
$strBacktrace .= ' in function '.$strFunc; |
} |
if ($val['function'] == 'include' || $val['function'] == 'require' || $val['function'] == 'include_once' || $val['function'] == 'require_once') { |
$strFunc = ''; |
} else { |
$strFunc = $val['function'].'('; |
if (isset($val['args'][0])) { |
$strFunc .= ' '; |
$strComma = ''; |
foreach ($val['args'] as $valArgs) { |
$strFunc .= $strComma.$this->_printVar($valArgs); |
$strComma = ', '; |
} |
$strFunc .= ' '; |
} |
$strFunc .= ')'; |
} |
$strBacktrace .= "\n"; |
} |
return $strBacktrace; |
} |
/** |
* convert some special vars into better readable output |
* |
* @param mixed $var value, which should be formatted |
* |
* @return string formatted string |
*/ |
private function _printVar($var) |
{ |
if (is_string($var)) { |
$search = array("\x00", "\x0a", "\x0d", "\x1a", "\x09"); |
$replace = array('\0', '\n', '\r', '\Z', '\t'); |
return ('"'.str_replace($search, $replace, $var).'"'); |
} elseif (is_bool($var)) { |
if ($var) { |
return ('true'); |
} else { |
return ('false'); |
} |
} elseif (is_array($var)) { |
$strResult = 'array( '; |
$strComma = ''; |
foreach ($var as $key=>$val) { |
$strResult .= $strComma.$this->_printVar($key).' => '.$this->_printVar($val); |
$strComma = ', '; |
} |
$strResult .= ' )'; |
return ($strResult); |
} |
// anything else, just let php try to print it |
return (var_export($var, true)); |
} |
} |
/web/acc/phpsysinfo/includes/interface/class.PSI_Interface_OS.inc.php |
---|
0,0 → 1,57 |
<?php |
/** |
* Basic OS Functions |
* |
* PHP version 5 |
* |
* @category PHP |
* @package PSI_Interfaces |
* @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.PSI_Interface_OS.inc.php 263 2009-06-22 13:01:52Z bigmichi1 $ |
* @link http://phpsysinfo.sourceforge.net |
*/ |
/** |
* define which methods a os class for phpsysinfo must implement |
* to be recognized and fully work without errors, these are the methods which |
* are called from outside to include the information in the main application |
* |
* @category PHP |
* @package PSI_Interfaces |
* @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 |
*/ |
interface PSI_Interface_OS |
{ |
/** |
* get a special encoding from os where phpsysinfo is running |
* |
* @return string |
*/ |
public function getEncoding(); |
/** |
* build the os information |
* |
* @return void |
*/ |
public function build(); |
/** |
* get the filled or unfilled (with default values) system object |
* |
* @return System |
*/ |
public function getSys(); |
/** |
* get os specific language |
* |
* @return string |
*/ |
public function getLanguage(); |
} |
/web/acc/phpsysinfo/includes/interface/class.PSI_Interface_Output.inc.php |
---|
0,0 → 1,35 |
<?php |
/** |
* Basic Output Functions |
* |
* PHP version 5 |
* |
* @category PHP |
* @package PSI_Interfaces |
* @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.PSI_Interface_Output.inc.php 214 2009-05-25 08:32:40Z bigmichi1 $ |
* @link http://phpsysinfo.sourceforge.net |
*/ |
/** |
* define which methods a output class for phpsysinfo must implement |
* to be recognized and fully work without errors |
* |
* @category PHP |
* @package PSI_Interfaces |
* @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 |
*/ |
interface PSI_Interface_Output |
{ |
/** |
* generate the output |
* |
* @return void |
*/ |
public function run(); |
} |
/web/acc/phpsysinfo/includes/interface/class.PSI_Interface_Plugin.inc.php |
---|
0,0 → 1,43 |
<?php |
/** |
* Basic Plugin Functions |
* |
* PHP version 5 |
* |
* @category PHP |
* @package PSI_Interfaces |
* @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.PSI_Interface_Plugin.inc.php 273 2009-06-24 11:40:09Z bigmichi1 $ |
* @link http://phpsysinfo.sourceforge.net |
*/ |
/** |
* define which methods a plugin class for phpsysinfo must implement |
* to be recognized and fully work without errors, these are the methods which |
* are called from outside to include the information in the main application |
* |
* @category PHP |
* @package PSI_Interfaces |
* @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 |
*/ |
interface PSI_Interface_Plugin |
{ |
/** |
* doing all tasks before the xml can be build |
* |
* @return void |
*/ |
public function execute(); |
/** |
* build the xml |
* |
* @return SimpleXMLElement entire XML content for the plugin which than can be appended to the main XML |
*/ |
public function xml(); |
} |
/web/acc/phpsysinfo/includes/interface/class.PSI_Interface_Sensor.inc.php |
---|
0,0 → 1,43 |
<?php |
/** |
* Basic Sensor Functions |
* |
* PHP version 5 |
* |
* @category PHP |
* @package PSI_Interfaces |
* @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.PSI_Interface_Sensor.inc.php 263 2009-06-22 13:01:52Z bigmichi1 $ |
* @link http://phpsysinfo.sourceforge.net |
*/ |
/** |
* define which methods every sensor class for phpsysinfo must implement |
* to be recognized and fully work without errors, these are the methods which |
* are called from outside to include the information in the main application |
* |
* @category PHP |
* @package PSI_Interfaces |
* @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 |
*/ |
interface PSI_Interface_Sensor |
{ |
/** |
* build the mbinfo information |
* |
* @return void |
*/ |
public function build(); |
/** |
* get the filled or unfilled (with default values) MBInfo object |
* |
* @return MBInfo |
*/ |
public function getMBInfo(); |
} |
/web/acc/phpsysinfo/includes/interface/class.PSI_Interface_UPS.inc.php |
---|
0,0 → 1,42 |
<?php |
/** |
* Basic UPS Functions |
* |
* PHP version 5 |
* |
* @category PHP |
* @package PSI_Interfaces |
* @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.PSI_Interface_UPS.inc.php 263 2009-06-22 13:01:52Z bigmichi1 $ |
* @link http://phpsysinfo.sourceforge.net |
*/ |
/** |
* define which methods a ups class for phpsysinfo must implement |
* to be recognized and fully work without errors |
* |
* @category PHP |
* @package PSI_Interfaces |
* @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 |
*/ |
interface PSI_Interface_UPS |
{ |
/** |
* build the ups information |
* |
* @return void |
*/ |
public function build(); |
/** |
* get the filled or unfilled (with default values) UPSInfo object |
* |
* @return UPSInfo |
*/ |
public function getUPSInfo(); |
} |
/web/acc/phpsysinfo/includes/js/README |
---|
0,0 → 1,10 |
versions, links and simple description of used files |
=========================================================== |
class.JavaScriptPacker.inc.php |
--------- |
VERSION : 1.1+FF4 |
URL : http://dean.edwards.name |
DESC : Downloaded from http://dean.edwards.name/download/ http://joliclic.free.fr/php/javascript-packer/en/ + Firefox 4 fix |
LICENSE : LGPL 2.1 (http://creativecommons.org/licenses/LGPL/2.1/) |
USED : define('PSI_JS_COMPRESSION', 'None'); or define('PSI_JS_COMPRESSION', 'Normal'); |
/web/acc/phpsysinfo/includes/js/class.JavaScriptPacker.inc.php |
---|
0,0 → 1,788 |
<?php |
/* 25 October 2011. version 1.1-FF4 |
* |
* This is the php version of the Dean Edwards JavaScript's Packer, |
* Based on : |
* |
* ParseMaster, version 1.0.2 (2005-08-19) Copyright 2005, Dean Edwards |
* a multi-pattern parser. |
* KNOWN BUG: erroneous behavior when using escapeChar with a replacement |
* value that is a function |
* |
* packer, version 2.0.2 (2005-08-19) Copyright 2004-2005, Dean Edwards |
* |
* License: http://creativecommons.org/licenses/LGPL/2.1/ |
* |
* Ported to PHP by Nicolas Martin. |
* |
* ---------------------------------------------------------------------- |
* changelog: |
* 1.1 : correct a bug, '\0' packed then unpacked becomes '\'. |
* 1.1-FF4 : Firefox 4 fix, Copyright 2011, Mieczyslaw Nalewaj |
* ---------------------------------------------------------------------- |
* |
* examples of usage : |
* $myPacker = new JavaScriptPacker($script, 62, true, false); |
* $packed = $myPacker->pack(); |
* |
* or |
* |
* $myPacker = new JavaScriptPacker($script, 'Normal', true, false); |
* $packed = $myPacker->pack(); |
* |
* or (default values) |
* |
* $myPacker = new JavaScriptPacker($script); |
* $packed = $myPacker->pack(); |
* |
* |
* params of the constructor : |
* $script: the JavaScript to pack, string. |
* $encoding: level of encoding, int or string : |
* 0,10,62,95 or 'None', 'Numeric', 'Normal', 'High ASCII'. |
* default: 62. |
* $fastDecode: include the fast decoder in the packed result, boolean. |
* default : true. |
* $specialChars: if you are flagged your private and local variables |
* in the script, boolean. |
* default: false. |
* |
* The pack() method return the compressed JavasScript, as a string. |
* |
* see http://dean.edwards.name/packer/usage/ for more information. |
* |
* Notes : |
* # need PHP 5 . Tested with PHP 5.1.2, 5.1.3, 5.1.4, 5.2.3 |
* |
* # The packed result may be different than with the Dean Edwards |
* version, but with the same length. The reason is that the PHP |
* function usort to sort array don't necessarily preserve the |
* original order of two equal member. The Javascript sort function |
* in fact preserve this order (but that's not require by the |
* ECMAScript standard). So the encoded keywords order can be |
* different in the two results. |
* |
* # Be careful with the 'High ASCII' Level encoding if you use |
* UTF-8 in your files... |
*/ |
class JavaScriptPacker |
{ |
// constants |
const IGNORE = '$1'; |
// validate parameters |
private $_script = ''; |
private $_encoding = 62; |
private $_fastDecode = true; |
private $_specialChars = false; |
private $LITERAL_ENCODING = array( |
'None' => 0, |
'Numeric' => 10, |
'Normal' => 62, |
'High ASCII' => 95 |
); |
public function __construct($_script, $_encoding = 62, $_fastDecode = true, $_specialChars = false) |
{ |
$this->_script = $_script . "\n"; |
if (array_key_exists($_encoding, $this->LITERAL_ENCODING)) |
$_encoding = $this->LITERAL_ENCODING[$_encoding]; |
$this->_encoding = min((int) $_encoding, 95); |
$this->_fastDecode = $_fastDecode; |
$this->_specialChars = $_specialChars; |
} |
public function pack() |
{ |
$this->_addParser('_basicCompression'); |
if ($this->_specialChars) |
$this->_addParser('_encodeSpecialChars'); |
if ($this->_encoding) |
$this->_addParser('_encodeKeywords'); |
// go! |
return $this->_pack($this->_script); |
} |
// apply all parsing routines |
private function _pack($script) |
{ |
for ($i = 0; isset($this->_parsers[$i]); $i++) { |
$script = call_user_func(array(&$this, $this->_parsers[$i]), $script); |
} |
return $script; |
} |
// keep a list of parsing functions, they'll be executed all at once |
private $_parsers = array(); |
private function _addParser($parser) |
{ |
$this->_parsers[] = $parser; |
} |
// zero encoding - just removal of white space and comments |
private function _basicCompression($script) |
{ |
$parser = new ParseMaster(); |
// make safe |
$parser->escapeChar = '\\'; |
// protect strings |
$parser->add('/\'[^\'\\n\\r]*\'/', self::IGNORE); |
$parser->add('/"[^"\\n\\r]*"/', self::IGNORE); |
// remove comments |
$parser->add('/\\/\\/[^\\n\\r]*[\\n\\r]/', ' '); |
$parser->add('/\\/\\*[^*]*\\*+([^\\/][^*]*\\*+)*\\//', ' '); |
// protect regular expressions |
$parser->add('/\\s+(\\/[^\\/\\n\\r\\*][^\\/\\n\\r]*\\/g?i?)/', '$2'); // IGNORE |
$parser->add('/[^\\w\\x24\\/\'"*)\\?:]\\/[^\\/\\n\\r\\*][^\\/\\n\\r]*\\/g?i?/', self::IGNORE); |
// remove: ;;; doSomething(); |
if ($this->_specialChars) $parser->add('/;;;[^\\n\\r]+[\\n\\r]/'); |
// remove redundant semi-colons |
$parser->add('/\\(;;\\)/', self::IGNORE); // protect for (;;) loops |
$parser->add('/;+\\s*([};])/', '$2'); |
// apply the above |
$script = $parser->exec($script); |
// remove white-space |
$parser->add('/(\\b|\\x24)\\s+(\\b|\\x24)/', '$2 $3'); |
$parser->add('/([+\\-])\\s+([+\\-])/', '$2 $3'); |
$parser->add('/\\s+/', ''); |
// done |
return $parser->exec($script); |
} |
private function _encodeSpecialChars($script) |
{ |
$parser = new ParseMaster(); |
// replace: $name -> n, $$name -> na |
$parser->add('/((\\x24+)([a-zA-Z$_]+))(\\d*)/', |
array('fn' => '_replace_name') |
); |
// replace: _name -> _0, double-underscore (__name) is ignored |
$regexp = '/\\b_[A-Za-z\\d]\\w*/'; |
// build the word list |
$keywords = $this->_analyze($script, $regexp, '_encodePrivate'); |
// quick ref |
$encoded = $keywords['encoded']; |
$parser->add($regexp, |
array( |
'fn' => '_replace_encoded', |
'data' => $encoded |
) |
); |
return $parser->exec($script); |
} |
private function _encodeKeywords($script) |
{ |
// escape high-ascii values already in the script (i.e. in strings) |
if ($this->_encoding > 62) |
$script = $this->_escape95($script); |
// create the parser |
$parser = new ParseMaster(); |
$encode = $this->_getEncoder($this->_encoding); |
// for high-ascii, don't encode single character low-ascii |
$regexp = ($this->_encoding > 62) ? '/\\w\\w+/' : '/\\w+/'; |
// build the word list |
$keywords = $this->_analyze($script, $regexp, $encode); |
$encoded = $keywords['encoded']; |
// encode |
$parser->add($regexp, |
array( |
'fn' => '_replace_encoded', |
'data' => $encoded |
) |
); |
if (empty($script)) return $script; |
else { |
//$res = $parser->exec($script); |
//$res = $this->_bootStrap($res, $keywords); |
//return $res; |
return $this->_bootStrap($parser->exec($script), $keywords); |
} |
} |
private function _analyze($script, $regexp, $encode) |
{ |
// analyse |
// retreive all words in the script |
$all = array(); |
preg_match_all($regexp, $script, $all); |
$_sorted = array(); // list of words sorted by frequency |
$_encoded = array(); // dictionary of word->encoding |
$_protected = array(); // instances of "protected" words |
$all = $all[0]; // simulate the javascript comportement of global match |
if (!empty($all)) { |
$unsorted = array(); // same list, not sorted |
$protected = array(); // "protected" words (dictionary of word->"word") |
$value = array(); // dictionary of charCode->encoding (eg. 256->ff) |
$this->_count = array(); // word->count |
$i = count($all); $j = 0; //$word = null; |
// count the occurrences - used for sorting later |
do { |
--$i; |
$word = '$' . $all[$i]; |
if (!isset($this->_count[$word])) { |
$this->_count[$word] = 0; |
$unsorted[$j] = $word; |
// make a dictionary of all of the protected words in this script |
// these are words that might be mistaken for encoding |
//if (is_string($encode) && method_exists($this, $encode)) |
$values[$j] = call_user_func(array(&$this, $encode), $j); |
$protected['$' . $values[$j]] = $j++; |
} |
// increment the word counter |
$this->_count[$word]++; |
} while ($i > 0); |
// prepare to sort the word list, first we must protect |
// words that are also used as codes. we assign them a code |
// equivalent to the word itself. |
// e.g. if "do" falls within our encoding range |
// then we store keywords["do"] = "do"; |
// this avoids problems when decoding |
$i = count($unsorted); |
do { |
$word = $unsorted[--$i]; |
if (isset($protected[$word]) /*!= null*/) { |
$_sorted[$protected[$word]] = substr($word, 1); |
$_protected[$protected[$word]] = true; |
$this->_count[$word] = 0; |
} |
} while ($i); |
// sort the words by frequency |
// Note: the javascript and php version of sort can be different : |
// in php manual, usort : |
// " If two members compare as equal, |
// their order in the sorted array is undefined." |
// so the final packed script is different of the Dean's javascript version |
// but equivalent. |
// the ECMAscript standard does not guarantee this behaviour, |
// and thus not all browsers (e.g. Mozilla versions dating back to at |
// least 2003) respect this. |
usort($unsorted, array(&$this, '_sortWords')); |
$j = 0; |
// because there are "protected" words in the list |
// we must add the sorted words around them |
do { |
if (!isset($_sorted[$i])) |
$_sorted[$i] = substr($unsorted[$j++], 1); |
$_encoded[$_sorted[$i]] = $values[$i]; |
} while (++$i < count($unsorted)); |
} |
return array( |
'sorted' => $_sorted, |
'encoded' => $_encoded, |
'protected' => $_protected); |
} |
private $_count = array(); |
private function _sortWords($match1, $match2) |
{ |
return $this->_count[$match2] - $this->_count[$match1]; |
} |
// build the boot function used for loading and decoding |
private function _bootStrap($packed, $keywords) |
{ |
$ENCODE = $this->_safeRegExp('$encode\\($count\\)'); |
// $packed: the packed script |
$packed = "'" . $this->_escape($packed) . "'"; |
// $ascii: base for encoding |
$ascii = min(count($keywords['sorted']), $this->_encoding); |
if ($ascii == 0) $ascii = 1; |
// $count: number of words contained in the script |
$count = count($keywords['sorted']); |
// $keywords: list of words contained in the script |
foreach ($keywords['protected'] as $i=>$value) { |
$keywords['sorted'][$i] = ''; |
} |
// convert from a string to an array |
ksort($keywords['sorted']); |
$keywords = "'" . implode('|', $keywords['sorted']) . "'.split('|')"; |
$encode = ($this->_encoding > 62) ? '_encode95' : $this->_getEncoder($ascii); |
$encode = $this->_getJSFunction($encode); |
$encode = preg_replace('/_encoding/', '$ascii', $encode); |
$encode = preg_replace('/arguments\\.callee/', '$encode', $encode); |
$inline = '\\$count' . ($ascii > 10 ? '.toString(\\$ascii)' : ''); |
// $decode: code snippet to speed up decoding |
if ($this->_fastDecode) { |
// create the decoder |
$decode = $this->_getJSFunction('_decodeBody'); |
if ($this->_encoding > 62) |
$decode = preg_replace('/\\\\w/', '[\\xa1-\\xff]', $decode); |
// perform the encoding inline for lower ascii values |
elseif ($ascii < 36) |
$decode = preg_replace($ENCODE, $inline, $decode); |
// special case: when $count==0 there are no keywords. I want to keep |
// the basic shape of the unpacking funcion so i'll frig the code... |
if ($count == 0) |
$decode = preg_replace($this->_safeRegExp('($count)\\s*=\\s*1'), '$1=0', $decode, 1); |
} |
// boot function |
$unpack = $this->_getJSFunction('_unpack'); |
if ($this->_fastDecode) { |
// insert the decoder |
$this->buffer = $decode; |
$unpack = preg_replace_callback('/\\{/', array(&$this, '_insertFastDecode'), $unpack, 1); |
} |
$unpack = preg_replace('/"/', "'", $unpack); |
if ($this->_encoding > 62) { // high-ascii |
// get rid of the word-boundaries for regexp matches |
$unpack = preg_replace('/\'\\\\\\\\b\'\s*\\+|\\+\s*\'\\\\\\\\b\'/', '', $unpack); |
} |
if ($ascii > 36 || $this->_encoding > 62 || $this->_fastDecode) { |
// insert the encode function |
$this->buffer = $encode; |
$unpack = preg_replace_callback('/\\{/', array(&$this, '_insertFastEncode'), $unpack, 1); |
} else { |
// perform the encoding inline |
$unpack = preg_replace($ENCODE, $inline, $unpack); |
} |
// pack the boot function too |
$unpackPacker = new JavaScriptPacker($unpack, 0, false, true); |
$unpack = $unpackPacker->pack(); |
// arguments |
$params = array($packed, $ascii, $count, $keywords); |
if ($this->_fastDecode) { |
$params[] = 0; |
$params[] = '{}'; |
} |
$params = implode(',', $params); |
// the whole thing |
//Firefox 4 fix, old: return 'eval(' . $unpack . '(' . $params . "))\n"; |
return "(typeof setTimeout=='function'?setTimeout:eval)(" . $unpack . "(" . $params . "));\n"; |
} |
private $buffer; |
private function _insertFastDecode($match) |
{ |
return '{' . $this->buffer . ';'; |
} |
private function _insertFastEncode($match) |
{ |
return '{$encode=' . $this->buffer . ';'; |
} |
// mmm.. ..which one do i need ?? |
private function _getEncoder($ascii) |
{ |
return $ascii > 10 ? $ascii > 36 ? $ascii > 62 ? |
'_encode95' : '_encode62' : '_encode36' : '_encode10'; |
} |
// zero encoding |
// characters: 0123456789 |
private function _encode10($charCode) |
{ |
return $charCode; |
} |
// inherent base36 support |
// characters: 0123456789abcdefghijklmnopqrstuvwxyz |
private function _encode36($charCode) |
{ |
return base_convert($charCode, 10, 36); |
} |
// hitch a ride on base36 and add the upper case alpha characters |
// characters: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |
private function _encode62($charCode) |
{ |
$res = ''; |
if ($charCode >= $this->_encoding) { |
$res = $this->_encode62((int) ($charCode / $this->_encoding)); |
} |
$charCode = $charCode % $this->_encoding; |
if ($charCode > 35) |
return $res . chr($charCode + 29); |
else |
return $res . base_convert($charCode, 10, 36); |
} |
// use high-ascii values |
// characters: ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ |
private function _encode95($charCode) |
{ |
$res = ''; |
if ($charCode >= $this->_encoding) |
$res = $this->_encode95($charCode / $this->_encoding); |
return $res . chr(($charCode % $this->_encoding) + 161); |
} |
private function _safeRegExp($string) |
{ |
return '/'.preg_replace('/\$/', '\\\$', $string).'/'; |
} |
private function _encodePrivate($charCode) |
{ |
return "_" . $charCode; |
} |
// protect characters used by the parser |
private function _escape($script) |
{ |
return preg_replace('/([\\\\\'])/', '\\\$1', $script); |
} |
// protect high-ascii characters already in the script |
private function _escape95($script) |
{ |
return preg_replace_callback( |
'/[\\xa1-\\xff]/', |
array(&$this, '_escape95Bis'), |
$script |
); |
} |
private function _escape95Bis($match) |
{ |
return '\x'.((string) dechex(ord($match))); |
} |
private function _getJSFunction($aName) |
{ |
if (defined('self::JSFUNCTION'.$aName)) |
return constant('self::JSFUNCTION'.$aName); |
else |
return ''; |
} |
// JavaScript Functions used. |
// Note : In Dean's version, these functions are converted |
// with 'String(aFunctionName);'. |
// This internal conversion complete the original code, ex : |
// 'while (aBool) anAction();' is converted to |
// 'while (aBool) { anAction(); }'. |
// The JavaScript functions below are corrected. |
// unpacking function - this is the boot strap function |
// data extracted from this packing routine is passed to |
// this function when decoded in the target |
// NOTE ! : without the ';' final. |
const JSFUNCTION_unpack = |
'function ($packed, $ascii, $count, $keywords, $encode, $decode) { |
while ($count--) { |
if ($keywords[$count]) { |
$packed = $packed.replace(new RegExp(\'\\\\b\' + $encode($count) + \'\\\\b\', \'g\'), $keywords[$count]); |
} |
} |
return $packed; |
}'; |
/* |
'function ($packed, $ascii, $count, $keywords, $encode, $decode) { |
while ($count--) |
if ($keywords[$count]) |
$packed = $packed.replace(new RegExp(\'\\\\b\' + $encode($count) + \'\\\\b\', \'g\'), $keywords[$count]); |
return $packed; |
}'; |
*/ |
// code-snippet inserted into the unpacker to speed up decoding |
const JSFUNCTION_decodeBody = |
//_decode = function () { |
// does the browser support String.replace where the |
// replacement value is a function? |
' if (!\'\'.replace(/^/, String)) { |
// decode all the values we need |
while ($count--) { |
$decode[$encode($count)] = $keywords[$count] || $encode($count); |
} |
// global replacement function |
$keywords = [function ($encoded) {return $decode[$encoded]}]; |
// generic match |
$encode = function () {return \'\\\\w+\'}; |
// reset the loop counter - we are now doing a global replace |
$count = 1; |
} |
'; |
//}; |
/* |
' if (!\'\'.replace(/^/, String)) { |
// decode all the values we need |
while ($count--) $decode[$encode($count)] = $keywords[$count] || $encode($count); |
// global replacement function |
$keywords = [function ($encoded) {return $decode[$encoded]}]; |
// generic match |
$encode = function () {return\'\\\\w+\'}; |
// reset the loop counter - we are now doing a global replace |
$count = 1; |
}'; |
*/ |
// zero encoding |
// characters: 0123456789 |
const JSFUNCTION_encode10 = |
'function ($charCode) { |
return $charCode; |
}';//;'; |
// inherent base36 support |
// characters: 0123456789abcdefghijklmnopqrstuvwxyz |
const JSFUNCTION_encode36 = |
'function ($charCode) { |
return $charCode.toString(36); |
}';//;'; |
// hitch a ride on base36 and add the upper case alpha characters |
// characters: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |
const JSFUNCTION_encode62 = |
'function ($charCode) { |
return ($charCode < _encoding ? \'\' : arguments.callee(parseInt($charCode / _encoding))) + |
(($charCode = $charCode % _encoding) > 35 ? String.fromCharCode($charCode + 29) : $charCode.toString(36)); |
}'; |
// use high-ascii values |
// characters: ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ |
const JSFUNCTION_encode95 = |
'function ($charCode) { |
return ($charCode < _encoding ? \'\' : arguments.callee($charCode / _encoding)) + |
String.fromCharCode($charCode % _encoding + 161); |
}'; |
} |
class ParseMaster |
{ |
public $ignoreCase = false; |
public $escapeChar = ''; |
// constants |
const EXPRESSION = 0; |
const REPLACEMENT = 1; |
const LENGTH = 2; |
// used to determine nesting levels |
private $GROUPS = '/\\(/';//g |
private $SUB_REPLACE = '/\\$\\d/'; |
private $INDEXED = '/^\\$\\d+$/'; |
private $TRIM = '/([\'"])\\1\\.(.*)\\.\\1\\1$/'; |
private $ESCAPE = '/\\\./';//g |
private $QUOTE = '/\'/'; |
private $DELETED = '/\\x01[^\\x01]*\\x01/';//g |
public function add($expression, $replacement = '') |
{ |
// count the number of sub-expressions |
// - add one because each pattern is itself a sub-expression |
$length = 1 + preg_match_all($this->GROUPS, $this->_internalEscape((string) $expression), $out); |
// treat only strings $replacement |
if (is_string($replacement)) { |
// does the pattern deal with sub-expressions? |
if (preg_match($this->SUB_REPLACE, $replacement)) { |
// a simple lookup? (e.g. "$2") |
if (preg_match($this->INDEXED, $replacement)) { |
// store the index (used for fast retrieval of matched strings) |
$replacement = (int) (substr($replacement, 1)) - 1; |
} else { // a complicated lookup (e.g. "Hello $2 $1") |
// build a function to do the lookup |
$quote = preg_match($this->QUOTE, $this->_internalEscape($replacement)) |
? '"' : "'"; |
$replacement = array( |
'fn' => '_backReferences', |
'data' => array( |
'replacement' => $replacement, |
'length' => $length, |
'quote' => $quote |
) |
); |
} |
} |
} |
// pass the modified arguments |
if (!empty($expression)) $this->_add($expression, $replacement, $length); |
else $this->_add('/^$/', $replacement, $length); |
} |
public function exec($string) |
{ |
// execute the global replacement |
$this->_escaped = array(); |
// simulate the _patterns.toSTring of Dean |
$regexp = '/'; |
foreach ($this->_patterns as $reg) { |
$regexp .= '(' . substr($reg[self::EXPRESSION], 1, -1) . ')|'; |
} |
$regexp = substr($regexp, 0, -1) . '/'; |
$regexp .= ($this->ignoreCase) ? 'i' : ''; |
$string = $this->_escape($string, $this->escapeChar); |
$string = preg_replace_callback( |
$regexp, |
array( |
&$this, |
'_replacement' |
), |
$string |
); |
$string = $this->_unescape($string, $this->escapeChar); |
return preg_replace($this->DELETED, '', $string); |
} |
public function reset() |
{ |
// clear the patterns collection so that this object may be re-used |
$this->_patterns = array(); |
} |
// private |
private $_escaped = array(); // escaped characters |
private $_patterns = array(); // patterns stored by index |
// create and add a new pattern to the patterns collection |
private function _add() |
{ |
$arguments = func_get_args(); |
$this->_patterns[] = $arguments; |
} |
// this is the global replace function (it's quite complicated) |
private function _replacement($arguments) |
{ |
if (empty($arguments)) return ''; |
$i = 1; $j = 0; |
// loop through the patterns |
while (isset($this->_patterns[$j])) { |
$pattern = $this->_patterns[$j++]; |
// do we have a result? |
if (isset($arguments[$i]) && ($arguments[$i] != '')) { |
$replacement = $pattern[self::REPLACEMENT]; |
if (is_array($replacement) && isset($replacement['fn'])) { |
if (isset($replacement['data'])) $this->buffer = $replacement['data']; |
return call_user_func(array(&$this, $replacement['fn']), $arguments, $i); |
} elseif (is_int($replacement)) { |
return $arguments[$replacement + $i]; |
} |
$delete = ($this->escapeChar == '' || |
strpos($arguments[$i], $this->escapeChar) === false) |
? '' : "\x01" . $arguments[$i] . "\x01"; |
return $delete . $replacement; |
// skip over references to sub-expressions |
} else { |
$i += $pattern[self::LENGTH]; |
} |
} |
} |
private function _backReferences($match, $offset) |
{ |
$replacement = $this->buffer['replacement']; |
$quote = $this->buffer['quote']; |
$i = $this->buffer['length']; |
while ($i) { |
$replacement = str_replace('$'.$i--, $match[$offset + $i], $replacement); |
} |
return $replacement; |
} |
private function _replace_name($match, $offset) |
{ |
$length = strlen($match[$offset + 2]); |
$start = $length - max($length - strlen($match[$offset + 3]), 0); |
return substr($match[$offset + 1], $start, $length) . $match[$offset + 4]; |
} |
private function _replace_encoded($match, $offset) |
{ |
return $this->buffer[$match[$offset]]; |
} |
// php : we cannot pass additional data to preg_replace_callback, |
// and we cannot use &$this in create_function, so let's go to lower level |
private $buffer; |
// encode escaped characters |
private function _escape($string, $escapeChar) |
{ |
if ($escapeChar) { |
$this->buffer = $escapeChar; |
return preg_replace_callback( |
'/\\' . $escapeChar . '(.)' .'/', |
array(&$this, '_escapeBis'), |
$string |
); |
} else { |
return $string; |
} |
} |
private function _escapeBis($match) |
{ |
$this->_escaped[] = $match[1]; |
return $this->buffer; |
} |
// decode escaped characters |
private function _unescape($string, $escapeChar) |
{ |
if ($escapeChar) { |
$regexp = '/'.'\\'.$escapeChar.'/'; |
$this->buffer = array('escapeChar'=> $escapeChar, 'i' => 0); |
return preg_replace_callback( |
$regexp, |
array(&$this, '_unescapeBis'), |
$string |
); |
} else { |
return $string; |
} |
} |
private function _unescapeBis() |
{ |
if (isset($this->_escaped[$this->buffer['i']]) |
&& $this->_escaped[$this->buffer['i']] != '') |
{ |
$temp = $this->_escaped[$this->buffer['i']]; |
} else { |
$temp = ''; |
} |
$this->buffer['i']++; |
return $this->buffer['escapeChar'] . $temp; |
} |
private function _internalEscape($string) |
{ |
return preg_replace($this->ESCAPE, '', $string); |
} |
} |
/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); |
} |
} |
/web/acc/phpsysinfo/includes/plugin/class.PSI_Plugin.inc.php |
---|
0,0 → 1,134 |
<?php |
/** |
* Basic Plugin Functions |
* |
* PHP version 5 |
* |
* @category PHP |
* @package PSI_Plugin |
* @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.PSI_Plugin.inc.php 661 2012-08-27 11:26:39Z namiltd $ |
* @link http://phpsysinfo.sourceforge.net |
*/ |
/** |
* basic functions to get a plugin working in phpSysinfo |
* every plugin must implement this abstract class to be a valid plugin, main tasks |
* of this class are reading the configuration file and check for the required files |
* (*.js, lang/en.xml) to get everything working, if we have errors here we log them |
* to our global error object |
* |
* @category PHP |
* @package PSI_Plugin |
* @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 PSI_Plugin implements PSI_Interface_Plugin |
{ |
/** |
* name of the plugin (classname) |
* |
* @var string |
*/ |
private $_plugin_name = ""; |
/** |
* full directory path of the plugin |
* |
* @var string |
*/ |
private $_plugin_base = ""; |
/** |
* global object for error handling |
* |
* @var Error |
*/ |
protected $global_error = ""; |
/** |
* xml tamplate with header |
* |
* @var SimpleXMLExtended |
*/ |
protected $xml; |
/** |
* build the global Error object, read the configuration and check if all files are available |
* for a minimalistic function of the plugin |
* |
* @param string $plugin_name name of the plugin |
* @param string $enc target encoding |
* @return void |
*/ |
public function __construct($plugin_name, $enc) |
{ |
$this->global_error = PSI_Error::Singleton(); |
if (trim($plugin_name) != "") { |
$this->_plugin_name = $plugin_name; |
$this->_plugin_base = PSI_APP_ROOT."/plugins/".strtolower($this->_plugin_name)."/"; |
$this->_checkfiles(); |
$this->_getconfig(); |
} else { |
$this->global_error->addError("__construct()", "Parent constructor called without Plugin-Name!"); |
} |
$this->_createXml($enc); |
} |
/** |
* read the plugin configuration file, if we have one in the plugin directory |
* |
* @return void |
*/ |
private function _getconfig() |
{ |
if ((!defined('PSI_PLUGIN_'.strtoupper($this->_plugin_name).'_ACCESS')) && |
(!defined('PSI_PLUGIN_'.strtoupper($this->_plugin_name).'_FILE')) && |
(!defined('PSI_PLUGIN_'.strtoupper($this->_plugin_name).'_SHOW_SERIAL'))) { |
$this->global_error->addError("phpsysinfo.ini", "Config for plugin ".$this->_plugin_name." not exist!"); |
} |
} |
/** |
* check if there is a default translation file availabe and also the required js file for |
* appending the content of the plugin to the main webpage |
* |
* @return void |
*/ |
private function _checkfiles() |
{ |
if (!file_exists($this->_plugin_base."js/".strtolower($this->_plugin_name).".js")) { |
$this->global_error->addError("file_exists(".$this->_plugin_base."js/".strtolower($this->_plugin_name).".js)", "JS-File for Plugin '".$this->_plugin_name."' is missing!"); |
} else { |
if (!is_readable($this->_plugin_base."js/".strtolower($this->_plugin_name).".js")) { |
$this->global_error->addError("is_readable(".$this->_plugin_base."js/".strtolower($this->_plugin_name).".js)", "JS-File for Plugin '".$this->_plugin_name."' is not readable but present!"); |
} |
} |
if (!file_exists($this->_plugin_base."lang/en.xml")) { |
$this->global_error->addError("file_exists(".$this->_plugin_base."lang/en.xml)", "At least an english translation must exist for the plugin!"); |
} else { |
if (!is_readable($this->_plugin_base."lang/en.xml")) { |
$this->global_error->addError("is_readable(".$this->_plugin_base."js/".$this->_plugin_name.".js)", "The english translation can't be read but is present!"); |
} |
} |
} |
/** |
* create the xml template where plugin information are added to |
* |
* @param string $enc target encoding |
* |
* @return void |
*/ |
private function _createXml($enc) |
{ |
$dom = new DOMDocument('1.0', 'UTF-8'); |
$root = $dom->createElement("Plugin_".$this->_plugin_name); |
$dom->appendChild($root); |
$this->xml = new SimpleXMLExtended(simplexml_import_dom($dom), $enc); |
} |
} |
/web/acc/phpsysinfo/includes/to/class.MBInfo.inc.php |
---|
0,0 → 1,261 |
<?php |
/** |
* MBInfo TO class |
* |
* PHP version 5 |
* |
* @category PHP |
* @package PSI_TO |
* @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.MBInfo.inc.php 253 2009-06-17 13:07:50Z bigmichi1 $ |
* @link http://phpsysinfo.sourceforge.net |
*/ |
/** |
* MBInfo TO class |
* |
* @category PHP |
* @package PSI_TO |
* @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 MBInfo |
{ |
/** |
* array with SensorDevices for temperatures |
* |
* @see SensorDevice |
* |
* @var array |
*/ |
private $_mbTemp = array(); |
/** |
* array with SensorDevices for fans |
* |
* @see SensorDevice |
* |
* @var array |
*/ |
private $_mbFan = array(); |
/** |
* array with SensorDevices for voltages |
* |
* @see SensorDevice |
* |
* @var array |
*/ |
private $_mbVolt = array(); |
/** |
* array with SensorDevices for power |
* |
* @see SensorDevice |
* |
* @var array |
*/ |
private $_mbPower = array(); |
/** |
* array with SensorDevices for apmers |
* |
* @see SensorDevice |
* |
* @var array |
*/ |
private $_mbCurrent = array(); |
/** |
* array with SensorDevices for other |
* |
* @see SensorDevice |
* |
* @var array |
*/ |
private $_mbOther = array(); |
/** |
* Returns $_mbFan. |
* |
* @see System::$_mbFan |
* |
* @return array |
*/ |
public function getMbFan() |
{ |
if (defined('PSI_SORT_SENSORS_LIST') && PSI_SORT_SENSORS_LIST) { |
usort($this->_mbFan, array('CommonFunctions', 'name_natural_compare')); |
} |
return $this->_mbFan; |
} |
/** |
* Sets $_mbFan. |
* |
* @param SensorDevice $mbFan fan device |
* |
* @see System::$_mbFan |
* |
* @return void |
*/ |
public function setMbFan($mbFan) |
{ |
array_push($this->_mbFan, $mbFan); |
} |
/** |
* Returns $_mbTemp. |
* |
* @see System::$_mbTemp |
* |
* @return array |
*/ |
public function getMbTemp() |
{ |
if (defined('PSI_SORT_SENSORS_LIST') && PSI_SORT_SENSORS_LIST) { |
usort($this->_mbTemp, array('CommonFunctions', 'name_natural_compare')); |
} |
return $this->_mbTemp; |
} |
/** |
* Sets $_mbTemp. |
* |
* @param SensorDevice $mbTemp temp device |
* |
* @see System::$_mbTemp |
* |
* @return void |
*/ |
public function setMbTemp($mbTemp) |
{ |
array_push($this->_mbTemp, $mbTemp); |
} |
/** |
* Returns $_mbVolt. |
* |
* @see System::$_mbVolt |
* |
* @return array |
*/ |
public function getMbVolt() |
{ |
if (defined('PSI_SORT_SENSORS_LIST') && PSI_SORT_SENSORS_LIST) { |
usort($this->_mbVolt, array('CommonFunctions', 'name_natural_compare')); |
} |
return $this->_mbVolt; |
} |
/** |
* Sets $_mbVolt. |
* |
* @param SensorDevice $mbVolt voltage device |
* |
* @see System::$_mbVolt |
* |
* @return void |
*/ |
public function setMbVolt($mbVolt) |
{ |
array_push($this->_mbVolt, $mbVolt); |
} |
/** |
* Returns $_mbPower. |
* |
* @see System::$_mbPower |
* |
* @return array |
*/ |
public function getMbPower() |
{ |
if (defined('PSI_SORT_SENSORS_LIST') && PSI_SORT_SENSORS_LIST) { |
usort($this->_mbPower, array('CommonFunctions', 'name_natural_compare')); |
} |
return $this->_mbPower; |
} |
/** |
* Sets $_mbPower. |
* |
* @param SensorDevice $mbPower power device |
* |
* @see System::$_mbPower |
* |
* @return void |
*/ |
public function setMbPower($mbPower) |
{ |
array_push($this->_mbPower, $mbPower); |
} |
/** |
* Returns $_mbCurrent. |
* |
* @see System::$_mbCurrent |
* |
* @return array |
*/ |
public function getMbCurrent() |
{ |
if (defined('PSI_SORT_SENSORS_LIST') && PSI_SORT_SENSORS_LIST) { |
usort($this->_mbCurrent, array('CommonFunctions', 'name_natural_compare')); |
} |
return $this->_mbCurrent; |
} |
/** |
* Sets $_mbCurrent. |
* |
* @param SensorDevice $mbCurrent current device |
* |
* @see System::$_mbCurrent |
* |
* @return void |
*/ |
public function setMbCurrent($mbCurrent) |
{ |
array_push($this->_mbCurrent, $mbCurrent); |
} |
/** |
* Returns $_mbOther. |
* |
* @see System::$_mbOther |
* |
* @return array |
*/ |
public function getMbOther() |
{ |
if (defined('PSI_SORT_SENSORS_LIST') && PSI_SORT_SENSORS_LIST) { |
usort($this->_mbOther, array('CommonFunctions', 'name_natural_compare')); |
} |
return $this->_mbOther; |
} |
/** |
* Sets $_mbOther. |
* |
* @param SensorDevice $mbOther other device |
* |
* @see System::$_mbOther |
* |
* @return void |
*/ |
public function setMbOther($mbOther) |
{ |
array_push($this->_mbOther, $mbOther); |
} |
} |
/web/acc/phpsysinfo/includes/to/class.System.inc.php |
---|
0,0 → 1,1207 |
<?php |
/** |
* System TO class |
* |
* PHP version 5 |
* |
* @category PHP |
* @package PSI_TO |
* @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.System.inc.php 255 2009-06-17 13:39:41Z bigmichi1 $ |
* @link http://phpsysinfo.sourceforge.net |
*/ |
/** |
* System TO class |
* |
* @category PHP |
* @package PSI_TO |
* @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 System |
{ |
/** |
* name of the host where phpSysInfo runs |
* |
* @var String |
*/ |
private $_hostname = "localhost"; |
/** |
* ip of the host where phpSysInfo runs |
* |
* @var String |
*/ |
private $_ip = "127.0.0.1"; |
/** |
* detailed Information about the kernel |
* |
* @var String |
*/ |
private $_kernel = "Unknown"; |
/** |
* name of the distribution |
* |
* @var String |
*/ |
private $_distribution = "Unknown"; |
/** |
* icon of the distribution (must be available in phpSysInfo) |
* |
* @var String |
*/ |
private $_distributionIcon = "unknown.png"; |
/** |
* detailed Information about the machine name |
* |
* @var String |
*/ |
private $_machine = ""; |
/** |
* time in sec how long the system is running |
* |
* @var Integer |
*/ |
private $_uptime = 0; |
/** |
* count of users that are currently logged in |
* |
* @var Integer |
*/ |
private $_users = 0; |
/** |
* load of the system |
* |
* @var String |
*/ |
private $_load = ""; |
/** |
* load of the system in percent (all cpus, if more than one) |
* |
* @var Integer |
*/ |
private $_loadPercent = null; |
/** |
* array with cpu devices |
* |
* @see CpuDevice |
* |
* @var array |
*/ |
private $_cpus = array(); |
/** |
* array with network devices |
* |
* @see NetDevice |
* |
* @var array |
*/ |
private $_netDevices = array(); |
/** |
* array with pci devices |
* |
* @see HWDevice |
* |
* @var array |
*/ |
private $_pciDevices = array(); |
/** |
* array with ide devices |
* |
* @see HWDevice |
* |
* @var array |
*/ |
private $_ideDevices = array(); |
/** |
* array with scsi devices |
* |
* @see HWDevice |
* |
* @var array |
*/ |
private $_scsiDevices = array(); |
/** |
* array with usb devices |
* |
* @see HWDevice |
* |
* @var array |
*/ |
private $_usbDevices = array(); |
/** |
* array with thunderbolt devices |
* |
* @see HWDevice |
* |
* @var array |
*/ |
private $_tbDevices = array(); |
/** |
* array with I2C devices |
* |
* @see HWDevice |
* |
* @var array |
*/ |
private $_i2cDevices = array(); |
/** |
* array with NVMe devices |
* |
* @see HWDevice |
* |
* @var array |
*/ |
private $_nvmeDevices = array(); |
/** |
* array with disk devices |
* |
* @see DiskDevice |
* |
* @var array |
*/ |
private $_diskDevices = array(); |
/** |
* free memory in bytes |
* |
* @var Integer |
*/ |
private $_memFree = 0; |
/** |
* total memory in bytes |
* |
* @var Integer |
*/ |
private $_memTotal = 0; |
/** |
* used memory in bytes |
* |
* @var Integer |
*/ |
private $_memUsed = 0; |
/** |
* used memory by applications in bytes |
* |
* @var Integer |
*/ |
private $_memApplication = null; |
/** |
* used memory for buffers in bytes |
* |
* @var Integer |
*/ |
private $_memBuffer = null; |
/** |
* used memory for cache in bytes |
* |
* @var Integer |
*/ |
private $_memCache = null; |
/** |
* array with swap devices |
* |
* @see DiskDevice |
* |
* @var array |
*/ |
private $_swapDevices = array(); |
/** |
* array of types of processes |
* |
* @var array |
*/ |
private $_processes = array(); |
/** |
* remove duplicate Entries and Count |
* |
* @param array $arrDev list of HWDevices |
* |
* @see HWDevice |
* |
* @return array |
*/ |
public static function removeDupsAndCount($arrDev) |
{ |
$result = array(); |
foreach ($arrDev as $dev) { |
if (count($result) === 0) { |
array_push($result, $dev); |
} else { |
$found = false; |
foreach ($result as $tmp) { |
if ($dev->equals($tmp)) { |
$tmp->setCount($tmp->getCount() + 1); |
$found = true; |
break; |
} |
} |
if (!$found) { |
array_push($result, $dev); |
} |
} |
} |
return $result; |
} |
/** |
* return percent of used memory |
* |
* @see System::_memUsed |
* @see System::_memTotal |
* |
* @return Integer |
*/ |
public function getMemPercentUsed() |
{ |
if ($this->_memTotal > 0) { |
return round($this->_memUsed / $this->_memTotal * 100); |
} else { |
return 0; |
} |
} |
/** |
* return percent of used memory for applications |
* |
* @see System::_memApplication |
* @see System::_memTotal |
* |
* @return Integer |
*/ |
public function getMemPercentApplication() |
{ |
if ($this->_memApplication !== null) { |
if (($this->_memApplication > 0) && ($this->_memTotal > 0)) { |
return round($this->_memApplication / $this->_memTotal * 100); |
} else { |
return 0; |
} |
} else { |
return null; |
} |
} |
/** |
* return percent of used memory for cache |
* |
* @see System::_memCache |
* @see System::_memTotal |
* |
* @return Integer |
*/ |
public function getMemPercentCache() |
{ |
if ($this->_memCache !== null) { |
if (($this->_memCache > 0) && ($this->_memTotal > 0)) { |
if (($this->_memApplication !== null) && ($this->_memApplication > 0)) { |
return round(($this->_memCache + $this->_memApplication) / $this->_memTotal * 100) - $this->getMemPercentApplication(); |
} else { |
return round($this->_memCache / $this->_memTotal * 100); |
} |
} else { |
return 0; |
} |
} else { |
return null; |
} |
} |
/** |
* return percent of used memory for buffer |
* |
* @see System::_memBuffer |
* @see System::_memTotal |
* |
* @return Integer |
*/ |
public function getMemPercentBuffer() |
{ |
if ($this->_memBuffer !== null) { |
if (($this->_memBuffer > 0) && ($this->_memTotal > 0)) { |
if (($this->_memCache !== null) && ($this->_memCache > 0)) { |
if (($this->_memApplication !== null) && ($this->_memApplication > 0)) { |
return round(($this->_memBuffer + $this->_memApplication + $this->_memCache) / $this->_memTotal * 100) - $this->getMemPercentApplication() - $this->getMemPercentCache(); |
} else { |
return round(($this->_memBuffer + $this->_memCache) / $this->_memTotal * 100) - $this->getMemPercentCache(); |
} |
} elseif (($this->_memApplication !== null) && ($this->_memApplication > 0)) { |
return round(($this->_memBuffer + $this->_memApplication) / $this->_memTotal * 100) - $this->getMemPercentApplication(); |
} else { |
return round($this->_memBuffer / $this->_memTotal * 100); |
} |
} else { |
return 0; |
} |
} else { |
return null; |
} |
} |
/** |
* Returns total free swap space |
* |
* @see System::_swapDevices |
* @see DiskDevice::getFree() |
* |
* @return Integer |
*/ |
public function getSwapFree() |
{ |
if (count($this->_swapDevices) > 0) { |
$free = 0; |
foreach ($this->_swapDevices as $dev) { |
$free += $dev->getFree(); |
} |
return $free; |
} |
return null; |
} |
/** |
* Returns total swap space |
* |
* @see System::_swapDevices |
* @see DiskDevice::getTotal() |
* |
* @return Integer |
*/ |
public function getSwapTotal() |
{ |
if (count($this->_swapDevices) > 0) { |
$total = 0; |
foreach ($this->_swapDevices as $dev) { |
$total += $dev->getTotal(); |
} |
return $total; |
} else { |
return null; |
} |
} |
/** |
* Returns total used swap space |
* |
* @see System::_swapDevices |
* @see DiskDevice::getUsed() |
* |
* @return Integer |
*/ |
public function getSwapUsed() |
{ |
if (count($this->_swapDevices) > 0) { |
$used = 0; |
foreach ($this->_swapDevices as $dev) { |
$used += $dev->getUsed(); |
} |
return $used; |
} else { |
return null; |
} |
} |
/** |
* return percent of total swap space used |
* |
* @see System::getSwapUsed() |
* @see System::getSwapTotal() |
* |
* @return Integer |
*/ |
public function getSwapPercentUsed() |
{ |
if ($this->getSwapTotal() !== null) { |
if ($this->getSwapTotal() > 0) { |
return round($this->getSwapUsed() / $this->getSwapTotal() * 100); |
} else { |
return 0; |
} |
} else { |
return null; |
} |
} |
/** |
* Returns $_distribution. |
* |
* @see System::$_distribution |
* |
* @return String |
*/ |
public function getDistribution() |
{ |
return $this->_distribution; |
} |
/** |
* Sets $_distribution. |
* |
* @param String $distribution distributionname |
* |
* @see System::$_distribution |
* |
* @return Void |
*/ |
public function setDistribution($distribution) |
{ |
$this->_distribution = $distribution; |
} |
/** |
* Returns $_distributionIcon. |
* |
* @see System::$_distributionIcon |
* |
* @return String |
*/ |
public function getDistributionIcon() |
{ |
return $this->_distributionIcon; |
} |
/** |
* Sets $_distributionIcon. |
* |
* @param String $distributionIcon distribution icon |
* |
* @see System::$_distributionIcon |
* |
* @return Void |
*/ |
public function setDistributionIcon($distributionIcon) |
{ |
$this->_distributionIcon = $distributionIcon; |
} |
/** |
* Returns $_hostname. |
* |
* @see System::$_hostname |
* |
* @return String |
*/ |
public function getHostname() |
{ |
return $this->_hostname; |
} |
/** |
* Sets $_hostname. |
* |
* @param String $hostname hostname |
* |
* @see System::$_hostname |
* |
* @return Void |
*/ |
public function setHostname($hostname) |
{ |
$this->_hostname = $hostname; |
} |
/** |
* Returns $_ip. |
* |
* @see System::$_ip |
* |
* @return String |
*/ |
public function getIp() |
{ |
return $this->_ip; |
} |
/** |
* Sets $_ip. |
* |
* @param String $ip IP |
* |
* @see System::$_ip |
* |
* @return Void |
*/ |
public function setIp($ip) |
{ |
$this->_ip = $ip; |
} |
/** |
* Returns $_kernel. |
* |
* @see System::$_kernel |
* |
* @return String |
*/ |
public function getKernel() |
{ |
return $this->_kernel; |
} |
/** |
* Sets $_kernel. |
* |
* @param String $kernel kernelname |
* |
* @see System::$_kernel |
* |
* @return Void |
*/ |
public function setKernel($kernel) |
{ |
$this->_kernel = $kernel; |
} |
/** |
* Returns $_load. |
* |
* @see System::$_load |
* |
* @return String |
*/ |
public function getLoad() |
{ |
return $this->_load; |
} |
/** |
* Sets $_load. |
* |
* @param String $load current system load |
* |
* @see System::$_load |
* |
* @return Void |
*/ |
public function setLoad($load) |
{ |
$this->_load = $load; |
} |
/** |
* Returns $_loadPercent. |
* |
* @see System::$_loadPercent |
* |
* @return Integer |
*/ |
public function getLoadPercent() |
{ |
return $this->_loadPercent; |
} |
/** |
* Sets $_loadPercent. |
* |
* @param Integer $loadPercent load percent |
* |
* @see System::$_loadPercent |
* |
* @return Void |
*/ |
public function setLoadPercent($loadPercent) |
{ |
$this->_loadPercent = $loadPercent; |
} |
/** |
* Returns $_machine. |
* |
* @see System::$_machine |
* |
* @return String |
*/ |
public function getMachine() |
{ |
return $this->_machine; |
} |
/** |
* Sets $_machine. |
* |
* @param string $machine machine |
* |
* @see System::$_machine |
* |
* @return Void |
*/ |
public function setMachine($machine) |
{ |
$this->_machine = $machine; |
} |
/** |
* Returns $_uptime. |
* |
* @see System::$_uptime |
* |
* @return Integer |
*/ |
public function getUptime() |
{ |
return $this->_uptime; |
} |
/** |
* Sets $_uptime. |
* |
* @param integer $uptime uptime |
* |
* @see System::$_uptime |
* |
* @return Void |
*/ |
public function setUptime($uptime) |
{ |
$this->_uptime = $uptime; |
} |
/** |
* Returns $_users. |
* |
* @see System::$_users |
* |
* @return Integer |
*/ |
public function getUsers() |
{ |
return $this->_users; |
} |
/** |
* Sets $_users. |
* |
* @param Integer $users user count |
* |
* @see System::$_users |
* |
* @return Void |
*/ |
public function setUsers($users) |
{ |
$this->_users = $users; |
} |
/** |
* Returns $_cpus. |
* |
* @see System::$_cpus |
* |
* @return array |
*/ |
public function getCpus() |
{ |
return $this->_cpus; |
} |
/** |
* Sets $_cpus. |
* |
* @param CpuDevice $cpus cpu device |
* |
* @see System::$_cpus |
* @see CpuDevice |
* |
* @return Void |
*/ |
public function setCpus($cpus) |
{ |
array_push($this->_cpus, $cpus); |
} |
/** |
* Returns $_netDevices. |
* |
* @see System::$_netDevices |
* |
* @return array |
*/ |
public function getNetDevices() |
{ |
if (defined('PSI_SORT_NETWORK_INTERFACES_LIST') && PSI_SORT_NETWORK_INTERFACES_LIST) { |
usort($this->_netDevices, array('CommonFunctions', 'name_natural_compare')); |
} |
return $this->_netDevices; |
} |
/** |
* Sets $_netDevices. |
* |
* @param NetDevice $netDevices network device |
* |
* @see System::$_netDevices |
* @see NetDevice |
* |
* @return Void |
*/ |
public function setNetDevices($netDevices) |
{ |
array_push($this->_netDevices, $netDevices); |
} |
/** |
* Returns $_pciDevices. |
* |
* @see System::$_pciDevices |
* |
* @return array |
*/ |
public function getPciDevices() |
{ |
return $this->_pciDevices; |
} |
/** |
* Sets $_pciDevices. |
* |
* @param HWDevice $pciDevices pci device |
* |
* @see System::$_pciDevices |
* @see HWDevice |
* |
* @return Void |
*/ |
public function setPciDevices($pciDevices) |
{ |
array_push($this->_pciDevices, $pciDevices); |
} |
/** |
* Returns $_ideDevices. |
* |
* @see System::$_ideDevices |
* |
* @return array |
*/ |
public function getIdeDevices() |
{ |
return $this->_ideDevices; |
} |
/** |
* Sets $_ideDevices. |
* |
* @param HWDevice $ideDevices ide device |
* |
* @see System::$_ideDevices |
* @see HWDevice |
* |
* @return Void |
*/ |
public function setIdeDevices($ideDevices) |
{ |
array_push($this->_ideDevices, $ideDevices); |
} |
/** |
* Returns $_scsiDevices. |
* |
* @see System::$_scsiDevices |
* |
* @return array |
*/ |
public function getScsiDevices() |
{ |
return $this->_scsiDevices; |
} |
/** |
* Sets $_scsiDevices. |
* |
* @param HWDevice $scsiDevices scsi devices |
* |
* @see System::$_scsiDevices |
* @see HWDevice |
* |
* @return Void |
*/ |
public function setScsiDevices($scsiDevices) |
{ |
array_push($this->_scsiDevices, $scsiDevices); |
} |
/** |
* Returns $_usbDevices. |
* |
* @see System::$_usbDevices |
* |
* @return array |
*/ |
public function getUsbDevices() |
{ |
return $this->_usbDevices; |
} |
/** |
* Sets $_usbDevices. |
* |
* @param HWDevice $usbDevices usb device |
* |
* @see System::$_usbDevices |
* @see HWDevice |
* |
* @return Void |
*/ |
public function setUsbDevices($usbDevices) |
{ |
array_push($this->_usbDevices, $usbDevices); |
} |
/** |
* Returns $_tbDevices. |
* |
* @see System::$_tbDevices |
* |
* @return array |
*/ |
public function getTbDevices() |
{ |
return $this->_tbDevices; |
} |
/** |
* Sets $_tbDevices. |
* |
* @param HWDevice $tbDevices thunderbolt device |
* |
* @see System::$_tbDevices |
* @see HWDevice |
* |
* @return Void |
*/ |
public function setTbDevices($tbDevices) |
{ |
array_push($this->_tbDevices, $tbDevices); |
} |
/** |
* Returns $_i2cDevices. |
* |
* @see System::$_i2cDevices |
* |
* @return array |
*/ |
public function getI2cDevices() |
{ |
return $this->_i2cDevices; |
} |
/** |
* Sets $_i2cDevices. |
* |
* @param HWDevice $i2cDevices I2C device |
* |
* @see System::$_i2cDevices |
* @see HWDevice |
* |
* @return Void |
*/ |
public function setI2cDevices($i2cDevices) |
{ |
array_push($this->_i2cDevices, $i2cDevices); |
} |
/** |
* Returns $_nvmeDevices. |
* |
* @see System::$_nvmeDevices |
* |
* @return array |
*/ |
public function getNvmeDevices() |
{ |
return $this->_nvmeDevices; |
} |
/** |
* Sets $_nvmeDevices. |
* |
* @param HWDevice $nvmeDevices NVMe device |
* |
* @see System::$_nvmeDevices |
* @see HWDevice |
* |
* @return Void |
*/ |
public function setNvmeDevices($nvmeDevices) |
{ |
array_push($this->_nvmeDevices, $nvmeDevices); |
} |
/** |
* Returns $_diskDevices. |
* |
* @see System::$_diskDevices |
* |
* @return array |
*/ |
public function getDiskDevices() |
{ |
return $this->_diskDevices; |
} |
/** |
* Sets $_diskDevices. |
* |
* @param DiskDevice $diskDevices disk device |
* |
* @see System::$_diskDevices |
* @see DiskDevice |
* |
* @return void |
*/ |
public function setDiskDevices($diskDevices) |
{ |
array_push($this->_diskDevices, $diskDevices); |
} |
/** |
* Returns $_memApplication. |
* |
* @see System::$_memApplication |
* |
* @return Integer |
*/ |
public function getMemApplication() |
{ |
return $this->_memApplication; |
} |
/** |
* Sets $_memApplication. |
* |
* @param Integer $memApplication application memory |
* |
* @see System::$_memApplication |
* |
* @return Void |
*/ |
public function setMemApplication($memApplication) |
{ |
$this->_memApplication = $memApplication; |
} |
/** |
* Returns $_memBuffer. |
* |
* @see System::$_memBuffer |
* |
* @return Integer |
*/ |
public function getMemBuffer() |
{ |
return $this->_memBuffer; |
} |
/** |
* Sets $_memBuffer. |
* |
* @param Integer $memBuffer buffer memory |
* |
* @see System::$_memBuffer |
* |
* @return Void |
*/ |
public function setMemBuffer($memBuffer) |
{ |
$this->_memBuffer = $memBuffer; |
} |
/** |
* Returns $_memCache. |
* |
* @see System::$_memCache |
* |
* @return Integer |
*/ |
public function getMemCache() |
{ |
return $this->_memCache; |
} |
/** |
* Sets $_memCache. |
* |
* @param Integer $memCache cache memory |
* |
* @see System::$_memCache |
* |
* @return Void |
*/ |
public function setMemCache($memCache) |
{ |
$this->_memCache = $memCache; |
} |
/** |
* Returns $_memFree. |
* |
* @see System::$_memFree |
* |
* @return Integer |
*/ |
public function getMemFree() |
{ |
return $this->_memFree; |
} |
/** |
* Sets $_memFree. |
* |
* @param Integer $memFree free memory |
* |
* @see System::$_memFree |
* |
* @return Void |
*/ |
public function setMemFree($memFree) |
{ |
$this->_memFree = $memFree; |
} |
/** |
* Returns $_memTotal. |
* |
* @see System::$_memTotal |
* |
* @return Integer |
*/ |
public function getMemTotal() |
{ |
return $this->_memTotal; |
} |
/** |
* Sets $_memTotal. |
* |
* @param Integer $memTotal total memory |
* |
* @see System::$_memTotal |
* |
* @return Void |
*/ |
public function setMemTotal($memTotal) |
{ |
$this->_memTotal = $memTotal; |
} |
/** |
* Returns $_memUsed. |
* |
* @see System::$_memUsed |
* |
* @return Integer |
*/ |
public function getMemUsed() |
{ |
return $this->_memUsed; |
} |
/** |
* Sets $_memUsed. |
* |
* @param Integer $memUsed used memory |
* |
* @see System::$_memUsed |
* |
* @return Void |
*/ |
public function setMemUsed($memUsed) |
{ |
$this->_memUsed = $memUsed; |
} |
/** |
* Returns $_swapDevices. |
* |
* @see System::$_swapDevices |
* |
* @return array |
*/ |
public function getSwapDevices() |
{ |
return $this->_swapDevices; |
} |
/** |
* Sets $_swapDevices. |
* |
* @param DiskDevice $swapDevices swap devices |
* |
* @see System::$_swapDevices |
* @see DiskDevice |
* |
* @return Void |
*/ |
public function setSwapDevices($swapDevices) |
{ |
array_push($this->_swapDevices, $swapDevices); |
} |
/** |
* Returns $_processes. |
* |
* @see System::$_processes |
* |
* @return array |
*/ |
public function getProcesses() |
{ |
return $this->_processes; |
} |
/** |
* Sets $_proceses. |
* |
* @param $processes array of types of processes |
* |
* @see System::$_processes |
* |
* @return Void |
*/ |
public function setProcesses($processes) |
{ |
$this->_processes = $processes; |
/* |
foreach ($processes as $proc_type=>$proc_count) { |
$this->_processes[$proc_type] = $proc_count; |
} |
*/ |
} |
} |
/web/acc/phpsysinfo/includes/to/class.UPSInfo.inc.php |
---|
0,0 → 1,62 |
<?php |
/** |
* MBInfo TO class |
* |
* PHP version 5 |
* |
* @category PHP |
* @package PSI_TO |
* @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.UPSInfo.inc.php 329 2009-09-07 11:21:44Z bigmichi1 $ |
* @link http://phpsysinfo.sourceforge.net |
*/ |
/** |
* MBInfo TO class |
* |
* @category PHP |
* @package PSI_TO |
* @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 UPSInfo |
{ |
/** |
* array with upsdivices |
* |
* @see UPSDevice |
* |
* @var array |
*/ |
private $_upsDevices = array(); |
/** |
* Returns $_upsDevices. |
* |
* @see UPSInfo::$_upsDevices |
* |
* @return array |
*/ |
public function getUpsDevices() |
{ |
return $this->_upsDevices; |
} |
/** |
* Sets $_upsDevices. |
* |
* @param UPSDevice $upsDevices upsdevice |
* |
* @see UPSInfo::$_upsDevices |
* |
* @return void |
*/ |
public function setUpsDevices($upsDevices) |
{ |
array_push($this->_upsDevices, $upsDevices); |
} |
} |
/web/acc/phpsysinfo/includes/ups/class.apcupsd.inc.php |
---|
0,0 → 1,148 |
<?php |
/** |
* Apcupsd class |
* |
* PHP version 5 |
* |
* @category PHP |
* @package PSI_UPS |
* @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.apcupsd.inc.php 661 2012-08-27 11:26:39Z namiltd $ |
* @link http://phpsysinfo.sourceforge.net |
*/ |
/** |
* getting ups information from apcupsd program |
* |
* @category PHP |
* @package PSI_UPS |
* @author Michael Cramer <BigMichi1@users.sourceforge.net> |
* @author Artem Volk <artvolk@mail.ru> |
* @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 Apcupsd extends UPS |
{ |
/** |
* internal storage for all gathered data |
* |
* @var array |
*/ |
private $_output = array(); |
/** |
* get all information from all configured ups in phpsysinfo.ini and store output in internal array |
*/ |
public function __construct() |
{ |
parent::__construct(); |
if (defined('PSI_UPS_APCUPSD_LIST') && is_string(PSI_UPS_APCUPSD_LIST)) { |
if (preg_match(ARRAY_EXP, PSI_UPS_APCUPSD_LIST)) { |
$upses = eval(PSI_UPS_APCUPSD_LIST); |
} else { |
$upses = array(PSI_UPS_APCUPSD_LIST); |
} |
foreach ($upses as $ups) { |
CommonFunctions::executeProgram('apcaccess', 'status '.trim($ups), $temp); |
if (! empty($temp)) { |
$this->_output[] = $temp; |
} |
} |
} else { //use default if address and port not defined |
CommonFunctions::executeProgram('apcaccess', 'status', $temp); |
if (! empty($temp)) { |
$this->_output[] = $temp; |
} |
} |
} |
/** |
* parse the input and store data in resultset for xml generation |
* |
* @return Void |
*/ |
private function _info() |
{ |
foreach ($this->_output as $ups) { |
$dev = new UPSDevice(); |
// General info |
if (preg_match('/^UPSNAME\s*:\s*(.*)$/m', $ups, $data)) { |
$dev->setName(trim($data[1])); |
} |
if (preg_match('/^MODEL\s*:\s*(.*)$/m', $ups, $data)) { |
$model = trim($data[1]); |
if (preg_match('/^APCMODEL\s*:\s*(.*)$/m', $ups, $data)) { |
$dev->setModel($model.' ('.trim($data[1]).')'); |
} else { |
$dev->setModel($model); |
} |
} |
if (preg_match('/^UPSMODE\s*:\s*(.*)$/m', $ups, $data)) { |
$dev->setMode(trim($data[1])); |
} |
if (preg_match('/^STARTTIME\s*:\s*(.*)$/m', $ups, $data)) { |
$dev->setStartTime(trim($data[1])); |
} |
if (preg_match('/^STATUS\s*:\s*(.*)$/m', $ups, $data)) { |
$dev->setStatus(trim($data[1])); |
} |
if (preg_match('/^ITEMP\s*:\s*(.*)$/m', $ups, $data)) { |
$temperatur = trim($data[1]); |
if (($temperatur !== "-273.1 C") && ($temperatur !== "-273.1 C Internal")) { |
$dev->setTemperatur($temperatur); |
} |
} |
// Outages |
if (preg_match('/^NUMXFERS\s*:\s*(.*)$/m', $ups, $data)) { |
$dev->setOutages(trim($data[1])); |
} |
if (preg_match('/^LASTXFER\s*:\s*(.*)$/m', $ups, $data)) { |
$dev->setLastOutage(trim($data[1])); |
} |
if (preg_match('/^XOFFBATT\s*:\s*(.*)$/m', $ups, $data)) { |
$dev->setLastOutageFinish(trim($data[1])); |
} |
// Line |
if (preg_match('/^LINEV\s*:\s*(\d*\.\d*)(.*)$/m', $ups, $data)) { |
$dev->setLineVoltage(trim($data[1])); |
} |
if (preg_match('/^LINEFREQ\s*:\s*(\d*\.\d*)(.*)$/m', $ups, $data)) { |
$dev->setLineFrequency(trim($data[1])); |
} |
if (preg_match('/^LOADPCT\s*:\s*(\d*\.\d*)(.*)$/m', $ups, $data)) { |
$dev->setLoad(trim($data[1])); |
} |
// Battery |
if (preg_match('/^BATTDATE\s*:\s*(.*)$/m', $ups, $data)) { |
$dev->setBatteryDate(trim($data[1])); |
} |
if (preg_match('/^BATTV\s*:\s*(\d*\.\d*)(.*)$/m', $ups, $data)) { |
$dev->setBatteryVoltage(trim($data[1])); |
} |
if (preg_match('/^BCHARGE\s*:\s*(\d*\.\d*)(.*)$/m', $ups, $data)) { |
$dev->setBatterCharge(trim($data[1])); |
} |
if (preg_match('/^TIMELEFT\s*:\s*(\d*\.\d*)(.*)$/m', $ups, $data)) { |
$dev->setTimeLeft(trim($data[1])); |
} |
$this->upsinfo->setUpsDevices($dev); |
} |
} |
/** |
* get the information |
* |
* @see PSI_Interface_UPS::build() |
* |
* @return Void |
*/ |
public function build() |
{ |
$this->_info(); |
} |
} |
/web/acc/phpsysinfo/includes/ups/class.nut.inc.php |
---|
0,0 → 1,142 |
<?php |
/** |
* Nut class |
* |
* PHP version 5 |
* |
* @category PHP |
* @package PSI_UPS |
* @author Artem Volk <artvolk@mail.ru> |
* @author Anders Häggström <hagge@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.nut.inc.php 661 2012-08-27 11:26:39Z namiltd $ |
* @link http://phpsysinfo.sourceforge.net |
*/ |
/** |
* getting ups information from upsc program |
* |
* @category PHP |
* @package PSI_UPS |
* @author Artem Volk <artvolk@mail.ru> |
* @author Anders Häggström <hagge@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 Nut extends UPS |
{ |
/** |
* internal storage for all gathered data |
* |
* @var array |
*/ |
private $_output = array(); |
/** |
* get all information from all configured ups and store output in internal array |
*/ |
public function __construct() |
{ |
parent::__construct(); |
if (defined('PSI_UPS_NUT_LIST') && is_string(PSI_UPS_NUT_LIST)) { |
if (preg_match(ARRAY_EXP, PSI_UPS_NUT_LIST)) { |
$upses = eval(PSI_UPS_NUT_LIST); |
} else { |
$upses = array(PSI_UPS_NUT_LIST); |
} |
foreach ($upses as $ups) { |
CommonFunctions::executeProgram('upsc', '-l '.trim($ups), $output, PSI_DEBUG); |
$ups_names = preg_split("/\n/", $output, -1, PREG_SPLIT_NO_EMPTY); |
foreach ($ups_names as $ups_name) { |
CommonFunctions::executeProgram('upsc', trim($ups_name).'@'.trim($ups), $temp, PSI_DEBUG); |
if (! empty($temp)) { |
$this->_output[trim($ups_name).'@'.trim($ups)] = $temp; |
} |
} |
} |
} else { //use default if address and port not defined |
CommonFunctions::executeProgram('upsc', '-l', $output, PSI_DEBUG); |
$ups_names = preg_split("/\n/", $output, -1, PREG_SPLIT_NO_EMPTY); |
foreach ($ups_names as $ups_name) { |
CommonFunctions::executeProgram('upsc', trim($ups_name), $temp, PSI_DEBUG); |
if (! empty($temp)) { |
$this->_output[trim($ups_name)] = $temp; |
} |
} |
} |
} |
/** |
* parse the input and store data in resultset for xml generation |
* |
* @return void |
*/ |
private function _info() |
{ |
if (! empty($this->_output)) { |
foreach ($this->_output as $name => $value) { |
$temp = preg_split("/\n/", $value, -1, PREG_SPLIT_NO_EMPTY); |
$ups_data = array(); |
foreach ($temp as $valueTemp) { |
$line = preg_split('/: /', $valueTemp, 2); |
$ups_data[$line[0]] = isset($line[1]) ? trim($line[1]) : ''; |
} |
$dev = new UPSDevice(); |
//General |
$dev->setName($name); |
if (isset($ups_data['ups.model'])) { |
$dev->setModel($ups_data['ups.model']); |
} |
if (isset($ups_data['driver.name'])) { |
$dev->setMode($ups_data['driver.name']); |
} |
if (isset($ups_data['ups.status'])) { |
$dev->setStatus($ups_data['ups.status']); |
} |
//Line |
if (isset($ups_data['input.voltage'])) { |
$dev->setLineVoltage($ups_data['input.voltage']); |
} |
if (isset($ups_data['input.frequency'])) { |
$dev->setLineFrequency($ups_data['input.frequency']); |
} |
if (isset($ups_data['ups.load'])) { |
$dev->setLoad($ups_data['ups.load']); |
} |
//Battery |
if (isset($ups_data['battery.voltage'])) { |
$dev->setBatteryVoltage($ups_data['battery.voltage']); |
} |
if (isset($ups_data['battery.charge'])) { |
$dev->setBatterCharge($ups_data['battery.charge']); |
} |
if (isset($ups_data['battery.runtime'])) { |
$dev->setTimeLeft(round($ups_data['battery.runtime']/60, 2)); |
} |
//Temperature |
if (isset($ups_data['ups.temperature'])) { |
$dev->setTemperatur($ups_data['ups.temperature']); |
} |
$this->upsinfo->setUpsDevices($dev); |
} |
} |
} |
/** |
* get the information |
* |
* @see PSI_Interface_UPS::build() |
* |
* @return Void |
*/ |
public function build() |
{ |
$this->_info(); |
} |
} |
/web/acc/phpsysinfo/includes/ups/class.pmset.inc.php |
---|
0,0 → 1,96 |
<?php |
/** |
* Pmset class |
* |
* PHP version 5 |
* |
* @category PHP |
* @package PSI_UPS |
* @author Robert Pelletier <drizzt@menzonet.org> |
* @copyright 2014 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.nut.inc.php 661 2012-08-27 11:26:39Z namiltd $ |
* @link http://phpsysinfo.sourceforge.net |
*/ |
/** |
* getting ups information from pmset program |
* |
* @category PHP |
* @package PSI_UPS |
* @author Robert Pelletier <drizzt@menzonet.org> |
* @copyright 2014 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 Pmset extends UPS |
{ |
/** |
* internal storage for all gathered data |
* |
* @var array |
*/ |
private $_output = array(); |
/** |
* get all information from all configured ups and store output in internal array |
*/ |
public function __construct() |
{ |
parent::__construct(); |
$temp = ""; |
if (CommonFunctions::executeProgram('pmset', '-g batt', $temp) && !empty($temp)) { |
$this->_output[] = $temp; |
} |
} |
/** |
* parse the input and store data in resultset for xml generation |
* |
* @return void |
*/ |
private function _info() |
{ |
if (empty($this->_output)) { |
return; |
} |
$model = array(); |
$percCharge = array(); |
$lines = explode(PHP_EOL, implode($this->_output)); |
if (count($lines)>1) { |
$model = explode('FW:', $lines[1]); |
if (strpos($model[0], 'InternalBattery') === false) { |
$dev = new UPSDevice(); |
$percCharge = explode(';', $lines[1]); |
$dev->setName('UPS'); |
if ($model !== false) { |
$dev->setModel(substr(trim($model[0]), 1)); |
} |
if ($percCharge !== false) { |
$dev->setBatterCharge(trim(substr($percCharge[0], -4, 3))); |
$dev->setStatus(trim($percCharge[1])); |
if (isset($percCharge[2])) { |
$time = explode(':', $percCharge[2]); |
$hours = $time[0]; |
$minutes = $hours*60+substr($time[1], 0, 2); |
$dev->setTimeLeft($minutes); |
} |
} |
$dev->setMode("pmset"); |
$this->upsinfo->setUpsDevices($dev); |
} |
} |
} |
/** |
* get the information |
* |
* @see PSI_Interface_UPS::build() |
* |
* @return Void |
*/ |
public function build() |
{ |
$this->_info(); |
} |
} |
/web/acc/phpsysinfo/includes/ups/class.powersoftplus.inc.php |
---|
0,0 → 1,115 |
<?php |
/** |
* PowerSoftPlus class |
* |
* PHP version 5 |
* |
* @category PHP |
* @package PSI_UPS |
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net> |
* @copyright 2014 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.powersoftplus.inc.php 661 2014-06-13 11:26:39Z namiltd $ |
* @link http://phpsysinfo.sourceforge.net |
*/ |
/** |
* getting ups information from powersoftplus program |
* |
* @category PHP |
* @package PSI_UPS |
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net> |
* @copyright 2014 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 PowerSoftPlus extends UPS |
{ |
/** |
* internal storage for all gathered data |
* |
* @var array |
*/ |
private $_output = array(); |
/** |
* get all information from all configured ups in phpsysinfo.ini and store output in internal array |
*/ |
public function __construct() |
{ |
parent::__construct(); |
CommonFunctions::executeProgram('powersoftplus', '-p', $temp); |
if (! empty($temp)) { |
$this->_output[] = $temp; |
} |
} |
/** |
* parse the input and store data in resultset for xml generation |
* |
* @return Void |
*/ |
private function _info() |
{ |
foreach ($this->_output as $ups) { |
$dev = new UPSDevice(); |
// General info |
$dev->setName("EVER"); |
$dev->setMode("PowerSoftPlus"); |
$maxpwr = 0; |
$load = null; |
if (preg_match('/^Identifier: UPS Model\s*:\s*(.*)$/m', $ups, $data)) { |
$dev->setModel(trim($data[1])); |
if (preg_match('/\s(\d*)[^\d]*$/', trim($data[1]), $number)) { |
$maxpwr=$number[1]*0.65; |
} |
} |
if (preg_match('/^Current UPS state\s*:\s*(.*)$/m', $ups, $data)) { |
$dev->setStatus(trim($data[1])); |
} |
if (preg_match('/^Output load\s*:\s*(.*)\s\[\%\]$/m', $ups, $data)) { |
$load = trim($data[1]); |
} |
//wrong Output load issue |
if (($load == 0) && ($maxpwr != 0) && preg_match('/^Effective power\s*:\s*(.*)\s\[W\]$/m', $ups, $data)) { |
$load = 100.0*trim($data[1])/$maxpwr; |
} |
if ($load != null) { |
$dev->setLoad($load); |
} |
// Battery |
if (preg_match('/^Battery voltage\s*:\s*(.*)\s\[Volt\]$/m', $ups, $data)) { |
$dev->setBatteryVoltage(trim($data[1])); |
} |
if (preg_match('/^Battery state\s*:\s*(.*)$/m', $ups, $data)) { |
if (preg_match('/^At full capacity$/', trim($data[1]))) { |
$dev->setBatterCharge(100); |
} elseif (preg_match('/^(Discharged)|(Depleted)$/', trim($data[1]))) { |
$dev->setBatterCharge(0); |
} |
} |
// Line |
if (preg_match('/^Input voltage\s*:\s*(.*)\s\[Volt\]$/m', $ups, $data)) { |
$dev->setLineVoltage(trim($data[1])); |
} |
if (preg_match('/^Input frequency\s*:\s*(.*)\s\[Hz\]$/m', $ups, $data)) { |
$dev->setLineFrequency(trim($data[1])); |
} |
$this->upsinfo->setUpsDevices($dev); |
} |
} |
/** |
* get the information |
* |
* @see PSI_Interface_UPS::build() |
* |
* @return Void |
*/ |
public function build() |
{ |
$this->_info(); |
} |
} |
/web/acc/phpsysinfo/includes/ups/class.snmpups.inc.php |
---|
0,0 → 1,286 |
<?php |
/** |
* SNMPups class |
* |
* PHP version 5 |
* |
* @category PHP |
* @package PSI_UPS |
* @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.apcupsd.inc.php 661 2012-08-27 11:26:39Z namiltd $ |
* @link http://phpsysinfo.sourceforge.net |
*/ |
/** |
* getting ups information from SNMPups program |
* |
* @category PHP |
* @package PSI_UPS |
* @author Michael Cramer <BigMichi1@users.sourceforge.net> |
* @author Artem Volk <artvolk@mail.ru> |
* @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 SNMPups extends UPS |
{ |
/** |
* internal storage for all gathered data |
* |
* @var array |
*/ |
private $_output = array(); |
/** |
* get all information from all configured ups in phpsysinfo.ini and store output in internal array |
*/ |
public function __construct() |
{ |
parent::__construct(); |
switch (strtolower(PSI_UPS_SNMPUPS_ACCESS)) { |
case 'command': |
if (defined('PSI_UPS_SNMPUPS_LIST') && is_string(PSI_UPS_SNMPUPS_LIST)) { |
if (preg_match(ARRAY_EXP, PSI_UPS_SNMPUPS_LIST)) { |
$upss = eval(PSI_UPS_SNMPUPS_LIST); |
} else { |
$upss = array(PSI_UPS_SNMPUPS_LIST); |
} |
foreach ($upss as $ups) { |
CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$ups." .1.3.6.1.4.1.318.1.1.1.1", $buffer, PSI_DEBUG); |
if (strlen($buffer) > 0) { |
$this->_output[$ups] = $buffer; |
$buffer = ""; |
CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$ups." .1.3.6.1.4.1.318.1.1.1.2", $buffer, PSI_DEBUG); |
if (strlen($buffer) > 0) { |
$this->_output[$ups] .= "\n".$buffer; |
} |
$buffer = ""; |
CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$ups." .1.3.6.1.4.1.318.1.1.1.3", $buffer, PSI_DEBUG); |
if (strlen($buffer) > 0) { |
$this->_output[$ups] .= "\n".$buffer; |
} |
$buffer = ""; |
CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$ups." .1.3.6.1.4.1.318.1.1.1.4", $buffer, PSI_DEBUG); |
if (strlen($buffer) > 0) { |
$this->_output[$ups] .= "\n".$buffer; |
} |
} |
} |
} |
break; |
case 'php-snmp': |
if (!extension_loaded("snmp")) { |
$this->error->addError("Requirements error", "SNMPups plugin requires the snmp extension to php in order to work properly"); |
break; |
} |
snmp_set_valueretrieval(SNMP_VALUE_LIBRARY); |
snmp_set_oid_output_format(SNMP_OID_OUTPUT_NUMERIC); |
if (defined('PSI_UPS_SNMPUPS_LIST') && is_string(PSI_UPS_SNMPUPS_LIST)) { |
if (preg_match(ARRAY_EXP, PSI_UPS_SNMPUPS_LIST)) { |
$upss = eval(PSI_UPS_SNMPUPS_LIST); |
} else { |
$upss = array(PSI_UPS_SNMPUPS_LIST); |
} |
foreach ($upss as $ups) { |
if (! PSI_DEBUG) { |
restore_error_handler(); /* default error handler */ |
$old_err_rep = error_reporting(); |
error_reporting(E_ERROR); /* fatal errors only */ |
} |
$bufferarr=snmprealwalk($ups, "public", ".1.3.6.1.4.1.318.1.1.1.1", 1000000 * PSI_SNMP_TIMEOUT_INT, PSI_SNMP_RETRY_INT); |
if (! PSI_DEBUG) { |
error_reporting($old_err_rep); /* restore error level */ |
set_error_handler('errorHandlerPsi'); /* restore error handler */ |
} |
if (! empty($bufferarr)) { |
$buffer=""; |
foreach ($bufferarr as $id=>$string) { |
$buffer .= $id." = ".$string."\n"; |
} |
if (! PSI_DEBUG) { |
restore_error_handler(); /* default error handler */ |
$old_err_rep = error_reporting(); |
error_reporting(E_ERROR); /* fatal errors only */ |
} |
$bufferarr2=snmprealwalk($ups, "public", ".1.3.6.1.4.1.318.1.1.1.2", 1000000 * PSI_SNMP_TIMEOUT_INT, PSI_SNMP_RETRY_INT); |
$bufferarr3=snmprealwalk($ups, "public", ".1.3.6.1.4.1.318.1.1.1.3", 1000000 * PSI_SNMP_TIMEOUT_INT, PSI_SNMP_RETRY_INT); |
$bufferarr4=snmprealwalk($ups, "public", ".1.3.6.1.4.1.318.1.1.1.4", 1000000 * PSI_SNMP_TIMEOUT_INT, PSI_SNMP_RETRY_INT); |
if (! PSI_DEBUG) { |
error_reporting($old_err_rep); /* restore error level */ |
set_error_handler('errorHandlerPsi'); /* restore error handler */ |
} |
if (! empty($bufferarr2)) { |
foreach ($bufferarr2 as $id=>$string) { |
$buffer .= $id." = ".$string."\n"; |
} |
if (! empty($bufferarr3)) { |
foreach ($bufferarr3 as $id=>$string) { |
$buffer .= $id." = ".$string."\n"; |
} |
} } |
if (! empty($bufferarr4)) { |
foreach ($bufferarr4 as $id=>$string) { |
$buffer .= $id." = ".$string."\n"; |
} |
} |
if (strlen(trim($buffer)) > 0) { |
$this->_output[$ups] = $buffer; |
} |
} |
} |
} |
break; |
default: |
$this->error->addError("switch(PSI_UPS_SNMPUPS_ACCESS)", "Bad SNMPups configuration in phpsysinfo.ini"); |
break; |
} |
} |
/** |
* parse the input and store data in resultset for xml generation |
* |
* @return Void |
*/ |
private function _info() |
{ |
if (empty($this->_output)) { |
return; |
} |
foreach ($this->_output as $result) { |
$dev = new UPSDevice(); |
$status = ""; |
$status2 = ""; |
$status3 = ""; |
$dev->setMode("SNMP"); |
if (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.1\.1\.2\.0 = STRING:\s(.*)/m', $result, $data)) { |
$dev->setName(trim($data[1], "\" \r\t")); |
} |
if (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.1\.1\.1\.0 = STRING:\s(.*)/m', $result, $data)) { |
$dev->setModel(trim($data[1], "\" \r\t")); |
} |
if (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.4\.1\.1\.0 = INTEGER:\s(.*)/m', $result, $data)) { |
switch (trim($data[1])) { |
case 1: $status = "Unknown"; |
break; |
case 2: $status = "On Line"; |
break; |
case 3: $status = "On Battery"; |
break; |
case 4: $status = "On Smart Boost"; |
break; |
case 5: $status = "Timed Sleeping"; |
break; |
case 6: $status = "Software Bypass"; |
break; |
case 7: $status = "Off"; |
break; |
case 8: $status = "Rebooting"; |
break; |
case 9: $status = "Switched Bypass"; |
break; |
case 10:$status = "Hardware Failure Bypass"; |
break; |
case 11:$status = "Sleeping Until Power Returns"; |
break; |
case 12:$status = "On Smart Trim"; |
break; |
default: $status = "Unknown state (".trim($data[1]).")"; |
break; |
} |
} |
if (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.2\.1\.1\.0 = INTEGER:\s(.*)/m', $result, $data)) { |
$batstat = ""; |
switch (trim($data[1])) { |
case 1: $batstat = "Battery Unknown"; |
break; |
case 2: break; |
case 3: $batstat = "Battery Low"; |
break; |
default: $batstat = "Battery Unknown (".trim($data[1]).")"; |
break; |
} |
if ($batstat !== "") { |
if ($status !== "") { |
$status .= ", ".$batstat; |
} else { |
$status = $batstat; |
} |
} |
} |
if (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.2\.2\.4\.0 = INTEGER:\s(.*)/m', $result, $data)) { |
$batstat = ""; |
switch (trim($data[1])) { |
case 1: break; |
case 2: $batstat = "Replace Battery"; |
break; |
default: $batstat = "Replace Battery (".trim($data[1]).")"; |
break; |
} |
if ($batstat !== "") { |
if ($status !== "") { |
$status .= ", ".$batstat; |
} else { |
$status = $batstat; |
} |
} |
} |
if ($status !== "") { |
$dev->setStatus(trim($status)); |
} |
if (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.3\.3\.1\.0 = Gauge32:\s(.*)/m', $result, $data)) { |
$dev->setLineVoltage(trim($data[1])/10); |
} elseif (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.3\.2\.1\.0 = Gauge32:\s(.*)/m', $result, $data)) { |
$dev->setLineVoltage(trim($data[1])); |
} |
if (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.4\.3\.3\.0 = Gauge32:\s(.*)/m', $result, $data)) { |
$dev->setLoad(trim($data[1])/10); |
} elseif (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.4\.2\.3\.0 = Gauge32:\s(.*)/m', $result, $data)) { |
$dev->setLoad(trim($data[1])); |
} |
if (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.2\.3\.4\.0 = INTEGER:\s(.*)/m', $result, $data)) { |
$dev->setBatteryVoltage(trim($data[1])/10); |
} elseif (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.2\.2\.8\.0 = INTEGER:\s(.*)/m', $result, $data)) { |
$dev->setBatteryVoltage(trim($data[1])); |
} |
if (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.2\.3\.1\.0 = Gauge32:\s(.*)/m', $result, $data)) { |
$dev->setBatterCharge(trim($data[1])/10); |
} elseif (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.2\.2\.1\.0 = Gauge32:\s(.*)/m', $result, $data)) { |
$dev->setBatterCharge(trim($data[1])); |
} |
if (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.2\.2\.3\.0 = Timeticks:\s\((\d*)\)/m', $result, $data)) { |
$dev->setTimeLeft(trim($data[1])/6000); |
} |
if (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.2\.3\.2\.0 = Gauge32:\s(.*)/m', $result, $data)) { |
$dev->setTemperatur(trim($data[1])/10); |
} elseif (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.2\.2\.2\.0 = Gauge32:\s(.*)/m', $result, $data)) { |
$dev->setTemperatur(trim($data[1])); |
} |
if (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.2\.1\.3\.0 = STRING:\s(.*)/m', $result, $data)) { |
$dev->setBatteryDate(trim($data[1], "\" \r\t")); |
} |
if (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.3\.3\.4\.0 = Gauge32:\s(.*)/m', $result, $data)) { |
$dev->setLineFrequency(trim($data[1])/10); |
} elseif (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.3\.2\.4\.0 = Gauge32:\s(.*)/m', $result, $data)) { |
$dev->setLineFrequency(trim($data[1])); |
} |
$this->upsinfo->setUpsDevices($dev); |
} |
} |
/** |
* get the information |
* |
* @see PSI_Interface_UPS::build() |
* |
* @return Void |
*/ |
public function build() |
{ |
$this->_info(); |
} |
} |
/web/acc/phpsysinfo/includes/ups/class.ups.inc.php |
---|
0,0 → 1,64 |
<?php |
/** |
* Basic UPS Class |
* |
* PHP version 5 |
* |
* @category PHP |
* @package PSI_UPS |
* @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.ups.inc.php 661 2012-08-27 11:26:39Z namiltd $ |
* @link http://phpsysinfo.sourceforge.net |
*/ |
/** |
* Basic UPS functions for all UPS classes |
* |
* @category PHP |
* @package PSI_UPS |
* @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 UPS implements PSI_Interface_UPS |
{ |
/** |
* object for error handling |
* |
* @var PSI_Error |
*/ |
public $error; |
/** |
* main object for ups information |
* |
* @var UPSInfo |
*/ |
protected $upsinfo; |
/** |
* build the global Error object |
*/ |
public function __construct() |
{ |
$this->error = PSI_Error::singleton(); |
$this->upsinfo = new UPSInfo(); |
} |
/** |
* build and return the ups information |
* |
* @see PSI_Interface_UPS::getUPSInfo() |
* |
* @return UPSInfo |
*/ |
final public function getUPSInfo() |
{ |
$this->build(); |
return $this->upsinfo; |
} |
} |