Merge pull request #7 from n7tae/main

new peer tab
pull/8/head
Steve Miller 2020-11-08 15:55:57 -05:00 committed by GitHub
commit 6ff1e903f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 112 additions and 7 deletions

101
include/peers.php 100644
View File

@ -0,0 +1,101 @@
<?php
$Result = @fopen($CallingHome['ServerURL']."?do=GetReflectorList", "r");
$INPUT = "";
if ($Result) {
while (!feof ($Result)) {
$INPUT .= fgets ($Result, 1024);
}
$XML = new ParseXML();
$Reflectorlist = $XML->GetElement($INPUT, "reflectorlist");
$Reflectors = $XML->GetAllElements($Reflectorlist, "reflector");
}
fclose($Result);
?>
<table class="table table-striped table-hover">
<tr class="table-center">
<th class="col-md-1">#</th>
<th class="col-md-2">XLX Peer</th>
<th class="col-md-2">Last Heard</th>
<th class="col-md-2">Linked for</th>
<th class="col-md-2">Protocol</th>
<th class="col-md-1">Module</th><?php
if ($PageOptions['PeerPage']['IPModus'] != 'HideIP') {
echo '<th class="col-md-2">IP</th>';
}
?>
</tr>
<?php
$Reflector->LoadFlags();
for ($i=0;$i<$Reflector->PeerCount();$i++) {
echo '
<tr class="table-center">
<td>'.($i+1).'</td>';
$Name = $Reflector->Peers[$i]->GetCallSign();
$URL = '';
for ($j=1;$j<count($Reflectors);$j++) {
if ($Name === $XML->GetElement($Reflectors[$j], "name")) {
$URL = $XML->GetElement($Reflectors[$j], "dashboardurl");
}
}
if ($Result && (trim($URL) != "")) {
echo '<td><a href="'.$URL.'" target="_blank" class="listinglink" title="Visit the Dashboard of&nbsp;'.$Name.'" style="text-decoration:none;color:#000000;">'.$Name.'</a></td>';
} else {
echo '<td>'.$Name.'</td>';
}
echo '
<td>'.date("d.m.Y H:i", $Reflector->Peers[$i]->GetLastHeardTime()).'</td>
<td>'.FormatSeconds(time()-$Reflector->Peers[$i]->GetConnectTime()).' s</td>
<td>'.$Reflector->Peers[$i]->GetProtocol().'</td>
<td>'.$Reflector->Peers[$i]->GetLinkedModule().'</td>';
if ($PageOptions['PeerPage']['IPModus'] != 'HideIP') {
echo '<td>';
$Bytes = explode(".", $Reflector->Peers[$i]->GetIP());
$MC = $PageOptions['RepeatersPage']['MasqueradeCharacter'];
if ($Bytes !== false && count($Bytes) == 4) {
switch ($PageOptions['PeerPage']['IPModus']) {
case 'ShowLast1ByteOfIP':
echo $MC.'.'.$MC.'.'.$MC.'.'.$Bytes[3];
break;
case 'ShowLast2ByteOfIP':
echo $MC.'.'.$MC.'.'.$Bytes[2].'.'.$Bytes[3];
break;
case 'ShowLast3ByteOfIP':
echo $MC.'.'.$Bytes[1].'.'.$Bytes[2].'.'.$Bytes[3];
break;
default:
echo '<a href="http://'.$Reflector->Peers[$i]->GetIP().'" target="_blank" style="text-decoration:none;color:#000000;">'.$Reflector->Peers[$i]->GetIP().'</a>';
}
} else {
$ipstr = $Reflector->Peers[$i]->GetIP();
$count = substr_count($ipstr, ":");
if ($count > 1) {
if (1 == substr_count($ipstr, "::")) { $ipstr = str_replace("::", str_repeat(":", 9 - $count), $ipstr); }
if (7 == substr_count($ipstr, ":")) {
echo $MC.':'.$MC.':'.$MC.':'.$MC.':'.$MC.':'.$MC;
$Bytes = explode(":", $ipstr);
for( $k=6; $k<8; $k++) { echo (0==strlen($Bytes[$k])) ? ':0' : ':'.$Bytes[$k]; }
}
}
}
echo '</td>';
}
echo '</tr>';
if ($i == $PageOptions['PeerPage']['LimitTo']) { $i = $Reflector->PeerCount()+1; }
}
?>
</table>

View File

@ -4,7 +4,7 @@
* This dashboard is developed by KC1AWV for the mrefd M17
* reflector system. It is derived from the XLX dashboard
* originally developed by the DVBrazil team.
*
*
* version 1.1.2
*/
@ -109,6 +109,7 @@ $Reflector->LoadXML();
<ul class="navbar-nav mr-auto">
<li<?php echo (($_GET['show'] == "users") || ($_GET['show'] == "")) ? ' class="nav-item active"' : ''; ?>><a class="nav-link" href="./index.php">Last Heard</a></li>
<li<?php echo ($_GET['show'] == "links") ? ' class="nav-item active"' : ''; ?>><a class="nav-link" href="./index.php?show=links">Links (<?php echo $Reflector->NodeCount(); ?>)</a></li>
<li<?php echo ($_GET['show'] == "peers") ? ' class="nav-item active"' : ''; ?>><a class="nav-link" href="./index.php?show=peers">Peers (<?php echo $Reflector->PeerCount(); ?>)</a></li>
</ul>
<span class="navbar-text px-2">mrefd v<?php echo $Reflector->GetVersion(); ?> - Dashboard v1.2.0 <?php echo $PageOptions['LocalModification']; ?></span>
<span class="navbar-text px-2">Service uptime: <?php echo FormatSeconds($Reflector->GetServiceUptime()); ?></span>
@ -117,16 +118,19 @@ $Reflector->LoadXML();
<main role="main">
<div class="container-fluid">
<div class="row">
<?php
<?php
switch ($_GET['show']) {
case 'users' :
require_once("./include/users.php");
break;
case 'links' :
require_once("./include/links.php");
break;
default :
require_once("./include/users.php");
case 'links' :
require_once("./include/links.php");
break;
case 'peers' :
require_once("./include/peers.php");
break;
default :
require_once("./include/users.php");
}
?>