Undo GUI access

This commit is contained in:
bergware
2017-06-23 19:58:43 +02:00
parent bcaa259957
commit 66bbc91c3f
4 changed files with 0 additions and 125 deletions

View File

@@ -1,110 +0,0 @@
Menu="WebGui"
Title="GUI Access"
---
<?PHP
/* Copyright 2005-2017, Lime Technology
* Copyright 2012-2017, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
?>
<?
$emhttp = preg_split('/\s+/',exec("grep -Pm1 '/usr/local/sbin/emhttp' /boot/config/go"));
while (true) {
// strip any leading commands
if (strpos($emhttp[0],'emhttp')!==false) break;
array_shift($emhttp);
}
list($cmd,$options,$ports,$spare) = $emhttp;
if ($ports[0] == '-') {
$options .= substr($ports,1);
$ports = $spare;
}
list($http,$https) = explode(',',$ports);
switch ($options) {
case '' :
case '&' : $protocol = 'http'; $options = ''; break;
case '-p' : $protocol = $http ? 'http' : 'https'; break;
case '-rp':
case '-pr': $protocol = 'redirect'; break;
default : $protocol = 'http';
}
?>
<script>
function showPorts(form) {
var http = $(form).find('div#http');
var https = $(form).find('div#https');
switch (form.protocol.value) {
case 'http' : http.show(); https.hide(); break;
case 'https' : http.hide(); https.show(); break;
case 'redirect': http.show(); https.show(); break;
}
}
function setGUI(form) {
switch (form.protocol.value) {
case 'http':
if (form.http.value=='' || form.http.value=='80') {
$('input[name="#arg[1]"]').val('');
$('input[name="#arg[2]"]').val('');
} else {
$('input[name="#arg[1]"]').val('-p');
$('input[name="#arg[2]"]').val(form.http.value);
}
break;
case 'https':
$('input[name="#arg[1]"]').val('-p');
if (form.https.value=='') {
$('input[name="#arg[2]"]').val(',443');
} else {
$('input[name="#arg[2]"]').val(','+form.https.value);
}
break;
case 'redirect':
$('input[name="#arg[1]"]').val('-rp');
$('input[name="#arg[2]"]').val((form.http.value||'80')+','+(form.https.value||'443'));
break;
}
var port = $('input[name="#arg[2]"]').val();
$.post('/webGui/include/PortFree.php',{port:port},function(data){
if (data) {
var port = data.split(',')[0];
var process = data.split(',')[1];
swal('Port already in use',"Port "+port+" is used by process '"+process+"'",'error');
} else {
form.submit();
}
});
}
$(function() {
showPorts(document.access_mode);
});
</script>
<form markdown="1" name="access_mode" method="POST" action="/update.php" target="progressFrame">
<input type="hidden" name="#command" value="/webGui/scripts/accessmode">
<input type="hidden" name="#arg[1]" value="">
<input type="hidden" name="#arg[2]" value="">
GUI protocol:
: <select name="protocol" size="1" onchange="showPorts(this.form)">
<?=mk_option($protocol, "http", "HTTP")?>
<?=mk_option($protocol, "https", "HTTPS")?>
<?=mk_option($protocol, "redirect", "REDIRECT")?>
</select>
<div markdown="1" id="http" style="display:none">
HTTP port:
: <input type="text" name="http" maxlength="" value="<?=$http ?: '80'?>" class="narrow">
</div>
<div markdown="1" id="https" style="display:none">
HTTPS port:
: <input type="text" name="https" maxlength="" value="<?=$https ?: '443'?>" class="narrow">
</div>
&nbsp;
: <input type="button" value="Apply" onclick="setGUI(this.form)"><input type="button" value="Done" onclick="done()">
</form>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 308 B

View File

@@ -1,10 +0,0 @@
#!/bin/bash
# usage: accessmode [-r] [-p http [,https]]
[[ -n $1 ]] && options="$1" || options=
[[ -n $2 ]] && options="$1 $2"
[[ -n $options ]] && options="$options \&" || options="\&"
sed -ri "s|^(.*/usr/local/sbin/emhttp).*|\1 $options|1" /boot/config/go
# We need to restart the GUI in a separate process to prevent it from hanging
at -M -f /usr/local/emhttp/webGui/scripts/restart_gui now 2>/dev/null

View File

@@ -1,5 +0,0 @@
#!/bin/bash
# read go file settings and restart GUI
# called from accessmode script
/usr/local/sbin/emhttp $(grep -Po '^.*/usr/local/sbin/emhttp \K[^&]*' /boot/config/go) restart >/dev/null