extra callsign checking

The dashboard filter out log entries with callsigns with less than 3
characters
This commit is contained in:
LX3JL 2016-01-27 15:56:41 +01:00
parent f555f0effc
commit d6eecca9d9
2 changed files with 46 additions and 88 deletions

48
dashboard/index.php Executable file → Normal file
View File

@ -1,26 +1,4 @@
<?php
// ----------------------------------------------------------------------------
// xlxd
//
// Created by Luc Engelmann (LX1IQ) on 31/12/2015
// Copyright © 2015 Luc Engelmann (LX1IQ). All rights reserved.
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
//
// xlxd 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 3 of the License, or
// (at your option) any later version.
//
// xlxd 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
$FILE = "/var/log/xlxd.xml";
@ -55,10 +33,10 @@ if (intval($ServiceName) !== 0) {
$AllNodesString = $XML->GetElement($FILECONTENT, $LinkedNodesName);
$tmpNodes = $XML->GetAllElements($AllNodesString, "NODE");
for ($i=0;$i<count($tmpNodes);$i++) {
for ($i=0;$i<count($tmpNodes);$i++) {
$Node = new Node($XML->GetElement($tmpNodes[$i], 'Callsign'), $XML->GetElement($tmpNodes[$i], 'IP'), $XML->GetElement($tmpNodes[$i], 'LinkedModule'), $XML->GetElement($tmpNodes[$i], 'Protocol'), $XML->GetElement($tmpNodes[$i], 'ConnectTime'), $XML->GetElement($tmpNodes[$i], 'LastHeardTime'));
$Reflector->AddNode($Node);
}
}
$AllStationsString = $XML->GetElement($FILECONTENT, $LinkedUsersName);
$tmpStations = $XML->GetAllElements($AllStationsString, "STATION");
@ -78,18 +56,18 @@ for ($i=0;$i<count($tmpStations);$i++) {
<link rel="stylesheet" type="text/css" href="./css/layout.css">
<link rel="icon" href="./favicon.ico" type="image/vnd.microsoft.icon">
<script>
function ReloadPage() {
document.location.href = "./index.php<?php if (isset($_GET['show'])) { echo '?show='.$_GET['show']; } ?>";
}
<?php
if (!isset($_GET['show']) || (($_GET['show'] != 'liveircddb') && ($_GET['show'] != 'liveccs'))) {
echo '
setTimeout(ReloadPage, 10000);';
}
?>
</script>
</head>
<body>
@ -100,13 +78,13 @@ for ($i=0;$i<count($tmpStations);$i++) {
<tr>
<td><a href="./index.php" class="menulink">Users / Modules</a></td><td><a href="./index.php?show=repeaters" class="menulink">Repeaters / Nodes</a></td><td><a href="./index.php?show=liveircddb" class="menulink">D-Star live</a></td><td><a href="./index.php?show=liveccs" class="menulink">CCS live</a></td>
</tr>
</table>
</div>
<div id="info"><?php echo str_replace ("up" , "&nbsp;&nbsp;Server uptime" , GetSystemUptime()); ?>&nbsp;<br />XLX<?php echo $ServiceName; ?>&nbsp;v<?php echo $XML->GetElement($FILECONTENT, "Version"); ?>&nbsp;-&nbsp;Dashboard v2.0.4&nbsp;&nbsp;</div>
<div id="info"><?php echo str_replace ("up" , "&nbsp;&nbsp;Server uptime" , GetSystemUptime()); ?>&nbsp;<br />XLX<?php echo $ServiceName; ?>&nbsp;v<?php echo $XML->GetElement($FILECONTENT, "Version"); ?>&nbsp;-&nbsp;Dashboard v2.0.5&nbsp;&nbsp;</div>
</div>
<div id="content" align="center">
<?php
if (!isset($_GET['show'])) $_GET['show'] = "";
switch ($_GET['show']) {
@ -117,12 +95,12 @@ for ($i=0;$i<count($tmpStations);$i++) {
default : require_once("./pgs/users.php");
}
?>
?>
<div style="width:100%;text-align:center;margin-top:50px;"><a href="mailto:dvc@rlx.lu" style="font-family:verdana;color:#000000;font-size:12pt;text-decoration:none;">dvc@rlx.lu</a></div>
</div>
</body>
</html>

86
dashboard/pgs/class.reflector.php Executable file → Normal file
View File

@ -1,39 +1,17 @@
<?php
// ----------------------------------------------------------------------------
// xlxd
//
// Created by Luc Engelmann (LX1IQ) on 31/12/2015
// Copyright © 2015 Luc Engelmann (LX1IQ). All rights reserved.
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
//
// xlxd 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 3 of the License, or
// (at your option) any later version.
//
// xlxd 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
class xReflector {
public $Nodes = null;
public $Stations = null;
private $Flagarray = null;
private $Flagfile = null;
public function __construct() {
$this->Nodes = array();
$this->Stations = array();
}
public function SetFlagFile($Flagfile) {
if (file_exists($Flagfile) && (is_readable($Flagfile))) {
$this->Flagfile = $Flagfile;
@ -41,7 +19,7 @@ class xReflector {
}
return false;
}
public function LoadFlags() {
if ($this->Flagfile != null) {
$this->Flagarray = array();
@ -51,17 +29,17 @@ class xReflector {
while(!feof($handle)) {
$row = fgets($handle,1024);
$tmp = explode(";", $row);
if (isset($tmp[0])) { $this->Flagarray[$i]['Country'] = $tmp[0]; } else { $this->Flagarray[$i]['Country'] = 'Undefined'; }
if (isset($tmp[1])) { $this->Flagarray[$i]['ISO'] = $tmp[1]; } else { $this->Flagarray[$i]['ISO'] = "Undefined"; }
$this->Flagarray[$i]['DXCC'] = array();
if (isset($tmp[2])) {
if (isset($tmp[2])) {
$tmp2 = explode("-", $tmp[2]);
for ($j=0;$j<count($tmp2);$j++) {
$this->Flagarray[$i]['DXCC'][] = $tmp2[$j];
}
}
$i++;
$i++;
}
fclose($handle);
}
@ -69,17 +47,17 @@ class xReflector {
}
return false;
}
public function AddNode($NodeObject) {
if (is_object($NodeObject)) {
$this->Nodes[] = $NodeObject;
}
}
public function NodeCount() {
return count($this->Nodes);
}
public function GetNode($ArrayIndex) {
if (isset($this->Nodes[$ArrayIndex])) {
return $this->Nodes[$ArrayIndex];
@ -89,41 +67,43 @@ class xReflector {
public function AddStation($StationObject, $AllowDouble = false) {
if (is_object($StationObject)) {
if ($AllowDouble) {
$this->Stations[] = $StationObject;
}
else {
$FoundStationInList = false;
$i = 0;
$tmp = explode(" ", $StationObject->GetCallsign());
$RealCallsign = trim($tmp[0]);
while (!$FoundStationInList && $i<$this->StationCount()) {
if ($this->Stations[$i]->GetCallsignOnly() == $RealCallsign) {
$FoundStationInList = true;
}
$i++;
}
if (!$FoundStationInList) {
$this->Stations[] = $StationObject;
if (strlen(trim($RealCallsign)) > 3) {
$this->Stations[] = $StationObject;
}
}
}
}
}
public function GetSuffixOfRepeater($Repeater) {
$suffix = "";
$found = false;
$i = 0;
while (!$found && $i < $this->NodeCount()) {
if (strpos($this->Nodes[$i]->GetCallSign(), $Repeater) !== false) {
$suffix = $this->Nodes[$i]->GetSuffix();
$found = true;
}
@ -131,18 +111,18 @@ class xReflector {
}
return $suffix;
}
public function StationCount() {
return count($this->Stations);
}
public function GetStation($ArrayIndex) {
if (isset($this->Stations[$ArrayIndex])) {
return $this->Stations[$ArrayIndex];
}
return false;
}
public function GetFlag($Callsign) {
$Image = "";
$FoundFlag = false;
@ -151,7 +131,7 @@ class xReflector {
$j = 0;
$Prefix = substr($Callsign, 0, $Letters);
while (($j < count($this->Flagarray)) && (!$FoundFlag)) {
$z = 0;
while (($z < count($this->Flagarray[$j]['DXCC'])) && (!$FoundFlag)) {
if (trim($Prefix) == trim($this->Flagarray[$j]['DXCC'][$z])) {
@ -164,9 +144,9 @@ class xReflector {
}
$Letters++;
}
if (!$FoundFlag) {
$Prefix = substr($Callsign, 0, 1);
$Prefix = substr($Callsign, 0, 1);
if ($Prefix == 'N') { $Image = "us"; }
if ($Prefix == 'K') { $Image = "us"; }
if ($Prefix == 'W') { $Image = "us"; }
@ -176,7 +156,7 @@ class xReflector {
}
return strtolower($Image);
}
public function GetModules() {
$out = array();
for ($i=0;$i<$this->NodeCount();$i++) {
@ -194,17 +174,17 @@ class xReflector {
}
return $out;
}
public function GetCallSignsInModules($Module) {
$out = array();
for ($i=0;$i<$this->NodeCount();$i++) {
if ($this->Nodes[$i]->GetLinkedModule() == $Module) {
$out[] = $this->Nodes[$i]->GetCallsign();
}
}
}
return $out;
}
}
?>
?>