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 <?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"; $FILE = "/var/log/xlxd.xml";
@ -55,10 +33,10 @@ if (intval($ServiceName) !== 0) {
$AllNodesString = $XML->GetElement($FILECONTENT, $LinkedNodesName); $AllNodesString = $XML->GetElement($FILECONTENT, $LinkedNodesName);
$tmpNodes = $XML->GetAllElements($AllNodesString, "NODE"); $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')); $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); $Reflector->AddNode($Node);
} }
$AllStationsString = $XML->GetElement($FILECONTENT, $LinkedUsersName); $AllStationsString = $XML->GetElement($FILECONTENT, $LinkedUsersName);
$tmpStations = $XML->GetAllElements($AllStationsString, "STATION"); $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="stylesheet" type="text/css" href="./css/layout.css">
<link rel="icon" href="./favicon.ico" type="image/vnd.microsoft.icon"> <link rel="icon" href="./favicon.ico" type="image/vnd.microsoft.icon">
<script> <script>
function ReloadPage() { function ReloadPage() {
document.location.href = "./index.php<?php if (isset($_GET['show'])) { echo '?show='.$_GET['show']; } ?>"; document.location.href = "./index.php<?php if (isset($_GET['show'])) { echo '?show='.$_GET['show']; } ?>";
} }
<?php <?php
if (!isset($_GET['show']) || (($_GET['show'] != 'liveircddb') && ($_GET['show'] != 'liveccs'))) { if (!isset($_GET['show']) || (($_GET['show'] != 'liveircddb') && ($_GET['show'] != 'liveccs'))) {
echo ' echo '
setTimeout(ReloadPage, 10000);'; setTimeout(ReloadPage, 10000);';
} }
?> ?>
</script> </script>
</head> </head>
<body> <body>
@ -100,13 +78,13 @@ for ($i=0;$i<count($tmpStations);$i++) {
<tr> <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> <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> </tr>
</table> </table>
</div> </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>
<div id="content" align="center"> <div id="content" align="center">
<?php <?php
if (!isset($_GET['show'])) $_GET['show'] = ""; if (!isset($_GET['show'])) $_GET['show'] = "";
switch ($_GET['show']) { switch ($_GET['show']) {
@ -117,12 +95,12 @@ for ($i=0;$i<count($tmpStations);$i++) {
default : require_once("./pgs/users.php"); 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 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> </div>
</body> </body>
</html> </html>

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

@ -1,39 +1,17 @@
<?php <?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 { class xReflector {
public $Nodes = null; public $Nodes = null;
public $Stations = null; public $Stations = null;
private $Flagarray = null; private $Flagarray = null;
private $Flagfile = null; private $Flagfile = null;
public function __construct() { public function __construct() {
$this->Nodes = array(); $this->Nodes = array();
$this->Stations = array(); $this->Stations = array();
} }
public function SetFlagFile($Flagfile) { public function SetFlagFile($Flagfile) {
if (file_exists($Flagfile) && (is_readable($Flagfile))) { if (file_exists($Flagfile) && (is_readable($Flagfile))) {
$this->Flagfile = $Flagfile; $this->Flagfile = $Flagfile;
@ -41,7 +19,7 @@ class xReflector {
} }
return false; return false;
} }
public function LoadFlags() { public function LoadFlags() {
if ($this->Flagfile != null) { if ($this->Flagfile != null) {
$this->Flagarray = array(); $this->Flagarray = array();
@ -51,17 +29,17 @@ class xReflector {
while(!feof($handle)) { while(!feof($handle)) {
$row = fgets($handle,1024); $row = fgets($handle,1024);
$tmp = explode(";", $row); $tmp = explode(";", $row);
if (isset($tmp[0])) { $this->Flagarray[$i]['Country'] = $tmp[0]; } else { $this->Flagarray[$i]['Country'] = 'Undefined'; } 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"; } if (isset($tmp[1])) { $this->Flagarray[$i]['ISO'] = $tmp[1]; } else { $this->Flagarray[$i]['ISO'] = "Undefined"; }
$this->Flagarray[$i]['DXCC'] = array(); $this->Flagarray[$i]['DXCC'] = array();
if (isset($tmp[2])) { if (isset($tmp[2])) {
$tmp2 = explode("-", $tmp[2]); $tmp2 = explode("-", $tmp[2]);
for ($j=0;$j<count($tmp2);$j++) { for ($j=0;$j<count($tmp2);$j++) {
$this->Flagarray[$i]['DXCC'][] = $tmp2[$j]; $this->Flagarray[$i]['DXCC'][] = $tmp2[$j];
} }
} }
$i++; $i++;
} }
fclose($handle); fclose($handle);
} }
@ -69,17 +47,17 @@ class xReflector {
} }
return false; return false;
} }
public function AddNode($NodeObject) { public function AddNode($NodeObject) {
if (is_object($NodeObject)) { if (is_object($NodeObject)) {
$this->Nodes[] = $NodeObject; $this->Nodes[] = $NodeObject;
} }
} }
public function NodeCount() { public function NodeCount() {
return count($this->Nodes); return count($this->Nodes);
} }
public function GetNode($ArrayIndex) { public function GetNode($ArrayIndex) {
if (isset($this->Nodes[$ArrayIndex])) { if (isset($this->Nodes[$ArrayIndex])) {
return $this->Nodes[$ArrayIndex]; return $this->Nodes[$ArrayIndex];
@ -89,41 +67,43 @@ class xReflector {
public function AddStation($StationObject, $AllowDouble = false) { public function AddStation($StationObject, $AllowDouble = false) {
if (is_object($StationObject)) { if (is_object($StationObject)) {
if ($AllowDouble) { if ($AllowDouble) {
$this->Stations[] = $StationObject; $this->Stations[] = $StationObject;
} }
else { else {
$FoundStationInList = false; $FoundStationInList = false;
$i = 0; $i = 0;
$tmp = explode(" ", $StationObject->GetCallsign()); $tmp = explode(" ", $StationObject->GetCallsign());
$RealCallsign = trim($tmp[0]); $RealCallsign = trim($tmp[0]);
while (!$FoundStationInList && $i<$this->StationCount()) { while (!$FoundStationInList && $i<$this->StationCount()) {
if ($this->Stations[$i]->GetCallsignOnly() == $RealCallsign) { if ($this->Stations[$i]->GetCallsignOnly() == $RealCallsign) {
$FoundStationInList = true; $FoundStationInList = true;
} }
$i++; $i++;
} }
if (!$FoundStationInList) { if (!$FoundStationInList) {
$this->Stations[] = $StationObject; if (strlen(trim($RealCallsign)) > 3) {
$this->Stations[] = $StationObject;
}
} }
} }
} }
} }
public function GetSuffixOfRepeater($Repeater) { public function GetSuffixOfRepeater($Repeater) {
$suffix = ""; $suffix = "";
$found = false; $found = false;
$i = 0; $i = 0;
while (!$found && $i < $this->NodeCount()) { while (!$found && $i < $this->NodeCount()) {
if (strpos($this->Nodes[$i]->GetCallSign(), $Repeater) !== false) { if (strpos($this->Nodes[$i]->GetCallSign(), $Repeater) !== false) {
$suffix = $this->Nodes[$i]->GetSuffix(); $suffix = $this->Nodes[$i]->GetSuffix();
$found = true; $found = true;
} }
@ -131,18 +111,18 @@ class xReflector {
} }
return $suffix; return $suffix;
} }
public function StationCount() { public function StationCount() {
return count($this->Stations); return count($this->Stations);
} }
public function GetStation($ArrayIndex) { public function GetStation($ArrayIndex) {
if (isset($this->Stations[$ArrayIndex])) { if (isset($this->Stations[$ArrayIndex])) {
return $this->Stations[$ArrayIndex]; return $this->Stations[$ArrayIndex];
} }
return false; return false;
} }
public function GetFlag($Callsign) { public function GetFlag($Callsign) {
$Image = ""; $Image = "";
$FoundFlag = false; $FoundFlag = false;
@ -151,7 +131,7 @@ class xReflector {
$j = 0; $j = 0;
$Prefix = substr($Callsign, 0, $Letters); $Prefix = substr($Callsign, 0, $Letters);
while (($j < count($this->Flagarray)) && (!$FoundFlag)) { while (($j < count($this->Flagarray)) && (!$FoundFlag)) {
$z = 0; $z = 0;
while (($z < count($this->Flagarray[$j]['DXCC'])) && (!$FoundFlag)) { while (($z < count($this->Flagarray[$j]['DXCC'])) && (!$FoundFlag)) {
if (trim($Prefix) == trim($this->Flagarray[$j]['DXCC'][$z])) { if (trim($Prefix) == trim($this->Flagarray[$j]['DXCC'][$z])) {
@ -164,9 +144,9 @@ class xReflector {
} }
$Letters++; $Letters++;
} }
if (!$FoundFlag) { if (!$FoundFlag) {
$Prefix = substr($Callsign, 0, 1); $Prefix = substr($Callsign, 0, 1);
if ($Prefix == 'N') { $Image = "us"; } if ($Prefix == 'N') { $Image = "us"; }
if ($Prefix == 'K') { $Image = "us"; } if ($Prefix == 'K') { $Image = "us"; }
if ($Prefix == 'W') { $Image = "us"; } if ($Prefix == 'W') { $Image = "us"; }
@ -176,7 +156,7 @@ class xReflector {
} }
return strtolower($Image); return strtolower($Image);
} }
public function GetModules() { public function GetModules() {
$out = array(); $out = array();
for ($i=0;$i<$this->NodeCount();$i++) { for ($i=0;$i<$this->NodeCount();$i++) {
@ -194,17 +174,17 @@ class xReflector {
} }
return $out; return $out;
} }
public function GetCallSignsInModules($Module) { public function GetCallSignsInModules($Module) {
$out = array(); $out = array();
for ($i=0;$i<$this->NodeCount();$i++) { for ($i=0;$i<$this->NodeCount();$i++) {
if ($this->Nodes[$i]->GetLinkedModule() == $Module) { if ($this->Nodes[$i]->GetLinkedModule() == $Module) {
$out[] = $this->Nodes[$i]->GetCallsign(); $out[] = $this->Nodes[$i]->GetCallsign();
} }
} }
return $out; return $out;
} }
} }
?> ?>