diff --git a/dashboard/json/.htaccess b/dashboard/json/.htaccess new file mode 100644 index 0000000..46623a5 --- /dev/null +++ b/dashboard/json/.htaccess @@ -0,0 +1,6 @@ +RewriteEngine On +RewriteBase /json/ +RewriteRule ^index\\.php$ - [L] +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule . /json/index.php [L] \ No newline at end of file diff --git a/dashboard/json/index.php b/dashboard/json/index.php new file mode 100644 index 0000000..7bcacad --- /dev/null +++ b/dashboard/json/index.php @@ -0,0 +1,61 @@ +SetXMLFile($Service['XMLFile']); +$Reflector->SetPIDFile($Service['PIDFile']); +$Reflector->LoadXML(); +$Reflector->SetFlagFile($_SERVER['DOCUMENT_ROOT'] . "/pgs/country.csv"); +$Reflector->LoadFlags(); + +$Request = $_SERVER['REQUEST_URI']; +$ViewDir = '/views/'; + +switch ($Request) { + case '/json/links': + require __DIR__ . $ViewDir . 'links.php'; + break; + + case '/json/metadata': + require __DIR__ . $ViewDir . 'metadata.php'; + break; + + case '/json/modulesinuse': + require __DIR__ . $ViewDir . 'modulesinuse.php'; + break; + + case '/json/peers': + require __DIR__ . $ViewDir . 'peers.php'; + break; + + case '/json/reflector': + require __DIR__ . $ViewDir . 'reflector.php'; + break; + + case '/json/stations': + require __DIR__ . $ViewDir . 'stations.php'; + break; + + case '/json/status': + require __DIR__ . $ViewDir . 'status.php'; + break; + + default: + header('Content-Type: text/plain'); + http_response_code(404); + echo('404 page not found'); + +} + +?> \ No newline at end of file diff --git a/dashboard/json/views/links.php b/dashboard/json/views/links.php new file mode 100644 index 0000000..6718f2d --- /dev/null +++ b/dashboard/json/views/links.php @@ -0,0 +1,24 @@ +NodeCount();$i++) { + + // craft payload array + $payload[$i] = array( + 'callsign' => $Reflector->Nodes[$i]->GetCallSign() . ' ' . $Reflector->Nodes[$i]->GetSuffix(), + 'ip' => $Reflector->Nodes[$i]->GetIP(), + 'linkedmodule' => $Reflector->Nodes[$i]->GetLinkedModule(), + 'protocol' => $Reflector->Nodes[$i]->GetProtocol(), + 'connecttime' => gmdate('Y-m-d\TH:i:sp', $Reflector->Nodes[$i]->GetConnectTime()), + 'lastheardtime' => gmdate('Y-m-d\TH:i:sp', $Reflector->Nodes[$i]->GetLastHeardTime()) + ); + +} + + +// json encode payload array +$records = json_encode($payload); + +echo $records; + +?> \ No newline at end of file diff --git a/dashboard/json/views/metadata.php b/dashboard/json/views/metadata.php new file mode 100644 index 0000000..fad5ed8 --- /dev/null +++ b/dashboard/json/views/metadata.php @@ -0,0 +1,23 @@ + $PageOptions['DashboardVersion'], + 'ipV4' => @$Net4[0]['ip'], + 'ipV6' => @$Net6[0]['ipv6'], + 'reflector_callsign' => str_replace("XLX", "URF", $Reflector->GetReflectorName()), + 'reflector_version' => $Reflector->GetVersion(), + 'sysop_email' => $PageOptions['ContactEmail'] +); + + +// json encode payload array +$records = json_encode($payload); + +echo $records; + +?> \ No newline at end of file diff --git a/dashboard/json/views/modulesinuse.php b/dashboard/json/views/modulesinuse.php new file mode 100644 index 0000000..85ba9c4 --- /dev/null +++ b/dashboard/json/views/modulesinuse.php @@ -0,0 +1,30 @@ +GetModules(); +sort($Modules, SORT_STRING); + + +/*** Add modules to payload ***/ +for ($i=0;$i $Modules[$i] + ); + + $Users = $Reflector->GetNodesInModulesByID($Modules[$i]); + + for ($j=0;$jGetCallsignAndSuffixByID($Users[$j]); + + } + +} + + +// json encode payload array +$records = json_encode($payload); + +echo $records; + +?> \ No newline at end of file diff --git a/dashboard/json/views/peers.php b/dashboard/json/views/peers.php new file mode 100644 index 0000000..c3dc079 --- /dev/null +++ b/dashboard/json/views/peers.php @@ -0,0 +1,22 @@ +PeerCount();$i++) { + + $payload[$i] = array( + 'callsign' => $Reflector->Peers[$i]->GetCallSign(), + 'ip' => $Reflector->Peers[$i]->GetIP(), + 'linkedmodule' => $Reflector->Peers[$i]->GetLinkedModule(), + 'connecttime' => gmdate('Y-m-d\TH:i:sp', $Reflector->Peers[$i]->GetConnectTime()), + 'lastheardtime' => gmdate('Y-m-d\TH:i:sp', $Reflector->Peers[$i]->GetLastHeardTime()) + ); + +} + + +// json encode payload array +$records = json_encode($payload); + +echo $records; + +?> \ No newline at end of file diff --git a/dashboard/json/views/reflector.php b/dashboard/json/views/reflector.php new file mode 100644 index 0000000..fe25d61 --- /dev/null +++ b/dashboard/json/views/reflector.php @@ -0,0 +1,70 @@ + date('Y-m-d\TH:i:sp', time()), + 'status' => $Status, + 'uptime' => $Reflector->GetServiceUptime() +); + + +/*** add data to payload ***/ +$payload['data'] = array( + 'filetime' => date('Y-m-d\TH:i:sp', filemtime($Service['XMLFile'])), + 'callsign' => str_replace("XLX", "URF", $Reflector->GetReflectorName()), + 'version' => $Reflector->GetVersion() +); + + +/*** Add peers to payload ***/ +for ($i=0;$i<$Reflector->PeerCount();$i++) { + + $payload['data']['peers'][] = array( + 'callsign' => $Reflector->Peers[$i]->GetCallSign(), + 'ip' => $Reflector->Peers[$i]->GetIP(), + 'linkedmodule' => $Reflector->Peers[$i]->GetLinkedModule(), + 'connecttime' => date('Y-m-d\TH:i:sp', $Reflector->Peers[$i]->GetConnectTime()), + 'lastheardtime' => date('Y-m-d\TH:i:sp', $Reflector->Peers[$i]->GetLastHeardTime()) + ); + +} + + +/*** Add nodes to payload ***/ +for ($i=0;$i<$Reflector->NodeCount();$i++) { + + // craft payload array + $payload['data']['nodes'][] = array( + 'callsign' => $Reflector->Nodes[$i]->GetCallSign() . ' ' . $Reflector->Nodes[$i]->GetSuffix(), + 'ip' => $Reflector->Nodes[$i]->GetIP(), + 'linkedmodule' => $Reflector->Nodes[$i]->GetLinkedModule(), + 'protocol' => $Reflector->Nodes[$i]->GetProtocol(), + 'connecttime' => gmdate('Y-m-d\TH:i:sp', $Reflector->Nodes[$i]->GetConnectTime()), + 'lastheardtime' => gmdate('Y-m-d\TH:i:sp', $Reflector->Nodes[$i]->GetLastHeardTime()) + ); + +} + + +/*** Add stations to payload ***/ +for ($i=0;$i<$Reflector->StationCount();$i++) { + + // craft payload array + $payload['data']['stations'][] = array( + 'callsign' => $Reflector->Stations[$i]->GetCallSign(), + 'vianode' => $Reflector->Stations[$i]->GetVia(), + 'onmodule' => $Reflector->Stations[$i]->GetModule(), + 'viapeer' => $Reflector->Stations[$i]->GetPeer(), + 'lastheardtime' => gmdate('Y-m-d\TH:i:sp', $Reflector->Stations[$i]->GetLastHeardTime()) + ); + +} + + +// json encode payload array +$records = json_encode($payload); + +echo $records; + +?> \ No newline at end of file diff --git a/dashboard/json/views/stations.php b/dashboard/json/views/stations.php new file mode 100644 index 0000000..e0ae95e --- /dev/null +++ b/dashboard/json/views/stations.php @@ -0,0 +1,36 @@ +StationCount();$i++) { + + $tmp = preg_split('/\s+/', $Reflector->Stations[$i]->GetCallSign(), -1, PREG_SPLIT_NO_EMPTY); + $Callsign = $tmp[0]; + + $tmp = preg_split('/\s+/', $Reflector->Stations[$i]->GetVia(), -1, PREG_SPLIT_NO_EMPTY); + $CallsignSuffix = $tmp[1]; + + // craft payload array + $payload['stations'][$i] = array( + 'callsign' => $Callsign, + 'callsignsuffix' => $CallsignSuffix, + 'vianode' => $Reflector->Stations[$i]->GetVia(), + 'onmodule' => $Reflector->Stations[$i]->GetModule(), + 'lastheard' => gmdate('Y-m-d\TH:i:sp', $Reflector->Stations[$i]->GetLastHeardTime()) + ); + + list ($CountryCode, $Country) = $Reflector->GetFlag($Reflector->Stations[$i]->GetCallSign()); + + $payload['stations'][$i]['country'] = array ( + 'country' => $Country, + 'countrycode' => $CountryCode + ); + +} + + +// json encode payload array +$records = json_encode($payload); + +echo $records; + +?> \ No newline at end of file diff --git a/dashboard/json/views/status.php b/dashboard/json/views/status.php new file mode 100644 index 0000000..5ebcb38 --- /dev/null +++ b/dashboard/json/views/status.php @@ -0,0 +1,18 @@ + gmdate('U', time()), + 'lasturfdupdate' => gmdate('U', filemtime($Service['XMLFile'])), + 'reflectorstatus' => $ReflectorStatus, + 'reflectoruptimeseconds' => $Reflector->GetServiceUptime() +); + + +// json encode payload array +$records = json_encode($payload); + +echo $records; + +?> diff --git a/dashboard/pgs/config.inc.php b/dashboard/pgs/config.inc.php index ee027e0..bfd71d6 100644 --- a/dashboard/pgs/config.inc.php +++ b/dashboard/pgs/config.inc.php @@ -16,7 +16,7 @@ $PageOptions = array(); $PageOptions['ContactEmail'] = 'your_email'; // Support E-Mail address -$PageOptions['DashboardVersion'] = '2.4.1'; // Dashboard Version +$PageOptions['DashboardVersion'] = '2.5.0'; // Dashboard Version $PageOptions['PageRefreshActive'] = true; // Activate automatic refresh $PageOptions['PageRefreshDelay'] = '10000'; // Page refresh time in miliseconds