From a248c0ef39303c594a50700e4edf7fc90d8fbeff Mon Sep 17 00:00:00 2001 From: Luiz Amaral Date: Sun, 27 Aug 2017 18:09:08 -0300 Subject: [PATCH] Dashboard 2 updates for xlxd 2.x.x --- dashboard2/index.php | 312 ++++++++++++++++------------- dashboard2/pgs/class.node.php | 9 +- dashboard2/pgs/class.parsexml.php | 21 +- dashboard2/pgs/class.reflector.php | 37 +++- dashboard2/pgs/class.station.php | 5 +- dashboard2/pgs/config.inc.php | 5 +- dashboard2/pgs/peers.php | 44 +++- dashboard2/pgs/repeaters.php | 2 +- dashboard2/pgs/users.php | 183 +++++++++++++---- 9 files changed, 404 insertions(+), 214 deletions(-) diff --git a/dashboard2/index.php b/dashboard2/index.php index 9f15fa0..1769c4f 100644 --- a/dashboard2/index.php +++ b/dashboard2/index.php @@ -6,15 +6,23 @@ * The dashboard is based of the Bootstrap dashboard template. */ -if (file_exists("./pgs/functions.php")) { require_once("./pgs/functions.php"); } else { die("functions.php does not exist."); } -if (file_exists("./pgs/config.inc.php")) { require_once("./pgs/config.inc.php"); } else { die("config.inc.php does not exist."); } +if (file_exists("./pgs/functions.php")) { + require_once("./pgs/functions.php"); +} else { + die("functions.php does not exist."); +} +if (file_exists("./pgs/config.inc.php")) { + require_once("./pgs/config.inc.php"); +} else { + die("config.inc.php does not exist."); +} -if (!class_exists('ParseXML')) require_once("./pgs/class.parsexml.php"); -if (!class_exists('Node')) require_once("./pgs/class.node.php"); +if (!class_exists('ParseXML')) require_once("./pgs/class.parsexml.php"); +if (!class_exists('Node')) require_once("./pgs/class.node.php"); if (!class_exists('xReflector')) require_once("./pgs/class.reflector.php"); -if (!class_exists('Station')) require_once("./pgs/class.station.php"); -if (!class_exists('Peer')) require_once("./pgs/class.peer.php"); -if (!class_exists('Interlink')) require_once("./pgs/class.interlink.php"); +if (!class_exists('Station')) require_once("./pgs/class.station.php"); +if (!class_exists('Peer')) require_once("./pgs/class.peer.php"); +if (!class_exists('Interlink')) require_once("./pgs/class.interlink.php"); $Reflector = new xReflector(); $Reflector->SetFlagFile("./pgs/country.csv"); @@ -23,176 +31,198 @@ $Reflector->SetXMLFile($Service['XMLFile']); $Reflector->LoadXML(); -if ($CallingHome['Active']) { - - $CallHomeNow = false; - if (!file_exists($CallingHome['HashFile'])) { - $Hash = CreateCode(16); - $LastSync = 0; - $Ressource = @fopen($CallingHome['HashFile'],"w"); - if ($Ressource) { - @fwrite($Ressource, "'); - @fclose($Ressource); - @exec("chmod 777 ".$CallingHome['HashFile']); - $CallHomeNow = true; - } - } - else { - include($CallingHome['HashFile']); - if ($LastSync < (time() - $CallingHome['PushDelay'])) { - $Ressource = @fopen($CallingHome['HashFile'],"w"); - if ($Ressource) { +if ($CallingHome['Active']) { + + $CallHomeNow = false; + if (!file_exists($CallingHome['HashFile'])) { + $Hash = CreateCode(16); + $LastSync = 0; + $Ressource = @fopen($CallingHome['HashFile'], "w"); + if ($Ressource) { @fwrite($Ressource, "'); + @fwrite($Ressource, "\n" . '$LastSync = 0;'); + @fwrite($Ressource, "\n" . '$Hash = "' . $Hash . '";'); + @fwrite($Ressource, "\n\n" . '?>'); @fclose($Ressource); - } - $CallHomeNow = true; - } - } - - if ($CallHomeNow || isset($_GET['callhome'])) { - $Reflector->SetCallingHome($CallingHome, $Hash); - $Reflector->ReadInterlinkFile(); - $Reflector->PrepareInterlinkXML(); - $Reflector->PrepareReflectorXML(); - $Reflector->CallHome(); - } -} -else { - $Hash = ""; + @exec("chmod 777 " . $CallingHome['HashFile']); + $CallHomeNow = true; + } + } else { + include($CallingHome['HashFile']); + if ($LastSync < (time() - $CallingHome['PushDelay'])) { + $Ressource = @fopen($CallingHome['HashFile'], "w"); + if ($Ressource) { + @fwrite($Ressource, "'); + @fclose($Ressource); + } + $CallHomeNow = true; + } + } + + if ($CallHomeNow || isset($_GET['callhome'])) { + $Reflector->SetCallingHome($CallingHome, $Hash); + $Reflector->ReadInterlinkFile(); + $Reflector->PrepareInterlinkXML(); + $Reflector->PrepareReflectorXML(); + $Reflector->CallHome(); + } +} else { + $Hash = ""; } ?> - - - - - - - - - - - - <?php echo $Reflector->GetReflectorName(); ?> Reflector Dashboard - - + + + + + + + + + - - + + <?php echo $Reflector->GetReflectorName(); ?> Reflector Dashboard + + + - - + + - - - + - if ($PageOptions['PageRefreshActive']) { - echo ' + + + function ReloadPage() { document.location.href = "./index.php'; - if (isset($_GET['show'])) { - echo '?show='.$_GET['show']; - } - echo '"; + if (isset($_GET['show'])) { + echo '?show=' . $_GET['show']; + } + echo '"; }'; - if (!isset($_GET['show']) || (($_GET['show'] != 'liveircddb') && ($_GET['show'] != 'reflectors') && ($_GET['show'] != 'interlinks'))) { - echo ' - setTimeout(ReloadPage, '.$PageOptions['PageRefreshDelay'].');'; - } - echo ' + if (!isset($_GET['show']) || (($_GET['show'] != 'liveircddb') && ($_GET['show'] != 'reflectors') && ($_GET['show'] != 'interlinks'))) { + echo ' + setTimeout(ReloadPage, ' . $PageOptions['PageRefreshDelay'] . ');'; + } + echo ' '; - } - if (!isset($_GET['show'])) $_GET['show'] = ""; -?> + } + if (!isset($_GET['show'])) $_GET['show'] = ""; + ?> - - -
-
+
+
- - your private hash in '.$CallingHome['HashFile'].' could not be created, please check your config file and the permissions for the defined folder. + your private hash in ' . $CallingHome['HashFile'] . ' could not be created, please check your config file and the permissions for the defined folder.
'; - } - } + } + } - switch ($_GET['show']) { - case 'users' : require_once("./pgs/users.php"); break; - case 'repeaters' : require_once("./pgs/repeaters.php"); break; - case 'liveircddb' : require_once("./pgs/liveircddb.php"); break; - case 'peers' : require_once("./pgs/peers.php"); break; - case 'reflectors' : require_once("./pgs/reflectors.php"); break; - default : require_once("./pgs/users.php"); - } + switch ($_GET['show']) { + case 'users' : + require_once("./pgs/users.php"); + break; + case 'repeaters' : + require_once("./pgs/repeaters.php"); + break; + case 'liveircddb' : + require_once("./pgs/liveircddb.php"); + break; + case 'peers' : + require_once("./pgs/peers.php"); + break; + case 'reflectors' : + require_once("./pgs/reflectors.php"); + break; + default : + require_once("./pgs/users.php"); + } -?> + ?> -
-
+
+ - + - - - - - - - + + + + + + + diff --git a/dashboard2/pgs/class.node.php b/dashboard2/pgs/class.node.php index 523e0ba..30a19d3 100644 --- a/dashboard2/pgs/class.node.php +++ b/dashboard2/pgs/class.node.php @@ -10,8 +10,9 @@ class Node { private $LastHeardTime; private $Suffix; private $Prefix; + private $RandomID; - public function __construct($Callsign, $IP, $LinkedModule, $Protocol, $ConnectTime, $LastHeardTime) { + public function __construct($Callsign, $IP, $LinkedModule, $Protocol, $ConnectTime, $LastHeardTime, $RandomID) { $this->IP = $IP; @@ -34,8 +35,8 @@ class Node { $this->Prefix = ""; } - - $this->LinkedModule = trim($LinkedModule); + $this->LinkedModule = trim($LinkedModule); + $this->RandomID = $RandomID; } public function GetFullCallsign() { return $this->FullCallsign; } @@ -47,6 +48,8 @@ class Node { public function GetLastHeardTime() { return $this->LastHeardTime; } public function GetSuffix() { return $this->Suffix; } public function GetPrefix() { return $this->Prefix; } + public function GetRandomID() { return $this->RandomID; } + } ?> diff --git a/dashboard2/pgs/class.parsexml.php b/dashboard2/pgs/class.parsexml.php index 700ee87..1d4069e 100644 --- a/dashboard2/pgs/class.parsexml.php +++ b/dashboard2/pgs/class.parsexml.php @@ -1,32 +1,29 @@ ") === false) return false; if (strpos($InputString, "") === false) return false; - + $Element = substr($InputString, strpos($InputString, "<".$ElementName.">")+strlen($ElementName)+2, strpos($InputString, "")-strpos($InputString, "<".$ElementName.">")-strlen($ElementName)-2); return $Element; - + } - + public function GetAllElements($InputString, $ElementName) { $Elements = array(); while (strpos($InputString, $ElementName) !== false) { $Elements[] = $this->GetElement($InputString, $ElementName); - $InputString = substr($InputString, strpos($InputString, "")+strlen($ElementName)+3, strlen($InputString)); + $InputString = substr($InputString, strpos($InputString, "")+strlen($ElementName)+3, strlen($InputString)); } return $Elements; } - - + } - - -?> \ No newline at end of file +?> diff --git a/dashboard2/pgs/class.reflector.php b/dashboard2/pgs/class.reflector.php index 67fab68..f15f092 100644 --- a/dashboard2/pgs/class.reflector.php +++ b/dashboard2/pgs/class.reflector.php @@ -59,14 +59,14 @@ class xReflector { $tmpNodes = $XML->GetAllElements($AllNodesString, "NODE"); for ($i=0;$iGetElement($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'), CreateCode(16)); $this->AddNode($Node); } $AllStationsString = $XML->GetElement($this->XMLContent, $LinkedUsersName); $tmpStations = $XML->GetAllElements($AllStationsString, "STATION"); for ($i=0;$iGetElement($tmpStations[$i], 'Callsign'), $XML->GetElement($tmpStations[$i], 'Via node'), $XML->GetElement($tmpStations[$i], 'Via peer'), $XML->GetElement($tmpStations[$i], 'LastHeardTime')); + $Station = new Station($XML->GetElement($tmpStations[$i], 'Callsign'), $XML->GetElement($tmpStations[$i], 'Via node'), $XML->GetElement($tmpStations[$i], 'Via peer'), $XML->GetElement($tmpStations[$i], 'LastHeardTime'), $XML->GetElement($tmpStations[$i], 'On module')); $this->AddStation($Station, false); } @@ -213,7 +213,7 @@ class xReflector { } } } - + public function GetSuffixOfRepeater($Repeater, $LinkedModul, $StartWithIndex = 0) { $suffix = ""; $found = false; @@ -230,6 +230,19 @@ class xReflector { return $suffix; } + public function GetCallsignAndSuffixByID($RandomId) { + $suffix = ""; + $callsign = ""; + $i = 0; + while ($i < $this->NodeCount()) { + if ($this->Nodes[$i]->GetRandomID() == $RandomId) { + return $this->Nodes[$i]->GetCallSign().'-'.$this->Nodes[$i]->GetSuffix(); + } + $i++; + } + return 'N/A'; + } + public function StationCount() { return count($this->Stations); } @@ -264,7 +277,6 @@ class xReflector { } $Letters--; } - return array(strtolower($Image), $Name); } @@ -287,6 +299,7 @@ class xReflector { } public function GetModuleOfNode($Node) { + die("FUNCTION DEPRECATED..."); $Node = trim(str_replace(" ", "-", $Node)); $Node = trim(str_replace(" ", "-", $Node)); $Node = trim(str_replace(" ", "-", $Node)); @@ -314,6 +327,16 @@ class xReflector { return $out; } + public function GetNodesInModulesById($Module) { + $out = array(); + for ($i=0;$i<$this->NodeCount();$i++) { + if ($this->Nodes[$i]->GetLinkedModule() == $Module) { + $out[] = $this->Nodes[$i]->GetRandomID(); + } + } + return $out; + } + public function SetCallingHome($CallingHomeVariables, $Hash) { if (!isset($CallingHomeVariables['Active'])) { $CallingHomeVariables['Active'] = false; } @@ -345,11 +368,6 @@ class xReflector { public function PushCallingHome() { $CallingHome = @fopen($this->CallingHomeServerURL."?ReflectorName=".$this->ReflectorName."&ReflectorUptime=".$this->ServiceUptime."&ReflectorHash=".$this->CallingHomeHash."&DashboardURL=".$this->CallingHomeDashboardURL."&Country=".urlencode($this->CallingHomeCountry)."&Comment=".urlencode($this->CallingHomeComment)."&OverrideIP=".$this->CallingHomeOverrideIP, "r"); - - - - - //debug($this->CallingHomeServerURL."?ReflectorName=".$this->ReflectorName."&ReflectorUptime=".$this->ServiceUptime."&ReflectorHash=".$this->CallingHomeHash."&DashboardURL=".$this->CallingHomeDashboardURL."&Country=".urlencode($this->CallingHomeCountry)."&Comment=".urlencode($this->CallingHomeComment)); } public function ReadInterlinkFile() { @@ -402,6 +420,7 @@ class xReflector { '.$this->CallingHomeCountry.' '.$this->CallingHomeComment.' '.$this->CallingHomeOverrideIP.' + '.$this->Version.' '; } diff --git a/dashboard2/pgs/class.station.php b/dashboard2/pgs/class.station.php index 5541e02..533601c 100644 --- a/dashboard2/pgs/class.station.php +++ b/dashboard2/pgs/class.station.php @@ -8,8 +8,9 @@ class Station { private $Suffix; private $CallsignOnly; private $Peer; + private $OnModule; - public function __construct($Callsign, $Via, $Peer, $LastHeardTime) { + public function __construct($Callsign, $Via, $Peer, $LastHeardTime, $OnModule) { $this->Callsign = trim($Callsign); $this->Via = trim($Via); $this->Peer = trim($Peer); @@ -23,6 +24,7 @@ class Station { $tmp = explode(" ", $Callsign); $this->CallsignOnly = $tmp[0]; + $this->OnModule = $OnModule; } public function GetCallsign() { return $this->Callsign; } @@ -31,6 +33,7 @@ class Station { public function GetLastHeardTime() { return $this->LastHeardTime; } public function GetSuffix() { return $this->Suffix; } public function GetCallsignOnly() { return $this->CallsignOnly; } + public function GetModule() { return $this->OnModule; } } diff --git a/dashboard2/pgs/config.inc.php b/dashboard2/pgs/config.inc.php index b282b2d..c841796 100644 --- a/dashboard2/pgs/config.inc.php +++ b/dashboard2/pgs/config.inc.php @@ -16,7 +16,7 @@ $PageOptions = array(); $PageOptions['ContactEmail'] = 'your_email'; // Support E-Mail address -$PageOptions['DashboardVersion'] = '2.3.1'; // Dashboard Version +$PageOptions['DashboardVersion'] = '2.3.7'; // Dashboard Version $PageOptions['PageRefreshActive'] = true; // Activate automatic refresh $PageOptions['PageRefreshDelay'] = '10000'; // Page refresh time in miliseconds @@ -33,6 +33,7 @@ $PageOptions['PeerPage']['LimitTo'] = 99; // Numb $PageOptions['PeerPage']['IPModus'] = 'ShowFullIP'; // See possible options above $PageOptions['PeerPage']['MasqueradeCharacter'] = '*'; // Character used for masquerade +$PageOptions['LastHeardPage']['LimitTo'] = 39; // Number of stations to show $PageOptions['ModuleNames'] = array(); // Module nomination $PageOptions['ModuleNames']['A'] = 'Int.'; @@ -47,7 +48,7 @@ $PageOptions['MetaAuthor'] = 'LX1IQ'; $PageOptions['MetaRevisit'] = 'After 30 Days'; // Meta Tag Values, usefull for Search Engine $PageOptions['MetaRobots'] = 'index,follow'; // Meta Tag Values, usefull for Search Engine - +$PageOptions['UserPage']['ShowFilter'] = true; // Show Filter on Users page $Service['PIDFile'] = '/var/log/xlxd.pid'; $Service['XMLFile'] = '/var/log/xlxd.xml'; diff --git a/dashboard2/pgs/peers.php b/dashboard2/pgs/peers.php index 9271818..1f45c13 100644 --- a/dashboard2/pgs/peers.php +++ b/dashboard2/pgs/peers.php @@ -1,3 +1,23 @@ +GetElement($INPUT, "reflectorlist"); + $Reflectors = $XML->GetAllElements($Reflectorlist, "reflector"); +} + +fclose($Result); +?> + @@ -22,15 +42,28 @@ for ($i=0;$i<$Reflector->PeerCount();$i++) { echo ' - - + '; + + $Name = $Reflector->Peers[$i]->GetCallSign(); + $URL = ''; + + for ($j=1;$jGetElement($Reflectors[$j], "name")) { + $URL = $XML->GetElement($Reflectors[$j], "dashboardurl"); + } + } + if ($Result && (trim($URL) != "")) { + echo ''; + } else { + echo ''; + } + echo ' '; if ($PageOptions['PeerPage']['IPModus'] != 'HideIP') { - echo ' - '; } - echo ' - '; + echo ''; if ($i == $PageOptions['PeerPage']['LimitTo']) { $i = $Reflector->PeerCount()+1; } } diff --git a/dashboard2/pgs/repeaters.php b/dashboard2/pgs/repeaters.php index 3e1f643..a7562b9 100644 --- a/dashboard2/pgs/repeaters.php +++ b/dashboard2/pgs/repeaters.php @@ -49,7 +49,7 @@ for ($i=0;$i<$Reflector->NodeCount();$i++) { case 'C' : echo '2m'; break; case 'D' : echo 'Dongle'; break; case 'G' : echo 'Internet-Gateway'; break; - default : + default : echo ''; } } echo ' diff --git a/dashboard2/pgs/users.php b/dashboard2/pgs/users.php index bff6a75..bc8f92f 100644 --- a/dashboard2/pgs/users.php +++ b/dashboard2/pgs/users.php @@ -1,6 +1,86 @@ + +
#
'.($i+1).''.$Reflector->Peers[$i]->GetCallSign().''.($i+1).''.$Name.''.$Name.''.date("d.m.Y H:i", $Reflector->Peers[$i]->GetLastHeardTime()).' '.FormatSeconds(time()-$Reflector->Peers[$i]->GetConnectTime()).' s '.$Reflector->Peers[$i]->GetProtocol().' '.$Reflector->Peers[$i]->GetLinkedModule().''; + echo ''; $Bytes = explode(".", $Reflector->Peers[$i]->GetIP()); if ($Bytes !== false && count($Bytes) == 4) { switch ($PageOptions['PeerPage']['IPModus']) { @@ -42,8 +75,7 @@ for ($i=0;$i<$Reflector->PeerCount();$i++) { } echo '
+ + +'; +} +?> @@ -15,36 +95,59 @@ $Reflector->LoadFlags(); for ($i=0;$i<$Reflector->StationCount();$i++) { - echo ' - - - - - - - - - + $ShowThisStation = true; + if ($PageOptions['UserPage']['ShowFilter']) { + $CS = true; + if ($_SESSION['FilterCallSign'] != null) { + if (!fnmatch($_SESSION['FilterCallSign'], $Reflector->Stations[$i]->GetCallSign(), FNM_CASEFOLD)) { + $CS = false; + } + } + $MO = true; + if ($_SESSION['FilterModule'] != null) { + if (trim(strtolower($_SESSION['FilterModule'])) != strtolower($Reflector->Stations[$i]->GetModule())) { + $MO = false; + } + } + + $ShowThisStation = ($CS && $MO); + } + + if ($ShowThisStation) { + + echo ' + + + + + + + + + '; - if ($i == 39) { $i = $Reflector->StationCount()+1; } + } + if ($i == $PageOptions['LastHeardPage']['LimitTo']) { + $i = $Reflector->StationCount() + 1; + } } ?> @@ -56,11 +159,16 @@ for ($i=0;$i<$Reflector->StationCount();$i++) { GetModules(); +sort($Modules, SORT_STRING); echo ''; for ($i=0;$i'.$PageOptions['ModuleNames'][$Modules[$i]].' '.$Modules[$i].''; + echo ''; } else { echo ' @@ -71,20 +179,17 @@ for ($i=0;$i'; +$GlobalPositions = array(); + for ($i=0;$iGetCallSignsInModules($Modules[$i]); + $Users = $Reflector->GetNodesInModulesByID($Modules[$i]); echo '
+ + + '; + if (($_SESSION['FilterModule'] != null) || ($_SESSION['FilterCallSign'] != null)) { + echo ' + '; + } + echo ' + +
+
+ + + +
+
Disable filters +
+ + + +
+
+
# Flag
'; - echo ($i==0 ? '' : $i+1); - - - echo ''; - - list ($Flag, $Name) = $Reflector->GetFlag($Reflector->Stations[$i]->GetCallSign()); - if (file_exists("./img/flags/".$Flag.".png")) { - echo ''.$Name.''.$Name.''; - } - echo ''.$Reflector->Stations[$i]->GetCallsignOnly().''.$Reflector->Stations[$i]->GetSuffix().''.$Reflector->Stations[$i]->GetVia(); - if ($Reflector->Stations[$i]->GetPeer() != $Reflector->GetReflectorName()) { - echo ' / '.$Reflector->Stations[$i]->GetPeer(); - } - echo ''.@date("d.m.Y H:i", $Reflector->Stations[$i]->GetLastHeardTime()).''; - if ($Reflector->Stations[$i]->GetPeer() == $Reflector->GetReflectorName()) { - echo trim($Reflector->GetModuleOfNode($Reflector->Stations[$i]->GetVia())); - } - echo '
'; + if ($i == 0 && $Reflector->Stations[$i]->GetLastHeardTime() > (time() - 60)) { + echo ''; + } else { + echo($i + 1); + } + + + echo ''; + + list ($Flag, $Name) = $Reflector->GetFlag($Reflector->Stations[$i]->GetCallSign()); + if (file_exists("./img/flags/" . $Flag . ".png")) { + echo '' . $Name . '' . $Name . ''; + } + echo '' . $Reflector->Stations[$i]->GetCallsignOnly() . '' . $Reflector->Stations[$i]->GetSuffix() . '' . $Reflector->Stations[$i]->GetVia(); + if ($Reflector->Stations[$i]->GetPeer() != $Reflector->GetReflectorName()) { + echo ' / ' . $Reflector->Stations[$i]->GetPeer(); + } + echo '' . @date("d.m.Y H:i", $Reflector->Stations[$i]->GetLastHeardTime()) . '' . $Reflector->Stations[$i]->GetModule() . '
'.$PageOptions['ModuleNames'][$Modules[$i]]; + if (trim($PageOptions['ModuleNames'][$Modules[$i]]) != "") { + echo '
'; + } + echo $Modules[$i].'
'; + $UserCheckedArray = array(); for ($j=0;$jGetSuffixOfRepeater($Users[$j], $Modules[$i], max($CurrentPositions)+1); - } - else { - $Displayname = $Users[$j].'-'.$Reflector->GetSuffixOfRepeater($Users[$j], $Modules[$i]); - } + $Displayname = $Reflector->GetCallsignAndSuffixByID($Users[$j]); echo ' @@ -99,4 +204,4 @@ echo ''; ?>
'.$Displayname.'
- + \ No newline at end of file