This commit is contained in:
2026-07-19 18:01:05 +08:00
commit fe4b286ce1
132 changed files with 25378 additions and 0 deletions
+215
View File
@@ -0,0 +1,215 @@
<?php
/**
* D-Star reflector link status — one row per repeater module (A-D).
*
* AJAX-loaded partial; refreshed every 15 seconds by /index.php. Used
* in BOTH MMDVMHost mode (when D-Star Network is enabled) and
* dstarrepeater mode.
*
* For each `repeaterBand1`..`4` configured in /etc/ircddbgateway,
* inspects /var/log/pi-star/Links.log for the most recent link state
* line (DExtra / DPlus / DCS / CCS) targeting that module's callsign.
* Outputs columns: callsign, linked-to reflector, protocol, direction
* (Incoming / Outgoing), last-change timestamp.
*
* The log line shapes this file matches are documented inline as
* comments next to each preg_match_all — preserve those samples
* verbatim if Links.log format ever drifts.
*
* AJAX-loaded partial — embeddable variant only. Omits the
* X-Frame-Options / frame-ancestors directives that the parent
* /index.php already asserts; they apply to iframe ancestry, not
* to XHR responses, so emitting them here is just dead bytes.
*/
require_once($_SERVER['DOCUMENT_ROOT'] . '/config/security_headers.php');
setEmbeddableSecurityHeaders();
include_once $_SERVER['DOCUMENT_ROOT'].'/config/ircddblocal.php';
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
$configs = array();
if ($configfile = fopen($gatewayConfigPath,'r')) {
while ($line = fgets($configfile)) {
list($key,$value) = preg_split('/=/',$line);
$value = trim(str_replace('"','',$value));
if ($key != 'ircddbPassword' && strlen($value) > 0)
$configs[$key] = $value;
}
}
$progname = basename($_SERVER['SCRIPT_FILENAME'],".php");
$rev="20141101";
$MYCALL=strtoupper($callsign);
?>
<b><?php echo $lang['d-star_link_status'];?></b>
<table>
<tr>
<th><a class="tooltip" href="#">Radio<span><b>Radio Module</b></span></a></th>
<th><a class="tooltip" href="#">Default<span><b>Default Link Destination</b></span></a></th>
<th><a class="tooltip" href="#">Auto<span><b>AutoLink</b>- green: enabled<br />- red: disabled</span></a></th>
<th><a class="tooltip" href="#">Timer<span><b>Reset/Restart Timer</b></span></a></th>
<th><a class="tooltip" href="#">Link<span><b>Link-Status</b>- green: enabled<br />- red: disabled</span></a></th>
<th><a class="tooltip" href="#">Linked to<span><b>Linked Destination</b></span></a></th>
<th><a class="tooltip" href="#">Mode<span><b>Mode or Protocol used</b></span></a></th>
<th><a class="tooltip" href="#">Direction<span><b>Direction</b>Incoming or Outgoing</span></a></th>
<th><a class="tooltip" href="#">Last Change (<?php echo date('T')?>)<span><b>Timestamp of last change</b>Time of last change in <?php echo date('T')?> time zone</span></a></th>
</tr>
<?php
$tot = array(0=>"Never",1=>"Fixed",2=>"5min",3=>"10min",4=>"15min",5=>"20min",6=>"25min",7=>"30min",8=>"60min",9=>"90min",10=>"120min",11=>"180min",12=>"&nbsp;");
$ci = 0;
$tr = 0;
for($i = 1;$i < 5; $i++){
$param="repeaterBand" . $i;
if((isset($configs[$param])) && strlen($configs[$param]) == 1) {
$ci++;
if($ci > 1) { $ci = 0; }
print "<tr>";
$tr = 1;
$module = $configs[$param];
$rcall = sprintf("%-7.7s%-1.1s",$MYCALL,$module);
$param="repeaterCall" . $i;
if(isset($configs[$param])) { $rptrcall=sprintf("%-7.7s%-1.1s",$configs[$param],$module); } else { $rptrcall = $rcall;}
print "<td>".str_replace(' ', '&nbsp;', substr($rptrcall,0,8))."</td>";
$param="reflector" . $i;
if(isset($configs[$param])) { print "<td>".str_replace(' ', '&nbsp;', substr($configs[$param],0,8))."</td>"; } else { print "<td>&nbsp;</td>";}
$param="atStartup" . $i;
if($configs[$param] == 1){print "<td>Auto</td>"; } else { print "<td>No</td>"; }
$param="reconnect" . $i;
if(isset($configs[$param])) { $t = $configs[$param]; } else { $t = 0; }
if($t > 12){ $t = 12; }
print "<td>$tot[$t]</td>";
$j=0;
if ($linkLog = @fopen($linkLogPath,'r')) {
while ($linkLine = fgets($linkLog)) {
//$statimg = "<img src=\"images/20red.png\">";
$statimg = "Down";
$linkDate = "&nbsp;";
$protocol = "&nbsp;";
$linkType = "&nbsp;";
$linkRptr = "&nbsp;";
$linkRefl = "&nbsp;";
// Reflector-Link, sample:
// 2011-09-22 02:15:06: DExtra link - Type: Repeater Rptr: DB0LJ B Refl: XRF023 A Dir: Outgoing
// 2012-10-12 17:15:45: DCS link - Type: Repeater Rptr: DB0LJ B Refl: DCS001 L Dir: Outgoing
// 2012-10-12 17:56:10: DCS link - Type: Repeater Rptr: DB0RPL B Refl: DCS015 B Dir: Outgoing
if(preg_match_all('/^(.{19}).*(D[A-Za-z]*).*Type: ([A-Za-z]*).*Rptr: (.{8}).*Refl: (.{8}).*Dir: Outgoing$/',$linkLine,$linx) > 0){
$statimg = "Up";
$linkDate = date("d-M-Y H:i:s", strtotime(substr($linx[1][0],0,19)));
$protocol = $linx[2][0];
$linkType = $linx[3][0];
$linkRptr = $linx[4][0];
$linkRefl = $linx[5][0];
if($linkRptr == $rptrcall){
print "<td>$statimg</td>";
print "<td>".str_replace(' ', '&nbsp;', substr($linkRefl,0,8))."</td>";
print "<td>$protocol</td>";
print "<td>Outgoing</td>";
$utc_time = $linkDate;
$utc_tz = new DateTimeZone('UTC');
$local_tz = new DateTimeZone(date_default_timezone_get ());
$dt = new DateTime($utc_time, $utc_tz);
$dt->setTimeZone($local_tz);
$local_time = $dt->format('H:i:s M jS');
print "<td>$local_time</td>";
print "</tr>\n";
$tr = 0;
}
}
}
fclose($linkLog);
}
if ($tr == 1){
print"<td>Down</td><td>None</td><td>--</td><td>----</td><td>----</td></tr>\n";
}
// 00000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000111111111122
// 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901
// 2012-05-08 21:16:31: DExtra link - Type: Repeater Rptr: DB0LJ A Refl: DB0MYK B Dir: Incoming
// 2012-05-08 21:16:31: DPlus link - Type: Dongle User: W1CDG H Dir: Incoming
if ($linkLog = @fopen($linkLogPath,'r')) {
while ($linkLine = fgets($linkLog)) {
$statimg = "Down";
$linkDate = "&nbsp;";
$protocol = "&nbsp;";
$linkType = "&nbsp;";
$linkRptr = "&nbsp;";
$linkRefl = "&nbsp;";
if(preg_match_all('/^(.{19}).*(D[A-Za-z]*).*Type: ([A-Za-z]*).*Rptr: (.{8}).*Refl: (.{8}).*Dir: Incoming$/',$linkLine,$linx) > 0){
$statimg = "Up";
$linkDate = date("d-M-Y H:i:s", strtotime(substr($linx[1][0],0,19)));
$protocol = $linx[2][0];
$linkType = $linx[3][0];
$linkRptr = $linx[4][0];
$linkRefl = $linx[5][0];
if($linkRptr == $rptrcall){
$ci++;
if($ci > 1) { $ci = 0; }
print "<tr>";
print "<td>".str_replace(' ', '&nbsp;', substr($rptrcall,0,8))."</td>";
print "<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>";
print "<td>$statimg</td>";
print "<td>".str_replace(' ', '&nbsp;', substr($linkRefl,0,8))."</td>";
print "<td>$protocol</td>";
print "<td>Incoming</td>";
$utc_time = $linkDate;
$utc_tz = new DateTimeZone('UTC');
$local_tz = new DateTimeZone(date_default_timezone_get ());
$dt = new DateTime($utc_time, $utc_tz);
$dt->setTimeZone($local_tz);
$local_time = $dt->format('H:i:s M jS');
print "<td>$local_time</td>";
print "</tr>\n";
//$tr = 0;
}
}
}
fclose($linkLog);
}
// 00000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000111111111122
// 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901
// 2012-05-08 21:16:31: DExtra link - Type: Repeater Rptr: DB0LJ A Refl: DB0MYK B Dir: Incoming
// 2012-05-08 21:16:31: DPlus link - Type: Dongle User: W1CDG H Dir: Incoming
if ($linkLog = @fopen($linkLogPath,'r')) {
while ($linkLine = fgets($linkLog)) {
$statimg = "Down";
$linkDate = "&nbsp;";
$protocol = "&nbsp;";
$linkType = "&nbsp;";
$linkRptr = "&nbsp;";
$linkRefl = "&nbsp;";
if(preg_match_all('/^(.{19}).*(D[A-Za-z]*).*Type: ([A-Za-z]*).*User: (.[^\s]+).*Dir: Incoming$/',$linkLine,$linx) > 0){
$statimg = "Up";
$linkDate = date("d-M-Y H:i:s", strtotime(substr($linx[1][0],0,19)));
$protocol = $linx[2][0];
$linkType = $linx[3][0];
$linkRptr = $linx[4][0];
$ci++;
if($ci > 1) { $ci = 0; }
print "<tr>";
print "<td>".str_replace(' ', '&nbsp;', substr($rptrcall,0,8))."</td>";
print "<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>";
print "<td>$statimg</td>";
print "<td>".str_replace(' ', '&nbsp;', substr($linkRptr,0,8))."</td>";
print "<td>$protocol</td>";
print "<td>Incoming</td>";
$utc_time = $linkDate;
$utc_tz = new DateTimeZone('UTC');
$local_tz = new DateTimeZone(date_default_timezone_get ());
$dt = new DateTime($utc_time, $utc_tz);
$dt->setTimeZone($local_tz);
$local_time = $dt->format('H:i:s M jS');
print "<td>$local_time</td>";
print "</tr>\n";
}
}
fclose($linkLog);
}
// End
}
}
?>
</table>
+147
View File
@@ -0,0 +1,147 @@
<?php
/**
* StarNet groups + active members partial.
*
* Sub-partial included by css_connections.php when at least one
* `starNetCallsign1`..`5` is configured in /etc/ircddbgateway.
*
* Two tables:
* 1. Configured groups — callsign, logoff callsign, info text,
* user/group timeouts. Pulled directly from /etc/ircddbgateway.
* 2. Active members — parsed from /var/log/pi-star/STARnet.log via
* a preg_match_all that walks every "Adding/Removing <call> from
* StarNet group <group>" line. We treat the log as the
* authoritative state: an "Adding" entry inserts; a "Removing"
* entry unsets. The final $groupsx map then holds current members.
*
* No security_headers call — it's a sub-sub-partial. Flagged for the
* security pass.
*/
require_once($_SERVER['DOCUMENT_ROOT'] . '/config/security_headers.php');
setSecurityHeaders();
include_once $_SERVER['DOCUMENT_ROOT'].'/config/ircddblocal.php';
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
$configs = array();
if ($configfile = fopen($gatewayConfigPath,'r')) {
while ($line = fgets($configfile)) {
list($key,$value) = preg_split('/=/',$line);
$value = trim(str_replace('"','',$value));
if ($key != 'ircddbPassword' && strlen($value) > 0)
$configs[$key] = $value;
}
}
$progname = basename($_SERVER['SCRIPT_FILENAME'],".php");
$rev="20141101";
$MYCALL=strtoupper($callsign);
?>
<b><?php echo $lang['active_starnet_groups'];?></b>
<table style="table-layout: fixed;">
<tr>
<th><a class="tooltip" href="#"><?php echo $lang['callsign'];?><span><b>Starnet Callsign</b></span></a></th>
<th><a class="tooltip" href="#"><?php echo $lang['logoff'];?><span><b>Starnet Logoff Callsign</b></span></a></th>
<th colspan="3"><a class="tooltip" href="#"><?php echo $lang['info'];?><span><b>Infotext</b></span></a></th>
<th><a class="tooltip" href="#"><?php echo $lang['utot'];?><span><b>User TimeOut (min)</b>inactivity time after which a user will be disconnected</span></a></th>
<th><a class="tooltip" href="#"><?php echo $lang['gtot'];?><span><b>Group TimeOut (min)</b>inactivity time after which the group will be disconnected</span></a></th>
</tr>
<?php
$ci = 0;
$i = 0;
$stngrp = array();
for($i = 1;$i < 6; $i++){
$param="starNetCallsign" . $i;
if(isset($configs[$param])) {
$gname = $configs[$param];
$stngrp[$gname] = $i;
$ci++;
if($ci > 1) { $ci = 0; }
print "<tr>";
print "<td align=\"center\">".str_replace(' ', '&nbsp;', substr($gname,0,8))."</td>";
$param="starNetLogoff" . $i;
if(isset($configs[$param])){ $output = str_replace(' ', '&nbsp;', substr($configs[$param],0,8)); print "<td align=\"center\">$output</td>";} else { print"<td>&nbsp;</td>";}
$param="starNetInfo" . $i;
if(isset($configs[$param])){ print "<td colspan=\"3\" align=\"left\">$configs[$param]</td>";} else { print"<td colspan=\"3\">&nbsp;</td>";}
$param="starNetUserTimeout" . $i;
if(isset($configs[$param])){ print "<td align=\"center\">$configs[$param]</td>";} else { print"<td>&nbsp;</td>";}
$param="starNetGroupTimeout" . $i;
if(isset($configs[$param])){ print "<td align=\"center\">$configs[$param]</td>";} else { print"<td>&nbsp;</td>";}
print "</tr>\n";
}
}
?>
</table><br />
<?php
$groupsx = array();
if ($starLog = fopen($starLogPath,'r')) {
while($logLine = fgets($starLog)) {
preg_match_all('/^(.{19}).*(Adding|Removing) (.{8}).*StarNet group (.{8}).*$/',$logLine,$matches);
$groupz = substr($matches[4][0],0,8);
$member = substr($matches[3][0],0,8);
$action = substr($matches[2][0],0,8);
$date = $matches[1][0];
$guid = $stngrp[$groupz];
if ($action == 'Adding'){
$groupsx[$guid][$groupz][$member] = $date;
}
elseif ($action == 'Removing'){
unset($groupsx[$guid][$groupz][$member]);
}
}
fclose($starLog);
}
//Clean the empty arrays from the multidimensional array
$groupsx = array_map('array_filter', $groupsx);
$active = 0;
for ($i = 1;$i < 6; $i++) {
if (isset($groupsx[$i])) {
$active = $active + count($groupsx[$i]);
}
}
if ($active >= 1) {
echo "<b>".$lang['active_starnet_members']."</b>\n";
echo "<table style=\"table-layout: fixed;\">\n";
echo "<tr>\n";
echo "<th><a class=tooltip href=\"#\">".$lang['time']." (".date('T').")<span><b>Time of Login</b></span></a></th>\n";
echo "<th><a class=tooltip href=\"#\">".$lang['group']."<span><b>Starnet Callsign</b></span></a></th>\n";
echo "<th><a class=tooltip href=\"#\">".$lang['callsign']."<span><b>Callsign</b></span></a></th>\n";
echo "</tr>\n";
$ci = 0;
$ulist = array();
$glist = array();
for($i = 1;$i < 6; $i++){
if(isset($groupsx[$i])){
$glist = $groupsx[$i];
foreach ($glist as $gcall => $ulist){
foreach ($ulist as $ucall => $ulogin){
$ci++;
if($ci > 1) { $ci = 0; }
$ulogin = date("d-M-Y H:i:s", strtotime(substr($ulogin,0,19)));
$utc_time = $ulogin;
$utc_tz = new DateTimeZone('UTC');
$local_tz = new DateTimeZone(date_default_timezone_get ());
$dt = new DateTime($utc_time, $utc_tz);
$dt->setTimeZone($local_tz);
$local_time = $dt->format('H:i:s M jS');
$groupz = str_replace(' ', '&nbsp;', substr($gcall,0,8));
$ucall = str_replace(' ', '', substr($ucall,0,8));
print "<tr>";
print "<td align=\"left\">$local_time</td>";
print "<td align=\"center\">$groupz</td>";
print "<td align=\"center\"><a href=\"http://www.qrz.com/db/$ucall\" target=\"_new\" alt=\"Lookup Callsign\">$ucall</a></td>";
print "</tr>\n";
}
}
}
}
echo "</table>\n<br />\n";
}
+95
View File
@@ -0,0 +1,95 @@
<?php
/**
* CCS (Connected Community System) connections + StarNet groups partial.
*
* AJAX-loaded partial; refreshed every 15 seconds by /index.php. Two
* sections rendered conditionally:
* 1. Active CCS Connections — read from /var/log/pi-star/Links.log,
* surfaced only if the log contains at least one "CCS link" line.
* 2. StarNet groups — included via active_starnet_groups.php only when
* `starNetCallsign1`..`5` are configured in /etc/ircddbgateway.
*
* AJAX-loaded partial — embeddable variant only. Omits the
* X-Frame-Options / frame-ancestors directives the parent already
* asserts; they apply to iframe ancestry, not XHR responses.
*/
require_once($_SERVER['DOCUMENT_ROOT'] . '/config/security_headers.php');
setEmbeddableSecurityHeaders();
include_once $_SERVER['DOCUMENT_ROOT'].'/config/ircddblocal.php';
$configs = array();
if ($configfile = fopen($gatewayConfigPath,'r')) {
while ($line = fgets($configfile)) {
list($key,$value) = preg_split('/=/',$line);
$value = trim(str_replace('"','',$value));
if ($key != 'ircddbPassword' && strlen($value) > 0)
$configs[$key] = $value;
}
}
$progname = basename($_SERVER['SCRIPT_FILENAME'],".php");
$rev="20141101";
$MYCALL=strtoupper($callsign);
?>
<?php
if (exec('grep "CCS link" '.$linkLogPath.' | wc -l') >=1) {
?>
<b>Active CCS Connections</b>
<table>
<tr>
<th><a class=tooltip href="#">Repeater<span><b>Callsign of connected repeater</b></span></a></th>
<th><a class=tooltip href="#">Linked to<span><b>Actual link status</b></span></a></th>
<th><a class=tooltip href="#">Protocol<span><b>Protocol</b></span></a></th>
<th><a class=tooltip href="#">Direction<span><b>Direction</b>incoming or outgoing</span></a></th>
<th><a class=tooltip href="#">Last Change (<?php echo date('T')?>)<span><b>Timestamp of last change</b><?php echo date('T')?></span></a></th>
</tr>
<?php
$ci = 0;
if ($linkLog = fopen($linkLogPath,'r')) {
$i=0;
while ($linkLine = fgets($linkLog)) {
// 2013-02-27 19:49:27: CCS link - Rptr: DB0LJ B Remote: DL5DI Dir: Incoming
if(preg_match_all('/^(.{19}).*(C[A-Za-z]*).*Rptr: (.{8}).*Remote: (.{8}).*Dir: (.{8})$/',$linkLine,$linx) > 0){
$utc_time = $linx[1][0];
$utc_tz = new DateTimeZone('UTC');
$local_tz = new DateTimeZone(date_default_timezone_get ());
$dt = new DateTime($utc_time, $utc_tz);
$dt->setTimeZone($local_tz);
$local_time = $dt->format('H:i:s M jS');
$linkDate = $local_time;
$linkType = $linx[2][0];
$linkRptr = $linx[3][0];
$linkRem = $linx[4][0];
$linkDir = $linx[5][0];
$ci++;
if($ci > 1) { $ci = 0; }
print "<tr>";
print "<td>$linkRptr</td>";
print "<td>$linkRem</td>";
print "<td>CCS</td>";
print "<td>$linkDir</td>";
print "<td>$linkDate</td>";
print "</tr>\n";
}
}
fclose($linkLog);
}
print "</table>\n<br />\n";
}
$stn_is_set = 0;
for($i = 1;$i < 6; $i++){
$param="starNetCallsign" . $i;
if(isset($configs[$param])) {
$stn_is_set = 1;
break;
}
}
if($stn_is_set > 0){
include_once $_SERVER['DOCUMENT_ROOT'].'/dstarrepeater/active_starnet_groups.php';
}
+18
View File
@@ -0,0 +1,18 @@
<table>
<tr><th>ircDDB Network</th><th>APRS Host</th><th>CCS</th><th>DCS</th><th>DExtra</th><th>DPlus</th><th>D-Rats</th><th>Info</th><th>ircDDB</th><th>Echo</th><th>Log</th></tr>
<tr style="background: #ffffff;">
<td><?php print $configs['ircddbHostname']; ?></td>
<td><?php if($configs['aprsEnabled'] == 1){ print $configs['aprsHostname']; } else { print "<img src=\"images/20red.png\">";} ?></td>
<?php
if($configs['ccsEnabled'] == 1){print "<td style=\"background-color:#1d1;\">ON</td>"; } else { print "<td style=\"background:#606060; color:#b0b0b0;\">OFF</td>"; }
if($configs['dcsEnabled'] == 1){print "<td style=\"background-color:#1d1;\">ON</td>"; } else { print "<td style=\"background:#606060; color:#b0b0b0;\">OFF</td>"; }
if($configs['dextraEnabled'] == 1){print "<td style=\"background-color:#1d1;\">ON</td>"; } else { print "<td style=\"background:#606060; color:#b0b0b0;\">OFF</td>"; }
if($configs['dplusEnabled'] == 1){print "<td style=\"background-color:#1d1;\">ON</td>"; } else { print "<td style=\"background:#606060; color:#b0b0b0;\">OFF</td>"; }
if($configs['dratsEnabled'] == 1){print "<td style=\"background-color:#1d1;\">ON</td>"; } else { print "<td style=\"background:#606060; color:#b0b0b0;\">OFF</td>"; }
if($configs['infoEnabled'] == 1){print "<td style=\"background-color:#1d1;\">ON</td>"; } else { print "<td style=\"background:#606060; color:#b0b0b0;\">OFF</td>"; }
if($configs['ircddbEnabled'] == 1){print "<td style=\"background-color:#1d1;\">ON</td>"; } else { print "<td style=\"background:#606060; color:#b0b0b0;\">OFF</td>"; }
if($configs['echoEnabled'] == 1){print "<td style=\"background-color:#1d1;\">ON</td>"; } else { print "<td style=\"background:#606060; color:#b0b0b0;\">OFF</td>"; }
if($configs['logEnabled'] == 1){print "<td style=\"background-color:#1d1;\">ON</td>"; } else { print "<td style=\"background:#606060; color:#b0b0b0;\">OFF</td>"; }
?>
</tr>
</table>
View File
+138
View File
@@ -0,0 +1,138 @@
<?php
/**
* Last-heard list (D-Star repeater mode) — last 20 D-Star transmissions.
*
* AJAX-loaded partial; refreshed every ~3 seconds by /index.php in
* dstarrepeater mode. Renders a 5-column table: time, callsign, target,
* Rpt 1, Rpt 2. Each callsign links to the operator's chosen lookup
* service (RadioID or QRZ, sourced from /etc/pistar-css.ini's
* [Lookup] Service key) and to aprs.fi for dPRS data.
*
* Data flow: shells out to a `grep|sort|head` pipeline against
* `/var/log/pi-star/Headers.log` to build /tmp/lastheard.log, then
* regex-parses each line. The "Headers.log sample" comment block
* below documents the exact line shape the regex targets — preserve
* those examples verbatim if log format ever drifts.
*/
require_once($_SERVER['DOCUMENT_ROOT'] . '/config/security_headers.php');
// AJAX-loaded partial — embeddable variant only. See the note in
// mmdvmhost/lh.php for why the historical double-call was wrong.
setEmbeddableSecurityHeaders();
include_once $_SERVER['DOCUMENT_ROOT'].'/config/ircddblocal.php';
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
$configs = array();
if ($configfile = fopen($gatewayConfigPath,'r')) {
while ($line = fgets($configfile)) {
list($key,$value) = preg_split('/=/',$line);
$value = trim(str_replace('"','',$value));
if ($key != 'ircddbPassword' && strlen($value) > 0)
$configs[$key] = $value;
}
}
$progname = basename($_SERVER['SCRIPT_FILENAME'],".php");
$rev="20141101";
$MYCALL=strtoupper($callsign);
// Check if the config file exists
if (file_exists('/etc/pistar-css.ini')) {
// Use the values from the file
$piStarCssFile = '/etc/pistar-css.ini';
if (fopen($piStarCssFile,'r')) { $piStarCss = parse_ini_file($piStarCssFile, true); }
// Set the Values from the config file
if (isset($piStarCss['Lookup']['Service'])) { $callsignLookupSvc = $piStarCss['Lookup']['Service']; } // Lookup Service "QRZ" or "RadioID"
else { $callsignLookupSvc = "RadioID"; } // Set the default if its missing // Set the default if its missing
} else {
// Default values
$callsignLookupSvc = "RadioID";
}
// Safety net
if (($callsignLookupSvc != "RadioID") && ($callsignLookupSvc != "QRZ")) { $callsignLookupSvc = "RadioID"; }
// Setup the URL(s)
if ($callsignLookupSvc == "RadioID") { $callsignLookupUrl = "https://database.radioid.net/database/view?callsign="; }
if ($callsignLookupSvc == "QRZ") { $callsignLookupUrl = "https://www.qrz.com/db/"; }
?>
<b><?php echo $lang['last_heard_list'];?></b>
<table>
<tr>
<th><a class="tooltip" href="#"><?php echo $lang['time'];?> (<?php echo date('T')?>)</a></th>
<th><a class="tooltip" href="#"><?php echo $lang['callsign'];?></a></th>
<th><a class="tooltip" href="#"><?php echo $lang['target'];?></a></th>
<th><a class="tooltip" href="#">RPT 1</a></th>
<th><a class="tooltip" href="#">RPT 2</a></th>
</tr>
<?php
// Headers.log sample:
// 0000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000111111111122
// 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901
// 2012-06-05 12:18:41: DCS header - My: PU2ZHZ /T Your: CQCQCQ Rpt1: PU2ZHZ B Rpt2: DCS007 B Flags: 00 00 00
// 2012-05-29 21:33:56: DPlus header - My: PD1RB /IC92 Your: CQCQCQ Rpt1: PE1RJV B Rpt2: REF017 A Flags: 00 00 00
// 2013-02-09 13:49:57: DExtra header - My: DO7MT / Your: CQCQCQ Rpt1: XRF001 G Rpt2: XRF001 C Flags: 00 00 00
//
exec('(grep -v " /TIME" '.$hdrLogPath.'|sort -r -k7,7|sort -u -k7,8|sort -r|head -20 >/tmp/lastheard.log) 2>&1 &');
$ci = 0;
if ($LastHeardLog = fopen("/tmp/lastheard.log",'r')) {
while ($linkLine = fgets($LastHeardLog)) {
if(preg_match_all('/^(.{19}).*My: (.*).*Your: (.*).*Rpt1: (.*).*Rpt2: (.*).*Flags: (.*)$/',$linkLine,$linx) > 0){
$ci++;
if($ci > 1) { $ci = 0; }
$QSODate = date("d-M-Y H:i:s", strtotime(substr($linx[1][0],0,19)));
// Every value below is parsed out of /var/log/pi-star/Headers.log
// — log lines produced by RF traffic, where the
// transmitting station sets the callsign field. Without
// escaping, a hostile callsign lands in the dashboard's
// ~3 second AJAX refresh. Normalise once here so each
// echo below works on safe values.
//
// $myCallRaw — raw 8-char callsign window
// $myCallHtml — HTML-safe display form
// $myCallLink — first whitespace-delimited token (the
// callsign without the space-padded
// suffix) — used for href URLs
// $myCallLinkHtml / $myCallLinkUrl — the URL forms
// $myIdHtml — 4-char ID after the `/` (HTML-safe)
// $yourCallHtml / $rpt1Html / $rpt2Html — target +
// repeaters with `&nbsp;` substitution applied AFTER
// escaping so the literal entity isn't double-encoded.
$myCallRaw = str_replace(' ', '', substr($linx[2][0],0,8));
$myCallHtml = htmlspecialchars($myCallRaw, ENT_QUOTES, 'UTF-8');
$myCallLink = strtok(substr($linx[2][0],0,8), " ");
$myCallLinkUrl = rawurlencode((string)$myCallLink);
$myIdHtml = htmlspecialchars(str_replace(' ', '', substr($linx[2][0],9,4)), ENT_QUOTES, 'UTF-8');
$yourCallHtml = str_replace(' ', '&nbsp;',
htmlspecialchars(substr($linx[3][0],0,8), ENT_QUOTES, 'UTF-8'));
$rpt1Html = str_replace(' ', '&nbsp;',
htmlspecialchars(substr($linx[4][0],0,8), ENT_QUOTES, 'UTF-8'));
$rpt2Html = str_replace(' ', '&nbsp;',
htmlspecialchars(substr($linx[5][0],0,8), ENT_QUOTES, 'UTF-8'));
$utc_time = $QSODate;
$utc_tz = new DateTimeZone('UTC');
$local_tz = new DateTimeZone(date_default_timezone_get ());
$dt = new DateTime($utc_time, $utc_tz);
$dt->setTimeZone($local_tz);
$local_time = $dt->format('H:i:s M jS');
print "<tr>";
print "<td align=\"left\">$local_time</td>";
print "<td align=\"left\" width=\"180\"><div style=\"float:left;\"><a href=\"".$callsignLookupUrl.$myCallLinkUrl."\" target=\"_blank\">$myCallHtml</a>";
if($myIdHtml !== '') { print "/$myIdHtml</div> <div style=\"text-align:right;\">&#40;<a href=\"https://aprs.fi/#!call=".$myCallLinkUrl."*\" target=\"_blank\">dPRS</a>&#41;</div></td>"; }
else { print "</div> <div style=\"text-align:right;\">&#40;<a href=\"https://aprs.fi/#!call=".$myCallLinkUrl."*\" target=\"_blank\">dPRS</a>&#41;</div></td>"; }
print "<td align=\"left\" width=\"100\">$yourCallHtml</td>";
print "<td align=\"left\" width=\"100\">$rpt1Html</td>";
print "<td align=\"left\" width=\"100\">$rpt2Html</td>";
print "</tr>\n";
}
}
fclose($LastHeardLog);
}
?>
</table>
+233
View File
@@ -0,0 +1,233 @@
<?php
/**
* D-Star reflector link manager — admin-only POST handler + form.
*
* Loaded inline by /index.php only on the admin path
* (`$_SERVER["PHP_SELF"] == "/admin/index.php"` gate at the top).
* Two responsibilities:
*
* 1. POST handler. Accepts form fields:
* - Link ("LINK" or "UNLINK")
* - RefName (7-char reflector name, e.g. REF001 / DCS007)
* - Letter (single-letter reflector module, A-Z)
* - Module (8-char repeater callsign+band, e.g. "MW0MWZ B")
* Each is validated by a preg_match whitelist (unsetting on bad
* input) before being interpolated into a `sudo remotecontrold ...`
* shell command. Refer to the security pass for hardening — the
* validation is the only barrier to command injection.
*
* 2. Form rendering. Drop-downs for Module (from repeaterBand1..4),
* RefName (DCS_Hosts.txt + DPlus_Hosts.txt + DExtra_Hosts.txt),
* Letter (A-Z), and a LINK / UNLINK radio pair. Uses the
* alternative `if (...): ... else: ?> ...HTML... <?php endif; ?>`
* template syntax — preserve the colons.
*
* Also surfaces a "PiStar-Keeper Logbook" panel below the form when
* /usr/local/sbin/pistar-keeper is running (last 5 entries from
* /var/pistar-keeper/pistar-keeper.log + a download link).
*/
require_once($_SERVER['DOCUMENT_ROOT'] . '/config/security_headers.php');
setSecurityHeaders();
if ($_SERVER["PHP_SELF"] == "/admin/index.php") {
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
if (!empty($_POST) && isset($_POST["dstrMgrSubmit"])):
//if (!empty($_POST)):
if (preg_match('/[^A-Z]/',$_POST["Link"])) { unset ($_POST["Link"]);}
if ($_POST["Link"] == "LINK") {
if (preg_match('/[^A-Za-z0-9 ]/',$_POST["RefName"])) { unset ($_POST["RefName"]);}
if (preg_match('/[^A-Z]/',$_POST["Letter"])) { unset ($_POST["Letter"]);}
if (preg_match('/[^A-Z0-9 ]/',$_POST["Module"])) { unset ($_POST["Module"]);}
}
if ($_POST["Link"] == "UNLINK") {
if (preg_match('/[^A-Z0-9 ]/',$_POST["Module"])) { unset ($_POST["Module"]);}
}
if (empty($_POST["RefName"]) || empty($_POST["Letter"]) || empty($_POST["Module"])) { echo "Somthing wrong with your input, try again";}
else {
if (strlen($_POST["RefName"]) != 7) {
$targetRef = str_pad($_POST["RefName"], 7, " ");
} else {
$targetRef = $_POST["RefName"];
}
$targetRef = $targetRef.$_POST["Letter"];
$targetRef = strtoupper($targetRef);
$module = $_POST["Module"];
if (strlen($module) != 8) { //Fix the length of the module information
$moduleFixedCs = strlen($module) - 1; //Length of the string, -1
$moduleFixedBand = substr($module, -1); //Single Band Letter in the 8th position
$moduleFixedCallPad = str_pad(substr($module, 0, $moduleFixedCs), 7); //Pad the callsign area to 7 chars
$module = $moduleFixedCallPad.$moduleFixedBand; //Re add the band information
};
$unlinkCommand = "sudo remotecontrold \"".$module."\" unlink";
$linkCommand = "sudo remotecontrold \"".$module."\" link never \"".$targetRef."\"";
if ($module != $targetRef && $_POST["Link"] == "LINK") { // Sanity check that we are not connecting to ourself
echo "<b>D-Star Link Manager</b>\n";
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
echo htmlspecialchars((string)exec($linkCommand), ENT_QUOTES, 'UTF-8');
echo "</td></tr>\n</table>\n";
}
if ($module == $targetRef && $_POST["Link"] == "LINK") { // Sanity Check Failed
echo "<b>D-Star Link Manager</b>\n";
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
echo "Cannot link to myself - Aborting link request!";
echo "</td></tr>\n</table>\n";
}
if ($_POST["Link"] == "UNLINK") { // Allow Unlink no matter what
echo "<b>D-Star Link Manager</b>\n";
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
echo htmlspecialchars((string)exec($unlinkCommand), ENT_QUOTES, 'UTF-8');
echo "</td></tr>\n</table>\n";
}
}
unset($_POST);
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
else: ?>
<b><?php echo $lang['d-star_link_manager'];?></b>
<form action="//<?php echo htmlentities($_SERVER['HTTP_HOST']).htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
<?php csrf_field(); ?>
<table>
<tr>
<th width="150"><a class="tooltip" href="#">Radio Module<span><b>Radio Module</b></span></a></th>
<th width="180"><a class="tooltip" href="#">Reflector<span><b>Reflector</b></span></a></th>
<th width="150"><a class="tooltip" href="#">Link / Un-Link<span><b>Link / Un-Link</b></span></a></th>
<th><a class="tooltip" href="#">Action<span><b>Action</b></span></a></th>
</tr>
<tr>
<td>
<select name="Module">
<?php
$ci = 0;
for($i = 1;$i < 5; $i++){
$param="repeaterBand" . $i;
if((isset($configs[$param])) && strlen($configs[$param]) == 1) {
$ci++;
if($ci > 1) { $ci = 0; }
$module = $configs[$param];
$rcall = sprintf("%-7.7s%-1.1s",$MYCALL,$module);
$param="repeaterCall" . $i;
if(isset($configs[$param])) { $rptrcall=sprintf("%-7.7s%-1.1s",$configs[$param],$module); } else { $rptrcall = $rcall;}
print "<option>$rptrcall</option>\n";
}
} ?>
</select>
</td>
<td>
<select name="RefName"
onchange="if (this.options[this.selectedIndex].value == 'customOption') {
toggleField(this,this.nextSibling);
this.selectedIndex='0';
} ">
<?php
$dcsFile = fopen("/usr/local/etc/DCS_Hosts.txt", "r");
$dplusFile = fopen("/usr/local/etc/DPlus_Hosts.txt", "r");
$dextraFile = fopen("/usr/local/etc/DExtra_Hosts.txt", "r");
echo " <option value=\"".substr($configs['reflector1'], 0, 6)."\" selected=\"selected\">".substr($configs['reflector1'], 0, 6)."</option>\n";
echo " <option value=\"customOption\">Text Entry</option>\n";
while (!feof($dcsFile)) {
$dcsLine = fgets($dcsFile);
if (strpos($dcsLine, 'DCS') !== FALSE && strpos($dcsLine, '#') === FALSE) {
echo " <option value=\"".substr($dcsLine, 0, 6)."\">".substr($dcsLine, 0, 6)."</option>\n";
}
if (strpos($dcsLine, 'XLX') !== FALSE && strpos($dcsLine, '#') === FALSE) {
echo " <option value=\"".substr($dcsLine, 0, 6)."\">".substr($dcsLine, 0, 6)."</option>\n";
}
}
fclose($dcsFile);
while (!feof($dplusFile)) {
$dplusLine = fgets($dplusFile);
if (strpos($dplusLine, 'REF') !== FALSE && strpos($dplusLine, '#') === FALSE) {
echo " <option value=\"".substr($dplusLine, 0, 6)."\">".substr($dplusLine, 0, 6)."</option>\n";
}
if (strpos($dplusLine, 'XRF') !== FALSE && strpos($dplusLine, '#') === FALSE) {
echo " <option value=\"".substr($dplusLine, 0, 6)."\">".substr($dplusLine, 0, 6)."</option>\n";
}
}
fclose($dplusFile);
while (!feof($dextraFile)) {
$dextraLine = fgets($dextraFile);
if (strpos($dextraLine, 'XRF') !== FALSE && strpos($dextraLine, '#') === FALSE)
echo " <option value=\"".substr($dextraLine, 0, 6)."\">".substr($dextraLine, 0, 6)."</option>\n";
}
fclose($dextraFile);
?>
</select><input name="RefName" style="display:none;" disabled="disabled" type="text" size="7" maxlength="7"
onblur="if(this.value==''){toggleField(this,this.previousSibling);}" />
<select name="Letter">
<?php echo " <option value=\"".substr($configs['reflector1'], 7)."\" selected=\"selected\">".substr($configs['reflector1'], 7)."</option>\n"; ?>
<option>A</option>
<option>B</option>
<option>C</option>
<option>D</option>
<option>E</option>
<option>F</option>
<option>G</option>
<option>H</option>
<option>I</option>
<option>J</option>
<option>K</option>
<option>L</option>
<option>M</option>
<option>N</option>
<option>O</option>
<option>P</option>
<option>Q</option>
<option>R</option>
<option>S</option>
<option>T</option>
<option>U</option>
<option>V</option>
<option>W</option>
<option>X</option>
<option>Y</option>
<option>Z</option>
</select>
</td>
<td>
<input type="radio" name="Link" value="LINK" checked="checked" />Link
<input type="radio" name="Link" value="UNLINK" />UnLink
</td>
<td>
<input type="submit" name="dstrMgrSubmit" value="Request Change" />
</td>
</tr>
</table>
</form>
<?php endif; ?>
<?php
exec ("pgrep pistar-keeper", $pids);
if (!empty($pids))
{
echo "<br />\n";
echo "<b>PiStar-Keeper Logbook</b><input type=button onClick=\"location.href='/admin/pistar-keeper-download.php'\" value=\"Download Logbook\">\n";
echo "<table>\n";
echo " <tr>\n";
echo " <th><a class=\"tooltip\" href=\"#\">PiStar-Keeper Log Entries (UTC)<span><b>PiStar-Keeper Log Entries (UTC)</b></span></th>\n";
echo " </tr>\n";
exec ("tail -n 5 /var/pistar-keeper/pistar-keeper.log", $lines);
$counter = 0;
foreach ($lines as $line) {
echo "<tr><td align=\"left\">".$lines[$counter]."</td></tr>\n";
$counter++;
}
echo "</table>\n";
}
}
+123
View File
@@ -0,0 +1,123 @@
<?php
/**
* Local TX list (D-Star repeater mode) — recent local transmissions
* the connected D-Star repeater has worked.
*
* AJAX-loaded partial; refreshed every ~3 seconds by /index.php in
* dstarrepeater mode. Same layout as last_herd.php (time / callsign /
* target / Rpt1 / Rpt2) but filters Headers.log by "Repeater header"
* lines so it only surfaces RF traffic, not network-side activity.
*
* Data flow: shells out to grep|sort against /var/log/pi-star/Headers.log
* to build /tmp/worked.log, then regex-parses each line. Callsign links
* use the operator's chosen lookup service (RadioID or QRZ from
* /etc/pistar-css.ini's [Lookup] Service key) plus aprs.fi for dPRS.
*
* The "Headers.log sample" comment block below documents the exact line
* shape the regex targets — preserve those examples verbatim.
*/
require_once($_SERVER['DOCUMENT_ROOT'] . '/config/security_headers.php');
// AJAX-loaded partial — embeddable variant only. See the note in
// mmdvmhost/lh.php for why the historical double-call was wrong.
setEmbeddableSecurityHeaders();
include_once $_SERVER['DOCUMENT_ROOT'].'/config/ircddblocal.php';
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
$configs = array();
if ($configfile = fopen($gatewayConfigPath,'r')) {
while ($line = fgets($configfile)) {
list($key,$value) = preg_split('/=/',$line);
$value = trim(str_replace('"','',$value));
if ($key != 'ircddbPassword' && strlen($value) > 0)
$configs[$key] = $value;
}
}
$progname = basename($_SERVER['SCRIPT_FILENAME'],".php");
$rev="20141101";
$MYCALL=strtoupper($callsign);
// Check if the config file exists
if (file_exists('/etc/pistar-css.ini')) {
// Use the values from the file
$piStarCssFile = '/etc/pistar-css.ini';
if (fopen($piStarCssFile,'r')) { $piStarCss = parse_ini_file($piStarCssFile, true); }
// Set the Values from the config file
if (isset($piStarCss['Lookup']['Service'])) { $callsignLookupSvc = $piStarCss['Lookup']['Service']; } // Lookup Service "QRZ" or "RadioID"
else { $callsignLookupSvc = "RadioID"; } // Set the default if its missing // Set the default if its missing
} else {
// Default values
$callsignLookupSvc = "RadioID";
}
// Safety net
if (($callsignLookupSvc != "RadioID") && ($callsignLookupSvc != "QRZ")) { $callsignLookupSvc = "RadioID"; }
// Setup the URL(s)
if ($callsignLookupSvc == "RadioID") { $callsignLookupUrl = "https://database.radioid.net/database/view?callsign="; }
if ($callsignLookupSvc == "QRZ") { $callsignLookupUrl = "https://www.qrz.com/db/"; }
?>
<b><?php echo $lang['local_tx_list'];?></b>
<table>
<tr>
<th><a class="tooltip" href="#"><?php echo $lang['time'];?> (<?php echo date('T')?>)</a></th>
<th><a class="tooltip" href="#"><?php echo $lang['callsign'];?></a></th>
<th><a class="tooltip" href="#"><?php echo $lang['target'];?></a></th>
<th><a class="tooltip" href="#">RPT 1</a></th>
<th><a class="tooltip" href="#">RPT 2</a></th>
</tr>
<?php
// Headers.log sample:
// 0000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000111111111122
// 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901
// 2012-05-29 20:31:53: Repeater header - My: PE1AGO /HANS Your: CQCQCQ Rpt1: PI1DEC B Rpt2: PI1DEC G Flags: 00 00 00
//
exec('(grep "Repeater header" '.$hdrLogPath.'|sort -r -k7,7|sort -u -k7,8|sort -r >/tmp/worked.log) 2>&1 &');
$ci = 0;
if ($WorkedLog = fopen("/tmp/worked.log",'r')) {
while ($linkLine = fgets($WorkedLog)) {
if(preg_match_all('/^(.{19}).*My: (.*).*Your: (.*).*Rpt1: (.*).*Rpt2: (.*).*Flags: (.*)$/',$linkLine,$linx) > 0){
$ci++;
if($ci > 1) { $ci = 0; }
$QSODate = date("d-M-Y H:i:s", strtotime(substr($linx[1][0],0,19)));
// Same normalisation pattern as dstarrepeater/last_herd.php —
// see the note in that file for the rationale.
$myCallRaw = str_replace(' ', '', substr($linx[2][0],0,8));
$myCallHtml = htmlspecialchars($myCallRaw, ENT_QUOTES, 'UTF-8');
$myCallLink = strtok(substr($linx[2][0],0,8), " ");
$myCallLinkUrl = rawurlencode((string)$myCallLink);
$myIdHtml = htmlspecialchars(str_replace(' ', '', substr($linx[2][0],9,4)), ENT_QUOTES, 'UTF-8');
$yourCallHtml = str_replace(' ', '&nbsp;',
htmlspecialchars(substr($linx[3][0],0,8), ENT_QUOTES, 'UTF-8'));
$rpt1Html = str_replace(' ', '&nbsp;',
htmlspecialchars(substr($linx[4][0],0,8), ENT_QUOTES, 'UTF-8'));
$rpt2Html = str_replace(' ', '&nbsp;',
htmlspecialchars(substr($linx[5][0],0,8), ENT_QUOTES, 'UTF-8'));
$utc_time = $QSODate;
$utc_tz = new DateTimeZone('UTC');
$local_tz = new DateTimeZone(date_default_timezone_get ());
$dt = new DateTime($utc_time, $utc_tz);
$dt->setTimeZone($local_tz);
$local_time = $dt->format('H:i:s M jS');
print "<tr>";
print "<td align=\"left\">$local_time</td>";
print "<td align=\"left\" width=\"180\"><div style=\"float:left;\"><a href=\"".$callsignLookupUrl.$myCallLinkUrl."\" target=\"_blank\">$myCallHtml</a>";
if($myIdHtml !== '') { print "/$myIdHtml</div> <div style=\"text-align:right;\">&#40;<a href=\"https://aprs.fi/#!call=".$myCallLinkUrl."*\" target=\"_blank\">dPRS</a>&#41;</div></td>"; }
else { print "</div> <div style=\"text-align:right;\">&#40;<a href=\"https://aprs.fi/#!call=".$myCallLinkUrl."*\" target=\"_blank\">dPRS</a>&#41;</div></td>"; }
print "<td align=\"left\" width=\"100\">$yourCallHtml</td>";
print "<td align=\"left\" width=\"100\">$rpt1Html</td>";
print "<td align=\"left\" width=\"100\">$rpt2Html</td>";
print "</tr>\n";
}
}
fclose($WorkedLog);
}
?>
</table>
+81
View File
@@ -0,0 +1,81 @@
<?php
/**
* System info partial — hostname, kernel, platform, CPU load/temp, service
* status grid (MMDVMHost / DStarRepeater / ircDDBGateway / TimeServer /
* PiStar-Watchdog / PiStar-Remote).
*
* Loaded inline by /index.php on the admin path and AJAX-refreshed every
* 15 seconds via $("#sysInfo").load(...). Used in BOTH MMDVMHost and
* DStarRepeater modes (same partial, gated by /index.php).
*
* Served two ways from /index.php: an inline `include` for the initial
* page render, then AJAX `$("#sysInfo").load(...)` for refreshes. On
* the inline path the parent has already emitted full security headers
* (and the headers_sent() guard inside makes our call idempotent); on
* the AJAX path the response is XHR — X-Frame-Options / frame-ancestors
* apply to iframe ancestry, not XHR, so the embeddable variant is the
* correct choice in both directions.
*
* Reads /etc/ircddbgateway (flat key=value via the hand-rolled parser)
* to surface the gateway callsign in the hardware-info table.
*/
require_once($_SERVER['DOCUMENT_ROOT'] . '/config/security_headers.php');
setEmbeddableSecurityHeaders();
include_once $_SERVER['DOCUMENT_ROOT'].'/config/ircddblocal.php';
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
include_once $_SERVER['DOCUMENT_ROOT'].'/mmdvmhost/tools.php';
$configs = array();
if ($configfile = fopen($gatewayConfigPath,'r')) {
while ($line = fgets($configfile)) {
list($key,$value) = preg_split('/=/',$line);
$value = trim(str_replace('"','',$value));
if ($key != 'ircddbPassword' && strlen($value) > 0)
$configs[$key] = $value;
}
}
$progname = basename($_SERVER['SCRIPT_FILENAME'],".php");
$rev="20141101";
$MYCALL=strtoupper($callsign);
?>
<?php
$cpuLoad = sys_getloadavg();
$cpuTempCRaw = exec('cat /sys/class/thermal/thermal_zone0/temp');
if ($cpuTempCRaw > 1000) { $cpuTempC = round($cpuTempCRaw / 1000, 1); } else { $cpuTempC = round($cpuTempCRaw, 1); }
$cpuTempF = round(+$cpuTempC * 9 / 5 + 32, 1);
if ($cpuTempC < 50) { $cpuTempHTML = "<td style=\"background: #1d1\">".$cpuTempC."&deg;C / ".$cpuTempF."&deg;F</td>\n"; }
if ($cpuTempC >= 50) { $cpuTempHTML = "<td style=\"background: #fa0\">".$cpuTempC."&deg;C / ".$cpuTempF."&deg;F</td>\n"; }
if ($cpuTempC >= 69) { $cpuTempHTML = "<td style=\"background: #f00\">".$cpuTempC."&deg;C / ".$cpuTempF."&deg;F</td>\n"; }
?>
<b><?php echo $lang['hardware_info'];?></b>
<table style="table-layout: fixed;">
<tr>
<th><a class="tooltip" href="#"><?php echo $lang['hostname'];?><br /><span><b>System IP Address:<br /><?php echo str_replace(',', ',<br />', exec('hostname -I'));?></b></span></a></th>
<th><a class="tooltip" href="#"><?php echo $lang['kernel'];?><span><b>Release</b></span></a></th>
<th colspan="2"><a class="tooltip" href="#"><?php echo $lang['platform'];?><span><b>Uptime:<br /><?php echo str_replace(',', ',<br />', exec('uptime -p'));?></b></span></a></th>
<th><a class="tooltip" href="#"><?php echo $lang['cpu_load'];?><span><b>CPU Load</b></span></a></th>
<th><a class="tooltip" href="#"><?php echo $lang['cpu_temp'];?><span><b>CPU Temp</b></span></a></th>
</tr>
<tr>
<td><?php $h = php_uname('n'); if (strlen($h) >= 16) { $h = substr($h, 0, 14) . '..'; } echo htmlspecialchars((string)$h, ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars((string)php_uname('r'), ENT_QUOTES, 'UTF-8');?></td>
<td colspan="2"><?php echo htmlspecialchars((string)exec('/usr/local/bin/platformDetect.sh'), ENT_QUOTES, 'UTF-8');?></td>
<td><?php echo number_format($cpuLoad[0],2);?> / <?php echo number_format($cpuLoad[1],2);?> / <?php echo number_format($cpuLoad[2],2);?></td>
<?php echo $cpuTempHTML; ?>
</tr>
<tr>
<th colspan="6"><?php echo $lang['service_status'];?></th>
</tr>
<tr>
<td style="background: #<?php if (isProcessRunning('MMDVMHost')) { echo "1d1"; } else { echo "b55"; } ?>">MMDVMHost</td>
<td style="background: #<?php if (isProcessRunning('dstarrepeaterd')) { echo "1d1"; } else { echo "b55"; } ?>">DStarRepeater</td>
<td style="background: #<?php if (isProcessRunning('ircddbgatewayd')) { echo "1d1"; } else { echo "b55"; } ?>">ircDDBGateway</td>
<td style="background: #<?php if (isProcessRunning('timeserverd')) { echo "1d1"; } else { echo "b55"; } ?>">TimeServer</td>
<td style="background: #<?php if (isProcessRunning('/usr/local/sbin/pistar-watchdog',true)) { echo "1d1"; } else { echo "b55"; } ?>">PiStar-Watchdog</td>
<td style="background: #<?php if (isProcessRunning('/usr/local/sbin/pistar-remote',true)) { echo "1d1"; } else { echo "b55"; } ?>">PiStar-Remote</td>
</tr>
</table>
<br />