* 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:
@@ -1,46 +1,32 @@
|
||||
<?php
|
||||
echo "<!DOCTYPE html>";
|
||||
echo "<head>";
|
||||
echo "<meta charset=\"UTF-8\">";
|
||||
echo "<title> </title>";
|
||||
echo "</head>";
|
||||
echo "<body>";
|
||||
if (PHP_OS != 'Linux') {
|
||||
echo "Test works only on Linux";
|
||||
echo "</body>";
|
||||
die();
|
||||
}
|
||||
|
||||
define('APP_ROOT', dirname(__FILE__).'/..');
|
||||
require_once APP_ROOT.'/includes/interface/class.PSI_Interface_OS.inc.php';
|
||||
require_once APP_ROOT.'/includes/os/class.OS.inc.php';
|
||||
require_once APP_ROOT.'/includes/to/class.System.inc.php';
|
||||
require_once APP_ROOT.'/includes/os/class.Linux.inc.php';
|
||||
define('PSI_USE_VHOST', false);
|
||||
define('PSI_APP_ROOT', dirname(__FILE__).'/..');
|
||||
define('PSI_DEBUG', false);
|
||||
define('PSI_LOAD_BAR', false);
|
||||
require_once PSI_APP_ROOT.'/includes/interface/class.PSI_Interface_OS.inc.php';
|
||||
require_once PSI_APP_ROOT.'/includes/os/class.OS.inc.php';
|
||||
require_once PSI_APP_ROOT.'/includes/to/class.System.inc.php';
|
||||
require_once PSI_APP_ROOT.'/includes/os/class.Linux.inc.php';
|
||||
|
||||
$log_file = "";
|
||||
$lsb = true; //enable detection lsb_release -a
|
||||
$lsbfile = true; //enable detection /etc/lsb-release
|
||||
$files = true; //enable detection files
|
||||
$osfile = true; //enable detection /etc/os-release
|
||||
$other = true; //enable other detection
|
||||
|
||||
class Error
|
||||
class PSI_Error
|
||||
{
|
||||
public static function singleton()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class Parser
|
||||
{
|
||||
public static function lspci()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
public static function df()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
class CommonFunctions
|
||||
{
|
||||
private static function _parse_log_file($string)
|
||||
@@ -48,6 +34,7 @@ class CommonFunctions
|
||||
global $log_file;
|
||||
if (file_exists($log_file)) {
|
||||
$contents = @file_get_contents($log_file);
|
||||
$contents = preg_replace("/\r\n/", "\n", $contents);
|
||||
if ($contents && preg_match("/^\-\-\-\-\-\-\-\-\-\-".preg_quote($string, '/')."\-\-\-\-\-\-\-\-\-\-\n/m", $contents, $matches, PREG_OFFSET_CAPTURE)) {
|
||||
$findIndex = $matches[0][1];
|
||||
if (preg_match("/\n/m", $contents, $matches, PREG_OFFSET_CAPTURE, $findIndex)) {
|
||||
@@ -68,9 +55,20 @@ class CommonFunctions
|
||||
|
||||
public static function rfts($strFileName, &$strRet, $intLines = 0, $intBytes = 4096, $booErrorRep = true)
|
||||
{
|
||||
global $lsb;
|
||||
global $lsbfile;
|
||||
if ($lsb || $lsbfile || ($strFileName != "/etc/lsb-release")) {
|
||||
global $files;
|
||||
global $osfile;
|
||||
global $other;
|
||||
if ($strFileName=="/etc/lsb-release") {
|
||||
$test = $lsbfile;
|
||||
} elseif ($strFileName=="/etc/os-release") {
|
||||
$test = $osfile;
|
||||
} elseif (($strFileName=="/etc/DISTRO_SPECS") || ($strFileName=="/etc/distro-release")|| ($strFileName=="/etc/system-release") || ($strFileName=="/etc/debian_version") || ($strFileName=="/etc/slackware-version") || ($strFileName=="/etc/config/uLinux.conf")) {
|
||||
$test = $other;
|
||||
} else {
|
||||
$test = $files;
|
||||
}
|
||||
if ($test) {
|
||||
$strRet=self::_parse_log_file($strFileName);
|
||||
if ($strRet && ($intLines == 1) && (strpos($strRet, "\n") !== false)) {
|
||||
$strRet=trim(substr($strRet, 0, strpos($strRet, "\n")));
|
||||
@@ -82,127 +80,116 @@ class CommonFunctions
|
||||
}
|
||||
}
|
||||
|
||||
public static function executeProgram($strProgramname, $strArgs, &$strBuffer, $booErrorRep = true)
|
||||
public static function executeProgram($strProgramname, $strArgs, &$strBuffer, $booErrorRep = true, $timeout = 30)
|
||||
{
|
||||
global $lsb;
|
||||
global $files;
|
||||
$strBuffer = '';
|
||||
if ($strProgramname=='lsb_release') {
|
||||
return $lsb && ($strBuffer = self::_parse_log_file('lsb_release -a'));
|
||||
} else {
|
||||
return $strBuffer = self::_parse_log_file($strProgramname);
|
||||
return $files && ($strBuffer = self::_parse_log_file($strProgramname));
|
||||
}
|
||||
}
|
||||
|
||||
public static function fileexists($strFileName)
|
||||
{
|
||||
global $log_file;
|
||||
global $lsb;
|
||||
global $lsbfile;
|
||||
if (file_exists($log_file)
|
||||
&& ($lsb || $lsbfile || ($strFileName != "/etc/lsb-release"))
|
||||
&& ($contents = @file_get_contents($log_file))
|
||||
&& preg_match("/^\-\-\-\-\-\-\-\-\-\-".preg_quote($strFileName, '/')."\-\-\-\-\-\-\-\-\-\-\n/m", $contents)) {
|
||||
return true;
|
||||
global $files;
|
||||
global $osfile;
|
||||
global $other;
|
||||
global $log_file;
|
||||
if ($strFileName=="/etc/lsb-release") {
|
||||
$test = $lsbfile;
|
||||
} elseif ($strFileName=="/etc/os-release") {
|
||||
$test = $osfile;
|
||||
} elseif (($strFileName=="/etc/DISTRO_SPECS") || ($strFileName=="/etc/distro-release") || ($strFileName=="/etc/system-release") || ($strFileName=="/etc/debian_version") || ($strFileName=="/etc/slackware-version") || ($strFileName=="/etc/config/uLinux.conf")) {
|
||||
$test = $other;
|
||||
} else {
|
||||
$test = $files;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function gdc()
|
||||
{
|
||||
return array();
|
||||
return $test && file_exists($log_file) && ($contents = @file_get_contents($log_file)) && preg_match("/^\-\-\-\-\-\-\-\-\-\-".preg_quote($strFileName, '/')."\-\-\-\-\-\-\-\-\-\-\r?\n/m", $contents);
|
||||
}
|
||||
}
|
||||
|
||||
$system = new Linux();
|
||||
if ($handle = opendir(APP_ROOT.'/sample/distrotest')) {
|
||||
echo "<table cellpadding=\"2\" border=\"1\" CELLSPACING=\"0\"";
|
||||
echo "<tr>";
|
||||
echo "<td>Distrotest sample</td>";
|
||||
echo "<td>Distro Name</td>";
|
||||
echo "<td>Distro Icon</td>";
|
||||
echo "<td>Distro Name (no lsb_release)</td>";
|
||||
echo "<td>Distro Icon (no lsb_release)</td>";
|
||||
echo "<td>Distro Name (no lsb_release and no /etc/lsb-release)</td>";
|
||||
echo "<td>Distro Icon (no lsb_release and no /etc/lsb-release)</td>";
|
||||
echo "</tr>";
|
||||
while (false !== ($entry = readdir($handle))) {
|
||||
if (($entry!=".")&&($entry!="..")) {
|
||||
if ($shandle = opendir(APP_ROOT."/sample/distrotest/$entry")) {
|
||||
while (false !== ($sentry = readdir($shandle))) {
|
||||
if (($sentry!=".")&&($sentry!="..")) {
|
||||
$log_file=APP_ROOT.'/sample/distrotest/'.$entry.'/'.$sentry;
|
||||
class _Linux extends Linux
|
||||
{
|
||||
public function build()
|
||||
{
|
||||
parent::_distro();
|
||||
}
|
||||
}
|
||||
|
||||
function echodist($entry, $system, $_lsb, $_lsbfile, $_files, $_osfile, $_other)
|
||||
{
|
||||
global $lsb;
|
||||
global $lsbfile;
|
||||
global $files;
|
||||
global $osfile;
|
||||
global $other;
|
||||
|
||||
$lsb = $_lsb;
|
||||
$lsbfile = $_lsbfile;
|
||||
$files = $_files;
|
||||
$osfile = $_osfile;
|
||||
$other = $_other;
|
||||
|
||||
$sys = $system->getSys();
|
||||
$distro=$sys->getDistribution();
|
||||
$icon=$sys->getDistributionIcon();
|
||||
if ($icon == '') $icon="unknown.png";
|
||||
echo "<td>";
|
||||
|
||||
if ($icon != $entry.'.png')
|
||||
echo "<span style='color:red'>";
|
||||
else
|
||||
echo "<span>";
|
||||
if ($distro !== 'Linux') {
|
||||
echo "<img src=\"../gfx/images/".$icon."\" title=\"".$icon."\" height=\"16\" width=\"16\"/>";
|
||||
echo $distro;
|
||||
}
|
||||
echo "</span></td>";
|
||||
$sys->setDistributionIcon("");
|
||||
}
|
||||
|
||||
$system = new _Linux('none');
|
||||
$dirs = scandir(PSI_APP_ROOT.'/sample/distrotest');
|
||||
if (($dirs !== false) && (count($dirs) > 0)) {
|
||||
$dirs = array_diff($dirs, array('.', '..'));
|
||||
if (($dirs !== false) && (count($dirs) > 0)) {
|
||||
natcasesort($dirs);
|
||||
echo "<table cellpadding=\"2\" border=\"1\" CELLSPACING=\"0\">";
|
||||
echo "<tr>";
|
||||
echo "<td>Distrotest sample</td>";
|
||||
echo "<td>Distro Name</td>";
|
||||
echo "<td>Distro Name (lsb_release only)</td>";
|
||||
echo "<td>Distro Name (/etc/lsb-release only)</td>";
|
||||
echo "<td>Distro Name (files only)</td>";
|
||||
echo "<td>Distro Name (os-release only)</td>";
|
||||
echo "<td>Distro Name (other only)</td>";
|
||||
echo "</tr>";
|
||||
foreach ($dirs as $entry) {
|
||||
$files = scandir(PSI_APP_ROOT."/sample/distrotest/$entry");
|
||||
if (($files !== false) && (count($files) > 0)) {
|
||||
$files = array_diff($files, array('.', '..'));
|
||||
if (($files !== false) && (count($files) > 0)) {
|
||||
natcasesort($files);
|
||||
foreach ($files as $sentry) {
|
||||
$log_file=PSI_APP_ROOT.'/sample/distrotest/'.$entry.'/'.$sentry;
|
||||
echo "<tr>";
|
||||
echo "<td>".$entry.'/'.$sentry."</td>";
|
||||
|
||||
$lsb = true;
|
||||
$lsbfile = true;
|
||||
$sys=$system->getSys();
|
||||
$distro=$sys->getDistribution();
|
||||
$icon=$sys->getDistributionIcon();
|
||||
if ($icon == '') $icon="unknown.png";
|
||||
if ($icon != $entry.'.png')
|
||||
echo "<td style='color:red'>";
|
||||
else
|
||||
echo "<td>";
|
||||
echo $distro."</td>";
|
||||
if ($icon != $entry.'.png')
|
||||
echo "<td style='color:red'>";
|
||||
else
|
||||
echo "<td>";
|
||||
echo "<img src=\"../gfx/images/".$icon."\" height=\"16\" width=\"16\">";
|
||||
echo $icon."</td>";
|
||||
$sys->setDistribution("");
|
||||
$sys->setDistributionIcon("");
|
||||
|
||||
$lsb = false;
|
||||
$lsbfile = true;
|
||||
$sys=$system->getSys();
|
||||
$distro=$sys->getDistribution();
|
||||
$icon=$sys->getDistributionIcon();
|
||||
if ($icon == '') $icon="unknown.png";
|
||||
if ($icon != $entry.'.png')
|
||||
echo "<td style='color:red'>";
|
||||
else
|
||||
echo "<td>";
|
||||
echo $distro."</td>";
|
||||
if ($icon != $entry.'.png')
|
||||
echo "<td style='color:red'>";
|
||||
else
|
||||
echo "<td>";
|
||||
echo "<img src=\"../gfx/images/".$icon."\" height=\"16\" width=\"16\">";
|
||||
echo $icon."</td>";
|
||||
$sys->setDistribution("");
|
||||
$sys->setDistributionIcon("");
|
||||
|
||||
$lsb = false;
|
||||
$lsbfile = false;
|
||||
$sys=$system->getSys();
|
||||
$distro=$sys->getDistribution();
|
||||
$icon=$sys->getDistributionIcon();
|
||||
if ($icon == '') $icon="unknown.png";
|
||||
if ($icon != $entry.'.png')
|
||||
echo "<td style='color:red'>";
|
||||
else
|
||||
echo "<td>";
|
||||
echo $distro."</td>";
|
||||
if ($icon != $entry.'.png')
|
||||
echo "<td style='color:red'>";
|
||||
else
|
||||
echo "<td>";
|
||||
echo "<img src=\"../gfx/images/".$icon."\" height=\"16\" width=\"16\">";
|
||||
echo $icon."</td>";
|
||||
$sys->setDistribution("");
|
||||
$sys->setDistributionIcon("");
|
||||
|
||||
echodist($entry, $system, true, true, true, true, true);
|
||||
echodist($entry, $system, true, false, false, false, false);
|
||||
echodist($entry, $system, false, true, false, false, false);
|
||||
echodist($entry, $system, false, false, true, false, false);
|
||||
echodist($entry, $system, false, false, false, true, false);
|
||||
echodist($entry, $system, false, false, false, false, true);
|
||||
echo "</tr>";
|
||||
}
|
||||
}
|
||||
closedir($shandle);
|
||||
}
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
echo "</table>";
|
||||
closedir($handle);
|
||||
}
|
||||
echo "</body>";
|
||||
|
Reference in New Issue
Block a user