Thread: [Phpsysinfo-subversion] SF.net SVN: phpsysinfo:[42] includes
Brought to you by:
namiltd
From: <Big...@us...> - 2008-12-08 11:09:09
|
Revision: 42 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=42&view=rev Author: BigMichi1 Date: 2008-12-08 11:09:07 +0000 (Mon, 08 Dec 2008) Log Message: ----------- import cvs Added Paths: ----------- includes/class.Error.inc.php includes/class.psi_plugin.inc.php includes/common_functions.php includes/interfaces/ includes/interfaces/class.psi_os_interface.inc.php includes/interfaces/class.psi_plugin_interface.inc.php includes/interfaces/class.psi_sensor_interface.inc.php includes/redir.php includes/ups/ includes/ups/class.apcupsd.inc.php includes/xml.class.php Added: includes/class.Error.inc.php =================================================================== --- includes/class.Error.inc.php (rev 0) +++ includes/class.Error.inc.php 2008-12-08 11:09:07 UTC (rev 42) @@ -0,0 +1,264 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +class Error { + /** + * holds the instance of this class + * + * @access private + * @static + * @var object + */ + private static $instance; + /** + * holds the error messages + * + * @access private + * @var array + */ + private $arrErrorList; + /** + * current number ob errors + * + * @access private + * @var integer + */ + private $errors; + /** + * initalize some used vars + * + * @access private + */ + private function __construct() { + $this->errors = 0; + $this->arrErrorList = array (); + } + /** + * Singleton function + * + * @access public + * @return object 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 + * + * @access public + */ + public function __clone() { + trigger_error("Can't be cloned", E_USER_ERROR); + } + /** + * adds an error to the internal list + * + * @access public + * @param string Command, which cause the Error + * @param string additional Message, to describe the Error + * + */ + public function addError($strCommand, $strMessage) { + $index = count($this->arrErrorList) + 1; + $this->arrErrorList[$index]['command'] = $strCommand; + $this->arrErrorList[$index]['message'] = $this->trace($strMessage); + $this->errors++; + } + /** + * adds a waraning to the internal list + * + * @access public + * @param string Warning message to display + * + */ + 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 in a html table + * + * @access public + * @return string contains a HTML table which can be used to echo out the errors + * + */ + public function ErrorsAsHTML() { + $strHTMLString = ""; + $strWARNString = ""; + $strHTMLhead = "<table width=\"100%\" border=\"0\">\n" . "\t<tr>\n" . "\t\t<td><font size=\"-1\"><b>Command</b></font></td>\n" . "\t\t<td><font size=\"-1\"><b>Message</b></font></td>\n" . "\t</tr>\n"; + $strHTMLfoot = "</table>\n"; + if ($this->errors > 0) { + foreach ($this->arrErrorList as $arrLine) { + if ($arrLine['command'] == "WARN") { + $strWARNString .= "<font size=\"-1\"><b>WARNING: " . str_replace("\n", "<br/>", htmlspecialchars($arrLine['message'])) . "</b></font><br/>\n"; + } else { + $strHTMLString .= "\t<tr>\n" . "\t\t<td><font size=\"-1\">" . htmlspecialchars($arrLine['command']) . "</font></td>\n" . "\t\t<td><font size=\"-1\">" . str_replace("\n", "<br/>", $arrLine['message']) . "</font></td>\n" . "\t</tr>\n"; + } + } + } + if (!empty ($strHTMLString)) { + $strHTMLString = $strWARNString . $strHTMLhead . $strHTMLString . $strHTMLfoot; + } else { + $strHTMLString = $strWARNString; + } + return $strHTMLString; + } + /** + * converts the internal error and warning list to a XML file + * + * @access public + * @return XML data containing the errors + * + */ + public function ErrorsAsXML() { + $xml = simplexml_load_string("<?xml version='1.0'?>\n<phpsysinfo></phpsysinfo>"); + $generation = $xml->addChild('Generation'); + $generation->addAttribute('version', PSI_VERSION); + $generation->addAttribute('timestamp', time()); + if ($this->errors > 0) { + foreach ($this->arrErrorList as $arrLine) { + $error = $xml->addChild('Error'); + $error->addChild('Function', $arrLine['command']); + $error->addChild('Message', $arrLine['message']); + } + } + return $xml->asXML(); + } + /** + * add the errors to an existing xml document + * + * @access public + * @param SimpleXMLObject reference existing simplexmlobject to which errors are added if present + * + */ + public function ErrorsAddToXML(& $xml) { + if ($this->errors > 0) { + $xmlerr = $xml->addChild('Errors'); + foreach ($this->arrErrorList as $arrLine) { + $error = $xmlerr->addChild('Error'); + $error->addChild('Function', utf8_encode(trim(htmlspecialchars($arrLine['command'])))); + $error->addChild('Message', utf8_encode(trim(htmlspecialchars($arrLine['message'])))); + } + } + } + /** + * check if errors exists + * + * @access public + * @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 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(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 $val) { + $strFunc .= $strComma . $this->print_var($val); + $strComma = ', '; + } + $strFunc .= ' '; + } + $strFunc .= ')'; + } + $strBacktrace .= "\n"; + } + return $strBacktrace; + } + /** + * convert some special vars into better readable output + * + * @param mixed value, which should be formatted + * @return string formatted string + */ + private function print_var($var) { + if (is_string($var)) { + return ('"' . str_replace(array ( + "\x00", + "\x0a", + "\x0d", + "\x1a", + "\x09" + ), array ( + '\0', + '\n', + '\r', + '\Z', + '\t' + ), $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->print_var($key) . ' => ' . $this->print_var($val); + $strComma = ', '; + } + $strResult .= ' )'; + return ($strResult); + } + // anything else, just let php try to print it + return (var_export($var, true)); + } +} +?> Property changes on: includes/class.Error.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/class.psi_plugin.inc.php =================================================================== --- includes/class.psi_plugin.inc.php (rev 0) +++ includes/class.psi_plugin.inc.php 2008-12-08 11:09:07 UTC (rev 42) @@ -0,0 +1,58 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +abstract class psi_plugin implements psi_plugin_interface { + private $plugin_name = ""; + private $plugin_base = ""; + protected $plugin_config = array (); + protected $global_error = ""; + + public function __construct($plugin_name = "") { + if (trim($plugin_name) != "") { + $this->global_error = Error :: Singleton(); + $this->plugin_name = $plugin_name; + $this->plugin_base = "./plugins/" . $this->plugin_name . "/"; + $this->checkfiles(); + $this->getconfig(); + } else { + $this->global_error->addError("__construct()", "Parent constructor called without Plugin-Name!"); + } + } + + private function getconfig() { + $filename = $this->plugin_base . $this->plugin_name . ".ini"; + if (file_exists($filename)) { + $this->plugin_config = parse_ini_file($filename, true); + } + } + + private function checkfiles() { + if (!file_exists($this->plugin_base . "js/" . $this->plugin_name . ".js")) { + $this->global_error->addError("file_exists(" . $this->plugin_base . "js/" . $this->plugin_name . ".js)", "JS-File for Plugin '" . $this->plugin_name . "' is missing!"); + } + 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!"); + } + } +} +?> Property changes on: includes/class.psi_plugin.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/common_functions.php =================================================================== --- includes/common_functions.php (rev 0) +++ includes/common_functions.php 2008-12-08 11:09:07 UTC (rev 42) @@ -0,0 +1,254 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +// Version number +define('PSI_VERSION', '3.0-rc6'); + +// usefull during development +// error_reporting(E_ALL|E_NOTICE|E_STRICT); +// Find a system program. Do path checking +function find_program($strProgram) { + global $addpaths; + $arrPath = array ( + '/bin', + '/sbin', + '/usr/bin', + '/usr/sbin', + '/usr/local/bin', + '/usr/local/sbin' + ); + if (PSI_ADD_PATHS !== false) { + $addpaths = explode(',', PSI_ADD_PATHS); + $arrPath = array_merge($arrPath, $addpaths); + } + if (function_exists("is_executable")) { + foreach ($arrPath as $strPath) { + $strProgrammpath = $strPath . "/" . $strProgram; + if (is_executable($strProgrammpath)) { + return $strProgrammpath; + } + } + } else { + return strpos($strProgram, '.exe'); + } +} + +// Execute a system program. return a trim()'d result. +// does very crude pipe checking. you need ' | ' for it to work +// ie $program = execute_program('netstat', '-anp | grep LIST'); +// NOT $program = execute_program('netstat', '-anp|grep LIST'); +function execute_program($strProgramname, $strArgs = '', & $strBuffer, $booErrorRep = true) { + $error = Error :: singleton(); + $strBuffer = ''; + $strError = ''; + $pipes = array(); + $strProgram = find_program($strProgramname); + if (!$strProgram) { + if ($booErrorRep) { + $error->addError('find_program(' . $strProgramname . ')', 'program not found on the machine'); + } + return false; + } + // see if we've gotten a |, if we have we need to do patch checking on the cmd + if ($strArgs) { + $arrArgs = split(' ', $strArgs); + for ($i = 0; $i < count($arrArgs); $i++) { + if ($arrArgs[$i] == '|') { + $strCmd = $arrArgs[$i +1]; + $strNewcmd = find_program($strCmd); + $strArgs = ereg_replace("\| " . $strCmd, "| " . $strNewcmd, $strArgs); + } + } + } + // no proc_open() below php 4.3 + $descriptorspec = array ( + 0 => array ( + "pipe", + "r" + ), // stdin is a pipe that the child will read from + 1 => array ( + "pipe", + "w" + ), // stdout is a pipe that the child will write to + 2 => array ( + "pipe", + "w" + ) // stderr is a pipe that the child will write to + + ); + $process = proc_open($strProgram . " " . $strArgs, $descriptorspec, $pipes); + if (is_resource($process)) { + while (!feof($pipes[1])) { + $strBuffer .= fgets($pipes[1], 1024); + } + fclose($pipes[1]); + while (!feof($pipes[2])) { + $strError .= fgets($pipes[2], 1024); + } + fclose($pipes[2]); + } + $return_value = proc_close($process); + $strError = trim($strError); + $strBuffer = trim($strBuffer); + if (!empty ($strError) && $return_value <> 0) { + if ($booErrorRep) { + $error->addError($strProgram, $strError . "\nReturn value: " . $return_value); + } + return false; + } + if (!empty ($strError)) { + if ($booErrorRep) { + $error->addError($strProgram, $strError . "\nReturn value: " . $return_value); + } + return true; + } + return true; +} + +// find duplicate entrys and count them, show this value befor the duplicated name +function finddups($arrInput) { + $arrResult = array (); + if (is_array($arrInput)) { + $arrBuffer = array_count_values($arrInput); + foreach ($arrBuffer as $strKey => $intValue) { + if ($intValue > 1) { + $arrResult[] = "(" . $intValue . "x) " . $strKey; + } else { + $arrResult[] = $strKey; + } + } + } + return $arrResult; +} + +function rfts($strFileName, & $strRet, $intLines = 0, $intBytes = 4096, $booErrorRep = true) { + $error = Error :: singleton(); + $strFile = ""; + $intCurLine = 1; + if (file_exists($strFileName)) { + if ($fd = fopen($strFileName, 'r')) { + while (!feof($fd)) { + $strFile .= fgets($fd, $intBytes); + if ($intLines <= $intCurLine && $intLines != 0) { + break; + } else { + $intCurLine++; + } + } + fclose($fd); + $strRet = $strFile; + } else { + if ($booErrorRep) { + $error->addError('fopen(' . $strFileName . ')', 'file can not read by phpsysinfo'); + } + return false; + } + } else { + if ($booErrorRep) { + $error->addError('file_exists(' . $strFileName . ')', 'the file does not exist on your machine'); + } + return false; + } + return true; +} + +function gdc($strPath, $booErrorRep = true) { + $error = Error :: singleton(); + $arrDirectoryContent = array (); + if (is_dir($strPath)) { + if ($handle = opendir($strPath)) { + while (($strFile = readdir($handle)) !== false) { + if ($strFile != "." && $strFile != ".." && $strFile != "CVS") { + $arrDirectoryContent[] = $strFile; + } + } + closedir($handle); + } else { + if ($booErrorRep) { + $error->addError('opendir(' . $strPath . ')', 'directory can not be read by phpsysinfo'); + } + } + } else { + if ($booErrorRep) { + $error->addError('is_dir(' . $strPath . ')', 'directory does not exist on your machine'); + } + } + return $arrDirectoryContent; +} + +function __autoload($class_name) { + $dirs = array ( + '/plugins/' . $class_name . '/', + '/includes/', + '/includes/interfaces/', + '/includes/os/' + ); + foreach ($dirs as $dir) { + if (file_exists(APP_ROOT . $dir . 'class.' . $class_name . '.inc.php')) { + require_once (APP_ROOT . $dir . 'class.' . $class_name . '.inc.php'); + return; + } + } +} + +/** + * Check for the SimpleXML fuction. + * + * We need that extension for almost everything, + * even our error class needs this to output the errors. + * Because of that this function willreturn a hard coded + * XML string (with headers) if the SimpleXML extension isn't loaded. + * Then it will terminate the script. + * See bug #1787137 + * + * @access public + * + */ +function checkForExtensions() { + $extensions = array ( + 'simplexml', + 'pcre', + 'xml', + 'xsl' + ); + $text = ""; + $error = false; + $text .= "<?xml version='1.0'?>\n"; + $text .= "<phpsysinfo>\n"; + $text .= " <Error>\n"; + foreach ($extensions as $extension) { + if (!extension_loaded($extension)) { + $text .= " <Function>checkForExtensions</Function>\n"; + $text .= " <Message>phpSysInfo requires the " . $extension . " extension to php in order to work properly.</Message>\n"; + $error = true; + } + } + $text .= " </Error>\n"; + $text .= "</phpsysinfo>"; + if ($error) { + header("Content-Type: text/xml\n\n"); + echo $text; + die(); + } +} +?> Property changes on: includes/common_functions.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/interfaces/class.psi_os_interface.inc.php =================================================================== --- includes/interfaces/class.psi_os_interface.inc.php (rev 0) +++ includes/interfaces/class.psi_os_interface.inc.php 2008-12-08 11:09:07 UTC (rev 42) @@ -0,0 +1,44 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +interface psi_os_interface { + public function vhostname(); + public function vip_addr(); + public function chostname(); + public function ip_addr(); + public function kernel(); + public function uptime(); + public function users(); + public function loadavg($bar = false); + public function cpu_info(); + public function pci(); + public function ide(); + public function scsi(); + public function usb(); + public function network(); + public function memory(); + public function filesystems(); + public function distro(); + public function distroicon(); +} +?> Property changes on: includes/interfaces/class.psi_os_interface.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/interfaces/class.psi_plugin_interface.inc.php =================================================================== --- includes/interfaces/class.psi_plugin_interface.inc.php (rev 0) +++ includes/interfaces/class.psi_plugin_interface.inc.php 2008-12-08 11:09:07 UTC (rev 42) @@ -0,0 +1,28 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +interface psi_plugin_interface { + public function execute(); + public function xml(); +} +?> Property changes on: includes/interfaces/class.psi_plugin_interface.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/interfaces/class.psi_sensor_interface.inc.php =================================================================== --- includes/interfaces/class.psi_sensor_interface.inc.php (rev 0) +++ includes/interfaces/class.psi_sensor_interface.inc.php 2008-12-08 11:09:07 UTC (rev 42) @@ -0,0 +1,29 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +interface psi_sensor_interface { + public function temperature(); + public function voltage(); + public function fans(); +} +?> Property changes on: includes/interfaces/class.psi_sensor_interface.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/redir.php =================================================================== --- includes/redir.php (rev 0) +++ includes/redir.php 2008-12-08 11:09:07 UTC (rev 42) @@ -0,0 +1,84 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +$display = isset ($_GET['disp']) ? $_GET['disp'] : ""; +switch ($display) { + case "static" : + define('PSI_INTERNAL_XML', false); + require_once ("./xml.php"); + $xmlfile = $xml->getXML(); + $xslfile = "phpsysinfo.xslt"; + $xml = new DOMDocument(); + $xml->loadXML($xmlfile); + $xsl = new DOMDocument(); + $xsl->load($xslfile); + $proc = new XSLTProcessor; + $proc->importStyleSheet($xsl); + echo $proc->transformToXML($xml); + die(); + break; + case "dynamic" : + break; + default : + echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; + echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"; + echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"; + echo " <head>\n"; + echo " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n"; + echo " <meta http-equiv=\"Content-Script-Type\" content=\"text/javascript\" />\n"; + echo " <meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />\n"; + echo " <link type=\"text/css\" rel=\"stylesheet\" href=\"./templates/two.css\" />\n"; + echo " <title>Redirection</title>\n"; + echo " <noscript>\n"; + echo " <meta http-equiv=\"refresh\" content=\"2; URL=index.php?disp=static\" />\n"; + echo " </noscript>\n"; + echo " <script type=\"text/JavaScript\" language=\"JavaScript\">\n"; + echo " <!--\n"; + echo " var sTargetURL = \"index.php?disp=dynamic\";\n"; + echo " function doRedirect() {\n"; + echo " setTimeout( \"window.location.href = sTargetURL\", 2*1000 );\n"; + echo " }\n"; + echo " //-->\n"; + echo " </script>\n"; + echo " <script type=\"text/JavaScript\" language=\"JavaScript1.1\">\n"; + echo " <!--\n"; + echo " function doRedirect() {\n"; + echo " window.location.replace( sTargetURL );\n"; + echo " }\n"; + echo " doRedirect();\n"; + echo " //-->\n"; + echo " </script>\n"; + echo " </head>\n"; + echo " <body onload=\"doRedirect()\">\n"; + echo " <h1>REDIRECTING ... </h1>\n"; + echo " <div style=\"position:absolute;top:150px;text-align:center;width:95%;\">\n"; + echo " <p style=\"margin:12pt;\">Loading <a href=\"index.php?disp=static\">redirection target</a></p>\n"; + echo " <p style=\"margin:12pt;\">In approx. 2 seconds the redirection target page should load.<br/>\n"; + echo " If it doesn't please select the link above.</p>\n"; + echo " <p style=\"margin:12pt;\">Generated by <a href=\"http://phpsysinfo.sourceforge.net/\">phpSysInfo - " . PSI_VERSION . "</a></p>\n"; + echo " </div>\n"; + echo " </body>\n"; + echo "</html>\n"; + die(); +} +?> Property changes on: includes/redir.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/ups/class.apcupsd.inc.php =================================================================== --- includes/ups/class.apcupsd.inc.php (rev 0) +++ includes/ups/class.apcupsd.inc.php 2008-12-08 11:09:07 UTC (rev 42) @@ -0,0 +1,120 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +// This class was created by Artem Volk ( artvolk at mail dot ru ) +class upsinfo { + private $output = array(); + public function __construct() { + $upses = explode(',', PSI_UPSINFO_APCUPSD_UPS_LIST); + $temp = ''; + for ($i = 0; $i < count($upses); $i++) { + execute_program('apcaccess', 'status ' . trim($upses[$i]), $temp); + if (isset ($temp) && !empty ($temp)) { + $this->output[$i] = $temp; + } + } + } + public function info() { + if (isset ($this->output) && count($this->output) > 0) { + $results = Array (); + for ($i = 0; $i < count($this->output); $i++) { + // General info + if (preg_match('/^UPSNAME\s*:\s*(.*)$/m', $this->output[$i], $data)) { + $results[$i]['name'] = trim($data[1]); + } else { + $results[$i]['name'] = ''; + } + if (preg_match('/^MODEL\s*:\s*(.*)$/m', $this->output[$i], $data)) { + $results[$i]['model'] = trim($data[1]); + } else { + $results[$i]['model'] = ''; + } + if (preg_match('/^UPSMODE\s*:\s*(.*)$/m', $this->output[$i], $data)) { + $results[$i]['mode'] = trim($data[1]); + } else { + $results[$i]['mode'] = ''; + } + if (preg_match('/^STARTTIME\s*:\s*(.*)$/m', $this->output[$i], $data)) { + $results[$i]['start_time'] = trim($data[1]); + } else { + $results[$i]['start_time'] = ''; + } + if (preg_match('/^STATUS\s*:\s*(.*)$/m', $this->output[$i], $data)) { + $results[$i]['status'] = trim($data[1]); + } else { + $results[$i]['status'] = ''; + } + if (preg_match('/^ITEMP\s*:\s*(.*)$/m', $this->output[$i], $data)) { + $results[$i]['temperature'] = trim($data[1]); + } else { + $results[$i]['temperature'] = ''; + } + // Outages + if (preg_match('/^NUMXFERS\s*:\s*(.*)$/m', $this->output[$i], $data)) { + $results[$i]['outages_count'] = trim($data[1]); + } else { + $results[$i]['outages_count'] = ''; + } + if (preg_match('/^LASTXFER\s*:\s*(.*)$/m', $this->output[$i], $data)) { + $results[$i]['last_outage'] = trim($data[1]); + } else { + $results[$i]['last_outage'] = ''; + } + if (preg_match('/^XOFFBATT\s*:\s*(.*)$/m', $this->output[$i], $data)) { + $results[$i]['last_outage_finish'] = trim($data[1]); + } else { + $results[$i]['last_outage_finish'] = ''; + } + // Line + if (preg_match('/^LINEV\s*:\s*(\d*\.\d*)(.*)$/m', $this->output[$i], $data)) { + $results[$i]['line_voltage'] = trim($data[1]); + } else { + $results[$i]['line_voltage'] = ''; + } + if (preg_match('/^LOADPCT\s*:\s*(\d*\.\d*)(.*)$/m', $this->output[$i], $data)) { + $results[$i]['load_percent'] = trim($data[1]); + } else { + $results[$i]['load_percent'] = ''; + } + // Battery + if (preg_match('/^BATTV\s*:\s*(\d*\.\d*)(.*)$/m', $this->output[$i], $data)) { + $results[$i]['battery_voltage'] = trim($data[1]); + } else { + $results[$i]['battery_voltage'] = ''; + } + if (preg_match('/^BCHARGE\s*:\s*(\d*\.\d*)(.*)$/m', $this->output[$i], $data)) { + $results[$i]['battery_charge_percent'] = trim($data[1]); + } else { + $results[$i]['battery_charge_percent'] = ''; + } + if (preg_match('/^TIMELEFT\s*:\s*(\d*\.\d*)(.*)$/m', $this->output[$i], $data)) { + $results[$i]['time_left_minutes'] = trim($data[1]); + } else { + $results[$i]['time_left_minutes'] = ''; + } + } + return $results; + } + } +} +?> Property changes on: includes/ups/class.apcupsd.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/xml.class.php =================================================================== --- includes/xml.class.php (rev 0) +++ includes/xml.class.php 2008-12-08 11:09:07 UTC (rev 42) @@ -0,0 +1,362 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +***************************************************************************/ +// +// $Id$ +// +class xml { + private $sysinfo; + private $mbinfo; + private $hddtemp; + private $upsinfo; + private $xml; + private $errors; + private $plugins; + private $plugin_request = false; + private $complete_request = false; + public function __construct($pluginname = "", $complete = false) { + ($pluginname == "") ? $this->plugin_request = false : $this->plugin_request = true; + ($complete) ? $this->complete_request = true : $this->complete_request = false; + $this->errors = Error :: singleton(); + if (!$this->plugin_request || $this->complete_request) { + $this->sysinfo = new sysinfo(); + if (PSI_MBINFO) { + $this->mbinfo = new mbinfo; + } + if (PSI_HDDTEMP) { + $this->hddtemp = new hddtemp; + } + if (PSI_UPSINFO) { + $this->upsinfo = new upsinfo; + } + } + $this->xml = simplexml_load_string("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phpsysinfo xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"phpsysinfo.xsd\"></phpsysinfo>"); + $generation = $this->xml->addChild('Generation'); + $generation->addAttribute('version', PSI_VERSION); + $generation->addAttribute('timestamp', time()); + $options = $this->xml->addChild('Options'); + $options->addChild('tempFormat', PSI_TEMP_FORMAT); + $options->addChild('byteFormat', PSI_BYTE_FORMAT); + $options->addChild('refresh', PSI_REFRESH ? PSI_REFRESH : 'false'); + $plug = $options->addChild('Used_Plugins'); + if ((!$this->plugin_request || $this->complete_request) && PSI_PLUGINS !== false) { + $this->plugins = explode(",", PSI_PLUGINS); + foreach ($this->plugins as $plugin) { + $plug->addChild('Plugin', $plugin); + } + } else { + $this->plugins = array ( + $pluginname + ); + } + } + private function buildVitals() { + $strLoadavg = ''; + $arrBuf = $this->sysinfo->loadavg(PSI_LOAD_BAR); + foreach ($arrBuf['avg'] as $strValue) { + $strLoadavg .= $strValue . ' '; + } + $vitals = $this->xml->addChild('Vitals'); + if (PSI_USE_VHOST === true) { + $vitals->addChild('Hostname', utf8_encode(trim(htmlspecialchars($this->sysinfo->vhostname())))); + $vitals->addChild('IPAddr', $this->sysinfo->vip_addr()); + } else { + $vitals->addChild('Hostname', utf8_encode(trim(htmlspecialchars($this->sysinfo->chostname())))); + $vitals->addChild('IPAddr', $this->sysinfo->ip_addr()); + } + $vitals->addChild('Kernel', utf8_encode(trim(htmlspecialchars($this->sysinfo->kernel())))); + $vitals->addChild('Distro', utf8_encode(trim(htmlspecialchars($this->sysinfo->distro())))); + $vitals->addChild('Distroicon', utf8_encode(trim(htmlspecialchars($this->sysinfo->distroicon())))); + $vitals->addChild('Uptime', $this->sysinfo->uptime()); + $vitals->addChild('Users', $this->sysinfo->users()); + $vitals->addChild('LoadAvg', $strLoadavg); + if (isset ($arrBuf['cpupercent'])) { + $vitals->addChild('CPULoad', round($arrBuf['cpupercent'], 2)); + } + } + private function buildNetwork() { + $arrNet = $this->sysinfo->network(); + $network = $this->xml->addChild('Network'); + $hideDevices = explode(',', PSI_HIDE_NETWORK_INTERFACE); + foreach ($arrNet as $strDev => $arrStats) { + if (!in_array($strDev, $hideDevices)) { + $device = $network->addChild('NetDevice'); + $device->addChild('Name', utf8_encode(trim(htmlspecialchars($strDev)))); + $device->addChild('RxBytes', $arrStats['rx_bytes']); + $device->addChild('TxBytes', $arrStats['tx_bytes']); + $device->addChild('Err', $arrStats['errs']); + $device->addChild('Drops', $arrStats['drop']); + } + } + } + private function buildHardware() { + $hardware = $this->xml->addChild('Hardware'); + $cpu = $hardware->addChild('CPU'); + $pci = $hardware->addChild('PCI'); + $ide = $hardware->addChild('IDE'); + $scsi = $hardware->addChild('SCSI'); + $usb = $hardware->addChild('USB'); + $arrSys = $this->sysinfo->cpu_info(); + $arrBuf = finddups($this->sysinfo->pci()); + if (count($arrBuf)) { + for ($i = 0, $max = sizeof($arrBuf); $i < $max; $i++) { + if ($arrBuf[$i]) { + $tmp = $pci->addChild('Device'); + $tmp->addChild('Name', utf8_encode(trim(htmlspecialchars($arrBuf[$i])))); + } + } + } + $arrBuf = $this->sysinfo->ide(); + if (count($arrBuf)) { + foreach ($arrBuf as $strKey => $arrValue) { + $tmp = $ide->addChild('Device'); + $tmp->addChild('Name', $strKey . ': ' . utf8_encode(trim(htmlspecialchars($arrValue['model'])))); + if (isset ($arrValue['capacity'])) { + $tmp->addChild('Capacity', $arrValue['capacity']); + } + } + } + $arrBuf = $this->sysinfo->scsi(); + if (count($arrBuf)) { + foreach ($arrBuf as $strKey => $arrValue) { + $tmp = $scsi->addChild('Device'); + if ($strKey >= '0' && $strKey <= '9') { + $tmp->addChild('Name', utf8_encode(trim(htmlspecialchars($arrValue['model'])))); + } else { + $tmp->addChild('Name', $strKey . ': ' . utf8_encode(trim(htmlspecialchars($arrValue['model'])))); + } + if (isset ($arrrValue['capacity'])) { + $tmp->addChild('Capacity', $arrValue['capacity']); + } + } + } + $arrBuf = finddups($this->sysinfo->usb()); + if (count($arrBuf)) { + for ($i = 0, $max = sizeof($arrBuf); $i < $max; $i++) { + if (trim($arrBuf[$i]) != "") { + $tmp = $usb->addChild('Device'); + $tmp->addChild('Name', utf8_encode(trim(htmlspecialchars($arrBuf[$i])))); + } + } + } + $cpu->addChild('Number', $arrSys['cpus']); + $cpu->addChild('Model', utf8_encode(trim(htmlspecialchars($arrSys['model'])))); + if (isset ($arrSys['temp'])) { + $cpu->addChild('Cputemp', $arrSys['temp']); + } + $cpu->addChild('Cpuspeed', $arrSys['cpuspeed']); + if (isset ($arrSys['busspeed'])) { + $cpu->addChild('Busspeed', $arrSys['busspeed']); + } + if (isset ($arrSys['cache'])) { + $cpu->addChild('Cache', $arrSys['cache']); + } + if (isset ($arrSys['bogomips'])) { + $cpu->addChild('Bogomips', $arrSys['bogomips']); + } + } + private function buildMemory() { + $arrMem = $this->sysinfo->memory(); + $i = 0; + $memory = $this->xml->addChild('Memory'); + $memory->addChild('Free', $arrMem['ram']['free']); + $memory->addChild('Used', $arrMem['ram']['used']); + $memory->addChild('Total', $arrMem['ram']['total']); + $memory->addChild('Percent', $arrMem['ram']['percent']); + if (isset ($arrMem['ram']['app'])) { + $memory->addChild('App', $arrMem['ram']['app']); + $memory->addChild('AppPercent', $arrMem['ram']['app_percent']); + $memory->addChild('Buffers', $arrMem['ram']['buffers']); + $memory->addChild('BuffersPercent', $arrMem['ram']['buffers_percent']); + $memory->addChild('Cached', $arrMem['ram']['cached']); + $memory->addChild('CachedPercent', $arrMem['ram']['cached_percent']); + } + $swap = $this->xml->addChild('Swap'); + if (count($arrMem['devswap']) > 0) { + $swap->addChild('Free', $arrMem['swap']['free']); + $swap->addChild('Used', $arrMem['swap']['used']); + $swap->addChild('Total', $arrMem['swap']['total']); + $swap->addChild('Percent', $arrMem['swap']['percent']); + } + $swapDev = $this->xml->addChild('Swapdevices'); + foreach ($arrMem['devswap'] as $arrDevice) { + $swapMount = $swapDev->addChild('Mount'); + $swapMount->addChild('MountPointID', $i++); + $swapMount->addChild('Type', 'Swap'); + $dev = $swapMount->addChild('Device'); + $dev->addChild('Name', utf8_encode(trim(htmlspecialchars($arrDevice['dev'])))); + $swapMount->addChild('Percent', $arrDevice['percent']); + $swapMount->addChild('Free', $arrDevice['free']); + $swapMount->addChild('Used', $arrDevice['used']); + $swapMount->addChild('Size', $arrDevice['total']); + } + } + private function buildFilesystems() { + $hideMounts = array (); + $hideFstypes = array (); + $hideDisks = array (); + if (PSI_HIDE_MOUNTS != "") { + $hideMounts = explode(',', PSI_HIDE_MOUNTS); + } + if (PSI_HIDE_FS_TYPES != "") { + $hideFstypes = explode(',', PSI_HIDE_FS_TYPES); + } + if (PSI_HIDE_DISKS != "") { + $hideDisks = explode(',', PSI_HIDE_DISKS); + } + $arrFs = $this->sysinfo->filesystems(); + $fs = $this->xml->addChild('FileSystem'); + for ($i = 0, $max = sizeof($arrFs); $i < $max; $i++) { + if (!in_array($arrFs[$i]['mount'], $hideMounts, true) && !in_array($arrFs[$i]['fstype'], $hideFstypes, true) && !in_array($arrFs[$i]['disk'], $hideDisks, true)) { + $mount = $fs->addChild('Mount'); + $mount->addchild('MountPointID', $i); + if (PSI_SHOW_MOUNT_POINT === true) { + $mount->addchild('MountPoint', utf8_encode(trim(htmlspecialchars($arrFs[$i]['mount'])))); + } + $mount->addchild('Type', $arrFs[$i]['fstype']); + $dev = $mount->addchild('Device'); + $dev->addChild('Name', utf8_encode(trim(htmlspecialchars($arrFs[$i]['disk'])))); + $mount->addchild('Percent', $arrFs[$i]['percent']); + $mount->addchild('Free', $arrFs[$i]['free']); + $mount->addchild('Used', $arrFs[$i]['used']); + $mount->addchild('Size', $arrFs[$i]['size']); + if (isset ($arrFs[$i]['options'])) { + $mount->addchild('MountOptions', $arrFs[$i]['options']); + } + if (isset ($arrFs[$i]['inodes'])) { + $mount->addchild('Inodes', $arrFs[$i]['inodes']); + } + } + } + } + private function buildMbinfo() { + $mbinfo = $this->xml->addChild('MBinfo'); + $arrBuff = $this->mbinfo->temperature(); + if (sizeof($arrBuff) > 0) { + $temp = $mbinfo->addChild('Temperature'); + foreach ($arrBuff as $arrValue) { + $item = $temp->addChild('Item'); + $item->addChild('Label', utf8_encode(trim(htmlspecialchars($arrValue['label'])))); + $item->addChild('Value', $arrValue['value']); + $item->addChild('Limit', $arrValue['limit']); + } + } + $arrBuff = $this->mbinfo->fans(); + if (sizeof($arrBuff) > 0) { + $fan = $mbinfo->addChild('Fans'); + foreach ($arrBuff as $arrValue) { + $item = $fan->addChild('Item'); + $item->addChild('Label', utf8_encode(trim(htmlspecialchars($arrValue['label'])))); + $item->addChild('Value', $arrValue['value']); + $item->addChild('Min', $arrValue['min']); + } + } + $arrBuff = $this->mbinfo->voltage(); + if (sizeof($arrBuff) > 0) { + $volt = $mbinfo->addChild('Voltage'); + foreach ($arrBuff as $arrValue) { + $item = $volt->addChild('Item'); + $item->addChild('Label', utf8_encode(trim(htmlspecialchars($arrValue['label'])))); + $item->addChild('Value', $arrValue['value']); + $item->addChild('Min', $arrValue['min']); + $item->addChild('Max', $arrValue['max']); + } + } + } + private function buildHddtemp() { + $arrBuf = $this->hddtemp->temperature(); + $hddtemp = $this->xml->addChild('HDDTemp'); + for ($i = 0, $max = sizeof($arrBuf); $i < $max; $i++) { + $item = $hddtemp->addChild('Item'); + $item->addChild('Label', utf8_encode(trim(htmlspecialchars($arrBuf[$i]['label'])))); + $item->addChild('Value', $arrBuf[$i]['value']); + $item->addChild('Model', utf8_encode(trim(htmlspecialchars($arrBuf[$i]['model'])))); + } + } + private function buildUpsinfo() { + $arrBuf = $this->upsinfo->info(); + if (isset ($arrBuf) && !empty ($arrBuf)) { + $upsinfo = $this->xml->addChild('UPSinfo'); + for ($i = 0, $max = sizeof($arrBuf); $i < $max; $i++) { + $item = $upsinfo->addChild('Ups'); + $item->addChild('Name', utf8_encode(trim(htmlspecialchars($arrBuf[$i]['name'])))); + $item->addChild('Model', utf8_encode(trim(htmlspecialchars($arrBuf[$i]['model'])))); + $item->addChild('Mode', utf8_encode(trim(htmlspecialchars($arrBuf[$i]['mode'])))); + $item->addChild('StartTime', utf8_encode(trim(htmlspecialchars($arrBuf[$i]['start_time'])))); + $item->addChild('Status', utf8_encode(trim(htmlspecialchars($arrBuf[$i]['status'])))); + $item->addChild('UPSTemperature', utf8_encode(trim(htmlspecialchars($arrBuf[$i]['temperature'])))); + $item->addChild('OutagesCount', $arrBuf[$i]['outages_count']); + $item->addChild('LastOutage', utf8_encode(trim(htmlspecialchars($arrBuf[$i]['last_outage'])))); + $item->addChild('LastOutageFinish', utf8_encode(trim(htmlspecialchars($arrBuf[$i]['last_outage_finish'])))); + $item->addChild('LineVoltage', $arrBuf[$i]['line_voltage']); + $item->addChild('LoadPercent', $arrBuf[$i]['load_percent']); + $item->addChild('BatteryVoltage', $arrBuf[$i]['battery_voltage']); + $item->addChild('BatteryChargePercent', $arrBuf[$i]['battery_charge_percent']); + $item->addChild('TimeLeftMinutes', $arrBuf[$i]['time_left_minutes']); + } + } + } + public function buildXml() { + if (!$this->plugin_request || $this->complete_request) { + $this->buildVitals(); + $this->buildNetwork(); + $this->buildHardware(); + $this->buildMemory(); + $this->buildFilesystems(); + if (PSI_MBINFO) { + $this->buildMbinfo(); + } + if (PSI_HDDTEMP) { + $this->buildHddtemp(); + } + if (PSI_UPSINFO) { + $this->buildUpsinfo(); + } + } + $this->buildPlugins(); + $this->errors->ErrorsAddToXML($this->xml); + } + public function printXml() { + header("Content-Type: text/xml\n\n"); + echo $this->xml->asXML(); + } + public function getXml() { + return $this->xml->asXML(); + } + private function buildPlugins() { + $pluginroot = $this->xml->addChild("Plugins"); + if ($this->plugin_request || $this->complete_request) { + if (defined('PSI_PLUGINS')) { + foreach ($this->plugins as $plugin) { + $object = new $plugin (); + $object->execute(); + $this->combinexml($pluginroot, $object->xml()); + } + } + } + } + private function combinexml(SimpleXMLElement $parent, SimpleXMLElement $new_child) { + $node1 = dom_import_simplexml($parent); + $dom_sxe = dom_import_simplexml($new_child); + $node2 = $node1->ownerDocument->importNode($dom_sxe, true); + $node1->appendChild($node2); + } +} +?> Property changes on: includes/xml.class.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Big...@us...> - 2008-12-08 12:07:21
|
Revision: 43 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=43&view=rev Author: BigMichi1 Date: 2008-12-08 11:47:13 +0000 (Mon, 08 Dec 2008) Log Message: ----------- import cvs Added Paths: ----------- includes/mb/ includes/mb/class.coretemp.inc.php includes/mb/class.hddtemp.inc.php includes/mb/class.healthd.inc.php includes/mb/class.hwsensors.inc.php includes/mb/class.ipmi.inc.php includes/mb/class.lmsensors.inc.php includes/mb/class.mbm5.inc.php includes/mb/class.mbmon.inc.php Added: includes/mb/class.coretemp.inc.php =================================================================== --- includes/mb/class.coretemp.inc.php (rev 0) +++ includes/mb/class.coretemp.inc.php 2008-12-08 11:47:13 UTC (rev 43) @@ -0,0 +1,48 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +// This class was created by William Johansson ( radar at radhuset dot org ) +class mbinfo { + function temperature() { + $results = array (); + $smp = 1; + execute_program('sysctl', '-n kern.smp.cpus', $smp); + for ($i = 0; $i < $smp; $i++) { + $temp = 0; + if (execute_program('sysctl', '-n dev.cpu.' . $i . '.temperature', $temp)) { + $results[$i]['label'] = "CPU " . ($i +1); + $results[$i]['value'] = $temp; + $results[$i]['limit'] = '70.0'; + $results[$i]['percent'] = $results[$i]['value'] * 100 / $results[$i]['limit']; + } + } + return $results; + } + function fans() { + return null; + } + function voltage() { + return null; + } +} +?> Property changes on: includes/mb/class.coretemp.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/mb/class.hddtemp.inc.php =================================================================== --- includes/mb/class.hddtemp.inc.php (rev 0) +++ includes/mb/class.hddtemp.inc.php 2008-12-08 11:47:13 UTC (rev 43) @@ -0,0 +1,131 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +class hddtemp { + private $debug = PSI_DEBUG; + + public function __construct() { + $this->error = Error :: Singleton(); + } + + public function temperature() { + $ar_buf = array (); + $results = array (); + switch (PSI_HDD_TEMP) { + case "tcp" : + // Timo van Roermund: connect to the hddtemp daemon, use a 5 second timeout. + $fp = @ fsockopen('localhost', 7634, $errno, $errstr, 5); + // if connected, read the output of the hddtemp daemon + if ($fp) { + // read output of the daemon + $lines = ''; + while (!feof($fp)) { + $lines .= fread($fp, 1024); + } + // close the connection + fclose($fp); + } else { + if ($this->debug) { + $this->error->addError("HDDTemp error", "HDDTemp error: " . $errno . ", " . $errstr); + } + } + $lines = str_replace("||", "|\n|", $lines); + $ar_buf = explode("\n", $lines); + break; + case "suid" : + $strDrives = ""; + $strContent = ""; + $hddtemp_value = ""; + if (rfts("/proc/diskstats", $strContent, 0, 4096, false)) { + $arrContent = explode("\n", $strContent); + foreach ($arrContent as $strLine) { + preg_match("/^\s(.*)\s([a-z]*)\s(.*)/", $strLine, $arrSplit); + if (!empty ($arrSplit[2])) { + $strDrive = '/dev/' . $arrSplit[2]; + if (file_exists($strDrive)) { + $strDrives = $strDrives . $strDrive . ' '; + } + } + } + } else { + if (rfts("/proc/partitions", $strContent, 0, 4096, false)) { + $arrContent = explode("\n", $strContent); + foreach ($arrContent as $strLine) { + if (!preg_match("/^\s(.*)\s([\/a-z0-9]*(\/disc))\s(.*)/", $strLine, $arrSplit)) { + preg_match("/^\s(.*)\s([a-z]*)\s(.*)/", $strLine, $arrSplit); + } + if (!empty ($arrSplit[2])) { + $strDrive = '/dev/' . $arrSplit[2]; + if (file_exists($strDrive)) { + $strDrives = $strDrives . $strDrive . ' '; + } + } + } + } + } + if (trim($strDrives) == "") { + return array (); + } + if (execute_program("hddtemp", $strDrives, $hddtemp_value)) { + $hddtemp_value = explode("\n", $hddtemp_value); + foreach ($hddtemp_value as $line) { + $temp = preg_split("/:\s/", $line, 3); + if (count($temp) == 3 && preg_match("/^[0-9]/", $temp[2])) { + preg_match("/^([0-9]*)(.*)/", $temp[2], $ar_temp); + $temp[2] = trim($ar_temp[1]); + $temp[3] = trim($ar_temp[2]); + array_push($ar_buf, "|" . implode("|", $temp) . "|"); + } + } + } else { + return array (); + } + break; + default : + if ($this->debug) { + $this->error->addError("HDDTemp error", "Bad hddtemp configuration in config.php"); + } + } + // Timo van Roermund: parse the info from the hddtemp daemon. + $i = 0; + foreach ($ar_buf as $line) { + $data = array (); + if (ereg("\|(.*)\|(.*)\|(.*)\|(.*)\|", $line, $data)) { + if (trim($data[3]) != "ERR") { + // get the info we need + $results[$i]['label'] = $data[1]; + if (is_numeric($data[3])) { + $results[$i]['value'] = $data[3]; + } else { + $results[$i]['value'] = 0; + } + //extra processing because of a bug in some versions of hddtemp + $results[$i]['model'] = trim(str_replace("\x10\x80", "", $data[2])); + $i++; + } + } + } + return $results; + } +} +?> Property changes on: includes/mb/class.hddtemp.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/mb/class.healthd.inc.php =================================================================== --- includes/mb/class.healthd.inc.php (rev 0) +++ includes/mb/class.healthd.inc.php 2008-12-08 11:47:13 UTC (rev 43) @@ -0,0 +1,103 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +class mbinfo { + private $lines; + public function temperature() { + $ar_buf = array (); + $results = array (); + if (!isset ($this->lines)) { + execute_program('healthdc', '-t', $this->lines); + } + $ar_buf = preg_split("/\t+/", $this->lines); + $results[0]['label'] = 'temp1'; + $results[0]['value'] = $ar_buf[1]; + $results[0]['limit'] = '70.0'; + $results[0]['percent'] = $results[0]['value'] * 100 / $results[0]['limit']; + $results[1]['label'] = 'temp2'; + $results[1]['value'] = $ar_buf[2]; + $results[1]['limit'] = '70.0'; + $results[1]['percent'] = $results[1]['value'] * 100 / $results[1]['limit']; + $results[2]['label'] = 'temp3'; + $results[2]['value'] = $ar_buf[3]; + $results[2]['limit'] = '70.0'; + $results[2]['percent'] = $results[2]['value'] * 100 / $results[2]['limit']; + return $results; + } + public function fans() { + $ar_buf = array (); + $results = array (); + if (!isset ($this->lines)) { + execute_program('healthdc', '-t', $this->lines); + } + $ar_buf = preg_split("/\t+/", $this->lines); + $results[0]['label'] = 'fan1'; + $results[0]['value'] = $ar_buf[4]; + $results[0]['min'] = '3000'; + $results[1]['label'] = 'fan2'; + $results[1]['value'] = $ar_buf[5]; + $results[1]['min'] = '3000'; + $results[2]['label'] = 'fan3'; + $results[2]['value'] = $ar_buf[6]; + $results[2]['min'] = '3000'; + return $results; + } + public function voltage() { + $ar_buf = array (); + $results = array (); + if (!isset ($this->lines)) { + execute_program('healthdc', '-t', $this->lines); + } + $ar_buf = preg_split("/\t+/", $this->lines); + $results[0]['label'] = 'Vcore1'; + $results[0]['value'] = $ar_buf[7]; + $results[0]['min'] = '0.00'; + $results[0]['max'] = '0.00'; + $results[1]['label'] = 'Vcore2'; + $results[1]['value'] = $ar_buf[8]; + $results[1]['min'] = '0.00'; + $results[1]['max'] = '0.00'; + $results[2]['label'] = '3volt'; + $results[2]['value'] = $ar_buf[9]; + $results[2]['min'] = '0.00'; + $results[2]['max'] = '0.00'; + $results[3]['label'] = '+5Volt'; + $results[3]['value'] = $ar_buf[10]; + $results[3]['min'] = '0.00'; + $results[3]['max'] = '0.00'; + $results[4]['label'] = '+12Volt'; + $results[4]['value'] = $ar_buf[11]; + $results[4]['min'] = '0.00'; + $results[4]['max'] = '0.00'; + $results[5]['label'] = '-12Volt'; + $results[5]['value'] = $ar_buf[12]; + $results[5]['min'] = '0.00'; + $results[5]['max'] = '0.00'; + $results[6]['label'] = '-5Volt'; + $results[6]['value'] = $ar_buf[13]; + $results[6]['min'] = '0.00'; + $results[6]['max'] = '0.00'; + return $results; + } +} +?> Property changes on: includes/mb/class.healthd.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/mb/class.hwsensors.inc.php =================================================================== --- includes/mb/class.hwsensors.inc.php (rev 0) +++ includes/mb/class.hwsensors.inc.php 2008-12-08 11:47:13 UTC (rev 43) @@ -0,0 +1,80 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +class mbinfo { + private $lines; + function __construct() { + if (execute_program('sysctl', '-w hw.sensors', $this->lines)) { + $this->lines = explode("\n", $this->lines); + } else { + $this->lines = array (); + } + } + public function temperature() { + $ar_buf = array (); + $results = array (); + $j = 0; + foreach ($this->lines as $line) { + $ar_buf = preg_split("/[\s,]+/", $line); + if (isset ($ar_buf[3]) && $ar_buf[2] == 'temp') { + $results[$j]['label'] = $ar_buf[1]; + $results[$j]['value'] = $ar_buf[3]; + $results[$j]['limit'] = '70.0'; + $results[$j]['percent'] = $results[$j]['value'] * 100 / $results[$j]['limit']; + $j++; + } + } + return $results; + } + public function fans() { + $ar_buf = array (); + $results = array (); + $j = 0; + foreach ($this->lines as $line) { + $ar_buf = preg_split("/[\s,]+/", $line); + if (isset ($ar_buf[3]) && $ar_buf[2] == 'fanrpm') { + $results[$j]['label'] = $ar_buf[1]; + $results[$j]['value'] = $ar_buf[3]; + $j++; + } + } + return $results; + } + public function voltage() { + $ar_buf = array (); + $results = array (); + $j = 0; + foreach ($this->lines as $line) { + $ar_buf = preg_split("/[\s,]+/", $line); + if (isset ($ar_buf[3]) && $ar_buf[2] == 'volts_dc') { + $results[$j]['label'] = $ar_buf[1]; + $results[$j]['value'] = $ar_buf[3]; + $results[$j]['min'] = '0.00'; + $results[$j]['max'] = '0.00'; + $j++; + } + } + return $results; + } +} +?> Property changes on: includes/mb/class.hwsensors.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/mb/class.ipmi.inc.php =================================================================== --- includes/mb/class.ipmi.inc.php (rev 0) +++ includes/mb/class.ipmi.inc.php 2008-12-08 11:47:13 UTC (rev 43) @@ -0,0 +1,77 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +class mbinfo implements psi_sensor_interface { + private $lines = array (); + private $error; + public function __construct() { + $this->error = Error :: Singleton(); + switch (strtolower(PSI_SENSOR_ACCESS)) { + case 'tcp' : + $this->error->addError('__construct', 'Tcp not implemented for ipmi!!!'); + break; + case 'file' : + $lines = ""; + execute_program('ipmitool', 'sensor', $lines); + $this->lines = explode("\n", $lines); + break; + default : + $this->error->addError('__construct()', 'Wrong value set in config.php for PSI_SENSOR_ACCESS!!!'); + break; + } + } + public function temperature() { + $result = array (); + $i = 0; + foreach ($this->lines as $line) { + $buffer = preg_split("/[ ]+\|[ ]+/", $line); + if ($buffer[2] == "degrees C" && $buffer[5] != "na") { + $result[$i]['label'] = $buffer[0]; + $result[$i]['value'] = $buffer[1]; + $result[$i]['limit'] = $buffer[8]; + $i++; + } + } + return $result; + } + public function fans() { + $result = array (); + return $result; + } + public function voltage() { + $result = array (); + $i = 0; + foreach ($this->lines as $line) { + $buffer = preg_split("/[ ]+\|[ ]+/", $line); + if ($buffer[2] == "Volts" && $buffer[5] != "na") { + $result[$i]['label'] = $buffer[0]; + $result[$i]['value'] = $buffer[1]; + $result[$i]['min'] = $buffer[5]; + $result[$i]['max'] = $buffer[8]; + $i++; + } + } + return $result; + } +} +?> Property changes on: includes/mb/class.ipmi.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/mb/class.lmsensors.inc.php =================================================================== --- includes/mb/class.lmsensors.inc.php (rev 0) +++ includes/mb/class.lmsensors.inc.php 2008-12-08 11:47:13 UTC (rev 43) @@ -0,0 +1,173 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +class mbinfo { + private $lines; + function __construct() { + $lines = ""; + if (execute_program("sensors", "", $lines)) { + // Martijn Stolk: Dirty fix for misinterpreted output of sensors, + // where info could come on next line when the label is too long. + $lines = str_replace(":\n", ":", $lines); + $lines = str_replace("\n\n", "\n", $lines); + $this->lines = explode("\n", $lines); + } else { + $this->lines = array (); + } + } + public function temperature() { + $ar_buf = array (); + $results = array (); + $sensors_value = $this->lines; + foreach ($sensors_value as $line) { + $data = array (); + if (ereg("(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)", $line, $data)); + elseif (ereg("(.*):(.*)\((.*)=(.*)\)(.*)", $line, $data)); + else + (ereg("(.*):(.*)", $line, $data)); + if (count($data) > 1) { + $temp = substr(trim($data[2]), -1); + switch ($temp) { + case "C" : + case "F" : + array_push($ar_buf, $line); + } + } + } + $i = 0; + foreach ($ar_buf as $line) { + unset ($data); + if (ereg("(.*):(.*).C[ ]*\((.*)=(.*).C,(.*)=(.*).C\)(.*)\)", $line, $data)); + elseif (ereg("(.*):(.*).C[ ]*\((.*)=(.*).C,(.*)=(.*).C\)(.*)", $line, $data)); + elseif (ereg("(.*):(.*).C[ ]*\((.*)=(.*).C\)(.*)", $line, $data)); + else + (ereg("(.*):(.*).C", $line, $data)); + foreach ($data as $key => $value) { + if (preg_match("/^\+?([0-9\.]+).?$/", trim($value), $newvalue)) { + $data[$key] = trim($newvalue[1]); + } else { + $data[$key] = trim($value); + } + } + $results[$i]['label'] = $data[1]; + $results[$i]['value'] = $data[2]; + if (isset ($data[6]) && $data[2] > $data[6]) { + $results[$i]['limit'] = "75"; + $results[$i]['perce'] = "75"; + } else { + $results[$i]['limit'] = isset ($data[4]) ? $data[4] : "75"; + $results[$i]['perce'] = isset ($data[6]) ? $data[6] : "75"; + } + if ($results[$i]['limit'] < $results[$i]['perce']) { + $results[$i]['limit'] = $results[$i]['perce']; + } + $i++; + } + asort($results); + return array_values($results); + } + public function fans() { + $ar_buf = array (); + $results = array (); + $sensors_value = $this->lines; + foreach ($sensors_value as $line) { + $data = array (); + if (ereg("(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)", $line, $data)); + elseif (ereg("(.*):(.*)\((.*)=(.*)\)(.*)", $line, $data)); + else + ereg("(.*):(.*)", $line, $data); + if (count($data) > 1) { + $temp = explode(" ", trim($data[2])); + if (count($temp) == 1) + $temp = explode("\xb0", trim($data[2])); + if (isset ($temp[1])) { + switch ($temp[1]) { + case "RPM" : + array_push($ar_buf, $line); + } + } + } + } + $i = 0; + foreach ($ar_buf as $line) { + unset ($data); + if (ereg("(.*):(.*) RPM \((.*)=(.*) RPM,(.*)=(.*)\)(.*)\)", $line, $data)); + elseif (ereg("(.*):(.*) RPM \((.*)=(.*) RPM,(.*)=(.*)\)(.*)", $line, $data)); + elseif (ereg("(.*):(.*) RPM \((.*)=(.*) RPM\)(.*)", $line, $data)); + else + ereg("(.*):(.*) RPM", $line, $data); + $results[$i]['label'] = trim($data[1]); + $results[$i]['value'] = trim($data[2]); + $results[$i]['min'] = isset ($data[4]) ? trim($data[4]) : 0; + $i++; + } + asort($results); + return array_values($results); + } + public function voltage() { + $ar_buf = array (); + $results = array (); + $sensors_value = $this->lines; + foreach ($sensors_value as $line) { + $data = array (); + if (ereg("(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)", $line, $data)); + else + ereg("(.*):(.*)", $line, $data); + if (count($data) > 1) { + $temp = explode(" ", trim($data[2])); + if (count($temp) == 1) + $temp = explode("\xb0", trim($data[2])); + if (isset ($temp[1])) { + switch ($temp[1]) { + case "V" : + array_push($ar_buf, $line); + } + } + } + } + $i = 0; + foreach ($ar_buf as $line) { + unset ($data); + if (ereg("(.*):(.*) V \((.*)=(.*) V,(.*)=(.*) V\)(.*)\)", $line, $data)); + elseif (ereg("(.*):(.*) V \((.*)=(.*) V,(.*)=(.*) V\)(.*)", $line, $data)); + else + ereg("(.*):(.*) V$", $line, $data); + foreach ($data as $key => $value) { + if (preg_match("/^\+?([0-9\.]+)$/", trim($value), $newvalue)) { + $data[$key] = trim($newvalue[1]); + } else { + $data[$key] = trim($value); + } + } + if (isset ($data[1])) { + $results[$i]['label'] = $data[1]; + $results[$i]['value'] = $data[2]; + $results[$i]['min'] = isset ($data[4]) ? $data[4] : 0; + $results[$i]['max'] = isset ($data[6]) ? $data[6] : 0; + $i++; + } + } + return $results; + } +} +?> Property changes on: includes/mb/class.lmsensors.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/mb/class.mbm5.inc.php =================================================================== --- includes/mb/class.mbm5.inc.php (rev 0) +++ includes/mb/class.mbm5.inc.php 2008-12-08 11:47:13 UTC (rev 43) @@ -0,0 +1,86 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +class mbinfo { + private $buf_label; + private $buf_value; + function __construct() { + $buffer = ""; + rfts(APP_ROOT . "/data/MBM5.csv", $buffer); + if (strpos($buffer, ";") === false) { + $delim = ","; + } else { + $delim = ";"; + } + $buffer = split("\n", $buffer); + $this->buf_label = split($delim, substr($buffer[0], 0, -2)); + $this->buf_value = split($delim, substr($buffer[1], 0, -2)); + } + public function temperature() { + $results = array (); + $intCount = 0; + for ($intPosi = 3; $intPosi < 6; $intPosi++) { + if ($this->buf_value[$intPosi] == 0) { + continue; + } + $results[$intCount]['label'] = $this->buf_label[$intPosi]; + preg_match("/([0-9\.])*/", str_replace(",", ".", $this->buf_value[$intPosi]), $hits); + $results[$intCount]['value'] = $hits[0]; + $results[$intCount]['limit'] = '70.0'; + $intCount++; + } + return $results; + } + public function fans() { + $results = array (); + $intCount = 0; + for ($intPosi = 13; $intPosi < 16; $intPosi++) { + if (!isset ($this->buf_value[$intPosi])) { + continue; + } + $results[$intCount]['label'] = $this->buf_label[$intPosi]; + preg_match("/([0-9\.])*/", str_replace(",", ".", $this->buf_value[$intPosi]), $hits); + $results[$intCount]['value'] = $hits[0]; + $results[$intCount]['min'] = '3000'; + $intCount++; + } + return $results; + } + public function voltage() { + $results = array (); + $intCount = 0; + for ($intPosi = 6; $intPosi < 13; $intPosi++) { + if ($this->buf_value[$intPosi] == 0) { + continue; + } + $results[$intCount]['label'] = $this->buf_label[$intPosi]; + preg_match("/([0-9\.])*/", str_replace(",", ".", $this->buf_value[$intPosi]), $hits); + $results[$intCount]['value'] = $hits[0]; + $results[$intCount]['min'] = '0.00'; + $results[$intCount]['max'] = '0.00'; + $intCount++; + } + return $results; + } +} +?> Property changes on: includes/mb/class.mbm5.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/mb/class.mbmon.inc.php =================================================================== --- includes/mb/class.mbmon.inc.php (rev 0) +++ includes/mb/class.mbmon.inc.php 2008-12-08 11:47:13 UTC (rev 43) @@ -0,0 +1,103 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +class mbinfo implements psi_sensor_interface { + private $lines = array (); + public function __construct() { + $this->error = Error :: Singleton(); + switch (strtolower(PSI_SENSOR_ACCESS)) { + case 'tcp' : + $fp = fsockopen("localhost", 411, $errno, $errstr, 5); + if ($fp) { + $lines = ""; + while (!feof($fp)) { + $lines .= fread($fp, 1024); + } + $this->lines = explode("\n", $lines); + } else { + $this->error->addError("fsockopen()", $errno . " " . $errstr); + } + break; + case 'file' : + execute_program('mbmon', '-c 1 -r', $lines); + $this->lines = explode("\n", $lines); + break; + default : + $this->error->addError('__construct()', 'Wrong value set in config.php for PSI_SENSOR_ACCESS!!!'); + break; + } + } + public function temperature() { + $results = array (); + $i = 0; + foreach ($this->lines as $line) { + if (preg_match('/^(TEMP\d*)\s*:\s*(.*)$/D', $line, $data)) { + if ($data[2] <> '0') { + $results[$i]['label'] = $data[1]; + $results[$i]['limit'] = '70.0'; + if ($data[2] > 250) { + $results[$i]['value'] = 0; + $results[$i]['percent'] = 0; + } else { + $results[$i]['value'] = $data[2]; + $results[$i]['percent'] = $results[$i]['value'] * 100 / $results[$i]['limit']; + } + $i++; + } + } + } + return $results; + } + public function fans() { + $results = array (); + $i = 0; + foreach ($this->lines as $line) { + if (preg_match('/^(FAN\d*)\s*:\s*(.*)$/D', $line, $data)) { + if ($data[2] <> '0') { + $results[$i]['label'] = $data[1]; + $results[$i]['value'] = $data[2]; + $results[$i]['min'] = '3000'; + $i++; + } + } + } + return $results; + } + public function voltage() { + $results = array (); + $i = 0; + foreach ($this->lines as $line) { + if (preg_match('/^(V.*)\s*:\s*(.*)$/D', $line, $data)) { + if ($data[2] <> '+0.00') { + $results[$i]['label'] = $data[1]; + $results[$i]['value'] = $data[2]; + $results[$i]['min'] = '0.00'; + $results[$i]['max'] = '0.00'; + $i++; + } + } + } + return $results; + } +} +?> Property changes on: includes/mb/class.mbmon.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Big...@us...> - 2008-12-08 12:48:55
|
Revision: 44 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=44&view=rev Author: BigMichi1 Date: 2008-12-08 12:48:51 +0000 (Mon, 08 Dec 2008) Log Message: ----------- Added Paths: ----------- includes/os/ includes/os/class.Darwin.inc.php includes/os/class.DragonFly.inc.php includes/os/class.FreeBSD.inc.php includes/os/class.HP-UX.inc.php includes/os/class.Linux.inc.php includes/os/class.NetBSD.inc.php includes/os/class.OpenBSD.inc.php includes/os/class.SunOS.inc.php includes/os/class.WINNT.inc.php includes/os/class.bsd_common.inc.php includes/os/class.parser.inc.php Added: includes/os/class.Darwin.inc.php =================================================================== --- includes/os/class.Darwin.inc.php (rev 0) +++ includes/os/class.Darwin.inc.php 2008-12-08 12:48:51 UTC (rev 44) @@ -0,0 +1,191 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +if (!defined('IN_PHPSYSINFO')) { + die("No Hacking"); +} +$error->addWarning("The Darwin version of phpSysInfo is work in progress, some things currently don't work"); +class sysinfo extends bsd_common implements psi_os_interface { + private $debug = PSI_DEBUG; + // Our contstructor + // this function is run on the initialization of this class + public function __construct() { + parent :: __construct(); + $this->set_cpuregexp1 = ("CPU: (.*) \((.*)-MHz (.*)\)"); + $this->set_cpuregexp2("/(.*) ([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+)/"); + $this->set_scsiregexp1("^(.*): <(.*)> .*SCSI.*device"); + } + protected function grab_key($key) { + $s = ""; + if (execute_program('sysctl', $key, $s, $this->debug)) { + $s = ereg_replace($key . ': ', '', $s); + $s = ereg_replace($key . ' = ', '', $s); // fix Apple set keys + return $s; + } else { + return ''; + } + } + private function grab_ioreg($key) { + $s = ""; + if (execute_program('ioreg', '-cls "' . $key . '" | grep "' . $key . '"', $s, $this->debug)) { //ioreg -cls "$key" | grep "$key" + $s = ereg_replace('\|', '', $s); + $s = ereg_replace('\+\-\o', '', $s); + $s = ereg_replace('[ ]+', '', $s); + $s = ereg_replace('<[^>]+>', '', $s); // remove possible XML conflicts + return $s; + } else { + return ''; + } + } + protected function get_sys_ticks() { + $a = ""; + if (execute_program('sysctl', '-n kern.boottime', $a, $this->debug)) { + // get boottime (value in seconds) + $sys_ticks = time() - $a; + return $sys_ticks; + } else { + return 'N.A.'; + } + } + public function cpu_info() { + $results = array (); + $buf = ""; + // $results['model'] = $this->grab_key('hw.model'); // need to expand this somehow... + // $results['model'] = $this->grab_key('hw.machine'); + if (!execute_program('hostinfo', '| grep "Processor type"', $buf, $this->debug)) { + $buf = 'N.A.'; + } + $results['model'] = ereg_replace('Processor type: ', '', $buf); // get processor type + $results['cpus'] = $this->grab_key('hw.ncpu'); + $results['cpuspeed'] = round($this->grab_key('hw.cpufrequency') / 1000000); // return cpu speed - Mhz + $results['busspeed'] = round($this->grab_key('hw.busfrequency') / 1000000); // return bus speed - Mhz + $results['cache'] = round($this->grab_key('hw.l2cachesize') / 1024); // return l2 cache + if (($this->grab_key('hw.model') == "PowerMac3,6") && ($results['cpus'] == "2")) { + $results['model'] = 'Dual G4 - (PowerPC 7450)'; + } // is Dual G4 + if (($this->grab_key('hw.model') == "PowerMac7,2") && ($results['cpus'] == "2")) { + $results['model'] = 'Dual G5 - (PowerPC 970)'; + } // is Dual G5 + if (($this->grab_key('hw.model') == "PowerMac1,1") && ($results['cpus'] == "1")) { + $results['model'] = 'B&W G3 - (PowerPC 750)'; + } // is B&W G3 + return $results; + } + // get the pci device information out of ioreg + public function pci() { + $results = array (); + $s = $this->grab_ioreg('IOPCIDevice'); + $lines = split("\n", $s); + for ($i = 0, $max = sizeof($lines); $i < $max; $i++) { + $ar_buf = preg_split("/\s+/", $lines[$i], 19); + $results[$i] = $ar_buf[0]; + } + asort($results); + return array_values(array_unique($results)); + } + // get the ide device information out of ioreg + public function ide() { + $results = array (); + // ioreg | grep "Media <class IOMedia>" + $s = $this->grab_ioreg('IOATABlockStorageDevice'); + $lines = split("\n", $s); + $j = 0; + for ($i = 0, $max = sizeof($lines); $i < $max; $i++) { + $ar_buf = preg_split("/\/\//", $lines[$i], 19); + if (isset ($ar_buf[1]) && $ar_buf[1] == 'class IOMedia' && preg_match('/Media/', $ar_buf[0])) { + $results[$j++]['model'] = $ar_buf[0]; + } + } + asort($results); + return array_values(array_unique($results)); + } + public function memory() { + $pstat = ""; + $s = $this->grab_key('hw.memsize'); + $results['ram'] = array (); + $results['swap'] = array (); + $results['devswap'] = array (); + if (!execute_program('vm_stat', '', $pstat, $this->debug)) { + $pstat = ''; + } + $lines = split("\n", $pstat); + for ($i = 0, $max = sizeof($lines); $i < $max; $i++) { + $ar_buf = preg_split("/\s+/", $lines[$i], 19); + if ($i == 1) { + // calculate free memory from page sizes (each page = 4MB) + $results['ram']['free'] = $ar_buf[2] * 4 * 1024; + } + } + $results['ram']['total'] = $s; + $results['ram']['shared'] = 0; + $results['ram']['buffers'] = 0; + $results['ram']['used'] = $results['ram']['total'] - $results['ram']['free']; + $results['ram']['cached'] = 0; + $results['ram']['percent'] = round(($results['ram']['used'] * 100) / $results['ram']['total']); + // need to fix the swap info... + // meanwhile silence and / or disable the swap information + if (execute_program('swapinfo', '-k', $pstat, $this->debug)) { + $lines = split("\n", $pstat); + for ($i = 0, $max = sizeof($lines); $i < $max; $i++) { + $ar_buf = preg_split("/\s+/", $lines[$i], 6); + if ($i == 0) { + $results['swap']['total'] = 0; + $results['swap']['used'] = 0; + $results['swap']['free'] = 0; + $results['swap']['percent'] = 0; + } else { + $results['swap']['total'] = $results['swap']['total'] + $ar_buf[1] * 1024; + $results['swap']['used'] = $results['swap']['used'] + $ar_buf[2] * 1024; + $results['swap']['free'] = $results['swap']['free'] + $ar_buf[3] * 1024; + $results['swap']['percent'] = ceil(($results['swap']['used'] * 100) / (($results['swap']['total'] <= 0) ? 1 : $results['swap']['total'])); + } + } + } + return $results; + } + public function network() { + $netstat = ""; + if (execute_program('netstat', '-nbdi | cut -c1-24,42- | grep Link', $netstat, $this->debug)) { + $lines = split("\n", $netstat); + $results = array (); + for ($i = 0, $max = sizeof($lines); $i < $max; $i++) { + $ar_buf = preg_split("/\s+/", $lines[$i], 10); + if (!empty ($ar_buf[0])) { + $results[$ar_buf[0]] = array (); + $results[$ar_buf[0]]['rx_bytes'] = $ar_buf[5]; + $results[$ar_buf[0]]['tx_bytes'] = $ar_buf[8]; + $results[$ar_buf[0]]['errs'] = $ar_buf[4] + $ar_buf[7]; + $results[$ar_buf[0]]['drop'] = isset ($ar_buf[10]) ? $ar_buf[10] : 0; + } + } + return $results; + } else { + return array (); + } + } + public function distroicon() { + $result = 'Darwin.png'; + return ($result); + } +} +?> Property changes on: includes/os/class.Darwin.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/os/class.DragonFly.inc.php =================================================================== --- includes/os/class.DragonFly.inc.php (rev 0) +++ includes/os/class.DragonFly.inc.php 2008-12-08 12:48:51 UTC (rev 44) @@ -0,0 +1,95 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +if (!defined('IN_PHPSYSINFO')) { + die("No Hacking"); +} +class sysinfo extends bsd_common implements psi_os_interface { + // Our contstructor + // this function is run on the initialization of this class + public function __construct() { + parent :: __construct(); + $this->set_cpuregexp1("^cpu(.*)\, (.*) MHz"); + // TODO : scsi needs to be verified + $this->set_scsiregexp1("^(.*) at scsibus.*: <(.*)> .*"); + $this->set_scsiregexp2("^(da[0-9]): (.*)MB "); + $this->set_pciregexp1("/(.*): <(.*)>(.*) (pci|legacypci)[0-9]$/"); + $this->set_pciregexp2("/(.*): <(.*)>.* at [0-9\.]+$/"); + } + protected function get_sys_ticks() { + $a = $this->grab_key('kern.boottime'); + preg_match("/sec = ([0-9]+)/", $a, $buf); + $sys_ticks = time() - $buf[1]; + return $sys_ticks; + } + public function loadavg($bar = false) { + // TODO : bar not implemented yet, so call everytime with false + return parent :: loadavg(false); + } + public function network() { + $netstat_b = ""; + $netstat_n = ""; + execute_program('netstat', '-nbdi | cut -c1-25,44- | grep "^[a-z]*[0-9][ \t].*Link"', $netstat_b); + execute_program('netstat', '-ndi | cut -c1-25,44- | grep "^[a-z]*[0-9][ \t].*Link"', $netstat_n); + $lines_b = split("\n", $netstat_b); + $lines_n = split("\n", $netstat_n); + $results = array (); + for ($i = 0, $max = sizeof($lines_b); $i < $max; $i++) { + $ar_buf_b = preg_split("/\s+/", $lines_b[$i]); + $ar_buf_n = preg_split("/\s+/", $lines_n[$i]); + if (!empty ($ar_buf_b[0]) && !empty ($ar_buf_n[3])) { + $results[$ar_buf_b[0]] = array (); + $results[$ar_buf_b[0]]['rx_bytes'] = $ar_buf_b[5]; + $results[$ar_buf_b[0]]['tx_bytes'] = $ar_buf_b[8]; + $results[$ar_buf_b[0]]['errs'] = $ar_buf_n[4] + $ar_buf_n[6]; + $results[$ar_buf_b[0]]['drop'] = $ar_buf_n[8]; + } + } + return $results; + } + // get the ide device information out of dmesg + public function ide() { + $results = array (); + $s = 0; + $dmesg = $this->read_dmesg(); + for ($i = 0, $max = count($dmesg); $i < $max; $i++) { + $buf = $dmesg[$i]; + if (preg_match('/^(.*): (.*) <(.*)> at (ata[0-9]\-(.*)) (.*)/', $buf, $ar_buf)) { + $results[$ar_buf[1]]['model'] = $ar_buf[3]; + if (preg_match("/^acd[0-9](.*)/", $ar_buf[1])) { + $results[$ar_buf[1]]['media'] = $ar_buf[2]; + } else { + $results[$ar_buf[1]]['media'] = 'Hard Disk'; + $results[$ar_buf[1]]['capacity'] = $ar_buf[2] * 1024; + } + } + } + asort($results); + return $results; + } + public function distroicon() { + $result = 'DragonFly.png'; + return ($result); + } +} +?> Property changes on: includes/os/class.DragonFly.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/os/class.FreeBSD.inc.php =================================================================== --- includes/os/class.FreeBSD.inc.php (rev 0) +++ includes/os/class.FreeBSD.inc.php 2008-12-08 12:48:51 UTC (rev 44) @@ -0,0 +1,87 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +if (!defined('IN_PHPSYSINFO')) { + die("No Hacking"); +} +class sysinfo extends bsd_common implements psi_os_interface { + private $debug = PSI_DEBUG; + // Our contstructor + // this function is run on the initialization of this class + public function __construct() { + parent :: __construct(); + $this->set_cpuregexp1("CPU: (.*) \((.*)-MHz (.*)\)"); + $this->set_cpuregexp2("/(.*) ([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+)/"); + $this->set_scsiregexp1("^(.*): <(.*)> .*SCSI.*device"); + $this->set_scsiregexp2("^(da[0-9]): (.*)MB "); + $this->set_pciregexp1("/(.*): <(.*)>(.*) pci[0-9]$/"); + $this->set_pciregexp2("/(.*): <(.*)>.* at [.0-9]+ irq/"); + } + protected function get_sys_ticks() { + $s = explode(' ', $this->grab_key('kern.boottime')); + $a = ereg_replace('{ ', '', $s[3]); + $sys_ticks = time() - $a; + return $sys_ticks; + } + public function network() { + $netstat = ""; + if (!execute_program('netstat', '-nibd | grep Link', $netstat, $this->debug)) { + $netstat = ''; + } + $lines = split("\n", $netstat); + $results = array (); + for ($i = 0, $max = sizeof($lines); $i < $max; $i++) { + $ar_buf = preg_split("/\s+/", $lines[$i]); + if (!empty ($ar_buf[0])) { + $results[$ar_buf[0]] = array (); + if (strlen($ar_buf[3]) < 15) { + $results[$ar_buf[0]]['rx_bytes'] = $ar_buf[5]; + $results[$ar_buf[0]]['tx_bytes'] = $ar_buf[8]; + $results[$ar_buf[0]]['errs'] = $ar_buf[4] + $ar_buf[7]; + $results[$ar_buf[0]]['drop'] = $ar_buf[10]; + } else { + $results[$ar_buf[0]]['rx_bytes'] = $ar_buf[6]; + $results[$ar_buf[0]]['tx_bytes'] = $ar_buf[9]; + $results[$ar_buf[0]]['errs'] = $ar_buf[5] + $ar_buf[8]; + $results[$ar_buf[0]]['drop'] = $ar_buf[11]; + } + } + } + return $results; + } + public function distroicon() { + $result = 'FreeBSD.png'; + return ($result); + } + private function memory_additional($results) { + $pagesize = $this->grab_key("hw.pagesize"); + $results['ram']['cached'] = $this->grab_key("vm.stats.vm.v_cache_count") * $pagesize; + $results['ram']['cached_percent'] = round($results['ram']['cached'] * 100 / $results['ram']['total']); + $results['ram']['app'] = $this->grab_key("vm.stats.vm.v_active_count") * $pagesize; + $results['ram']['app_percent'] = round($results['ram']['app'] * 100 / $results['ram']['total']); + $results['ram']['buffers'] = $results['ram']['used'] - $results['ram']['app'] - $results['ram']['cached']; + $results['ram']['buffers_percent'] = round($results['ram']['buffers'] * 100 / $results['ram']['total']); + return $results; + } +} +?> Property changes on: includes/os/class.FreeBSD.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/os/class.HP-UX.inc.php =================================================================== --- includes/os/class.HP-UX.inc.php (rev 0) +++ includes/os/class.HP-UX.inc.php 2008-12-08 12:48:51 UTC (rev 44) @@ -0,0 +1,409 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +class sysinfo implements psi_os_interface { + // get our apache SERVER_NAME or vhost + public function vhostname() { + if (!($result = getenv('SERVER_NAME'))) { + $result = 'N.A.'; + } + return $result; + } + // get the IP address of our vhost name + public function vip_addr() { + return gethostbyname($this->vhostname()); + } + // get our canonical hostname + public function chostname() { + $ret = ""; + if (execute_program('hostname', '', $ret)) { + return $ret; + } else { + return 'N.A.'; + } + } + // get the IP address of our canonical hostname + public function ip_addr() { + if (!($result = getenv('SERVER_ADDR'))) { + $result = gethostbyname($this->chostname()); + } + return $result; + } + public function kernel() { + $ret = ""; + if (execute_program('uname', '-srvm', $ret)) { + return $ret; + } else { + return 'N.A.'; + } + } + public function uptime() { + $buf = ""; + $result = 0; + $ar_buf = array (); + if (execute_program('uptime', '', $buf)) { + if (preg_match("/up (\d+) days,\s*(\d+):(\d+),/", $buf, $ar_buf)) { + $min = $ar_buf[3]; + $hours = $ar_buf[2]; + $days = $ar_buf[1]; + $result = $days * 86400 + $hours * 3600 + $min * 60; + } + return $result; + } else { + return 'N.A.'; + } + } + public function users() { + $ret = ""; + if (execute_program('who', '-q', $ret)) { + $who = split('=', $ret); + $result = $who[1]; + return $result; + } else { + return 'N.A.'; + } + } + public function loadavg($bar = false) { + $buf = ""; + $ar_buf = array (); + if (execute_program('uptime', '', $buf)) { + if (preg_match("/average: (.*), (.*), (.*)$/", $buf, $ar_buf)) { + $results['avg'] = array ( + $ar_buf[1], + $ar_buf[2], + $ar_buf[3] + ); + } else { + $results['avg'] = array ( + 'N.A.', + 'N.A.', + 'N.A.' + ); + } + return $results; + } else { + return 'N.A.'; + } + } + public function cpu_info() { + $results = array (); + $ar_buf = array (); + $bufr = ""; + if (rfts('/proc/cpuinfo', $bufr)) { + $bufe = explode("\n", $bufr); + foreach ($bufe as $buf) { + list ($key, $value) = preg_split('/\s+:\s+/', trim($buf), 2); + // All of the tags here are highly architecture dependant. + // the only way I could reconstruct them for machines I don't + // have is to browse the kernel source. So if your arch isn't + // supported, tell me you want it written in. + switch ($key) { + case 'model name' : + $results['model'] = $value; + break; + case 'cpu MHz' : + $results['cpuspeed'] = sprintf('%.2f', $value); + break; + case 'cycle frequency [Hz]' : // For Alpha arch - 2.2.x + $results['cpuspeed'] = sprintf('%.2f', $value / 1000000); + break; + case 'clock' : // For PPC arch (damn borked POS) + $results['cpuspeed'] = sprintf('%.2f', $value); + break; + case 'cpu' : // For PPC arch (damn borked POS) + $results['model'] = $value; + break; + case 'revision' : // For PPC arch (damn borked POS) + $results['model'] .= ' ( rev: ' . $value . ')'; + break; + case 'cpu model' : // For Alpha arch - 2.2.x + $results['model'] .= ' (' . $value . ')'; + break; + case 'cache size' : + $results['cache'] = $value; + break; + case 'bogomips' : + $results['bogomips'] += $value; + break; + case 'BogoMIPS' : // For alpha arch - 2.2.x + $results['bogomips'] += $value; + break; + case 'BogoMips' : // For sparc arch + $results['bogomips'] += $value; + break; + case 'cpus detected' : // For Alpha arch - 2.2.x + $results['cpus'] += $value; + break; + case 'system type' : // Alpha arch - 2.2.x + $results['model'] .= ', ' . $value . ' '; + break; + case 'platform string' : // Alpha arch - 2.2.x + $results['model'] .= ' (' . $value . ')'; + break; + case 'processor' : + $results['cpus'] += 1; + break; + } + } + } + $keys = array_keys($results); + $keys2be = array ( + 'model', + 'cpuspeed', + 'cache', + 'bogomips', + 'cpus' + ); + while ($ar_buf = each($keys2be)) { + if (!in_array($ar_buf[1], $keys)) { + $results[$ar_buf[1]] = 'N.A.'; + } + } + return $results; + } + public function pci() { + $bufr = ""; + $results = array (); + if (rfts('/proc/pci', $bufr)) { + $bufe = explode("\n", $bufr); + foreach ($bufe as $buf) { + if (preg_match('/Bus/', $buf)) { + $device = true; + continue; + } + if ($device) { + list ($key, $value) = split(': ', $buf, 2); + if (!preg_match('/bridge/i', $key) && !preg_match('/USB/i', $key)) { + $results[] = preg_replace('/\([^\)]+\)\.$/', '', trim($value)); + } + $device = false; + } + } + } + asort($results); + return $results; + } + public function ide() { + $buf = ""; + $results = array (); + $bufd = gdc('/proc/ide'); + foreach ($bufd as $file) { + if (preg_match('/^hd/', $file)) { + $results[$file] = array (); + // Check if device is CD-ROM (CD-ROM capacity shows as 1024 GB) + if (rfts("/proc/ide/" . $file . "/media", $buf, 1)) { + $results[$file]['media'] = trim($buf); + if ($results[$file]['media'] == 'disk') { + $results[$file]['media'] = 'Hard Disk'; + } + if ($results[$file]['media'] == 'cdrom') { + $results[$file]['media'] = 'CD-ROM'; + } + } + if (rfts("/proc/ide/" . $file . "/model", $buf, 1)) { + $results[$file]['model'] = trim($buf); + if (preg_match('/WDC/', $results[$file]['model'])) { + $results[$file]['manufacture'] = 'Western Digital'; + } + elseif (preg_match('/IBM/', $results[$file]['model'])) { + $results[$file]['manufacture'] = 'IBM'; + } + elseif (preg_match('/FUJITSU/', $results[$file]['model'])) { + $results[$file]['manufacture'] = 'Fujitsu'; + } else { + $results[$file]['manufacture'] = 'Unknown'; + } + } + if (rfts("/proc/ide/" . $file . "/capacity", $buf, 1)) { + $results[$file]['capacity'] = trim($buf); + if ($results[$file]['media'] == 'CD-ROM') { + unset ($results[$file]['capacity']); + } + } + } + } + asort($results); + return $results; + } + public function scsi() { + $bufr = ""; + $results = array (); + $dev_vendor = ''; + $dev_model = ''; + $dev_rev = ''; + $dev_type = ''; + $s = 1; + if (rfts('/proc/scsi/scsi', $bufr)) { + $bufe = explode("\n", $bufr); + foreach ($bufe as $buf) { + if (preg_match('/Vendor/', $buf)) { + preg_match('/Vendor: (.*) Model: (.*) Rev: (.*)/i', $buf, $dev); + list ($key, $value) = split(': ', $buf, 2); + $dev_str = $value; + $get_type = 1; + continue; + } + if ($get_type) { + preg_match('/Type:\s+(\S+)/i', $buf, $dev_type); + $results[$s]['model'] = "$dev[1] $dev[2] ($dev_type[1])"; + $results[$s]['media'] = "Hard Disk"; + $s++; + $get_type = 0; + } + } + } + asort($results); + return $results; + } + public function usb() { + $bufr = ""; + $results = array (); + $devstring = 0; + $devnum = -1; + if (rfts('/proc/bus/usb/devices', $bufr)) { + $bufe = explode("\n", $bufr); + foreach ($bufe as $buf) { + if (preg_match('/^T/', $buf)) { + $devnum += 1; + } + if (preg_match('/^S/', $buf)) { + $devstring = 1; + } + if ($devstring) { + list ($key, $value) = split(': ', $buf, 2); + list ($key, $value2) = split('=', $value, 2); + $results[$devnum] .= " " . trim($value2); + $devstring = 0; + } + } + } + return $results; + } + public function network() { + $netstat = ""; + if (execute_program('netstat', '-ni | tail -n +2', $netstat)) { + $lines = split("\n", $netstat); + $results = array (); + for ($i = 0, $max = sizeof($lines); $i < $max; $i++) { + $ar_buf = preg_split("/\s+/", $lines[$i]); + if (!empty ($ar_buf[0]) && !empty ($ar_buf[3])) { + $results[$ar_buf[0]] = array (); + $results[$ar_buf[0]]['rx_bytes'] = $ar_buf[4]; + $results[$ar_buf[0]]['tx_bytes'] = $ar_buf[6]; + $results[$ar_buf[0]]['errs'] = $ar_buf[5] + $ar_buf[7]; + $results[$ar_buf[0]]['drop'] = $ar_buf[8]; + } + } + return $results; + } else { + return array (); + } + } + public function memory() { + $bufr = ""; + $results['swap'] = array (); + $results['devswap'] = array (); + if (rfts('/proc/meminfo', $bufr)) { + $bufe = explode("\n", $bufr); + foreach ($bufe as $buf) { + if (preg_match('/Mem:\s+(.*)$/', $buf, $ar_buf)) { + $ar_buf = preg_split('/\s+/', $ar_buf[1], 6); + $results['ram']['total'] = $ar_buf[0]; + $results['ram']['used'] = $ar_buf[1]; + $results['ram']['free'] = $ar_buf[2]; + $results['ram']['shared'] = $ar_buf[3]; + $results['ram']['buffers'] = $ar_buf[4]; + $results['ram']['cached'] = $ar_buf[5]; + // I don't like this since buffers and cache really aren't + // 'used' per say, but I get too many emails about it. + $results['ram']['percent'] = round(($results['ram']['used'] * 100) / $results['ram']['total']); + } + if (preg_match('/Swap:\s+(.*)$/', $buf, $ar_buf)) { + $ar_buf = preg_split('/\s+/', $ar_buf[1], 3); + $results['swap']['total'] = $ar_buf[0]; + $results['swap']['used'] = $ar_buf[1]; + $results['swap']['free'] = $ar_buf[2]; + $results['swap']['percent'] = ceil(($ar_buf[1] * 100) / (($ar_buf[0] <= 0) ? 1 : $ar_buf[0])); + // Get info on individual swap files + $swaps = ""; + if (rfts('/proc/swaps', $swaps)) { + $swapdevs = split("\n", $swaps); + for ($i = 1, $max = (sizeof($swapdevs) - 1); $i < $max; $i++) { + $ar_buf = preg_split('/\s+/', $swapdevs[$i], 6); + $results['devswap'][$i -1] = array (); + $results['devswap'][$i -1]['dev'] = $ar_buf[0]; + $results['devswap'][$i -1]['total'] = $ar_buf[2] * 1024; + $results['devswap'][$i -1]['used'] = $ar_buf[3] * 1024; + $results['devswap'][$i -1]['free'] = ($results['devswap'][$i -1]['total'] - $results['devswap'][$i -1]['used']); + $results['devswap'][$i -1]['percent'] = round(($ar_buf[3] * 100) / $ar_buf[2]); + } + break; + } + } + } + } + return $results; + } + public function filesystems() { + $df = ""; + if (execute_program('df', '-kP', $df)) { + $mounts = split("\n", $df); + } else { + $mounts = array (); + } + $fstype = array (); + $s = ""; + if (execute_program('mount', '-v', $s)) { + $lines = explode("\n", $s); + } else { + $lines = array (); + } + $i = 0; + while (list (, $line) = each($lines)) { + $a = split(' ', $line); + $fsdev[$a[0]] = $a[4]; + } + for ($i = 1, $j = 0, $max = sizeof($mounts); $i < $max; $i++) { + $ar_buf = preg_split("/\s+/", $mounts[$i], 6); + $results[$j] = array (); + $results[$j]['disk'] = $ar_buf[0]; + $results[$j]['size'] = $ar_buf[1] * 1024; + $results[$j]['used'] = $ar_buf[2] * 1024; + $results[$j]['free'] = $ar_buf[3] * 1024; + $results[$j]['percent'] = $ar_buf[4]; + $results[$j]['mount'] = $ar_buf[5]; + ($fstype[$ar_buf[5]]) ? $results[$j]['fstype'] = $fstype[$ar_buf[5]] : $results[$j]['fstype'] = $fsdev[$ar_buf[0]]; + $j++; + } + return $results; + } + public function distro() { + $result = 'HP-UX'; + return ($result); + } + public function distroicon() { + $result = 'unknown.png'; + return ($result); + } +} +?> Property changes on: includes/os/class.HP-UX.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/os/class.Linux.inc.php =================================================================== --- includes/os/class.Linux.inc.php (rev 0) +++ includes/os/class.Linux.inc.php 2008-12-08 12:48:51 UTC (rev 44) @@ -0,0 +1,551 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +if (!defined('IN_PHPSYSINFO')) { + die("No Hacking"); +} +class sysinfo implements psi_os_interface { + private $inifile = "distros.ini"; + private $icon = "unknown.png"; + private $distro = "unknown"; + private $parser; + private $debug = PSI_DEBUG; + // get the distro name and icon when create the sysinfo object + public function __construct() { + $distro_info = ""; + $buf = ""; + $this->parser = new parser(); + $this->parser->add_df_param('-P'); + $list = @ parse_ini_file(APP_ROOT . "/" . $this->inifile, true); + if (!$list) { + return; + } + // We have the '2> /dev/null' because Ubuntu gives an error on this command which causes the distro to be unknown + if (execute_program('lsb_release', '-a 2> /dev/null', $distro_info, $this->debug)) { + $distro_tmp = split("\n", $distro_info); + foreach ($distro_tmp as $info) { + $info_tmp = split(':', $info, 2); + $distro[$info_tmp[0]] = trim($info_tmp[1]); + } + if (!isset ($list[$distro['Distributor ID']])) { + return; + } + $this->icon = isset ($list[$distro['Distributor ID']]["Image"]) ? $list[$distro['Distributor ID']]["Image"] : $this->icon; + $this->distro = $distro['Description']; + } else { // Fall back in case 'lsb_release' does not exist ;) + foreach ($list as $section => $distribution) { + if (!isset ($distribution["Files"])) { + continue; + } else { + foreach (explode(";", $distribution["Files"]) as $filename) { + if (file_exists($filename)) { + rfts($filename, $buf); + $this->icon = isset ($distribution["Image"]) ? $distribution["Image"] : $this->icon; + $this->distro = isset ($distribution["Name"]) ? $distribution["Name"] . " " . trim($buf) : trim($buf); + break 2; + } + } + } + } + } + } + // get our apache SERVER_NAME or vhost + public function vhostname() { + if (!($result = getenv('SERVER_NAME'))) { + $result = 'N.A.'; + } + return $result; + } + // get the IP address of our vhost name + public function vip_addr() { + return gethostbyname($this->vhostname()); + } + // get our canonical hostname + public function chostname() { + $result = ""; + if (rfts('/proc/sys/kernel/hostname', $result, 1)) { + $result = trim($result); + $ip = gethostbyname($result); + if ($ip != $result) { + $result = gethostbyaddr($ip); + } else { + $result = 'Unknown'; + } + } else { + $result = "N.A."; + } + return $result; + } + // get the IP address of our canonical hostname + public function ip_addr() { + if (!($result = getenv('SERVER_ADDR'))) { + $result = gethostbyname($this->chostname()); + } + return $result; + } + public function kernel() { + $strBuf = ""; + if (execute_program('uname', '-r', $strBuf, $this->debug)) { + $result = trim($strBuf); + if (execute_program('uname', '-v', $strBuf, $this->debug)) { + if (preg_match('/SMP/', $strBuf)) { + $result .= ' (SMP)'; + } + } + if (execute_program('uname', '-m', $strBuf, $this->debug)) { + $result .= ' ' . trim($strBuf); + } + } else { + if (rfts('/proc/version', $strBuf, 1)) { + if (preg_match('/version (.*?) /', $strBuf, $ar_buf)) { + $result = $ar_buf[1]; + if (preg_match('/SMP/', $strBuf)) { + $result .= ' (SMP)'; + } + } else { + $result = "N.A."; + } + } else { + $result = "N.A."; + } + } + return $result; + } + public function uptime() { + $buf = ""; + rfts('/proc/uptime', $buf, 1); + $ar_buf = split(' ', $buf); + $result = trim($ar_buf[0]); + return $result; + } + public function users() { + $strResult = 0; + $strBuf = ""; + if (execute_program('who', '-q', $strBuf, $this->debug)) { + $arrWho = split('=', $strBuf); + $strResult = $arrWho[1]; + } + return $strResult; + } + public function loadavg($bar = false) { + $buf = ""; + if (rfts('/proc/loadavg', $buf)) { + $results['avg'] = preg_split("/\s/", $buf, 4); + // don't need the extra values, only first three + unset ($results['avg'][3]); + } else { + $results['avg'] = array ( + 'N.A.', + 'N.A.', + 'N.A.' + ); + } + if ($bar) { + if (rfts('/proc/stat', $buf, 1)) { + $ab = 0; + $ac = 0; + $ad = 0; + $ae = 0; + sscanf($buf, "%*s %Ld %Ld %Ld %Ld", $ab, $ac, $ad, $ae); + // Find out the CPU load + // user + sys = load + // total = total + $load = $ab + $ac + $ad; // cpu.user + cpu.sys + $total = $ab + $ac + $ad + $ae; // cpu.total + // we need a second value, wait 1 second befor getting (< 1 second no good value will occour) + sleep(1); + rfts('/proc/stat', $buf, 1); + sscanf($buf, "%*s %Ld %Ld %Ld %Ld", $ab, $ac, $ad, $ae); + $load2 = $ab + $ac + $ad; + $total2 = $ab + $ac + $ad + $ae; + $results['cpupercent'] = (100 * ($load2 - $load)) / ($total2 - $total); + } + } + return $results; + } + public function cpu_info() { + $bufr = ""; + $results = array ( + "cpus" => 0 + ); + if (rfts('/proc/cpuinfo', $bufr)) { + $bufe = explode("\n", $bufr); + $results = array ( + 'cpus' => 0, + 'bogomips' => 0 + ); + $ar_buf = array (); + foreach ($bufe as $buf) { + $arrBuff = preg_split('/\s+:\s+/', trim($buf)); + if (count($arrBuff) == 2) { + $key = $arrBuff[0]; + $value = $arrBuff[1]; + // All of the tags here are highly architecture dependant. + // the only way I could reconstruct them for machines I don't + // have is to browse the kernel source. So if your arch isn't + // supported, tell me you want it written in. + switch ($key) { + case 'model name' : + $results['model'] = $value; + break; + case 'cpu MHz' : + $results['cpuspeed'] = sprintf('%.2f', $value); + break; + case 'cycle frequency [Hz]' : // For Alpha arch - 2.2.x + $results['cpuspeed'] = sprintf('%.2f', $value / 1000000); + break; + case 'clock' : // For PPC arch (damn borked POS) + $results['cpuspeed'] = sprintf('%.2f', $value); + break; + case 'cpu' : // For PPC arch (damn borked POS) + $results['model'] = $value; + break; + case 'L2 cache' : // More for PPC + $results['cache'] = $value; + break; + case 'revision' : // For PPC arch (damn borked POS) + $results['model'] .= ' ( rev: ' . $value . ')'; + break; + case 'cpu model' : // For Alpha arch - 2.2.x + $results['model'] .= ' (' . $value . ')'; + break; + case 'cache size' : + $value = preg_replace("/[a-zA-Z]/", "", $value); + $results['cache'] = $value; + break; + case 'bogomips' : + $results['bogomips'] = $value; + break; + case 'BogoMIPS' : // For alpha arch - 2.2.x + $results['bogomips'] += $value; + break; + case 'BogoMips' : // For sparc arch + $results['bogomips'] += $value; + break; + case 'cpus detected' : // For Alpha arch - 2.2.x + $results['cpus'] += $value; + break; + case 'system type' : // Alpha arch - 2.2.x + $results['model'] .= ', ' . $value . ' '; + break; + case 'platform string' : // Alpha arch - 2.2.x + $results['model'] .= ' (' . $value . ')'; + break; + case 'processor' : + $results['cpus'] += 1; + break; + case 'Cpu0ClkTck' : // Linux sparc64 + $results['cpuspeed'] = sprintf('%.2f', hexdec($value) / 1000000); + break; + case 'Cpu0Bogo' : // Linux sparc64 & sparc32 + $results['bogomips'] = $value; + break; + case 'ncpus probed' : // Linux sparc64 & sparc32 + $results['cpus'] = $value; + break; + } + } + } + // sparc64 specific code follows + // This adds the ability to display the cache that a CPU has + // Originally made by Sven Blumenstein <ba...@ge...> in 2004 + // Modified by Tom Weustink <fre...@gm...> in 2004 + $sparclist = array ( + 'SUNW,UltraSPARC@0,0', + 'SUNW,UltraSPARC-II@0,0', + 'SUNW,UltraSPARC@1c,0', + 'SUNW,UltraSPARC-IIi@1c,0', + 'SUNW,UltraSPARC-II@1c,0', + 'SUNW,UltraSPARC-IIe@0,0' + ); + foreach ($sparclist as $name) { + if (rfts('/proc/openprom/' . $name . '/ecache-size', $buf, 1, 32, false)) { + $results['cache'] = base_convert($buf, 16, 10) / 1024 . ' KB'; + } + } + // sparc64 specific code ends + // XScale detection code + if ($results['cpus'] == 0) { + foreach ($bufe as $buf) { + $fields = preg_split('/\s*:\s*/', trim($buf), 2); + if (sizeof($fields) == 2) { + list ($key, $value) = $fields; + switch ($key) { + case 'Processor' : + $results['cpus'] += 1; + $results['model'] = $value; + break; + case 'BogoMIPS' : //BogoMIPS are not BogoMIPS on this CPU, it's the speed, no BogoMIPS available + $results['cpuspeed'] = $value; + break; + case 'I size' : + $results['cache'] = $value; + break; + case 'D size' : + $results['cache'] += $value; + break; + } + } + } + $results['cache'] = $results['cache'] / 1024; + } + } + $keys = array_keys($results); + $keys2be = array ( + 'model', + 'cpuspeed', + 'cpus' + ); + while ($ar_buf = each($keys2be)) { + if (!in_array($ar_buf[1], $keys)) { + $results[$ar_buf[1]] = '0'; + } + } + if (rfts('/proc/acpi/thermal_zone/THRM/temperature', $buf, 1, 4096, false)) { + $results['temp'] = substr($buf, 25, 2); + } + return $results; + } + public function pci() { + $strBuf = ""; + $arrResults = array (); + $booDevice = false; + if (!$arrResults = $this->parser->parse_lspci()) { + if (rfts('/proc/pci', $strBuf, 0, 4096, false)) { + $arrBuf = explode("\n", $strBuf); + foreach ($arrBuf as $strLine) { + if (preg_match('/Bus/', $strLine)) { + $booDevice = true; + continue; + } + if ($booDevice) { + list ($strKey, $strValue) = split(': ', $strLine, 2); + if (!preg_match('/bridge/i', $strKey) && !preg_match('/USB/i ', $strKey)) { + $arrResults[] = preg_replace('/\([^\)]+\)\.$/', '', trim($strValue)); + } + $booDevice = false; + } + } + asort($arrResults); + } + } + return $arrResults; + } + public function ide() { + $results = array (); + $buf = ""; + $bufd = gdc('/proc/ide', false); + foreach ($bufd as $file) { + if (preg_match('/^hd/', $file)) { + $results[$file] = array (); + if (rfts("/proc/ide/" . $file . "/media", $buf, 1)) { + $results[$file]['media'] = trim($buf); + if ($results[$file]['media'] == 'disk') { + $results[$file]['media'] = 'Hard Disk'; + if (rfts("/proc/ide/" . $file . "/capacity", $buf, 1, 4096, false) || rfts("/sys/block/" . $file . "/size", $buf, 1, 4096, false)) { + $results[$file]['capacity'] = trim($buf) * 512 / 1024; + } + } + elseif ($results[$file]['media'] == 'cdrom') { + $results[$file]['media'] = 'CD-ROM'; + unset ($results[$file]['capacity']); + } + } else { + unset ($results[$file]); + } + if (rfts("/proc/ide/" . $file . "/model", $buf, 1)) { + $results[$file]['model'] = trim($buf); + if (preg_match('/WDC/', $results[$file]['model'])) { + $results[$file]['manufacture'] = 'Western Digital'; + } + elseif (preg_match('/IBM/', $results[$file]['model'])) { + $results[$file]['manufacture'] = 'IBM'; + } + elseif (preg_match('/FUJITSU/', $results[$file]['model'])) { + $results[$file]['manufacture'] = 'Fujitsu'; + } else { + $results[$file]['manufacture'] = 'Unknown'; + } + } + } + } + asort($results); + return $results; + } + public function scsi() { + $bufr = ""; + $results = array (); + $dev_vendor = ''; + $dev_model = ''; + $dev_rev = ''; + $dev_type = ''; + $s = 1; + $get_type = 0; + if (execute_program('lsscsi', '-c', $bufr, $this->debug) || rfts('/proc/scsi/scsi', $bufr, 0, 4096, $this->debug)) { + $bufe = explode("\n", $bufr); + foreach ($bufe as $buf) { + if (preg_match('/Vendor/', $buf)) { + preg_match('/Vendor: (.*) Model: (.*) Rev: (.*)/i', $buf, $dev); + list ($key, $value) = split(': ', $buf, 2); + $dev_str = $value; + $get_type = true; + continue; + } + if ($get_type) { + preg_match('/Type:\s+(\S+)/i', $buf, $dev_type); + $results[$s]['model'] = "$dev[1] $dev[2] ($dev_type[1])"; + $results[$s]['media'] = "Hard Disk"; + $s++; + $get_type = false; + } + } + } + asort($results); + return $results; + } + public function usb() { + $bufr = ""; + $results = array (); + $devnum = -1; + if (!execute_program('lsusb', '', $bufr, $this->debug)) { + if (rfts('/proc/bus/usb/devices', $bufr, 0, 4096, false)) { + $bufe = explode("\n", $bufr); + foreach ($bufe as $buf) { + if (preg_match('/^T/', $buf)) { + $devnum += 1; + $results[$devnum] = ""; + } + elseif (preg_match('/^S:/', $buf)) { + list ($key, $value) = split(': ', $buf, 2); + list ($key, $value2) = split('=', $value, 2); + if (trim($key) != "SerialNumber") { + $results[$devnum] .= " " . trim($value2); + $devstring = 0; + } + } + } + } + } else { + $bufe = explode("\n", $bufr); + foreach ($bufe as $buf) { + $device = preg_split("/ /", $buf, 7); + if (isset ($device[6]) && trim($device[6]) != "") { + $results[$devnum++] = trim($device[6]); + } + } + } + return $results; + } + public function network() { + $results = array (); + $bufr = ""; + if (rfts('/proc/net/dev', $bufr)) { + $bufe = explode("\n", $bufr); + foreach ($bufe as $buf) { + if (preg_match('/:/', $buf)) { + list ($dev_name, $stats_list) = preg_split('/:/', $buf, 2); + $dev_name = trim($dev_name); + $stats = preg_split('/\s+/', trim($stats_list)); + $results[$dev_name] = array (); + $results[$dev_name]['rx_bytes'] = $stats[0]; + $results[$dev_name]['tx_bytes'] = $stats[8]; + $results[$dev_name]['errs'] = $stats[2] + $stats[10]; + $results[$dev_name]['drop'] = $stats[3] + $stats[11]; + } + } + } + return $results; + } + public function memory() { + $bufr = ""; + $results['ram'] = array ( + 'total' => 0, + 'free' => 0, + 'used' => 0, + 'percent' => 0 + ); + $results['swap'] = array ( + 'total' => 0, + 'free' => 0, + 'used' => 0, + 'percent' => 0 + ); + $results['devswap'] = array (); + if (rfts('/proc/meminfo', $bufr)) { + $bufe = explode("\n", $bufr); + foreach ($bufe as $buf) { + if (preg_match('/^MemTotal:\s+(.*)\s*kB/i', $buf, $ar_buf)) { + $results['ram']['total'] = $ar_buf[1] * 1024; + } else + if (preg_match('/^MemFree:\s+(.*)\s*kB/i', $buf, $ar_buf)) { + $results['ram']['free'] = $ar_buf[1] * 1024; + } else + if (preg_match('/^Cached:\s+(.*)\s*kB/i', $buf, $ar_buf)) { + $results['ram']['cached'] = $ar_buf[1] * 1204; + } else + if (preg_match('/^Buffers:\s+(.*)\s*kB/i', $buf, $ar_buf)) { + $results['ram']['buffers'] = $ar_buf[1] * 1024; + } + } + $results['ram']['used'] = $results['ram']['total'] - $results['ram']['free']; + $results['ram']['percent'] = round(($results['ram']['used'] * 100) / $results['ram']['total']); + // values for splitting memory usage + if (isset ($results['ram']['cached']) && isset ($results['ram']['buffers'])) { + $results['ram']['app'] = $results['ram']['used'] - $results['ram']['cached'] - $results['ram']['buffers']; + $results['ram']['app_percent'] = round(($results['ram']['app'] * 100) / $results['ram']['total']); + $results['ram']['buffers_percent'] = round(($results['ram']['buffers'] * 100) / $results['ram']['total']); + $results['ram']['cached_percent'] = round(($results['ram']['cached'] * 100) / $results['ram']['total']); + } + $bufr = ""; + if (rfts('/proc/swaps', $bufr)) { + $swaps = explode("\n", $bufr); + for ($i = 1; $i < (sizeof($swaps)); $i++) { + if (trim($swaps[$i]) != "") { + $ar_buf = preg_split('/\s+/', $swaps[$i], 6); + $results['devswap'][$i -1] = array (); + $results['devswap'][$i -1]['dev'] = $ar_buf[0]; + $results['devswap'][$i -1]['total'] = $ar_buf[2] * 1024; + $results['devswap'][$i -1]['used'] = $ar_buf[3] * 1024; + $results['devswap'][$i -1]['free'] = ($results['devswap'][$i -1]['total'] - $results['devswap'][$i -1]['used']); + $results['devswap'][$i -1]['percent'] = round(($ar_buf[3] * 100) / $ar_buf[2]); + $results['swap']['total'] += $ar_buf[2] * 1024; + $results['swap']['used'] += $ar_buf[3] * 1024; + $results['swap']['free'] = $results['swap']['total'] - $results['swap']['used']; + $results['swap']['percent'] = ceil(($results['swap']['used'] * 100) / (($results['swap']['total'] <= 0) ? 1 : $results['swap']['total'])); + } + } + } + } + return $results; + } + public function filesystems() { + return $this->parser->parse_filesystems(); + } + public function distro() { + return $this->distro; + } + public function distroicon() { + return $this->icon; + } +} +?> Property changes on: includes/os/class.Linux.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/os/class.NetBSD.inc.php =================================================================== --- includes/os/class.NetBSD.inc.php (rev 0) +++ includes/os/class.NetBSD.inc.php 2008-12-08 12:48:51 UTC (rev 44) @@ -0,0 +1,96 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +if (!defined('IN_PHPSYSINFO')) { + die("No Hacking"); +} +class sysinfo extends bsd_common implements psi_os_interface { + // Our contstructor + // this function is run on the initialization of this class + public function __construct() { + parent :: __construct(); + $this->set_cpuregexp1("^cpu(.*)\, (.*) MHz"); + $this->set_cpuregexp2("/user = (.*), nice = (.*), sys = (.*), intr = (.*), idle = (.*)/"); + $this->set_scsiregexp1("^(.*) at scsibus.*: <(.*)> .*"); + $this->set_scsiregexp2("^(da[0-9]): (.*)MB "); + $this->set_pciregexp1("/(.*) at pci[0-9] dev [0-9]* function [0-9]*: (.*)$/"); + $this->set_pciregexp2("/\"(.*)\" (.*).* at [.0-9]+ irq/"); + } + protected function get_sys_ticks() { + $a = $this->grab_key('kern.boottime'); + $sys_ticks = time() - $a; + return $sys_ticks; + } + public function network() { + $netstat_b = ""; + $netstat_n = ""; + execute_program('netstat', '-nbdi | cut -c1-25,44- | grep "^[a-z]*[0-9][ \t].*Link"', $netstat_b); + execute_program('netstat', '-ndi | cut -c1-25,44- | grep "^[a-z]*[0-9][ \t].*Link"', $netstat_n); + $lines_b = split("\n", $netstat_b); + $lines_n = split("\n", $netstat_n); + $results = array (); + for ($i = 0, $max = sizeof($lines_b); $i < $max; $i++) { + $ar_buf_b = preg_split("/\s+/", $lines_b[$i]); + $ar_buf_n = preg_split("/\s+/", $lines_n[$i]); + if (!empty ($ar_buf_b[0]) && !empty ($ar_buf_n[3])) { + $results[$ar_buf_b[0]] = array (); + $results[$ar_buf_b[0]]['rx_bytes'] = $ar_buf_b[3]; + $results[$ar_buf_b[0]]['tx_bytes'] = $ar_buf_b[4]; + $results[$ar_buf_b[0]]['errs'] = $ar_buf_n[4] + $ar_buf_n[6]; + $results[$ar_buf_b[0]]['drop'] = $ar_buf_n[8]; + } + } + return $results; + } + // get the ide device information out of dmesg + public function ide() { + $results = array (); + $s = 0; + $dmesg = $this->read_dmesg(); + for ($i = 0, $max = count($dmesg); $i < $max; $i++) { + $buf = $dmesg[$i]; + if (preg_match('/^(.*) at (pciide|wdc|atabus|atapibus)[0-9] (.*): <(.*)>/', $buf, $ar_buf)) { + $s = $ar_buf[1]; + $results[$s]['model'] = $ar_buf[4]; + $results[$s]['media'] = 'Hard Disk'; + // now loop again and find the capacity + for ($j = 0, $max1 = count($dmesg); $j < $max1; $j++) { + $buf_n = $dmesg[$j]; + if (preg_match("/^($s): (.*), (.*), (.*)MB, .*$/", $buf_n, $ar_buf_n)) { + $results[$s]['capacity'] = $ar_buf_n[4] * 2048 * 1.049; + } + elseif (preg_match("/^($s): (.*) MB, (.*), (.*), .*$/", $buf_n, $ar_buf_n)) { + $results[$s]['capacity'] = $ar_buf_n[2] * 2048; + } + } + } + } + asort($results); + return $results; + } + public function distroicon() { + $result = 'NetBSD.png'; + return ($result); + } +} +?> Property changes on: includes/os/class.NetBSD.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/os/class.OpenBSD.inc.php =================================================================== --- includes/os/class.OpenBSD.inc.php (rev 0) +++ includes/os/class.OpenBSD.inc.php 2008-12-08 12:48:51 UTC (rev 44) @@ -0,0 +1,102 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// +// $Id$ +// +if (!defined('IN_PHPSYSINFO')) { + die("No Hacking"); +} +class sysinfo extends bsd_common implements psi_os_interface { + private $debug = PSI_DEBUG; + // Our contstructor + // this function is run on the initialization of this class + public function __construct() { + parent :: __construct(); + $this->set_cpuregexp1("^cpu(.*) (.*) MHz"); + $this->set_cpuregexp2("/(.*),(.*),(.*),(.*),(.*)/"); + $this->set_scsiregexp1("^(.*) at scsibus.*: <(.*)> .*"); + $this->set_scsiregexp2("^(da[0-9]): (.*)MB "); + $this->set_pciregexp1("/(.*) at pci[0-9] .* \"(.*)\"/"); + $this->set_pciregexp2("/\"(.*)\" (.*).* at [.0-9]+ irq/"); + } + protected function get_sys_ticks() { + $a = $this->grab_key('kern.boottime'); + $sys_ticks = time() - $a; + return $sys_ticks; + } + public function network() { + $netstat_b = ""; + $netstat_n = ""; + execute_program('netstat', '-nbdi | cut -c1-25,44- | grep Link | grep -v \'* \'', $netstat_b, $this->debug); + execute_program('netstat', '-ndi | cut -c1-25,44- | grep Link | grep -v \'* \'', $netstat_n, $this->debug); + $lines_b = split("\n", $netstat_b); + $lines_n = split("\n", $netstat_n); + $results = array (); + for ($i = 0, $max = sizeof($lines_b); $i < $max; $i++) { + $ar_buf_b = preg_split("/\s+/", $lines_b[$i]); + $ar_buf_n = preg_split("/\s+/", $lines_n[$i]); + if (!empty ($ar_buf_b[0]) && !empty ($ar_buf_n[3])) { + $results[$ar_buf_b[0]] = array (); + $results[$ar_buf_b[0]]['rx_bytes'] = $ar_buf_b[3]; + $results[$ar_buf_b[0]]['tx_bytes'] = $ar_buf_b[4]; + $results[$ar_buf_b[0]]['errs'] = $ar_buf_n[4] + $ar_buf_n[6]; + $results[$ar_buf_b[0]]['drop'] = $ar_buf_n[8]; + } + } + return $results; + } + // get the ide device information out of dmesg + public function ide() { + $results = array (); + $s = 0; + $dmesg = $this->read_dmesg(); + for ($i = 0, $max = count($dmesg); $i < $max; $i++) { + $buf = $dmesg[$i]; + if (preg_match('/^(.*) at pciide[0-9] (.*): <(.*)>/', $buf, $ar_buf)) { + $s = $ar_buf[1]; + $results[$s]['model'] = $ar_buf[3]; + $results[$s]['media'] = 'Hard Disk'; + // now loop again and find the capacity + for ($j = 0, $max1 = count($dmesg); $j < $max1; $j++) { + $buf_n = $dmesg[$j]; + if (preg_match("/^($s): (.*), (.*), (.*)MB, .*$/", $buf_n, $ar_buf_n)) { + $results[$s]['capacity'] = $ar_buf_n[4] * 2048 * 1.049; + ; + } + } + } + } + asort($results); + return $results; + } + public function cpu_info() { + $results = array (); + $results['model'] = $this->grab_key('hw.model'); + $results['cpus'] = $this->grab_key('hw.ncpu'); + $results['cpuspeed'] = $this->grab_key('hw.cpuspeed'); + return $results; + } + public function distroicon() { + $result = 'OpenBSD.png'; + return ($result); + } +} +?> Property changes on: includes/os/class.OpenBSD.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/os/class.SunOS.inc.php =================================================================== --- includes/os/class.SunOS.inc.php (rev 0) +++ includes/os/class.SunOS.inc.php 2008-12-08 12:48:51 UTC (rev 44) @@ -0,0 +1,225 @@ +<?php +/*************************************************************************** + * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * + * http://phpsysinfo.sourceforge.net/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Fre... [truncated message content] |
From: <jac...@us...> - 2009-01-04 08:00:23
|
Revision: 68 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=68&view=rev Author: jacky672 Date: 2009-01-04 08:00:19 +0000 (Sun, 04 Jan 2009) Log Message: ----------- Option to hide/show picklist (language and/or template) Modified Paths: -------------- ChangeLog config.php.new includes/xml.class.php phpsysinfo.js Modified: ChangeLog =================================================================== --- ChangeLog 2008-12-31 14:07:50 UTC (rev 67) +++ ChangeLog 2009-01-04 08:00:19 UTC (rev 68) @@ -11,6 +11,7 @@ - [ADD] Added FR [ 1664157 ] DragonFlyBSD support - [ADD] Added FR [ 1869891 ] mbmon TCP support - [ADD] Added FR [ 1568822 ] IPIM Support + - [ADD] Option to hide picklist (language and/or template) - [FIX] Fixed hidenetworkinterfaces config option - [FIX] Fixed Bug [ 1987494 ] clicking on "Physical Memory" Modified: config.php.new =================================================================== --- config.php.new 2008-12-31 14:07:50 UTC (rev 67) +++ config.php.new 2009-01-04 08:00:19 UTC (rev 68) @@ -32,6 +32,12 @@ define('PSI_DEFAULT_LANG', 'en'); define('PSI_DEFAULT_TEMPLATE', 'phpsysinfo.css'); +// show/hide language and template picklist +// true = display picklist +// false = do not display picklist +define('PSI_SHOW_PICKLIST_TEMPLATE', true); +define('PSI_SHOW_PICKLIST_LANG', true); + //define the intervalle for refreshing data (ms) 1 000 = 1s define('PSI_REFRESH',10000); Modified: includes/xml.class.php =================================================================== --- includes/xml.class.php 2008-12-31 14:07:50 UTC (rev 67) +++ includes/xml.class.php 2009-01-04 08:00:19 UTC (rev 68) @@ -55,6 +55,8 @@ $options->addChild('tempFormat', PSI_TEMP_FORMAT); $options->addChild('byteFormat', PSI_BYTE_FORMAT); $options->addChild('refresh', PSI_REFRESH ? PSI_REFRESH : 'false'); + $options->addChild('showPickListTemplate', PSI_SHOW_PICKLIST_TEMPLATE ? PSI_SHOW_PICKLIST_TEMPLATE : 'false'); + $options->addChild('showPickListLang', PSI_SHOW_PICKLIST_LANG ? PSI_SHOW_PICKLIST_LANG : 'false'); $plug = $options->addChild('Used_Plugins'); if ((!$this->plugin_request || $this->complete_request) && PSI_PLUGINS !== false) { $this->plugins = explode(",", PSI_PLUGINS); Modified: phpsysinfo.js =================================================================== --- phpsysinfo.js 2008-12-31 14:07:50 UTC (rev 67) +++ phpsysinfo.js 2009-01-04 08:00:19 UTC (rev 68) @@ -249,6 +249,21 @@ $("#container").fadeIn("slow"); versioni = $("Generation", xml).attr("version"); $("#version").html(versioni); + + $("Options",xml).each(function(id) { + var options = $("Options",xml).get(id); + var showPickListLang = $("showPickListLang",options).text(); + var showPickListTemplate = $("showPickListTemplate",options).text(); + if(showPickListTemplate == 'false') { + $('#template').hide(); + $('span[@lang=044]').hide(); + } + if(showPickListLang == 'false') { + $('#lang').hide(); + $('span[@lang=045]').hide(); + } + }); + } function refreshMemory(xml) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Big...@us...> - 2009-01-26 13:15:47
|
Revision: 122 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=122&view=rev Author: BigMichi1 Date: 2009-01-26 13:15:43 +0000 (Mon, 26 Jan 2009) Log Message: ----------- documentation include mbstring check convert to utf-8 with mbstring functions Modified Paths: -------------- includes/common_functions.php includes/xml.class.php Modified: includes/common_functions.php =================================================================== --- includes/common_functions.php 2009-01-22 12:54:30 UTC (rev 121) +++ includes/common_functions.php 2009-01-26 13:15:43 UTC (rev 122) @@ -221,15 +221,12 @@ * See bug #1787137 */ function checkForExtensions() { - $extensions = array ('simplexml', 'pcre', 'xml', 'xsl'); + $extensions = array ('simplexml', 'pcre', 'xml', 'xsl', 'mbstring'); $text = ""; $error = false; $text .= "<?xml version='1.0'?>\n"; $text .= "<phpsysinfo>\n"; $text .= " <Error>\n"; - if(PHP_OS == 'WINNT') { - $extensions[] = 'iconv'; - } foreach ($extensions as $extension) { if (!extension_loaded($extension)) { $text .= " <Function>checkForExtensions</Function>\n"; Modified: includes/xml.class.php =================================================================== --- includes/xml.class.php 2009-01-22 12:54:30 UTC (rev 121) +++ includes/xml.class.php 2009-01-26 13:15:43 UTC (rev 122) @@ -1,106 +1,148 @@ <?php -/*************************************************************************** - * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * - * http://phpsysinfo.sourceforge.net/ * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ -// -// $Id$ -// +/** + * XML Generation class + * + * @license http://opensource.org/licenses/gpl-2.0.php + * @package psi + */ + +/** + * class for generation of the xml + * + * @author Michael Cramer (Big...@us...) + * @version $Id$ + * @copyright Copyright (C) 2008 by phpSysInfo + * @package psi + */ class xml { + /** + * Sysinfo object where the information retrieval methods are included + * + * @access private + * @var Sysinfo + */ private $sysinfo; - private $mbinfo; - private $hddtemp; - private $upsinfo; + + /** + * xml object with the xml content + * + * @access private + * @var SimpleXMLElement + */ private $xml; + + /** + * object for error handling + * + * @access private + * @var Error + */ private $errors; + + /** + * array with all enabled plugins (name) + * + * @access private + * @var array + */ private $plugins; + + /** + * generate a xml for a plugin or for the main app + * + * @access private + * @var boolean + */ private $plugin_request = false; + + /** + * generate the entire xml with all plugins or only a part of the xml (main or plugin) + * + * @access private + * @var boolean + */ private $complete_request = false; + + /** + * doing some initial tasks + * - generate the xml structure with the right header elements + * - get the error object for error output + * - get a instance of the sysinfo object + * + * @param string name of the plugin + * @param boolean generate xml with all plugins or not + */ public function __construct($pluginname = "", $complete = false) { ($pluginname == "") ? $this->plugin_request = false : $this->plugin_request = true; ($complete) ? $this->complete_request = true : $this->complete_request = false; - $this->errors = Error :: singleton(); - if (!$this->plugin_request || $this->complete_request) { + $this->errors = Error::singleton(); + if(!$this->plugin_request || $this->complete_request) { $this->sysinfo = new sysinfo(); - if (PSI_MBINFO) { - $this->mbinfo = new mbinfo; - } - if (PSI_HDDTEMP) { - $this->hddtemp = new hddtemp; - } - if (PSI_UPSINFO) { - $this->upsinfo = new upsinfo; - } } $this->xml = simplexml_load_string("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phpsysinfo xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"phpsysinfo.xsd\"></phpsysinfo>"); $generation = $this->xml->addChild('Generation'); $generation->addAttribute('version', PSI_VERSION); $generation->addAttribute('timestamp', time()); $options = $this->xml->addChild('Options'); - $options->addChild('tempFormat', PSI_TEMP_FORMAT); - $options->addChild('byteFormat', PSI_BYTE_FORMAT); - $options->addChild('refresh', PSI_REFRESH ? PSI_REFRESH : 'false'); - $options->addChild('showPickListTemplate', PSI_SHOW_PICKLIST_TEMPLATE ? PSI_SHOW_PICKLIST_TEMPLATE : 'false'); - $options->addChild('showPickListLang', PSI_SHOW_PICKLIST_LANG ? PSI_SHOW_PICKLIST_LANG : 'false'); + $options->addChild('tempFormat', defined('PSI_TEMP_FORMAT') ? PSI_TEMP_FORMAT : 'c'); + $options->addChild('byteFormat', defined('PSI_BYTE_FORMAT') ? PSI_BYTE_FORMAT : 'auto_binary'); + $options->addChild('refresh', defined('PSI_REFRESH') ? PSI_REFRESH : 'false'); + $options->addChild('showPickListTemplate', defined('PSI_SHOW_PICKLIST_TEMPLATE') ? PSI_SHOW_PICKLIST_TEMPLATE : 'false'); + $options->addChild('showPickListLang', defined('PSI_SHOW_PICKLIST_LANG') ? PSI_SHOW_PICKLIST_LANG : 'false'); $plug = $options->addChild('Used_Plugins'); - if ((!$this->plugin_request || $this->complete_request) && PSI_PLUGINS !== false) { - $this->plugins = explode(",", PSI_PLUGINS); - foreach ($this->plugins as $plugin) { + if((!$this->plugin_request || $this->complete_request) && PSI_PLUGINS !== false) { + $this->plugins = preg_split("/[\s]?,[\s]?/", PSI_PLUGINS, -1, PREG_SPLIT_NO_EMPTY); + foreach($this->plugins as $plugin) { $plug->addChild('Plugin', $plugin); } } else { - $this->plugins = array ( - $pluginname - ); + $this->plugins = array($pluginname); } } + + /** + * generate common information + * + * @access private + */ private function buildVitals() { $strLoadavg = ''; $arrBuf = $this->sysinfo->loadavg(PSI_LOAD_BAR); - foreach ($arrBuf['avg'] as $strValue) { + foreach($arrBuf['avg'] as $strValue) { $strLoadavg .= $strValue . ' '; } $vitals = $this->xml->addChild('Vitals'); - if (PSI_USE_VHOST === true) { - $vitals->addChild('Hostname', utf8_encode(trim(htmlspecialchars($this->sysinfo->vhostname())))); + if(PSI_USE_VHOST === true) { + $vitals->addChild('Hostname', $this->toUTF8(htmlspecialchars($this->sysinfo->vhostname()))); $vitals->addChild('IPAddr', $this->sysinfo->vip_addr()); } else { - $vitals->addChild('Hostname', utf8_encode(trim(htmlspecialchars($this->sysinfo->chostname())))); + $vitals->addChild('Hostname', $this->toUTF8(htmlspecialchars($this->sysinfo->chostname()))); $vitals->addChild('IPAddr', $this->sysinfo->ip_addr()); } - $vitals->addChild('Kernel', utf8_encode(trim(htmlspecialchars($this->sysinfo->kernel())))); - $vitals->addChild('Distro', utf8_encode(trim(htmlspecialchars($this->sysinfo->distro())))); - $vitals->addChild('Distroicon', utf8_encode(trim(htmlspecialchars($this->sysinfo->distroicon())))); + $vitals->addChild('Kernel', $this->toUTF8(htmlspecialchars($this->sysinfo->kernel()))); + $vitals->addChild('Distro', $this->toUTF8(htmlspecialchars($this->sysinfo->distro()))); + $vitals->addChild('Distroicon', $this->toUTF8(htmlspecialchars($this->sysinfo->distroicon()))); $vitals->addChild('Uptime', $this->sysinfo->uptime()); $vitals->addChild('Users', $this->sysinfo->users()); $vitals->addChild('LoadAvg', $strLoadavg); - if (isset ($arrBuf['cpupercent'])) { + if(isset($arrBuf['cpupercent'])) { $vitals->addChild('CPULoad', round($arrBuf['cpupercent'], 2)); } } + + /** + * generate the network information + * + * @access private + */ private function buildNetwork() { $arrNet = $this->sysinfo->network(); $network = $this->xml->addChild('Network'); - $hideDevices = explode(',', PSI_HIDE_NETWORK_INTERFACE); - foreach ($arrNet as $strDev => $arrStats) { - if (!in_array($strDev, $hideDevices)) { + $hideDevices = preg_split("/[\s]?,[\s]?/", PSI_HIDE_NETWORK_INTERFACE, -1, PREG_SPLIT_NO_EMPTY); + foreach($arrNet as $strDev => $arrStats) { + if(!in_array($strDev, $hideDevices)) { $device = $network->addChild('NetDevice'); - $device->addChild('Name', utf8_encode(trim(htmlspecialchars($strDev)))); + $device->addChild('Name', $this->toUTF8(htmlspecialchars($strDev))); $device->addChild('RxBytes', $arrStats['rx_bytes']); $device->addChild('TxBytes', $arrStats['tx_bytes']); $device->addChild('Err', $arrStats['errs']); @@ -108,6 +150,12 @@ } } } + + /** + * generate the hardware information + * + * @access private + */ private function buildHardware() { $hardware = $this->xml->addChild('Hardware'); $cpu = $hardware->addChild('CPU'); @@ -117,63 +165,69 @@ $usb = $hardware->addChild('USB'); $arrSys = $this->sysinfo->cpu_info(); $arrBuf = finddups($this->sysinfo->pci()); - if (count($arrBuf)) { + if(count($arrBuf)) { for ($i = 0, $max = sizeof($arrBuf); $i < $max; $i++) { if ($arrBuf[$i]) { $tmp = $pci->addChild('Device'); - $tmp->addChild('Name', utf8_encode(trim(htmlspecialchars($arrBuf[$i])))); + $tmp->addChild('Name', $this->toUTF8($arrBuf[$i])); } } } $arrBuf = $this->sysinfo->ide(); - if (count($arrBuf)) { - foreach ($arrBuf as $strKey => $arrValue) { + if(count($arrBuf)) { + foreach($arrBuf as $strKey => $arrValue) { $tmp = $ide->addChild('Device'); - $tmp->addChild('Name', $strKey . ': ' . utf8_encode(trim(htmlspecialchars($arrValue['model'])))); - if (isset ($arrValue['capacity'])) { + $tmp->addChild('Name', $strKey . ': ' . $this->toUTF8($arrValue['model'])); + if(isset($arrValue['capacity'])) { $tmp->addChild('Capacity', $arrValue['capacity']); } } } $arrBuf = $this->sysinfo->scsi(); - if (count($arrBuf)) { - foreach ($arrBuf as $strKey => $arrValue) { + if(count($arrBuf)) { + foreach($arrBuf as $strKey => $arrValue) { $tmp = $scsi->addChild('Device'); - if ($strKey >= '0' && $strKey <= '9') { - $tmp->addChild('Name', utf8_encode(trim(htmlspecialchars($arrValue['model'])))); + if($strKey >= '0' && $strKey <= '9') { + $tmp->addChild('Name', $this->toUTF8($arrValue['model'])); } else { - $tmp->addChild('Name', $strKey . ': ' . utf8_encode(trim(htmlspecialchars($arrValue['model'])))); + $tmp->addChild('Name', $strKey . ': ' . $this->toUTF8($arrValue['model'])); } - if (isset ($arrrValue['capacity'])) { + if(isset ($arrrValue['capacity'])) { $tmp->addChild('Capacity', $arrValue['capacity']); } } } $arrBuf = finddups($this->sysinfo->usb()); - if (count($arrBuf)) { - for ($i = 0, $max = sizeof($arrBuf); $i < $max; $i++) { - if (trim($arrBuf[$i]) != "") { + if(count($arrBuf)) { + for($i = 0, $max = sizeof($arrBuf); $i < $max; $i++) { + if(trim($arrBuf[$i]) != "") { $tmp = $usb->addChild('Device'); - $tmp->addChild('Name', utf8_encode(trim(htmlspecialchars($arrBuf[$i])))); + $tmp->addChild('Name', $this->toUTF8($arrBuf[$i])); } } } $cpu->addChild('Number', $arrSys['cpus']); - $cpu->addChild('Model', utf8_encode(trim(htmlspecialchars($arrSys['model'])))); - if (isset ($arrSys['temp'])) { + $cpu->addChild('Model', $this->toUTF8($arrSys['model'])); + if(isset ($arrSys['temp'])) { $cpu->addChild('Cputemp', $arrSys['temp']); } $cpu->addChild('Cpuspeed', $arrSys['cpuspeed']); - if (isset ($arrSys['busspeed'])) { + if(isset ($arrSys['busspeed'])) { $cpu->addChild('Busspeed', $arrSys['busspeed']); } - if (isset ($arrSys['cache'])) { + if(isset ($arrSys['cache'])) { $cpu->addChild('Cache', $arrSys['cache']); } - if (isset ($arrSys['bogomips'])) { + if(isset ($arrSys['bogomips'])) { $cpu->addChild('Bogomips', $arrSys['bogomips']); } } + + /** + * generate the memory information + * + * @access private + */ private function buildMemory() { $arrMem = $this->sysinfo->memory(); $i = 0; @@ -202,7 +256,7 @@ $swapMount->addChild('MountPointID', $i++); $swapMount->addChild('Type', 'Swap'); $dev = $swapMount->addChild('Device'); - $dev->addChild('Name', utf8_encode(trim(htmlspecialchars($arrDevice['dev'])))); + $dev->addChild('Name', $this->toUTF8($arrDevice['dev'])); $swapMount->addChild('Percent', $arrDevice['percent']); $swapMount->addChild('Free', $arrDevice['free']); $swapMount->addChild('Used', $arrDevice['used']); @@ -210,103 +264,130 @@ } } } + + /** + * generate the filesysteminformation + * + * @access private + */ private function buildFilesystems() { $hideMounts = array (); $hideFstypes = array (); $hideDisks = array (); - if (PSI_HIDE_MOUNTS != "") { + if(PSI_HIDE_MOUNTS != "") { $hideMounts = explode(',', PSI_HIDE_MOUNTS); } - if (PSI_HIDE_FS_TYPES != "") { + if(PSI_HIDE_FS_TYPES != "") { $hideFstypes = explode(',', PSI_HIDE_FS_TYPES); } - if (PSI_HIDE_DISKS != "") { + if(PSI_HIDE_DISKS != "") { $hideDisks = explode(',', PSI_HIDE_DISKS); } $arrFs = $this->sysinfo->filesystems(); $fs = $this->xml->addChild('FileSystem'); - for ($i = 0, $max = sizeof($arrFs); $i < $max; $i++) { - if (!in_array($arrFs[$i]['mount'], $hideMounts, true) && !in_array($arrFs[$i]['fstype'], $hideFstypes, true) && !in_array($arrFs[$i]['disk'], $hideDisks, true)) { + for($i = 0, $max = sizeof($arrFs); $i < $max; $i++) { + if(!in_array($arrFs[$i]['mount'], $hideMounts, true) && !in_array($arrFs[$i]['fstype'], $hideFstypes, true) && !in_array($arrFs[$i]['disk'], $hideDisks, true)) { $mount = $fs->addChild('Mount'); $mount->addchild('MountPointID', $i); - if (PSI_SHOW_MOUNT_POINT === true) { - $mount->addchild('MountPoint', utf8_encode(trim(htmlspecialchars($arrFs[$i]['mount'])))); + if(PSI_SHOW_MOUNT_POINT === true) { + $mount->addchild('MountPoint', $this->toUTF8($arrFs[$i]['mount'])); } $mount->addchild('Type', $arrFs[$i]['fstype']); $dev = $mount->addchild('Device'); - $dev->addChild('Name', utf8_encode(trim(htmlspecialchars($arrFs[$i]['disk'])))); + $dev->addChild('Name', $this->toUTF8($arrFs[$i]['disk'])); $mount->addchild('Percent', $arrFs[$i]['percent']); $mount->addchild('Free', $arrFs[$i]['free']); $mount->addchild('Used', $arrFs[$i]['used']); $mount->addchild('Size', $arrFs[$i]['size']); - if (isset ($arrFs[$i]['options'])) { + if(isset ($arrFs[$i]['options'])) { $mount->addchild('MountOptions', $arrFs[$i]['options']); } - if (isset ($arrFs[$i]['inodes'])) { + if(isset ($arrFs[$i]['inodes'])) { $mount->addchild('Inodes', $arrFs[$i]['inodes']); } } } } + + /** + * generate the motherboard information + * + * @access private + */ private function buildMbinfo() { + $mbinfo_data = new mbinfo(); $mbinfo = $this->xml->addChild('MBinfo'); - $arrBuff = $this->mbinfo->temperature(); + $arrBuff = $mbinfo_data->temperature(); if (sizeof($arrBuff) > 0) { $temp = $mbinfo->addChild('Temperature'); foreach ($arrBuff as $arrValue) { $item = $temp->addChild('Item'); - $item->addChild('Label', utf8_encode(trim(htmlspecialchars($arrValue['label'])))); + $item->addChild('Label', $arrValue['label']); $item->addChild('Value', $arrValue['value']); $item->addChild('Limit', $arrValue['limit']); } } - $arrBuff = $this->mbinfo->fans(); + $arrBuff = $mbinfo_data->fans(); if (sizeof($arrBuff) > 0) { $fan = $mbinfo->addChild('Fans'); foreach ($arrBuff as $arrValue) { $item = $fan->addChild('Item'); - $item->addChild('Label', utf8_encode(trim(htmlspecialchars($arrValue['label'])))); + $item->addChild('Label', $this->toUTF8($arrValue['label'])); $item->addChild('Value', $arrValue['value']); $item->addChild('Min', $arrValue['min']); } } - $arrBuff = $this->mbinfo->voltage(); + $arrBuff = $mbinfo_data->voltage(); if (sizeof($arrBuff) > 0) { $volt = $mbinfo->addChild('Voltage'); foreach ($arrBuff as $arrValue) { $item = $volt->addChild('Item'); - $item->addChild('Label', utf8_encode(trim(htmlspecialchars($arrValue['label'])))); + $item->addChild('Label', $this->toUTF8($arrValue['label'])); $item->addChild('Value', $arrValue['value']); $item->addChild('Min', $arrValue['min']); $item->addChild('Max', $arrValue['max']); } } } + + /** + * generate the hddtemp information + * + * @access private + */ private function buildHddtemp() { - $arrBuf = $this->hddtemp->temperature(); + $hddtemp_data = new hddtemp(); + $arrBuf = $hddtemp_data->temperature(); $hddtemp = $this->xml->addChild('HDDTemp'); - for ($i = 0, $max = sizeof($arrBuf); $i < $max; $i++) { + for($i = 0, $max = sizeof($arrBuf); $i < $max; $i++) { $item = $hddtemp->addChild('Item'); - $item->addChild('Label', utf8_encode(trim(htmlspecialchars($arrBuf[$i]['label'])))); + $item->addChild('Label', $this->toUTF8($arrBuf[$i]['label'])); $item->addChild('Value', $arrBuf[$i]['value']); - $item->addChild('Model', utf8_encode(trim(htmlspecialchars($arrBuf[$i]['model'])))); + $item->addChild('Model', $this->toUTF8($arrBuf[$i]['model'])); } } + + /** + * generate the ups information + * + * @access private + */ private function buildUpsinfo() { - $arrBuf = $this->upsinfo->info(); - if (isset ($arrBuf) && !empty ($arrBuf)) { + $upsinfo_data = new upsinfo(); + $arrBuf = $upsinfo_data->info(); + if(isset($arrBuf) && !empty($arrBuf)) { $upsinfo = $this->xml->addChild('UPSinfo'); - for ($i = 0, $max = sizeof($arrBuf); $i < $max; $i++) { + for($i = 0, $max = sizeof($arrBuf); $i < $max; $i++) { $item = $upsinfo->addChild('Ups'); - $item->addChild('Name', utf8_encode(trim(htmlspecialchars($arrBuf[$i]['name'])))); - $item->addChild('Model', utf8_encode(trim(htmlspecialchars($arrBuf[$i]['model'])))); - $item->addChild('Mode', utf8_encode(trim(htmlspecialchars($arrBuf[$i]['mode'])))); - $item->addChild('StartTime', utf8_encode(trim(htmlspecialchars($arrBuf[$i]['start_time'])))); - $item->addChild('Status', utf8_encode(trim(htmlspecialchars($arrBuf[$i]['status'])))); - $item->addChild('UPSTemperature', utf8_encode(trim(htmlspecialchars($arrBuf[$i]['temperature'])))); + $item->addChild('Name', $this->toUTF8($arrBuf[$i]['name'])); + $item->addChild('Model', $this->toUTF8($arrBuf[$i]['model'])); + $item->addChild('Mode', $arrBuf[$i]['mode']); + $item->addChild('StartTime', $arrBuf[$i]['start_time']); + $item->addChild('Status', $this->toUTF8($arrBuf[$i]['status'])); + $item->addChild('UPSTemperature', $this->toUTF8($arrBuf[$i]['temperature'])); $item->addChild('OutagesCount', $arrBuf[$i]['outages_count']); - $item->addChild('LastOutage', utf8_encode(trim(htmlspecialchars($arrBuf[$i]['last_outage'])))); - $item->addChild('LastOutageFinish', utf8_encode(trim(htmlspecialchars($arrBuf[$i]['last_outage_finish'])))); + $item->addChild('LastOutage', $this->toUTF8($arrBuf[$i]['last_outage'])); + $item->addChild('LastOutageFinish', $this->toUTF8($arrBuf[$i]['last_outage_finish'])); $item->addChild('LineVoltage', $arrBuf[$i]['line_voltage']); $item->addChild('LoadPercent', $arrBuf[$i]['load_percent']); $item->addChild('BatteryVoltage', $arrBuf[$i]['battery_voltage']); @@ -315,6 +396,12 @@ } } } + + /** + * generate the xml document + * + * @access public + */ public function buildXml() { if (!$this->plugin_request || $this->complete_request) { $this->buildVitals(); @@ -335,14 +422,33 @@ $this->buildPlugins(); $this->errors->ErrorsAddToXML($this->xml); } + + /** + * print the xml content as xml document with the correct headers for webservers + * + * @access public + */ public function printXml() { header("Cache-Control: no-cache, must-revalidate\n"); header("Content-Type: text/xml\n\n"); echo $this->xml->asXML(); } + + /** + * get the xml content as string + * + * @access public + * @return string + */ public function getXml() { return $this->xml->asXML(); } + + /** + * include xml-trees of the plugins to the main xml + * + * @access private + */ private function buildPlugins() { $pluginroot = $this->xml->addChild("Plugins"); if ($this->plugin_request || $this->complete_request) { @@ -355,11 +461,30 @@ } } } + + /** + * append a xml-tree to another xml-tree + * + * @access private + * @var SimpleXMLElement parent to which should be appended + * @var SimpleXMLElement child that should be appended + */ private function combinexml(SimpleXMLElement $parent, SimpleXMLElement $new_child) { $node1 = dom_import_simplexml($parent); $dom_sxe = dom_import_simplexml($new_child); $node2 = $node1->ownerDocument->importNode($dom_sxe, true); $node1->appendChild($node2); } + + /** + * convert a string into an UTF-8 string + * + * @access private + * @var string string to convert + * @return string UTF-8 string + */ + private function toUTF8($str) { + return htmlspecialchars(mb_detect_encoding($str) == 'UTF-8' ? trim($str) : trim(mb_convert_encoding($str, 'UTF-8'))); + } } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <big...@us...> - 2009-04-18 11:54:05
|
Revision: 193 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=193&view=rev Author: bigmichi1 Date: 2009-04-18 11:54:03 +0000 (Sat, 18 Apr 2009) Log Message: ----------- fix showing swap usage on Darwin Modified Paths: -------------- includes/os/class.Darwin.inc.php includes/xml/class.XML.inc.php Modified: includes/os/class.Darwin.inc.php =================================================================== --- includes/os/class.Darwin.inc.php 2009-04-18 11:36:37 UTC (rev 192) +++ includes/os/class.Darwin.inc.php 2009-04-18 11:54:03 UTC (rev 193) @@ -195,22 +195,22 @@ $results['ram']['used'] = $results['ram']['total']-$results['ram']['free']; $results['ram']['cached'] = 0; $results['ram']['percent'] = round(($results['ram']['used']*100)/$results['ram']['total']); - if (CommonFunctions::executeProgram('swapinfo', '-k', $pstat, PSI_DEBUG)) { - $lines = split("\n", $pstat); - for ($i = 0, $max = sizeof($lines); $i < $max; $i++) { - $ar_buf = preg_split("/\s+/", $lines[$i], 6); - if ($i == 0) { - $results['swap']['total'] = 0; - $results['swap']['used'] = 0; - $results['swap']['free'] = 0; - $results['swap']['percent'] = 0; - } else { - $results['swap']['total'] = $results['swap']['total']+$ar_buf[1]*1024; - $results['swap']['used'] = $results['swap']['used']+$ar_buf[2]*1024; - $results['swap']['free'] = $results['swap']['free']+$ar_buf[3]*1024; - $results['swap']['percent'] = ceil(($results['swap']['used']*100)/(($results['swap']['total'] <= 0)?1:$results['swap']['total'])); - } - } + + + $swapBuff = ""; + if (CommonFunctions::executeProgram('sysctl', 'vm.swapusage | colrm 1 22', $swapBuff, PSI_DEBUG)) { + $swap1 = split('M', $swapBuff); + $swap2 = split('=', $swap1[1]); + $swap3 = split('=', $swap1[2]); + + $results['swap']['total'] = $swap1[0] * 1024 * 1024; + $results['swap']['used'] = $swap2[1] * 1024 * 1024; + $results['swap']['free'] = $swap3[1] * 1024 * 1024; + if($results['swap']['total'] <= 0) { + $results['swap']['percent'] = 0; + } else { + $results['swap']['percent'] = round(($results['swap']['used'] * 100) / $results['swap']['total']); + } } return $results; } Modified: includes/xml/class.XML.inc.php =================================================================== --- includes/xml/class.XML.inc.php 2009-04-18 11:36:37 UTC (rev 192) +++ includes/xml/class.XML.inc.php 2009-04-18 11:54:03 UTC (rev 193) @@ -258,7 +258,7 @@ } $swap = $this->_xml->addChild('Swap'); $swapDev = $this->_xml->addChild('Swapdevices'); - if (count($arrMem['devswap']) > 0) { + if (count($arrMem['swap']) > 0) { $swap->addChild('Free', $arrMem['swap']['free']); $swap->addChild('Used', $arrMem['swap']['used']); $swap->addChild('Total', $arrMem['swap']['total']); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <big...@us...> - 2009-05-25 09:00:46
|
Revision: 219 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=219&view=rev Author: bigmichi1 Date: 2009-05-25 09:00:39 +0000 (Mon, 25 May 2009) Log Message: ----------- get os specific encoding for converting xml to utf8 Modified Paths: -------------- includes/interface/class.PSI_Interface_OS.inc.php includes/os/class.OS.inc.php includes/os/class.WINNT.inc.php includes/xml/class.XML.inc.php Modified: includes/interface/class.PSI_Interface_OS.inc.php =================================================================== --- includes/interface/class.PSI_Interface_OS.inc.php 2009-05-25 08:56:02 UTC (rev 218) +++ includes/interface/class.PSI_Interface_OS.inc.php 2009-05-25 09:00:39 UTC (rev 219) @@ -1,4 +1,4 @@ -<?php +<?php /** * Basic OS Functions * @@ -33,35 +33,35 @@ * @return string */ function vhostname(); - + /** * IP of the Virtual Host Name * * @return string */ function vipaddr(); - + /** * Canonical Host Name * * @return string */ function chostname(); - + /** * IP of the Canonical Host Name * * @return string */ function ipaddr(); - + /** * Kernel Version * * @return string */ function kernel(); - + /** * UpTime * time the system is running @@ -69,14 +69,14 @@ * @return integer */ function uptime(); - + /** * Number of Users * * @return integer */ function users(); - + /** * Processor Load * optionally create a loadbar @@ -86,75 +86,82 @@ * @return array */ function loadavg($bar = false); - + /** * CPU information * * @return array */ function cpuinfo(); - + /** * PCI devices * * @return array */ function pci(); - + /** * IDE devices * * @return array */ function ide(); - + /** * SCSI devices * * @return array */ function scsi(); - + /** * USB devices * * @return array */ function usb(); - + /** * Network devices * * @return array */ function network(); - + /** * Physical memory information and Swap Space information * * @return array */ function memory(); - + /** * filesystem information * * @return array */ function filesystems(); - + /** * Distribution * * @return string */ function distro(); - + /** * Distribution Icon * * @return string */ function distroicon(); + + /** + * get a special encoding from os where phpsysinfo is running + * + * @return string + */ + function getEncoding(); } -?> \ No newline at end of file +?> Modified: includes/os/class.OS.inc.php =================================================================== --- includes/os/class.OS.inc.php 2009-05-25 08:56:02 UTC (rev 218) +++ includes/os/class.OS.inc.php 2009-05-25 09:00:39 UTC (rev 219) @@ -23,7 +23,8 @@ * @version Release: 3.0 * @link http://phpsysinfo.sourceforge.net */ -abstract class OS implements PSI_Interface_OS { +abstract class OS implements PSI_Interface_OS +{ /** * object for error handling * @@ -37,7 +38,18 @@ public function __construct() { $this->error = Error::singleton(); - } + } + + /** + * get os specific encoding + * + * @see PSI_Interface_OS::getEncoding() + * + * @return string + */ + function getEncoding() + { + return null; + } } - ?> Modified: includes/os/class.WINNT.inc.php =================================================================== --- includes/os/class.WINNT.inc.php 2009-05-25 08:56:02 UTC (rev 218) +++ includes/os/class.WINNT.inc.php 2009-05-25 09:00:39 UTC (rev 219) @@ -25,7 +25,8 @@ * @version Release: 3.0 * @link http://phpsysinfo.sourceforge.net */ -class WINNT extends OS { +class WINNT extends OS +{ /** * holds the COM object that we pull all the WMI data from * @@ -52,6 +53,7 @@ */ public function __construct() { + parent::__construct(); // don't set this params for local connection, it will not work $strHostname = ''; $strUser = ''; @@ -63,7 +65,7 @@ $this->_wmi = $objLocator->ConnectServer(); } else { $this->_wmi = $objLocator->ConnectServer($strHostname, 'rootcimv2', $strHostname.'\\'.$strUser, $strPassword); - } + } $this->_getCodeSet(); } @@ -105,16 +107,18 @@ } else { if (in_array($propItem->Name, $strValue)) { $arrInstance[$propItem->Name] = trim($value); - } - } - } + } + } + } $arrData[] = $arrInstance; - } - } catch(Exception $e) { + } + } + catch(Exception $e) { if (PSI_DEBUG) { $this->error->addError($e->getCode(), $e->getMessage()); - } - } return $arrData; + } + } + return $arrData; } /** @@ -128,13 +132,13 @@ { if ( empty($this->_wmidevices)) { $this->_wmidevices = $this->_getWMI('Win32_PnPEntity', array('Name', 'PNPDeviceID')); - } + } $list = array(); foreach ($this->_wmidevices as $device) { if (substr($device['PNPDeviceID'], 0, strpos($device['PNPDeviceID'], "\\") + 1) == ($strType."\\")) { - $list[] = mb_convert_encoding($device['Name'], 'utf-8', 'windows-'.$this->_charset); - } - } + $list[] = $device['Name']; + } + } return $list; } @@ -147,7 +151,7 @@ { if (!($result = getenv('SERVER_NAME'))) { $result = 'N.A.'; - } + } return $result; } @@ -175,7 +179,7 @@ return gethostbyaddr($ip); } else { return 'Unknown'; - } + } } /** @@ -202,7 +206,7 @@ $result = $buffer[0]['Version']; if ($buffer[0]['ServicePackMajorVersion'] > 0) { $result .= ' SP'.$buffer[0]['ServicePackMajorVersion']; - } + } return $result; } @@ -247,8 +251,8 @@ foreach ($buffer as $process) { if (strtoupper($process['Caption']) == strtoupper('explorer.exe')) { $users++; - } - } + } + } return $users; } @@ -266,10 +270,10 @@ $cpuload = array(); for ($i = 0, $cnt_buffer = count($buffer); $i < $cnt_buffer; $i++) { $cpuload['avg'][] = $buffer[$i]['LoadPercentage']; - } + } if ($bar) { $cpuload['cpupercent'] = array_sum($cpuload['avg']) / count($buffer); - } + } return $cpuload; } @@ -287,12 +291,12 @@ $results['cpus'] += $cpu['NumberOfCores']; } else { $results['cpus']++; - } + } $results['model'] = $cpu['Name']; $results['cache'] = $cpu['L2CacheSize'] * 1024; $results['cpuspeed'] = $cpu['CurrentClockSpeed']; $results['busspeed'] = $cpu['ExtClock']; - } + } return $results; } @@ -318,7 +322,7 @@ $ide = array(); foreach ($buffer as $device) { $ide[]['model'] = $device; - } + } return $ide; } @@ -355,7 +359,7 @@ $results = array(); $buffer = $this->_getWMI('Win32_PerfRawData_Tcpip_NetworkInterface'); foreach ($buffer as $device) { - $dev_name = mb_convert_encoding($device['Name'], 'utf-8', 'windows-'.$this->_charset); + $dev_name = $device['Name']; // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_perfrawdata_tcpip_networkinterface.asp // there is a possible bug in the wmi interfaceabout uint32 and uint64: http://www.ureader.com/message/1244948.aspx, so that // magative numbers would occour, try to calculate the nagative value from total - positive number @@ -363,15 +367,15 @@ $results[$dev_name]['tx_bytes'] = $device['BytesTotalPersec'] - $device['BytesReceivedPersec']; } else { $results[$dev_name]['tx_bytes'] = $device['BytesSentPersec']; - } + } if ($device['BytesReceivedPersec'] < 0) { $results[$dev_name]['rx_bytes'] = $device['BytesTotalPersec'] - $device['BytesSentPersec']; } else { $results[$dev_name]['rx_bytes'] = $device['BytesReceivedPersec']; - } + } $results[$dev_name]['errs'] = $device['PacketsReceivedErrors']; $results[$dev_name]['drop'] = $device['PacketsReceivedDiscarded']; - } + } return $results; } @@ -414,15 +418,15 @@ $results['swap']['free'] += $results['devswap'][$k]['free']; // Iterate the counter by one. $k += 1; - } + } // Calculate the percent used of the total swap space. if ($k > 0) { if ($results['swap']['total'] <= 0) { $results['swap']['percent'] = 0; } else { $results['swap']['percent'] = ceil($results['swap']['used'] / $results['swap']['total'] * 100); - } - } + } + } return $results; } @@ -459,14 +463,14 @@ $results[$k]['percent'] = 0; } else { $results[$k]['percent'] = ceil($results[$k]['used'] / $results[$k]['size'] * 100); - } + } $results[$k]['fstype'] = $filesystem['FileSystem']; $results[$k]['disk'] = $typearray[$filesystem['DriveType']]; if ($filesystem['MediaType'] != "" && $filesystem['DriveType'] == 2) { $results[$k]['disk'] .= " (".$floppyarray[$filesystem['MediaType']].")"; - } + } $k += 1; - } + } return $results; } @@ -493,8 +497,20 @@ $icon = 'vista.png'; } else { $icon = 'xp.png'; - } + } return $icon; - } + } + + /** + * get os specific encoding + * + * @see OS::getEncoding() + * + * @return string + */ + function getEncoding() + { + return $this->_charset; + } } ?> Modified: includes/xml/class.XML.inc.php =================================================================== --- includes/xml/class.XML.inc.php 2009-05-25 08:56:02 UTC (rev 218) +++ includes/xml/class.XML.inc.php 2009-05-25 09:00:39 UTC (rev 219) @@ -1,4 +1,4 @@ -<?php +<?php /** * XML Generation class * @@ -31,49 +31,49 @@ * @var Sysinfo */ private $_sysinfo; - + /** * xml object with the xml content * * @var SimpleXMLElement */ private $_xml; - + /** * object for error handling * * @var Error */ private $_errors; - + /** * array with all enabled plugins (name) * * @var array */ private $_plugins; - + /** * plugin name if pluginrequest * * @var string */ private $_plugin = ''; - + /** * generate a xml for a plugin or for the main app * * @var boolean */ private $_plugin_request = false; - + /** * generate the entire xml with all plugins or only a part of the xml (main or plugin) * * @var boolean */ private $_complete_request = false; - + /** * doing some initial tasks * - generate the xml structure with the right header elements @@ -107,7 +107,7 @@ $this->_plugins = CommonFunctions::getPlugins(); $this->_xmlbody(); } - + /** * generate common information * @@ -123,22 +123,22 @@ $vitals = $this->_xml->addChild('Vitals'); if (PSI_USE_VHOST === true) { $vitals->addChild('Hostname', $this->_toUTF8(htmlspecialchars($this->_sysinfo->vhostname()))); - $vitals->addChild('IPAddr', $this->_sysinfo->vipaddr()); + $vitals->addChild('IPAddr', $this->_toUTF8($this->_sysinfo->vipaddr())); } else { $vitals->addChild('Hostname', $this->_toUTF8(htmlspecialchars($this->_sysinfo->chostname()))); - $vitals->addChild('IPAddr', $this->_sysinfo->ipaddr()); + $vitals->addChild('IPAddr', $this->_toUTF8($this->_sysinfo->ipaddr())); } $vitals->addChild('Kernel', $this->_toUTF8(htmlspecialchars($this->_sysinfo->kernel()))); $vitals->addChild('Distro', $this->_toUTF8(htmlspecialchars($this->_sysinfo->distro()))); $vitals->addChild('Distroicon', $this->_toUTF8(htmlspecialchars($this->_sysinfo->distroicon()))); - $vitals->addChild('Uptime', $this->_sysinfo->uptime()); - $vitals->addChild('Users', $this->_sysinfo->users()); - $vitals->addChild('LoadAvg', $strLoadavg); - if ( isset ($arrBuf['cpupercent'])) { - $vitals->addChild('CPULoad', round($arrBuf['cpupercent'], 2)); + $vitals->addChild('Uptime', $this->_toUTF8($this->_sysinfo->uptime())); + $vitals->addChild('Users', $this->_toUTF8($this->_sysinfo->users())); + $vitals->addChild('LoadAvg', $this->_toUTF8($strLoadavg)); + if (isset($arrBuf['cpupercent'])) { + $vitals->addChild('CPULoad', $this->_toUTF8(round($arrBuf['cpupercent'], 2))); } } - + /** * generate the network information * @@ -153,14 +153,14 @@ if (!in_array(trim($strDev), $hideDevices)) { $device = $network->addChild('NetDevice'); $device->addChild('Name', $this->_toUTF8(htmlspecialchars($strDev))); - $device->addChild('RxBytes', $arrStats['rx_bytes']); - $device->addChild('TxBytes', $arrStats['tx_bytes']); - $device->addChild('Err', $arrStats['errs']); - $device->addChild('Drops', $arrStats['drop']); + $device->addChild('RxBytes', $this->_toUTF8($arrStats['rx_bytes'])); + $device->addChild('TxBytes', $this->_toUTF8($arrStats['tx_bytes'])); + $device->addChild('Err', $this->_toUTF8($arrStats['errs'])); + $device->addChild('Drops', $this->_toUTF8($arrStats['drop'])); } } } - + /** * generate the hardware information * @@ -189,8 +189,8 @@ foreach ($arrBuf as $strKey=>$arrValue) { $tmp = $ide->addChild('Device'); $tmp->addChild('Name', $strKey.': '.$this->_toUTF8($arrValue['model'])); - if ( isset ($arrValue['capacity'])) { - $tmp->addChild('Capacity', $arrValue['capacity']); + if (isset($arrValue['capacity'])) { + $tmp->addChild('Capacity', $this->_toUTF8($arrValue['capacity'])); } } } @@ -201,10 +201,10 @@ if ($strKey >= '0' && $strKey <= '9') { $tmp->addChild('Name', $this->_toUTF8($arrValue['model'])); } else { - $tmp->addChild('Name', $strKey.': '.$this->_toUTF8($arrValue['model'])); + $tmp->addChild('Name', $this->_toUTF8($strKey.': '.$arrValue['model'])); } - if ( isset ($arrrValue['capacity'])) { - $tmp->addChild('Capacity', $arrValue['capacity']); + if (isset($arrrValue['capacity'])) { + $tmp->addChild('Capacity', $this->_toUTF8($arrValue['capacity'])); } } } @@ -219,21 +219,21 @@ } $cpu->addChild('Number', $arrSys['cpus']); $cpu->addChild('Model', $this->_toUTF8($arrSys['model'])); - if ( isset ($arrSys['temp'])) { - $cpu->addChild('Cputemp', $arrSys['temp']); + if (isset($arrSys['temp'])) { + $cpu->addChild('Cputemp', $this->_toUTF8($arrSys['temp'])); } - $cpu->addChild('Cpuspeed', $arrSys['cpuspeed']); - if ( isset ($arrSys['busspeed'])) { - $cpu->addChild('Busspeed', $arrSys['busspeed']); + $cpu->addChild('Cpuspeed', $this->_toUTF8($arrSys['cpuspeed'])); + if (isset($arrSys['busspeed'])) { + $cpu->addChild('Busspeed', $this->_toUTF8($arrSys['busspeed'])); } - if ( isset ($arrSys['cache'])) { - $cpu->addChild('Cache', $arrSys['cache']); + if (isset($arrSys['cache'])) { + $cpu->addChild('Cache', $this->_toUTF8($arrSys['cache'])); } - if ( isset ($arrSys['bogomips'])) { - $cpu->addChild('Bogomips', $arrSys['bogomips']); + if (isset($arrSys['bogomips'])) { + $cpu->addChild('Bogomips', $this->_toUTF8($arrSys['bogomips'])); } } - + /** * generate the memory information * @@ -248,35 +248,35 @@ $memory->addChild('Used', $arrMem['ram']['used']); $memory->addChild('Total', $arrMem['ram']['total']); $memory->addChild('Percent', $arrMem['ram']['percent']); - if ( isset ($arrMem['ram']['app'])) { - $memory->addChild('App', $arrMem['ram']['app']); - $memory->addChild('AppPercent', $arrMem['ram']['app_percent']); - $memory->addChild('Buffers', $arrMem['ram']['buffers']); - $memory->addChild('BuffersPercent', $arrMem['ram']['buffers_percent']); - $memory->addChild('Cached', $arrMem['ram']['cached']); - $memory->addChild('CachedPercent', $arrMem['ram']['cached_percent']); + if (isset($arrMem['ram']['app'])) { + $memory->addChild('App', $this->_toUTF8($arrMem['ram']['app'])); + $memory->addChild('AppPercent', $this->_toUTF8($arrMem['ram']['app_percent'])); + $memory->addChild('Buffers', $this->_toUTF8($arrMem['ram']['buffers'])); + $memory->addChild('BuffersPercent', $this->_toUTF8($arrMem['ram']['buffers_percent'])); + $memory->addChild('Cached', $this->_toUTF8($arrMem['ram']['cached'])); + $memory->addChild('CachedPercent', $this->_toUTF8($arrMem['ram']['cached_percent'])); } $swap = $this->_xml->addChild('Swap'); $swapDev = $this->_xml->addChild('Swapdevices'); if (count($arrMem['swap']) > 0) { - $swap->addChild('Free', $arrMem['swap']['free']); - $swap->addChild('Used', $arrMem['swap']['used']); - $swap->addChild('Total', $arrMem['swap']['total']); - $swap->addChild('Percent', $arrMem['swap']['percent']); + $swap->addChild('Free', $this->_toUTF8($arrMem['swap']['free'])); + $swap->addChild('Used', $this->_toUTF8($arrMem['swap']['used'])); + $swap->addChild('Total', $this->_toUTF8($arrMem['swap']['total'])); + $swap->addChild('Percent', $this->_toUTF8($arrMem['swap']['percent'])); foreach ($arrMem['devswap'] as $arrDevice) { $swapMount = $swapDev->addChild('Mount'); - $swapMount->addChild('MountPointID', $i++); - $swapMount->addChild('Type', 'Swap'); + $swapMount->addChild('MountPointID', $this->_toUTF8($i++)); + $swapMount->addChild('Type', $this->_toUTF8('Swap')); $dev = $swapMount->addChild('Device'); $dev->addChild('Name', $this->_toUTF8($arrDevice['dev'])); - $swapMount->addChild('Percent', $arrDevice['percent']); - $swapMount->addChild('Free', $arrDevice['free']); - $swapMount->addChild('Used', $arrDevice['used']); - $swapMount->addChild('Size', $arrDevice['total']); + $swapMount->addChild('Percent', $this->_toUTF8($arrDevice['percent'])); + $swapMount->addChild('Free', $this->_toUTF8($arrDevice['free'])); + $swapMount->addChild('Used', $this->_toUTF8($arrDevice['used'])); + $swapMount->addChild('Size', $this->_toUTF8($arrDevice['total'])); } } } - + /** * generate the filesysteminformation * @@ -284,9 +284,9 @@ */ private function _buildFilesystems() { - $hideMounts = array (); - $hideFstypes = array (); - $hideDisks = array (); + $hideMounts = array(); + $hideFstypes = array(); + $hideDisks = array(); if (PSI_HIDE_MOUNTS != "") { $hideMounts = explode(',', PSI_HIDE_MOUNTS); } @@ -301,27 +301,27 @@ for ($i = 0, $max = sizeof($arrFs); $i < $max; $i++) { if (!in_array($arrFs[$i]['mount'], $hideMounts, true) && !in_array($arrFs[$i]['fstype'], $hideFstypes, true) && !in_array($arrFs[$i]['disk'], $hideDisks, true)) { $mount = $fs->addChild('Mount'); - $mount->addchild('MountPointID', $i); + $mount->addchild('MountPointID', $this->_toUTF8($i)); if (PSI_SHOW_MOUNT_POINT === true) { $mount->addchild('MountPoint', $this->_toUTF8($arrFs[$i]['mount'])); } - $mount->addchild('Type', $arrFs[$i]['fstype']); + $mount->addchild('Type', $this->_toUTF8($arrFs[$i]['fstype'])); $dev = $mount->addchild('Device'); $dev->addChild('Name', $this->_toUTF8($arrFs[$i]['disk'])); - $mount->addchild('Percent', $arrFs[$i]['percent']); - $mount->addchild('Free', $arrFs[$i]['free']); - $mount->addchild('Used', $arrFs[$i]['used']); - $mount->addchild('Size', $arrFs[$i]['size']); - if ( isset ($arrFs[$i]['options'])) { - $mount->addchild('MountOptions', $arrFs[$i]['options']); + $mount->addchild('Percent', $this->_toUTF8($arrFs[$i]['percent'])); + $mount->addchild('Free', $this->_toUTF8($arrFs[$i]['free'])); + $mount->addchild('Used', $this->_toUTF8($arrFs[$i]['used'])); + $mount->addchild('Size', $this->_toUTF8($arrFs[$i]['size'])); + if (isset($arrFs[$i]['options'])) { + $mount->addchild('MountOptions', $this->_toUTF8($arrFs[$i]['options'])); } - if ( isset ($arrFs[$i]['inodes'])) { - $mount->addchild('Inodes', $arrFs[$i]['inodes']); + if (isset($arrFs[$i]['inodes'])) { + $mount->addchild('Inodes', $this->_toUTF8($arrFs[$i]['inodes'])); } } } } - + /** * generate the motherboard information * @@ -337,9 +337,9 @@ $temp = $mbinfo->addChild('Temperature'); foreach ($arrBuff as $arrValue) { $item = $temp->addChild('Item'); - $item->addChild('Label', $arrValue['label']); - $item->addChild('Value', $arrValue['value']); - $item->addChild('Limit', $arrValue['limit']); + $item->addChild('Label', $this->_toUTF8($arrValue['label'])); + $item->addChild('Value', $this->_toUTF8($arrValue['value'])); + $item->addChild('Limit', $this->_toUTF8($arrValue['limit'])); } } $arrBuff = $mbinfo_data->fans(); @@ -348,8 +348,8 @@ foreach ($arrBuff as $arrValue) { $item = $fan->addChild('Item'); $item->addChild('Label', $this->_toUTF8($arrValue['label'])); - $item->addChild('Value', $arrValue['value']); - $item->addChild('Min', $arrValue['min']); + $item->addChild('Value', $this->_toUTF8($arrValue['value'])); + $item->addChild('Min', $this->_toUTF8($arrValue['min'])); } } $arrBuff = $mbinfo_data->voltage(); @@ -358,13 +358,13 @@ foreach ($arrBuff as $arrValue) { $item = $volt->addChild('Item'); $item->addChild('Label', $this->_toUTF8($arrValue['label'])); - $item->addChild('Value', $arrValue['value']); - $item->addChild('Min', $arrValue['min']); - $item->addChild('Max', $arrValue['max']); + $item->addChild('Value', $this->_toUTF8($arrValue['value'])); + $item->addChild('Min', $this->_toUTF8($arrValue['min'])); + $item->addChild('Max', $this->_toUTF8($arrValue['max'])); } } } - + /** * generate the hddtemp information * @@ -378,11 +378,11 @@ for ($i = 0, $max = sizeof($arrBuf); $i < $max; $i++) { $item = $hddtemp->addChild('Item'); $item->addChild('Label', $this->_toUTF8($arrBuf[$i]['label'])); - $item->addChild('Value', $arrBuf[$i]['value']); + $item->addChild('Value', $this->_toUTF8($arrBuf[$i]['value'])); $item->addChild('Model', $this->_toUTF8($arrBuf[$i]['model'])); } } - + /** * generate the ups information * @@ -393,28 +393,28 @@ $upsinfoclass = PSI_UPS_PROGRAM; $upsinfo_data = new $upsinfoclass(); $arrBuf = $upsinfo_data->info(); - if ( isset ($arrBuf) && ! empty($arrBuf)) { + if (isset($arrBuf) && ! empty($arrBuf)) { $upsinfo = $this->_xml->addChild('UPSinfo'); for ($i = 0, $max = sizeof($arrBuf); $i < $max; $i++) { $item = $upsinfo->addChild('Ups'); $item->addChild('Name', $this->_toUTF8($arrBuf[$i]['name'])); $item->addChild('Model', $this->_toUTF8($arrBuf[$i]['model'])); - $item->addChild('Mode', $arrBuf[$i]['mode']); - $item->addChild('StartTime', $arrBuf[$i]['start_time']); + $item->addChild('Mode', $this->_toUTF8($arrBuf[$i]['mode'])); + $item->addChild('StartTime', $this->_toUTF8($arrBuf[$i]['start_time'])); $item->addChild('Status', $this->_toUTF8($arrBuf[$i]['status'])); $item->addChild('UPSTemperature', $this->_toUTF8($arrBuf[$i]['temperature'])); - $item->addChild('OutagesCount', $arrBuf[$i]['outages_count']); + $item->addChild('OutagesCount', $this->_toUTF8($arrBuf[$i]['outages_count'])); $item->addChild('LastOutage', $this->_toUTF8($arrBuf[$i]['last_outage'])); $item->addChild('LastOutageFinish', $this->_toUTF8($arrBuf[$i]['last_outage_finish'])); - $item->addChild('LineVoltage', $arrBuf[$i]['line_voltage']); - $item->addChild('LoadPercent', $arrBuf[$i]['load_percent']); - $item->addChild('BatteryVoltage', $arrBuf[$i]['battery_voltage']); - $item->addChild('BatteryChargePercent', $arrBuf[$i]['battery_charge_percent']); - $item->addChild('TimeLeftMinutes', $arrBuf[$i]['time_left_minutes']); + $item->addChild('LineVoltage', $this->_toUTF8($arrBuf[$i]['line_voltage'])); + $item->addChild('LoadPercent', $this->_toUTF8($arrBuf[$i]['load_percent'])); + $item->addChild('BatteryVoltage', $this->_toUTF8($arrBuf[$i]['battery_voltage'])); + $item->addChild('BatteryChargePercent', $this->_toUTF8($arrBuf[$i]['battery_charge_percent'])); + $item->addChild('TimeLeftMinutes', $this->_toUTF8($arrBuf[$i]['time_left_minutes'])); } } } - + /** * generate the xml document * @@ -443,7 +443,7 @@ } $this->_errors->errorsAddToXML($this->_xml); } - + /** * get the xml object * @@ -454,7 +454,7 @@ $this->_buildXml(); return $this->_xml; } - + /** * include xml-trees of the plugins to the main xml * @@ -478,7 +478,7 @@ } } } - + /** * append a xml-tree to another xml-tree * @@ -494,7 +494,7 @@ $node2 = $node1->ownerDocument->importNode($dom_sxe, true); $node1->appendChild($node2); } - + /** * convert a string into an UTF-8 string * @@ -504,13 +504,21 @@ */ private function _toUTF8($str) { - if (mb_detect_encoding($str) == 'UTF-8') { + if (mb_detect_encoding($str) == 'UTF-8' || !defined('PSI_CONVERT_FROM_CHARSET')) { return trim($str); } else { - return mb_convert_encoding(trim($str), 'UTF-8'); + if (defined('PSI_CONVERT_FROM_CHARSET')) { + return mb_convert_encoding(trim($str), 'UTF-8', PSI_CONVERT_FROM_CHARSET); + } else { + if ($this->_sysinfo->getEncoding() != null) { + return mb_convert_encoding(trim($str), 'UTF-8', $this->_sysinfo->getEncoding()); + } else { + return mb_convert_encoding(trim($str), 'UTF-8'); + } + } } } - + /** * build the xml structure where the content can be inserted * @@ -528,20 +536,20 @@ $generation->addAttribute('version', CommonFunctions::PSI_VERSION); $generation->addAttribute('timestamp', time()); $options = $this->_xml->addChild('Options'); - $options->addChild('tempFormat', defined('PSI_TEMP_FORMAT')?PSI_TEMP_FORMAT:'c'); - $options->addChild('byteFormat', defined('PSI_BYTE_FORMAT')?PSI_BYTE_FORMAT:'auto_binary'); - $options->addChild('refresh', defined('PSI_REFRESH')?PSI_REFRESH:0); - $options->addChild('showPickListTemplate', defined('PSI_SHOW_PICKLIST_TEMPLATE')?PSI_SHOW_PICKLIST_TEMPLATE:false); - $options->addChild('showPickListLang', defined('PSI_SHOW_PICKLIST_LANG')?PSI_SHOW_PICKLIST_LANG:false); + $options->addChild('tempFormat', $this->_toUTF8(defined('PSI_TEMP_FORMAT') ? PSI_TEMP_FORMAT : 'c')); + $options->addChild('byteFormat', $this->_toUTF8(defined('PSI_BYTE_FORMAT') ? PSI_BYTE_FORMAT : 'auto_binary')); + $options->addChild('refresh', $this->_toUTF8(defined('PSI_REFRESH') ? PSI_REFRESH : 0)); + $options->addChild('showPickListTemplate', $this->_toUTF8(defined('PSI_SHOW_PICKLIST_TEMPLATE') ? PSI_SHOW_PICKLIST_TEMPLATE : false)); + $options->addChild('showPickListLang', $this->_toUTF8(defined('PSI_SHOW_PICKLIST_LANG') ? PSI_SHOW_PICKLIST_LANG : false)); $plug = $options->addChild('Used_Plugins'); if ($this->_complete_request && count($this->_plugins) > 0) { foreach ($this->_plugins as $plugin) { - $plug->addChild('Plugin', $plugin); + $plug->addChild('Plugin', $this->_toUTF8($plugin)); } } elseif ($this->_plugin_request && count($this->_plugins) > 0) { - $plug->addChild('Plugin', $this->_plugin); + $plug->addChild('Plugin', $this->_toUTF8($this->_plugin)); } - + } } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jac...@us...> - 2009-05-29 16:18:40
|
Revision: 225 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=225&view=rev Author: jacky672 Date: 2009-05-29 16:18:39 +0000 (Fri, 29 May 2009) Log Message: ----------- Fix Windows encoding Modified Paths: -------------- includes/os/class.WINNT.inc.php includes/xml/class.XML.inc.php Modified: includes/os/class.WINNT.inc.php =================================================================== --- includes/os/class.WINNT.inc.php 2009-05-28 06:41:11 UTC (rev 224) +++ includes/os/class.WINNT.inc.php 2009-05-29 16:18:39 UTC (rev 225) @@ -77,7 +77,7 @@ private function _getCodeSet() { $buffer = $this->_getWMI('Win32_OperatingSystem', array('CodeSet')); - $this->_charset = $buffer[0]['CodeSet']; + $this->_charset = 'windows-'.$buffer[0]['CodeSet']; } /** Modified: includes/xml/class.XML.inc.php =================================================================== --- includes/xml/class.XML.inc.php 2009-05-28 06:41:11 UTC (rev 224) +++ includes/xml/class.XML.inc.php 2009-05-29 16:18:39 UTC (rev 225) @@ -504,7 +504,7 @@ */ private function _toUTF8($str) { - if (mb_detect_encoding($str) == 'UTF-8' || !defined('PSI_CONVERT_FROM_CHARSET')) { + if (mb_detect_encoding($str) == 'UTF-8' && !defined('PSI_CONVERT_FROM_CHARSET')) { return trim($str); } else { if (defined('PSI_CONVERT_FROM_CHARSET')) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <big...@us...> - 2009-06-09 10:34:26
|
Revision: 243 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=243&view=rev Author: bigmichi1 Date: 2009-06-09 10:34:19 +0000 (Tue, 09 Jun 2009) Log Message: ----------- release RC8 Modified Paths: -------------- ChangeLog README README_PLUGIN includes/class.CommonFunctions.inc.php Modified: ChangeLog =================================================================== --- ChangeLog 2009-06-09 06:36:24 UTC (rev 242) +++ ChangeLog 2009-06-09 10:34:19 UTC (rev 243) @@ -1,6 +1,6 @@ $Id$ -phpSysInfo 3.0 +phpSysInfo 3.0 RC-8, 2009-06-09 - [FIX] Fixed Notice Array to String conversion for scsi and ide - [FIX] Fixed UTF8 encoding for Windows Devices Modified: README =================================================================== --- README 2009-06-09 06:36:24 UTC (rev 242) +++ README 2009-06-09 10:34:19 UTC (rev 243) @@ -1,4 +1,4 @@ -phpSysInfo 3.0-RC7 - http://phpsysinfo.sourceforge.net/ +phpSysInfo 3.0-RC8 - http://phpsysinfo.sourceforge.net/ Copyright (c), 1999-2008, Uriah Welcome (pre...@us...) Copyright (c), 1999-2009, Michael Cramer (big...@us...) Modified: README_PLUGIN =================================================================== --- README_PLUGIN 2009-06-09 06:36:24 UTC (rev 242) +++ README_PLUGIN 2009-06-09 10:34:19 UTC (rev 243) @@ -1,4 +1,4 @@ -phpSysInfo 3.0-RC7 - http://phpsysinfo.sourceforge.net/ +phpSysInfo 3.0-RC8 - http://phpsysinfo.sourceforge.net/ Document written by Michael Cramer (bigmichi1 at sourceforge.net) !!Please read if you want to develop a plugin to understand our plugin system!! Modified: includes/class.CommonFunctions.inc.php =================================================================== --- includes/class.CommonFunctions.inc.php 2009-06-09 06:36:24 UTC (rev 242) +++ includes/class.CommonFunctions.inc.php 2009-06-09 10:34:19 UTC (rev 243) @@ -30,7 +30,7 @@ * * @var string */ - const PSI_VERSION = '3.0-rc7'; + const PSI_VERSION = '3.0-RC8'; /** * Find a system program, do also path checking when not running on WINNT This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <big...@us...> - 2009-06-24 06:19:17
|
Revision: 269 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=269&view=rev Author: bigmichi1 Date: 2009-06-24 06:18:12 +0000 (Wed, 24 Jun 2009) Log Message: ----------- change error output in xml to cdata Modified Paths: -------------- includes/error/class.Error.inc.php includes/xml/class.XML.inc.php Modified: includes/error/class.Error.inc.php =================================================================== --- includes/error/class.Error.inc.php 2009-06-24 05:31:03 UTC (rev 268) +++ includes/error/class.Error.inc.php 2009-06-24 06:18:12 UTC (rev 269) @@ -161,36 +161,36 @@ $dom = new DOMDocument(); $root = $dom->createElement("phpsysinfo"); $dom->appendChild($root); - $xml = simplexml_import_dom($dom); + $xml = new SimpleXMLExtended(simplexml_import_dom($dom), $encoding); $generation = $xml->addChild('Generation'); $generation->addAttribute('version', PSI_VERSION); $generation->addAttribute('timestamp', time()); - if ($this->_errors > 0) { - foreach ($this->_arrErrorList as $arrLine) { - $error = $xml->addChild('Error'); - $error->addChild('Function', $arrLine['command']); - $error->addChild('Message', $arrLine['message']); - } + $xmlerr = $xml->addChild("Errors"); + foreach ($this->_arrErrorList as $arrLine) { + $error = $xmlerr->addCData('Error', $arrLine['message']); + $error->addAttribute('Function', $arrLine['command']); } - return $xml->asXML(); + return $xml->getSimpleXmlElement()->asXML(); } /** * add the errors to an existing xml document * - * @param SimpleXMLObject &$xml reference existing simplexmlobject to which errors are added if present + * @param String $encoding encoding * - * @return void + * @return SimpleXmlElement */ - public function errorsAddToXML(&$xml) + public function errorsAddToXML($encoding) { - if ($this->_errors > 0) { - $xmlerr = $xml->addChild('Errors'); - foreach ($this->_arrErrorList as $arrLine) { - $error = $xmlerr->addChild('Error'); - $error->addChild('Function', utf8_encode(trim(htmlspecialchars($arrLine['command'])))); - $error->addChild('Message', utf8_encode(trim(htmlspecialchars($arrLine['message'])))); - } + $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->addAttribute('Function', $arrLine['command']); } + return $xmlerr->getSimpleXmlElement(); } /** * check if errors exists Modified: includes/xml/class.XML.inc.php =================================================================== --- includes/xml/class.XML.inc.php 2009-06-24 05:31:03 UTC (rev 268) +++ includes/xml/class.XML.inc.php 2009-06-24 06:18:12 UTC (rev 269) @@ -432,7 +432,7 @@ $this->_buildUpsinfo(); } $this->_buildPlugins(); - $this->_errors->errorsAddToXML($this->_xml); + $this->_xml->combinexml($this->_errors->errorsAddToXML($this->_sysinfo->getEncoding())); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jac...@us...> - 2009-07-26 05:41:32
|
Revision: 309 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=309&view=rev Author: jacky672 Date: 2009-07-26 05:41:23 +0000 (Sun, 26 Jul 2009) Log Message: ----------- [FIX] Fixed Bug [ 2826271 ] LMSensors XML attributes error Modified Paths: -------------- ChangeLog includes/mb/class.LMSensors.inc.php includes/xml/class.XML.inc.php Modified: ChangeLog =================================================================== --- ChangeLog 2009-07-21 06:59:50 UTC (rev 308) +++ ChangeLog 2009-07-26 05:41:23 UTC (rev 309) @@ -7,6 +7,7 @@ - [FIX] Fixed Bug [ 2804624 ] typos in config.php.new - [FIX] Fixed Bug [ 2811367 ] xml.php: prints warning in output - [FIX] Fixed bug [ 2820488 ] XML Parsing Error with E_ALL enabled + - [FIX] Fixed Bug [ 2826271 ] LMSensors XML attributes error - [ADD] Added FR [ 2804580 ] Memory Usage Display - [ADD] Added FR [ 2784341 ] Multi core CPU load Modified: includes/mb/class.LMSensors.inc.php =================================================================== --- includes/mb/class.LMSensors.inc.php 2009-07-21 06:59:50 UTC (rev 308) +++ includes/mb/class.LMSensors.inc.php 2009-07-26 05:41:23 UTC (rev 309) @@ -71,12 +71,12 @@ $ar_buf = array(); foreach ($this->_lines as $line) { $data = array(); - if (ereg("(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)", $line, $data)) { + if (preg_match("/(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)/", $line, $data)) { ; - } elseif (ereg("(.*):(.*)\((.*)=(.*)\)(.*)", $line, $data)) { + } elseif (preg_match("/(.*):(.*)\((.*)=(.*)\)(.*)/", $line, $data)) { ; } else { - (ereg("(.*):(.*)", $line, $data)); + (preg_match("/(.*):(.*)/", $line, $data)); } if (count($data) > 1) { $temp = substr(trim($data[2]), -1); @@ -89,14 +89,14 @@ } foreach ($ar_buf as $line) { $data = array(); - if (ereg("(.*):(.*).C[ ]*\((.*)=(.*).C,(.*)=(.*).C\)(.*)\)", $line, $data)) { + if (preg_match("/(.*):(.*).C[ ]*\((.*)=(.*).C,(.*)=(.*).C\)(.*)\)/", $line, $data)) { ; - } elseif (ereg("(.*):(.*).C[ ]*\((.*)=(.*).C,(.*)=(.*).C\)(.*)", $line, $data)) { + } elseif (preg_match("/(.*):(.*).C[ ]*\((.*)=(.*).C,(.*)=(.*).C\)(.*)/", $line, $data)) { ; - } elseif (ereg("(.*):(.*).C[ ]*\((.*)=(.*).C\)(.*)", $line, $data)) { + } elseif (preg_match("/(.*):(.*).C[ ]*\((.*)=(.*).C\)(.*)/", $line, $data)) { ; } else { - (ereg("(.*):(.*).C", $line, $data)); + (preg_match("/(.*):(.*).C/", $line, $data)); } foreach ($data as $key=>$value) { if (preg_match("/^\+?([0-9\.]+).?$/", trim($value), $newvalue)) { @@ -136,12 +136,12 @@ $ar_buf = array(); foreach ($this->_lines as $line) { $data = array(); - if (ereg("(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)", $line, $data)) { + if (preg_match("/(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)/", $line, $data)) { ; - } elseif (ereg("(.*):(.*)\((.*)=(.*)\)(.*)", $line, $data)) { + } elseif (preg_match("/(.*):(.*)\((.*)=(.*)\)(.*)/", $line, $data)) { ; } else { - ereg("(.*):(.*)", $line, $data); + preg_match("/(.*):(.*)/", $line, $data); } if (count($data) > 1) { $temp = preg_split("/ /", trim($data[2])); @@ -158,14 +158,14 @@ } foreach ($ar_buf as $line) { $data = array(); - if (ereg("(.*):(.*) RPM \((.*)=(.*) RPM,(.*)=(.*)\)(.*)\)", $line, $data)) { + if (preg_match("/(.*):(.*) RPM \((.*)=(.*) RPM,(.*)=(.*)\)(.*)\)/", $line, $data)) { ; - } elseif (ereg("(.*):(.*) RPM \((.*)=(.*) RPM,(.*)=(.*)\)(.*)", $line, $data)) { + } elseif (preg_match("/(.*):(.*) RPM \((.*)=(.*) RPM,(.*)=(.*)\)(.*)/", $line, $data)) { ; - } elseif (ereg("(.*):(.*) RPM \((.*)=(.*) RPM\)(.*)", $line, $data)) { + } elseif (preg_match("/(.*):(.*) RPM \((.*)=(.*) RPM\)(.*)/", $line, $data)) { ; } else { - ereg("(.*):(.*) RPM", $line, $data); + preg_match("(.*):(.*) RPM", $line, $data); } $dev = new SensorDevice(); $dev->setName(trim($data[1])); @@ -187,10 +187,10 @@ $ar_buf = array(); foreach ($this->_lines as $line) { $data = array(); - if (ereg("(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)", $line, $data)) { + if (preg_match("/(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)/", $line, $data)) { ; } else { - ereg("(.*):(.*)", $line, $data); + preg_match("/(.*):(.*)/", $line, $data); } if (count($data) > 1) { $temp = preg_split("/ /", trim($data[2])); @@ -207,12 +207,12 @@ } foreach ($ar_buf as $line) { $data = array(); - if (ereg("(.*):(.*) V \((.*)=(.*) V,(.*)=(.*) V\)(.*)\)", $line, $data)) { + if (preg_match("/(.*)\:(.*) V \((.*)=(.*) V,(.*)=(.*) V\)(.*)\)/", $line, $data)) { ; - } elseif (ereg("(.*):(.*) V \((.*)=(.*) V,(.*)=(.*) V\)(.*)", $line, $data)) { + } elseif (preg_match("/(.*):(.*) V \((.*)=(.*) V,(.*)=(.*) V\)(.*)/", $line, $data)) { ; } else { - ereg("(.*):(.*) V$", $line, $data); + preg_match("/(.*):(.*) V$/", $line, $data); } foreach ($data as $key=>$value) { if (preg_match("/^\+?([0-9\.]+)$/", trim($value), $newvalue)) { Modified: includes/xml/class.XML.inc.php =================================================================== --- includes/xml/class.XML.inc.php 2009-07-21 06:59:50 UTC (rev 308) +++ includes/xml/class.XML.inc.php 2009-07-26 05:41:23 UTC (rev 309) @@ -329,7 +329,7 @@ $item = $temp->addChild('Item'); $item->addAttribute('Label', $dev->getName()); $item->addAttribute('Value', $dev->getValue()); - $item->addAttribute('Limit', $dev->getMax()); + $item->addAttribute('Max', $dev->getMax()); } } if (PSI_HDDTEMP) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <big...@us...> - 2009-11-18 08:39:25
|
Revision: 342 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=342&view=rev Author: bigmichi1 Date: 2009-11-18 08:39:15 +0000 (Wed, 18 Nov 2009) Log Message: ----------- 3.0 release Modified Paths: -------------- README README_PLUGIN includes/class.CommonFunctions.inc.php Modified: README =================================================================== --- README 2009-10-26 07:29:51 UTC (rev 341) +++ README 2009-11-18 08:39:15 UTC (rev 342) @@ -1,4 +1,4 @@ -phpSysInfo 3.0-RC9 - http://phpsysinfo.sourceforge.net/ +phpSysInfo 3.0 - http://phpsysinfo.sourceforge.net/ Copyright (c), 1999-2008, Uriah Welcome (pre...@us...) Copyright (c), 1999-2009, Michael Cramer (big...@us...) Modified: README_PLUGIN =================================================================== --- README_PLUGIN 2009-10-26 07:29:51 UTC (rev 341) +++ README_PLUGIN 2009-11-18 08:39:15 UTC (rev 342) @@ -1,4 +1,4 @@ -phpSysInfo 3.0-RC9 - http://phpsysinfo.sourceforge.net/ +phpSysInfo 3.0 - http://phpsysinfo.sourceforge.net/ Document written by Michael Cramer (bigmichi1 at sourceforge.net) !!Please read if you want to develop a plugin to understand our plugin system!! Modified: includes/class.CommonFunctions.inc.php =================================================================== --- includes/class.CommonFunctions.inc.php 2009-10-26 07:29:51 UTC (rev 341) +++ includes/class.CommonFunctions.inc.php 2009-11-18 08:39:15 UTC (rev 342) @@ -30,7 +30,7 @@ * * @var string */ - const PSI_VERSION = '3.0-RC9'; + const PSI_VERSION = '3.0'; /** * Find a system program, do also path checking when not running on WINNT This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jac...@us...> - 2010-02-07 09:51:03
|
Revision: 362 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=362&view=rev Author: jacky672 Date: 2010-02-07 09:50:57 +0000 (Sun, 07 Feb 2010) Log Message: ----------- 3.0.3 release Modified Paths: -------------- includes/class.CommonFunctions.inc.php includes/xml/class.XML.inc.php Modified: includes/class.CommonFunctions.inc.php =================================================================== --- includes/class.CommonFunctions.inc.php 2010-01-31 11:32:30 UTC (rev 361) +++ includes/class.CommonFunctions.inc.php 2010-02-07 09:50:57 UTC (rev 362) @@ -30,7 +30,7 @@ * * @var string */ - const PSI_VERSION = '3.0.2'; + const PSI_VERSION = '3.0.3'; /** * Find a system program, do also path checking when not running on WINNT Modified: includes/xml/class.XML.inc.php =================================================================== --- includes/xml/class.XML.inc.php 2010-01-31 11:32:30 UTC (rev 361) +++ includes/xml/class.XML.inc.php 2010-02-07 09:50:57 UTC (rev 362) @@ -273,11 +273,11 @@ $mount->addAttribute('Used', $dev->getUsed()); $mount->addAttribute('Total', $dev->getTotal()); $mount->addAttribute('Percent', $dev->getPercentUsed()); - if (PSI_SHOW_MOUNT_OPTION === true) { + if (PSI_SHOW_MOUNT_OPTION === true) { if ($dev->getOptions() !== null) { $mount->addAttribute('MountOptions', $dev->getOptions()); } - } + } if ($dev->getPercentInodesUsed() !== null) { $mount->addAttribute('Inodes', $dev->getPercentInodesUsed()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Big...@us...> - 2009-01-15 14:01:26
|
Revision: 108 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=108&view=rev Author: BigMichi1 Date: 2009-01-15 14:01:17 +0000 (Thu, 15 Jan 2009) Log Message: ----------- Fixed Bug [ 1744664 ] unreachable mounted fs added a timeout to the fgets() method Modified Paths: -------------- ChangeLog includes/common_functions.php Modified: ChangeLog =================================================================== --- ChangeLog 2009-01-15 13:28:08 UTC (rev 107) +++ ChangeLog 2009-01-15 14:01:17 UTC (rev 108) @@ -19,6 +19,7 @@ - [FIX] Fixed hidenetworkinterfaces config option - [FIX] Fixed Bug [ 1987494 ] clicking on "Physical Memory" - [FIX] Fixed Bug [ 2005665 ] Re: [ 1956114 ] BSD with zero swap space + - [FIX] Fixed Bug [ 1744664 ] unreachable mounted fs - [FIX] Some fixes for recent /proc/mdstat files, also new sample file for tests - [FIX] Fedore distro must be read before Redhat - [FIX] Stop JavaScript alert popup when XML loading errors occurs Modified: includes/common_functions.php =================================================================== --- includes/common_functions.php 2009-01-15 13:28:08 UTC (rev 107) +++ includes/common_functions.php 2009-01-15 14:01:17 UTC (rev 108) @@ -29,14 +29,7 @@ // Find a system program. Do path checking function find_program($strProgram) { global $addpaths; - $arrPath = array ( - '/bin', - '/sbin', - '/usr/bin', - '/usr/sbin', - '/usr/local/bin', - '/usr/local/sbin' - ); + $arrPath = array ( '/bin', '/sbin', '/usr/bin', '/usr/sbin', '/usr/local/bin', '/usr/local/sbin' ); if (PSI_ADD_PATHS !== false) { $addpaths = explode(',', PSI_ADD_PATHS); $arrPath = array_merge($arrPath, $addpaths); @@ -80,30 +73,23 @@ } } } - // no proc_open() below php 4.3 $descriptorspec = array ( - 0 => array ( - "pipe", - "r" - ), // stdin is a pipe that the child will read from - 1 => array ( - "pipe", - "w" - ), // stdout is a pipe that the child will write to - 2 => array ( - "pipe", - "w" - ) // stderr is a pipe that the child will write to - + 0 => array ( "pipe", "r" ), // stdin is a pipe that the child will read from + 1 => array ( "pipe", "w" ), // stdout is a pipe that the child will write to + 2 => array ( "pipe", "w" ) // stderr is a pipe that the child will write to ); $process = proc_open($strProgram . " " . $strArgs, $descriptorspec, $pipes); if (is_resource($process)) { while (!feof($pipes[1])) { - $strBuffer .= fgets($pipes[1], 1024); + if(($line = fgetsPending($pipes[1], 1024)) !== false) { + $strBuffer .= $line; + } } fclose($pipes[1]); while (!feof($pipes[2])) { - $strError .= fgets($pipes[2], 1024); + if(($line = fgetsPending($pipes[2], 1024)) !== false) { + $strError .= $line; + } } fclose($pipes[2]); } @@ -148,7 +134,9 @@ if (file_exists($strFileName)) { if ($fd = fopen($strFileName, 'r')) { while (!feof($fd)) { - $strFile .= fgets($fd, $intBytes); + if(($line = fgetsPending($fd, $intBytes)) !== false) { + $strFile .= $line; + } if ($intLines <= $intCurLine && $intLines != 0) { break; } else { @@ -197,12 +185,7 @@ } function __autoload($class_name) { - $dirs = array ( - '/plugins/' . $class_name . '/', - '/includes/', - '/includes/interfaces/', - '/includes/os/' - ); + $dirs = array ( '/plugins/' . $class_name . '/', '/includes/', '/includes/interfaces/', '/includes/os/' ); foreach ($dirs as $dir) { if (file_exists(APP_ROOT . $dir . 'class.' . $class_name . '.inc.php')) { require_once (APP_ROOT . $dir . 'class.' . $class_name . '.inc.php'); @@ -212,25 +195,17 @@ } /** - * Check for the SimpleXML fuction. + * Check for the php extension * - * We need that extension for almost everything, + * We need that extensions for almost everything, * even our error class needs this to output the errors. - * Because of that this function willreturn a hard coded + * Because of that this function will return a hard coded * XML string (with headers) if the SimpleXML extension isn't loaded. * Then it will terminate the script. * See bug #1787137 - * - * @access public - * */ function checkForExtensions() { - $extensions = array ( - 'simplexml', - 'pcre', - 'xml', - 'xsl' - ); + $extensions = array ('simplexml', 'pcre', 'xml', 'xsl'); $text = ""; $error = false; $text .= "<?xml version='1.0'?>\n"; @@ -251,4 +226,17 @@ die(); } } + +/** + * fgetsPending( $in,$tv_sec ) - Get a pending line of data from stream $in, waiting a maximum of $tv_sec seconds + * @param + * @param integer seconds to wait + */ +function fgetsPending(&$in, $bytes = 1024, $tv_sec=10) { + if ( stream_select($read = array($in), $write=NULL, $except=NULL, $tv_sec) ) { + return fgets($in, $bytes); + } else { + return false; + } +} ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Big...@us...> - 2009-01-22 12:54:37
|
Revision: 121 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=121&view=rev Author: BigMichi1 Date: 2009-01-22 12:54:30 +0000 (Thu, 22 Jan 2009) Log Message: ----------- Fixed Bug [ 1870546 ] Localized device names on Russian Windows comment class file Modified Paths: -------------- ChangeLog includes/common_functions.php includes/os/class.WINNT.inc.php Modified: ChangeLog =================================================================== --- ChangeLog 2009-01-22 09:13:54 UTC (rev 120) +++ ChangeLog 2009-01-22 12:54:30 UTC (rev 121) @@ -21,6 +21,7 @@ - [FIX] Fixed Bug [ 1987494 ] clicking on "Physical Memory" - [FIX] Fixed Bug [ 2005665 ] Re: [ 1956114 ] BSD with zero swap space - [FIX] Fixed Bug [ 1744664 ] unreachable mounted fs + - [FIX] Fixed Bug [ 1870546 ] Localized device names on Russian Windows - [FIX] Some fixes for recent /proc/mdstat files, also new sample file for tests - [FIX] Fedore distro must be read before Redhat - [FIX] Stop JavaScript alert popup when XML loading errors occurs Modified: includes/common_functions.php =================================================================== --- includes/common_functions.php 2009-01-22 09:13:54 UTC (rev 120) +++ includes/common_functions.php 2009-01-22 12:54:30 UTC (rev 121) @@ -18,7 +18,7 @@ /** * Find a system program, do also path checking when not running on WINNT * on WINNT we simply return the name with the exe extension to the program name - * + * * @param string name of the program * @return string complete path and name of the program */ @@ -46,7 +46,7 @@ * does very crude pipe checking. you need ' | ' for it to work * ie $program = execute_program('netstat', '-anp | grep LIST'); * NOT $program = execute_program('netstat', '-anp|grep LIST'); - * + * * @param string name of the program * @param string arguments to the program * @param string output of the command @@ -105,7 +105,7 @@ /** * find duplicate entrys and count them, show this value befor the duplicated name - * + * * @param array source array that should be checked for duplicated names * @return array array with duplicate entries removed and a appended value, how many times the entry has appeared */ @@ -126,10 +126,10 @@ /** * read a file and return the content as a string - * + * * @param string name of the file which should be read * @param string content of the file (reference) - * @param integer control how many lines should be read + * @param integer control how many lines should be read * @param integer control how many bytes of each line should be read * @param boolean en- or disables the reporting of errors which should be logged * @return boolean command successfull or not @@ -227,6 +227,9 @@ $text .= "<?xml version='1.0'?>\n"; $text .= "<phpsysinfo>\n"; $text .= " <Error>\n"; + if(PHP_OS == 'WINNT') { + $extensions[] = 'iconv'; + } foreach ($extensions as $extension) { if (!extension_loaded($extension)) { $text .= " <Function>checkForExtensions</Function>\n"; Modified: includes/os/class.WINNT.inc.php =================================================================== --- includes/os/class.WINNT.inc.php 2009-01-22 09:13:54 UTC (rev 120) +++ includes/os/class.WINNT.inc.php 2009-01-22 12:54:30 UTC (rev 121) @@ -1,271 +1,389 @@ <?php -/*************************************************************************** - * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * - * http://phpsysinfo.sourceforge.net/ * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ -// -// $Id$ -// +/** + * WINNT System Class + * + * @license http://opensource.org/licenses/gpl-2.0.php + * @package psi_os + */ + +/** + * WINNT sysinfo class + * get all the required information from WINNT systems + * information are retrieved through the WMI interface + * + * @author Michael Cramer (Big...@us...) + * @version $Id$ + * @copyright Copyright (C) 2008 by phpSysInfo + * @package psi_os + */ class sysinfo implements psi_os_interface { - // $wmi holds the COM object that we pull all the WMI data from + /** + * holds the COM object that we pull all the WMI data from + * @var Object + */ private $wmi; - // Error singleton + + /** + * object for error handling + * @var Error + */ private $error; - // $wmidevices holds all devices, which are in the system + + /** + * holds all devices, which are in the system + * @var array + */ private $wmidevices; - // setting for debugging + + /** + * controls if debugging is turned on or off, value is defined in the main config.php + * @var boolean + */ private $debug = PSI_DEBUG; - // this constructor initialis the $wmi object + + /** + * store language encoding of the system to convert some output to utf-8 + * @var string + */ + private $charset = ""; + + /** + * build the global Error object and create the WMI connection + * + * @access public + */ public function __construct() { $this->error = Error :: singleton(); + // don't set this params for local connection, it will not work $strHostname = ''; $strUser = ''; $strPassword = ''; + // initialize the wmi object - $objLocator = new COM("WbemScripting.SWbemLocator"); - if ($strHostname == "") { + $objLocator = new COM('WbemScripting.SWbemLocator'); + if($strHostname == "") { $this->wmi = $objLocator->ConnectServer(); } else { - $this->wmi = $objLocator->ConnectServer($strHostname, "rootcimv2", "$strHostname\$strUser", $strPassword); + $this->wmi = $objLocator->ConnectServer($strHostname, 'rootcimv2', $strHostname . '\\' . $strUser, $strPassword); } + $this->getCodeSet(); } - // private function for getting a list of values in the specified context, optionally filter this list, based on the list from second parameter - private function GetWMI($strClass, $strValue = array ()) { - $arrData = array (); + + /** + * store the codepage of the os for converting some strings to utf-8 + * + * @access private + */ + private function getCodeSet() { + $buffer = $this->GetWMI('Win32_OperatingSystem', array('CodeSet')); + $this->charset = $buffer[0]['CodeSet']; + } + + /** + * function for getting a list of values in the specified context + * optionally filter this list, based on the list from second parameter + * + * @access private + * @var string name of the class where the values are stored + * @var array filter out only needed values, if not set all values of the class are returned + * @return array content of the class stored in an array + */ + private function GetWMI($strClass, $strValue = array()) { + $arrData = array(); $value = ""; try { $objWEBM = $this->wmi->Get($strClass); $arrProp = $objWEBM->Properties_; $arrWEBMCol = $objWEBM->Instances_(); - foreach ($arrWEBMCol as $objItem) { - @ reset($arrProp); - $arrInstance = array (); - foreach ($arrProp as $propItem) { - eval ("\$value = \$objItem->" . $propItem->Name . ";"); - if (empty ($strValue)) { + foreach($arrWEBMCol as $objItem) { + @reset($arrProp); + $arrInstance = array(); + foreach($arrProp as $propItem) { + eval("\$value = \$objItem->" . $propItem->Name . ";"); + if(empty($strValue)) { $arrInstance[$propItem->Name] = trim($value); } else { - if (in_array($propItem->Name, $strValue)) { + if(in_array($propItem->Name, $strValue)) { $arrInstance[$propItem->Name] = trim($value); } } } $arrData[] = $arrInstance; } - } catch (Exception $e) { - if ($this->debug) { + } catch(Exception $e) { + if($this->debug) { $this->error->addError($e->getCode(), $e->getMessage()); } } return $arrData; } - // private function for getting different device types from the system - private function _devicelist($strType) { - if (empty ($this->wmidevices)) { - $this->wmidevices = $this->GetWMI("Win32_PnPEntity", array ( - "Name", - "PNPDeviceID" - )); + + /** + * retrieve different device types from the system based on selector + * + * @access private + * @var string type of the devices that should be returned + * @return array list of devices of the specified type + */ + private function devicelist($strType) { + if(empty($this->wmidevices)) { + $this->wmidevices = $this->GetWMI('Win32_PnPEntity', array('Name', 'PNPDeviceID')); } - $list = array (); - foreach ($this->wmidevices as $device) { - if (substr($device["PNPDeviceID"], 0, strpos($device["PNPDeviceID"], "\\") + 1) == ($strType . "\\")) { - $list[] = $device["Name"]; + $list = array(); + foreach($this->wmidevices as $device) { + if(substr($device['PNPDeviceID'], 0, strpos($device['PNPDeviceID'], "\\") + 1) == ($strType . "\\")) { + $list[] = iconv('windows-' . $this->charset, 'utf-8', $device['Name']); } } return $list; } - // get our apache SERVER_NAME or vhost + + /** + * Virtual Host Name + * + * @access public + * @return string + */ public function vhostname() { - if (!($result = getenv('SERVER_NAME'))) { + if(!($result = getenv('SERVER_NAME'))) { $result = 'N.A.'; } return $result; } - // get the IP address of our vhost name + + /** + * IP of the Virtual Host Name + * + * @access public + * @return string + */ public function vip_addr() { return gethostbyname($this->vhostname()); } - // get our canonical hostname + + /** + * Canonical Host Name + * + @access public + @return string + */ public function chostname() { - $buffer = $this->GetWMI("Win32_ComputerSystem", array ( - "Name" - )); - $result = $buffer[0]["Name"]; + $buffer = $this->GetWMI('Win32_ComputerSystem', array('Name')); + $result = $buffer[0]['Name']; $ip = gethostbyname($result); - if ($ip != $result) { + if($ip != $result) { return gethostbyaddr($ip); } else { return 'Unknown'; } } - // get the IP address of our canonical hostname + + /** + * IP of the Canonical Host Name + * + * @access public + * @return string + */ public function ip_addr() { - $buffer = $this->GetWMI("Win32_ComputerSystem", array ( - "Name" - )); - $result = $buffer[0]["Name"]; + $buffer = $this->GetWMI('Win32_ComputerSystem', array('Name')); + $result = $buffer[0]['Name']; return gethostbyname($result); } + + /** + * Windows Version + * includes also ServicePack Version if installed + * + * @access public + * @return string + */ public function kernel() { - $buffer = $this->GetWMI("Win32_OperatingSystem", array ( - "Version", - "ServicePackMajorVersion" - )); - $result = $buffer[0]["Version"]; - if ($buffer[0]["ServicePackMajorVersion"] > 0) { - $result .= " SP" . $buffer[0]["ServicePackMajorVersion"]; + $buffer = $this->GetWMI('Win32_OperatingSystem', array('Version', 'ServicePackMajorVersion')); + $result = $buffer[0]['Version']; + if($buffer[0]['ServicePackMajorVersion'] > 0) { + $result .= ' SP' . $buffer[0]['ServicePackMajorVersion']; } return $result; } - // get the time the system is running + + /** + * UpTime + * time the system is running + * + * @access public + * @return integer + */ public function uptime() { $result = 0; - date_default_timezone_set("UTC"); - $buffer = $this->GetWMI("Win32_OperatingSystem", array ( - "LastBootUpTime", - "LocalDateTime" - )); - $byear = intval(substr($buffer[0]["LastBootUpTime"], 0, 4)); - $bmonth = intval(substr($buffer[0]["LastBootUpTime"], 4, 2)); - $bday = intval(substr($buffer[0]["LastBootUpTime"], 6, 2)); - $bhour = intval(substr($buffer[0]["LastBootUpTime"], 8, 2)); - $bminute = intval(substr($buffer[0]["LastBootUpTime"], 10, 2)); - $bseconds = intval(substr($buffer[0]["LastBootUpTime"], 12, 2)); - $lyear = intval(substr($buffer[0]["LocalDateTime"], 0, 4)); - $lmonth = intval(substr($buffer[0]["LocalDateTime"], 4, 2)); - $lday = intval(substr($buffer[0]["LocalDateTime"], 6, 2)); - $lhour = intval(substr($buffer[0]["LocalDateTime"], 8, 2)); - $lminute = intval(substr($buffer[0]["LocalDateTime"], 10, 2)); - $lseconds = intval(substr($buffer[0]["LocalDateTime"], 12, 2)); + date_default_timezone_set('UTC'); + $buffer = $this->GetWMI('Win32_OperatingSystem', array('LastBootUpTime', 'LocalDateTime')); + $byear = intval(substr($buffer[0]['LastBootUpTime'], 0, 4)); + $bmonth = intval(substr($buffer[0]['LastBootUpTime'], 4, 2)); + $bday = intval(substr($buffer[0]['LastBootUpTime'], 6, 2)); + $bhour = intval(substr($buffer[0]['LastBootUpTime'], 8, 2)); + $bminute = intval(substr($buffer[0]['LastBootUpTime'], 10, 2)); + $bseconds = intval(substr($buffer[0]['LastBootUpTime'], 12, 2)); + $lyear = intval(substr($buffer[0]['LocalDateTime'], 0, 4)); + $lmonth = intval(substr($buffer[0]['LocalDateTime'], 4, 2)); + $lday = intval(substr($buffer[0]['LocalDateTime'], 6, 2)); + $lhour = intval(substr($buffer[0]['LocalDateTime'], 8, 2)); + $lminute = intval(substr($buffer[0]['LocalDateTime'], 10, 2)); + $lseconds = intval(substr($buffer[0]['LocalDateTime'], 12, 2)); $boottime = mktime($bhour, $bminute, $bseconds, $bmonth, $bday, $byear); $localtime = mktime($lhour, $lminute, $lseconds, $lmonth, $lday, $lyear); $result = $localtime - $boottime; return $result; } - // count the users, which are logged in + + /** + * Number of Users + * + * @access public + * @return integer + */ public function users() { $users = 0; - $buffer = $this->GetWMI("Win32_Process", array ( - "Caption" - )); - foreach ($buffer as $process) { - if (strtoupper($process["Caption"]) == strtoupper("explorer.exe")) { + $buffer = $this->GetWMI('Win32_Process', array('Caption')); + foreach($buffer as $process) { + if(strtoupper($process['Caption']) == strtoupper('explorer.exe')) { $users++; } } return $users; } - // get the load of the processors + + /** + * Processor Load + * optionally create a loadbar + * + * @access public + * @var boolean include a bar + * @return array + */ public function loadavg($bar = false) { - $buffer = $this->GetWMI("Win32_Processor", array ( - "LoadPercentage" - )); - $cpuload = array (); - for ($i = 0; $i < count($buffer); $i++) { - $cpuload['avg'][] = $buffer[$i]["LoadPercentage"]; + $buffer = $this->GetWMI('Win32_Processor', array('LoadPercentage')); + $cpuload = array(); + for($i = 0; $i < count($buffer); $i++) { + $cpuload['avg'][] = $buffer[$i]['LoadPercentage']; } - if ($bar) { + if($bar) { $cpuload['cpupercent'] = array_sum($cpuload['avg']) / count($buffer); } return $cpuload; } - // get some informations about the cpu's + + /** + * CPU information + * + * @access public + * @return array + */ public function cpu_info() { - $buffer = $this->GetWMI("Win32_Processor", array ( - "Name", - "L2CacheSize", - "CurrentClockSpeed", - "ExtClock", - "NumberOfCores" - )); - $results["cpus"] = 0; - foreach ($buffer as $cpu) { - if (isset ($cpu["NumberOfCores"])) { - $results["cpus"] += $cpu["NumberOfCores"]; + $buffer = $this->GetWMI('Win32_Processor', array('Name', 'L2CacheSize', 'CurrentClockSpeed', 'ExtClock', 'NumberOfCores')); + $results['cpus'] = 0; + foreach($buffer as $cpu) { + if(isset($cpu['NumberOfCores'])) { + $results['cpus'] += $cpu['NumberOfCores']; } else { - $results["cpus"]++; + $results['cpus']++; } - $results["model"] = $cpu["Name"]; - $results["cache"] = $cpu["L2CacheSize"]; - $results["cpuspeed"] = $cpu["CurrentClockSpeed"]; - $results["busspeed"] = $cpu["ExtClock"]; + $results['model'] = $cpu['Name']; + $results['cache'] = $cpu['L2CacheSize']; + $results['cpuspeed'] = $cpu['CurrentClockSpeed']; + $results['busspeed'] = $cpu['ExtClock']; } return $results; } - // get the pci devices from the system + + /** + * PCI devices + * + * @access public + * @return array + */ public function pci() { - $pci = $this->_devicelist("PCI"); + $pci = $this->devicelist('PCI'); return $pci; } - // get the ide devices from the system + + /** + * IDE devices + * + * @access public + * @return array + */ public function ide() { - $buffer = $this->_devicelist("IDE"); - $ide = array (); - foreach ($buffer as $device) { + $buffer = $this->devicelist('IDE'); + $ide = array(); + foreach($buffer as $device) { $ide[]['model'] = $device; } return $ide; } - // get the scsi devices from the system + + /** + * SCSI devices + * + * @access public + * @return array + */ public function scsi() { - $scsi = $this->_devicelist("SCSI"); + $scsi = $this->devicelist('SCSI'); return $scsi; } - // get the usb devices from the system + + /** + * USB devices + * + * @access public + * @return array + */ public function usb() { - $usb = $this->_devicelist("USB"); + $usb = $this->devicelist('USB'); return $usb; } - // get the netowrk devices and rx/tx bytes + + /** + * Network devices + * includes also rx/tx bytes + * + * @access public + * @return array + */ public function network() { - $results = array (); - $buffer = $this->GetWMI("Win32_PerfRawData_Tcpip_NetworkInterface"); - foreach ($buffer as $device) { - $dev_name = $device["Name"]; + $results = array(); + $buffer = $this->GetWMI('Win32_PerfRawData_Tcpip_NetworkInterface'); + foreach($buffer as $device) { + $dev_name = $device['Name']; // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_perfrawdata_tcpip_networkinterface.asp // there is a possible bug in the wmi interfaceabout uint32 and uint64: http://www.ureader.com/message/1244948.aspx, so that // magative numbers would occour, try to calculate the nagative value from total - positive number - if ($device["BytesSentPersec"] < 0) { - $results[$dev_name]['tx_bytes'] = $device["BytesTotalPersec"] - $device["BytesReceivedPersec"]; + if ($device['BytesSentPersec'] < 0) { + $results[$dev_name]['tx_bytes'] = $device['BytesTotalPersec'] - $device['BytesReceivedPersec']; } else { - $results[$dev_name]['tx_bytes'] = $device["BytesSentPersec"]; + $results[$dev_name]['tx_bytes'] = $device['BytesSentPersec']; } - if ($device["BytesReceivedPersec"] < 0) { - $results[$dev_name]['rx_bytes'] = $device["BytesTotalPersec"] - $device["BytesSentPersec"]; + if ($device['BytesReceivedPersec'] < 0) { + $results[$dev_name]['rx_bytes'] = $device['BytesTotalPersec'] - $device['BytesSentPersec']; } else { - $results[$dev_name]['rx_bytes'] = $device["BytesReceivedPersec"]; + $results[$dev_name]['rx_bytes'] = $device['BytesReceivedPersec']; } - $results[$dev_name]['errs'] = $device["PacketsReceivedErrors"]; - $results[$dev_name]['drop'] = $device["PacketsReceivedDiscarded"]; + $results[$dev_name]['errs'] = $device['PacketsReceivedErrors']; + $results[$dev_name]['drop'] = $device['PacketsReceivedDiscarded']; } return $results; } + + /** + * Physical memory information and Swap Space information + * + * @access public + * @link http://msdn2.microsoft.com/En-US/library/aa394239.aspx, http://msdn2.microsoft.com/en-us/library/aa394246.aspx + * @return array + */ public function memory() { - /** - * Fetch the physical memory information. - * Win32_OperatingSystem: http://msdn2.microsoft.com/En-US/library/aa394239.aspx - */ - $buffer = $this->GetWMI("Win32_OperatingSystem", array ( - 'TotalVisibleMemorySize', - 'FreePhysicalMemory' - )); + $buffer = $this->GetWMI("Win32_OperatingSystem", array('TotalVisibleMemorySize', 'FreePhysicalMemory')); $results['ram']['total'] = $buffer[0]['TotalVisibleMemorySize'] * 1024; $results['ram']['free'] = $buffer[0]['FreePhysicalMemory'] * 1024; // Calculate used physical memory. @@ -277,14 +395,11 @@ $results['swap']['used'] = 0; $results['swap']['free'] = 0; $results['swap']['percent'] = 0; - /** - * Fetch information about the windows page file. - * Win32_PageFileUsage: http://msdn2.microsoft.com/en-us/library/aa394246.aspx - */ - $buffer = $this->GetWMI("Win32_PageFileUsage"); // no need to filter, using nearly everything from output + + $buffer = $this->GetWMI('Win32_PageFileUsage'); $k = 0; - $results['devswap'] = array (); - foreach ($buffer as $swapdevice) { + $results['devswap'] = array(); + foreach($buffer as $swapdevice) { $results['devswap'][$k]['dev'] = $swapdevice['Name']; $results['devswap'][$k]['total'] = $swapdevice['AllocatedBaseSize'] * 1024 * 1024; $results['devswap'][$k]['used'] = $swapdevice['CurrentUsage'] * 1024 * 1024; @@ -300,94 +415,75 @@ $k += 1; } // Calculate the percent used of the total swap space. - if ($k > 0) { + if($k > 0) { $results['swap']['percent'] = ceil($results['swap']['used'] / (($results['swap']['total'] <= 0) ? 1 : $results['swap']['total']) * 100); } return $results; } - // get the filesystem informations + + /** + * filesystem information + * + * @access public + * @return array + */ public function filesystems() { - $typearray = array ( - "Unknown", - "No Root Directory", - "Removable Disk", - "Local Disk", - "Network Drive", - "Compact Disc", - "RAM Disk" - ); - $floppyarray = array ( - "Unknown", - "5 1/4 in.", - "3 1/2 in.", - "3 1/2 in.", - "3 1/2 in.", - "3 1/2 in.", - "5 1/4 in.", - "5 1/4 in.", - "5 1/4 in.", - "5 1/4 in.", - "5 1/4 in.", - "Other", - "HD", - "3 1/2 in.", - "3 1/2 in.", - "5 1/4 in.", - "5 1/4 in.", - "3 1/2 in.", - "3 1/2 in.", - "5 1/4 in.", - "3 1/2 in.", - "3 1/2 in.", - "8 in." - ); - $buffer = $this->GetWMI("Win32_LogicalDisk", array ( - "Name", - "Size", - "FreeSpace", - "FileSystem", - "DriveType", - "MediaType" - )); + $typearray = array('Unknown', 'No Root Directory', 'Removable Disk', 'Local Disk', 'Network Drive', 'Compact Disc', 'RAM Disk'); + $floppyarray = array('Unknown', '5 1/4 in.', '3 1/2 in.', '3 1/2 in.', '3 1/2 in.', '3 1/2 in.', '5 1/4 in.', '5 1/4 in.', '5 1/4 in.', '5 1/4 in.', '5 1/4 in.', 'Other', 'HD', '3 1/2 in.', '3 1/2 in.', '5 1/4 in.', '5 1/4 in.', '3 1/2 in.', '3 1/2 in.', '5 1/4 in.', '3 1/2 in.', '3 1/2 in.', '8 in.'); + $buffer = $this->GetWMI('Win32_LogicalDisk', array('Name', 'Size', 'FreeSpace', 'FileSystem', 'DriveType', 'MediaType')); $k = 0; - foreach ($buffer as $filesystem) { - $results[$k]['mount'] = $filesystem["Name"]; + foreach($buffer as $filesystem) { + $results[$k]['mount'] = $filesystem['Name']; - if ($filesystem["Size"]) - $results[$k]['size'] = $filesystem["Size"]; - else + if ($filesystem['Size']) { + $results[$k]['size'] = $filesystem['Size']; + } else { $results[$k]['size'] = 0; + } - $results[$k]['used'] = ($filesystem["Size"] - $filesystem["FreeSpace"]); + $results[$k]['used'] = ($filesystem['Size'] - $filesystem['FreeSpace']); - if ($filesystem["FreeSpace"]) - $results[$k]['free'] = $filesystem["FreeSpace"]; - else + if ($filesystem['FreeSpace']) { + $results[$k]['free'] = $filesystem['FreeSpace']; + } else { $results[$k]['free'] = 0; + } - @ $results[$k]['percent'] = ceil($results[$k]['used'] / $results[$k]['size'] * 100); // silence this line, nobody is having a floppy in the drive everytime - $results[$k]['fstype'] = $filesystem["FileSystem"]; - $results[$k]['disk'] = $typearray[$filesystem["DriveType"]]; - if ($filesystem["MediaType"] != "" && $filesystem["DriveType"] == 2) - $results[$k]['disk'] .= " (" . $floppyarray[$filesystem["MediaType"]] . ")"; + // silence this line, nobody is having a floppy in the drive everytime + @$results[$k]['percent'] = ceil($results[$k]['used'] / $results[$k]['size'] * 100); + $results[$k]['fstype'] = $filesystem['FileSystem']; + $results[$k]['disk'] = $typearray[$filesystem['DriveType']]; + if ($filesystem['MediaType'] != "" && $filesystem['DriveType'] == 2) + $results[$k]['disk'] .= " (" . $floppyarray[$filesystem['MediaType']] . ")"; $k += 1; } return $results; } + + /** + * Distribution + * + * @access public + * @return string + */ public function distro() { - $buffer = $this->GetWMI("Win32_OperatingSystem", array ( - "Caption" - )); - return $buffer[0]["Caption"]; + $buffer = $this->GetWMI('Win32_OperatingSystem', array('Caption')); + return $buffer[0]['Caption']; } + + /** + * Distribution Icon + * + * @access public + * @return string + */ public function distroicon() { $version = $this->kernel(); - - if($version[0] == 6) + if($version[0] == 6) { $icon = 'vista.png'; - else + } else { $icon = 'xp.png'; - + } return $icon; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <big...@us...> - 2009-03-30 14:15:25
|
Revision: 173 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=173&view=rev Author: bigmichi1 Date: 2009-03-30 14:15:09 +0000 (Mon, 30 Mar 2009) Log Message: ----------- remove old files Removed Paths: ------------- includes/mb/class.coretemp.inc.php includes/mb/class.hddtemp.inc.php includes/mb/class.healthd.inc.php includes/mb/class.hwsensors.inc.php includes/mb/class.ipmi.inc.php includes/mb/class.lmsensors.inc.php includes/mb/class.mbm5.inc.php includes/mb/class.mbmon.inc.php includes/ups/class.apcupsd.inc.php Deleted: includes/mb/class.coretemp.inc.php =================================================================== --- includes/mb/class.coretemp.inc.php 2009-03-30 14:08:04 UTC (rev 172) +++ includes/mb/class.coretemp.inc.php 2009-03-30 14:15:09 UTC (rev 173) @@ -1,60 +0,0 @@ -<?php -/** - * mbinfo sensor class - * - * @license http://opensource.org/licenses/gpl-2.0.php - * @package psi_sensor - */ - -/** - * getting information from mbinfo - * - * @author William Johansson (radar@radhuset dot org) - * @version $Id$ - * @copyright Copyright (C) 2008 by phpSysInfo - * @package psi_sensor - */ -class coretemp implements psi_sensor_interface { - /** - * get temperature information - * - * @access public - * @return array temperatures in array with lable - */ - function temperature() { - $results = array(); - $smp = 1; - execute_program('sysctl', '-n kern.smp.cpus', $smp); - for ($i = 0; $i < $smp; $i++) { - $temp = 0; - if (execute_program('sysctl', '-n dev.cpu.' . $i . '.temperature', $temp)) { - $results[$i]['label'] = "CPU " . ($i +1); - $results[$i]['value'] = $temp; - $results[$i]['limit'] = '70.0'; - $results[$i]['percent'] = $results[$i]['value'] * 100 / $results[$i]['limit']; - } - } - return $results; - } - - /** - * get fan information - * - * @access public - * @return array fans in array with lable - */ - function fans() { - return null; - } - - /** - * get voltage information - * - * @access public - * @return array voltage in array with lable - */ - function voltage() { - return null; - } -} -?> Deleted: includes/mb/class.hddtemp.inc.php =================================================================== --- includes/mb/class.hddtemp.inc.php 2009-03-30 14:08:04 UTC (rev 172) +++ includes/mb/class.hddtemp.inc.php 2009-03-30 14:15:09 UTC (rev 173) @@ -1,138 +0,0 @@ -<?php -/** - * hddtemp sensor class - * - * @license http://opensource.org/licenses/gpl-2.0.php - * @package psi_sensor - */ - -/** - * getting information from hddtemp - * - * @author Michael Cramer (Big...@us...) - * @version $Id$ - * @copyright Copyright (C) 2008 by phpSysInfo - * @package psi_sensor - */ -class hddtemp { - /** - * object for error handling - * - * @access private - * @var Error - */ - private $error; - - /** - * create the error object - * - * @access public - */ - public function __construct() { - $this->error = Error::Singleton(); - } - - - /** - * get the temperature information from hddtemp - * access is available through tcp or command - * - * @access public - * @return array temperatures in array - */ - public function temperature() { - $ar_buf = array (); - $results = array (); - switch (PSI_HDD_TEMP) { - case "tcp" : - // Timo van Roermund: connect to the hddtemp daemon, use a 5 second timeout. - $fp = @fsockopen('localhost', 7634, $errno, $errstr, 5); - // if connected, read the output of the hddtemp daemon - if ($fp) { - $lines = ''; - while (!feof($fp)) { - $lines .= fread($fp, 1024); - } - fclose($fp); - } else { - $this->error->addError("HDDTemp error", "HDDTemp error: " . $errno . ", " . $errstr); - } - $lines = str_replace("||", "|\n|", $lines); - $ar_buf = explode("\n", $lines); - break; - case "command" : - $strDrives = ""; - $strContent = ""; - $hddtemp_value = ""; - if (rfts("/proc/diskstats", $strContent, 0, 4096, false)) { - $arrContent = explode("\n", $strContent); - foreach ($arrContent as $strLine) { - preg_match("/^\s(.*)\s([a-z]*)\s(.*)/", $strLine, $arrSplit); - if (!empty ($arrSplit[2])) { - $strDrive = '/dev/' . $arrSplit[2]; - if (file_exists($strDrive)) { - $strDrives = $strDrives . $strDrive . ' '; - } - } - } - } else { - if (rfts("/proc/partitions", $strContent, 0, 4096, false)) { - $arrContent = explode("\n", $strContent); - foreach ($arrContent as $strLine) { - if (!preg_match("/^\s(.*)\s([\/a-z0-9]*(\/disc))\s(.*)/", $strLine, $arrSplit)) { - preg_match("/^\s(.*)\s([a-z]*)\s(.*)/", $strLine, $arrSplit); - } - if (!empty ($arrSplit[2])) { - $strDrive = '/dev/' . $arrSplit[2]; - if (file_exists($strDrive)) { - $strDrives = $strDrives . $strDrive . ' '; - } - } - } - } - } - if (trim($strDrives) == "") { - return array (); - } - if (execute_program("hddtemp", $strDrives, $hddtemp_value)) { - $hddtemp_value = explode("\n", $hddtemp_value); - foreach ($hddtemp_value as $line) { - $temp = preg_split("/:\s/", $line, 3); - if (count($temp) == 3 && preg_match("/^[0-9]/", $temp[2])) { - preg_match("/^([0-9]*)(.*)/", $temp[2], $ar_temp); - $temp[2] = trim($ar_temp[1]); - $temp[3] = trim($ar_temp[2]); - array_push($ar_buf, "|" . implode("|", $temp) . "|"); - } - } - } else { - return array (); - } - break; - default : - $this->error->addError("HDDTemp error", "Bad hddtemp configuration in config.php"); - break; - } - // Timo van Roermund: parse the info from the hddtemp daemon. - $i = 0; - foreach ($ar_buf as $line) { - $data = array (); - if (ereg("\|(.*)\|(.*)\|(.*)\|(.*)\|", $line, $data)) { - if (trim($data[3]) != "ERR") { - // get the info we need - $results[$i]['label'] = $data[1]; - if (is_numeric($data[3])) { - $results[$i]['value'] = $data[3]; - } else { - $results[$i]['value'] = 0; - } - //extra processing because of a bug in some versions of hddtemp - $results[$i]['model'] = trim(str_replace("\x10\x80", "", $data[2])); - $i++; - } - } - } - return $results; - } -} -?> Deleted: includes/mb/class.healthd.inc.php =================================================================== --- includes/mb/class.healthd.inc.php 2009-03-30 14:08:04 UTC (rev 172) +++ includes/mb/class.healthd.inc.php 2009-03-30 14:15:09 UTC (rev 173) @@ -1,141 +0,0 @@ -<?php -/** - * healthd sensor class - * - * @license http://opensource.org/licenses/gpl-2.0.php - * @package psi_sensor - */ - -/** - * getting information from healthd - * - * @author Michael Cramer (Big...@us...) - * @version $Id$ - * @copyright Copyright (C) 2008 by phpSysInfo - * @package psi_sensor - */ -class healthd implements psi_sensor_interface { - /** - * object for error handling - * - * @access private - * @var Error - */ - private $error; - - /** - * content to parse - * - * @access private - * @var array - */ - private $lines = array(); - - /** - * fill the private content var through tcp or file access - * - * @access public - */ - public function __construct() { - $this->error = Error::Singleton(); - switch(strtolower(PSI_SENSOR_ACCESS)) { - case 'command' : - $lines = ""; - execute_program('healthdc', '-t', $lines); - $this->lines = explode("\n", $lines); - break; - default : - $this->error->addError('__construct()', 'Wrong value set in config.php for PSI_SENSOR_ACCESS!!!'); - break; - } - } - - /** - * get temperature information - * - * @access public - * @return array temperatures in array with lable - */ - public function temperature() { - $ar_buf = array (); - $results = array (); - $ar_buf = preg_split("/\t+/", $this->lines); - $results[0]['label'] = 'temp1'; - $results[0]['value'] = $ar_buf[1]; - $results[0]['limit'] = '70.0'; - $results[0]['percent'] = $results[0]['value'] * 100 / $results[0]['limit']; - $results[1]['label'] = 'temp2'; - $results[1]['value'] = $ar_buf[2]; - $results[1]['limit'] = '70.0'; - $results[1]['percent'] = $results[1]['value'] * 100 / $results[1]['limit']; - $results[2]['label'] = 'temp3'; - $results[2]['value'] = $ar_buf[3]; - $results[2]['limit'] = '70.0'; - $results[2]['percent'] = $results[2]['value'] * 100 / $results[2]['limit']; - return $results; - } - - /** - * get fan information - * - * @access public - * @return array fans in array with lable - */ - public function fans() { - $ar_buf = array (); - $results = array (); - $ar_buf = preg_split("/\t+/", $this->lines); - $results[0]['label'] = 'fan1'; - $results[0]['value'] = $ar_buf[4]; - $results[0]['min'] = '3000'; - $results[1]['label'] = 'fan2'; - $results[1]['value'] = $ar_buf[5]; - $results[1]['min'] = '3000'; - $results[2]['label'] = 'fan3'; - $results[2]['value'] = $ar_buf[6]; - $results[2]['min'] = '3000'; - return $results; - } - - /** - * get voltage information - * - * @access public - * @return array voltage in array with lable - */ - public function voltage() { - $ar_buf = array (); - $results = array (); - $ar_buf = preg_split("/\t+/", $this->lines); - $results[0]['label'] = 'Vcore1'; - $results[0]['value'] = $ar_buf[7]; - $results[0]['min'] = '0.00'; - $results[0]['max'] = '0.00'; - $results[1]['label'] = 'Vcore2'; - $results[1]['value'] = $ar_buf[8]; - $results[1]['min'] = '0.00'; - $results[1]['max'] = '0.00'; - $results[2]['label'] = '3volt'; - $results[2]['value'] = $ar_buf[9]; - $results[2]['min'] = '0.00'; - $results[2]['max'] = '0.00'; - $results[3]['label'] = '+5Volt'; - $results[3]['value'] = $ar_buf[10]; - $results[3]['min'] = '0.00'; - $results[3]['max'] = '0.00'; - $results[4]['label'] = '+12Volt'; - $results[4]['value'] = $ar_buf[11]; - $results[4]['min'] = '0.00'; - $results[4]['max'] = '0.00'; - $results[5]['label'] = '-12Volt'; - $results[5]['value'] = $ar_buf[12]; - $results[5]['min'] = '0.00'; - $results[5]['max'] = '0.00'; - $results[6]['label'] = '-5Volt'; - $results[6]['value'] = $ar_buf[13]; - $results[6]['min'] = '0.00'; - $results[6]['max'] = '0.00'; - return $results; - } -} -?> Deleted: includes/mb/class.hwsensors.inc.php =================================================================== --- includes/mb/class.hwsensors.inc.php 2009-03-30 14:08:04 UTC (rev 172) +++ includes/mb/class.hwsensors.inc.php 2009-03-30 14:15:09 UTC (rev 173) @@ -1,120 +0,0 @@ -<?php -/** - * hwsensors sensor class - * - * @license http://opensource.org/licenses/gpl-2.0.php - * @package psi_sensor - */ - -/** - * getting information from hwsensors - * - * @author Michael Cramer (Big...@us...) - * @version $Id$ - * @copyright Copyright (C) 2008 by phpSysInfo - * @package psi_sensor - */ -class hwsensors implements psi_sensor_interface { - /** - * object for error handling - * - * @access private - * @var Error - */ - private $error; - - /** - * content to parse - * - * @access private - * @var array - */ - private $lines = array(); - - /** - * fill the private content var through tcp or file access - * - * @access public - */ - function __construct() { - $this->error = Error::Singleton(); - switch(strtolower(PSI_SENSOR_ACCESS)) { - case 'tcp' : - $lines = ""; - execute_program('sysctl', '-w hw.sensors', $lines); - $this->lines = explode("\n", $lines); - break; - default : - $this->error->addError('__construct()', 'Wrong value set in config.php for PSI_SENSOR_ACCESS!!!'); - break; - } - } - - /** - * get temperature information - * - * @access public - * @return array temperatures in array with lable - */ - public function temperature() { - $ar_buf = array (); - $results = array (); - $j = 0; - foreach ($this->lines as $line) { - $ar_buf = preg_split("/[\s,]+/", $line); - if (isset ($ar_buf[3]) && $ar_buf[2] == 'temp') { - $results[$j]['label'] = $ar_buf[1]; - $results[$j]['value'] = $ar_buf[3]; - $results[$j]['limit'] = '70.0'; - $results[$j]['percent'] = $results[$j]['value'] * 100 / $results[$j]['limit']; - $j++; - } - } - return $results; - } - - /** - * get fan information - * - * @access public - * @return array fans in array with lable - */ - public function fans() { - $ar_buf = array (); - $results = array (); - $j = 0; - foreach ($this->lines as $line) { - $ar_buf = preg_split("/[\s,]+/", $line); - if (isset ($ar_buf[3]) && $ar_buf[2] == 'fanrpm') { - $results[$j]['label'] = $ar_buf[1]; - $results[$j]['value'] = $ar_buf[3]; - $j++; - } - } - return $results; - } - - /** - * get voltage information - * - * @access public - * @return array voltage in array with lable - */ - public function voltage() { - $ar_buf = array (); - $results = array (); - $j = 0; - foreach ($this->lines as $line) { - $ar_buf = preg_split("/[\s,]+/", $line); - if (isset ($ar_buf[3]) && $ar_buf[2] == 'volts_dc') { - $results[$j]['label'] = $ar_buf[1]; - $results[$j]['value'] = $ar_buf[3]; - $results[$j]['min'] = '0.00'; - $results[$j]['max'] = '0.00'; - $j++; - } - } - return $results; - } -} -?> Deleted: includes/mb/class.ipmi.inc.php =================================================================== --- includes/mb/class.ipmi.inc.php 2009-03-30 14:08:04 UTC (rev 172) +++ includes/mb/class.ipmi.inc.php 2009-03-30 14:15:09 UTC (rev 173) @@ -1,110 +0,0 @@ -<?php -/** - * ipmi sensor class - * - * @license http://opensource.org/licenses/gpl-2.0.php - * @package psi_sensor - */ - -/** - * getting information from ipmitool - * - * @author Michael Cramer (Big...@us...) - * @version $Id$ - * @copyright Copyright (C) 2008 by phpSysInfo - * @package psi_sensor - */ -class ipmi implements psi_sensor_interface { - /** - * content to parse - * - * @access private - * @var array - */ - private $lines = array(); - - /** - * object for error handling - * - * @access private - * @var Error - */ - private $error; - - /** - * fill the private content var through tcp or file access - * - * @access public - */ - public function __construct() { - $this->error = Error::Singleton(); - switch (strtolower(PSI_SENSOR_ACCESS)) { - case 'tcp' : - $this->error->addError('__construct', 'Tcp not implemented for ipmi!!!'); - break; - case 'command' : - $lines = ""; - execute_program('ipmitool', 'sensor', $lines); - $this->lines = explode("\n", $lines); - break; - default : - $this->error->addError('__construct()', 'Wrong value set in config.php for PSI_SENSOR_ACCESS!!!'); - break; - } - } - - /** - * get temperature information - * - * @access public - * @return array temperatures in array with lable - */ - public function temperature() { - $result = array (); - $i = 0; - foreach ($this->lines as $line) { - $buffer = preg_split("/[ ]+\|[ ]+/", $line); - if ($buffer[2] == "degrees C" && $buffer[5] != "na") { - $result[$i]['label'] = $buffer[0]; - $result[$i]['value'] = $buffer[1]; - $result[$i]['limit'] = $buffer[8]; - $i++; - } - } - return $result; - } - - /** - * get fan information - * - * @access public - * @return array fans in array with lable - */ - public function fans() { - $result = array (); - return $result; - } - - /** - * get voltage information - * - * @access public - * @return array voltage in array with lable - */ - public function voltage() { - $result = array (); - $i = 0; - foreach ($this->lines as $line) { - $buffer = preg_split("/[ ]+\|[ ]+/", $line); - if ($buffer[2] == "Volts" && $buffer[5] != "na") { - $result[$i]['label'] = $buffer[0]; - $result[$i]['value'] = $buffer[1]; - $result[$i]['min'] = $buffer[5]; - $result[$i]['max'] = $buffer[8]; - $i++; - } - } - return $result; - } -} -?> Deleted: includes/mb/class.lmsensors.inc.php =================================================================== --- includes/mb/class.lmsensors.inc.php 2009-03-30 14:08:04 UTC (rev 172) +++ includes/mb/class.lmsensors.inc.php 2009-03-30 14:15:09 UTC (rev 173) @@ -1,215 +0,0 @@ -<?php -/** - * lmsensor sensor class - * - * @license http://opensource.org/licenses/gpl-2.0.php - * @package psi_sensor - */ - -/** - * getting information from lmsensor - * - * @author Michael Cramer (Big...@us...) - * @version $Id$ - * @copyright Copyright (C) 2008 by phpSysInfo - * @package psi_sensor - */ -class lmsensors implements psi_sensor_interface { - /** - * object for error handling - * - * @access private - * @var Error - */ - private $error; - - /** - * content to parse - * - * @access private - * @var array - */ - private $lines = array(); - - /** - * fill the private content var through tcp or file access - * - * @access public - */ - function __construct() { - $this->error = Error::Singleton(); - switch(strtolower(PSI_SENSOR_ACCESS)) { - case 'command' : - $lines = ""; - if(execute_program("sensors", "", $lines)) { - // Martijn Stolk: Dirty fix for misinterpreted output of sensors, - // where info could come on next line when the label is too long. - $lines = str_replace(":\n", ":", $lines); - $lines = str_replace("\n\n", "\n", $lines); - $this->lines = explode("\n", $lines); - } else { - $this->lines = array (); - } - break; - default : - $this->error->addError('__construct()', 'Wrong value set in config.php for PSI_SENSOR_ACCESS!!!'); - break; - } - } - - /** - * get temperature information - * - * @access public - * @return array temperatures in array with lable - */ - public function temperature() { - $ar_buf = array (); - $results = array (); - $sensors_value = $this->lines; - foreach ($sensors_value as $line) { - $data = array (); - if (ereg("(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)", $line, $data)); - elseif (ereg("(.*):(.*)\((.*)=(.*)\)(.*)", $line, $data)); - else - (ereg("(.*):(.*)", $line, $data)); - if (count($data) > 1) { - $temp = substr(trim($data[2]), -1); - switch ($temp) { - case "C" : - case "F" : - array_push($ar_buf, $line); - } - } - } - $i = 0; - foreach ($ar_buf as $line) { - unset ($data); - if (ereg("(.*):(.*).C[ ]*\((.*)=(.*).C,(.*)=(.*).C\)(.*)\)", $line, $data)); - elseif (ereg("(.*):(.*).C[ ]*\((.*)=(.*).C,(.*)=(.*).C\)(.*)", $line, $data)); - elseif (ereg("(.*):(.*).C[ ]*\((.*)=(.*).C\)(.*)", $line, $data)); - else - (ereg("(.*):(.*).C", $line, $data)); - foreach ($data as $key => $value) { - if (preg_match("/^\+?([0-9\.]+).?$/", trim($value), $newvalue)) { - $data[$key] = trim($newvalue[1]); - } else { - $data[$key] = trim($value); - } - } - $results[$i]['label'] = $data[1]; - $results[$i]['value'] = $data[2]; - if (isset ($data[6]) && $data[2] > $data[6]) { - $results[$i]['limit'] = "75"; - $results[$i]['perce'] = "75"; - } else { - $results[$i]['limit'] = isset ($data[4]) ? $data[4] : "75"; - $results[$i]['perce'] = isset ($data[6]) ? $data[6] : "75"; - } - if ($results[$i]['limit'] < $results[$i]['perce']) { - $results[$i]['limit'] = $results[$i]['perce']; - } - $i++; - } - asort($results); - return array_values($results); - } - - /** - * get fan information - * - * @access public - * @return array fans in array with lable - */ - public function fans() { - $ar_buf = array (); - $results = array (); - $sensors_value = $this->lines; - foreach ($sensors_value as $line) { - $data = array (); - if (ereg("(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)", $line, $data)); - elseif (ereg("(.*):(.*)\((.*)=(.*)\)(.*)", $line, $data)); - else - ereg("(.*):(.*)", $line, $data); - if (count($data) > 1) { - $temp = explode(" ", trim($data[2])); - if (count($temp) == 1) - $temp = explode("\xb0", trim($data[2])); - if (isset ($temp[1])) { - switch ($temp[1]) { - case "RPM" : - array_push($ar_buf, $line); - } - } - } - } - $i = 0; - foreach ($ar_buf as $line) { - unset ($data); - if (ereg("(.*):(.*) RPM \((.*)=(.*) RPM,(.*)=(.*)\)(.*)\)", $line, $data)); - elseif (ereg("(.*):(.*) RPM \((.*)=(.*) RPM,(.*)=(.*)\)(.*)", $line, $data)); - elseif (ereg("(.*):(.*) RPM \((.*)=(.*) RPM\)(.*)", $line, $data)); - else - ereg("(.*):(.*) RPM", $line, $data); - $results[$i]['label'] = trim($data[1]); - $results[$i]['value'] = trim($data[2]); - $results[$i]['min'] = isset ($data[4]) ? trim($data[4]) : 0; - $i++; - } - asort($results); - return array_values($results); - } - - /** - * get voltage information - * - * @access public - * @return array voltage in array with lable - */ - public function voltage() { - $ar_buf = array (); - $results = array (); - $sensors_value = $this->lines; - foreach ($sensors_value as $line) { - $data = array (); - if (ereg("(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)", $line, $data)); - else - ereg("(.*):(.*)", $line, $data); - if (count($data) > 1) { - $temp = explode(" ", trim($data[2])); - if (count($temp) == 1) - $temp = explode("\xb0", trim($data[2])); - if (isset ($temp[1])) { - switch ($temp[1]) { - case "V" : - array_push($ar_buf, $line); - } - } - } - } - $i = 0; - foreach ($ar_buf as $line) { - unset ($data); - if (ereg("(.*):(.*) V \((.*)=(.*) V,(.*)=(.*) V\)(.*)\)", $line, $data)); - elseif (ereg("(.*):(.*) V \((.*)=(.*) V,(.*)=(.*) V\)(.*)", $line, $data)); - else - ereg("(.*):(.*) V$", $line, $data); - foreach ($data as $key => $value) { - if (preg_match("/^\+?([0-9\.]+)$/", trim($value), $newvalue)) { - $data[$key] = trim($newvalue[1]); - } else { - $data[$key] = trim($value); - } - } - if (isset ($data[1])) { - $results[$i]['label'] = $data[1]; - $results[$i]['value'] = $data[2]; - $results[$i]['min'] = isset ($data[4]) ? $data[4] : 0; - $results[$i]['max'] = isset ($data[6]) ? $data[6] : 0; - $i++; - } - } - return $results; - } -} -?> Deleted: includes/mb/class.mbm5.inc.php =================================================================== --- includes/mb/class.mbm5.inc.php 2009-03-30 14:08:04 UTC (rev 172) +++ includes/mb/class.mbm5.inc.php 2009-03-30 14:15:09 UTC (rev 173) @@ -1,137 +0,0 @@ -<?php -/** - * MBM5 sensor class - * - * @license http://opensource.org/licenses/gpl-2.0.php - * @package psi_sensor - */ - -/** - * getting information from Motherboard Monitor 5 - * information retrival through csv file - * - * @author Michael Cramer (Big...@us...) - * @version $Id$ - * @copyright Copyright (C) 2008 by phpSysInfo - * @package psi_sensor - */ -class mbm5 implements psi_sensor_interface { - /** - * object for error handling - * - * @access private - * @var Error - */ - private $error; - - /** - * array with the names of the labels - * - * @var array - * @access private - */ - private $buf_label = array(); - - - /** - * array withe the values - * - * @var array - * @access private - */ - private $buf_value = array(); - - /** - * read the MBM5.csv file and fill the private arrays - * - * @access public - */ - function __construct() { - $this->error = Error::Singleton(); - switch(strtolower(PSI_SENSOR_ACCESS)) { - case 'file' : - $buffer = ""; - rfts(APP_ROOT . "/data/MBM5.csv", $buffer); - if(strpos($buffer, ";") === false) { - $delim = ","; - } else { - $delim = ";"; - } - $buffer = split("\n", $buffer); - $this->buf_label = split($delim, substr($buffer[0], 0, -2)); - $this->buf_value = split($delim, substr($buffer[1], 0, -2)); - break; - default: - $this->error->addError('__construct()', 'Wrong value set in config.php for PSI_SENSOR_ACCESS!!!'); - break; - } - } - - /** - * get temperature information - * - * @access public - * @return array temperatures in array with lable - */ - public function temperature() { - $results = array(); - $intCount = 0; - for($intPosi = 3; $intPosi < 6; $intPosi++) { - if($this->buf_value[$intPosi] == 0) { - continue; - } - $results[$intCount]['label'] = $this->buf_label[$intPosi]; - preg_match("/([0-9\.])*/", str_replace(",", ".", $this->buf_value[$intPosi]), $hits); - $results[$intCount]['value'] = $hits[0]; - $results[$intCount]['limit'] = '70.0'; - $intCount++; - } - return $results; - } - - /** - * get fan information - * - * @access public - * @return array fans in array with lable - */ - public function fans() { - $results = array(); - $intCount = 0; - for($intPosi = 13; $intPosi < 16; $intPosi++) { - if(!isset ($this->buf_value[$intPosi])) { - continue; - } - $results[$intCount]['label'] = $this->buf_label[$intPosi]; - preg_match("/([0-9\.])*/", str_replace(",", ".", $this->buf_value[$intPosi]), $hits); - $results[$intCount]['value'] = $hits[0]; - $results[$intCount]['min'] = '3000'; - $intCount++; - } - return $results; - } - - /** - * get voltage information - * - * @access public - * @return array voltage in array with lable - */ - public function voltage() { - $results = array(); - $intCount = 0; - for($intPosi = 6; $intPosi < 13; $intPosi++) { - if($this->buf_value[$intPosi] == 0) { - continue; - } - $results[$intCount]['label'] = $this->buf_label[$intPosi]; - preg_match("/([0-9\.])*/", str_replace(",", ".", $this->buf_value[$intPosi]), $hits); - $results[$intCount]['value'] = $hits[0]; - $results[$intCount]['min'] = '0.00'; - $results[$intCount]['max'] = '0.00'; - $intCount++; - } - return $results; - } -} -?> Deleted: includes/mb/class.mbmon.inc.php =================================================================== --- includes/mb/class.mbmon.inc.php 2009-03-30 14:08:04 UTC (rev 172) +++ includes/mb/class.mbmon.inc.php 2009-03-30 14:15:09 UTC (rev 173) @@ -1,137 +0,0 @@ -<?php -/** - * mbinfo sensor class - * - * @license http://opensource.org/licenses/gpl-2.0.php - * @package psi_sensor - */ - -/** - * getting information from mbinfo - * - * @author Michael Cramer (Big...@us...) - * @version $Id$ - * @copyright Copyright (C) 2008 by phpSysInfo - * @package psi_sensor - */ -class mbmon implements psi_sensor_interface { - /** - * object for error handling - * - * @access private - * @var Error - */ - private $error; - - /** - * content to parse - * - * @access private - * @var array - */ - private $lines = array(); - - /** - * fill the private content var through tcp or file access - * - * @access public - */ - public function __construct() { - $this->error = Error::Singleton(); - switch(strtolower(PSI_SENSOR_ACCESS)) { - case 'tcp' : - $fp = fsockopen("localhost", 411, $errno, $errstr, 5); - if($fp) { - $lines = ""; - while(!feof($fp)) { - $lines .= fread($fp, 1024); - } - $this->lines = explode("\n", $lines); - } else { - $this->error->addError("fsockopen()", $errno . " " . $errstr); - } - break; - case 'command' : - execute_program('mbmon', '-c 1 -r', $lines); - $this->lines = explode("\n", $lines); - break; - default : - $this->error->addError('__construct()', 'Wrong value set in config.php for PSI_SENSOR_ACCESS!!!'); - break; - } - } - - /** - * get temperature information - * - * @access public - * @return array temperatures in array with lable - */ - public function temperature() { - $results = array(); - $i = 0; - foreach($this->lines as $line) { - if(preg_match('/^(TEMP\d*)\s*:\s*(.*)$/D', $line, $data)) { - if($data[2] <> '0') { - $results[$i]['label'] = $data[1]; - $results[$i]['limit'] = '70.0'; - if($data[2] > 250) { - $results[$i]['value'] = 0; - $results[$i]['percent'] = 0; - } else { - $results[$i]['value'] = $data[2]; - $results[$i]['percent'] = $results[$i]['value'] * 100 / $results[$i]['limit']; - } - $i++; - } - } - } - return $results; - } - - /** - * get fan information - * - * @access public - * @return array fans in array with lable - */ - public function fans() { - $results = array(); - $i = 0; - foreach($this->lines as $line) { - if(preg_match('/^(FAN\d*)\s*:\s*(.*)$/D', $line, $data)) { - if($data[2] <> '0') { - $results[$i]['label'] = $data[1]; - $results[$i]['value'] = $data[2]; - $results[$i]['min'] = '3000'; - $i++; - } - } - } - return $results; - } - - /** - * get voltage information - * - * @access public - * @return array voltage in array with lable - */ - public function voltage() { - $results = array(); - $i = 0; - foreach($this->lines as $line) { - if(preg_match('/^(V.*)\s*:\s*(.*)$/D', $line, $data)) { - if($data[2] <> '+0.00') { - $results[$i]['label'] = $data[1]; - $results[$i]['value'] = $data[2]; - $results[$i]['min'] = '0.00'; - $results[$i]['max'] = '0.00'; - $i++; - } - } - } - return $results; - } -} -?> Deleted: includes/ups/class.apcupsd.inc.php =================================================================== --- includes/ups/class.apcupsd.inc.php 2009-03-30 14:08:04 UTC (rev 172) +++ includes/ups/class.apcupsd.inc.php 2009-03-30 14:15:09 UTC (rev 173) @@ -1,120 +0,0 @@ -<?php -/*************************************************************************** - * Copyright (C) 2008 by phpSysInfo - A PHP System Information Script * - * http://phpsysinfo.sourceforge.net/ * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ -// -// $Id$ -// -// This class was created by Artem Volk ( artvolk at mail dot ru ) -class upsinfo { - private $output = array(); - public function __construct() { - $upses = explode(',', PSI_UPSINFO_APCUPSD_UPS_LIST); - $temp = ''; - for ($i = 0; $i < count($upses); $i++) { - execute_program('apcaccess', 'status ' . trim($upses[$i]), $temp); - if (isset ($temp) && !empty ($temp)) { - $this->output[$i] = $temp; - } - } - } - public function info() { - if (isset ($this->output) && count($this->output) > 0) { - $results = Array (); - for ($i = 0; $i < count($this->output); $i++) { - // General info - if (preg_match('/^UPSNAME\s*:\s*(.*)$/m', $this->output[$i], $data)) { - $results[$i]['name'] = trim($data[1]); - } else { - $results[$i]['name'] = ''; - } - if (preg_match('/^MODEL\s*:\s*(.*)$/m', $this->output[$i], $data)) { - $results[$i]['model'] = trim($data[1]); - } else { - $results[$i]['model'] = ''; - } - if (preg_match('/^UPSMODE\s*:\s*(.*)$/m', $this->output[$i], $data)) { - $results[$i]['mode'] = trim($data[1]); - } else { - $results[$i]['mode'] = ''; - } - if (preg_match('/^STARTTIME\s*:\s*(.*)$/m', $this->output[$i], $data)) { - $results[$i]['start_time'] = trim($data[1]); - } else { - $results[$i]['start_time'] = ''; - } - if (preg_match('/^STATUS\s*:\s*(.*)$/m', $this->output[$i], $data)) { - $results[$i]['status'] = trim($data[1]); - } else { - $results[$i]['status'] = ''; - } - if (preg_match('/^ITEMP\s*:\s*(.*)$/m', $this->output[$i], $data)) { - $results[$i]['temperature'] = trim($data[1]); - } else { - $results[$i]['temperature'] = ''; - } - // Outages - if (preg_match('/^NUMXFERS\s*:\s*(.*)$/m', $this->output[$i], $data)) { - $results[$i]['outages_count'] = trim($data[1]); - } else { - $results[$i]['outages_count'] = ''; - } - if (preg_match('/^LASTXFER\s*:\s*(.*)$/m', $this->output[$i], $data)) { - $results[$i]['last_outage'] = trim($data[1]); - } else { - $results[$i]['last_outage'] = ''; - } - if (preg_match('/^XOFFBATT\s*:\s*(.*)$/m', $this->output[$i], $data)) { - $results[$i]['last_outage_finish'] = trim($data[1]); - } else { - $results[$i]['last_outage_finish'] = ''; - } - // Line - if (preg_match('/^LINEV\s*:\s*(\d*\.\d*)(.*)$/m', $this->output[$i], $data)) { - $results[$i]['line_voltage'] = trim($data[1]); - } else { - $results[$i]['line_voltage'] = ''; - } - if (preg_match('/^LOADPCT\s*:\s*(\d*\.\d*)(.*)$/m', $this->output[$i], $data)) { - $results[$i]['load_percent'] = trim($data[1]); - } else { - $results[$i]['load_percent'] = ''; - } - // Battery - if (preg_match('/^BATTV\s*:\s*(\d*\.\d*)(.*)$/m', $this->output[$i], $data)) { - $results[$i]['battery_voltage'] = trim($data[1]); - } else { - $results[$i]['battery_voltage'] = ''; - } - if (preg_match('/^BCHARGE\s*:\s*(\d*\.\d*)(.*)$/m', $this->output[$i], $data)) { - $results[$i]['battery_charge_percent'] = trim($data[1]); - } else { - $results[$i]['battery_charge_percent'] = ''; - } - if (preg_match('/^TIMELEFT\s*:\s*(\d*\.\d*)(.*)$/m', $this->output[$i], $data)) { - $results[$i]['time_left_minutes'] = trim($data[1]); - } else { - $results[$i]['time_left_minutes'] = ''; - } - } - return $results; - } - } -} -?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <big...@us...> - 2009-05-04 07:22:26
|
Revision: 203 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=203&view=rev Author: bigmichi1 Date: 2009-05-04 07:22:18 +0000 (Mon, 04 May 2009) Log Message: ----------- fixing some ups bugs Modified Paths: -------------- includes/autoloader.inc.php includes/output/class.WebpageXML.inc.php includes/ups/class.Apcupsd.inc.php Modified: includes/autoloader.inc.php =================================================================== --- includes/autoloader.inc.php 2009-05-03 22:17:24 UTC (rev 202) +++ includes/autoloader.inc.php 2009-05-04 07:22:18 UTC (rev 203) @@ -1,4 +1,4 @@ -<?php +<?php /** * class autoloader * @@ -22,20 +22,23 @@ function __autoload($class_name) { $class_name = str_replace('-', '', $class_name); - $dirs = array ('/plugins/'.strtolower($class_name).'/', '/includes/', '/includes/interface/', '/includes/os/', '/includes/mb/', '/includes/plugin/', '/includes/xml/', '/includes/web/', '/includes/error/', '/includes/js/', '/includes/output/'); + $dirs = array('/plugins/'.strtolower($class_name).'/', '/includes/', '/includes/interface/', + '/includes/os/', '/includes/mb/', '/includes/plugin/', '/includes/xml/', + '/includes/web/', '/includes/error/', '/includes/js/', '/includes/output/', + '/includes/ups/'); $found = false; foreach ($dirs as $dir) { if (file_exists(APP_ROOT.$dir.'class.'.$class_name.'.inc.php')) { include_once APP_ROOT.$dir.'class.'.$class_name.'.inc.php'; $found = true; - } - } + } + } if (!$found) { $error = Error::singleton(); $error->addError("_autoload(\"".$class_name."\")", "autoloading of class file (class.".$class_name.".inc.php) failed!"); echo $error->errorsAsHTML(); - die (); - } + die(); + } } ?> Modified: includes/output/class.WebpageXML.inc.php =================================================================== --- includes/output/class.WebpageXML.inc.php 2009-05-03 22:17:24 UTC (rev 202) +++ includes/output/class.WebpageXML.inc.php 2009-05-04 07:22:18 UTC (rev 203) @@ -1,4 +1,4 @@ -<?php +<?php /** * XML Generator class * @@ -23,36 +23,35 @@ * @version Release: 3.0 * @link http://phpsysinfo.sourceforge.net */ -class WebpageXML extends Output implements PSI_Interface_Output -{ +class WebpageXML extends Output implements PSI_Interface_Output { /** * xml object that holds the generated xml * * @var XML */ private $_xml; - + /** * only plugin xml * * @var boolean */ private $_pluginRequest = false; - + /** * complete xml * * @var boolean */ private $_completeXML = false; - + /** * name of the plugin * * @var string */ private $_pluginName = null; - + /** * generate the output * @@ -65,7 +64,7 @@ if (!file_exists(APP_ROOT.'/includes/os/class.'.PHP_OS.'.inc.php')) { $this->error->addError("file_exists(class.".PHP_OS.".php.inc)", PHP_OS." is not currently supported"); } - + // check if there is a valid sensor configuration in config.php $found = false; if (PSI_SENSOR_PROGRAM !== false) { @@ -74,27 +73,27 @@ $this->error->addError("file_exists(class.".htmlspecialchars(PSI_SENSOR_PROGRAM).".inc.php)", "specified sensor program is not supported"); } else { $found = true; - } - } + } + } /** * motherboard information available or not * * @var boolean */ define('PSI_MBINFO', $found); - + // check if there is a valid hddtemp configuration in config.php $found = false; if (PSI_HDD_TEMP !== false) { $found = true; - } + } /** * hddtemp information available or not * * @var boolean */ define('PSI_HDDTEMP', $found); - + // check if there is a valid ups configuration in config.php $found = false; if (PSI_UPS_PROGRAM !== false) { @@ -102,32 +101,32 @@ $found = false; $this->error->addError("file_exists(class.".htmlspecialchars(PSI_UPS_PROGRAM).".inc.php)", "specified UPS program is not supported"); } else { - $found = false; - } - } + $found = true; + } + } /** * ups information available or not * * @var boolean */ define('PSI_UPSINFO', $found); - + // if there are errors stop executing the script until they are fixed if ($this->error->errorsExist()) { header("Content-Type: text/xml\n\n"); echo $this->error->errorsAsXML(); - exit ; - } + exit; + } } - + // Create the XML if ($this->_pluginRequest) { $this->_xml = new XML(false, $this->_pluginName); } else { $this->_xml = new XML($this->_completeXML); - } + } } - + /** * render the output * @@ -139,9 +138,9 @@ header("Content-Type: text/xml\n\n"); $xml = $this->_xml->getXml(); echo $xml->asXML(); - die (); + die(); } - + /** * get XML as pure string * @@ -152,7 +151,7 @@ $xml = $this->_xml->getXml(); return $xml->asXML(); } - + /** * set parameters for the XML generation process * @@ -166,14 +165,14 @@ parent::__construct(); if ($completeXML) { $this->_completeXML = true; - } + } if ($plugin) { if (in_array($plugin, CommonFunctions::getPlugins())) { $this->_pluginName = $plugin; $this->_pluginRequest = true; - } - } + } + } $this->_prepare(); - } + } } ?> Modified: includes/ups/class.Apcupsd.inc.php =================================================================== --- includes/ups/class.Apcupsd.inc.php 2009-05-03 22:17:24 UTC (rev 202) +++ includes/ups/class.Apcupsd.inc.php 2009-05-04 07:22:18 UTC (rev 203) @@ -24,15 +24,14 @@ * @version Release: 3.0 * @link http://phpsysinfo.sourceforge.net */ -class Apcupsd implements PSI_Interface_UPS -{ +class Apcupsd implements PSI_Interface_UPS { /** * internal storage for all gathered data * * @var array */ - private $_output = array (); - + private $_output = array(); + /** * get all information from all configured ups in config.php and store output in internal array */ @@ -42,12 +41,12 @@ foreach ($upses as $ups) { $temp = ''; CommonFunctions::executeProgram('apcaccess', 'status '.trim($ups), $temp); - if ( isset ($temp) && ! empty($temp)) { - array_push($this->_output[$i], $temp); - } - } + if (isset($temp) && ! empty($temp)) { + $this->_output[] = $temp; + } + } } - + /** * parse the input and store data in resultset for xml generation * @@ -55,86 +54,86 @@ */ public function info() { - if ( isset ($this->_output) && count($this->_output) > 0) { - $results = array (); + if (isset($this->_output) && count($this->_output) > 0) { + $results = array(); for ($i = 0, $cnt_output = count($this->_output); $i < $cnt_output; $i++) { // General info if (preg_match('/^UPSNAME\s*:\s*(.*)$/m', $this->_output[$i], $data)) { $results[$i]['name'] = trim($data[1]); } else { $results[$i]['name'] = ''; - } + } if (preg_match('/^MODEL\s*:\s*(.*)$/m', $this->_output[$i], $data)) { $results[$i]['model'] = trim($data[1]); } else { $results[$i]['model'] = ''; - } + } if (preg_match('/^UPSMODE\s*:\s*(.*)$/m', $this->_output[$i], $data)) { $results[$i]['mode'] = trim($data[1]); } else { $results[$i]['mode'] = ''; - } + } if (preg_match('/^STARTTIME\s*:\s*(.*)$/m', $this->_output[$i], $data)) { $results[$i]['start_time'] = trim($data[1]); } else { $results[$i]['start_time'] = ''; - } + } if (preg_match('/^STATUS\s*:\s*(.*)$/m', $this->_output[$i], $data)) { $results[$i]['status'] = trim($data[1]); } else { $results[$i]['status'] = ''; - } + } if (preg_match('/^ITEMP\s*:\s*(.*)$/m', $this->_output[$i], $data)) { $results[$i]['temperature'] = trim($data[1]); } else { $results[$i]['temperature'] = ''; - } + } // Outages if (preg_match('/^NUMXFERS\s*:\s*(.*)$/m', $this->_output[$i], $data)) { $results[$i]['outages_count'] = trim($data[1]); } else { $results[$i]['outages_count'] = ''; - } + } if (preg_match('/^LASTXFER\s*:\s*(.*)$/m', $this->_output[$i], $data)) { $results[$i]['last_outage'] = trim($data[1]); } else { $results[$i]['last_outage'] = ''; - } + } if (preg_match('/^XOFFBATT\s*:\s*(.*)$/m', $this->_output[$i], $data)) { $results[$i]['last_outage_finish'] = trim($data[1]); } else { $results[$i]['last_outage_finish'] = ''; - } + } // Line if (preg_match('/^LINEV\s*:\s*(\d*\.\d*)(.*)$/m', $this->_output[$i], $data)) { $results[$i]['line_voltage'] = trim($data[1]); } else { $results[$i]['line_voltage'] = ''; - } + } if (preg_match('/^LOADPCT\s*:\s*(\d*\.\d*)(.*)$/m', $this->_output[$i], $data)) { $results[$i]['load_percent'] = trim($data[1]); } else { $results[$i]['load_percent'] = ''; - } + } // Battery if (preg_match('/^BATTV\s*:\s*(\d*\.\d*)(.*)$/m', $this->_output[$i], $data)) { $results[$i]['battery_voltage'] = trim($data[1]); } else { $results[$i]['battery_voltage'] = ''; - } + } if (preg_match('/^BCHARGE\s*:\s*(\d*\.\d*)(.*)$/m', $this->_output[$i], $data)) { $results[$i]['battery_charge_percent'] = trim($data[1]); } else { $results[$i]['battery_charge_percent'] = ''; - } + } if (preg_match('/^TIMELEFT\s*:\s*(\d*\.\d*)(.*)$/m', $this->_output[$i], $data)) { $results[$i]['time_left_minutes'] = trim($data[1]); } else { $results[$i]['time_left_minutes'] = ''; - } - } + } + } return $results; - } - } + } + } } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <big...@us...> - 2009-05-25 09:12:17
|
Revision: 222 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=222&view=rev Author: bigmichi1 Date: 2009-05-25 09:12:08 +0000 (Mon, 25 May 2009) Log Message: ----------- xsl check is only done when generating static page Modified Paths: -------------- includes/class.CommonFunctions.inc.php includes/output/class.WebpageXSLT.inc.php Modified: includes/class.CommonFunctions.inc.php =================================================================== --- includes/class.CommonFunctions.inc.php 2009-05-25 09:06:07 UTC (rev 221) +++ includes/class.CommonFunctions.inc.php 2009-05-25 09:12:08 UTC (rev 222) @@ -27,7 +27,7 @@ { /** * phpSysInfo version - * + * * @var string */ const PSI_VERSION = '3.0-rc6'; @@ -235,12 +235,14 @@ * Then it will terminate the script. * See bug #1787137 * + * @param array $arrExt additional extensions for which a check should run + * * @return void */ - public static function checkForExtensions() + public static function checkForExtensions($arrExt = array()) { - // TODO XSL extension is only required in case there is no javascript, we'd better test this extension in this case only to improve compatibility - $extensions = array('simplexml', 'pcre', 'xml', 'xsl', 'mbstring'); + $arrReq = array('simplexml', 'pcre', 'xml', 'mbstring'); + $extensions = array_merge($arrExt, $arrReq); $text = ""; $error = false; $text .= "<?xml version='1.0'?>\n"; Modified: includes/output/class.WebpageXSLT.inc.php =================================================================== --- includes/output/class.WebpageXSLT.inc.php 2009-05-25 09:06:07 UTC (rev 221) +++ includes/output/class.WebpageXSLT.inc.php 2009-05-25 09:12:08 UTC (rev 222) @@ -40,6 +40,7 @@ */ public function run() { + CommonFunctions::checkForExtensions(array('xsl')); $xmlfile = $this->getXMLString(); $xslfile = "phpsysinfo.xslt"; $domxml = new DOMDocument(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <big...@us...> - 2009-06-02 07:45:24
|
Revision: 226 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=226&view=rev Author: bigmichi1 Date: 2009-06-02 07:44:57 +0000 (Tue, 02 Jun 2009) Log Message: ----------- Fixed Bug [ 2798507 ] Ups monitoring on windows Modified Paths: -------------- ChangeLog includes/class.CommonFunctions.inc.php Modified: ChangeLog =================================================================== --- ChangeLog 2009-05-29 16:18:39 UTC (rev 225) +++ ChangeLog 2009-06-02 07:44:57 UTC (rev 226) @@ -31,6 +31,7 @@ - [FIX] Fixed Bug [ 2529373 ] Is update of README required? (details inside) - [FIX] Fixed Bug [ 2538522 ] PHP Notice in static display mode (patch included) - [FIX] Fixed Bug [ 2577019 ] r129 break a lot of things (FreeBSD support patch included) + - [FIX] Fixed Bug [ 2798507 ] Ups monitoring on windows - [FIX] Some fixes for recent /proc/mdstat files, also new sample file for tests - [FIX] Fedore distro must be read before Redhat - [FIX] Stop JavaScript alert popup when XML loading errors occurs Modified: includes/class.CommonFunctions.inc.php =================================================================== --- includes/class.CommonFunctions.inc.php 2009-05-29 16:18:39 UTC (rev 225) +++ includes/class.CommonFunctions.inc.php 2009-06-02 07:44:57 UTC (rev 226) @@ -42,7 +42,13 @@ */ private static function _findProgram($strProgram) { - $arrPath = array('/bin', '/sbin', '/usr/bin', '/usr/sbin', '/usr/local/bin', '/usr/local/sbin'); + $arrPath = array(); + if (PHP_OS == 'WINNT') { + $strProgram .= '.exe'; + $arrPath = explode(';', getenv("Path")); + } else { + $arrPath = explode(':', getenv("PATH")); + } if (PSI_ADD_PATHS !== false) { $addpaths = explode(',', PSI_ADD_PATHS); $arrPath = array_merge($addpaths, $arrPath); // In this order so $addpaths is before $arrPath when looking for a program @@ -51,19 +57,15 @@ if ((bool)ini_get('open_basedir')) { $open_basedir = explode(':', ini_get('open_basedir')); } - if (PHP_OS != 'WINNT') { - foreach ($arrPath as $strPath) { - // To avoid "open_basedir restriction in effect" error when testing paths if restriction is enabled - if (($open_basedir && !in_array($strPath, $open_basedir)) || !is_dir($strPath)) { - continue; - } - $strProgrammpath = $strPath."/".$strProgram; - if (is_executable($strProgrammpath)) { - return $strProgrammpath; - } + foreach ($arrPath as $strPath) { + // To avoid "open_basedir restriction in effect" error when testing paths if restriction is enabled + if ((isset($open_basedir) && !in_array($strPath, $open_basedir)) || !is_dir($strPath)) { + continue; } - } else { - return $strProgram.'.exe'; + $strProgrammpath = $strPath."/".$strProgram; + if (is_executable($strProgrammpath)) { + return $strProgrammpath; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <big...@us...> - 2009-06-06 13:26:41
|
Revision: 232 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=232&view=rev Author: bigmichi1 Date: 2009-06-06 13:26:40 +0000 (Sat, 06 Jun 2009) Log Message: ----------- RC7 Modified Paths: -------------- ChangeLog README README_PLUGIN includes/class.CommonFunctions.inc.php Modified: ChangeLog =================================================================== --- ChangeLog 2009-06-06 12:32:46 UTC (rev 231) +++ ChangeLog 2009-06-06 13:26:40 UTC (rev 232) @@ -1,6 +1,6 @@ $Id$ -phpSysInfo 3.0 +phpSysInfo 3.0 RC-7, 2009-06-06 - [ADD] Korean, Danish, Finnish, Asturian, Slovene translation - [ADD] Option to hide disks (partitions) - [ADD] New definition file for our xml Modified: README =================================================================== --- README 2009-06-06 12:32:46 UTC (rev 231) +++ README 2009-06-06 13:26:40 UTC (rev 232) @@ -1,4 +1,4 @@ -phpSysInfo 3.0-RC6 - http://phpsysinfo.sourceforge.net/ +phpSysInfo 3.0-RC7 - http://phpsysinfo.sourceforge.net/ Copyright (c), 1999-2008, Uriah Welcome (pre...@us...) Copyright (c), 1999-2009, Michael Cramer (big...@us...) Modified: README_PLUGIN =================================================================== --- README_PLUGIN 2009-06-06 12:32:46 UTC (rev 231) +++ README_PLUGIN 2009-06-06 13:26:40 UTC (rev 232) @@ -1,4 +1,4 @@ -phpSysInfo 3.0-RC6 - http://phpsysinfo.sourceforge.net/ +phpSysInfo 3.0-RC7 - http://phpsysinfo.sourceforge.net/ Document written by Michael Cramer (bigmichi1 at sourceforge.net) !!Please read if you want to develop a plugin to understand our plugin system!! Modified: includes/class.CommonFunctions.inc.php =================================================================== --- includes/class.CommonFunctions.inc.php 2009-06-06 12:32:46 UTC (rev 231) +++ includes/class.CommonFunctions.inc.php 2009-06-06 13:26:40 UTC (rev 232) @@ -30,7 +30,7 @@ * * @var string */ - const PSI_VERSION = '3.0-rc6'; + const PSI_VERSION = '3.0-rc7'; /** * Find a system program, do also path checking when not running on WINNT This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <big...@us...> - 2009-06-17 13:06:50
|
Revision: 252 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=252&view=rev Author: bigmichi1 Date: 2009-06-17 13:06:44 +0000 (Wed, 17 Jun 2009) Log Message: ----------- Device TrasportObjects Added Paths: ----------- includes/to/ includes/to/device/ includes/to/device/class.CpuDevice.inc.php includes/to/device/class.DiskDevice.inc.php includes/to/device/class.HWDevice.inc.php includes/to/device/class.NetDevice.inc.php includes/to/device/class.SensorDevice.inc.php Added: includes/to/device/class.CpuDevice.inc.php =================================================================== --- includes/to/device/class.CpuDevice.inc.php (rev 0) +++ includes/to/device/class.CpuDevice.inc.php 2009-06-17 13:06:44 UTC (rev 252) @@ -0,0 +1,259 @@ +<?php +/** + * CpuDevice TO class + * + * PHP version 5 + * + * @category PHP + * @package PSI_TO + * @author Michael Cramer <Big...@us...> + * @copyright 2009 phpSysInfo + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @version SVN: $Id$ + * @link http://phpsysinfo.sourceforge.net + */ + /** + * CpuDevice TO class + * + * @category PHP + * @package PSI_TO + * @author Michael Cramer <Big...@us...> + * @copyright 2009 phpSysInfo + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @version Release: 3.0 + * @link http://phpsysinfo.sourceforge.net + */ +class CpuDevice +{ + /** + * model of the cpu + * + * @var String + */ + private $_model = ""; + + /** + * speed of the cpu in hertz + * + * @var Integer + */ + private $_cpuSpeed = 0; + + /** + * cache size in bytes, if available + * + * @var Integer + */ + private $_cache = null; + + /** + * busspeed in hertz, if available + * + * @var Integer + */ + private $_busSpeed = null; + + /** + * temperature of the cpu, if available + * + * @var Integer + */ + private $_temp = null; + + /** + * bogomips of the cpu, if available + * + * @var Integer + */ + private $_bogomips = null; + + /** + * current load in percent of the cpu, if available + * + * @var Integer + */ + private $_load = null; + + /** + * Returns $_bogomips. + * + * @see Cpu::$_bogomips + * + * @return Integer + */ + public function getBogomips() + { + return $this->_bogomips; + } + + /** + * Sets $_bogomips. + * + * @param Integer $bogomips bogompis + * + * @see Cpu::$_bogomips + * + * @return Void + */ + public function setBogomips($bogomips) + { + $this->_bogomips = $bogomips; + } + + /** + * Returns $_busSpeed. + * + * @see Cpu::$_busSpeed + * + * @return Integer + */ + public function getBusSpeed() + { + return $this->_busSpeed; + } + + /** + * Sets $_busSpeed. + * + * @param Integer $busSpeed busspeed + * + * @see Cpu::$_busSpeed + * + * @return Void + */ + public function setBusSpeed($busSpeed) + { + $this->_busSpeed = $busSpeed; + } + + /** + * Returns $_cache. + * + * @see Cpu::$_cache + * + * @return Integer + */ + public function getCache() + { + return $this->_cache; + } + + /** + * Sets $_cache. + * + * @param Integer $cache cache size + * + * @see Cpu::$_cache + * + * @return Void + */ + public function setCache($cache) + { + $this->_cache = $cache; + } + + /** + * Returns $_cpuSpeed. + * + * @see Cpu::$_cpuSpeed + * + * @return Integer + */ + public function getCpuSpeed() + { + return $this->_cpuSpeed; + } + + /** + * Sets $_cpuSpeed. + * + * @param Integer $cpuSpeed cpuspeed + * + * @see Cpu::$_cpuSpeed + * + * @return Void + */ + public function setCpuSpeed($cpuSpeed) + { + $this->_cpuSpeed = $cpuSpeed; + } + + /** + * Returns $_model. + * + * @see Cpu::$_model + * + * @return String + */ + public function getModel() + { + return $this->_model; + } + + /** + * Sets $_model. + * + * @param String $model cpumodel + * + * @see Cpu::$_model + * + * @return Void + */ + public function setModel($model) + { + $this->_model = $model; + } + + /** + * Returns $_temp. + * + * @see Cpu::$_temp + * + * @return Integer + */ + public function getTemp() + { + return $this->_temp; + } + + /** + * Sets $_temp. + * + * @param Integer $temp temperature + * + * @see Cpu::$_temp + * + * @return Void + */ + public function setTemp($temp) + { + $this->_temp = $temp; + } + + /** + * Returns $_load. + * + * @see CpuDevice::$_load + * + * @return Integer + */ + public function getLoad() + { + return $this->_load; + } + + /** + * Sets $_load. + * + * @param Integer $load load percent + * + * @see CpuDevice::$_load + * + * @return Void + */ + public function setLoad($load) + { + $this->_load = $load; + } +} +?> Property changes on: includes/to/device/class.CpuDevice.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/to/device/class.DiskDevice.inc.php =================================================================== --- includes/to/device/class.DiskDevice.inc.php (rev 0) +++ includes/to/device/class.DiskDevice.inc.php 2009-06-17 13:06:44 UTC (rev 252) @@ -0,0 +1,310 @@ +<?php +/** + * DiskDevice TO class + * + * PHP version 5 + * + * @category PHP + * @package PSI_TO + * @author Michael Cramer <Big...@us...> + * @copyright 2009 phpSysInfo + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @version SVN: $Id$ + * @link http://phpsysinfo.sourceforge.net + */ + /** + * DiskDevice TO class + * + * @category PHP + * @package PSI_TO + * @author Michael Cramer <Big...@us...> + * @copyright 2009 phpSysInfo + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @version Release: 3.0 + * @link http://phpsysinfo.sourceforge.net + */ +class DiskDevice +{ + /** + * name of the disk device + * + * @var String + */ + private $_name = ""; + + /** + * type of the filesystem on the disk device + * + * @var String + */ + private $_fsType = ""; + + /** + * diskspace that is free in bytes + * + * @var Integer + */ + private $_free = 0; + + /** + * diskspace that is used in bytes + * + * @var Integer + */ + private $_used = 0; + + /** + * total diskspace + * + * @var Integer + */ + private $_total = 0; + + /** + * mount point of the disk device if available + * + * @var String + */ + private $_mountPoint = null; + + /** + * additional options of the device, like mount options + * + * @var String + */ + private $_options = null; + + /** + * inodes usage in percent if available + * + * @var + */ + private $_percentInodesUsed = null; + + /** + * Returns PercentUsed calculated when function is called from internal values + * + * @see DiskDevice::$_total + * @see DiskDevice::$_used + * + * @return Integer + */ + public function getPercentUsed() + { + if ($this->_total > 0) { + return ceil($this->_used / $this->_total * 100); + } else { + return 0; + } + } + + + /** + * Returns $_PercentInodesUsed. + * + * @see DiskDevice::$_PercentInodesUsed + * + * @return Integer + */ + public function getPercentInodesUsed() + { + return $this->_percentInodesUsed; + } + + /** + * Sets $_PercentInodesUsed. + * + * @param Integer $percentInodesUsed inodes percent + * + * @see DiskDevice::$_PercentInodesUsed + * + * @return Void + */ + public function setPercentInodesUsed($percentInodesUsed) + { + $this->_percentInodesUsed = $percentInodesUsed; + } + + /** + * Returns $_free. + * + * @see DiskDevice::$_free + * + * @return Integer + */ + public function getFree() + { + return $this->_free; + } + + /** + * Sets $_free. + * + * @param Integer $free free bytes + * + * @see DiskDevice::$_free + * + * @return Void + */ + public function setFree($free) + { + $this->_free = $free; + } + + /** + * Returns $_fsType. + * + * @see DiskDevice::$_fsType + * + * @return String + */ + public function getFsType() + { + return $this->_fsType; + } + + /** + * Sets $_fsType. + * + * @param String $fsType filesystemtype + * + * @see DiskDevice::$_fsType + * + * @return Void + */ + public function setFsType($fsType) + { + $this->_fsType = $fsType; + } + + /** + * Returns $_mountPoint. + * + * @see DiskDevice::$_mountPoint + * + * @return String + */ + public function getMountPoint() + { + return $this->_mountPoint; + } + + /** + * Sets $_mountPoint. + * + * @param String $mountPoint mountpoint + * + * @see DiskDevice::$_mountPoint + * + * @return Void + */ + public function setMountPoint($mountPoint) + { + $this->_mountPoint = $mountPoint; + } + + /** + * Returns $_name. + * + * @see DiskDevice::$_name + * + * @return String + */ + public function getName() + { + return $this->_name; + } + + /** + * Sets $_name. + * + * @param String $name device name + * + * @see DiskDevice::$_name + * + * @return Void + */ + public function setName($name) + { + $this->_name = $name; + } + + /** + * Returns $_options. + * + * @see DiskDevice::$_options + * + * @return String + */ + public function getOptions() + { + return $this->_options; + } + + /** + * Sets $_options. + * + * @param String $options additional options + * + * @see DiskDevice::$_options + * + * @return Void + */ + public function setOptions($options) + { + $this->_options = $options; + } + + /** + * Returns $_total. + * + * @see DiskDevice::$_total + * + * @return Integer + */ + public function getTotal() + { + return $this->_total; + } + + /** + * Sets $_total. + * + * @param Integer $total total bytes + * + * @see DiskDevice::$_total + * + * @return Void + */ + public function setTotal($total) + { + $this->_total = $total; + } + + /** + * Returns $_used. + * + * @see DiskDevice::$_used + * + * @return Integer + */ + public function getUsed() + { + return $this->_used; + } + + /** + * Sets $_used. + * + * @param Integer $used used bytes + * + * @see DiskDevice::$_used + * + * @return Void + */ + public function setUsed($used) + { + $this->_used = $used; + } +} +?> Property changes on: includes/to/device/class.DiskDevice.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/to/device/class.HWDevice.inc.php =================================================================== --- includes/to/device/class.HWDevice.inc.php (rev 0) +++ includes/to/device/class.HWDevice.inc.php 2009-06-17 13:06:44 UTC (rev 252) @@ -0,0 +1,144 @@ +<?php +/** + * HWDevice TO class + * + * PHP version 5 + * + * @category PHP + * @package PSI_TO + * @author Michael Cramer <Big...@us...> + * @copyright 2009 phpSysInfo + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @version SVN: $Id$ + * @link http://phpsysinfo.sourceforge.net + */ + /** + * HWDevice TO class + * + * @category PHP + * @package PSI_TO + * @author Michael Cramer <Big...@us...> + * @copyright 2009 phpSysInfo + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @version Release: 3.0 + * @link http://phpsysinfo.sourceforge.net + */ +class HWDevice +{ + /** + * name of the device + * + * @var String + */ + private $_name = ""; + + /** + * capacity of the device, if not available it will be null + * + * @var Integer + */ + private $_capacity = null; + + /** + * count of the device + * + * @var Integer + */ + private $_count = 1; + + /** + * compare a given device with the internal one + * + * @param HWDevice $dev device that should be compared + * + * @return boolean + */ + public function equals($dev) + { + if ($dev->get_name() === $this->_name && $dev->get_capacity() === $this->_capacity) { + return true; + } else { + return false; + } + } + + /** + * Returns $_capacity. + * + * @see HWDevice::$_capacity + * + * @return Integer + */ + public function getCapacity() + { + return $this->_capacity; + } + + /** + * Sets $_capacity. + * + * @param Integer $capacity device capacity + * + * @see HWDevice::$_capacity + * + * @return Void + */ + public function setCapacity($capacity) + { + $this->_capacity = $capacity; + } + + /** + * Returns $_name. + * + * @see HWDevice::$_name + * + * @return String + */ + public function getName() + { + return $this->_name; + } + + /** + * Sets $_name. + * + * @param String $name device name + * + * @see HWDevice::$_name + * + * @return Void + */ + public function setName($name) + { + $this->_name = $name; + } + + + /** + * Returns $_count. + * + * @see HWDevice::$_count + * + * @return Integer + */ + public function getCount() + { + return $this->_count; + } + + /** + * Sets $_count. + * + * @param Integer $count device count + * + * @see HWDevice::$_count + * + * @return Void + */ + public function setCount($count) + { + $this->_count = $count; + } +} +?> Property changes on: includes/to/device/class.HWDevice.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/to/device/class.NetDevice.inc.php =================================================================== --- includes/to/device/class.NetDevice.inc.php (rev 0) +++ includes/to/device/class.NetDevice.inc.php 2009-06-17 13:06:44 UTC (rev 252) @@ -0,0 +1,193 @@ +<?php +/** + * NetDevice TO class + * + * PHP version 5 + * + * @category PHP + * @package PSI_TO + * @author Michael Cramer <Big...@us...> + * @copyright 2009 phpSysInfo + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @version SVN: $Id$ + * @link http://phpsysinfo.sourceforge.net + */ + /** + * NetDevice TO class + * + * @category PHP + * @package PSI_TO + * @author Michael Cramer <Big...@us...> + * @copyright 2009 phpSysInfo + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @version Release: 3.0 + * @link http://phpsysinfo.sourceforge.net + */ +class NetDevice +{ + /** + * name of the device + * + * @var String + */ + private $_name = ""; + + /** + * transmitted bytes + * + * @var Integer + */ + private $_txBytes = 0; + + /** + * received bytes + * + * @var Integer + */ + private $_rxBytes = 0; + + /** + * counted error packages + * + * @var Integer + */ + private $_errors = 0; + + /** + * counted droped packages + * + * @var Integer + */ + private $_drops = 0; + + /** + * Returns $_drops. + * + * @see NetDevice::$_drops + * + * @return Integer + */ + public function getDrops() + { + return $this->_drops; + } + + /** + * Sets $_drops. + * + * @param Integer $drops dropped packages + * + * @see NetDevice::$_drops + * + * @return Void + */ + public function setDrops($drops) + { + $this->_drops = $drops; + } + + /** + * Returns $_errors. + * + * @see NetDevice::$_errors + * + * @return Integer + */ + public function getErrors() + { + return $this->_errors; + } + + /** + * Sets $_errors. + * + * @param Integer $errors error packages + * + * @see NetDevice::$_errors + * + * @return Void + */ + public function setErrors($errors) + { + $this->_errors = $errors; + } + + /** + * Returns $_name. + * + * @see NetDevice::$_name + * + * @return String + */ + public function getName() + { + return $this->_name; + } + + /** + * Sets $_name. + * + * @param String $name device name + * + * @see NetDevice::$_name + * + * @return Void + */ + public function setName($name) + { + $this->_name = $name; + } + + /** + * Returns $_rxBytes. + * + * @see NetDevice::$_rxBytes + * + * @return Integer + */ + public function getRxBytes() + { + return $this->_rxBytes; + } + + /** + * Sets $_rxBytes. + * + * @param Integer $rxBytes received bytes + * + * @see NetDevice::$_rxBytes + * + * @return Void + */ + public function setRxBytes($rxBytes) + { + $this->_rxBytes = $rxBytes; + } + + /** + * Returns $_txBytes. + * + * @see NetDevice::$_txBytes + * + * @return Integer + */ + public function getTxBytes() + { + return $this->_txBytes; + } + + /** + * Sets $_txBytes. + * + * @param Integer $txBytes transmitted bytes + * + * @see NetDevice::$_txBytes + * + * @return Void + */ + public function setTxBytes($txBytes) + { + $this->_txBytes = $txBytes; + } +} +?> Property changes on: includes/to/device/class.NetDevice.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF Added: includes/to/device/class.SensorDevice.inc.php =================================================================== --- includes/to/device/class.SensorDevice.inc.php (rev 0) +++ includes/to/device/class.SensorDevice.inc.php 2009-06-17 13:06:44 UTC (rev 252) @@ -0,0 +1,161 @@ +<?php +/** + * SensorDevice TO class + * + * PHP version 5 + * + * @category PHP + * @package PSI_TO + * @author Michael Cramer <Big...@us...> + * @copyright 2009 phpSysInfo + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @version SVN: $Id$ + * @link http://phpsysinfo.sourceforge.net + */ + /** + * SensorDevice TO class + * + * @category PHP + * @package PSI_TO + * @author Michael Cramer <Big...@us...> + * @copyright 2009 phpSysInfo + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @version Release: 3.0 + * @link http://phpsysinfo.sourceforge.net + */ +class SensorDevice +{ + /** + * name of the sensor + * + * @var String + */ + private $_name = ""; + + /** + * current value of the sensor + * + * @var Integer + */ + private $_value = 0; + + /** + * maximum value of the sensor + * + * @var Integer + */ + private $_max = 0; + + /** + * minimum value of the sensor + * + * @var Integer + */ + private $_min = 0; + + + /** + * Returns $_max. + * + * @see Sensor::$_max + * + * @return Integer + */ + public function getMax() + { + return $this->_max; + } + + /** + * Sets $_max. + * + * @param Integer $max maximum value + * + * @see Sensor::$_max + * + * @return Void + */ + public function setMax($max) + { + $this->_max = $max; + } + + /** + * Returns $_min. + * + * @see Sensor::$_min + * + * @return Integer + */ + public function getMin() + { + return $this->_min; + } + + /** + * Sets $_min. + * + * @param Integer $min minimum value + * + * @see Sensor::$_min + * + * @return Void + */ + public function setMin($min) + { + $this->_min = $min; + } + + /** + * Returns $_name. + * + * @see Sensor::$_name + * + * @return String + */ + public function getName() + { + return $this->_name; + } + + /** + * Sets $_name. + * + * @param String $name sensor name + * + * @see Sensor::$_name + * + * @return Void + */ + public function setName($name) + { + $this->_name = $name; + } + + /** + * Returns $_value. + * + * @see Sensor::$_value + * + * @return Integer + */ + public function getValue() + { + return $this->_value; + } + + /** + * Sets $_value. + * + * @param Integer $value current value + * + * @see Sensor::$_value + * + * @return Void + */ + public function setValue($value) + { + $this->_value = $value; + } +} +?> Property changes on: includes/to/device/class.SensorDevice.inc.php ___________________________________________________________________ Added: svn:mime-type + text/x-php Added: svn:keywords + Id Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Big...@us...> - 2009-07-18 12:15:41
|
Revision: 304 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=304&view=rev Author: BigMichi1 Date: 2009-07-18 12:15:12 +0000 (Sat, 18 Jul 2009) Log Message: ----------- remove strtolower for case sensitive plugin names Modified Paths: -------------- includes/autoloader.inc.php includes/output/class.Webpage.inc.php includes/plugin/class.PSI_Plugin.inc.php Modified: includes/autoloader.inc.php =================================================================== --- includes/autoloader.inc.php 2009-07-18 11:59:56 UTC (rev 303) +++ includes/autoloader.inc.php 2009-07-18 12:15:12 UTC (rev 304) @@ -25,7 +25,7 @@ function __autoload($class_name) { $class_name = str_replace('-', '', $class_name); - $dirs = array('/plugins/'.strtolower($class_name).'/', '/includes/', '/includes/interface/', '/includes/to/', '/includes/to/device/', '/includes/os/', '/includes/mb/', '/includes/plugin/', '/includes/xml/', '/includes/web/', '/includes/error/', '/includes/js/', '/includes/output/', '/includes/ups/'); + $dirs = array('/plugins/'.$class_name.'/', '/includes/', '/includes/interface/', '/includes/to/', '/includes/to/device/', '/includes/os/', '/includes/mb/', '/includes/plugin/', '/includes/xml/', '/includes/web/', '/includes/error/', '/includes/js/', '/includes/output/', '/includes/ups/'); foreach ($dirs as $dir) { if (file_exists(APP_ROOT.$dir.'class.'.$class_name.'.inc.php')) { Modified: includes/output/class.Webpage.inc.php =================================================================== --- includes/output/class.Webpage.inc.php 2009-07-18 11:59:56 UTC (rev 303) +++ includes/output/class.Webpage.inc.php 2009-07-18 12:15:12 UTC (rev 304) @@ -149,7 +149,7 @@ echo " <script type=\"text/JavaScript\" src=\"./js.php?name=jquery.treeTable\"></script>\n"; echo " <script type=\"text/JavaScript\" src=\"./js.php?name=phpsysinfo\"></script>\n"; foreach (CommonFunctions::getPlugins() as $plugin) { - echo " <script type=\"text/JavaScript\" src=\"./js.php?plugin=".strtolower(trim($plugin))."&name=".trim($plugin)."\"></script>\n"; + echo " <script type=\"text/JavaScript\" src=\"./js.php?plugin=".trim($plugin)."&name=".trim($plugin)."\"></script>\n"; } echo " <title>PhpSysInfo ".CommonFunctions::PSI_VERSION."</title>\n"; echo " </head>\n"; Modified: includes/plugin/class.PSI_Plugin.inc.php =================================================================== --- includes/plugin/class.PSI_Plugin.inc.php 2009-07-18 11:59:56 UTC (rev 303) +++ includes/plugin/class.PSI_Plugin.inc.php 2009-07-18 12:15:12 UTC (rev 304) @@ -71,7 +71,7 @@ $this->global_error = Error::Singleton(); if (trim($plugin_name) != "") { $this->_plugin_name = $plugin_name; - $this->_plugin_base = APP_ROOT."/plugins/".strtolower($this->_plugin_name)."/"; + $this->_plugin_base = APP_ROOT."/plugins/".$this->_plugin_name."/"; $this->_checkfiles(); $this->_getconfig(); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <big...@us...> - 2009-09-02 15:48:38
|
Revision: 315 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=315&view=rev Author: bigmichi1 Date: 2009-09-02 15:48:31 +0000 (Wed, 02 Sep 2009) Log Message: ----------- remove errorsAsHTML() fix "Undefined variable" and "undefined constant" in class.Error.inc.php Modified Paths: -------------- includes/autoloader.inc.php includes/error/class.Error.inc.php includes/output/class.Output.inc.php includes/output/class.WebpageXML.inc.php Modified: includes/autoloader.inc.php =================================================================== --- includes/autoloader.inc.php 2009-08-22 14:55:22 UTC (rev 314) +++ includes/autoloader.inc.php 2009-09-02 15:48:31 UTC (rev 315) @@ -37,8 +37,7 @@ $error = Error::singleton(); $error->addError("_autoload(\"".$class_name."\")", "autoloading of class file (class.".$class_name.".inc.php) failed!"); - echo $error->errorsAsHTML(); - die(); + $error->errorsAsXML(); } /** Modified: includes/error/class.Error.inc.php =================================================================== --- includes/error/class.Error.inc.php 2009-08-22 14:55:22 UTC (rev 314) +++ includes/error/class.Error.inc.php 2009-09-02 15:48:31 UTC (rev 315) @@ -124,53 +124,28 @@ } /** - * converts the internal error and warning list in a html table - * - * @return string contains a HTML table which can be used to echo out the errors - */ - public function errorsAsHTML() - { - $strHTMLString = ""; - $strWARNString = ""; - $strHTMLhead = "<table width=\"100%\" border=\"0\">\n"."\t<tr>\n"."\t\t<td><font size=\"-1\"><b>Command</b></font></td>\n"."\t\t<td><font size=\"-1\"><b>Message</b></font></td>\n"."\t</tr>\n"; - $strHTMLfoot = "</table>\n"; - if ($this->_errors > 0) { - foreach ($this->_arrErrorList as $arrLine) { - if ($arrLine['command'] == "WARN") { - $strWARNString .= "<font size=\"-1\"><b>WARNING: ".str_replace("\n", "<br/>", htmlspecialchars($arrLine['message']))."</b></font><br/>\n"; - } else { - $strHTMLString .= "\t<tr>\n"."\t\t<td><font size=\"-1\">".htmlspecialchars($arrLine['command'])."</font></td>\n"."\t\t<td><font size=\"-1\">".str_replace("\n", "<br/>", $arrLine['message'])."</font></td>\n"."\t</tr>\n"; - } - } - } - if (! empty($strHTMLString)) { - $strHTMLString = $strWARNString.$strHTMLhead.$strHTMLString.$strHTMLfoot; - } else { - $strHTMLString = $strWARNString; - } - return $strHTMLString; - } - - /** * converts the internal error and warning list to a XML file * - * @return string XML data containing the errors + * @return void */ public function errorsAsXML() { - $dom = new DOMDocument(); + $dom = new DOMDocument('1.0', 'UTF-8'); $root = $dom->createElement("phpsysinfo"); $dom->appendChild($root); - $xml = new SimpleXMLExtended(simplexml_import_dom($dom), $encoding); + $xml = new SimpleXMLExtended(simplexml_import_dom($dom), 'UTF-8'); $generation = $xml->addChild('Generation'); - $generation->addAttribute('version', PSI_VERSION); + $generation->addAttribute('version', CommonFunctions::PSI_VERSION); $generation->addAttribute('timestamp', time()); $xmlerr = $xml->addChild("Errors"); foreach ($this->_arrErrorList as $arrLine) { $error = $xmlerr->addCData('Error', $arrLine['message']); $error->addAttribute('Function', $arrLine['command']); } - return $xml->getSimpleXmlElement()->asXML(); + 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 Modified: includes/output/class.Output.inc.php =================================================================== --- includes/output/class.Output.inc.php 2009-08-22 14:55:22 UTC (rev 314) +++ includes/output/class.Output.inc.php 2009-09-02 15:48:31 UTC (rev 315) @@ -55,8 +55,7 @@ include_once APP_ROOT.'/config.php'; } if ($this->error->errorsExist()) { - echo $this->error->errorsAsHTML(); - exit; + $this->error->errorsAsXML(); } } } Modified: includes/output/class.WebpageXML.inc.php =================================================================== --- includes/output/class.WebpageXML.inc.php 2009-08-22 14:55:22 UTC (rev 314) +++ includes/output/class.WebpageXML.inc.php 2009-09-02 15:48:31 UTC (rev 315) @@ -114,9 +114,7 @@ // if there are errors stop executing the script until they are fixed if ($this->error->errorsExist()) { - header("Content-Type: text/xml\n\n"); - echo $this->error->errorsAsXML(); - exit; + $this->error->errorsAsXML(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <big...@us...> - 2009-09-07 11:57:41
|
Revision: 331 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=331&view=rev Author: bigmichi1 Date: 2009-09-07 11:57:19 +0000 (Mon, 07 Sep 2009) Log Message: ----------- release RC-9 Modified Paths: -------------- ChangeLog README README_PLUGIN includes/class.CommonFunctions.inc.php Modified: ChangeLog =================================================================== --- ChangeLog 2009-09-07 11:49:04 UTC (rev 330) +++ ChangeLog 2009-09-07 11:57:19 UTC (rev 331) @@ -1,6 +1,6 @@ $Id$ -phpSysInfo 3.0 +phpSysInfo 3.0 RC-9, 2009-09-07 - [FIX] Fixed Bug [ 2803472 ] Error loading XML document if no swap if activated - [FIX] Fixed Bug [ 2803964 ] Disabling language or template picklist fails - [FIX] Fixed Bug [ 2803480 ] Empty page when hddtemp enabled Modified: README =================================================================== --- README 2009-09-07 11:49:04 UTC (rev 330) +++ README 2009-09-07 11:57:19 UTC (rev 331) @@ -1,4 +1,4 @@ -phpSysInfo 3.0-RC8 - http://phpsysinfo.sourceforge.net/ +phpSysInfo 3.0-RC9 - http://phpsysinfo.sourceforge.net/ Copyright (c), 1999-2008, Uriah Welcome (pre...@us...) Copyright (c), 1999-2009, Michael Cramer (big...@us...) Modified: README_PLUGIN =================================================================== --- README_PLUGIN 2009-09-07 11:49:04 UTC (rev 330) +++ README_PLUGIN 2009-09-07 11:57:19 UTC (rev 331) @@ -1,4 +1,4 @@ -phpSysInfo 3.0-RC8 - http://phpsysinfo.sourceforge.net/ +phpSysInfo 3.0-RC9 - http://phpsysinfo.sourceforge.net/ Document written by Michael Cramer (bigmichi1 at sourceforge.net) !!Please read if you want to develop a plugin to understand our plugin system!! Modified: includes/class.CommonFunctions.inc.php =================================================================== --- includes/class.CommonFunctions.inc.php 2009-09-07 11:49:04 UTC (rev 330) +++ includes/class.CommonFunctions.inc.php 2009-09-07 11:57:19 UTC (rev 331) @@ -30,7 +30,7 @@ * * @var string */ - const PSI_VERSION = '3.0-RC8'; + const PSI_VERSION = '3.0-RC9'; /** * Find a system program, do also path checking when not running on WINNT This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <big...@us...> - 2009-09-25 07:58:43
|
Revision: 335 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=335&view=rev Author: bigmichi1 Date: 2009-09-25 07:58:30 +0000 (Fri, 25 Sep 2009) Log Message: ----------- add special Error Metjod for PHP-Warnigs triggered by errorHandlerPsi Modified Paths: -------------- includes/autoloader.inc.php includes/error/class.Error.inc.php Modified: includes/autoloader.inc.php =================================================================== --- includes/autoloader.inc.php 2009-09-16 15:21:39 UTC (rev 334) +++ includes/autoloader.inc.php 2009-09-25 07:58:30 UTC (rev 335) @@ -53,7 +53,7 @@ function errorHandlerPsi($level, $message, $file, $line) { $error = Error::singleton(); - $error->addError("errorHandlerPsi : ", "Level : ".$level." Message : ".$message." File : ".$file." Line : ".$line); + $error->addPhpError("errorHandlerPsi : ", "Level : ".$level." Message : ".$message." File : ".$file." Line : ".$line); } set_error_handler('errorHandlerPsi'); Modified: includes/error/class.Error.inc.php =================================================================== --- includes/error/class.Error.inc.php 2009-09-16 15:21:39 UTC (rev 334) +++ includes/error/class.Error.inc.php 2009-09-25 07:58:30 UTC (rev 335) @@ -81,7 +81,7 @@ } /** - * adds an error to the internal list + * 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 @@ -90,9 +90,22 @@ */ 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'] = $this->_trace($strMessage); + $this->_arrErrorList[$index]['message'] = $strMessage; $this->_errors++; } @@ -106,9 +119,22 @@ */ public function addConfigError($strCommand, $strMessage) { - $this->addError($strCommand, "Wrong Value in config.php for ".$strMessage); + $this->_addError($strCommand, "Wrong Value in config.php for ".$strMessage); } + /** + * add a php error to the internal list + * + * @param object $strCommand Command, which cause the Error + * @param object $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 * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |