From 8d8143fed916ce539ffca36e5923bb18d1ffa383 Mon Sep 17 00:00:00 2001 From: Tom Early Date: Mon, 13 Jul 2020 13:15:54 -0700 Subject: [PATCH] XLX->XRF --- dashboard.xrf/pgs/class.reflector.php | 144 +++++++++++++------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/dashboard.xrf/pgs/class.reflector.php b/dashboard.xrf/pgs/class.reflector.php index d066819..8d9924e 100644 --- a/dashboard.xrf/pgs/class.reflector.php +++ b/dashboard.xrf/pgs/class.reflector.php @@ -1,7 +1,7 @@ Nodes = array(); $this->Stations = array(); @@ -35,61 +35,61 @@ class xReflector { $this->Interlinks = array(); $this->Transferinterlink = false; } - + public function LoadXML() { if ($this->XMLFile != null) { $handle = fopen($this->XMLFile, 'r'); $this->XMLContent = fread($handle, filesize($this->XMLFile)); fclose($handle); - - $this->ServiceName = substr($this->XMLContent, strpos($this->XMLContent, "ServiceName = substr($this->XMLContent, strpos($this->XMLContent, "ServiceName)) { $this->ServiceName = null; return false; } - - $this->ReflectorName = "XLX".$this->ServiceName; - - $LinkedPeersName = "XLX".$this->ServiceName." linked peers"; - $LinkedNodesName = "XLX".$this->ServiceName." linked nodes"; - $LinkedUsersName = "XLX".$this->ServiceName." heard users"; - + + $this->ReflectorName = "XRF".$this->ServiceName; + + $LinkedPeersName = "XRF".$this->ServiceName." linked peers"; + $LinkedNodesName = "XRF".$this->ServiceName." linked nodes"; + $LinkedUsersName = "XRF".$this->ServiceName." heard users"; + $XML = new ParseXML(); - + $AllNodesString = $XML->GetElement($this->XMLContent, $LinkedNodesName); $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'), 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'), $XML->GetElement($tmpStations[$i], 'On module')); $this->AddStation($Station, false); } - + $AllPeersString = $XML->GetElement($this->XMLContent, $LinkedPeersName); $tmpPeers = $XML->GetAllElements($AllPeersString, "PEER"); for ($i=0;$iGetElement($tmpPeers[$i], 'Callsign'), $XML->GetElement($tmpPeers[$i], 'IP'), $XML->GetElement($tmpPeers[$i], 'LinkedModule'), $XML->GetElement($tmpPeers[$i], 'Protocol'), $XML->GetElement($tmpPeers[$i], 'ConnectTime'), $XML->GetElement($tmpPeers[$i], 'LastHeardTime')); $this->AddPeer($Peer, false); } - - $this->Version = $XML->GetElement($this->XMLContent, "Version"); + + $this->Version = $XML->GetElement($this->XMLContent, "Version"); } } - + public function GetVersion() { return $this->Version; } - + public function GetReflectorName() { return $this->ReflectorName; } - + public function SetXMLFile($XMLFile) { if (file_exists($XMLFile) && (is_readable($XMLFile))) { $this->XMLFile = $XMLFile; @@ -99,7 +99,7 @@ class xReflector { $this->XMLContent = null; } } - + public function SetPIDFile($ProcessIDFile) { if (file_exists($ProcessIDFile)) { $this->ProcessIDFile = $ProcessIDFile; @@ -110,11 +110,11 @@ class xReflector { $this->ServiceUptime = null; } } - + public function GetServiceUptime() { return $this->ServiceUptime; } - + public function SetFlagFile($Flagfile) { if (file_exists($Flagfile) && (is_readable($Flagfile))) { $this->Flagfile = $Flagfile; @@ -122,7 +122,7 @@ class xReflector { } return false; } - + public function LoadFlags() { if ($this->Flagfile != null) { $this->Flagarray = array(); @@ -133,18 +133,18 @@ 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;$jFlagarray[$i]['DXCC'][] = $tmp2[$j]; $this->Flagarray_DXCC[ trim($tmp2[$j]) ] = $i; } } - $i++; + $i++; } fclose($handle); } @@ -152,17 +152,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]; @@ -175,11 +175,11 @@ class xReflector { $this->Peers[] = $PeerObject; } } - + public function PeerCount() { return count($this->Peers); } - + public function GetPeer($ArrayIndex) { if (isset($this->Peer[$ArrayIndex])) { return $this->Peer[$ArrayIndex]; @@ -189,34 +189,34 @@ 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) { if (strlen(trim($RealCallsign)) > 3) { $this->Stations[] = $StationObject; } } - + } } } - + public function GetSuffixOfRepeater($Repeater, $LinkedModul, $StartWithIndex = 0) { $suffix = ""; $found = false; @@ -232,7 +232,7 @@ class xReflector { } return $suffix; } - + public function GetCallsignAndSuffixByID($RandomId) { $suffix = ""; $callsign = ""; @@ -250,18 +250,18 @@ class xReflector { } return 'N/A'; } - + 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 = ""; $Letters = 4; @@ -277,7 +277,7 @@ class xReflector { } return array(strtolower($Image), $Name); } - + public function GetModules() { $out = array(); for ($i=0;$i<$this->NodeCount();$i++) { @@ -295,7 +295,7 @@ class xReflector { } return $out; } - + public function GetModuleOfNode($Node) { die("FUNCTION DEPRECATED..."); $Node = trim(str_replace(" ", "-", $Node)); @@ -305,38 +305,38 @@ class xReflector { $i = 0; $Module = ""; while (!$found && $i<$this->NodeCount()) { - if (strpos($Node, $this->Nodes[$i]->GetFullCallsign()) !== false) { - $Module = $this->Nodes[$i]->GetLinkedModule(); + if (strpos($Node, $this->Nodes[$i]->GetFullCallsign()) !== false) { + $Module = $this->Nodes[$i]->GetLinkedModule(); $found = true; } - + $i++; } return $Module; - } - + } + 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; } - + 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; } if (!isset($CallingHomeVariables['MyDashBoardURL'])) { $CallingHomeVariables['MyDashBoardURL'] = ''; } if (!isset($CallingHomeVariables['ServerURL'])) { $CallingHomeVariables['ServerURL'] = ''; } @@ -344,16 +344,16 @@ class xReflector { if (!isset($CallingHomeVariables['Comment'])) { $CallingHomeVariables['Comment'] = ''; } if (!isset($CallingHomeVariables['OverrideIPAddress'])) { $CallingHomeVariables['OverrideIPAddress'] = false; } if (!isset($CallingHomeVariables['InterlinkFile'])) { $CallingHomeVariables['InterlinkFile'] = ''; } - - if (!file_exists($CallingHomeVariables['InterlinkFile'])) { - $this->Interlinkfile = ''; + + if (!file_exists($CallingHomeVariables['InterlinkFile'])) { + $this->Interlinkfile = ''; $this->Transferinterlink = false; } else { $this->Transferinterlink = true; $this->Interlinkfile = $CallingHomeVariables['InterlinkFile']; } - + $this->CallingHomeActive = ($CallingHomeVariables['Active'] === true); $this->CallingHomeHash = $Hash; $this->CallingHomeDashboardURL = $CallingHomeVariables['MyDashBoardURL']; @@ -361,13 +361,13 @@ class xReflector { $this->CallingHomeCountry = $CallingHomeVariables['Country']; $this->CallingHomeComment = $CallingHomeVariables['Comment']; $this->CallingHomeOverrideIP = $CallingHomeVariables['OverrideIPAddress']; - + } - + 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"); - } - + } + public function ReadInterlinkFile() { if (file_exists($this->Interlinkfile) && (is_readable($this->Interlinkfile))) { $this->Interlinks = array(); @@ -379,7 +379,7 @@ class xReflector { $this->Interlinks[] = new Interlink(); if (isset($Interlink[0])) { $this->Interlinks[count($this->Interlinks)-1]->SetName(trim($Interlink[0])); } if (isset($Interlink[1])) { $this->Interlinks[count($this->Interlinks)-1]->SetAddress(trim($Interlink[1])); } - if (isset($Interlink[2])) { + if (isset($Interlink[2])) { $Modules = str_split(trim($Interlink[2]), 1); for ($j=0;$jInterlinks[count($this->Interlinks)-1]->AddModule($Modules[$j]); @@ -391,7 +391,7 @@ class xReflector { } return false; } - + public function PrepareInterlinkXML() { $xml = ' '; @@ -407,7 +407,7 @@ class xReflector { '; $this->InterlinkXML = $xml; } - + public function PrepareReflectorXML() { $this->ReflectorXML = ' @@ -421,28 +421,28 @@ class xReflector { '.$this->Version.' '; } - + public function CallHome() { $xml = ' CallingHome'.$this->ReflectorXML.$this->InterlinkXML; $p = @stream_context_create(array('http' => array('header' => "Content-type: application/x-www-form-urlencoded\r\n", - 'method' => 'POST', + 'method' => 'POST', 'content' => http_build_query(array('xml' => $xml)) ))); $result = @file_get_contents($this->CallingHomeServerURL, false, $p); if ($result === false) { die("CONNECTION FAILED!"); } } - + public function InterlinkCount() { return count($this->Interlinks); } - + public function GetInterlink($Index) { if (isset($this->Interlinks[$Index])) return $this->Interlinks[$Index]; return array(); } - + public function IsInterlinked($Reflectorname) { $i = -1; $f = false; @@ -457,7 +457,7 @@ class xReflector { } return -1; } - + } ?>