Project

General

Profile

Feature #1815 » vpn_openvpn_export.php

Andy I., 08/27/2011 04:45 AM

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

    
5
	Copyright (C) 2008 Shrew Soft Inc.
6
	Copyright (C) 2010 Ermal Lu�i
7
	All rights reserved. 
8

    
9
	Redistribution and use in source and binary forms, with or without
10
	modification, are permitted provided that the following conditions are met:
11
	
12
	1. Redistributions of source code must retain the above copyright notice,
13
	   this list of conditions and the following disclaimer.
14
	
15
	2. Redistributions in binary form must reproduce the above copyright
16
	   notice, this list of conditions and the following disclaimer in the
17
	   documentation and/or other materials provided with the distribution.
18
	
19
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
	POSSIBILITY OF SUCH DAMAGE.
29

    
30
	DISABLE_PHP_LINT_CHECKING
31
*/
32

    
33
require("globals.inc");
34
require("guiconfig.inc");
35
require("openvpn-client-export.inc");
36

    
37
$pgtitle = array("OpenVPN", "Client Export Utility");
38

    
39
if (!is_array($config['openvpn']['openvpn-server']))
40
	$config['openvpn']['openvpn-server'] = array();
41

    
42
$a_server = $config['openvpn']['openvpn-server'];
43

    
44
if (!is_array($config['system']['user']))
45
	$config['system']['user'] = array();
46

    
47
$a_user = $config['system']['user'];
48

    
49
if (!is_array($config['cert']))
50
	$config['cert'] = array();
51

    
52
$a_cert = $config['cert'];
53

    
54
$ras_server = array();
55
foreach($a_server as $sindex => $server) {
56
	if (isset($server['disable']))
57
		continue;
58
	$ras_user = array();
59
	$ras_certs = array();
60
	if (stripos($server['mode'], "server") === false)
61
		continue;
62
	if ($server['authmode'] == "Local Database" && ($server['mode'] != "server_user")) {
63
		foreach($a_user as $uindex => $user) {
64
			if (!is_array($user['cert']))
65
				continue;
66
			foreach($user['cert'] as $cindex => $cert) {
67
				// If $cert is not an array, it's a certref not a cert.
68
				if (!is_array($cert))
69
					$cert = lookup_cert($cert);
70
	
71
				if ($cert['caref'] != $server['caref'])
72
					continue;
73
				$ras_userent = array();
74
				$ras_userent['uindex'] = $uindex;
75
				$ras_userent['cindex'] = $cindex;
76
				$ras_userent['name'] = $user['name'];
77
				$ras_userent['certname'] = $cert['descr'];
78
				$ras_user[] = $ras_userent;
79
			}
80
		}
81
	} elseif ((!empty($server['authmode']) && ($server['mode'] != "server_user")) || ($server['mode'] == "server_tls")) {
82
		foreach($a_cert as $cindex => $cert) {
83
			if ($cert['caref'] != $server['caref'])
84
				continue;
85
			$ras_cert_entry['cindex'] = $cindex;
86
			$ras_cert_entry['certname'] = $cert['descr'];
87
			$ras_cert_entry['certref'] = $cert['refid'];
88
			$ras_certs[] = $ras_cert_entry;
89
		}
90
	}
91

    
92
	$ras_serverent = array();
93
	$prot = $server['protocol'];
94
	$port = $server['local_port'];
95
	if ($server['description'])
96
		$name = "{$server['description']} {$prot}:{$port}";
97
	else
98
		$name = "Server {$prot}:{$port}";
99
	$ras_serverent['index'] = $sindex;
100
	$ras_serverent['name'] = $name;
101
	$ras_serverent['users'] = $ras_user;
102
	$ras_serverent['certs'] = $ras_certs;
103
	$ras_serverent['mode'] = $server['mode'];
104
	$ras_server[] = $ras_serverent;
105
}
106

    
107
$id = $_GET['id'];
108
if (isset($_POST['id']))
109
	$id = $_POST['id'];
110

    
111
$act = $_GET['act'];
112
if (isset($_POST['act']))
113
	$act = $_POST['act'];
114

    
115
$error = false;
116
if($act == "conf" || $act == "confall") {
117
	$srvid = $_GET['srvid'];
118
	$usrid = $_GET['usrid'];
119
	$crtid = $_GET['crtid'];
120
	if ($srvid === false) {
121
		pfSenseHeader("vpn_openvpn_export.php");
122
		exit;
123
	} else if (($config['openvpn']['openvpn-server'][$srvid]['mode'] != "server_user") &&
124
		(($usrid === false) || ($crtid === false))) {
125
		pfSenseHeader("vpn_openvpn_export.php");
126
		exit;
127
	}
128

    
129
	if ($config['openvpn']['openvpn-server'][$srvid]['mode'] == "server_user")
130
		$nokeys = true;
131
	else
132
		$nokeys = false;
133

    
134
	if (empty($_GET['useaddr'])) {
135
		$error = true;
136
		$input_errors[] = "You need to specify an IP or hostname.";
137
	} else
138
		$useaddr = $_GET['useaddr'];
139

    
140
	$advancedoptions = $_GET['advancedoptions'];
141

    
142
	$usetoken = $_GET['usetoken'];
143
	$password = "";
144
	if ($_GET['password'])
145
		$password = $_GET['password'];
146

    
147
	$proxy = "";
148
	if (!empty($_GET['proxy_addr']) || !empty($_GET['proxy_port'])) {
149
		$proxy = array();
150
		if (empty($_GET['proxy_addr'])) {
151
			$error = true;
152
			$input_errors[] = "You need to specify an address for the proxy port.";
153
		} else
154
			$proxy['ip'] = $_GET['proxy_addr'];
155
		if (empty($_GET['proxy_port'])) {
156
			$error = true;
157
			$input_errors[] = "You need to specify a port for the proxy ip.";
158
		} else
159
			$proxy['port'] = $_GET['proxy_port'];
160
		$proxy['proxy_authtype'] = $_GET['proxy_authtype'];
161
		if ($_GET['proxy_authtype'] != "none") {
162
			if (empty($_GET['proxy_user'])) {
163
				$error = true;
164
				$input_errors[] = "You need to specify a username with the proxy config.";
165
			} else
166
				$proxy['user'] = $_GET['proxy_user'];
167
			if (!empty($_GET['proxy_user']) && empty($_GET['proxy_password'])) {
168
				$error = true;
169
				$input_errors[] = "You need to specify a password with the proxy user.";
170
			} else
171
				$proxy['password'] = $_GET['proxy_password'];
172
		}
173
	}
174

    
175
	$exp_name = openvpn_client_export_prefix($srvid);
176
	if ($act == "confall")
177
		$zipconf = true;
178
	$exp_data = openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $usetoken, $nokeys, $proxy, $zipconf, $password, false, false, $advancedoptions);
179
	if (!$exp_data) {
180
		$input_errors[] = "Failed to export config files!";
181
		$error = true;
182
	}
183
	if (!$error) {
184
		if ($act == "confall") {
185
			$exp_name = urlencode($exp_data);
186
			$exp_size = filesize("{$g['tmp_path']}/{$exp_data}");
187
		} else {
188
			$exp_name = urlencode($exp_name."-config.ovpn");
189
			$exp_size = strlen($exp_data);
190
		}
191

    
192
		header('Pragma: ');
193
		header('Cache-Control: ');
194
		header("Content-Type: application/octet-stream");
195
		header("Content-Disposition: attachment; filename={$exp_name}");
196
		header("Content-Length: $exp_size");
197
		if ($act == "confall")
198
			readfile("{$g['tmp_path']}/{$exp_data}");
199
		else
200
			echo $exp_data;
201

    
202
		@unlink($exp_data);
203
		exit;
204
	}
205
}
206

    
207
if($act == "visc") {
208
	$srvid = $_GET['srvid'];
209
	$usrid = $_GET['usrid'];
210
	$crtid = $_GET['crtid'];
211
	if ($srvid === false) {
212
		pfSenseHeader("vpn_openvpn_export.php");
213
		exit;
214
	} else if (($config['openvpn']['openvpn-server'][$srvid]['mode'] != "server_user") &&
215
		(($usrid === false) || ($crtid === false))) {
216
		pfSenseHeader("vpn_openvpn_export.php");
217
		exit;
218
	}
219
	if (empty($_GET['useaddr'])) {
220
		$error = true;
221
		$input_errors[] = "You need to specify an IP or hostname.";
222
	} else
223
		$useaddr = $_GET['useaddr'];
224

    
225
	$advancedoptions = $_GET['advancedoptions'];
226

    
227
	$usetoken = $_GET['usetoken'];
228
	$password = "";
229
	if ($_GET['password'])
230
		$password = $_GET['password'];
231

    
232
	$proxy = "";
233
	if (!empty($_GET['proxy_addr']) || !empty($_GET['proxy_port'])) {
234
		$proxy = array();
235
		if (empty($_GET['proxy_addr'])) {
236
			$error = true;
237
			$input_errors[] = "You need to specify an address for the proxy port.";
238
		} else
239
			$proxy['ip'] = $_GET['proxy_addr'];
240
		if (empty($_GET['proxy_port'])) {
241
			$error = true;
242
			$input_errors[] = "You need to specify a port for the proxy ip.";
243
		} else
244
			$proxy['port'] = $_GET['proxy_port'];
245
		$proxy['proxy_authtype'] = $_GET['proxy_authtype'];
246
		if ($_GET['proxy_authtype'] != "none") {
247
			if (empty($_GET['proxy_user'])) {
248
				$error = true;
249
				$input_errors[] = "You need to specify a username with the proxy config.";
250
			} else
251
				$proxy['user'] = $_GET['proxy_user'];
252
			if (!empty($_GET['proxy_user']) && empty($_GET['proxy_password'])) {
253
				$error = true;
254
				$input_errors[] = "You need to specify a password with the proxy user.";
255
			} else
256
				$proxy['password'] = $_GET['proxy_password'];
257
		}
258
	}
259

    
260
	$exp_name = openvpn_client_export_prefix($srvid);
261
	$exp_name = urlencode($exp_name."-Viscosity.visc.zip");
262
	$exp_path = viscosity_openvpn_client_config_exporter($srvid, $usrid, $crtid, $useaddr, $usetoken, $password, $proxy, $advancedoptions);
263
	if (!$exp_path) {
264
		$input_errors[] = "Failed to export config files!";
265
		$error = true;
266
	}
267
	if (!$error) {
268
		$exp_size = filesize($exp_path);
269

    
270
		header('Pragma: ');
271
		header('Cache-Control: ');
272
		header("Content-Type: application/octet-stream");
273
		header("Content-Disposition: attachment; filename={$exp_name}");
274
		header("Content-Length: $exp_size");
275
		readfile($exp_path);
276
		//unlink($exp_path);
277
		exit;
278
	}
279
}
280

    
281
if($act == "inst") {
282
	$srvid = $_GET['srvid'];
283
	$usrid = $_GET['usrid'];
284
	$crtid = $_GET['crtid'];
285
	if ($srvid === false) {
286
		pfSenseHeader("vpn_openvpn_export.php");
287
		exit;
288
	} else if (($config['openvpn']['openvpn-server'][$srvid]['mode'] != "server_user") &&
289
		(($usrid === false) || ($crtid === false))) {
290
		pfSenseHeader("vpn_openvpn_export.php");
291
		exit;
292
	}
293
	if (empty($_GET['useaddr'])) {
294
		$error = true;
295
		$input_errors[] = "You need to specify an IP or hostname.";
296
	} else
297
		$useaddr = $_GET['useaddr'];
298

    
299
	$advancedoptions = $_GET['advancedoptions'];
300

    
301
	$usetoken = $_GET['usetoken'];
302
	$password = "";
303
	if ($_GET['password'])
304
		$password = $_GET['password'];
305

    
306
	$proxy = "";
307
	if (!empty($_GET['proxy_addr']) || !empty($_GET['proxy_port'])) {
308
		$proxy = array();
309
		if (empty($_GET['proxy_addr'])) {
310
			$error = true;
311
			$input_errors[] = "You need to specify an address for the proxy port.";
312
		} else
313
			$proxy['ip'] = $_GET['proxy_addr'];
314
		if (empty($_GET['proxy_port'])) {
315
			$error = true;
316
			$input_errors[] = "You need to specify a port for the proxy ip.";
317
		} else
318
			$proxy['port'] = $_GET['proxy_port'];
319
		$proxy['proxy_authtype'] = $_GET['proxy_authtype'];
320
		if ($_GET['proxy_authtype'] != "none") {
321
			if (empty($_GET['proxy_user'])) {
322
				$error = true;
323
				$input_errors[] = "You need to specify a username with the proxy config.";
324
			} else
325
				$proxy['user'] = $_GET['proxy_user'];
326
			if (!empty($_GET['proxy_user']) && empty($_GET['proxy_password'])) {
327
				$error = true;
328
				$input_errors[] = "You need to specify a password with the proxy user.";
329
			} else
330
				$proxy['password'] = $_GET['proxy_password'];
331
		}
332
	}
333

    
334
	$exp_name = openvpn_client_export_prefix($srvid);
335
	$exp_name = urlencode($exp_name."-install.exe");
336
	$exp_path = openvpn_client_export_installer($srvid, $usrid, $crtid, $useaddr, $usetoken, $password, $proxy, $advancedoptions);
337
	if (!$exp_path) {
338
		$input_errors[] = "Failed to export config files!";
339
		$error = true;
340
	}
341
	if (!$error) {
342
		$exp_size = filesize($exp_path);
343

    
344
		header('Pragma: ');
345
		header('Cache-Control: ');
346
		header("Content-Type: application/octet-stream");
347
		header("Content-Disposition: attachment; filename={$exp_name}");
348
		header("Content-Length: $exp_size");
349
		readfile($exp_path);
350
		unlink($exp_path);
351
		exit;
352
	}
353
}
354

    
355
include("head.inc");
356

    
357
?>
358

    
359
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
360
<?php include("fbegin.inc"); ?>
361
<script language="JavaScript">
362
	var viscosityAvailable = false;
363
<!--
364

    
365
var servers = new Array();
366
<?php foreach ($ras_server as $sindex => $server): ?>
367
servers[<?=$sindex;?>] = new Array();
368
servers[<?=$sindex;?>][0] = '<?=$server['index'];?>';
369
servers[<?=$sindex;?>][1] = new Array();
370
servers[<?=$sindex;?>][2] = '<?=$server['mode'];?>';
371
servers[<?=$sindex;?>][3] = new Array();
372
<?php		foreach ($server['users'] as $uindex => $user): ?>
373
servers[<?=$sindex;?>][1][<?=$uindex;?>] = new Array();
374
servers[<?=$sindex;?>][1][<?=$uindex;?>][0] = '<?=$user['uindex'];?>';
375
servers[<?=$sindex;?>][1][<?=$uindex;?>][1] = '<?=$user['cindex'];?>';
376
servers[<?=$sindex;?>][1][<?=$uindex;?>][2] = '<?=$user['name'];?>';
377
servers[<?=$sindex;?>][1][<?=$uindex;?>][3] = '<?=str_replace("'", "\\'", $user['certname']);?>';
378
<?		endforeach; ?>
379
<?php		$c=0;
380
		foreach ($server['certs'] as $cert): ?>
381
servers[<?=$sindex;?>][3][<?=$c;?>] = new Array();
382
servers[<?=$sindex;?>][3][<?=$c;?>][0] = '<?=$cert['cindex'];?>';
383
servers[<?=$sindex;?>][3][<?=$c;?>][1] = '<?=str_replace("'", "\\'", $cert['certname']);?>';
384
<?		$c++;
385
		endforeach; ?>
386
<?	endforeach; ?>
387

    
388
function download_begin(act, i, j) {
389

    
390
	var index = document.getElementById("server").selectedIndex;
391
	var users = servers[index][1];
392
	var certs = servers[index][3];
393
	var useaddr;
394
	var advancedoptions;
395

    
396
	if (document.getElementById("useaddr").value == "other") {
397
		if (document.getElementById("useaddr_hostname").value == "") {
398
			alert("Please specify an IP address or hostname.");
399
			return;
400
		}
401
		useaddr = document.getElementById("useaddr_hostname").value;
402
	} else
403
		useaddr = document.getElementById("useaddr").value;
404

    
405
	advancedoptions = document.getElementById("advancedoptions").value;
406

    
407

    
408
	var usetoken = 0;
409
	if (document.getElementById("usetoken").checked)
410
		usetoken = 1;
411
	var usepass = 0;
412
	if (document.getElementById("usepass").checked)
413
		usepass = 1;
414

    
415
	var pass = document.getElementById("pass").value;
416
	var conf = document.getElementById("conf").value;
417
	if (usepass && (act == "inst")) {
418
		if (!pass || !conf) {
419
			alert("The password or confirm field is empty");
420
			return;
421
		}
422
		if (pass != conf) {
423
			alert("The password and confirm fields must match");
424
			return;
425
		}
426
	}
427

    
428
	var useproxy = 0;
429
	var useproxypass = 0;
430
	if (document.getElementById("useproxy").checked)
431
		useproxy = 1;
432

    
433
	var proxyaddr = document.getElementById("proxyaddr").value;
434
	var proxyport = document.getElementById("proxyport").value;
435
	if (useproxy) {
436
		if (!proxyaddr || !proxyport) {
437
			alert("The proxy ip and port cannot be empty");
438
			return;
439
		}
440

    
441
		if (document.getElementById("useproxypass").value != 'none')
442
			useproxypass = 1;
443

    
444
		var proxyauth = document.getElementById("useproxypass").value;
445
		var proxyuser = document.getElementById("proxyuser").value;
446
		var proxypass = document.getElementById("proxypass").value;
447
		var proxyconf = document.getElementById("proxyconf").value;
448
		if (useproxypass) {
449
			if (!proxyuser) {
450
				alert("Please fill the proxy username and passowrd.");
451
				return;
452
			}
453
			if (!proxypass || !proxyconf) {
454
				alert("The proxy password or confirm field is empty");
455
				return;
456
			}
457
			if (proxypass != proxyconf) {
458
				alert("The proxy password and confirm fields must match");
459
				return;
460
			}
461
		}
462
	}
463

    
464
	var dlurl;
465
	dlurl  = "/vpn_openvpn_export.php?act=" + act;
466
	dlurl += "&srvid=" + escape(servers[index][0]);
467
	if (users[i]) {
468
		dlurl += "&usrid=" + escape(users[i][0]);
469
		dlurl += "&crtid=" + escape(users[i][1]);
470
	}
471
	if (certs[j]) {
472
		dlurl += "&usrid=";
473
		dlurl += "&crtid=" + escape(certs[j][0]);
474
	}
475
	dlurl += "&useaddr=" + escape(useaddr);
476
	dlurl += "&usetoken=" + escape(usetoken);
477
	if (usepass)
478
		dlurl += "&password=" + escape(pass);
479
	if (useproxy) {
480
		dlurl += "&proxy_addr=" + escape(proxyaddr);
481
		dlurl += "&proxy_port=" + escape(proxyport);
482
		dlurl += "&proxy_authtype=" + escape(proxyauth);
483
		if (useproxypass) {
484
			dlurl += "&proxy_user=" + escape(proxyuser);
485
			dlurl += "&proxy_password=" + escape(proxypass);
486
		}
487
	}
488

    
489
	dlurl += "&advancedoptions=" + escape(advancedoptions);
490

    
491
	window.open(dlurl,"_self");
492
}
493

    
494
function server_changed() {
495

    
496
	var table = document.getElementById("users");
497
	while (table.rows.length > 1 )
498
		table.deleteRow(1);
499

    
500
	var index = document.getElementById("server").selectedIndex;
501
	var users = servers[index][1];
502
	var certs = servers[index][3];
503
	for (i=0; i < users.length; i++) {
504
		var row = table.insertRow(table.rows.length);
505
		var cell0 = row.insertCell(0);
506
		var cell1 = row.insertCell(1);
507
		var cell2 = row.insertCell(2);
508
		cell0.className = "listlr";
509
		cell0.innerHTML = users[i][2];
510
		cell1.className = "listr";
511
		cell1.innerHTML = users[i][3];
512
		cell2.className = "listr";
513
		cell2.innerHTML = "<a href='javascript:download_begin(\"conf\"," + i + ", -1)'>Configuration</a>";
514
		cell2.innerHTML += "<br/>";
515
		cell2.innerHTML += "<a href='javascript:download_begin(\"confall\"," + i + ", -1)'>Configuration archive</a>";
516
		cell2.innerHTML += "<br/>";
517
		cell2.innerHTML += "<a href='javascript:download_begin(\"inst\"," + i + ", -1)'>Windows Installer</a>";
518
		cell2.innerHTML += "<br/>";
519
		cell2.innerHTML += "<a href='javascript:download_begin(\"visc\"," + i + ", -1)'>Viscosity Bundle</a>";
520
	}
521
	for (j=0; j < certs.length; j++) {
522
		var row = table.insertRow(table.rows.length);
523
		var cell0 = row.insertCell(0);
524
		var cell1 = row.insertCell(1);
525
		var cell2 = row.insertCell(2);
526
		cell0.className = "listlr";
527
		if (servers[index][2] == "server_tls") {
528
			cell0.innerHTML = "Certificate (SSL/TLS, no Auth)";
529
		} else {
530
			cell0.innerHTML = "Certificate with External Auth";
531
		}
532
		cell1.className = "listr";
533
		cell1.innerHTML = certs[j][1];
534
		cell2.className = "listr";
535
		cell2.innerHTML = "<a href='javascript:download_begin(\"conf\", -1," + j + ")'>Configuration</a>";
536
		cell2.innerHTML += "<br/>";
537
		cell2.innerHTML += "<a href='javascript:download_begin(\"confall\", -1," + j + ")'>Configuration archive</a>";
538
		cell2.innerHTML += "<br/>";
539
		cell2.innerHTML += "<a href='javascript:download_begin(\"inst\", -1," + j + ")'>Windows Installer</a>";
540
		cell2.innerHTML += "<br/>";
541
		cell2.innerHTML += "<a href='javascript:download_begin(\"visc\", -1," + j + ")'>Viscosity Bundle</a>";
542
	}
543
	if (servers[index][2] == 'server_user') {
544
		var row = table.insertRow(table.rows.length);
545
		var cell0 = row.insertCell(0);
546
		var cell1 = row.insertCell(1);
547
		var cell2 = row.insertCell(2);
548
		cell0.className = "listlr";
549
		cell0.innerHTML = "Authentication Only (No Cert)";
550
		cell1.className = "listr";
551
		cell1.innerHTML = "none";
552
		cell2.className = "listr";
553
		cell2.innerHTML = "<a href='javascript:download_begin(\"conf\"," + i + ")'>Configuration</a>";
554
		cell2.innerHTML += "<br/>";
555
		cell2.innerHTML += "<a href='javascript:download_begin(\"confall\"," + i + ")'>Configuration archive</a>";
556
		cell2.innerHTML += "<br/>";
557
		cell2.innerHTML += "<a href='javascript:download_begin(\"inst\"," + i + ")'>Windows Installer</a>";
558
		cell2.innerHTML += "<br/>";
559
		cell2.innerHTML += "<a href='javascript:download_begin(\"visc\"," + i + ")'>Viscosity Bundle</a>";
560
	}
561
}
562

    
563
function useaddr_changed(obj) {
564

    
565
	if (obj.value == "other")
566
		$('HostName').show();
567
	else
568
		$('HostName').hide();
569
	
570
}
571

    
572
function usepass_changed() {
573

    
574
	if (document.getElementById("usepass").checked)
575
		document.getElementById("usepass_opts").style.display = "";
576
	else
577
		document.getElementById("usepass_opts").style.display = "none";
578
}
579

    
580
function useproxy_changed(obj) {
581

    
582
	if ((obj.id == "useproxy" && obj.checked) ||
583
		$(obj.id + 'pass').value != 'none') {
584
		$(obj.id + '_opts').show();
585
	} else {
586
		$(obj.id + '_opts').hide();
587
	}
588
}
589
//-->
590
</script>
591
<?php
592
	if ($input_errors)
593
		print_input_errors($input_errors);
594
	if ($savemsg)
595
		print_info_box($savemsg);
596
?>
597
<table width="100%" border="0" cellpadding="0" cellspacing="0">
598
 	<tr>
599
		<td>
600
			<?php 
601
				$tab_array = array();
602
				$tab_array[] = array(gettext("Server"), false, "vpn_openvpn_server.php");
603
				$tab_array[] = array(gettext("Client"), false, "vpn_openvpn_client.php");
604
				$tab_array[] = array(gettext("Client Specific Overrides"), false, "vpn_openvpn_csc.php");
605
				$tab_array[] = array(gettext("Wizards"), false, "wizard.php?xml=openvpn_wizard.xml");
606
				$tab_array[] = array(gettext("Client Export"), true, "vpn_openvpn_export.php");
607
				$tab_array[] = array(gettext("Shared Key Export"), false, "vpn_openvpn_export_shared.php");
608
				display_top_tabs($tab_array);
609
			?>
610
		</td>
611
	</tr>
612
	<tr>
613
		<td id="mainarea">
614
			<div class="tabcont">
615
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
616
					<tr>
617
						<td width="22%" valign="top" class="vncellreq">Remote Access Server</td>
618
						<td width="78%" class="vtable">
619
							<select name="server" id="server" class="formselect" onChange="server_changed()">
620
								<?php foreach($ras_server as & $server): ?>
621
								<option value="<?=$server['sindex'];?>"><?=$server['name'];?></option>
622
								<?php endforeach; ?>
623
							</select>
624
						</td>
625
					</tr>
626
					<tr>
627
						<td width="22%" valign="top" class="vncell">Host Name Resolution</td>
628
						<td width="78%" class="vtable">
629
							<table border="0" cellpadding="2" cellspacing="0">
630
								<tr>
631
									<td>
632
										<select name="useaddr" id="useaddr" class="formselect" onChange="useaddr_changed(this)">
633
											<option value="serveraddr" >Interface IP Address</option>
634
											<option value="serverhostname" >Installation hostname</option>
635
											<?php if (is_array($config['dyndnses']['dyndns'])): ?>
636
												<?php foreach ($config['dyndnses']['dyndns'] as $ddns): ?>
637
													<option value="<?php echo $ddns["host"] ?>">DynDNS: <?php echo $ddns["host"] ?></option>
638
												<?php endforeach; ?>
639
											<?php endif; ?>
640
											<option value="other">Other</option>
641
										</select>
642
										<br />
643
										<div style="display:none;" name="HostName" id="HostName">
644
											<input name="useaddr_hostname" id="useaddr_hostname" />
645
											<span class="vexpl">
646
												Enter the hostname or IP address the client will use to connect to this server.
647
											</span>
648
										</div>
649
									</td>
650
								</tr>
651
							</table>
652
						</td>
653
					</tr>
654
					<tr>
655
						<td width="22%" valign="top" class="vncell">Certificate Export Options</td>
656
						<td width="78%" class="vtable">
657
							<table border="0" cellpadding="2" cellspacing="0">
658
								<tr>
659
									<td>
660
										<input name="usetoken" id="usetoken" type="checkbox" value="yes">
661
									</td>
662
									<td>
663
										<span class="vexpl">
664
											 Use Microsoft Certificate Storage instead of local files.
665
										</span>
666
									</td>
667
								</tr>
668
							</table>
669
							<table border="0" cellpadding="2" cellspacing="0">
670
								<tr>
671
									<td>
672
										<input name="usepass" id="usepass" type="checkbox" value="yes" onClick="usepass_changed()">
673
									</td>
674
									<td>
675
										<span class="vexpl">
676
											Use a password to protect the pkcs12 file contents.
677
										</span>
678
									</td>
679
								</tr>
680
							</table>
681
							<table border="0" cellpadding="2" cellspacing="0" id="usepass_opts" style="display:none">
682
								<tr>
683
									<td align="right">
684
										<span class="vexpl">
685
											 &nbsp;Password :&nbsp;
686
										</span>
687
									</td>
688
									<td>
689
										<input name="pass" id="pass" type="password" class="formfld pwd" size="20" value="" />
690
									</td>
691
								</tr>
692
								<tr>
693
									<td align="right">
694
										<span class="vexpl">
695
											 &nbsp;Confirm :&nbsp;
696
										</span>
697
									</td>
698
									<td>
699
										<input name="conf" id="conf" type="password" class="formfld pwd" size="20" value="" />
700
									</td>
701
								</tr>
702
							</table>
703
						</td>
704
					</tr>
705
					<tr>
706
						<td width="22%" valign="top" class="vncell">Use HTTP Proxy</td>
707
						<td width="78%" class="vtable">
708
							 <table border="0" cellpadding="2" cellspacing="0">
709
								<tr>
710
									<td>
711
										<input name="useproxy" id="useproxy" type="checkbox" value="yes" onClick="useproxy_changed(this)">
712

    
713
									</td>
714
									<td>
715
										<span class="vexpl">
716
											Use HTTP proxy to communicate with the server.
717
										</span>
718
									</td>
719
								</tr>
720
							</table>
721
							<table border="0" cellpadding="2" cellspacing="0" id="useproxy_opts" style="display:none">
722
								<tr>
723
									<td align="right" width='25%'>
724
										<span class="vexpl">
725
											 &nbsp;     IP Address :&nbsp;
726
										</span>
727
									</td>
728
									<td>
729
										<input name="proxyaddr" id="proxyaddr" class="formfld unknown" size="20" value="" />
730
									</td>
731
								</tr>
732
								<tr>
733
									<td align="right" width='25%'>
734
										<span class="vexpl">
735
											 &nbsp;      Port :&nbsp;
736
										</span>
737
														<td>
738
										<input name="proxyport" id="proxyport" class="formfld unknown" size="5" value="" />
739
									</td>
740
								</tr>
741
							<br />
742
								<tr>
743
									<td width="25%">
744

    
745
									</td>
746
									<td>
747
										<select name="useproxypass" id="useproxypass" class="formselect" onChange="useproxy_changed(this)">
748
											<option value="none">none</option>
749
											<option value="basic">basic</option>
750
											<option value="ntlm">ntlm</option>
751
										</select>
752
										<span class="vexpl">
753
											Choose HTTP proxy authentication if any.
754
										</span>
755
							<br />
756
							<table border="0" cellpadding="2" cellspacing="0" id="useproxypass_opts" style="display:none">
757
								<tr>
758
									<td align="right" width="25%">
759
										<span class="vexpl">
760
											 &nbsp;Username :&nbsp;
761
										</span>
762
									</td>
763
									<td>
764
										<input name="proxyuser" id="proxyuser" class="formfld unknown" size="20" value="" />
765
									</td>
766
								</tr>
767
								<tr>
768
									<td align="right" width="25%">
769
										<span class="vexpl">
770
											 &nbsp;Password :&nbsp;
771
										</span>
772
									</td>
773
									<td>
774
										<input name="proxypass" id="proxypass" type="password" class="formfld pwd" size="20" value="" />
775
									</td>
776
								</tr>
777
								<tr>
778
									<td align="right" width="25%">
779
										<span class="vexpl">
780
											 &nbsp;Confirm :&nbsp;
781
										</span>
782
														<td>
783
										<input name="proxyconf" id="proxyconf" type="password" class="formfld pwd" size="20" value="" />
784
									</td>
785
								</tr>
786
							</table>
787
									</td>
788
								</tr>
789
							</table>
790
						</td>
791
					</tr>
792
					<tr>
793
						<td colspan="2" class="list" height="12">&nbsp;</td>
794
					</tr>
795
					<tr>
796
						<td width="22%" valign="top" class="vncell">Additional configuration options</td>
797
						<td width="78%" class="vtable">
798
							<textarea rows="6" cols="78" name="advancedoptions" id="advancedoptions"></textarea><br/>
799
							<?=gettext("Enter any additional options you would like to add to the OpenVPN client export configuration here, separated by a line break or semicolon"); ?><br/>
800
							<?=gettext("EXAMPLE: remote-random"); ?>;
801
						</td>
802
					</tr>
803
					<tr>
804
						<td colspan="2" valign="top" class="listtopic">Client Install Packages</td>
805
					</tr>
806
				</table>
807
				<table width="100%" id="users" width="100%" border="0" cellpadding="0" cellspacing="0">
808
					<tr>
809
						<td width="25%" class="listhdrr"><?=gettext("User");?></td>
810
						<td width="50%" class="listhdrr"><?=gettext("Certificate Name");?></td>
811
						<td width="25%" class="listhdrr"><?=gettext("Export");?></td>
812
					</tr>
813
				</table>
814
				<table width="100%" width="100%" border="0" cellpadding="5" cellspacing="10">
815
					<tr>
816
						<td align="right" valign="top" width="5%"><?= gettext("NOTE:") ?></td>
817
						<td><?= gettext("If you expect to see a certain client in the list but it is not there, it is usually due to a CA mismatch between the OpenVPN server instance and the client certificates 
818

    
819
found in the User Manager.") ?></td>
820
					</tr>
821
				</table>
822
			</div>
823
		</td>
824
	</tr>
825
</table>
826
<script language="JavaScript">
827
<!--
828
server_changed();
829
//-->
830
</script>
831
</body>
832
<?php include("fend.inc"); ?>
    (1-1/1)