* Mon May 12 2025 Brian Read <brianr@koozali.org> 11.0.0-1.sme
- Adding SM2 panel [SME: 13004] - Upgrade to phpsysinfo 3.4.4 - Add code to delete inline styles and add css to make it look better. - version saved / built uses the static version, which means no drops downs and choices.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* @package PSI
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version SVN: $Id: class.Parser.inc.php 604 2012-07-10 07:31:34Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -19,7 +19,7 @@
|
||||
* @package PSI
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -28,22 +28,44 @@ class Parser
|
||||
/**
|
||||
* parsing the output of lspci command
|
||||
*
|
||||
* @return Array
|
||||
* @param bool $debug
|
||||
* @return array
|
||||
*/
|
||||
public static function lspci($debug = PSI_DEBUG)
|
||||
{
|
||||
$arrResults = array();
|
||||
if (CommonFunctions::executeProgram("lspci", "", $strBuf, $debug)) {
|
||||
if (CommonFunctions::executeProgram("lspci", (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS)?"-m":"", $strBuf, $debug)) {
|
||||
$arrLines = preg_split("/\n/", $strBuf, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($arrLines as $strLine) {
|
||||
$arrParams = preg_split('/ /', trim($strLine), 2);
|
||||
if (count($arrParams) == 2)
|
||||
$strName = $arrParams[1];
|
||||
else
|
||||
$strName = "unknown";
|
||||
$strName = preg_replace('/\(.*\)/', '', $strName);
|
||||
$dev = new HWDevice();
|
||||
$dev->setName($strName);
|
||||
$arrParams = preg_split('/(\"? ")|(\" (?=-))/', trim($strLine));
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS && ($cp = count($arrParams)) >= 6) {
|
||||
$arrParams[$cp-1] = trim($arrParams[$cp-1], '"'); // remove last "
|
||||
$dev->setName($arrParams[1].': '.$arrParams[2].' '.$arrParams[3]);
|
||||
if (preg_match('/^-/', $arrParams[4])) {
|
||||
if (($arrParams[5] !== "") && !preg_match('/^Unknown vendor/', $arrParams[5])) {
|
||||
$dev->setManufacturer(trim($arrParams[5]));
|
||||
}
|
||||
if (($arrParams[6] !== "") && !preg_match('/^Device /', $arrParams[6])) {
|
||||
$dev->setProduct(trim($arrParams[6]));
|
||||
}
|
||||
} else {
|
||||
if (($arrParams[4] !== "") && !preg_match('/^Unknown vendor/', $arrParams[4])) {
|
||||
$dev->setManufacturer(trim($arrParams[4]));
|
||||
}
|
||||
if (($arrParams[5] !== "") && !preg_match('/^Device /', $arrParams[5])) {
|
||||
$dev->setProduct(trim($arrParams[5]));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$strLine=trim(preg_replace('/(")|( -\S+)/', '', $strLine));
|
||||
$arrParams = preg_split('/ /', trim($strLine), 2);
|
||||
if (count($arrParams) == 2)
|
||||
$strName = preg_replace('/\(rev\s[^\)]+\)/', '', $arrParams[1]);
|
||||
else
|
||||
$strName = "unknown";
|
||||
$dev->setName($strName);
|
||||
}
|
||||
$arrResults[] = $dev;
|
||||
}
|
||||
}
|
||||
@@ -54,48 +76,66 @@ class Parser
|
||||
/**
|
||||
* parsing the output of df command
|
||||
*
|
||||
* @param string $df_param additional parameter for df command
|
||||
* @param string $df_param additional parameter for df command
|
||||
* @param bool $get_inodes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function df($df_param = "")
|
||||
public static function df($df_param = "", $get_inodes = true)
|
||||
{
|
||||
$arrResult = array();
|
||||
if (CommonFunctions::executeProgram('mount', '', $mount, PSI_DEBUG)) {
|
||||
$mount = preg_split("/\n/", $mount, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($mount as $mount_line) {
|
||||
if (preg_match("/(\S+) on ([\S ]+) type (.*) \((.*)\)/", $mount_line, $mount_buf)) {
|
||||
$mount_parm[$mount_buf[2]]['fstype'] = $mount_buf[3];
|
||||
$mount_parm[$mount_buf[2]]['name'] = $mount_buf[1];
|
||||
if (PSI_SHOW_MOUNT_OPTION) $mount_parm[$mount_buf[2]]['options'] = $mount_buf[4];
|
||||
$parm = array();
|
||||
$parm['mountpoint'] = trim($mount_buf[2]);
|
||||
$parm['fstype'] = $mount_buf[3];
|
||||
$parm['name'] = $mount_buf[1];
|
||||
if (PSI_SHOW_MOUNT_OPTION) $parm['options'] = $mount_buf[4];
|
||||
$mount_parm[] = $parm;
|
||||
} elseif (preg_match("/(\S+) is (.*) mounted on (\S+) \(type (.*)\)/", $mount_line, $mount_buf)) {
|
||||
$mount_parm[$mount_buf[3]]['fstype'] = $mount_buf[4];
|
||||
$mount_parm[$mount_buf[3]]['name'] = $mount_buf[1];
|
||||
if (PSI_SHOW_MOUNT_OPTION) $mount_parm[$mount_buf[3]]['options'] = $mount_buf[2];
|
||||
$parm = array();
|
||||
$parm['mountpoint'] = trim($mount_buf[3]);
|
||||
$parm['fstype'] = $mount_buf[4];
|
||||
$parm['name'] = $mount_buf[1];
|
||||
if (PSI_SHOW_MOUNT_OPTION) $parm['options'] = $mount_buf[2];
|
||||
$mount_parm[] = $parm;
|
||||
} elseif (preg_match("/(\S+) (.*) on (\S+) \((.*)\)/", $mount_line, $mount_buf)) {
|
||||
$mount_parm[$mount_buf[3]]['fstype'] = $mount_buf[2];
|
||||
$mount_parm[$mount_buf[3]]['name'] = $mount_buf[1];
|
||||
if (PSI_SHOW_MOUNT_OPTION) $mount_parm[$mount_buf[3]]['options'] = $mount_buf[4];
|
||||
$parm = array();
|
||||
$parm['mountpoint'] = trim($mount_buf[3]);
|
||||
$parm['fstype'] = $mount_buf[2];
|
||||
$parm['name'] = $mount_buf[1];
|
||||
if (PSI_SHOW_MOUNT_OPTION) $parm['options'] = $mount_buf[4];
|
||||
$mount_parm[] = $parm;
|
||||
} elseif (preg_match("/(\S+) on ([\S ]+) \((\S+)(,\s(.*))?\)/", $mount_line, $mount_buf)) {
|
||||
$mount_parm[$mount_buf[2]]['fstype'] = $mount_buf[3];
|
||||
$mount_parm[$mount_buf[2]]['name'] = $mount_buf[1];
|
||||
if (PSI_SHOW_MOUNT_OPTION) $mount_parm[$mount_buf[2]]['options'] = isset($mount_buf[5]) ? $mount_buf[5] : '';
|
||||
$parm = array();
|
||||
$parm['mountpoint'] = trim($mount_buf[2]);
|
||||
$parm['fstype'] = $mount_buf[3];
|
||||
$parm['name'] = $mount_buf[1];
|
||||
if (PSI_SHOW_MOUNT_OPTION) $parm['options'] = isset($mount_buf[5]) ? $mount_buf[5] : '';
|
||||
$mount_parm[] = $parm;
|
||||
}
|
||||
}
|
||||
} elseif (CommonFunctions::rfts("/etc/mtab", $mount)) {
|
||||
} elseif (CommonFunctions::rfts(((PSI_ROOT_FILESYSTEM === '')||(PSI_OS !== 'Linux'))?"/etc/mtab":"/proc/1/mounts", $mount)) {
|
||||
$mount = preg_split("/\n/", $mount, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($mount as $mount_line) {
|
||||
if (preg_match("/(\S+) (\S+) (\S+) (\S+) ([0-9]+) ([0-9]+)/", $mount_line, $mount_buf)) {
|
||||
$parm = array();
|
||||
$mount_point = preg_replace("/\\\\040/i", ' ', $mount_buf[2]); //space as \040
|
||||
$mount_parm[$mount_point]['fstype'] = $mount_buf[3];
|
||||
$mount_parm[$mount_point]['name'] = $mount_buf[1];
|
||||
if (PSI_SHOW_MOUNT_OPTION) $mount_parm[$mount_point]['options'] = $mount_buf[4];
|
||||
$parm['mountpoint'] = $mount_point;
|
||||
$parm['fstype'] = $mount_buf[3];
|
||||
$parm['name'] = $mount_buf[1];
|
||||
if (PSI_SHOW_MOUNT_OPTION) $parm['options'] = $mount_buf[4];
|
||||
$mount_parm[] = $parm;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CommonFunctions::executeProgram('df', '-k '.$df_param, $df, PSI_DEBUG)) {
|
||||
$df = "";
|
||||
CommonFunctions::executeProgram('df', '-k '.$df_param, $df, PSI_DEBUG);
|
||||
if ($df!=="") {
|
||||
$df = preg_split("/\n/", $df, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (PSI_SHOW_INODES) {
|
||||
if ($get_inodes && PSI_SHOW_INODES) {
|
||||
if (CommonFunctions::executeProgram('df', '-i '.$df_param, $df2, PSI_DEBUG)) {
|
||||
$df2 = preg_split("/\n/", $df2, -1, PREG_SPLIT_NO_EMPTY);
|
||||
// Store inode use% in an associative array (df_inodes) for later use
|
||||
@@ -133,13 +173,103 @@ class Parser
|
||||
}
|
||||
if (PSI_SHOW_MOUNT_POINT) $dev->setMountPoint($df_buf[5]);
|
||||
|
||||
if (isset($mount_parm[$df_buf[5]])) {
|
||||
$dev->setFsType($mount_parm[$df_buf[5]]['fstype']);
|
||||
$notwas = true;
|
||||
if (isset($mount_parm)) {
|
||||
foreach ($mount_parm as $mount_param) { //name and mountpoint find
|
||||
if (($mount_param['name']===trim($df_buf[0])) && ($mount_param['mountpoint']===$df_buf[5])) {
|
||||
$dev->setFsType($mount_param['fstype']);
|
||||
if (PSI_SHOW_MOUNT_OPTION && (trim($mount_param['options'])!=="")) {
|
||||
if (PSI_SHOW_MOUNT_CREDENTIALS) {
|
||||
$dev->setOptions($mount_param['options']);
|
||||
} else {
|
||||
$mpo=$mount_param['options'];
|
||||
|
||||
$mpo=preg_replace('/(^guest,)|(^guest$)|(,guest$)/i', '', $mpo);
|
||||
$mpo=preg_replace('/,guest,/i', ',', $mpo);
|
||||
|
||||
$mpo=preg_replace('/(^user=[^,]*,)|(^user=[^,]*$)|(,user=[^,]*$)/i', '', $mpo);
|
||||
$mpo=preg_replace('/,user=[^,]*,/i', ',', $mpo);
|
||||
|
||||
$mpo=preg_replace('/(^username=[^,]*,)|(^username=[^,]*$)|(,username=[^,]*$)/i', '', $mpo);
|
||||
$mpo=preg_replace('/,username=[^,]*,/i', ',', $mpo);
|
||||
|
||||
$mpo=preg_replace('/(^password=[^,]*,)|(^password=[^,]*$)|(,password=[^,]*$)/i', '', $mpo);
|
||||
$mpo=preg_replace('/,password=[^,]*,/i', ',', $mpo);
|
||||
|
||||
$dev->setOptions($mpo);
|
||||
}
|
||||
}
|
||||
$notwas = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($notwas) foreach ($mount_parm as $mount_param) { //mountpoint find
|
||||
if ($mount_param['mountpoint']===$df_buf[5]) {
|
||||
$dev->setFsType($mount_param['fstype']);
|
||||
if (PSI_SHOW_MOUNT_OPTION && (trim($mount_param['options'])!=="")) {
|
||||
if (PSI_SHOW_MOUNT_CREDENTIALS) {
|
||||
$dev->setOptions($mount_param['options']);
|
||||
} else {
|
||||
$mpo=$mount_param['options'];
|
||||
|
||||
$mpo=preg_replace('/(^guest,)|(^guest$)|(,guest$)/i', '', $mpo);
|
||||
$mpo=preg_replace('/,guest,/i', ',', $mpo);
|
||||
|
||||
$mpo=preg_replace('/(^user=[^,]*,)|(^user=[^,]*$)|(,user=[^,]*$)/i', '', $mpo);
|
||||
$mpo=preg_replace('/,user=[^,]*,/i', ',', $mpo);
|
||||
|
||||
$mpo=preg_replace('/(^username=[^,]*,)|(^username=[^,]*$)|(,username=[^,]*$)/i', '', $mpo);
|
||||
$mpo=preg_replace('/,username=[^,]*,/i', ',', $mpo);
|
||||
|
||||
$mpo=preg_replace('/(^password=[^,]*,)|(^password=[^,]*$)|(,password=[^,]*$)/i', '', $mpo);
|
||||
$mpo=preg_replace('/,password=[^,]*,/i', ',', $mpo);
|
||||
|
||||
$dev->setOptions($mpo);
|
||||
}
|
||||
}
|
||||
$notwas = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($notwas) {
|
||||
$dev->setFsType('unknown');
|
||||
}
|
||||
|
||||
if ($get_inodes && PSI_SHOW_INODES && isset($df_inodes[trim($df_buf[0])])) {
|
||||
$dev->setPercentInodesUsed($df_inodes[trim($df_buf[0])]);
|
||||
}
|
||||
$arrResult[] = $dev;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isset($mount_parm)) {
|
||||
foreach ($mount_parm as $mount_param) {
|
||||
if (is_dir($mount_param['mountpoint'])) {
|
||||
$total = disk_total_space($mount_param['mountpoint']);
|
||||
if (($mount_param['fstype'] != 'none') && ($total > 0)) {
|
||||
$dev = new DiskDevice();
|
||||
$dev->setName($mount_param['name']);
|
||||
$dev->setFsType($mount_param['fstype']);
|
||||
|
||||
if (PSI_SHOW_MOUNT_POINT) $dev->setMountPoint($mount_param['mountpoint']);
|
||||
|
||||
$dev->setTotal($total);
|
||||
$free = disk_free_space($mount_param['mountpoint']);
|
||||
if ($free > 0) {
|
||||
$dev->setFree($free);
|
||||
} else {
|
||||
$free = 0;
|
||||
}
|
||||
if ($total > $free) $dev->setUsed($total - $free);
|
||||
|
||||
if (PSI_SHOW_MOUNT_OPTION) {
|
||||
if (PSI_SHOW_MOUNT_CREDENTIALS) {
|
||||
$dev->setOptions($mount_parm[$df_buf[5]]['options']);
|
||||
$dev->setOptions($mount_param['options']);
|
||||
} else {
|
||||
$mpo=$mount_parm[$df_buf[5]]['options'];
|
||||
$mpo=$mount_param['options'];
|
||||
|
||||
$mpo=preg_replace('/(^guest,)|(^guest$)|(,guest$)/i', '', $mpo);
|
||||
$mpo=preg_replace('/,guest,/i', ',', $mpo);
|
||||
@@ -156,56 +286,8 @@ class Parser
|
||||
$dev->setOptions($mpo);
|
||||
}
|
||||
}
|
||||
$arrResult[] = $dev;
|
||||
}
|
||||
if (PSI_SHOW_INODES && isset($df_inodes[trim($df_buf[0])])) {
|
||||
$dev->setPercentInodesUsed($df_inodes[trim($df_buf[0])]);
|
||||
}
|
||||
$arrResult[] = $dev;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isset($mount_parm)) {
|
||||
foreach ($mount_parm as $mount_point=>$mount_param) {
|
||||
$total = disk_total_space($mount_point);
|
||||
if (($mount_param['fstype'] != 'none') && ($total > 0)) {
|
||||
$dev = new DiskDevice();
|
||||
$dev->setName($mount_param['name']);
|
||||
$dev->setFsType($mount_param['fstype']);
|
||||
|
||||
if (PSI_SHOW_MOUNT_POINT) $dev->setMountPoint($mount_point);
|
||||
|
||||
$dev->setTotal($total);
|
||||
$free = disk_free_space($mount_point);
|
||||
if ($free > 0) {
|
||||
$dev->setFree($free);
|
||||
} else {
|
||||
$free = 0;
|
||||
}
|
||||
if ($total > $free) $dev->setUsed($total - $free);
|
||||
|
||||
if (PSI_SHOW_MOUNT_OPTION) {
|
||||
if (PSI_SHOW_MOUNT_CREDENTIALS) {
|
||||
$dev->setOptions($mount_param['options']);
|
||||
} else {
|
||||
$mpo=$mount_param['options'];
|
||||
|
||||
$mpo=preg_replace('/(^guest,)|(^guest$)|(,guest$)/i', '', $mpo);
|
||||
$mpo=preg_replace('/,guest,/i', ',', $mpo);
|
||||
|
||||
$mpo=preg_replace('/(^user=[^,]*,)|(^user=[^,]*$)|(,user=[^,]*$)/i', '', $mpo);
|
||||
$mpo=preg_replace('/,user=[^,]*,/i', ',', $mpo);
|
||||
|
||||
$mpo=preg_replace('/(^username=[^,]*,)|(^username=[^,]*$)|(,username=[^,]*$)/i', '', $mpo);
|
||||
$mpo=preg_replace('/,username=[^,]*,/i', ',', $mpo);
|
||||
|
||||
$mpo=preg_replace('/(^password=[^,]*,)|(^password=[^,]*$)|(,password=[^,]*$)/i', '', $mpo);
|
||||
$mpo=preg_replace('/,password=[^,]*,/i', ',', $mpo);
|
||||
|
||||
$dev->setOptions($mpo);
|
||||
}
|
||||
}
|
||||
$arrResult[] = $dev;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user