Projet

Général

Profil

Télécharger (44,5 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / vpn_openvpn_client.php @ b9e9903d

1
<?php
2
/*
3
	vpn_openvpn_client.php
4

    
5
	Copyright (C) 2008 Shrew Soft Inc.
6
	All rights reserved.
7

    
8
	Redistribution and use in source and binary forms, with or without
9
	modification, are permitted provided that the following conditions are met:
10

    
11
	1. Redistributions of source code must retain the above copyright notice,
12
	   this list of conditions and the following disclaimer.
13

    
14
	2. Redistributions in binary form must reproduce the above copyright
15
	   notice, this list of conditions and the following disclaimer in the
16
	   documentation and/or other materials provided with the distribution.
17

    
18
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
	POSSIBILITY OF SUCH DAMAGE.
28
*/
29

    
30
##|+PRIV
31
##|*IDENT=page-openvpn-client
32
##|*NAME=OpenVPN: Client page
33
##|*DESCR=Allow access to the 'OpenVPN: Client' page.
34
##|*MATCH=vpn_openvpn_client.php*
35
##|-PRIV
36

    
37
require("guiconfig.inc");
38
require_once("openvpn.inc");
39

    
40
$pgtitle = array(gettext("OpenVPN"), gettext("Client"));
41
$shortcut_section = "openvpn";
42

    
43
if (!is_array($config['openvpn']['openvpn-client']))
44
	$config['openvpn']['openvpn-client'] = array();
45

    
46
$a_client = &$config['openvpn']['openvpn-client'];
47

    
48
if (!is_array($config['ca']))
49
	$config['ca'] = array();
50

    
51
$a_ca =& $config['ca'];
52

    
53
if (!is_array($config['cert']))
54
	$config['cert'] = array();
55

    
56
$a_cert =& $config['cert'];
57

    
58
if (!is_array($config['crl']))
59
	$config['crl'] = array();
60

    
61
$a_crl =& $config['crl'];
62

    
63
if (is_numericint($_GET['id']))
64
	$id = $_GET['id'];
65
if (isset($_POST['id']) && is_numericint($_POST['id']))
66
	$id = $_POST['id'];
67

    
68
$act = $_GET['act'];
69
if (isset($_POST['act']))
70
	$act = $_POST['act'];
71

    
72
if (isset($id) && $a_client[$id])
73
	$vpnid = $a_client[$id]['vpnid'];
74
else
75
	$vpnid = 0;
76

    
77
if ($_GET['act'] == "del") {
78

    
79
	if (!isset($a_client[$id])) {
80
		pfSenseHeader("vpn_openvpn_client.php");
81
		exit;
82
	}
83
	if (!empty($a_client[$id]))
84
		openvpn_delete('client', $a_client[$id]);
85
	unset($a_client[$id]);
86
	write_config();
87
	$savemsg = gettext("Client successfully deleted")."<br />";
88
}
89

    
90
if($_GET['act']=="new"){
91
	$pconfig['autokey_enable'] = "yes";
92
	$pconfig['tlsauth_enable'] = "yes";
93
	$pconfig['autotls_enable'] = "yes";
94
	$pconfig['interface'] = "wan";
95
	$pconfig['server_port'] = 1194;
96
	$pconfig['verbosity_level'] = 1; // Default verbosity is 1
97
	// OpenVPN Defaults to SHA1
98
	$pconfig['digest'] = "SHA1";
99
}
100

    
101
global $simplefields;
102
$simplefields = array('auth_user','auth_pass');
103

    
104
if($_GET['act']=="edit"){
105

    
106
	if (isset($id) && $a_client[$id]) {
107
		foreach($simplefields as $stat)
108
			$pconfig[$stat] = $a_client[$id][$stat];
109

    
110
		$pconfig['disable'] = isset($a_client[$id]['disable']);
111
		$pconfig['mode'] = $a_client[$id]['mode'];
112
		$pconfig['protocol'] = $a_client[$id]['protocol'];
113
		$pconfig['interface'] = $a_client[$id]['interface'];
114
		if (!empty($a_client[$id]['ipaddr'])) {
115
			$pconfig['interface'] = $pconfig['interface'] . '|' . $a_client[$id]['ipaddr'];
116
		}
117
		$pconfig['local_port'] = $a_client[$id]['local_port'];
118
		$pconfig['server_addr'] = $a_client[$id]['server_addr'];
119
		$pconfig['server_port'] = $a_client[$id]['server_port'];
120
		$pconfig['resolve_retry'] = $a_client[$id]['resolve_retry'];
121
		$pconfig['proxy_addr'] = $a_client[$id]['proxy_addr'];
122
		$pconfig['proxy_port'] = $a_client[$id]['proxy_port'];
123
		$pconfig['proxy_user'] = $a_client[$id]['proxy_user'];
124
		$pconfig['proxy_passwd'] = $a_client[$id]['proxy_passwd'];
125
		$pconfig['proxy_authtype'] = $a_client[$id]['proxy_authtype'];
126
		$pconfig['description'] = $a_client[$id]['description'];
127
		$pconfig['custom_options'] = $a_client[$id]['custom_options'];
128
		$pconfig['ns_cert_type'] = $a_client[$id]['ns_cert_type'];
129
		$pconfig['dev_mode'] = $a_client[$id]['dev_mode'];
130

    
131
		if ($pconfig['mode'] != "p2p_shared_key") {
132
			$pconfig['caref'] = $a_client[$id]['caref'];
133
			$pconfig['certref'] = $a_client[$id]['certref'];
134
			if ($a_client[$id]['tls']) {
135
				$pconfig['tlsauth_enable'] = "yes";
136
				$pconfig['tls'] = base64_decode($a_client[$id]['tls']);
137
			}
138
		} else
139
			$pconfig['shared_key'] = base64_decode($a_client[$id]['shared_key']);
140
		$pconfig['crypto'] = $a_client[$id]['crypto'];
141
		// OpenVPN Defaults to SHA1 if unset
142
		$pconfig['digest'] = !empty($a_client[$id]['digest']) ? $a_client[$id]['digest'] : "SHA1";
143
		$pconfig['engine'] = $a_client[$id]['engine'];
144

    
145
		$pconfig['tunnel_network'] = $a_client[$id]['tunnel_network'];
146
		$pconfig['tunnel_networkv6'] = $a_client[$id]['tunnel_networkv6'];
147
		$pconfig['remote_network'] = $a_client[$id]['remote_network'];
148
		$pconfig['remote_networkv6'] = $a_client[$id]['remote_networkv6'];
149
		$pconfig['use_shaper'] = $a_client[$id]['use_shaper'];
150
		$pconfig['compression'] = $a_client[$id]['compression'];
151
		$pconfig['passtos'] = $a_client[$id]['passtos'];
152

    
153
		// just in case the modes switch
154
		$pconfig['autokey_enable'] = "yes";
155
		$pconfig['autotls_enable'] = "yes";
156
		
157
		// New features
158
		$pconfig['no_tun_ipv6'] = $a_client[$id]['no_tun_ipv6'];
159
		$pconfig['route_no_pull'] = $a_client[$id]['route_no_pull'];
160
		$pconfig['route_no_exec'] = $a_client[$id]['route_no_exec'];
161
		$pconfig['verbosity_level'] = $a_client[$id]['verbosity_level'];
162
	}
163
}
164

    
165
if ($_POST) {
166

    
167
	unset($input_errors);
168
	$pconfig = $_POST;
169

    
170
	if (isset($id) && $a_client[$id])
171
		$vpnid = $a_client[$id]['vpnid'];
172
	else
173
		$vpnid = 0;
174

    
175
	list($iv_iface, $iv_ip) = explode ("|",$pconfig['interface']);
176
	if (is_ipaddrv4($iv_ip) && (stristr($pconfig['protocol'], "6") !== false)) {
177
		$input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv6 protocol and an IPv4 IP address.");
178
	} elseif (is_ipaddrv6($iv_ip) && (stristr($pconfig['protocol'], "6") === false)) {
179
		$input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv4 protocol and an IPv6 IP address.");
180
	} elseif ((stristr($pconfig['protocol'], "6") === false) && !get_interface_ip($iv_iface) && ($pconfig['interface'] != "any")) {
181
		$input_errors[] = gettext("An IPv4 protocol was selected, but the selected interface has no IPv4 address.");
182
	} elseif ((stristr($pconfig['protocol'], "6") !== false) && !get_interface_ipv6($iv_iface) && ($pconfig['interface'] != "any")) {
183
		$input_errors[] = gettext("An IPv6 protocol was selected, but the selected interface has no IPv6 address.");
184
	}
185

    
186
	if ($pconfig['mode'] != "p2p_shared_key")
187
		$tls_mode = true;
188
	else
189
		$tls_mode = false;
190

    
191
	/* input validation */
192
	if ($pconfig['local_port']) {
193

    
194
		if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port'))
195
			$input_errors[] = $result;
196

    
197
		$portused = openvpn_port_used($pconfig['protocol'], $pconfig['interface'], $pconfig['local_port'], $vpnid);
198
		if (($portused != $vpnid) && ($portused != 0))
199
			$input_errors[] = gettext("The specified 'Local port' is in use. Please select another value");
200
	}
201

    
202
	if ($result = openvpn_validate_host($pconfig['server_addr'], 'Server host or address'))
203
		$input_errors[] = $result;
204

    
205
	if ($result = openvpn_validate_port($pconfig['server_port'], 'Server port'))
206
		$input_errors[] = $result;
207

    
208
	if ($pconfig['proxy_addr']) {
209

    
210
		if ($result = openvpn_validate_host($pconfig['proxy_addr'], 'Proxy host or address'))
211
			$input_errors[] = $result;
212

    
213
		if ($result = openvpn_validate_port($pconfig['proxy_port'], 'Proxy port'))
214
			$input_errors[] = $result;
215

    
216
		if ($pconfig['proxy_authtype'] != "none") {
217
			if (empty($pconfig['proxy_user']) || empty($pconfig['proxy_passwd']))
218
				$input_errors[] = gettext("User name and password are required for proxy with authentication.");
219
		}
220
	}
221

    
222
	if($pconfig['tunnel_network'])
223
		if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'IPv4 Tunnel Network', false, "ipv4"))
224
			$input_errors[] = $result;
225

    
226
	if($pconfig['tunnel_networkv6'])
227
		if ($result = openvpn_validate_cidr($pconfig['tunnel_networkv6'], 'IPv6 Tunnel Network', false, "ipv6"))
228
			$input_errors[] = $result;
229

    
230
	if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'IPv4 Remote Network', true, "ipv4"))
231
		$input_errors[] = $result;
232

    
233
	if ($result = openvpn_validate_cidr($pconfig['remote_networkv6'], 'IPv6 Remote Network', true, "ipv6"))
234
		$input_errors[] = $result;
235

    
236
	if (!empty($pconfig['use_shaper']) && (!is_numeric($pconfig['use_shaper']) || ($pconfig['use_shaper'] <= 0)))
237
		$input_errors[] = gettext("The bandwidth limit must be a positive numeric value.");
238

    
239
	if ($pconfig['autokey_enable'])
240
		$pconfig['shared_key'] = openvpn_create_key();
241

    
242
	if (!$tls_mode && !$pconfig['autokey_enable'])
243
		if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") ||
244
			!strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----"))
245
			$input_errors[] = gettext("The field 'Shared Key' does not appear to be valid");
246

    
247
	if ($tls_mode && $pconfig['tlsauth_enable'] && !$pconfig['autotls_enable'])
248
		if (!strstr($pconfig['tls'], "-----BEGIN OpenVPN Static key V1-----") ||
249
			!strstr($pconfig['tls'], "-----END OpenVPN Static key V1-----"))
250
			$input_errors[] = gettext("The field 'TLS Authentication Key' does not appear to be valid");
251

    
252
	/* If we are not in shared key mode, then we need the CA/Cert. */
253
	if ($pconfig['mode'] != "p2p_shared_key") {
254
		$reqdfields = explode(" ", "caref");
255
		$reqdfieldsn = array(gettext("Certificate Authority"));
256
	} elseif (!$pconfig['autokey_enable']) {
257
		/* We only need the shared key filled in if we are in shared key mode and autokey is not selected. */
258
		$reqdfields = array('shared_key');
259
		$reqdfieldsn = array(gettext('Shared key'));
260
	}
261

    
262
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
263

    
264
	if (($pconfig['mode'] != "p2p_shared_key") && empty($pconfig['certref']) && empty($pconfig['auth_user']) && empty($pconfig['auth_pass'])) {
265
		$input_errors[] = gettext("If no Client Certificate is selected, a username and password must be entered.");
266
	}
267

    
268
	if (!$input_errors) {
269

    
270
		$client = array();
271

    
272
		foreach($simplefields as $stat)
273
			update_if_changed($stat, $client[$stat], $_POST[$stat]);
274

    
275
		if ($vpnid)
276
			$client['vpnid'] = $vpnid;
277
		else
278
			$client['vpnid'] = openvpn_vpnid_next();
279

    
280
		if ($_POST['disable'] == "yes")
281
			$client['disable'] = true;
282
		$client['protocol'] = $pconfig['protocol'];
283
		$client['dev_mode'] = $pconfig['dev_mode'];
284
		list($client['interface'], $client['ipaddr']) = explode ("|",$pconfig['interface']);
285
		$client['local_port'] = $pconfig['local_port'];
286
		$client['server_addr'] = $pconfig['server_addr'];
287
		$client['server_port'] = $pconfig['server_port'];
288
		$client['resolve_retry'] = $pconfig['resolve_retry'];
289
		$client['proxy_addr'] = $pconfig['proxy_addr'];
290
		$client['proxy_port'] = $pconfig['proxy_port'];
291
		$client['proxy_authtype'] = $pconfig['proxy_authtype'];
292
		$client['proxy_user'] = $pconfig['proxy_user'];
293
		$client['proxy_passwd'] = $pconfig['proxy_passwd'];
294
		$client['description'] = $pconfig['description'];
295
		$client['mode'] = $pconfig['mode'];
296
		$client['custom_options'] = str_replace("\r\n", "\n", $pconfig['custom_options']);
297

    
298
		if ($tls_mode) {
299
			$client['caref'] = $pconfig['caref'];
300
			$client['certref'] = $pconfig['certref'];
301
			if ($pconfig['tlsauth_enable']) {
302
				if ($pconfig['autotls_enable'])
303
					$pconfig['tls'] = openvpn_create_key();
304
				$client['tls'] = base64_encode($pconfig['tls']);
305
			}
306
		} else {
307
			$client['shared_key'] = base64_encode($pconfig['shared_key']);
308
		}
309
		$client['crypto'] = $pconfig['crypto'];
310
		$client['digest'] = $pconfig['digest'];
311
		$client['engine'] = $pconfig['engine'];
312

    
313
		$client['tunnel_network'] = $pconfig['tunnel_network'];
314
		$client['tunnel_networkv6'] = $pconfig['tunnel_networkv6'];
315
		$client['remote_network'] = $pconfig['remote_network'];
316
		$client['remote_networkv6'] = $pconfig['remote_networkv6'];
317
		$client['use_shaper'] = $pconfig['use_shaper'];
318
		$client['compression'] = $pconfig['compression'];
319
		$client['passtos'] = $pconfig['passtos'];
320

    
321
		// New features
322
		$client['no_tun_ipv6'] = $pconfig['no_tun_ipv6'];
323
		$client['route_no_pull'] = $pconfig['route_no_pull'];
324
		$client['route_no_exec'] = $pconfig['route_no_exec'];
325
		$client['verbosity_level'] = $pconfig['verbosity_level'];
326

    
327
		if (isset($id) && $a_client[$id])
328
			$a_client[$id] = $client;
329
		else
330
			$a_client[] = $client;
331

    
332
		openvpn_resync('client', $client);
333
		write_config();
334

    
335
		header("Location: vpn_openvpn_client.php");
336
		exit;
337
	}
338
}
339

    
340
include("head.inc");
341

    
342
?>
343

    
344
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
345
<?php include("fbegin.inc"); ?>
346
<script type="text/javascript">
347
//<![CDATA[
348

    
349
function mode_change() {
350
	index = document.iform.mode.selectedIndex;
351
	value = document.iform.mode.options[index].value;
352
	switch(value) {
353
		case "p2p_tls":
354
			document.getElementById("tls").style.display="";
355
			document.getElementById("tls_ca").style.display="";
356
			document.getElementById("tls_cert").style.display="";
357
			document.getElementById("psk").style.display="none";
358
			break;
359
		case "p2p_shared_key":
360
			document.getElementById("tls").style.display="none";
361
			document.getElementById("tls_ca").style.display="none";
362
			document.getElementById("tls_cert").style.display="none";
363
			document.getElementById("psk").style.display="";
364
			break;
365
	}
366
}
367

    
368
function dev_mode_change() {
369
	index = document.iform.dev_mode.selectedIndex;
370
	value = document.iform.dev_mode.options[index].value;
371
	switch(value) {
372
		case "tun":
373
			document.getElementById("chkboxNoTunIPv6").style.display="";
374
			break;
375
		case "tap":
376
			document.getElementById("chkboxNoTunIPv6").style.display="none";
377
			break;
378
	}
379
}
380

    
381
function autokey_change() {
382
	if (document.iform.autokey_enable.checked)
383
		document.getElementById("autokey_opts").style.display="none";
384
	else
385
		document.getElementById("autokey_opts").style.display="";
386
}
387

    
388
function useproxy_changed() {
389

    
390
	if (jQuery('#proxy_authtype').val() != 'none') {
391
		jQuery('#proxy_authtype_opts').show();
392
	} else {
393
		jQuery('#proxy_authtype_opts').hide();
394
	}
395
}
396

    
397
function tlsauth_change() {
398

    
399
<?php if (!$pconfig['tls']): ?>
400
	if (document.iform.tlsauth_enable.checked)
401
		document.getElementById("tlsauth_opts").style.display="";
402
	else
403
		document.getElementById("tlsauth_opts").style.display="none";
404
<?php endif; ?>
405

    
406
	autotls_change();
407
}
408

    
409
function autotls_change() {
410

    
411
<?php if (!$pconfig['tls']): ?>
412
	autocheck = document.iform.autotls_enable.checked;
413
<?php else: ?>
414
	autocheck = false;
415
<?php endif; ?>
416

    
417
	if (document.iform.tlsauth_enable.checked && !autocheck)
418
		document.getElementById("autotls_opts").style.display="";
419
	else
420
		document.getElementById("autotls_opts").style.display="none";
421
}
422

    
423
//]]>
424
</script>
425
<?php
426
if (!$savemsg)
427
	$savemsg = "";
428

    
429
if ($input_errors)
430
	print_input_errors($input_errors);
431
if ($savemsg)
432
	print_info_box($savemsg);
433
?>
434
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="vpn openvpn client">
435
	<tr>
436
		<td class="tabnavtbl">
437
			<?php
438
				$tab_array = array();
439
				$tab_array[] = array(gettext("Server"), false, "vpn_openvpn_server.php");
440
				$tab_array[] = array(gettext("Client"), true, "vpn_openvpn_client.php");
441
				$tab_array[] = array(gettext("Client Specific Overrides"), false, "vpn_openvpn_csc.php");
442
				$tab_array[] = array(gettext("Wizards"), false, "wizard.php?xml=openvpn_wizard.xml");
443
				add_package_tabs("OpenVPN", $tab_array);
444
				display_top_tabs($tab_array);
445
			?>
446
		</td>
447
	</tr>
448
	<tr>
449
		<td class="tabcont">
450

    
451
			<?php if($act=="new" || $act=="edit"): ?>
452

    
453
			<form action="vpn_openvpn_client.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
454
				<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="general information">
455
					<tr>
456
						<td colspan="2" valign="top" class="listtopic"><?=gettext("General information"); ?></td>
457
					</tr>
458
					<tr>
459
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled"); ?></td>
460
						<td width="78%" class="vtable">
461
							<table border="0" cellpadding="0" cellspacing="0" summary="enable disable client">
462
								<tr>
463
									<td>
464
										<?php set_checked($pconfig['disable'],$chk); ?>
465
										<input name="disable" type="checkbox" value="yes" <?=$chk;?> />
466
									</td>
467
									<td>
468
										&nbsp;
469
										<span class="vexpl">
470
											<strong><?=gettext("Disable this client"); ?></strong><br />
471
										</span>
472
									</td>
473
								</tr>
474
							</table>
475
							<?=gettext("Set this option to disable this client without removing it from the list"); ?>.
476
						</td>
477
					</tr>
478
					<tr>
479
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server Mode");?></td>
480
						<td width="78%" class="vtable">
481
							<select name="mode" id="mode" class="formselect" onchange="mode_change()">
482
							<?php
483
								foreach ($openvpn_client_modes as $name => $desc):
484
									$selected = "";
485
									if ($pconfig['mode'] == $name)
486
										$selected = "selected=\"selected\"";
487
							?>
488
								<option value="<?=$name;?>" <?=$selected;?>><?=$desc;?></option>
489
							<?php endforeach; ?>
490
							</select>
491
						</td>
492
					</tr>
493
					<tr>
494
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
495
							<td width="78%" class="vtable">
496
							<select name='protocol' class="formselect">
497
							<?php
498
								foreach ($openvpn_prots as $prot):
499
									$selected = "";
500
									if ($pconfig['protocol'] == $prot)
501
										$selected = "selected=\"selected\"";
502
							?>
503
								<option value="<?=$prot;?>" <?=$selected;?>><?=$prot;?></option>
504
							<?php endforeach; ?>
505
							</select>
506
							</td>
507
					</tr>
508
					<tr>
509
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Device mode");?></td>
510
							<td width="78%" class="vtable">
511
							<select name='dev_mode' class="formselect" onchange="dev_mode_change()">
512
							<?php
513
								foreach ($openvpn_dev_mode as $mode):
514
									$selected = "";
515
									if ($pconfig['dev_mode'] == $mode)
516
										$selected = "selected=\"selected\"";
517
							?>
518
								<option value="<?=$mode;?>" <?=$selected;?>><?=$mode;?></option>
519
							<?php endforeach; ?>
520
							</select>
521
							</td>
522
					</tr>
523
					<tr>
524
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td>
525
						<td width="78%" class="vtable">
526
							<select name="interface" class="formselect">
527
								<?php
528
									$interfaces = get_configured_interface_with_descr();
529
									$carplist = get_configured_carp_interface_list();
530
									foreach ($carplist as $cif => $carpip)
531
										$interfaces[$cif.'|'.$carpip] = $carpip." (".get_vip_descr($carpip).")";
532
									$aliaslist = get_configured_ip_aliases_list();
533
									foreach ($aliaslist as $aliasip => $aliasif)
534
										$interfaces[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
535
									$grouplist = return_gateway_groups_array();
536
									foreach ($grouplist as $name => $group) {
537
										if($group['ipprotocol'] != inet)
538
											continue;
539
										if($group[0]['vip'] <> "")
540
											$vipif = $group[0]['vip'];
541
										else
542
											$vipif = $group[0]['int'];
543
										$interfaces[$name] = "GW Group {$name}";
544
									}
545
									$interfaces['lo0'] = "Localhost";
546
									$interfaces['any'] = "any";
547
									foreach ($interfaces as $iface => $ifacename):
548
										$selected = "";
549
										if ($iface == $pconfig['interface'])
550
											$selected = "selected=\"selected\"";
551
								?>
552
									<option value="<?=$iface;?>" <?=$selected;?>>
553
										<?=htmlspecialchars($ifacename);?>
554
									</option>
555
								<?php endforeach; ?>
556
							</select> <br />
557
						</td>
558
					</tr>
559
					<tr>
560
						<td width="22%" valign="top" class="vncell"><?=gettext("Local port");?></td>
561
						<td width="78%" class="vtable">
562
							<input name="local_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['local_port']);?>" />
563
							<br />
564
							<?=gettext("Set this option if you would like to bind to a specific port. Leave this blank or enter 0 for a random dynamic port."); ?>
565
						</td>
566
					</tr>
567
					<tr>
568
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server host or address");?></td>
569
						<td width="78%" class="vtable">
570
							<input name="server_addr" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['server_addr']);?>" />
571
						</td>
572
					</tr>
573
					<tr>
574
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server port");?></td>
575
						<td width="78%" class="vtable">
576
							<input name="server_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['server_port']);?>" />
577
						</td>
578
					</tr>
579
					<tr>
580
						<td width="22%" valign="top" class="vncell"><?=gettext("Proxy host or address");?></td>
581
						<td width="78%" class="vtable">
582
							<input name="proxy_addr" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['proxy_addr']);?>" />
583
						</td>
584
					</tr>
585
					<tr>
586
						<td width="22%" valign="top" class="vncell"><?=gettext("Proxy port");?></td>
587
						<td width="78%" class="vtable">
588
							<input name="proxy_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['proxy_port']);?>" />
589
						</td>
590
					</tr>
591
					<tr>
592
						<td width="22%" valign="top" class="vncell"><?=gettext("Proxy authentication extra options");?></td>
593
						<td width="78%" class="vtable">
594
							<table border="0" cellpadding="2" cellspacing="0" summary="proxy authentication">
595
								<tr>
596
									<td align="right" width="25%">
597
										<span class="vexpl">
598
											 &nbsp;<?=gettext("Authentication method"); ?> :&nbsp;
599
										</span>
600
									</td>
601
									<td>
602
										<select name="proxy_authtype" id="proxy_authtype" class="formfld select" onchange="useproxy_changed()">
603
											<option value="none" <?php if ($pconfig['proxy_authtype'] == "none") echo "selected=\"selected\""; ?>><?=gettext("none"); ?></option>
604
											<option value="basic" <?php if ($pconfig['proxy_authtype'] == "basic") echo "selected=\"selected\""; ?>><?=gettext("basic"); ?></option>
605
											<option value="ntlm" <?php if ($pconfig['proxy_authtype'] == "ntlm") echo "selected=\"selected\""; ?>><?=gettext("ntlm"); ?></option>
606
										</select>
607
									</td>
608
								</tr>
609
							</table>
610
							<br />
611
							 <table border="0" cellpadding="2" cellspacing="0" id="proxy_authtype_opts" style="display:none" summary="proxy authentication options">
612
								<tr>
613
									<td align="right" width="25%">
614
										<span class="vexpl">
615
											 &nbsp;<?=gettext("Username"); ?> :&nbsp;
616
										</span>
617
									</td>
618
									<td>
619
										<input name="proxy_user" id="proxy_user" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['proxy_user']);?>" />
620
									</td>
621
								</tr>
622
								<tr>
623
									<td align="right" width="25%">
624
										<span class="vexpl">
625
											 &nbsp;<?=gettext("Password"); ?> :&nbsp;
626
										</span>
627
									</td>
628
									<td>
629
										<input name="proxy_passwd" id="proxy_passwd" type="password" class="formfld pwd" size="20" value="<?=htmlspecialchars($pconfig['proxy_passwd']);?>" />
630
									</td>
631
								</tr>
632
							</table>
633
						</td>
634
					</tr>
635
					<tr>
636
						<td width="22%" valign="top" class="vncell"><?=gettext("Server host name resolution"); ?></td>
637
						<td width="78%" class="vtable">
638
							<table border="0" cellpadding="2" cellspacing="0" summary="server host name resolution">
639
								<tr>
640
									<td>
641
										<?php set_checked($pconfig['resolve_retry'],$chk); ?>
642
										<input name="resolve_retry" type="checkbox" value="yes" <?=$chk;?> />
643
									</td>
644
									<td>
645
										<span class="vexpl">
646
											<?=gettext("Infinitely resolve server"); ?>
647
										</span>
648
									</td>
649
								</tr>
650
							</table>
651
							<?=gettext("Continuously attempt to resolve the server host " .
652
							"name. Useful when communicating with a server " .
653
							"that is not permanently connected to the Internet"); ?>.
654
						</td>
655
					</tr>
656
					<tr>
657
						<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
658
						<td width="78%" class="vtable">
659
							<input name="description" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['description']);?>" />
660
							<br />
661
							<?=gettext("You may enter a description here for your reference (not parsed)"); ?>.
662
						</td>
663
					</tr>
664
					<tr>
665
						<td colspan="2" class="list" height="12"></td>
666
					</tr>
667
					<tr>
668
						<td colspan="2" valign="top" class="listtopic"><?=gettext("User Authentication Settings"); ?></td>
669
					</tr>
670
					<tr>
671
						<td width="22%" valign="top" class="vncell"><?=gettext("User name/pass"); ?></td>
672
						<td width="78%" class="vtable">
673
							<?=gettext("Leave empty when no user name and password are needed."); ?>
674
							<br/>
675
							<table border="0" cellpadding="2" cellspacing="0" summary="user name password">
676
								<tr>
677
									<td align="right" width="25%">
678
									<span class="vexpl">
679
									&nbsp;<?=gettext("Username"); ?> :&nbsp;
680
									</span>
681
									</td>
682
									<td>
683
									<input name="auth_user" id="auth_user" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['auth_user']);?>" />
684
									</td>
685
								</tr>
686
								<tr>
687
									<td align="right" width="25%">
688
									<span class="vexpl">
689
									&nbsp;<?=gettext("Password"); ?> :&nbsp;
690
									</span>
691
									</td>
692
									<td>
693
									<input name="auth_pass" id="auth_pass" type="password" class="formfld pwd" size="20" value="<?=htmlspecialchars($pconfig['auth_pass']);?>" />
694
									</td>
695
								</tr>
696
							</table>
697
						</td>
698
					</tr>
699
					<tr>
700
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Cryptographic Settings"); ?></td>
701
					</tr>
702
					<tr id="tls">
703
						<td width="22%" valign="top" class="vncellreq"><?=gettext("TLS Authentication"); ?></td>
704
						<td width="78%" class="vtable">
705
							<table border="0" cellpadding="2" cellspacing="0" summary="tls authentication">
706
								<tr>
707
									<td>
708
										<?php set_checked($pconfig['tlsauth_enable'],$chk); ?>
709
										<input name="tlsauth_enable" id="tlsauth_enable" type="checkbox" value="yes" <?=$chk;?> onclick="tlsauth_change()" />
710
									</td>
711
									<td>
712
										<span class="vexpl">
713
											<?=gettext("Enable authentication of TLS packets"); ?>.
714
										</span>
715
									</td>
716
								</tr>
717
							</table>
718
							<?php if (!$pconfig['tls']): ?>
719
							<table border="0" cellpadding="2" cellspacing="0" id="tlsauth_opts" summary="tls authentication options">
720
								<tr>
721
									<td>
722
										<?php set_checked($pconfig['autotls_enable'],$chk); ?>
723
										<input name="autotls_enable" id="autotls_enable" type="checkbox" value="yes" <?=$chk;?> onclick="autotls_change()" />
724
									</td>
725
									<td>
726
										<span class="vexpl">
727
											<?=gettext("Automatically generate a shared TLS authentication key"); ?>.
728
										</span>
729
									</td>
730
								</tr>
731
							</table>
732
							<?php endif; ?>
733
							<table border="0" cellpadding="2" cellspacing="0" id="autotls_opts" summary="tls authentication options">
734
								<tr>
735
									<td>
736
										<textarea name="tls" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['tls']);?></textarea>
737
										<br />
738
										<?=gettext("Paste your shared key here"); ?>.
739
									</td>
740
								</tr>
741
							</table>
742
						</td>
743
					</tr>
744
					<tr id="tls_ca">
745
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Peer Certificate Authority"); ?></td>
746
							<td width="78%" class="vtable">
747
							<?php if (count($a_ca)): ?>
748
							<select name='caref' class="formselect">
749
							<?php
750
								foreach ($a_ca as $ca):
751
									$selected = "";
752
									if ($pconfig['caref'] == $ca['refid'])
753
										$selected = "selected=\"selected\"";
754
							?>
755
								<option value="<?=$ca['refid'];?>" <?=$selected;?>><?=$ca['descr'];?></option>
756
							<?php endforeach; ?>
757
							</select>
758
							<?php else: ?>
759
								<b>No Certificate Authorities defined.</b> <br />Create one under <a href="system_camanager.php">System &gt; Cert Manager</a>.
760
							<?php endif; ?>
761
							</td>
762
					</tr>
763
					<tr id="tls_cert">
764
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Client Certificate"); ?></td>
765
							<td width="78%" class="vtable">
766
							<select name='certref' class="formselect">
767
							<?php
768
							foreach ($a_cert as $cert):
769
								$selected = "";
770
								$caname = "";
771
								$inuse = "";
772
								$revoked = "";
773
								$ca = lookup_ca($cert['caref']);
774
								if ($ca)
775
									$caname = " (CA: {$ca['descr']})";
776
								if ($pconfig['certref'] == $cert['refid'])
777
									$selected = "selected=\"selected\"";
778
								if (cert_in_use($cert['refid']))
779
									$inuse = " *In Use";
780
								if (is_cert_revoked($cert))
781
									$revoked = " *Revoked";
782
							?>
783
								<option value="<?=$cert['refid'];?>" <?=$selected;?>><?=$cert['descr'] . $caname . $inuse . $revoked;?></option>
784
							<?php endforeach; ?>
785
								<option value="" <?PHP if (empty($pconfig['certref'])) echo "selected=\"selected\""; ?>>None (Username and Password required)</option>
786
							</select>
787
							<?php if (!count($a_cert)): ?>
788
								<b>No Certificates defined.</b> <br />Create one under <a href="system_certmanager.php">System &gt; Cert Manager</a> if one is required for this connection.
789
							<?php endif; ?>
790
						</td>
791
					</tr>
792
					<tr id="psk">
793
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Shared Key"); ?></td>
794
						<td width="78%" class="vtable">
795
							<?php if (!$pconfig['shared_key']): ?>
796
							<table border="0" cellpadding="2" cellspacing="0" summary="shared key">
797
								<tr>
798
									<td>
799
										<?php set_checked($pconfig['autokey_enable'],$chk); ?>
800
										<input name="autokey_enable" type="checkbox" value="yes" <?=$chk;?> onclick="autokey_change()" />
801
									</td>
802
									<td>
803
										<span class="vexpl">
804
											<?=gettext("Automatically generate a shared key"); ?>.
805
										</span>
806
									</td>
807
								</tr>
808
							</table>
809
							<?php endif; ?>
810
							<table border="0" cellpadding="2" cellspacing="0" id="autokey_opts" summary="shared key options">
811
								<tr>
812
									<td>
813
										<textarea name="shared_key" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['shared_key']);?></textarea>
814
										<br />
815
										<?=gettext("Paste your shared key here"); ?>.
816
									</td>
817
								</tr>
818
							</table>
819
						</td>
820
					</tr>
821
					<tr>
822
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Encryption algorithm"); ?></td>
823
						<td width="78%" class="vtable">
824
							<select name="crypto" class="formselect">
825
								<?php
826
									$cipherlist = openvpn_get_cipherlist();
827
									foreach ($cipherlist as $name => $desc):
828
									$selected = "";
829
									if ($name == $pconfig['crypto'])
830
										$selected = " selected=\"selected\"";
831
								?>
832
								<option value="<?=$name;?>"<?=$selected?>>
833
									<?=htmlspecialchars($desc);?>
834
								</option>
835
								<?php endforeach; ?>
836
							</select>
837
						</td>
838
					</tr>
839
					<tr>
840
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Auth Digest Algorithm"); ?></td>
841
						<td width="78%" class="vtable">
842
							<select name="digest" class="formselect">
843
								<?php
844
									$digestlist = openvpn_get_digestlist();
845
									foreach ($digestlist as $name => $desc):
846
									$selected = "";
847
									if ($name == $pconfig['digest'])
848
										$selected = " selected=\"selected\"";
849
								?>
850
								<option value="<?=$name;?>"<?=$selected?>>
851
									<?=htmlspecialchars($desc);?>
852
								</option>
853
								<?php endforeach; ?>
854
							</select>
855
						</td>
856
					</tr>
857
					<tr id="engine">
858
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Hardware Crypto"); ?></td>
859
						<td width="78%" class="vtable">
860
							<select name="engine" class="formselect">
861
								<?php
862
									$engines = openvpn_get_engines();
863
									foreach ($engines as $name => $desc):
864
									$selected = "";
865
									if ($name == $pconfig['engine'])
866
										$selected = " selected=\"selected\"";
867
								?>
868
								<option value="<?=$name;?>"<?=$selected?>>
869
									<?=htmlspecialchars($desc);?>
870
								</option>
871
								<?php endforeach; ?>
872
							</select>
873
						</td>
874
					</tr>
875
					<tr>
876
						<td colspan="2" class="list" height="12"></td>
877
					</tr>
878
					<tr>
879
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Tunnel Settings"); ?></td>
880
					</tr>
881
					<tr>
882
						<td width="22%" valign="top" class="vncell"><?=gettext("IPv4 Tunnel Network"); ?></td>
883
						<td width="78%" class="vtable">
884
							<input name="tunnel_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['tunnel_network']);?>" />
885
							<br />
886
							<?=gettext("This is the virtual network used for private " .
887
							"communications between this client and the " .
888
							"server expressed using CIDR (eg. 10.0.8.0/24). " .
889
							"The first network address is assumed to be the " .
890
							"server address and the second network address " .
891
							"will be assigned to the client virtual " .
892
							"interface"); ?>.
893
						</td>
894
					</tr>
895
					<tr>
896
						<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Tunnel Network"); ?></td>
897
						<td width="78%" class="vtable">
898
							<input name="tunnel_networkv6" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['tunnel_networkv6']);?>" />
899
							<br />
900
							<?=gettext("This is the IPv6 virtual network used for private " .
901
							"communications between this client and the " .
902
							"server expressed using CIDR (eg. fe80::/64). " .
903
							"The first network address is assumed to be the " .
904
							"server address and the second network address " .
905
							"will be assigned to the client virtual " .
906
							"interface"); ?>.
907
						</td>
908
					</tr>
909
					<tr>
910
						<td width="22%" valign="top" class="vncell"><?=gettext("IPv4 Remote Network/s"); ?></td>
911
						<td width="78%" class="vtable">
912
							<input name="remote_network" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['remote_network']);?>" />
913
							<br />
914
							<?=gettext("These are the IPv4 networks that will be routed through " .
915
							"the tunnel, so that a site-to-site VPN can be " .
916
							"established without manually changing the routing tables. " .
917
							"Expressed as a comma-separated list of one or more CIDR ranges. " .
918
							"If this is a site-to-site VPN, enter the " .
919
							"remote LAN/s here. You may leave this blank to " .
920
							"only communicate with other clients"); ?>.
921
						</td>
922
					</tr>
923
					<tr>
924
						<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Remote Network/s"); ?></td>
925
						<td width="78%" class="vtable">
926
							<input name="remote_networkv6" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['remote_networkv6']);?>" />
927
							<br />
928
							<?=gettext("These are the IPv6 networks that will be routed through " .
929
							"the tunnel, so that a site-to-site VPN can be " .
930
							"established without manually changing the routing tables. " .
931
							"Expressed as a comma-separated list of one or more IP/PREFIX. " .
932
							"If this is a site-to-site VPN, enter the " .
933
							"remote LAN/s here. You may leave this blank to " .
934
							"only communicate with other clients"); ?>.
935
						</td>
936
					</tr>
937
					<tr>
938
						<td width="22%" valign="top" class="vncell"><?=gettext("Limit outgoing bandwidth");?></td>
939
						<td width="78%" class="vtable">
940
							<input name="use_shaper" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['use_shaper']);?>" />
941
							<br />
942
							<?=gettext("Maximum outgoing bandwidth for this tunnel. " .
943
							"Leave empty for no limit. The input value has " .
944
							"to be something between 100 bytes/sec and 100 " .
945
							"Mbytes/sec (entered as bytes per second)"); ?>.
946
						</td>
947
					</tr>
948
					<tr>
949
						<td width="22%" valign="top" class="vncell"><?=gettext("Compression"); ?></td>
950
						<td width="78%" class="vtable">
951
							<select name="compression" class="formselect">
952
								<?php
953
									foreach ($openvpn_compression_modes as $cmode => $cmodedesc):
954
									$selected = "";
955
									if ($cmode == $pconfig['compression'])
956
										$selected = " selected=\"selected\"";
957
								?>
958
								<option value="<?= $cmode ?>" <?= $selected ?>><?= $cmodedesc ?></option>
959
								<?php endforeach; ?>
960
							</select>
961
							<br />
962
							<?=gettext("Compress tunnel packets using the LZO algorithm. Adaptive compression will dynamically disable compression for a period of time if OpenVPN detects that the data in the packets is not being compressed efficiently."); ?>.
963
						</td>
964
					</tr>
965
					<tr>
966
						<td width="22%" valign="top" class="vncell"><?=gettext("Type-of-Service"); ?></td>
967
						<td width="78%" class="vtable">
968
							<table border="0" cellpadding="2" cellspacing="0" summary="type-of-service">
969
								<tr>
970
									<td>
971
										<?php set_checked($pconfig['passtos'],$chk); ?>
972
										<input name="passtos" type="checkbox" value="yes" <?=$chk;?> />
973
									</td>
974
									<td>
975
										<span class="vexpl">
976
											<?=gettext("Set the TOS IP header value of tunnel packets to match the encapsulated packet value"); ?>.
977
										</span>
978
									</td>
979
								</tr>
980
							</table>
981
						</td>
982
					</tr>
983

    
984

    
985
					<tr id="chkboxNoTunIPv6">
986
						<td width="22%" valign="top" class="vncell"><?=gettext("Disable IPv6"); ?></td>
987
						<td width="78%" class="vtable">
988
							<table border="0" cellpadding="2" cellspacing="0" summary="disable-ipv6">
989
								<tr>
990
									<td>
991
										<?php set_checked($pconfig['no_tun_ipv6'],$chk); ?>
992
										<input name="no_tun_ipv6" type="checkbox" value="yes" <?=$chk;?> />
993
									</td>
994
									<td>
995
										<span class="vexpl">
996
											<?=gettext("Do not forward IPv6 traffic"); ?>.
997
										</span>
998
									</td>
999
								</tr>
1000
							</table>
1001
						</td>
1002
					</tr>
1003

    
1004
					<tr id="chkboxRouteNoPull">
1005
						<td width="22%" valign="top" class="vncell"><?=gettext("Dont pull routes"); ?></td>
1006
						<td width="78%" class="vtable">
1007
							<table border="0" cellpadding="2" cellspacing="0" summary="dont-pull-routes">
1008
								<tr>
1009
									<td>
1010
										<?php set_checked($pconfig['route_no_pull'],$chk); ?>
1011
										<input name="route_no_pull" type="checkbox" value="yes" <?=$chk;?> />
1012
									</td>
1013
									<td>
1014
										<span class="vexpl">
1015
											<?=gettext("Don't add or remove routes automatically. Instead pass routes to "); ?> <strong>--route-up</strong> <?=gettext("script using environmental variables"); ?>.
1016
										</span>
1017
									</td>
1018
								</tr>
1019
							</table>
1020
						</td>
1021
					</tr>
1022

    
1023
					<tr id="chkboxRouteNoExec">
1024
						<td width="22%" valign="top" class="vncell"><?=gettext("Dont add/remove routes"); ?></td>
1025
						<td width="78%" class="vtable">
1026
							<table border="0" cellpadding="2" cellspacing="0" summary="dont-exec-routes">
1027
								<tr>
1028
									<td>
1029
										<?php set_checked($pconfig['route_no_exec'],$chk); ?>
1030
										<input name="route_no_exec" type="checkbox" value="yes" <?=$chk;?> />
1031
									</td>
1032
									<td>
1033
										<span class="vexpl">
1034
											<?=gettext("This option effectively bars the server from adding routes to the client's routing table, however note that this option still allows the server to set the TCP/IP properties of the client's TUN/TAP interface"); ?>.
1035
										</span>
1036
									</td>
1037
								</tr>
1038
							</table>
1039
						</td>
1040
					</tr>
1041
				</table>
1042

    
1043
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts" summary="advance configuration">
1044
					<tr>
1045
						<td colspan="2" class="list" height="12"></td>
1046
					</tr>
1047
					<tr>
1048
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced configuration"); ?></td>
1049
					</tr>
1050
					<tr>
1051
						<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
1052
						<td width="78%" class="vtable">
1053
							<table border="0" cellpadding="2" cellspacing="0" summary="advance configuration">
1054
								<tr>
1055
									<td>
1056
										<textarea rows="6" cols="78" name="custom_options" id="custom_options"><?=htmlspecialchars($pconfig['custom_options']);?></textarea><br />
1057
										<?=gettext("Enter any additional options you would like to add to the OpenVPN client configuration here, separated by a semicolon"); ?><br />
1058
										<?=gettext("EXAMPLE:"); ?> <strong>remote server.mysite.com 1194;</strong> or <strong>remote 1.2.3.4 1194;</strong>
1059
									</td>
1060
								</tr>
1061
							</table>
1062
						</td>
1063
					</tr>
1064

    
1065
					<tr id="comboboxVerbosityLevel">
1066
							<td width="22%" valign="top" class="vncell"><?=gettext("Verbosity level");?></td>
1067
							<td width="78%" class="vtable">
1068
							<select name="verbosity_level" class="formselect">
1069
							<?php
1070
								foreach ($openvpn_verbosity_level as $verb_value => $verb_desc):
1071
									$selected = "";
1072
									if ($pconfig['verbosity_level'] == $verb_value)
1073
										$selected = "selected=\"selected\"";
1074
							?>
1075
								<option value="<?=$verb_value;?>" <?=$selected;?>><?=$verb_desc;?></option>
1076
							<?php endforeach; ?>
1077
							</select>
1078
							<br />
1079
							<?=gettext("Each level shows all info from the previous levels. Level 3 is recommended if you want a good summary of what's happening without being swamped by output"); ?>.<br /> <br />
1080
							<strong>none</strong> -- <?=gettext("No output except fatal errors"); ?>. <br />
1081
							<strong>default</strong>-<strong>4</strong> -- <?=gettext("Normal usage range"); ?>. <br />
1082
							<strong>5</strong> -- <?=gettext("Output R and W characters to the console for each packet read and write, uppercase is used for TCP/UDP packets and lowercase is used for TUN/TAP packets"); ?>. <br />
1083
							<strong>6</strong>-<strong>11</strong> -- <?=gettext("Debug info range"); ?>.
1084
							</td>
1085
					</tr>
1086

    
1087
				</table>
1088

    
1089
				<br />
1090
				<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="icons">
1091
					<tr>
1092
						<td width="22%" valign="top">&nbsp;</td>
1093
						<td width="78%">
1094
							<input name="save" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
1095
							<input name="act" type="hidden" value="<?=$act;?>" />
1096
							<?php if (isset($id) && $a_client[$id]): ?>
1097
							<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
1098
							<?php endif; ?>
1099
						</td>
1100
					</tr>
1101
				</table>
1102
			</form>
1103

    
1104
			<?php else: ?>
1105

    
1106
			<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="list of openvpn clients">
1107
				<thead>
1108
				<tr>
1109
					<td width="10%" class="listhdrr"><?=gettext("Disabled"); ?></td>
1110
					<td width="10%" class="listhdrr"><?=gettext("Protocol"); ?></td>
1111
					<td width="30%" class="listhdrr"><?=gettext("Server"); ?></td>
1112
					<td width="40%" class="listhdrr"><?=gettext("Description"); ?></td>
1113
					<td width="10%" class="list"></td>
1114
				</tr>
1115
				</thead>
1116
				<tfoot>
1117
				<tr>
1118
					<td class="list" colspan="4"></td>
1119
					<td class="list">
1120
						<a href="vpn_openvpn_client.php?act=new"><img src="./themes/<?=$g['theme'];?>/images/icons/icon_plus.gif" title="<?=gettext("add client"); ?>" width="17" height="17" border="0" alt="add" />
1121
						</a>
1122
					</td>
1123
				</tr>
1124
				<tr>
1125
					<td colspan="4">
1126
						<p>
1127
							<?=gettext("Additional OpenVPN clients can be added here.");?>
1128
						</p>
1129
					</td>
1130
				</tr>
1131
				</tfoot>
1132
				<tbody>
1133
				<?php
1134
					$i = 0;
1135
					foreach($a_client as $client):
1136
						$disabled = "NO";
1137
						if (isset($client['disable']))
1138
							$disabled = "YES";
1139
						$server = "{$client['server_addr']}:{$client['server_port']}";
1140
				?>
1141
				<tr ondblclick="document.location='vpn_openvpn_client.php?act=edit&amp;id=<?=$i;?>'">
1142
					<td class="listlr">
1143
						<?=$disabled;?>
1144
					</td>
1145
					<td class="listr">
1146
						<?=htmlspecialchars($client['protocol']);?>
1147
					</td>
1148
					<td class="listr">
1149
						<?=htmlspecialchars($server);?>
1150
					</td>
1151
					<td class="listbg">
1152
						<?=htmlspecialchars($client['description']);?>
1153
					</td>
1154
					<td valign="middle" class="list nowrap">
1155
						<a href="vpn_openvpn_client.php?act=edit&amp;id=<?=$i;?>">
1156
							<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit client"); ?>" width="17" height="17" border="0" alt="edit" />
1157
						</a>
1158
						&nbsp;
1159
						<a href="vpn_openvpn_client.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this client?"); ?>')">
1160
							<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete client"); ?>" width="17" height="17" border="0" alt="delete" />
1161
						</a>
1162
					</td>
1163
				</tr>
1164
				<?php
1165
					$i++;
1166
					endforeach;
1167
				?>
1168
				<tr style="dispaly:none;"><td></td></tr>
1169
				</tbody>
1170
			</table>
1171

    
1172
			<?php endif; ?>
1173

    
1174
		</td>
1175
	</tr>
1176
</table>
1177
<script type="text/javascript">
1178
//<![CDATA[
1179
mode_change();
1180
autokey_change();
1181
tlsauth_change();
1182
useproxy_changed();
1183
//]]>
1184
</script>
1185
<?php include("fend.inc"); ?>
1186
</body>
1187
</html>
1188

    
1189
<?php
1190

    
1191
/* local utility functions */
1192

    
1193
function set_checked($var,& $chk) {
1194
	if($var)
1195
		$chk = "checked=\"checked\"";
1196
	else
1197
		$chk = "";
1198
}
1199

    
1200
?>
(246-246/255)