}
    }
    stop_service();
    ynh_setting_set('service_enabled', $service_enabled);
    $settings = array();
    if ($service_enabled == 1) {
        foreach ($ssids as $ssid) {
            foreach ($ssid as $setting => $value) {
                $settings[$setting] .= "{$value}|";
            }
        }
        ynh_setting_set('multissid', count($ssids));
        ynh_setting_set('wifi_device', $_POST['wifi_device']);
        ynh_setting_set('wifi_channel', $_POST['wifi_channel']);
        foreach ($settings as $setting => $value) {
            ynh_setting_set($setting, preg_replace('/\\|$/', '', $value));
        }
        $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();
                throw new Exception(_('You need to select an associated hotspot'));
            }
        } catch (Exception $e) {
            flash('error', _('PirateBox') . " {$id}: " . $e->getMessage() . ' (' . _('configuration not updated') . ').');
            goto redirect;
        }
    }
    stop_service();
    ynh_setting_set('service_enabled', $service_enabled);
    if ($service_enabled == 1) {
        ynh_setting_set('opt_name', $_POST['opt_name']);
        ynh_setting_set('opt_renaming', isset($_POST['opt_renaming']) ? 1 : 0);
        ynh_setting_set('opt_maxspace', $_POST['opt_maxspace']);
        ynh_setting_set('opt_deleting', isset($_POST['opt_deleting']) ? 1 : 0);
        ynh_setting_set('opt_chat', isset($_POST['opt_chat']) ? 1 : 0);
        ynh_setting_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 = '';
Exemple #3
0
         }
     } catch (Exception $e) {
         flash('error', $e->getMessage() . ' (' . _('configuration not updated') . ').');
         goto redirect;
     }
 }
 stop_service();
 ynh_setting_set('service_enabled', $service_enabled);
 if ($service_enabled == 1) {
     ynh_setting_set('server_name', $_POST['server_name']);
     ynh_setting_set('server_port', $_POST['server_port']);
     ynh_setting_set('server_proto', $_POST['server_proto']);
     ynh_setting_set('login_user', $_POST['login_user']);
     ynh_setting_set('login_passphrase', $_POST['login_passphrase']);
     ynh_setting_set('ip6_net', $ip6_net);
     ynh_setting_set('ip6_addr', $ip6_addr);
     file_put_contents('/etc/openvpn/client.conf.tpl', $_POST['raw_openvpn']);
     if ($_FILES['crt_client']['error'] == UPLOAD_ERR_OK) {
         move_uploaded_file($_FILES['crt_client']['tmp_name'], '/etc/openvpn/keys/user.crt');
     } elseif ($_POST['crt_client_delete'] == 1) {
         unlink('/etc/openvpn/keys/user.crt');
     }
     if ($_FILES['crt_client_key']['error'] == UPLOAD_ERR_OK) {
         move_uploaded_file($_FILES['crt_client_key']['tmp_name'], '/etc/openvpn/keys/user.key');
     } elseif ($_POST['crt_client_key_delete'] == 1) {
         unlink('/etc/openvpn/keys/user.key');
     }
     if ($_FILES['crt_server_ca']['error'] == UPLOAD_ERR_OK) {
         move_uploaded_file($_FILES['crt_server_ca']['tmp_name'], '/etc/openvpn/keys/ca-server.crt');
     }
     if (!empty($_POST['login_user'])) {