2016-01-01 07:42:52 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class xReflector {
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
public $Nodes = null;
|
|
|
|
public $Stations = null;
|
2016-02-11 12:51:12 -05:00
|
|
|
public $Peers = null;
|
2016-01-01 07:42:52 -05:00
|
|
|
private $Flagarray = null;
|
|
|
|
private $Flagfile = null;
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
public function __construct() {
|
|
|
|
$this->Nodes = array();
|
|
|
|
$this->Stations = array();
|
2016-02-11 12:51:12 -05:00
|
|
|
$this->Peers = array();
|
2016-01-01 07:42:52 -05:00
|
|
|
}
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
public function SetFlagFile($Flagfile) {
|
|
|
|
if (file_exists($Flagfile) && (is_readable($Flagfile))) {
|
|
|
|
$this->Flagfile = $Flagfile;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
public function LoadFlags() {
|
|
|
|
if ($this->Flagfile != null) {
|
|
|
|
$this->Flagarray = array();
|
|
|
|
$handle = fopen($this->Flagfile,"r");
|
|
|
|
if ($handle) {
|
|
|
|
$i = 0;
|
|
|
|
while(!feof($handle)) {
|
|
|
|
$row = fgets($handle,1024);
|
|
|
|
$tmp = explode(";", $row);
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
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();
|
2016-01-27 09:56:41 -05:00
|
|
|
if (isset($tmp[2])) {
|
2016-01-01 07:42:52 -05:00
|
|
|
$tmp2 = explode("-", $tmp[2]);
|
|
|
|
for ($j=0;$j<count($tmp2);$j++) {
|
|
|
|
$this->Flagarray[$i]['DXCC'][] = $tmp2[$j];
|
|
|
|
}
|
|
|
|
}
|
2016-01-27 09:56:41 -05:00
|
|
|
$i++;
|
2016-01-01 07:42:52 -05:00
|
|
|
}
|
|
|
|
fclose($handle);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
public function AddNode($NodeObject) {
|
|
|
|
if (is_object($NodeObject)) {
|
|
|
|
$this->Nodes[] = $NodeObject;
|
|
|
|
}
|
|
|
|
}
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
public function NodeCount() {
|
|
|
|
return count($this->Nodes);
|
|
|
|
}
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
public function GetNode($ArrayIndex) {
|
|
|
|
if (isset($this->Nodes[$ArrayIndex])) {
|
|
|
|
return $this->Nodes[$ArrayIndex];
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-02-11 12:51:12 -05:00
|
|
|
public function AddPeer($PeerObject) {
|
|
|
|
if (is_object($PeerObject)) {
|
|
|
|
$this->Peers[] = $PeerObject;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function PeerCount() {
|
|
|
|
return count($this->Peers);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function GetPeer($ArrayIndex) {
|
|
|
|
if (isset($this->Peer[$ArrayIndex])) {
|
|
|
|
return $this->Peer[$ArrayIndex];
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
public function AddStation($StationObject, $AllowDouble = false) {
|
|
|
|
if (is_object($StationObject)) {
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
if ($AllowDouble) {
|
|
|
|
$this->Stations[] = $StationObject;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$FoundStationInList = false;
|
|
|
|
$i = 0;
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
$tmp = explode(" ", $StationObject->GetCallsign());
|
|
|
|
$RealCallsign = trim($tmp[0]);
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
while (!$FoundStationInList && $i<$this->StationCount()) {
|
|
|
|
if ($this->Stations[$i]->GetCallsignOnly() == $RealCallsign) {
|
|
|
|
$FoundStationInList = true;
|
|
|
|
}
|
|
|
|
$i++;
|
|
|
|
}
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
if (!$FoundStationInList) {
|
2016-01-27 09:56:41 -05:00
|
|
|
if (strlen(trim($RealCallsign)) > 3) {
|
|
|
|
$this->Stations[] = $StationObject;
|
|
|
|
}
|
2016-01-01 07:42:52 -05:00
|
|
|
}
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-02-19 06:23:06 -05:00
|
|
|
public function GetSuffixOfRepeater($Repeater, $LinkedModul, $StartWithIndex = 0) {
|
2016-01-01 07:42:52 -05:00
|
|
|
$suffix = "";
|
|
|
|
$found = false;
|
2016-02-19 06:23:06 -05:00
|
|
|
$i = $StartWithIndex;
|
2016-01-01 07:42:52 -05:00
|
|
|
while (!$found && $i < $this->NodeCount()) {
|
2016-02-19 06:23:06 -05:00
|
|
|
if ($this->Nodes[$i]->GetLinkedModule() == $LinkedModul) {
|
|
|
|
if (strpos($this->Nodes[$i]->GetCallSign(), $Repeater) !== false) {
|
|
|
|
$suffix = $this->Nodes[$i]->GetSuffix();
|
|
|
|
$found = true;
|
|
|
|
}
|
2016-01-01 07:42:52 -05:00
|
|
|
}
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
return $suffix;
|
|
|
|
}
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
public function StationCount() {
|
|
|
|
return count($this->Stations);
|
|
|
|
}
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
public function GetStation($ArrayIndex) {
|
|
|
|
if (isset($this->Stations[$ArrayIndex])) {
|
|
|
|
return $this->Stations[$ArrayIndex];
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
public function GetFlag($Callsign) {
|
|
|
|
$Image = "";
|
|
|
|
$FoundFlag = false;
|
|
|
|
$Letters = 2;
|
|
|
|
while (($Letters < 5) && (!$FoundFlag)) {
|
|
|
|
$j = 0;
|
|
|
|
$Prefix = substr($Callsign, 0, $Letters);
|
|
|
|
while (($j < count($this->Flagarray)) && (!$FoundFlag)) {
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
$z = 0;
|
|
|
|
while (($z < count($this->Flagarray[$j]['DXCC'])) && (!$FoundFlag)) {
|
|
|
|
if (trim($Prefix) == trim($this->Flagarray[$j]['DXCC'][$z])) {
|
|
|
|
$Image = $this->Flagarray[$j]['ISO'];
|
|
|
|
$FoundFlag = true;
|
|
|
|
}
|
|
|
|
$z++;
|
|
|
|
}
|
|
|
|
$j++;
|
|
|
|
}
|
|
|
|
$Letters++;
|
|
|
|
}
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
return strtolower($Image);
|
|
|
|
}
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
public function GetModules() {
|
|
|
|
$out = array();
|
|
|
|
for ($i=0;$i<$this->NodeCount();$i++) {
|
|
|
|
$Found = false;
|
|
|
|
$b = 0;
|
|
|
|
while ($b < count($out) && !$Found) {
|
|
|
|
if ($out[$b] == $this->Nodes[$i]->GetLinkedModule()) {
|
|
|
|
$Found = true;
|
|
|
|
}
|
|
|
|
$b++;
|
|
|
|
}
|
|
|
|
if (!$Found && (trim($this->Nodes[$i]->GetLinkedModule()) != "")) {
|
|
|
|
$out[] = $this->Nodes[$i]->GetLinkedModule();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $out;
|
|
|
|
}
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
public function GetCallSignsInModules($Module) {
|
|
|
|
$out = array();
|
|
|
|
for ($i=0;$i<$this->NodeCount();$i++) {
|
|
|
|
if ($this->Nodes[$i]->GetLinkedModule() == $Module) {
|
|
|
|
$out[] = $this->Nodes[$i]->GetCallsign();
|
2016-01-27 09:56:41 -05:00
|
|
|
}
|
2016-01-01 07:42:52 -05:00
|
|
|
}
|
|
|
|
return $out;
|
|
|
|
}
|
2016-01-27 09:56:41 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
}
|
|
|
|
|
2016-02-04 06:21:42 -05:00
|
|
|
?>
|