diff --git a/src/www/vpn_openvpn_export_shared.php b/src/www/vpn_openvpn_export_shared.php
index e2ed59e05..962462293 100644
--- a/src/www/vpn_openvpn_export_shared.php
+++ b/src/www/vpn_openvpn_export_shared.php
@@ -36,138 +36,122 @@ require_once("openvpn-client-export.inc");
$pgtitle = array("OpenVPN", "Client Export Utility");
-if (!isset($config['openvpn']['openvpn-server'])) {
- $config['openvpn']['openvpn-server'] = array();
-}
-
-$a_server = $config['openvpn']['openvpn-server'];
-
$ras_server = array();
-foreach ($a_server as $sindex => $server) {
- if (isset($server['disable'])) {
- continue;
- }
- $ras_user = array();
- if ($server['mode'] != "p2p_shared_key") {
- continue;
- }
+if (isset($config['openvpn']['openvpn-server'])) {
+ foreach ($config['openvpn']['openvpn-server'] as $sindex => $server) {
+ if (isset($server['disable'])) {
+ continue;
+ }
+ $ras_user = array();
+ if ($server['mode'] != "p2p_shared_key") {
+ continue;
+ }
- $ras_serverent = array();
- $prot = $server['protocol'];
- $port = $server['local_port'];
- if ($server['description']) {
- $name = "{$server['description']} {$prot}:{$port}";
- } else {
- $name = "Shared Key Server {$prot}:{$port}";
- }
- $ras_serverent['index'] = $sindex;
- $ras_serverent['name'] = $name;
- $ras_serverent['mode'] = $server['mode'];
- $ras_server[] = $ras_serverent;
+ $ras_serverent = array();
+ $prot = $server['protocol'];
+ $port = $server['local_port'];
+ if ($server['description']) {
+ $name = "{$server['description']} {$prot}:{$port}";
+ } else {
+ $name = "Shared Key Server {$prot}:{$port}";
+ }
+ $ras_serverent['index'] = $sindex;
+ $ras_serverent['name'] = $name;
+ $ras_serverent['mode'] = $server['mode'];
+ $ras_server[] = $ras_serverent;
+ }
}
-$id = $_GET['id'];
-if (isset($_POST['id'])) {
- $id = $_POST['id'];
-}
-
-$act = $_GET['act'];
-if (isset($_POST['act'])) {
- $act = $_POST['act'];
-}
-
-$error = false;
-
-if (($act == "skconf") || ($act == "skzipconf")) {
- $srvid = $_GET['srvid'];
- if (($srvid === false) || ($config['openvpn']['openvpn-server'][$srvid]['mode'] != "p2p_shared_key")) {
- redirectHeader("vpn_openvpn_export.php");
- exit;
- }
-
- if (empty($_GET['useaddr'])) {
- $error = true;
- $input_errors[] = "You need to specify an IP or hostname.";
- } else {
- $useaddr = $_GET['useaddr'];
- }
-
- $proxy = "";
- if (!empty($_GET['proxy_addr']) || !empty($_GET['proxy_port'])) {
- $proxy = array();
- if (empty($_GET['proxy_addr'])) {
- $error = true;
- $input_errors[] = "You need to specify an address for the proxy port.";
- } else {
- $proxy['ip'] = $_GET['proxy_addr'];
+if (isset($_GET['act'])) {
+ $input_errors = array();
+ $act = $_GET['act'];
+ if (($act == "skconf") || ($act == "skzipconf")) {
+ $srvid = isset($_GET['srvid']) ? $_GET['srvid'] : false;
+ if ( $srvid === false || !isset($config['openvpn']['openvpn-server'][$srvid]['mode']) ||
+ $config['openvpn']['openvpn-server'][$srvid]['mode'] != "p2p_shared_key") {
+ redirectHeader("vpn_openvpn_export.php");
+ exit;
}
- if (empty($_GET['proxy_port'])) {
- $error = true;
- $input_errors[] = "You need to specify a port for the proxy ip.";
+
+ if (empty($_GET['useaddr'])) {
+ $input_errors[] = "You need to specify an IP or hostname.";
} else {
- $proxy['port'] = $_GET['proxy_port'];
+ $useaddr = $_GET['useaddr'];
}
- $proxy['proxy_type'] = $_GET['proxy_type'];
- $proxy['proxy_authtype'] = $_GET['proxy_authtype'];
- if ($_GET['proxy_authtype'] != "none") {
- if (empty($_GET['proxy_user'])) {
- $error = true;
- $input_errors[] = "You need to specify a username with the proxy config.";
+
+ $proxy = "";
+ if (!empty($_GET['proxy_addr']) || !empty($_GET['proxy_port'])) {
+ $proxy = array();
+ if (empty($_GET['proxy_addr'])) {
+ $input_errors[] = "You need to specify an address for the proxy port.";
} else {
- $proxy['user'] = $_GET['proxy_user'];
+ $proxy['ip'] = $_GET['proxy_addr'];
}
- if (!empty($_GET['proxy_user']) && empty($_GET['proxy_password'])) {
- $error = true;
- $input_errors[] = "You need to specify a password with the proxy user.";
+ if (empty($_GET['proxy_port'])) {
+ $input_errors[] = "You need to specify a port for the proxy ip.";
} else {
- $proxy['password'] = $_GET['proxy_password'];
+ $proxy['port'] = $_GET['proxy_port'];
+ }
+ $proxy['proxy_type'] = $_GET['proxy_type'];
+ $proxy['proxy_authtype'] = $_GET['proxy_authtype'];
+ if ($_GET['proxy_authtype'] != "none") {
+ if (empty($_GET['proxy_user'])) {
+ $input_errors[] = "You need to specify a username with the proxy config.";
+ } else {
+ $proxy['user'] = $_GET['proxy_user'];
+ }
+ if (!empty($_GET['proxy_user']) && empty($_GET['proxy_password'])) {
+ $input_errors[] = "You need to specify a password with the proxy user.";
+ } else {
+ $proxy['password'] = $_GET['proxy_password'];
+ }
}
}
- }
- $exp_name = openvpn_client_export_prefix($srvid);
- if ($act == "skzipconf") {
- $zipconf = true;
- }
- $exp_data = openvpn_client_export_sharedkey_config($srvid, $useaddr, $proxy, $zipconf);
- if (!$exp_data) {
- $input_errors[] = "Failed to export config files!";
- $error = true;
- }
- if (!$error) {
- if ($zipconf) {
- $exp_name = urlencode($exp_data);
- $exp_size = filesize("/tmp/{$exp_data}");
- } else {
- $exp_name = urlencode($exp_name."-config.ovpn");
- $exp_size = strlen($exp_data);
+ $exp_name = openvpn_client_export_prefix($srvid);
+ if ($act == "skzipconf") {
+ $zipconf = true;
}
-
- header('Pragma: ');
- header('Cache-Control: ');
- header("Content-Type: application/octet-stream");
- header("Content-Disposition: attachment; filename={$exp_name}");
- header("Content-Length: $exp_size");
- if ($zipconf) {
- readfile("/tmp/{$exp_data}");
- } else {
- echo $exp_data;
+ $exp_data = openvpn_client_export_sharedkey_config($srvid, $useaddr, $proxy, $zipconf);
+ if (!$exp_data) {
+ $input_errors[] = "Failed to export config files!";
}
+ if (count($input_errors) == 0) {
+ if ($zipconf) {
+ $exp_name = urlencode($exp_data);
+ $exp_size = filesize("/tmp/{$exp_data}");
+ } else {
+ $exp_name = urlencode($exp_name."-config.ovpn");
+ $exp_size = strlen($exp_data);
+ }
- @unlink("/tmp/{$exp_data}");
- exit;
+ header('Pragma: ');
+ header('Cache-Control: ');
+ header("Content-Type: application/octet-stream");
+ header("Content-Disposition: attachment; filename={$exp_name}");
+ header("Content-Length: $exp_size");
+ if ($zipconf) {
+ readfile("/tmp/{$exp_data}");
+ } else {
+ echo $exp_data;
+ }
+
+ @unlink("/tmp/{$exp_data}");
+ exit;
+ }
}
}
include("head.inc");
-
?>
-
+
@@ -300,199 +290,122 @@ if (isset($savemsg)) {
print_info_box($savemsg);
}
?>
-
-
-
-
-
-
-
-
-
-
-
- Shared Key Server
-
-
-
+
+
+
+
+
+
+
+
+
+
+ =gettext("full help"); ?>
+
+
+
+
+ =gettext("Shared Key Server");?>
+
+
+
+ =htmlspecialchars($server['name']);?>
+
+
+
+
+
+ =gettext("Host Name Resolution");?>
+
+
+ =gettext("Interface IP Address");?>
+ =gettext("Installation hostname");?>
+
- =$server['name'];?>
-
+ ">=gettext("DynDNS:");?> = htmlspecialchars($ddns["host"]);?>
+
-
-
-
-
- Host Name Resolution
-
-
-
-
-
- Use Proxy
-
-
+
+
+
+
+
+
-
-
-
- Use proxy to communicate with the server.
-
-
-
-
-
-
-
-
-
-
-
- Client Configuration Packages
-
-
-
-
- =gettext("Client Type");?>
- =gettext("Export");?>
-
-
-
-
- = gettext("NOTE:") ?>
- = gettext("These are shared key configurations for use in site-to-site tunnels with other routers. Shared key tunnels are not normally used for remote access connections to end users.") ?>
-
-
-
-
-
-
-
-
-