Remove backup/restore and factory reset; add APRS/POCSAG custom settings

- Remove admin/config_backup.php (backup/restore page) and all nav
  links to it across the admin pages and the expert-mode shared header.
- Remove factory reset: the full-device version in configure.php
  (JS confirm, POST handler that reset three git repos + wiped /etc
  config, and the hidden form) and the CSS-only version in
  expert/edit_dashboard.php.
- Remove the PiStar-Remote and BM API full editors
  (admin/expert/fulledit_pistar-remote.php, fulledit_bmapikey.php)
  and their links from the expert-mode menu.
- Add a "custom" option to the APRS server dropdown in configure.php
  so operators can type their own server + port instead of picking
  from APRSHosts.txt; wires the port through to ircDDBGateway,
  YSFGateway/YSF2DMR/YSF2NXDN/YSF2P25, and APRSGateway (previously
  only the hostname was ever configurable, port was hardcoded 14580).
- Extend the POCSAG frequency band validator (functions.js) to also
  treat 150-160MHz as a valid/green range.
This commit is contained in:
2026-07-21 14:41:30 +08:00
parent 0c4bed5b6f
commit 7c93c30689
12 changed files with 48 additions and 577 deletions
+45 -53
View File
@@ -203,19 +203,12 @@ $MYCALL=strtoupper($configs['gatewayCallsign']);
disablesubmitbuttons();
document.getElementById("autoApPassForm").submit();
}
function factoryReset() {
if (confirm('WARNING: This will set all your settings back to factory defaults. WiFi setup will be retained to maintain network access to this Pi.\n\nAre you SURE you want to do this?\n\nPress OK to restore the factory configuration\nPress Cancel to go back.')) {
document.getElementById("factoryReset").submit();
} else {
return false;
}
}
function resizeIframe(obj) {
var numpix = parseInt(obj.contentWindow.document.body.scrollHeight, 10);
obj.style.height = numpix + 'px';
}
</script>
<script type="text/javascript" src="/functions.js?version=1.715"></script>
<script type="text/javascript" src="/functions.js?version=1.717"></script>
</head>
<body onload="checkFrequency(); return false;">
<?php
@@ -253,9 +246,7 @@ if (file_exists($bmAPIkeyFile) && fopen($bmAPIkeyFile,'r')) {
<a href="/admin/" style="color: #ffffff;"><?php echo $lang['admin'];?></a> |
<a href="/admin/expert/" style="color: #ffffff;">专家模式</a> |
<a href="/admin/calibration.php" style="color: #ffffff;">校准</a> |
<a href="/admin/power.php" style="color: #ffffff;"><?php echo $lang['power'];?></a> |
<a href="/admin/config_backup.php" style="color: #ffffff;"><?php echo $lang['backup_restore'];?></a> |
<a href="javascript:factoryReset();" style="color: #ffffff;"><?php echo $lang['factory_reset'];?></a>
<a href="/admin/power.php" style="color: #ffffff;"><?php echo $lang['power'];?></a>
</p>
</div>
<div class="contentwide">
@@ -361,33 +352,6 @@ if ($_SERVER["PHP_SELF"] == "/admin/configure.php") {
// Let the services actualy stop
sleep(1);
// Factory Reset Handler Here
if (empty($_POST['factoryReset']) != TRUE ) {
echo "<br />\n";
echo "<div class=\"settings-card\" style=\"max-width:480px;margin:24px auto;text-align:center;\">\n";
echo "<table>\n";
echo "<tr><th>Factory Reset Config</th></tr>\n";
echo "<tr><td>Loading fresh configuration file(s)...</td><tr>\n";
echo "</table>\n";
echo "</div>\n";
unset($_POST);
// Over-write the config files with the clean copies
exec('sudo unzip -o /usr/local/bin/config_clean.zip -d /etc/');
exec('sudo rm -rf /etc/dstar-radio.*');
exec('sudo rm -rf /etc/pistar-css.ini');
exec('sudo git --work-tree=/usr/local/sbin --git-dir=/usr/local/sbin/.git update-index --assume-unchanged pistar-upnp.service');
exec('sudo git --work-tree=/usr/local/sbin --git-dir=/usr/local/sbin/.git reset --hard origin/master');
exec('sudo git --work-tree=/usr/local/bin --git-dir=/usr/local/bin/.git reset --hard origin/master');
exec('sudo git --work-tree=/var/www/dashboard --git-dir=/var/www/dashboard/.git reset --hard origin/master');
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},5000);</script>';
// Make the root filesystem read-only
system('sudo sync && sudo sync && sudo sync && sudo mount -o remount,ro /');
echo "<br />\n</div>\n";
echo "</div>\n</body>\n</html>\n";
die();
}
// Handle the case where the config is not read correctly
if (count($configmmdvm) <= 18) {
echo "<br />\n";
@@ -550,18 +514,41 @@ if ($_SERVER["PHP_SELF"] == "/admin/configure.php") {
// Set the APRS Host for ircDDBGateway
if (empty($_POST['selectedAPRSHost']) != TRUE ) {
$rollAPRSHost = 'sudo sed -i "/aprsHostname=/c\\aprsHostname='.escapeshellcmd($_POST['selectedAPRSHost']).'" /etc/ircddbgateway';
// "custom" lets the operator type their own APRS-IS server + port
// instead of picking from /usr/local/etc/APRSHosts.txt (which is
// always port 14580). Validate both before use: the value is
// still run through escapeshellcmd() below, but a hostname
// containing "/" would break the sed "/pattern/c\..." syntax
// (sed's default delimiter), so reject anything that isn't a
// plain hostname/IP up front rather than relying on
// escapeshellcmd() alone.
if ($_POST['selectedAPRSHost'] === 'custom' && !empty($_POST['customAPRSHost']) && preg_match('/^[A-Za-z0-9.\-]+$/', trim($_POST['customAPRSHost']))) {
$aprsHost = escapeshellcmd(trim($_POST['customAPRSHost']));
$aprsPort = (!empty($_POST['customAPRSPort']) && ctype_digit(trim($_POST['customAPRSPort'])) && (int)trim($_POST['customAPRSPort']) >= 1 && (int)trim($_POST['customAPRSPort']) <= 65535) ? trim($_POST['customAPRSPort']) : '14580';
} else {
$aprsHost = escapeshellcmd($_POST['selectedAPRSHost']);
$aprsPort = '14580';
}
$rollAPRSHost = 'sudo sed -i "/aprsHostname=/c\\aprsHostname='.$aprsHost.'" /etc/ircddbgateway';
system($rollAPRSHost);
$configysfgateway['aprs.fi']['Server'] = escapeshellcmd($_POST['selectedAPRSHost']);
$configysf2dmr['aprs.fi']['Server'] = escapeshellcmd($_POST['selectedAPRSHost']);
$configysf2nxdn['aprs.fi']['Server'] = escapeshellcmd($_POST['selectedAPRSHost']);
$configysf2p25['aprs.fi']['Server'] = escapeshellcmd($_POST['selectedAPRSHost']);
$rollAPRSPort = 'sudo sed -i "/^aprsPort=/c\\aprsPort='.$aprsPort.'" /etc/ircddbgateway';
system($rollAPRSPort);
$configysfgateway['aprs.fi']['Server'] = $aprsHost;
$configysfgateway['aprs.fi']['Port'] = $aprsPort;
$configysf2dmr['aprs.fi']['Server'] = $aprsHost;
$configysf2dmr['aprs.fi']['Port'] = $aprsPort;
$configysf2nxdn['aprs.fi']['Server'] = $aprsHost;
$configysf2nxdn['aprs.fi']['Port'] = $aprsPort;
$configysf2p25['aprs.fi']['Server'] = $aprsHost;
$configysf2p25['aprs.fi']['Port'] = $aprsPort;
$configysf2dmr['aprs.fi']['Enable'] = "0";
$configysf2nxdn['aprs.fi']['Enable'] = "0";
$configysf2p25['aprs.fi']['Enable'] = "0";
if ($configPistarRelease['Pi-Star']['Version'] >= "4.1.4") {
$rollAPRSGatewayHost = 'sudo sed -i "/Server=/c\\Server='.escapeshellcmd($_POST['selectedAPRSHost']).'" /etc/aprsgateway';
$rollAPRSGatewayHost = 'sudo sed -i "/Server=/c\\Server='.$aprsHost.'" /etc/aprsgateway';
system($rollAPRSGatewayHost);
$rollAPRSGatewayPort = 'sudo sed -i "/^Port=/c\\Port='.$aprsPort.'" /etc/aprsgateway';
system($rollAPRSGatewayPort);
}
}
@@ -3604,10 +3591,6 @@ else:
$toggleircddbEnabledCr = "";
}
?>
<form id="factoryReset" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
<div><input type="hidden" name="factoryReset" value="1" /></div>
</form>
<form id="config" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
<h2><?php echo $lang['control_software'];?></h2>
<div class="settings-card">
@@ -4069,22 +4052,31 @@ else:
}
} ?>
<div class="field-row">
<div align="left"><a class="tooltip2" href="#"><?php echo $lang['aprs_host'];?>:<span><b>APRS Host</b>Set your prefered APRS host here.</span></a></div>
<div colspan="2" style="text-align: left;"><select name="selectedAPRSHost">
<?php
<div align="left"><a class="tooltip2" href="#"><?php echo $lang['aprs_host'];?>:<span><b>APRS Host</b>Set your prefered APRS host here, or pick "自定义" to type your own server + port.</span></a></div>
<div colspan="2" style="text-align: left;">
<select name="selectedAPRSHost" onchange="document.getElementById('customAPRSFields').style.display = (this.value == 'custom') ? 'inline' : 'none';">
<?php
$testAPSRHost = $configs['aprsHostname'];
$aprsHostIsCustom = true;
$aprsHostFile = fopen("/usr/local/etc/APRSHosts.txt", "r");
while (!feof($aprsHostFile)) {
$aprsHostFileLine = fgets($aprsHostFile);
$aprsHost = preg_split('/:/', $aprsHostFileLine);
if ((strpos($aprsHost[0], ';') === FALSE ) && ($aprsHost[0] != '')) {
if ($testAPSRHost == $aprsHost[0]) { echo " <option value=\"$aprsHost[0]\" selected=\"selected\">$aprsHost[0]</option>\n"; }
if ($testAPSRHost == $aprsHost[0]) { echo " <option value=\"$aprsHost[0]\" selected=\"selected\">$aprsHost[0]</option>\n"; $aprsHostIsCustom = false; }
else { echo " <option value=\"$aprsHost[0]\">$aprsHost[0]</option>\n"; }
}
}
fclose($aprsHostFile);
echo " <option value=\"custom\"".($aprsHostIsCustom ? " selected=\"selected\"" : "").">自定义 (Custom)</option>\n";
?>
</select></div>
</select>
<span id="customAPRSFields" style="display:<?php echo $aprsHostIsCustom ? 'inline' : 'none'; ?>;">
<input type="text" name="customAPRSHost" placeholder="server.example.com" size="22" maxlength="64" value="<?php echo $aprsHostIsCustom ? htmlspecialchars(trim($testAPSRHost), ENT_QUOTES, 'UTF-8') : ''; ?>" />
:
<input type="text" name="customAPRSPort" placeholder="14580" size="6" maxlength="5" value="<?php echo htmlspecialchars(trim(isset($configs['aprsPort']) ? $configs['aprsPort'] : '14580'), ENT_QUOTES, 'UTF-8'); ?>" />
</span>
</div>
</div>
<div class="field-row">
<div align="left"><a class="tooltip2" href="#"><?php echo $lang['timezone'];?>:<span><b>System TimeZone</b>Set the system timezone</span></a></div>