Project

General

Profile

Download (20.1 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	vpn_openvpn_csc.php
4

    
5
	Copyright (C) 2008 Shrew Soft Inc.
6
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
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

    
31
##|+PRIV
32
##|*IDENT=page-openvpn-csc
33
##|*NAME=OpenVPN: Client Specific Override page
34
##|*DESCR=Allow access to the 'OpenVPN: Client Specific Override' page.
35
##|*MATCH=vpn_openvpn_csc.php*
36
##|-PRIV
37

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

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

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

    
47
$a_csc = &$config['openvpn']['openvpn-csc'];
48

    
49
if (is_numericint($_GET['id']))
50
	$id = $_GET['id'];
51

    
52
if (isset($_POST['id']) && is_numericint($_POST['id']))
53
	$id = $_POST['id'];
54

    
55
$act = $_GET['act'];
56

    
57
if (isset($_POST['act']))
58
	$act = $_POST['act'];
59

    
60
if ($_GET['act'] == "del") {
61
	if (!$a_csc[$id]) {
62
		pfSenseHeader("vpn_openvpn_csc.php");
63
		exit;
64
	}
65

    
66
	openvpn_delete_csc($a_csc[$id]);
67
	unset($a_csc[$id]);
68
	write_config();
69
	$savemsg = gettext("Client Specific Override successfully deleted")."<br />";
70
}
71

    
72
if($_GET['act']=="edit"){
73

    
74
	if (isset($id) && $a_csc[$id]) {
75
		$pconfig['custom_options'] = $a_csc[$id]['custom_options'];
76
		$pconfig['disable'] = isset($a_csc[$id]['disable']);
77
		$pconfig['common_name'] = $a_csc[$id]['common_name'];
78
		$pconfig['block'] = $a_csc[$id]['block'];
79
		$pconfig['description'] = $a_csc[$id]['description'];
80

    
81
		$pconfig['tunnel_network'] = $a_csc[$id]['tunnel_network'];
82
		$pconfig['local_network'] = $a_csc[$id]['local_network'];
83
		$pconfig['local_networkv6'] = $a_csc[$id]['local_networkv6'];
84
		$pconfig['remote_network'] = $a_csc[$id]['remote_network'];
85
		$pconfig['remote_networkv6'] = $a_csc[$id]['remote_networkv6'];
86
		$pconfig['gwredir'] = $a_csc[$id]['gwredir'];
87

    
88
		$pconfig['push_reset'] = $a_csc[$id]['push_reset'];
89

    
90
		$pconfig['dns_domain'] = $a_csc[$id]['dns_domain'];
91

    
92
		if ($pconfig['dns_domain'])
93
			$pconfig['dns_domain_enable'] = true;
94

    
95
		$pconfig['dns_server1'] = $a_csc[$id]['dns_server1'];
96
		$pconfig['dns_server2'] = $a_csc[$id]['dns_server2'];
97
		$pconfig['dns_server3'] = $a_csc[$id]['dns_server3'];
98
		$pconfig['dns_server4'] = $a_csc[$id]['dns_server4'];
99

    
100
		if ($pconfig['dns_server1'] ||
101
			$pconfig['dns_server2'] ||
102
			$pconfig['dns_server3'] ||
103
			$pconfig['dns_server4'])
104
			$pconfig['dns_server_enable'] = true;
105

    
106
		$pconfig['ntp_server1'] = $a_csc[$id]['ntp_server1'];
107
		$pconfig['ntp_server2'] = $a_csc[$id]['ntp_server2'];
108

    
109
		if ($pconfig['ntp_server1'] ||
110
			$pconfig['ntp_server2'])
111
			$pconfig['ntp_server_enable'] = true;
112

    
113
		$pconfig['netbios_enable'] = $a_csc[$id]['netbios_enable'];
114
		$pconfig['netbios_ntype'] = $a_csc[$id]['netbios_ntype'];
115
		$pconfig['netbios_scope'] = $a_csc[$id]['netbios_scope'];
116

    
117
		$pconfig['wins_server1'] = $a_csc[$id]['wins_server1'];
118
		$pconfig['wins_server2'] = $a_csc[$id]['wins_server2'];
119

    
120
		if ($pconfig['wins_server1'] ||
121
			$pconfig['wins_server2'])
122
			$pconfig['wins_server_enable'] = true;
123

    
124
		$pconfig['nbdd_server1'] = $a_csc[$id]['nbdd_server1'];
125

    
126
		if ($pconfig['nbdd_server1'])
127
			$pconfig['nbdd_server_enable'] = true;
128
	}
129
}
130

    
131
if ($_POST) {
132

    
133
	unset($input_errors);
134
	$pconfig = $_POST;
135

    
136
	/* input validation */
137
	if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'Tunnel network'))
138
		$input_errors[] = $result;
139

    
140
	if ($result = openvpn_validate_cidr($pconfig['local_network'], 'IPv4 Local Network', true, "ipv4"))
141
		$input_errors[] = $result;
142

    
143
	if ($result = openvpn_validate_cidr($pconfig['local_networkv6'], 'IPv6 Local Network', true, "ipv6"))
144
		$input_errors[] = $result;
145

    
146
	if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'IPv4 Remote Network', true, "ipv4"))
147
		$input_errors[] = $result;
148

    
149
	if ($result = openvpn_validate_cidr($pconfig['remote_networkv6'], 'IPv6 Remote Network', true, "ipv6"))
150
		$input_errors[] = $result;
151

    
152
	if ($pconfig['dns_server_enable']) {
153
		if (!empty($pconfig['dns_server1']) && !is_ipaddr(trim($pconfig['dns_server1'])))
154
			$input_errors[] = gettext("The field 'DNS Server #1' must contain a valid IP address");
155
		if (!empty($pconfig['dns_server2']) && !is_ipaddr(trim($pconfig['dns_server2'])))
156
			$input_errors[] = gettext("The field 'DNS Server #2' must contain a valid IP address");
157
		if (!empty($pconfig['dns_server3']) && !is_ipaddr(trim($pconfig['dns_server3'])))
158
			$input_errors[] = gettext("The field 'DNS Server #3' must contain a valid IP address");
159
		if (!empty($pconfig['dns_server4']) && !is_ipaddr(trim($pconfig['dns_server4'])))
160
			$input_errors[] = gettext("The field 'DNS Server #4' must contain a valid IP address");
161
	}
162

    
163
	if ($pconfig['ntp_server_enable']) {
164
		if (!empty($pconfig['ntp_server1']) && !is_ipaddr(trim($pconfig['ntp_server1'])))
165
			$input_errors[] = gettext("The field 'NTP Server #1' must contain a valid IP address");
166
		if (!empty($pconfig['ntp_server2']) && !is_ipaddr(trim($pconfig['ntp_server2'])))
167
			$input_errors[] = gettext("The field 'NTP Server #2' must contain a valid IP address");
168
		if (!empty($pconfig['ntp_server3']) && !is_ipaddr(trim($pconfig['ntp_server3'])))
169
			$input_errors[] = gettext("The field 'NTP Server #3' must contain a valid IP address");
170
		if (!empty($pconfig['ntp_server4']) && !is_ipaddr(trim($pconfig['ntp_server4'])))
171
			$input_errors[] = gettext("The field 'NTP Server #4' must contain a valid IP address");
172
	}
173

    
174
	if ($pconfig['netbios_enable']) {
175
		if ($pconfig['wins_server_enable']) {
176
			if (!empty($pconfig['wins_server1']) && !is_ipaddr(trim($pconfig['wins_server1'])))
177
				$input_errors[] = gettext("The field 'WINS Server #1' must contain a valid IP address");
178
			if (!empty($pconfig['wins_server2']) && !is_ipaddr(trim($pconfig['wins_server2'])))
179
				$input_errors[] = gettext("The field 'WINS Server #2' must contain a valid IP address");
180
		}
181

    
182
		if ($pconfig['nbdd_server_enable']) {
183
			if (!empty($pconfig['nbdd_server1']) && !is_ipaddr(trim($pconfig['nbdd_server1'])))
184
				$input_errors[] = gettext("The field 'NetBIOS Data Distribution Server #1' must contain a valid IP address");
185
		}
186
	}
187

    
188
	$reqdfields[] = 'common_name';
189
	$reqdfieldsn[] = 'Common name';
190

    
191
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
192

    
193
	if (!$input_errors) {
194
		$csc = array();
195

    
196
		$csc['custom_options'] = $pconfig['custom_options'];
197

    
198
		if ($_POST['disable'] == "yes")
199
			$csc['disable'] = true;
200

    
201
		$csc['common_name'] = $pconfig['common_name'];
202
		$csc['block'] = $pconfig['block'];
203
		$csc['description'] = $pconfig['description'];
204
		$csc['tunnel_network'] = $pconfig['tunnel_network'];
205
		$csc['local_network'] = $pconfig['local_network'];
206
		$csc['local_networkv6'] = $pconfig['local_networkv6'];
207
		$csc['remote_network'] = $pconfig['remote_network'];
208
		$csc['remote_networkv6'] = $pconfig['remote_networkv6'];
209
		$csc['gwredir'] = $pconfig['gwredir'];
210
		$csc['push_reset'] = $pconfig['push_reset'];
211

    
212
		if ($pconfig['dns_domain_enable'])
213
			$csc['dns_domain'] = $pconfig['dns_domain'];
214

    
215
		if ($pconfig['dns_server_enable']) {
216
			$csc['dns_server1'] = $pconfig['dns_server1'];
217
			$csc['dns_server2'] = $pconfig['dns_server2'];
218
			$csc['dns_server3'] = $pconfig['dns_server3'];
219
			$csc['dns_server4'] = $pconfig['dns_server4'];
220
		}
221

    
222
		if ($pconfig['ntp_server_enable']) {
223
			$csc['ntp_server1'] = $pconfig['ntp_server1'];
224
			$csc['ntp_server2'] = $pconfig['ntp_server2'];
225
		}
226

    
227
		$csc['netbios_enable'] = $pconfig['netbios_enable'];
228
		$csc['netbios_ntype'] = $pconfig['netbios_ntype'];
229
		$csc['netbios_scope'] = $pconfig['netbios_scope'];
230

    
231
		if ($pconfig['netbios_enable']) {
232
			if ($pconfig['wins_server_enable']) {
233
				$csc['wins_server1'] = $pconfig['wins_server1'];
234
				$csc['wins_server2'] = $pconfig['wins_server2'];
235
			}
236

    
237
			if ($pconfig['dns_server_enable'])
238
				$csc['nbdd_server1'] = $pconfig['nbdd_server1'];
239
		}
240

    
241
		if (isset($id) && $a_csc[$id]) {
242
			$old_csc_cn = $a_csc[$id]['common_name'];
243
			$a_csc[$id] = $csc;
244
		} else
245
			$a_csc[] = $csc;
246

    
247
		if (!empty($old_csc_cn))
248
			openvpn_cleanup_csc($old_csc_cn);
249

    
250
		openvpn_resync_csc($csc);
251
		write_config();
252

    
253
		header("Location: vpn_openvpn_csc.php");
254
		exit;
255
	}
256
}
257

    
258
include("head.inc");
259

    
260
if ($input_errors)
261
	print_input_errors($input_errors);
262

    
263
if ($savemsg)
264
	print_info_box($savemsg, 'success');
265

    
266
$tab_array = array();
267
$tab_array[] = array(gettext("Server"), false, "vpn_openvpn_server.php");
268
$tab_array[] = array(gettext("Client"), false, "vpn_openvpn_client.php");
269
$tab_array[] = array(gettext("Client Specific Overrides"), true, "vpn_openvpn_csc.php");
270
$tab_array[] = array(gettext("Wizards"), false, "wizard.php?xml=openvpn_wizard.xml");
271
add_package_tabs("OpenVPN", $tab_array);
272
display_top_tabs($tab_array);
273

    
274
if($act=="new" || $act=="edit"):
275
	require('classes/Form.class.php');
276

    
277
	$form = new Form();
278

    
279
	$section = new Form_Section('General Information');
280

    
281
	$section->addInput(new Form_Checkbox(
282
		'disable',
283
		'Disable',
284
		'Disable this override',
285
		$pconfig['disable']
286
	))->setHelp('Set this option to disable this client-specific override without removing it from the list.');
287

    
288
	$section->addInput(new Form_Input(
289
		'common_name',
290
		'Common name',
291
		'text',
292
		$pconfig['common_name']
293
	))->setHelp('Enter the client\'s X.509 common name.');
294

    
295
	$section->addInput(new Form_Input(
296
		'description',
297
		'Description',
298
		'text',
299
		$pconfig['description']
300
	))->setHelp('You may enter a description here for your reference (not parsed). ');
301

    
302
	$section->addInput(new Form_Checkbox(
303
		'block',
304
		'Connection blocking',
305
		'Block this client connection based on its common name. ',
306
		$pconfig['block']
307
	))->setHelp('Don\'t use this option to permanently disable a client due to a compromised key or password. Use a CRL (certificate revocation list) instead. ');
308

    
309
	$form->add($section);
310

    
311
	$section = new Form_Section('Tunnel settings');
312

    
313
	$section->addInput(new Form_Input(
314
		'tunnel_network',
315
		'Tunnel Network',
316
		'text',
317
		$pconfig['tunnel_network']
318
	))->setHelp('This is the virtual network used for private communications between this client and the server expressed using CIDR (eg. 10.0.8.0/24). ' .
319
				'The first network address is assumed to be the server address and the second network address will be assigned to the client virtual interface. ');
320

    
321
	$section->addInput(new Form_Input(
322
		'local_network',
323
		'IPv4 Local Network/s',
324
		'text',
325
		$pconfig['local_network']
326
	))->setHelp('These are the IPv4 networks that will be accessible from this particular client. Expressed as a comma-separated list of one or more CIDR ranges. ' . '<br />' .
327
				'NOTE: You do not need to specify networks here if they have already been defined on the main server configuration.');
328

    
329
	$section->addInput(new Form_Input(
330
		'local_networkv6',
331
		'IPv6 Local Network/s',
332
		'text',
333
		$pconfig['local_networkv6']
334
	))->setHelp('These are the IPv4 networks that will be accessible from this particular client. Expressed as a comma-separated list of one or more IP/PREFIX networks.' . '<br />' .
335
				'NOTE: You do not need to specify networks here if they have already been defined on the main server configuration.');
336

    
337
	$section->addInput(new Form_Input(
338
		'remote_network',
339
		'IPv4 Remote Network/s',
340
		'text',
341
		$pconfig['remote_network']
342
	))->setHelp('These are the IPv4 networks that will be routed to this client specifically using iroute, so that a site-to-site VPN can be established. ' .
343
				'Expressed as a comma-separated list of one or more CIDR ranges. You may leave this blank if there are no client-side networks to be routed.' . '<br />' .
344
				'NOTE: Remember to add these subnets to the IPv4 Remote Networks list on the corresponding OpenVPN server settings.');
345

    
346
	$section->addInput(new Form_Input(
347
		'remote_networkv6',
348
		'IPv6 Remote Network/s',
349
		'text',
350
		$pconfig['remote_networkv6']
351
	))->setHelp('These are the IPv4 networks that will be routed to this client specifically using iroute, so that a site-to-site VPN can be established. ' .
352
				'Expressed as a comma-separated list of one or more IP/PREFIX networks. You may leave this blank if there are no client-side networks to be routed.' . '<br />' .
353
				'NOTE: Remember to add these subnets to the IPv6 Remote Networks list on the corresponding OpenVPN server settings.');
354

    
355
	$section->addInput(new Form_Checkbox(
356
		'gwredir',
357
		'Redirect Gateway',
358
		'Force all client generated traffic through the tunnel.',
359
		$pconfig['gwredir']
360
	));
361

    
362
	$form->add($section);
363

    
364
	$section = new Form_Section('Client settings');
365

    
366
	// Default domain name
367
	$section->addInput(new Form_Checkbox(
368
		'push_reset',
369
		'Server Definitions',
370
		'Prevent this client from receiving any server-defined client settings. ',
371
		$pconfig['push_reset']
372
	));
373

    
374
	$section->addInput(new Form_Checkbox(
375
		'dns_domain_enable',
376
		'DNS Default Domain',
377
		'Provide a default domain name to clients',
378
		$pconfig['dns_domain_enable']
379
	))->toggles('.dnsdomain');
380

    
381
	$group = new Form_Group('DNS Domain');
382
	$group->addClass('dnsdomain');
383

    
384
	$group->add(new Form_Input(
385
		'dns_domain',
386
		'DNS Domain',
387
		'text',
388
		$pconfig['dns_domain']
389
	));
390

    
391
	$section->add($group);
392

    
393
	// DNS servers
394
	$section->addInput(new Form_Checkbox(
395
		'dns_server_enable',
396
		'DNS Servers',
397
		'Provide a DNS server list to clients',
398
		$pconfig['dns_server_enable']
399
	))->toggles('.dnsservers');
400

    
401
	$group = new Form_Group(null);
402
	$group->addClass('dnsservers');
403

    
404
	$group->add(new Form_Input(
405
		'dns_server1',
406
		null,
407
		'text',
408
		$pconfig['dns_server1']
409
	))->setHelp('Server 1');
410

    
411
	$group->add(new Form_Input(
412
		'dns_server2',
413
		null,
414
		'text',
415
		$pconfig['dns_server2']
416
	))->setHelp('Server 2');
417

    
418
	$group->add(new Form_Input(
419
		'dns_server3',
420
		null,
421
		'text',
422
		$pconfig['dns_server3']
423
	))->setHelp('Server 3');
424

    
425
	$group->add(new Form_Input(
426
		'dns_server4',
427
		null,
428
		'text',
429
		$pconfig['dns_server4']
430
	))->setHelp('Server 4');
431

    
432
	$section->add($group);
433

    
434
	// NTP servers
435
	$section->addInput(new Form_Checkbox(
436
		'ntp_server_enable',
437
		'NTP Servers',
438
		'Provide an NTP server list to clients',
439
		$pconfig['ntp_server_enable']
440
	))->toggles('.ntpservers');
441

    
442
	$group = new Form_Group(null);
443
	$group->addClass('ntpservers');
444

    
445
	$group->add(new Form_Input(
446
		'ntp_server1',
447
		null,
448
		'text',
449
		$pconfig['ntp_server1']
450
	))->setHelp('Server 1');
451

    
452
	$group->add(new Form_Input(
453
		'ntp_server2',
454
		null,
455
		'text',
456
		$pconfig['ntp_server2']
457
	))->setHelp('Server 2');
458

    
459
	$section->add($group);
460

    
461
	// NTP servers - For this section we need to use Javascript hiding since there
462
	// are nested toggles
463
	$section->addInput(new Form_Checkbox(
464
		'netbios_enable',
465
		'Netbios Option',
466
		'Enable Netbios over TCP/IP',
467
		$pconfig['netbios_enable']
468
	))->setHelp('If this option is not set, all NetBIOS-over-TCP/IP options (including WINS) will be disabled. ');
469

    
470
	$section->addInput(new Form_Select(
471
		'netbios_ntype',
472
		'Node Type',
473
		$pconfig['netbios_ntype'],
474
		$netbios_nodetypes
475
	))->setHelp('Possible options: b-node (broadcasts), p-node (point-to-point name queries to a WINS server), m-node (broadcast then query name server), ' .
476
				'and h-node (query name server, then broadcast). ');
477

    
478
	$section->addInput(new Form_Input(
479
		'netbios_scope',
480
		null,
481
		'text',
482
		$pconfig['netbios_scope']
483
	))->setHelp('A NetBIOS Scope ID provides an extended naming service for NetBIOS over TCP/IP. ' .
484
				'The NetBIOS scope ID isolates NetBIOS traffic on a single network to only those nodes with the same NetBIOS scope ID. ');
485

    
486
	$section->addInput(new Form_Checkbox(
487
		'wins_server_enable',
488
		'WINS servers',
489
		'Provide a WINS server list to clients',
490
		$pconfig['wins_server_enable']
491
	));
492

    
493
	$group = new Form_Group(null);
494

    
495
	$group->add(new Form_Input(
496
		'wins_server1',
497
		null,
498
		'text',
499
		$pconfig['wins_server1']
500
	))->setHelp('Server 1');
501

    
502
	$group->add(new Form_Input(
503
		'wins_server2',
504
		null,
505
		'text',
506
		$pconfig['wins_server2']
507
	))->setHelp('Server 2');
508

    
509
	$group->addClass('winsservers');
510

    
511
	$section->add($group);
512

    
513
	$section->addInput(new Form_TextArea(
514
		'custom_options',
515
		'Advanced',
516
		$pconfig['custom_options']
517
	))->setHelp('Enter any additional options you would like to add for this client specific override, separated by a semicolon. ' . '<br />' .
518
				'EXAMPLE: push "route 10.0.0.0 255.255.255.0"; ');
519

    
520
	// The hidden fields
521
	$section->addInput(new Form_Input(
522
		'act',
523
		null,
524
		'hidden',
525
		$act
526
	));
527

    
528
	if (isset($id) && $a_csc[$id]) {
529
		$section->addInput(new Form_Input(
530
			'id',
531
			null,
532
			'hidden',
533
			$id
534
		));
535
	}
536

    
537
	$form->add($section);
538
	print($form);
539

    
540
?>
541

    
542
<script>
543
//<![CDATA[
544
events.push(function(){
545
	var visible = false;
546

    
547
	// Hides the <div> in which the specified input element lives so that the input, its label and help text are hidden
548
	function hideInput(id, hide) {
549
		if(hide)
550
			$('#' + id).parent().parent('div').addClass('hidden');
551
		else
552
			$('#' + id).parent().parent('div').removeClass('hidden');
553
	}
554

    
555
	// Hides the <div> in which the specified checkbox lives so that the checkbox, its label and help text are hidden
556
	function hideCheckbox(id, hide) {
557
		if(hide)
558
			$('#' + id).parent().parent().parent('div').addClass('hidden');
559
		else
560
			$('#' + id).parent().parent().parent('div').removeClass('hidden');
561
	}
562

    
563
	// Hides all elements of the specified class. This will usually be a section or group
564
	function hideClass(s_class, hide) {
565
		if(hide)
566
			$('.' + s_class).hide();
567
		else
568
			$('.' + s_class).show();
569
	}
570

    
571
	// Hide/show that section, but have to also respect the wins_server_enable checkbox
572
	function setNetbios() {
573
		if($('#netbios_enable').prop('checked')) {
574
			hideInput('netbios_ntype', false);
575
			hideInput('netbios_scope', false);
576
			hideCheckbox('wins_server_enable', false);
577
			setWins();
578
		} else {
579
			hideInput('netbios_ntype', true);
580
			hideInput('netbios_scope', true);
581
			hideCheckbox('wins_server_enable', true);
582
			hideClass('winsservers', true);
583
		}
584
	}
585

    
586
	function setWins() {
587
		hideClass('winsservers', ! $('#wins_server_enable').prop('checked'));
588
	}
589

    
590
	// On clicking the netbios_enable checkbox
591
	$('#netbios_enable').click(function () {
592
		setNetbios();
593
	});
594

    
595
	// On clicking the wins_server_enable checkbox
596
	$('#wins_server_enable').click(function () {
597
		setWins();
598
	});
599

    
600
	// On initial page load
601
	setNetbios();
602
});
603
//]]>
604
</script>
605

    
606
<?php
607
else :  // Not an 'add' or an 'edit'. Just the table of Override CSCs
608
?>
609

    
610
<div class="panel panel-default">
611
	<div class="panel-heading"><?=gettext('CSC Overrides')?></div>
612
	<div class="panel-body table-responsive">
613
		<table class="table table-striped table-hover table-condensed">
614
			<thead>
615
				<tr>
616
					<th><?=gettext("Disabled")?></th>
617
					<th><?=gettext("Common Name")?></th>
618
					<th><?=gettext("Description")?></th>
619
					<th> <!-- Buttons --></th>
620
				</tr>
621
			</thead>
622
			<tbody>
623
<?php
624
	$i = 0;
625
	foreach($a_csc as $csc):
626
		$disabled = isset($csc['disable']) ? "Yes":"No";
627
?>
628
				<tr>
629
					<td class="listlr">
630
						<?=$disabled?>
631
					</td>
632
					<td class="listr">
633
						<?=htmlspecialchars($csc['common_name'])?>
634
					</td>
635
					<td class="listbg">
636
						<?=htmlspecialchars($csc['description'])?>
637
					</td>
638
					<td>
639
						<a href="vpn_openvpn_csc.php?act=edit&amp;id=<?=$i?>" class="btn btn-info btn-xs"><?=gettext('Edit')?></a>
640
						<a href="vpn_openvpn_csc.php?act=del&amp;id=<?=$i?>" class="btn btn-danger btn-xs"><?=gettext('Delete')?></a>
641
					</td>
642
				</tr>
643
<?php
644
	   $i++;
645
	endforeach;
646
?>
647
			</tbody>
648
		</table>
649

    
650
		<nav class="action-buttons">
651
			<a href="vpn_openvpn_csc.php?act=new" class="btn btn-success btn-sm"><?=gettext('Add CSC')?></a>
652
		</nav>
653

    
654
	</div>
655
</div>
656

    
657
<?php
658
endif;
659
include("foot.inc");
(233-233/241)