7c93c30689
- 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.
158 lines
6.1 KiB
PHP
158 lines
6.1 KiB
PHP
<?php
|
|
// Load the language support
|
|
require_once('../config/language.php');
|
|
//Load the Pi-Star Release file
|
|
$pistarReleaseConfig = '/etc/pistar-release';
|
|
$configPistarRelease = array();
|
|
$configPistarRelease = parse_ini_file($pistarReleaseConfig, true);
|
|
//Load the Version Info
|
|
require_once('../config/version.php');
|
|
?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" lang="en">
|
|
<head>
|
|
<meta name="robots" content="index" />
|
|
<meta name="robots" content="follow" />
|
|
<meta name="language" content="English" />
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
<meta name="Author" content="Andrew Taylor (MW0MWZ)" />
|
|
<meta name="Description" content="CDN Expert Editor" />
|
|
<meta name="KeyWords" content="CDN" />
|
|
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
|
<meta http-equiv="pragma" content="no-cache" />
|
|
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
|
|
<meta http-equiv="Expires" content="0" />
|
|
<title>CDN - Digital Voice Dashboard - Expert Editor</title>
|
|
<link rel="stylesheet" type="text/css" href="../css/pistar-css.php" />
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<?php include './header-menu.inc'; ?>
|
|
<div class="contentwide">
|
|
|
|
<?php
|
|
if (!file_exists('/etc/pistar-css.ini')) {
|
|
//The source file does not exist, lets create it....
|
|
$outFile = fopen("/tmp/bW1kd4jg6b3N0DQo.tmp", "w") or die("Unable to open file!");
|
|
$fileContent = "[Background]\nPage=f3f4f8\nContent=ffffff\nBanners=4f46e5\n\n";
|
|
$fileContent .= "[Text]\nBanners=ffffff\nBannersDrop=1e1b4b\n\n";
|
|
$fileContent .= "[Tables]\nHeadDrop=3730a3\nBgEven=f8fafc\nBgOdd=eef0f5\n\n";
|
|
$fileContent .= "[Content]\nText=111827\n\n";
|
|
$fileContent .= "[BannerH1]\nEnabled=0\nText=\"Some Text\"\n\n";
|
|
$fileContent .= "[BannerExtText]\nEnabled=0\nText=\"Some long text entry\"\n\n";
|
|
$fileContent .= "[Lookup]\nService=\"RadioID\"\n";
|
|
fwrite($outFile, $fileContent);
|
|
fclose($outFile);
|
|
|
|
// Put the file back where it should be
|
|
exec('sudo mount -o remount,rw /'); // Make rootfs writable
|
|
exec('sudo cp /tmp/bW1kd4jg6b3N0DQo.tmp /etc/pistar-css.ini'); // Move the file back
|
|
exec('sudo chmod 644 /etc/pistar-css.ini'); // Set the correct runtime permissions
|
|
exec('sudo chown root:root /etc/pistar-css.ini'); // Set the owner
|
|
exec('sudo mount -o remount,ro /'); // Make rootfs read-only
|
|
}
|
|
|
|
//Do some file wrangling...
|
|
exec('sudo cp /etc/pistar-css.ini /tmp/bW1kd4jg6b3N0DQo.tmp');
|
|
exec('sudo chown www-data:www-data /tmp/bW1kd4jg6b3N0DQo.tmp');
|
|
exec('sudo chmod 664 /tmp/bW1kd4jg6b3N0DQo.tmp');
|
|
|
|
//ini file to open
|
|
$filepath = '/tmp/bW1kd4jg6b3N0DQo.tmp';
|
|
|
|
//after the form submit
|
|
if($_POST) {
|
|
$data = $_POST;
|
|
//update ini file, call function
|
|
update_ini_file($data, $filepath);
|
|
}
|
|
|
|
//this is the function going to update your ini file
|
|
function update_ini_file($data, $filepath) {
|
|
$content = "";
|
|
|
|
//parse the ini file to get the sections
|
|
//parse the ini file using default parse_ini_file() PHP function
|
|
$parsed_ini = parse_ini_file($filepath, true);
|
|
|
|
foreach($data as $section=>$values) {
|
|
// UnBreak special cases
|
|
$section = str_replace("_", " ", $section);
|
|
$section = str_replace("BannerH2", "BannerH1", $section);
|
|
$content .= "[".$section."]\n";
|
|
//append the values
|
|
foreach($values as $key=>$value) {
|
|
if ($value == '') {
|
|
$content .= $key."=none\n";
|
|
}
|
|
else {
|
|
$content .= $key."=".$value."\n";
|
|
}
|
|
}
|
|
$content .= "\n";
|
|
}
|
|
|
|
//write it into file
|
|
if (!$handle = fopen($filepath, 'w')) {
|
|
return false;
|
|
}
|
|
|
|
$success = fwrite($handle, $content);
|
|
fclose($handle);
|
|
|
|
// Updates complete - copy the working file back to the proper location
|
|
exec('sudo mount -o remount,rw /'); // Make rootfs writable
|
|
exec('sudo cp /tmp/bW1kd4jg6b3N0DQo.tmp /etc/pistar-css.ini'); // Move the file back
|
|
exec('sudo chmod 644 /etc/pistar-css.ini'); // Set the correct runtime permissions
|
|
exec('sudo chown root:root /etc/pistar-css.ini'); // Set the owner
|
|
exec('sudo mount -o remount,ro /'); // Make rootfs read-only
|
|
|
|
return $success;
|
|
}
|
|
|
|
//parse the ini file using default parse_ini_file() PHP function
|
|
$parsed_ini = parse_ini_file($filepath, true);
|
|
if (isset($parsed_ini['Lookup']['popupWidth'])) { unset($parsed_ini['Lookup']['popupWidth']); }
|
|
if (isset($parsed_ini['Lookup']['popupHeight'])) { unset($parsed_ini['Lookup']['popupHeight']); }
|
|
|
|
echo '<form action="" method="post">'."\n";
|
|
foreach($parsed_ini as $section=>$values) {
|
|
// keep the section as hidden text so we can update once the form submitted
|
|
echo "<input type=\"hidden\" value=\"$section\" name=\"$section\" />\n";
|
|
echo "<div class=\"settings-card\">\n";
|
|
echo "<h3>$section</h3>\n";
|
|
// print all other values as input fields, so can edit.
|
|
// note the name='' attribute it has both section and key
|
|
foreach($values as $key=>$value) {
|
|
if ( $section == "Lookup" && $key == "Service" ) {
|
|
echo "<div class=\"field-row\"><div>$key</div><div>\n";
|
|
echo " <select name=\"{$section}[$key]\" />\n";
|
|
if ($value == "RadioID") {
|
|
echo " <option value=\"RadioID\" selected=\"selected\">RadioID Callsign Lookup</option>\n";
|
|
} else {
|
|
echo " <option value=\"RadioID\">RadioID Callsign Lookup</option>\n";
|
|
}
|
|
if ($value == "QRZ") {
|
|
echo " <option value=\"QRZ\" selected=\"selected\">QRZ Callsign Lookup</option>\n";
|
|
} else {
|
|
echo " <option value=\"QRZ\">QRZ Callsign Lookup</option>\n";
|
|
}
|
|
echo " </select>\n";
|
|
echo "</div></div>\n";
|
|
} else {
|
|
echo "<div class=\"field-row\"><div>$key</div><div><input type=\"text\" name=\"{$section}[$key]\" value=\"$value\" /></div></div>\n";
|
|
}
|
|
}
|
|
echo "</div>\n";
|
|
echo '<div class="field-actions"><input type="submit" value="'.$lang['apply'].'" /></div>'."\n";
|
|
}
|
|
echo "</form>";
|
|
?>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</body>
|
|
</html>
|