mirror of
https://github.com/YunoHost-Apps/hotspot_ynh.git
synced 2024-09-03 19:25:53 +02:00
Frontend ready for multissid
This commit is contained in:
parent
5ff2647035
commit
5aa581e147
5 changed files with 353 additions and 257 deletions
|
@ -60,6 +60,14 @@ function ipv6_compressed($ip) {
|
||||||
return $output[0];
|
return $output[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getArray($str) {
|
||||||
|
return explode('|', $str);
|
||||||
|
}
|
||||||
|
|
||||||
|
function noneValue($str) {
|
||||||
|
return $str == 'none' ? '' : $str;
|
||||||
|
}
|
||||||
|
|
||||||
function is_connected_through_hotspot($ip6_net, $ip4_nat_prefix) {
|
function is_connected_through_hotspot($ip6_net, $ip4_nat_prefix) {
|
||||||
$ip = $_SERVER['REMOTE_ADDR'];
|
$ip = $_SERVER['REMOTE_ADDR'];
|
||||||
$ip6_regex = '/^'.preg_quote(preg_replace('/::$/', '', $ip6_net)).':/';
|
$ip6_regex = '/^'.preg_quote(preg_replace('/::$/', '', $ip6_net)).':/';
|
||||||
|
@ -71,6 +79,8 @@ function is_connected_through_hotspot($ip6_net, $ip4_nat_prefix) {
|
||||||
dispatch('/', function() {
|
dispatch('/', function() {
|
||||||
exec('sudo iwconfig', $devs);
|
exec('sudo iwconfig', $devs);
|
||||||
$wifi_device = moulinette_get('wifi_device');
|
$wifi_device = moulinette_get('wifi_device');
|
||||||
|
$multissid = moulinette_get('multissid');
|
||||||
|
$ssids = array();
|
||||||
$devs_list = '';
|
$devs_list = '';
|
||||||
|
|
||||||
foreach($devs AS $dev) {
|
foreach($devs AS $dev) {
|
||||||
|
@ -83,24 +93,43 @@ dispatch('/', function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$wifi_ssid = getArray(moulinette_get('wifi_ssid'));
|
||||||
|
$wifi_secure = getArray(moulinette_get('wifi_secure'));
|
||||||
|
$wifi_passphrase = getArray(moulinette_get('wifi_passphrase'));
|
||||||
|
$wifi_channel = getArray(moulinette_get('wifi_channel'));
|
||||||
|
$ip6_net = getArray(moulinette_get('ip6_net'));
|
||||||
|
$ip6_dns0 = getArray(moulinette_get('ip6_dns0'));
|
||||||
|
$ip6_dns1 = getArray(moulinette_get('ip6_dns1'));
|
||||||
|
$ip4_nat_prefix = getArray(moulinette_get('ip4_nat_prefix'));
|
||||||
|
$ip4_dns0 = getArray(moulinette_get('ip4_dns0'));
|
||||||
|
$ip4_dns1 = getArray(moulinette_get('ip4_dns1'));
|
||||||
|
|
||||||
|
for($i = 0; $i < $multissid; $i++) {
|
||||||
|
$ssid = [
|
||||||
|
'id' => $i,
|
||||||
|
'wifi_ssid' => noneValue($wifi_ssid[$i]),
|
||||||
|
'wifi_secure' => noneValue($wifi_secure[$i]),
|
||||||
|
'wifi_passphrase' => noneValue($wifi_passphrase[$i]),
|
||||||
|
'wifi_channel' => noneValue($wifi_channel[$i]),
|
||||||
|
'ip6_net' => noneValue($ip6_net[$i]),
|
||||||
|
'ip6_dns0' => noneValue($ip6_dns0[$i]),
|
||||||
|
'ip6_dns1' => noneValue($ip6_dns1[$i]),
|
||||||
|
'ip4_nat_prefix' => noneValue($ip4_nat_prefix[$i]),
|
||||||
|
'ip4_dns0' => noneValue($ip4_dns0[$i]),
|
||||||
|
'ip4_dns1' => noneValue($ip4_dns1[$i]),
|
||||||
|
];
|
||||||
|
|
||||||
|
array_push($ssids, $ssid);
|
||||||
|
}
|
||||||
|
|
||||||
$ip6_net = moulinette_get('ip6_net');
|
$ip6_net = moulinette_get('ip6_net');
|
||||||
$ip6_net = ($ip6_net == 'none') ? '' : $ip6_net;
|
$ip6_net = ($ip6_net == 'none') ? '' : $ip6_net;
|
||||||
$ip4_nat_prefix = moulinette_get('ip4_nat_prefix');
|
$ip4_nat_prefix = moulinette_get('ip4_nat_prefix');
|
||||||
|
|
||||||
set('service_enabled', moulinette_get('service_enabled'));
|
set('service_enabled', moulinette_get('service_enabled'));
|
||||||
set('wifi_ssid', moulinette_get('wifi_ssid'));
|
set('ssids', $ssids);
|
||||||
set('wifi_secure', moulinette_get('wifi_secure'));
|
|
||||||
set('wifi_passphrase', moulinette_get('wifi_passphrase'));
|
|
||||||
set('wifi_channel', moulinette_get('wifi_channel'));
|
|
||||||
set('wifi_n', moulinette_get('wifi_n'));
|
|
||||||
set('wifi_device', $wifi_device);
|
set('wifi_device', $wifi_device);
|
||||||
set('wifi_device_list', $devs_list);
|
set('wifi_device_list', $devs_list);
|
||||||
set('ip6_net', $ip6_net);
|
|
||||||
set('ip6_dns0', moulinette_get('ip6_dns0'));
|
|
||||||
set('ip6_dns1', moulinette_get('ip6_dns1'));
|
|
||||||
set('ip4_nat_prefix', $ip4_nat_prefix);
|
|
||||||
set('ip4_dns0', moulinette_get('ip4_dns0'));
|
|
||||||
set('ip4_dns1', moulinette_get('ip4_dns1'));
|
|
||||||
set('faststatus', service_faststatus() == 0);
|
set('faststatus', service_faststatus() == 0);
|
||||||
set('is_connected_through_hotspot', is_connected_through_hotspot($ip6_net, $ip4_nat_prefix));
|
set('is_connected_through_hotspot', is_connected_through_hotspot($ip6_net, $ip4_nat_prefix));
|
||||||
|
|
||||||
|
@ -109,113 +138,118 @@ dispatch('/', function() {
|
||||||
|
|
||||||
dispatch_put('/settings', function() {
|
dispatch_put('/settings', function() {
|
||||||
exec('ip link show '.escapeshellarg($_POST['wifi_device']), $output, $retcode);
|
exec('ip link show '.escapeshellarg($_POST['wifi_device']), $output, $retcode);
|
||||||
$wifi_device_exists = ($retcode == 0);
|
|
||||||
|
|
||||||
$ip6_net = empty($_POST['ip6_net']) ? 'none' : $_POST['ip6_net'];
|
$wifi_device_exists = ($retcode == 0);
|
||||||
$ip6_addr = 'none';
|
|
||||||
$ip6_dns0 = $_POST['ip6_dns0'];
|
|
||||||
$ip6_dns1 = $_POST['ip6_dns1'];
|
|
||||||
$service_enabled = isset($_POST['service_enabled']) ? 1 : 0;
|
$service_enabled = isset($_POST['service_enabled']) ? 1 : 0;
|
||||||
$wifi_secure = isset($_POST['wifi_secure']) ? 1 : 0;
|
$ssids = array();
|
||||||
|
$id = 0;
|
||||||
|
|
||||||
if($service_enabled == 1) {
|
if($service_enabled == 1) {
|
||||||
try {
|
try {
|
||||||
if(empty($_POST['wifi_ssid']) || empty($_POST['wifi_passphrase']) || empty($_POST['wifi_channel'])) {
|
foreach($_POST['ssid'] as $key => $ssid) {
|
||||||
throw new Exception(T_('Your Wifi Hotspot needs a name, a password and a channel'));
|
$id = $key + 1;
|
||||||
}
|
|
||||||
|
|
||||||
if(strlen($_POST['wifi_passphrase']) < 8 || strlen($_POST['wifi_passphrase']) > 63) {
|
$ssid['ip6_net'] = empty($ssid['ip6_net']) ? 'none' : $ssid['ip6_net'];
|
||||||
throw new Exception(T_('Your password must from 8 to 63 characters (WPA2 passphrase)'));
|
$ssid['ip6_addr'] = 'none';
|
||||||
}
|
$ssid['wifi_secure'] = isset($ssid['wifi_secure']) ? 1 : 0;
|
||||||
|
|
||||||
if(preg_match('/[^[:print:]]/', $_POST['wifi_passphrase'])) {
|
if(!$ssid['wifi_secure']) {
|
||||||
throw new Exception(T_('Only printable ASCII characters are permitted in your password'));
|
$ssid['wifi_passphrase'] = 'none';
|
||||||
}
|
|
||||||
|
|
||||||
if(!$wifi_device_exists) {
|
|
||||||
throw new Exception(T_('The wifi antenna interface seems not exist on the system'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if($ip6_net != 'none') {
|
|
||||||
$ip6_net = ipv6_expanded($ip6_net);
|
|
||||||
|
|
||||||
if(empty($ip6_net)) {
|
|
||||||
throw new Exception(T_('The IPv6 Delegated Prefix format looks bad'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$ip6_blocs = explode(':', $ip6_net);
|
if(empty($ssid['wifi_ssid']) || empty($ssid['wifi_passphrase']) || empty($ssid['wifi_channel'])) {
|
||||||
$ip6_addr = "${ip6_blocs[0]}:${ip6_blocs[1]}:${ip6_blocs[2]}:${ip6_blocs[3]}:${ip6_blocs[4]}:${ip6_blocs[5]}:${ip6_blocs[6]}:42";
|
throw new Exception(T_('Your Wifi Hotspot needs a name, a password and a channel'));
|
||||||
|
|
||||||
$ip6_net = ipv6_compressed($ip6_net);
|
|
||||||
$ip6_addr = ipv6_compressed($ip6_addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!empty($ip6_dns0)) {
|
|
||||||
$ip6_dns0 = ipv6_expanded($ip6_dns0);
|
|
||||||
|
|
||||||
if(empty($ip6_dns0)) {
|
|
||||||
throw new Exception(T_('The format of the first IPv6 DNS Resolver looks bad'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$ip6_dns0 = ipv6_compressed($ip6_dns0);
|
if($ssid['wifi_secure'] && (strlen($ssid['wifi_passphrase']) < 8 || strlen($ssid['wifi_passphrase']) > 63)) {
|
||||||
|
throw new Exception(T_('Your password must from 8 to 63 characters (WPA2 passphrase)'));
|
||||||
|
}
|
||||||
|
|
||||||
if(!empty($ip6_dns1)) {
|
if($ssid['wifi_secure'] && preg_match('/[^[:print:]]/', $ssid['wifi_passphrase'])) {
|
||||||
$ip6_dns1 = ipv6_expanded($ip6_dns1);
|
throw new Exception(T_('Only printable ASCII characters are permitted in your password'));
|
||||||
|
}
|
||||||
|
|
||||||
if(empty($ip6_dns1)) {
|
if(!$wifi_device_exists) {
|
||||||
throw new Exception(T_('The format of the second IPv6 DNS Resolver looks bad'));
|
throw new Exception(T_('The wifi antenna interface seems not exist on the system'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if($ssid['ip6_net'] != 'none') {
|
||||||
|
$ssid['ip6_net'] = ipv6_expanded($ssid['ip6_net']);
|
||||||
|
|
||||||
|
if(empty($ssid['ip6_net'])) {
|
||||||
|
throw new Exception(T_('The IPv6 Delegated Prefix format looks bad'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$ip6_dns1 = ipv6_compressed($ip6_dns1);
|
$ip6_blocs = explode(':', $ssid['ip6_net']);
|
||||||
|
$ssid['ip6_addr'] = "${ip6_blocs[0]}:${ip6_blocs[1]}:${ip6_blocs[2]}:${ip6_blocs[3]}:${ip6_blocs[4]}:${ip6_blocs[5]}:${ip6_blocs[6]}:42";
|
||||||
|
|
||||||
|
$ssid['ip6_net'] = ipv6_compressed($ssid['ip6_net']);
|
||||||
|
$ssid['ip6_addr'] = ipv6_compressed($ssid['ip6_addr']);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(inet_pton($_POST['ip4_dns0']) === false) {
|
if(!empty($ssid['ip6_dns0'])) {
|
||||||
throw new Exception(T_('The format of the first IPv4 DNS Resolver looks bad'));
|
$ssid['ip6_dns0'] = ipv6_expanded($ssid['ip6_dns0']);
|
||||||
}
|
|
||||||
|
|
||||||
if(inet_pton($_POST['ip4_dns1']) === false) {
|
if(empty($ssid['ip6_dns0'])) {
|
||||||
throw new Exception(T_('The format of the second IPv4 DNS Resolver looks bad'));
|
throw new Exception(T_('The format of the first IPv6 DNS Resolver looks bad'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(inet_pton("${_POST['ip4_nat_prefix']}.0") === false) {
|
$ssid['ip6_dns0'] = ipv6_compressed($ssid['ip6_dns0']);
|
||||||
throw new Exception(T_('The format of the IPv4 NAT Prefix (/24) looks bad : x.x.x expected)'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(filter_var("${_POST['ip4_nat_prefix']}.0", FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE) !== false) {
|
if(!empty($ssid['ip6_dns1'])) {
|
||||||
throw new Exception(T_('The IPv4 NAT Prefix must be from a private range'));
|
$ssid['ip6_dns1'] = ipv6_expanded($ssid['ip6_dns1']);
|
||||||
}
|
|
||||||
|
|
||||||
|
if(empty($ssid['ip6_dns1'])) {
|
||||||
|
throw new Exception(T_('The format of the second IPv6 DNS Resolver looks bad'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$ssid['ip6_dns1'] = ipv6_compressed($ssid['ip6_dns1']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(inet_pton($ssid['ip4_dns0']) === false) {
|
||||||
|
throw new Exception(T_('The format of the first IPv4 DNS Resolver looks bad'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(inet_pton($ssid['ip4_dns1']) === false) {
|
||||||
|
throw new Exception(T_('The format of the second IPv4 DNS Resolver looks bad'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(inet_pton("${ssid['ip4_nat_prefix']}.0") === false) {
|
||||||
|
throw new Exception(T_('The format of the IPv4 NAT Prefix (/24) looks bad : x.x.x expected)'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(filter_var("${ssid['ip4_nat_prefix']}.0", FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE) !== false) {
|
||||||
|
throw new Exception(T_('The IPv4 NAT Prefix must be from a private range'));
|
||||||
|
}
|
||||||
|
|
||||||
|
array_push($ssids, $ssid);
|
||||||
|
}
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
flash('error', $e->getMessage().' ('.T_('configuration not updated').').');
|
flash('error', T_('SSID')." $id: ".$e->getMessage().' ('.T_('configuration not updated').').');
|
||||||
goto redirect;
|
goto redirect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_service();
|
//stop_service();
|
||||||
|
|
||||||
moulinette_set('service_enabled', $service_enabled);
|
moulinette_set('service_enabled', $service_enabled);
|
||||||
|
$settings = array();
|
||||||
|
|
||||||
if($service_enabled == 1) {
|
if($service_enabled == 1) {
|
||||||
moulinette_set('wifi_ssid', $_POST['wifi_ssid']);
|
foreach($ssids as $ssid) {
|
||||||
moulinette_set('wifi_secure', $wifi_secure);
|
foreach($ssid as $setting => $value) {
|
||||||
|
$settings[$setting] .= "$value|";
|
||||||
if($wifi_secure == 1) {
|
}
|
||||||
moulinette_set('wifi_passphrase', $_POST['wifi_passphrase']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
moulinette_set('wifi_channel', $_POST['wifi_channel']);
|
moulinette_set('multissid', count($ssids));
|
||||||
moulinette_set('wifi_n', isset($_POST['wifi_n']) ? 1 : 0);
|
|
||||||
moulinette_set('wifi_device', $_POST['wifi_device']);
|
|
||||||
moulinette_set('ip6_net', $ip6_net);
|
|
||||||
moulinette_set('ip6_addr', $ip6_addr);
|
|
||||||
moulinette_set('ip6_dns0', $_POST['ip6_dns0']);
|
|
||||||
moulinette_set('ip6_dns1', $_POST['ip6_dns1']);
|
|
||||||
moulinette_set('ip4_nat_prefix', $_POST['ip4_nat_prefix']);
|
|
||||||
moulinette_set('ip4_dns0', $_POST['ip4_dns0']);
|
|
||||||
moulinette_set('ip4_dns1', $_POST['ip4_dns1']);
|
|
||||||
|
|
||||||
$retcode = start_service();
|
foreach($settings as $setting => $value) {
|
||||||
|
moulinette_set($setting, preg_replace('/\|$/', '', $value));
|
||||||
|
}
|
||||||
|
|
||||||
|
//$retcode = start_service();
|
||||||
|
|
||||||
if($retcode == 0) {
|
if($retcode == 0) {
|
||||||
flash('success', T_('Configuration updated and service successfully reloaded'));
|
flash('success', T_('Configuration updated and service successfully reloaded'));
|
||||||
|
|
|
@ -140,3 +140,15 @@ div#wifiparty_passphrase span.passother {
|
||||||
div#wifiparty_passphrase span.passspace {
|
div#wifiparty_passphrase span.passspace {
|
||||||
color: #CCC;
|
color: #CCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul.nav-tabs {
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.tabs {
|
||||||
|
padding: 14px 14px 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.tabs a {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
|
@ -16,35 +16,47 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
function wifiSecureBtn() {
|
||||||
|
if($(this).parent().hasClass('off')) {
|
||||||
|
$(this).closest('.form-group').next().hide('slow');
|
||||||
|
} else {
|
||||||
|
$(this).closest('.form-group').next().show('slow');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function tabsClick() {
|
||||||
|
var ssid = $(this).closest('.ssid');
|
||||||
|
var tab = $(this).parent().attr('data-tab');
|
||||||
|
|
||||||
|
ssid.find('li.active').removeClass('active');
|
||||||
|
$(this).parent().addClass('active');
|
||||||
|
|
||||||
|
ssid.find('.tabs').hide();
|
||||||
|
ssid.find('.tab' + tab).show();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function dropDownClick() {
|
||||||
|
var menu = $(this).parent();
|
||||||
|
var items = menu.children();
|
||||||
|
var button = menu.prev();
|
||||||
|
var input = button.prev();
|
||||||
|
|
||||||
|
items.removeClass('active');
|
||||||
|
$(this).addClass('active');
|
||||||
|
|
||||||
|
button.text($(this).text());
|
||||||
|
button.append(' <span class="caret"></span>');
|
||||||
|
|
||||||
|
input.val($(this).text());
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('.btn-group').button();
|
$('.btn-group').button();
|
||||||
$('[data-toggle="tooltip"]').tooltip();
|
$('[data-toggle="tooltip"]').tooltip();
|
||||||
|
|
||||||
$('.fileinput').click(function() {
|
$('.dropdown-menu li').click(dropDownClick);
|
||||||
var realinputid = '#' + $(this).attr('id').replace(/_chooser.*/, '');
|
|
||||||
$(realinputid).click();
|
|
||||||
});
|
|
||||||
|
|
||||||
$('input[type="file"]').change(function() {
|
|
||||||
var choosertxtid = '#' + $(this).attr('id') + '_choosertxt';
|
|
||||||
|
|
||||||
$(choosertxtid).val($(this).val().replace(/^.*[\/\\]/, ''));
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.dropdown-menu li').click(function() {
|
|
||||||
var menu = $(this).parent();
|
|
||||||
var items = menu.children();
|
|
||||||
var button = menu.prev();
|
|
||||||
var input = button.prev();
|
|
||||||
|
|
||||||
items.removeClass('active');
|
|
||||||
$(this).addClass('active');
|
|
||||||
|
|
||||||
button.text($(this).text());
|
|
||||||
button.append(' <span class="caret"></span>');
|
|
||||||
|
|
||||||
input.attr('value', $(this).text());
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.switch').bootstrapToggle();
|
$('.switch').bootstrapToggle();
|
||||||
|
|
||||||
|
@ -78,7 +90,7 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#wifiparty').click(function() {
|
$('.wifiparty').click(function() {
|
||||||
$('#wifiparty_screen').show('slow');
|
$('#wifiparty_screen').show('slow');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -102,13 +114,7 @@ $(document).ready(function() {
|
||||||
$('#wifiparty_screen').hide();
|
$('#wifiparty_screen').hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#wifi_secure').change(function() {
|
$('.wifi_secure').change(wifiSecureBtn);
|
||||||
if($('#wifi_secure').parent().hasClass('off')) {
|
|
||||||
$('.secure').hide('slow');
|
|
||||||
} else {
|
|
||||||
$('.secure').show('slow');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#service_enabled').change(function() {
|
$('#service_enabled').change(function() {
|
||||||
if($('#service_enabled').parent().hasClass('off')) {
|
if($('#service_enabled').parent().hasClass('off')) {
|
||||||
|
@ -117,6 +123,54 @@ $(document).ready(function() {
|
||||||
$('.enabled').show('slow');
|
$('.enabled').show('slow');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('.nav-tabs a').click(tabsClick);
|
||||||
|
|
||||||
|
$('#newssid').click(function() {
|
||||||
|
var clone = $('#ssids').children().first().clone();
|
||||||
|
var id = parseInt($('.ssid').length);
|
||||||
|
|
||||||
|
clone.find('.dropdownmenu').each(function(i) {
|
||||||
|
var initial = $('#ssids').children().first().find('.dropdownmenu');
|
||||||
|
var clone = initial.eq(i).clone(true, true);
|
||||||
|
|
||||||
|
$(this).after(clone);
|
||||||
|
$(this).remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
clone.find('[name]').each(function() {
|
||||||
|
$(this).attr('name', $(this).attr('name').replace('[0]', '[' + id + ']'));
|
||||||
|
});
|
||||||
|
|
||||||
|
clone.find('[data-toggle="tooltip"]').tooltip();
|
||||||
|
|
||||||
|
clone.find('input[type=text]').each(function() {
|
||||||
|
if($(this).attr('name').match('dns')) {
|
||||||
|
$(this).val($(this).attr('placeholder'));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$(this).val('');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
clone.find('input[type=checkbox]').each(function() {
|
||||||
|
$(this).parent().after($(this));
|
||||||
|
$(this).prev().remove();
|
||||||
|
$(this).attr('checked', false);
|
||||||
|
});
|
||||||
|
|
||||||
|
clone.find('.switch').bootstrapToggle();
|
||||||
|
clone.find('.wifi_secure').change(wifiSecureBtn);
|
||||||
|
clone.find('.nav-tabs a').click(tabsClick);
|
||||||
|
clone.find('.dropdown-menu li').click(dropDownClick);
|
||||||
|
clone.find('.wifi_passphrase').hide();
|
||||||
|
|
||||||
|
clone.find('h3').each(function() {
|
||||||
|
$(this).text($(this).data('label') + ' ' + (id + 1));
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#ssids').append(clone);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).keydown(function(e) {
|
$(document).keydown(function(e) {
|
||||||
|
|
118
sources/views/_ssid.html.php
Normal file
118
sources/views/_ssid.html.php
Normal file
|
@ -0,0 +1,118 @@
|
||||||
|
<div class="panel panel-default ssid enabled" <?= $service_enabled == 0 ? 'style="display: none"' : '' ?>>
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h3 class="panel-title" data-label="<?= T_("SSID") ?>"><?= T_("SSID") ?> <?= $ssid['id'] + 1 ?></h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="nav nav-tabs nav-justified">
|
||||||
|
<li role="presentation" data-tab="wifi" class="active"><a href="#"><?= T_("Wifi") ?></a></li>
|
||||||
|
<li role="presentation" data-tab="ipv6"><a href="#"><?= T_("IPv6") ?></a></li>
|
||||||
|
<li role="presentation" data-tab="ipv4"><a href="#"><?= T_("IPv4") ?></a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<!-- Wifi -->
|
||||||
|
<div class="tabs tabwifi">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label"><?= T_('Name (SSID)') ?></label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input type="text" class="form-control" name="ssid[<?= $ssid['id'] ?>][wifi_ssid]" placeholder="myNeutralNetwork" value="<?= $ssid['wifi_ssid'] ?>" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="wifi_secure" class="col-sm-3 control-label"><?= T_('Secure') ?></label>
|
||||||
|
<div class="col-sm-9 input-group-btn" data-toggle="tooltip" data-title="<?= T_('Disabling the Secure Wifi allows everyone to join the hotspot and spy the traffic (but it\'s perfect for a PirateBox)') ?>">
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="checkbox" class="form-control switch wifi_secure" name="ssid[<?= $ssid['id'] ?>][wifi_secure]" value="1" <?= $ssid['wifi_secure'] == 1 ? 'checked="checked"' : '' ?> />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group wifi_passphrase" <?= $ssid['wifi_secure'] == 0 ? 'style="display: none"' : '' ?>>
|
||||||
|
<label class="col-sm-3 control-label"><?= T_('Password (WPA2)') ?></label>
|
||||||
|
<div class="input-group col-sm-9" style="padding: 0 15px">
|
||||||
|
<input type="text" data-toggle="tooltip" data-title="<?= T_('At least 8 characters') ?>" class="form-control" name="ssid[<?= $ssid['id'] ?>][wifi_passphrase]" placeholder="VhegT8oev0jZI" value="<?= $ssid['wifi_passphrase'] ?>" />
|
||||||
|
<a class="btn input-group-addon wifiparty" data-toggle="tooltip" data-title="<?= T_('Show to your friends how to access to your hotspot') ?>"><span class="glyphicon glyphicon-fullscreen"></span></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label"><?= T_('Channel') ?></label>
|
||||||
|
<div class="col-sm-9 input-group-btn">
|
||||||
|
<div class="input-group dropdownmenu">
|
||||||
|
<input type="text" name="ssid[<?= $ssid['id'] ?>][wifi_channel]" value="<?= $ssid['wifi_channel'] ?>" style="display: none" />
|
||||||
|
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><?= $ssid['wifi_channel'] ?> <span class="caret"></span></button>
|
||||||
|
<ul class="dropdown-menu dropdown-menu-left" role="menu">
|
||||||
|
<li <?= $ssid['wifi_channel'] == 1 ? 'class="active"' : '' ?>><a href="javascript:;">1</a></li>
|
||||||
|
<li <?= $ssid['wifi_channel'] == 2 ? 'class="active"' : '' ?>><a href="javascript:;">2</a></li>
|
||||||
|
<li <?= $ssid['wifi_channel'] == 3 ? 'class="active"' : '' ?>><a href="javascript:;">3</a></li>
|
||||||
|
<li <?= $ssid['wifi_channel'] == 4 ? 'class="active"' : '' ?>><a href="javascript:;">4</a></li>
|
||||||
|
<li <?= $ssid['wifi_channel'] == 5 ? 'class="active"' : '' ?>><a href="javascript:;">5</a></li>
|
||||||
|
<li <?= $ssid['wifi_channel'] == 6 ? 'class="active"' : '' ?>><a href="javascript:;">6</a></li>
|
||||||
|
<li <?= $ssid['wifi_channel'] == 7 ? 'class="active"' : '' ?>><a href="javascript:;">7</a></li>
|
||||||
|
<li <?= $ssid['wifi_channel'] == 8 ? 'class="active"' : '' ?>><a href="javascript:;">8</a></li>
|
||||||
|
<li <?= $ssid['wifi_channel'] == 9 ? 'class="active"' : '' ?>><a href="javascript:;">9</a></li>
|
||||||
|
<li <?= $ssid['wifi_channel'] == 10 ? 'class="active"' : '' ?>><a href="javascript:;">10</a></li>
|
||||||
|
<li <?= $ssid['wifi_channel'] == 11 ? 'class="active"' : '' ?>><a href="javascript:;">11</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- IPv6 -->
|
||||||
|
<div class="tabs tabipv6" style="display: none">
|
||||||
|
<?php if(empty($ssid['ip6_net'])): ?>
|
||||||
|
<div class="alert alert-dismissible alert-warning fade in" style="margin: 2px 2px 17px" role="alert">
|
||||||
|
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||||
|
<strong><?= T_('Notice') ?>:</strong> <?= T_("Currently, your wifi clients don't have IPv6 and it's a very bad thing. Ask your Internet Service Provider an IPv6 delegated prefix, or") ?>
|
||||||
|
<a href="http://db.ffdn.org" class="alert-link"><?= T_('change providers') ?></a>!
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label"><?= T_('Delegated prefix') ?></label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input type="text" class="form-control" name="ssid[<?= $ssid['id'] ?>][ip6_net]" placeholder="2001:db8:42::" value="<?= $ssid['ip6_net'] ?>" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label"><?= T_('First DNS resolver') ?></label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input type="text" class="form-control" name="ssid[<?= $ssid['id'] ?>][ip6_dns0]" placeholder="2001:913::8" value="<?= $ssid['ip6_dns0'] ?>" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label"><?= T_('Second DNS resolver') ?></label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input type="text" class="form-control" name="ssid[<?= $ssid['id'] ?>][ip6_dns1]" placeholder="2001:910:800::40" value="<?= $ssid['ip6_dns1'] ?>" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- IPv4 -->
|
||||||
|
<div class="tabs tabipv4" style="display: none">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label"><?= T_('NAT prefix (/24)') ?></label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input type="text" class="form-control" name="ssid[<?= $ssid['id'] ?>][ip4_nat_prefix]" placeholder="10.0.242" value="<?= $ssid['ip4_nat_prefix'] ?>" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label"><?= T_('First DNS resolver') ?></label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input type="text" class="form-control" name="ssid[<?= $ssid['id'] ?>][ip4_dns0]" placeholder="80.67.188.188" value="<?= $ssid['ip4_dns0'] ?>" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label"><?= T_('Second DNS resolver') ?></label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input type="text" class="form-control" name="ssid[<?= $ssid['id'] ?>][ip4_dns1]" placeholder="80.67.169.12" value="<?= $ssid['ip4_dns1'] ?>" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
|
@ -70,78 +70,13 @@
|
||||||
|
|
||||||
<div style="padding: 14px 14px 0 10px">
|
<div style="padding: 14px 14px 0 10px">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="wifi_secure" class="col-sm-3 control-label"><?= T_('Hotspot Enabled') ?></label>
|
<label for="service_enabled" class="col-sm-3 control-label"><?= T_('Hotspot Enabled') ?></label>
|
||||||
<div class="col-sm-9 input-group-btn">
|
<div class="col-sm-9 input-group-btn">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="checkbox" class="form-control switch" name="service_enabled" id="service_enabled" value="1" <?= $service_enabled == 1 ? 'checked="checked"' : '' ?> />
|
<input type="checkbox" class="form-control switch" name="service_enabled" id="service_enabled" value="1" <?= $service_enabled == 1 ? 'checked="checked"' : '' ?> />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="panel panel-default enabled" <?= $service_enabled == 0 ? 'style="display: none"' : '' ?>>
|
|
||||||
<div class="panel-heading">
|
|
||||||
<h3 class="panel-title"><?= T_("Wifi") ?></h3>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="padding: 14px 14px 0 10px">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="wifi_ssid" class="col-sm-3 control-label"><?= T_('Name (SSID)') ?></label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input type="text" class="form-control" name="wifi_ssid" id="wifi_ssid" placeholder="myNeutralNetwork" value="<?= $wifi_ssid ?>" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="wifi_secure" class="col-sm-3 control-label"><?= T_('Secure') ?></label>
|
|
||||||
<div class="col-sm-9 input-group-btn" data-toggle="tooltip" data-title="<?= T_('Disabling the Secure Wifi allows everyone to join the hotspot and spy the traffic (but it\'s perfect for a PirateBox)') ?>">
|
|
||||||
<div class="input-group">
|
|
||||||
<input type="checkbox" class="form-control switch" name="wifi_secure" id="wifi_secure" value="1" <?= $wifi_secure == 1 ? 'checked="checked"' : '' ?> />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group secure" <?= $wifi_secure == 0 ? 'style="display: none"' : '' ?>>
|
|
||||||
<label for="wifi_passphrase" class="col-sm-3 control-label"><?= T_('Password (WPA2)') ?></label>
|
|
||||||
<div class="input-group col-sm-9" style="padding: 0 15px">
|
|
||||||
<input type="text" data-toggle="tooltip" data-title="<?= T_('At least 8 characters') ?>" class="form-control" name="wifi_passphrase" id="wifi_passphrase" placeholder="VhegT8oev0jZI" value="<?= $wifi_passphrase ?>" />
|
|
||||||
<a class="btn input-group-addon" id="wifiparty" data-toggle="tooltip" data-title="<?= T_('Show to your friends how to access to your hotspot') ?>"><span class="glyphicon glyphicon-fullscreen"></span></a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="wifi_channel" class="col-sm-3 control-label"><?= T_('Channel') ?></label>
|
|
||||||
<div class="col-sm-9 input-group-btn">
|
|
||||||
<div class="input-group">
|
|
||||||
<input type="text" name="wifi_channel" id="wifi_channel" value="<?= $wifi_channel ?>" style="display: none" />
|
|
||||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><?= $wifi_channel ?> <span class="caret"></span></button>
|
|
||||||
<ul class="dropdown-menu dropdown-menu-left" role="menu">
|
|
||||||
<li <?= $wifi_channel == 1 ? 'class="active"' : '' ?>><a href="#">1</a></li>
|
|
||||||
<li <?= $wifi_channel == 2 ? 'class="active"' : '' ?>><a href="#">2</a></li>
|
|
||||||
<li <?= $wifi_channel == 3 ? 'class="active"' : '' ?>><a href="#">3</a></li>
|
|
||||||
<li <?= $wifi_channel == 4 ? 'class="active"' : '' ?>><a href="#">4</a></li>
|
|
||||||
<li <?= $wifi_channel == 5 ? 'class="active"' : '' ?>><a href="#">5</a></li>
|
|
||||||
<li <?= $wifi_channel == 6 ? 'class="active"' : '' ?>><a href="#">6</a></li>
|
|
||||||
<li <?= $wifi_channel == 7 ? 'class="active"' : '' ?>><a href="#">7</a></li>
|
|
||||||
<li <?= $wifi_channel == 8 ? 'class="active"' : '' ?>><a href="#">8</a></li>
|
|
||||||
<li <?= $wifi_channel == 9 ? 'class="active"' : '' ?>><a href="#">9</a></li>
|
|
||||||
<li <?= $wifi_channel == 10 ? 'class="active"' : '' ?>><a href="#">10</a></li>
|
|
||||||
<li <?= $wifi_channel == 11 ? 'class="active"' : '' ?>><a href="#">11</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group" style="display: none">
|
|
||||||
<label for="wifi_n" class="col-sm-3 control-label"><?= T_('Wifi N') ?></label>
|
|
||||||
<div class="col-sm-9 input-group-btn" data-toggle="tooltip" data-title="<?= T_('Only if your antenna is 802.11n compliant') ?>">
|
|
||||||
<div class="input-group">
|
|
||||||
<input type="checkbox" class="form-control switch" name="wifi_n" id="wifi_n" value="1" <?= $wifi_n == 1 ? 'checked="checked"' : '' ?> />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="wifi_device" class="col-sm-3 control-label"><?= T_('Device') ?></label>
|
<label for="wifi_device" class="col-sm-3 control-label"><?= T_('Device') ?></label>
|
||||||
<div class="col-sm-9 input-group-btn">
|
<div class="col-sm-9 input-group-btn">
|
||||||
|
@ -157,71 +92,14 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel panel-success enabled" <?= $service_enabled == 0 ? 'style="display: none"' : '' ?>>
|
<div id="ssids">
|
||||||
<div class="panel-heading">
|
<?php foreach($ssids as $ssid): ?>
|
||||||
<h3 class="panel-title" data-toggle="tooltip" data-title="<?= T_('Real Internet') ?>"><?= T_("IPv6") ?></h3>
|
<?php set('ssid', $ssid) ?>
|
||||||
</div>
|
<?= partial('_ssid.html.php') ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
<div style="padding: 14px 14px 0 10px">
|
|
||||||
<?php if(empty($ip6_net)): ?>
|
|
||||||
<div class="alert alert-dismissible alert-warning fade in" style="margin: 2px 2px 17px" role="alert">
|
|
||||||
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
|
||||||
<strong><?= T_('Notice') ?>:</strong> <?= T_("Currently, your wifi clients don't have IPv6 and it's a very bad thing. Ask your Internet Service Provider an IPv6 delegated prefix, or") ?>
|
|
||||||
<a href="http://db.ffdn.org" class="alert-link"><?= T_('change providers') ?></a>!
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="ip6_net" class="col-sm-3 control-label"><?= T_('Delegated prefix') ?></label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input type="text" class="form-control" name="ip6_net" id="ip6_net" placeholder="2001:db8:42::" value="<?= $ip6_net ?>" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="ip6_dns0" class="col-sm-3 control-label"><?= T_('First DNS resolver') ?></label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input type="text" class="form-control" name="ip6_dns0" id="ip6_dns0" placeholder="2001:913::8" value="<?= $ip6_dns0 ?>" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="ip6_dns1" class="col-sm-3 control-label"><?= T_('Second DNS resolver') ?></label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input type="text" class="form-control" name="ip6_dns1" id="ip6_dns1" placeholder="2001:910:800::40" value="<?= $ip6_dns1 ?>" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel panel-danger enabled" <?= $service_enabled == 0 ? 'style="display: none"' : '' ?>>
|
<button id="newssid" type="button" class="btn btn-default">Add</button>
|
||||||
<div class="panel-heading">
|
|
||||||
<h3 class="panel-title" data-toggle="tooltip" data-title="<?= T_('Old Internet') ?>"><?= T_("IPv4") ?></h3>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="padding: 14px 14px 0 10px">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="ip4_nat_prefix" class="col-sm-3 control-label"><?= T_('NAT prefix (/24)') ?></label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input type="text" class="form-control" name="ip4_nat_prefix" id="ip4_nat_prefix" placeholder="10.0.242" value="<?= $ip4_nat_prefix ?>" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="ip4_dns0" class="col-sm-3 control-label"><?= T_('First DNS resolver') ?></label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input type="text" class="form-control" name="ip4_dns0" id="ip4_dns0" placeholder="80.67.188.188" value="<?= $ip4_dns0 ?>" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="ip4_dns1" class="col-sm-3 control-label"><?= T_('Second DNS resolver') ?></label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input type="text" class="form-control" name="ip4_dns1" id="ip4_dns1" placeholder="80.67.169.12" value="<?= $ip4_dns1 ?>" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div style="text-align: center">
|
<div style="text-align: center">
|
||||||
|
|
Loading…
Reference in a new issue