added switch reflector button inspired by OE7JKT. Be sure to add /bin/sed into sudoers! Not finished completely, actually loads only DMRplus-Reflector-list.

This commit is contained in:
dg9vh 2017-03-28 08:28:39 +00:00
parent 03285d6011
commit 677bac73ff
5 changed files with 140 additions and 1 deletions

View file

@ -42,6 +42,7 @@ textdomain('messages');
<li>dg0cco</li>
<li>sa7bnt</li>
<li>ct2jay</li>
<li>oe7jkt</li>
<li><?php echo _("and some others..."); ?></li>
</ul>
<p><?php echo _("Those, who felt forgotten, feel free to commit a change into github of this file."); ?></p>

View file

@ -849,9 +849,33 @@ function decodeAlias($logLine) {
return $tok1.$tok2.$tok3.$tok4.$tok5.$tok6.$tok7;
}
function getGitVersion(){
exec("git rev-parse HEAD", $output);
return 'GitID #<a href="https://github.com/dg9vh/MMDVMHost-Dashboard/commit/'.substr($output[0],0,7).'">'.substr($output[0],0,7).'</a>';
}
function getDMRReflectors($network) {
$refls = array();
switch ($network) {
case "DMRPLUS":
$refls = getDMRReflectorsFromURL("http://ham-dmr.de/reflector.db");
break;
case "BRANDMEISTER":
$refls = getDMRReflectorsFromURL("http://185.79.71.94/reflector.db");
break;
}
return $refls;
}
function getDMRReflectorsFromURL($url) {
$data = file_get_contents($url);
$rows = explode("\n",$data);
$refls = array();
foreach($rows as $row) {
$refls[] = str_getcsv($row,"@",'');
}
return $refls;
}
?>

View file

@ -133,6 +133,24 @@ if (defined("ENABLENETWORKSWITCHING")) {
?>
<button onclick="window.location.href='./scripts/switchnetwork.php?network=DMRPLUS'" type="button" class="btn btn-default navbar-btn"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span>&nbsp;<?php echo _("DMRplus"); ?></button>
<button onclick="window.location.href='./scripts/switchnetwork.php?network=BRANDMEISTER'" type="button" class="btn btn-default navbar-btn"><span class="glyphicon glyphicon-fire" aria-hidden="true"></span>&nbsp;<?php echo _("BrandMeister"); ?></button>
<?php
}
if (defined("ENABLEREFLECTORSWITCHING") && (getEnabled("DMR Network", $mmdvmconfigs) == 1)) {
$reflectors = getDMRReflectors("DMRPLUS");
?>
<form method = "get" action ="./scripts/switchreflector.php" class="form-inline" role="form">
<div class="form-group">
<select id="reflector" name="reflector" class="form-control" style="width: 80px;">
<?php
foreach ($reflectors as $reflector) {
if (strlen($reflector[1])>0)
echo'<option value="'.$reflector[0].'">'.$reflector[1].'</option>';
}
?>
</select>
<button type="submit" class="btn btn-default navbar-btn"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span>&nbsp;<?php echo _("ReflSwitch"); ?></button>
</div></form>
<?php
}
}

View file

@ -0,0 +1,92 @@
<?php
//ea4gkq
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
// do not touch this includes!!! Never ever!!!
include "../config/config.php";
include "../include/tools.php";
include "../include/functions.php";
include "../include/init.php";
if (!isset($_SERVER['PHP_AUTH_USER']) && SWITCHNETWORKUSER !== "" && SWITCHNETWORKPW !== "") {
header('WWW-Authenticate: Basic realm="Dashboard"');
header('HTTP/1.0 401 Unauthorized');
echo 'Zur Ausführung bitte die geforderten Login-Daten eingeben!';
exit;
} else {
if ($_SERVER['PHP_AUTH_USER'] == SWITCHNETWORKUSER && $_SERVER['PHP_AUTH_PW'] == SWITCHNETWORKPW) {
$fileName = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".date("Y-m-d").".log";
?>
<!doctype html>
<html lang="es">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<!-- Das neueste kompilierte und minimierte CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<!-- Optionales Theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
<!-- Das neueste kompilierte und minimierte JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<meta http-equiv="refresh" content="10; URL=../">
<title><?php echo getCallsign($mmdvmconfigs) ?> - MMDVM-Dashboard by DG9VH</title>
</head>
<body>
<div class="page-header">
<h1><small>MMDVM-Dashboard by DG9VH for <?php
if (getConfigItem("General", "Duplex", $mmdvmconfigs) == "1") {
echo "Repeater";
} else {
echo "Hotspot";
}
?>:</small> <?php echo getCallsign($mmdvmconfigs) ?></h1>
<h4>MMDVMHost by G4KLX Version: <?php echo getMMDVMHostVersion() ?></h4>
<button onclick="window.location.href='../index.php'" type="button" class="btn btn-default navbar-btn"><span class="glyphicon glyphicon-home" aria-hidden="true"></span>&nbsp;Home</button>
</script>
</div>
<?php
$reflektor_nr=$_GET['reflector'];
checkSetup();
include "../include/sysinfo.php";
exec( "sudo /bin/sed '/#Options/d' -i ".MMDVMINIPATH."/".MMDVMINIFILENAME);
exec( "sudo /bin/sed 's/Options=StartRef=.*$/Options=StartRef=".$reflektor_nr.";RelinkTime=20;Userlink=1;/' -i ".MMDVMINIPATH."/".MMDVMINIFILENAME);
exec( REBOOTMMDVM );
// /bin/sed '/#Options/d' -i /opt/MMDVMHost/MMDVM.ini
// #dann
// /bin/sed 's/Options=StartRef=.*$/Options=StartRef='"$Reflektor"';RelinkTime=22;Userlink=1;/' -i /opt/MMDVMHost/MMDVM.ini
?>
<div class="alert alert-info" role="alert">Switching reflector to <b><?php echo $reflektor_nr; ?></b><br>Restarting in new selected network in progress</div>
<div class="panel panel-info">
<?php
$datum = date("d-m-Y");
$uhrzeit = date("H:i:s");
echo "Last Update $datum, $uhrzeit";
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
echo '<!--Page generated in '.$total_time.' seconds.-->';
} else {
header('WWW-Authenticate: Basic realm="Dashboard"');
header('HTTP/1.0 401 Unauthorized');
echo 'Zur Ausführung bitte die geforderten Login-Daten eingeben!';
exit;
}
}
?> | get your own at: <a href="https://github.com/dg9vh/MMDVMHost-Dashboard">https://github.com/dg9vh/MMDVMHost-Dashboard</a>
</div>
</body>
</html>

View file

@ -261,6 +261,10 @@ get_tz_options(constant("TIMEZONE"), "Timezone", '');
<span class="input-group-addon" id="ENABLENETWORKSWITCHING" style="width: 300px"><?php echo _("Enable Network-Switching-Function"); ?></span>
<div class="panel-body"><input type="checkbox" name="ENABLENETWORKSWITCHING" <?php if (defined("ENABLENETWORKSWITCHING")) echo "checked" ?>></div>
</div>
<div class="input-group">
<span class="input-group-addon" id="ENABLEREFLECTORSWITCHING" style="width: 300px"><?php echo _("Enable Reflector-Switching-Function"); ?></span>
<div class="panel-body"><input type="checkbox" name="ENABLEREFLECTORSWITCHING" <?php if (defined("ENABLEREFLECTORSWITCHING")) echo "checked" ?>></div>
</div>
<div class="input-group">
<span class="input-group-addon" id="SWITCHNETWORKUSER" style="width: 300px"><?php echo _("Username for switching networks:"); ?></span>
<input type="text" value="<?php echo constant("SWITCHNETWORKUSER") ?>" name="SWITCHNETWORKUSER" class="form-control" placeholder="username" aria-describedby="SWITCHNETWORKUSER">