".htmlentities($ssids[$i]).'';
}
set('faststatus', service_faststatus() == 0);
set('service_enabled', moulinette_get('service_enabled'));
set('wifi_device_id', $wifi_device_id);
set('wifi_ssid', $wifi_ssid);
set('wifi_ssid_list', $wifi_ssid_list);
return render('settings.html.php');
});
dispatch_put('/settings', function() {
$service_enabled = isset($_POST['service_enabled']) ? 1 : 0;
if($service_enabled == 1) {
try {
if($_POST['wifi_device_id'] == -1) {
throw new Exception(_('You need to select an associated hotspot'));
}
} catch(Exception $e) {
flash('error', $e->getMessage().' ('._('configuration not updated').').');
goto redirect;
}
}
stop_service();
moulinette_set('service_enabled', $service_enabled);
if($service_enabled == 1) {
moulinette_set('wifi_device_id', $_POST['wifi_device_id']);
$retcode = start_service();
if($retcode == 0) {
flash('success', _('Configuration updated and service successfully reloaded'));
} else {
flash('error', _('Configuration updated but service reload failed'));
}
} else {
flash('success', _('Service successfully disabled'));
}
redirect:
redirect_to('/');
});
dispatch('/status', function() {
$status_lines = service_status();
$status_list = '';
foreach($status_lines AS $status_line) {
if(preg_match('/^\[INFO\]/', $status_line)) {
$status_list .= ''.htmlspecialchars($status_line).'';
}
elseif(preg_match('/^\[OK\]/', $status_line)) {
$status_list .= ''.htmlspecialchars($status_line).'';
}
elseif(preg_match('/^\[WARN\]/', $status_line)) {
$status_list .= ''.htmlspecialchars($status_line).'';
}
elseif(preg_match('/^\[ERR\]/', $status_line)) {
$status_list .= ''.htmlspecialchars($status_line).'';
}
}
echo $status_list;
});
dispatch('/lang/:locale', function($locale = 'en') {
switch($locale) {
case 'fr':
$_SESSION['locale'] = 'fr';
break;
default:
$_SESSION['locale'] = 'en';
}
redirect_to('/');
});