* 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:
2025-05-14 16:14:01 +01:00
parent 80b1da5fa5
commit c8ce77259d
952 changed files with 51341 additions and 28699 deletions

View File

@@ -0,0 +1,143 @@
<?php
/**
* PingTime Plugin
*
* PHP version 5
*
* @category PHP
* @package PSI_Plugin_PingTest
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
* @copyright 2017 phpSysInfo
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
* @version SVN: $Id: class.pingtest.inc.php 1 2017-09-01 09:01:15Z namiltd $
* @link http://phpsysinfo.sourceforge.net
*/
class PingTest extends PSI_Plugin
{
/**
* variable, which holds the content of the command
* @var array
*/
private $_filecontent = array();
/**
* variable, which holds the result before the xml is generated out of this array
* @var array
*/
private $_result = array();
/**
* read the data into an internal array and also call the parent constructor
*
* @param String $enc target encoding
*/
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
if (defined('PSI_PLUGIN_PINGTEST_ADDRESSES') && is_string(PSI_PLUGIN_PINGTEST_ADDRESSES)) {
if (preg_match(ARRAY_EXP, PSI_PLUGIN_PINGTEST_ADDRESSES)) {
$addresses = eval(PSI_PLUGIN_PINGTEST_ADDRESSES);
} else {
$addresses = array(PSI_PLUGIN_PINGTEST_ADDRESSES);
}
switch (strtolower(PSI_PLUGIN_PINGTEST_ACCESS)) {
case 'command':
if (PHP_OS == 'WINNT') {
$params = "-n 1";
if (defined('PSI_PLUGIN_PINGTEST_TIMEOUT')) {
if (($tout = max(intval(PSI_PLUGIN_PINGTEST_TIMEOUT), 0)) > 0) {
$params .= " -w ".(1000*$tout);
}
} else {
$params .= " -w 2000";
}
} else {
$params = "-c 1";
if (defined('PSI_PLUGIN_PINGTEST_TIMEOUT')) {
if (($tout = max(intval(PSI_PLUGIN_PINGTEST_TIMEOUT), 0)) > 0) {
$params .= " -W ".$tout;
}
} else {
$params .= " -W 2";
}
}
foreach ($addresses as $address) {
CommonFunctions::executeProgram("ping".((strpos($address, ':') === false)?'':((PHP_OS != 'WINNT')?'6':'')), $params." ".$address, $buffer, PSI_DEBUG);
if ((strlen($buffer) > 0) && preg_match("/[=<]([\d\.]+)\s*ms/", $buffer, $tmpout)) {
$this->_filecontent[] = array($address, $tmpout[1]);
}
}
break;
case 'data':
CommonFunctions::rftsdata("pingtest.tmp", $buffer);
$addresses = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
foreach ($addresses as $address) {
$pt = preg_split("/[\s]?\|[\s]?/", $address, -1, PREG_SPLIT_NO_EMPTY);
if (count($pt) == 2) {
$this->_filecontent[] = array(trim($pt[0]), trim($pt[1]));
}
}
break;
default:
$this->global_error->addConfigError("__construct()", "[pingtest] ACCESS");
}
}
}
/**
* doing all tasks to get the required informations that the plugin needs
* result is stored in an internal array
*
* @return void
*/
public function execute()
{
if (defined('PSI_PLUGIN_PINGTEST_ADDRESSES') && is_string(PSI_PLUGIN_PINGTEST_ADDRESSES)) {
if (preg_match(ARRAY_EXP, PSI_PLUGIN_PINGTEST_ADDRESSES)) {
$addresses = eval(PSI_PLUGIN_PINGTEST_ADDRESSES);
} else {
$addresses = array(PSI_PLUGIN_PINGTEST_ADDRESSES);
}
foreach ($addresses as $address) {
$this->_result[] = array($address, $this->address_inarray($address, $this->_filecontent));
}
}
}
/**
* generates the XML content for the plugin
*
* @return SimpleXMLElement entire XML content for the plugin
*/
public function xml()
{
foreach ($this->_result as $pt) {
$xmlps = $this->xml->addChild("Ping");
$xmlps->addAttribute("Address", $pt[0]);
$xmlps->addAttribute("PingTime", $pt[1]);
}
return $this->xml->getSimpleXmlElement();
}
/**
* checks an array if pingtest address is in
*
* @param mixed $needle what to find
* @param array $haystack where to find
*
* @return pingtime - found<br>"lost" - not found
*/
private function address_inarray($needle, $haystack)
{
foreach ($haystack as $stalk) {
if ($needle === $stalk[0]) {
return $stalk[1];
}
}
return "lost";
}
}

View File

@@ -0,0 +1,6 @@
/*
$Id: pingtest.css 1 2017-09-02 10:17:22Z namiltd $
*/
#Plugin_PingTestTable thead tr th {
cursor: pointer;
}

View File

@@ -0,0 +1,131 @@
/***************************************************************************
* 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: pingtest.js 1 2017-09-01 08:23:45Z namiltd $
//
/*global $, jQuery, buildBlock, datetime, plugin_translate, genlang */
"use strict";
var pingtest_show = false, pingtest_table;
/**
* insert content into table
* @param {jQuery} xml plugin-XML
*/
function pingtest_populate(xml) {
var address = "", pingtime = 0, state = "", hostname = "";
pingtest_table.fnClearTable();
hostname = $("Plugins Plugin_PingTest", xml).attr('Hostname');
if (hostname !== undefined) {
$('span[class=Hostname_PingTest]').html(hostname);
}
$("Plugins Plugin_PingTest Ping", xml).each(function pingtest_getprocess(idp) {
address = $(this).attr("Address");
pingtime = parseInt($(this).attr("PingTime"), 10);
if (!isNaN(pingtime)) {
state = "<span style=\"display:none;\">" + pingtime.toString() + "</span>" + pingtime.toString() + "&nbsp;ms";
}
else {
state = "<span style=\"display:none;\">1000000</span>" + genlang(4, "PingTest");
}
pingtest_table.fnAddData(["<span style=\"display:none;\">" + address + "</span>" + address, state]);
pingtest_show = true;
});
}
/**
* fill the plugin block with table structure
*/
function pingtest_buildTable() {
var html = "";
html += "<div style=\"overflow-x:auto;\">\n";
html += " <table id=\"Plugin_PingTestTable\" style=\"border-collapse:collapse;\">\n";
html += " <thead>\n";
html += " <tr>\n";
html += " <th>" + genlang(2, "PingTest") + "</th>\n";
html += " <th>" + genlang(3, "PingTest") + "</th>\n";
html += " </tr>\n";
html += " </thead>\n";
html += " <tbody>\n";
html += " </tbody>\n";
html += " </table>\n";
html += "</div>\n";
$("#Plugin_PingTest").append(html);
pingtest_table = $("#Plugin_PingTestTable").dataTable({
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": true,
"bInfo": false,
"bProcessing": true,
"bAutoWidth": false,
"bStateSave": true,
"aoColumns": [{
"sType": 'span-ip'
}, {
"sType": 'span-number'
}]
});
}
/**
* load the xml via ajax
*/
function pingtest_request() {
$("#Reload_PingTestTable").attr("title", "reload");
$.ajax({
url: "xml.php?plugin=PingTest",
dataType: "xml",
error: function pingtest_error() {
$.jGrowl("Error loading XML document for Plugin PingTest!");
},
success: function pingtest_buildblock(xml) {
populateErrors(xml);
pingtest_populate(xml);
if (pingtest_show) {
plugin_translate("PingTest");
$("#Plugin_PingTest").show();
}
}
});
}
$(document).ready(function pingtest_buildpage() {
$("#footer").before(buildBlock("PingTest", 1, true));
$("#Plugin_PingTest").addClass("halfsize");
pingtest_buildTable();
pingtest_request();
$("#Reload_PingTestTable").click(function pingtest_reload(id) {
pingtest_request();
$(this).attr("title", datetime());
});
});

View File

@@ -0,0 +1,27 @@
function renderPlugin_pingtest(data) {
var directives = {
PingTime: {
html: function () {
return ((this.PingTime === "lost") ? genlang(4, 'pingtest') : this.PingTime + String.fromCharCode(160) + "ms");
}
}
};
if (data.Plugins.Plugin_PingTest !== undefined) {
var psitems = items(data.Plugins.Plugin_PingTest.Ping);
if (psitems.length > 0) {
var pt_memory = [];
pt_memory.push_attrs(psitems);
$('#pingtest-data').render(pt_memory, directives);
$('#pingtest_Address').removeClass("sorttable_sorted"); // reset sort order
sorttable.innerSortFunction.apply($('#pingtest_Address')[0], []);
$('#block_pingtest').show();
} else {
$('#block_pingtest').hide();
}
} else {
$('#block_pingtest').hide();
}
}

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
phpSysInfo language file Language: Czech Created by: Ashus
-->
<tns:translationPlugin language="czech" charset="utf-8"
xmlns:tns="http://phpsysinfo.sourceforge.net/translation-plugin" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://phpsysinfo.sourceforge.net/translation-plugin ../../../language/translation-plugin.xsd">
<expression id="plugin_pingtest_001" name="pingtest_title">
<exp>Ping</exp>
</expression>
<expression id="plugin_pingtest_002" name="pingtest_address">
<exp>Adresa</exp>
</expression>
<expression id="plugin_pingtest_003" name="pingtest_pingtime">
<exp>Odezva</exp>
</expression>
<expression id="plugin_pingtest_004" name="pingtest_lost">
<exp>ztráta</exp>
</expression>
</tns:translationPlugin>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: de.xml 661 2017-09-01 09:01:17Z namiltd $ -->
<!--
phpSysInfo language file Language: German Created by: Mieczyslaw Nalewaj
-->
<tns:translationPlugin language="german" charset="utf-8"
xmlns:tns="http://phpsysinfo.sourceforge.net/translation-plugin" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://phpsysinfo.sourceforge.net/translation-plugin ../../../language/translation-plugin.xsd">
<expression id="plugin_pingtest_001" name="pingtest_title">
<exp>Ping-Test</exp>
</expression>
<expression id="plugin_pingtest_002" name="pingtest_address">
<exp>Adresse</exp>
</expression>
<expression id="plugin_pingtest_003" name="pingtest_pingtime">
<exp>Pingzeit</exp>
</expression>
<expression id="plugin_pingtest_004" name="pingtest_lost">
<exp>verloren</exp>
</expression>
</tns:translationPlugin>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: en.xml 661 2017-09-01 09:01:17Z namiltd $ -->
<!--
phpSysInfo language file Language: English Created by: Mieczyslaw Nalewaj
-->
<tns:translationPlugin language="english" charset="utf-8"
xmlns:tns="http://phpsysinfo.sourceforge.net/translation-plugin" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://phpsysinfo.sourceforge.net/translation-plugin ../../../language/translation-plugin.xsd">
<expression id="plugin_pingtest_001" name="pingtest_title">
<exp>Ping Test</exp>
</expression>
<expression id="plugin_pingtest_002" name="pingtest_address">
<exp>Address</exp>
</expression>
<expression id="plugin_pingtest_003" name="pingtest_pingtime">
<exp>Ping Time</exp>
</expression>
<expression id="plugin_pingtest_004" name="pingtest_lost">
<exp>lost</exp>
</expression>
</tns:translationPlugin>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: gr.xml 661 2017-09-01 09:01:17Z namiltd $ -->
<!--
phpSysInfo language file Language: Greek Created by: ChriZathens
-->
<tns:translationPlugin language="greek" charset="utf-8"
xmlns:tns="http://phpsysinfo.sourceforge.net/translation-plugin" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://phpsysinfo.sourceforge.net/translation-plugin ../../../language/translation-plugin.xsd">
<expression id="plugin_pingtest_001" name="pingtest_title">
<exp>Δοκιμή Ping</exp>
</expression>
<expression id="plugin_pingtest_002" name="pingtest_address">
<exp>Διεύθυνση</exp>
</expression>
<expression id="plugin_pingtest_003" name="pingtest_pingtime">
<exp>Χρόνος Απόκρισης</exp>
</expression>
<expression id="plugin_pingtest_004" name="pingtest_lost">
<exp>χάθηκε</exp>
</expression>
</tns:translationPlugin>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: pl.xml 661 2017-09-01 09:01:17Z namiltd $ -->
<!--
phpSysInfo language file Language: Polish Created by: Mieczyslaw Nalewaj
-->
<tns:translationPlugin language="polish" charset="utf-8"
xmlns:tns="http://phpsysinfo.sourceforge.net/translation-plugin" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://phpsysinfo.sourceforge.net/translation-plugin ../../../language/translation-plugin.xsd">
<expression id="plugin_pingtest_001" name="pingtest_title">
<exp>Test Pingu</exp>
</expression>
<expression id="plugin_pingtest_002" name="pingtest_address">
<exp>Adres</exp>
</expression>
<expression id="plugin_pingtest_003" name="pingtest_pingtime">
<exp>Czas Pingu</exp>
</expression>
<expression id="plugin_pingtest_004" name="pingtest_lost">
<exp>zagubiony</exp>
</expression>
</tns:translationPlugin>

View File

@@ -0,0 +1,26 @@
<div class="col-lg-6" id="block_pingtest" style="display:none;">
<div class="card" id="panel_pingtest" style="display:none;">
<div class="card-header"><span class="lang_plugin_pingtest_001">Ping Test</span>
<span class="hostname_pingtest"></span>
<div id="reload_pingtest" class="reload" title="reload"></div>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="pingtest" class="table table-hover table-sm sortable">
<thead>
<tr>
<th class="sorttable_ip" id="pingtest_Address"><span class="lang_plugin_pingtest_002">Address</span></th>
<th class="rightCell"><span class="lang_plugin_pingtest_003">Ping Time</span></th>
</tr>
</thead>
<tbody id="pingtest-data">
<tr>
<th><span data-bind="Address"></span></th>
<td class="rightCell"><span data-bind="PingTime"></span></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>