= 86400)
return sprintf("%0.2f days", $sec/86400);
$hrs = intdiv($sec, 3600);
$sec %= 3600;
$min = intdiv($sec, 60);
$sec %= 60;
if ($hrs) return sprintf("%2d hr %2d min %2d sec", $hrs, $min, $sec);
if ($min) return sprintf("%2d min %2d sec", $min, $sec);
return sprintf("%2d sec", $sec);
}
function RptrToAprs(string $rptr)
{
if (8==strlen($rptr) && 8==strlen(trim($rptr)) && strpos($rptr, ' ')) {
$link = strstr($rptr, ' ', true).'-'.$rptr[7];
return ''.$rptr.'';
}
return $rptr;
}
function MyAndSfxToQrz(string $my, string $sfx)
{
$my = trim($my);
$sfx = trim($sfx);
if (0 == strlen($my)) {
$my = 'Empty MYCall ';
} else {
if (strpos($my, ' '))
$link = strstr($my, ' ', true);
else
$link = $my;
if (strlen($sfx))
$my .= '/'.$sfx;
$len = strlen($my);
$my = ''.$my.'';
while ($len < 13) {
$my .= ' ';
$len += 1;
}
}
return $my;
}
ParseKVFile($cfgdir.'/qn.cfg', $cfg);
ParseKVFile($cfgdir.'/defaults', $defaults);
?>
QnetGateway Dashboard
2) {
echo 'Processes:
', "\n";
echo str_replace(' ', ' ', 'USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
'), "\n";
$lines = explode("\n", `ps -aux | grep -e qngateway -e qnlink -e qndtmf -e qndvap -e qnitap -e qnrelay -e qndvrptr -e qnmodem -e MMDVMHost | grep -v grep`);
foreach ($lines as $line) {
echo str_replace(' ', ' ', $line), "
\n";
}
echo '', "\n";
}
if ('true' == GetCFGValue('dash_show_lh')) {
echo 'Last Heard:
', "\n";
$rstr = 'MyCall/Sfx URCall Module Gateway Last Time
';
echo str_replace(' ', ' ', $rstr), "\n";
$dbname = GetCFGValue('dash_sql_filename');
$db = new SQLite3($dbname, SQLITE3_OPEN_READONLY);
$ss = 'SELECT mycall,sfx,urcall,module,gateway,strftime("%s","now")-lasttime FROM LHEARD ORDER BY 6 LIMIT '.GetCFGValue('dash_lastheard_count').' ';
if ($stmnt = $db->prepare($ss)) {
if ($result = $stmnt->execute()) {
while ($row = $result->FetchArray(SQLITE3_NUM)) {
$rstr = MyAndSfxToQrz($row[0], $row[1]).' '.$row[2].' '.RptrToAprs($row[3]).' '.$row[4].' '.SecToString(intval($row[5])).'
';
echo str_replace('*', ' ', str_replace(' ', ' ', $rstr)), "\n";
}
$result->finalize();
}
$stmnt->close();
}
$db->Close();
echo '
', "\n";
}
if ('true' == GetCFGValue('dash_show_ip')) {
echo 'IP Addresses:
', "\n";
echo '', "\n";
echo '| Internal | IPV4 | IPV6 |
', "\n";
echo '| ', GetIP('internal'), ' | ', GetIP('ipv4'), ' | ', GetIP('ipv6'), ' |
', "\n";
echo '
', "\n";
}
if ('true' == GetCFGValue('dash_show_mo')) {
echo 'Modules:
', "\n";
echo "\n";
echo '| Module | Modem | Frequency | Repeater | Repeater IP |
', "\n";
foreach (array('a', 'b', 'c') as $mod) {
$module = 'module_'.$mod;
if (array_key_exists($module, $cfg)) {
$configured[] = strtoupper($mod);
$freq = 0.0;
if (array_key_exists($module.'_tx_frequency', $cfg))
$freq = $cfg[$module.'_tx_frequency'];
else if (array_key_exists($module.'_frequency', $cfg))
$freq = $cfg[$module.'_frequency'];
$stat = GetStatus($mod, $cfg);
if (8==strlen($stat[1]) && 1==strlen($stat[2]))
$linkstatus = substr($stat[1], 0, 7).$stat[2];
else
$linkstatus = 'Unlinked';
echo '| ',strtoupper($mod),' | ',$cfg[$module],' | ',$freq,' | ',$linkstatus,' | ',$stat[3],' |
',"\n";
}
}
echo '
', "\n";
}
if ('true' == GetCFGValue('dash_show_ur')) {
echo 'Send URCall:
', "\n";
echo '', "\n";
if (isset($_POST['sendurcall'])) {
$furcall = $_POST['furcall'];
if (empty($_POST['fmodule'])) {
if (1==count($configured)) {
$fmodule = $configured[0];
}
} else {
$fmodule = $_POST['fmodule'];
}
}
$furcall = str_replace(' ', '_', trim(preg_replace('/[^0-9a-z ]/', '', strtolower($furcall))));
if (strlen($furcall)>0 && strlen($fmodule)>0) {
$command = 'qnremote '.strtolower($fmodule).' '.strtolower($cfg['ircddb_login']).' '.$furcall;
echo $command, "
\n";
$unused = `$command`;
}
}
?>
QnetGateway Dashboard Version 2.0 Copyright (©) by Thomas A. Early, N7TAE.