vpn_openvpn_csc.php 31.6 KB
Newer Older
1
<?php
2

Ad Schellevis's avatar
Ad Schellevis committed
3
/*
4
	Copyright (C) 2014-2015 Deciso B.V.
Ad Schellevis's avatar
Ad Schellevis committed
5
	Copyright (C) 2008 Shrew Soft Inc.
6
	All rights reserved.
Ad Schellevis's avatar
Ad Schellevis committed
7 8 9

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

Ad Schellevis's avatar
Ad Schellevis committed
11 12
	1. Redistributions of source code must retain the above copyright notice,
	   this list of conditions and the following disclaimer.
13

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

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

30
require_once("guiconfig.inc");
Ad Schellevis's avatar
Ad Schellevis committed
31
require_once("openvpn.inc");
32
require_once("services.inc");
33
require_once("interfaces.inc");
34
require_once('pfsense-utils.inc');
Ad Schellevis's avatar
Ad Schellevis committed
35

36
$service_hook = 'openvpn';
Ad Schellevis's avatar
Ad Schellevis committed
37

38 39 40 41 42 43 44 45 46
// define all fields used in this form
$all_form_fields = "custom_options,disable,common_name,block,description
,tunnel_network,local_network,local_networkv6,remote_network
,remote_networkv6,gwredir,push_reset,dns_domain,dns_server1
,dns_server2,dns_server3,dns_server4,ntp_server1,ntp_server2
,netbios_enable,netbios_ntype,netbios_scope,wins_server1
,wins_server2";

// read config.
47
if (!isset($config['openvpn']['openvpn-csc'])) {
48 49
    $config['openvpn']['openvpn-csc'] = array();
}
Ad Schellevis's avatar
Ad Schellevis committed
50 51
$a_csc = &$config['openvpn']['openvpn-csc'];

52 53 54
$vpnid = 0;
$act=null;
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
        $pconfig = array();
    if (isset($_GET['act'])) {
            $act = $_GET['act'];
    }
    if (isset($_GET['id']) && is_numericint($_GET['id'])) {
        $id = $_GET['id'];
    }

    if ($act=="edit" && isset($id) && isset($a_csc[$id])) {
            // 1 on 1 copy of config attributes
        foreach (explode(",", $all_form_fields) as $fieldname) {
            $fieldname = trim($fieldname);
            if (isset($a_csc[$id][$fieldname])) {
                $pconfig[$fieldname] = $a_csc[$id][$fieldname];
            } elseif (!isset($pconfig[$fieldname])) {
                // initialize element
                $pconfig[$fieldname] = null;
            }
        }
    } else {
            // init all form attributes
        foreach (explode(",", $all_form_fields) as $fieldname) {
                $fieldname = trim($fieldname);
            if (!isset($pconfig[$fieldname])) {
                    $pconfig[$fieldname] = null;
            }
        }
    }
83
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
84 85 86 87 88 89 90 91 92 93 94
        $input_errors = array();
        $pconfig = $_POST;
    if (isset($_POST['act'])) {
        $act = $_POST['act'];
    }
    if (isset($_POST['id']) && is_numericint($_POST['id'])) {
        $id = $_POST['id'];
    }

    if ($act == "del") {
        if (!isset($a_csc[$id])) {
95
            header("Location: vpn_openvpn_csc.php");
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
            exit;
        }

            @unlink("/var/etc/openvpn-csc/{$a_csc[$id]['common_name']}");
        unset($a_csc[$id]);
        write_config();
    } else {
            /* perform validations */
        if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'Tunnel network')) {
            $input_errors[] = $result;
        }
        if ($result = openvpn_validate_cidr($pconfig['local_network'], 'IPv4 Local Network', true, "ipv4")) {
            $input_errors[] = $result;
        }
        if ($result = openvpn_validate_cidr($pconfig['local_networkv6'], 'IPv6 Local Network', true, "ipv6")) {
            $input_errors[] = $result;
        }
        if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'IPv4 Remote Network', true, "ipv4")) {
            $input_errors[] = $result;
        }
        if ($result = openvpn_validate_cidr($pconfig['remote_networkv6'], 'IPv6 Remote Network', true, "ipv6")) {
            $input_errors[] = $result;
        }

        if (!empty($pconfig['dns_server_enable'])) {
            if (!empty($pconfig['dns_server1']) && !is_ipaddr(trim($pconfig['dns_server1']))) {
                $input_errors[] = gettext("The field 'DNS Server #1' must contain a valid IP address");
            }
            if (!empty($pconfig['dns_server2']) && !is_ipaddr(trim($pconfig['dns_server2']))) {
                $input_errors[] = gettext("The field 'DNS Server #2' must contain a valid IP address");
            }
            if (!empty($pconfig['dns_server3']) && !is_ipaddr(trim($pconfig['dns_server3']))) {
                $input_errors[] = gettext("The field 'DNS Server #3' must contain a valid IP address");
            }
            if (!empty($pconfig['dns_server4']) && !is_ipaddr(trim($pconfig['dns_server4']))) {
                $input_errors[] = gettext("The field 'DNS Server #4' must contain a valid IP address");
            }
        }

        if (!empty($pconfig['ntp_server_enable'])) {
            if (!empty($pconfig['ntp_server1']) && !is_ipaddr(trim($pconfig['ntp_server1']))) {
                $input_errors[] = gettext("The field 'NTP Server #1' must contain a valid IP address");
            }
            if (!empty($pconfig['ntp_server2']) && !is_ipaddr(trim($pconfig['ntp_server2']))) {
                $input_errors[] = gettext("The field 'NTP Server #2' must contain a valid IP address");
            }
            if (!empty($pconfig['ntp_server3']) && !is_ipaddr(trim($pconfig['ntp_server3']))) {
                $input_errors[] = gettext("The field 'NTP Server #3' must contain a valid IP address");
            }
            if (!empty($pconfig['ntp_server4']) && !is_ipaddr(trim($pconfig['ntp_server4']))) {
                $input_errors[] = gettext("The field 'NTP Server #4' must contain a valid IP address");
            }
        }

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

        $reqdfields[] = 'common_name';
        $reqdfieldsn[] = 'Common name';

        do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);

        if (count($input_errors) == 0) {
            $csc = array();
                    // 1 on 1 copy of config attributes
            foreach (explode(",", $all_form_fields) as $fieldname) {
                    $fieldname = trim($fieldname);
                if (!empty($pconfig[$fieldname])) {
                        $csc[$fieldname] = $pconfig[$fieldname];
                }
            }

                    // handle fields with some kind of logic
            if (!empty($pconfig['disable']) && $pconfig['disable'] == "yes") {
                $csc['disable'] = true;
            }

            if (isset($id) && $a_csc[$id]) {
                $old_csc_cn = $a_csc[$id]['common_name'];
                $a_csc[$id] = $csc;
            } else {
                $a_csc[] = $csc;
            }

            if (!empty($old_csc_cn)) {
                        @unlink('/var/etc/openvpn-csc/' . basename($old_csc_cn));
            }
                    openvpn_resync_csc($csc);
                    write_config();

                    header("Location: vpn_openvpn_csc.php");
                    exit;
        }
    }
198
}
Ad Schellevis's avatar
Ad Schellevis committed
199

200 201
// escape form output before processing
legacy_html_escape_form_data($pconfig);
Ad Schellevis's avatar
Ad Schellevis committed
202 203 204 205 206

include("head.inc");

?>

207
<body>
208

Ad Schellevis's avatar
Ad Schellevis committed
209 210 211
<script type="text/javascript">
//<![CDATA[

212 213 214 215 216
$( document ).ready(function() {
	// link delete buttons
	$(".act_delete").click(function(){
		var id = $(this).attr("id").split('_').pop(-1);
		BootstrapDialog.show({
Fabian Franz's avatar
Fabian Franz committed
217
				type:BootstrapDialog.TYPE_DANGER,
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
				title: "<?= gettext("OpenVPN");?>",
				message: "<?= gettext("Do you really want to delete this csc?"); ?>",
				buttons: [{
                label: "<?= gettext("No");?>",
                action: function(dialogRef) {
                    dialogRef.close();
                }}, {
									label: "<?= gettext("Yes");?>",
									action: function(dialogRef) {
										$.post(window.location, {act: 'del', id:id}, function(data) {
													location.reload();
										});
										dialogRef.close();
								}
            }]
		});
	});
	// init form (old stuff)
	if (document.iform != undefined) {
		dns_domain_change();
		dns_server_change();
		wins_server_change();
		ntp_server_change();
		netbios_change();
	}

});


Ad Schellevis's avatar
Ad Schellevis committed
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
function dns_domain_change() {

	if (document.iform.dns_domain_enable.checked)
		document.getElementById("dns_domain_data").style.display="";
	else
		document.getElementById("dns_domain_data").style.display="none";
}

function dns_server_change() {

	if (document.iform.dns_server_enable.checked)
		document.getElementById("dns_server_data").style.display="";
	else
		document.getElementById("dns_server_data").style.display="none";
}

function wins_server_change() {

	if (document.iform.wins_server_enable.checked)
		document.getElementById("wins_server_data").style.display="";
	else
		document.getElementById("wins_server_data").style.display="none";
}

function ntp_server_change() {

	if (document.iform.ntp_server_enable.checked)
		document.getElementById("ntp_server_data").style.display="";
	else
		document.getElementById("ntp_server_data").style.display="none";
}

function netbios_change() {

	if (document.iform.netbios_enable.checked) {
		document.getElementById("netbios_data").style.display="";
		document.getElementById("wins_opts").style.display="";
	} else {
		document.getElementById("netbios_data").style.display="none";
		document.getElementById("wins_opts").style.display="none";
	}
}

//]]>
</script>
292 293 294

<?

295 296 297 298
if ($act!="new" && $act!="edit") {
    $main_buttons = array(
        array('href'=>'vpn_openvpn_csc.php?act=new', 'label'=>gettext("add csc")),
    );
299 300
}

Ad Schellevis's avatar
Ad Schellevis committed
301
?>
302 303 304 305

<?php include("fbegin.inc"); ?>

	<section class="page-content-main">
306
		<div class="container-fluid">
307
			<div class="row">
308

Ad Schellevis's avatar
Ad Schellevis committed
309
				<?php
310
                if (isset($input_errors) && count($input_errors) > 0) {
311 312
                    print_input_errors($input_errors);
                }
313
                if (isset($savemsg)) {
314 315 316
                    print_info_box($savemsg);
                }
                ?>
317 318


319
			    <section class="col-xs-12">
Ad Schellevis's avatar
Ad Schellevis committed
320
					<div class="tab-content content-box col-xs-12">
321

322 323
							<?php if ($act=="new" || $act=="edit") :
?>
324
							<form action="vpn_openvpn_csc.php" method="post" name="iform" id="iform">
325
							 <div class="table-responsive">
326 327
								<table class="table table-striped table-sort">
									<tr>
328 329 330
										<td width="22%"><?=gettext("General information"); ?></td>
										<td width="78%" align="right">
											<small><?=gettext("full help"); ?> </small>
331
											<i class="fa fa-toggle-off text-danger" style="cursor: pointer;" id="show_all_help_page" type="button"></i></a>
332
										</td>
333
									</tr>
334
									<tr>
335
										<td width="22%" valign="top" class="vncellreq"><a id="help_for_disable" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Disabled"); ?></td>
336
										<td width="78%" class="vtable">
337 338 339 340
											<input name="disable" type="checkbox" value="yes" <?= !empty($pconfig['disable']) ? "checked=\"checked\"" : "";?> />
											<div class="hidden" for="help_for_disable">
												<?=gettext("Set this option to disable this client-specific override without removing it from the list"); ?>
											</div>
341 342
										</td>
									</tr>
343
									<tr>
344
										<td width="22%" valign="top" class="vncellreq"><a id="help_for_common_name" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Common name"); ?></td>
345
										<td width="78%" class="vtable">
346 347 348 349
											<input name="common_name" type="text" class="formfld unknown" size="30" value="<?=$pconfig['common_name'];?>" />
											<div class="hidden" for="help_for_common_name">
												<?=gettext("Enter the client's X.509 common name here"); ?>.
											</div>
350 351
										</td>
									</tr>
352
									<tr>
353
										<td width="22%" valign="top" class="vncell"><a id="help_for_description" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Description"); ?></td>
354
										<td width="78%" class="vtable">
355 356
											<input name="description" type="text" class="formfld unknown" size="30" value="<?=$pconfig['description'];?>" />
											<div class="hidden" for="help_for_description">
357
												<?=gettext("You may enter a description here for your reference (not parsed)"); ?>.
358
											</div>
359 360 361
										</td>
									</tr>
									<tr>
362
										<td width="22%" valign="top" class="vncell"><a id="help_for_block" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Connection blocking"); ?></td>
363
										<td width="78%" class="vtable">
364 365 366 367
											<input name="block" type="checkbox" value="yes" <?= !empty($pconfig['block']) ? "checked=\"checked\"" : "";?> />
											<div class="hidden" for="help_for_block">
													<?=gettext("Block this client connection based on its common name"); ?>.<br/>
													<?=gettext("Don't use this option to permanently disable a " .
368 369
                                                     "client due to a compromised key or password. " .
                                                     "Use a CRL (certificate revocation list) instead"); ?>.
370
											</div>
371 372 373 374 375 376 377 378 379
										</td>
									</tr>
									<tr>
										<td colspan="2" class="list" height="12"></td>
									</tr>
									<tr>
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Tunnel Settings"); ?></td>
									</tr>
									<tr>
380
										<td width="22%" valign="top" class="vncell"><a id="help_for_tunnel_network" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Tunnel Network"); ?></td>
381
										<td width="78%" class="vtable">
382 383 384
											<input name="tunnel_network" type="text" class="formfld unknown" size="20" value="<?=$pconfig['tunnel_network'];?>" />
											<div class="hidden" for="help_for_tunnel_network">
												<?=gettext("This is the virtual network used for private " .
385 386 387 388 389 390
                                                "communications between this client and the " .
                                                "server expressed using CIDR (eg. 10.0.8.0/24). " .
                                                "The first network address is assumed to be the " .
                                                "server address and the second network address " .
                                                "will be assigned to the client virtual " .
                                                "interface"); ?>.
391
											</div>
392 393 394
										</td>
									</tr>
									<tr id="local_optsv4">
395
										<td width="22%" valign="top" class="vncell"><a id="help_for_local_network" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("IPv4 Local Network/s"); ?></td>
396
										<td width="78%" class="vtable">
397 398 399
											<input name="local_network" type="text" class="formfld unknown" size="40" value="<?=$pconfig['local_network'];?>" />
											<div class="hidden" for="help_for_local_network">
												<?=gettext("These are the IPv4 networks that will be accessible " .
400
                                                "from this particular client. Expressed as a comma-separated list of one or more CIDR ranges."); ?>
401
											<br /><?=gettext("NOTE: You do not need to specify networks here if they have " .
402
                                            "already been defined on the main server configuration.");?>
403
											</div>
404 405 406
										</td>
									</tr>
									<tr id="local_optsv6">
407
										<td width="22%" valign="top" class="vncell"><a id="help_for_local_networkv6" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("IPv6 Local Network/s"); ?></td>
408
										<td width="78%" class="vtable">
409 410
											<input name="local_networkv6" type="text" class="formfld unknown" size="40" value="<?=$pconfig['local_networkv6'];?>" />
											<div class="hidden" for="help_for_local_networkv6">
411 412 413 414
                                                    <?=gettext("These are the IPv6 networks that will be accessible " .
                                                    "from this particular client. Expressed as a comma-separated list of one or more IP/PREFIX networks."); ?><br />
                                                    <?=gettext("NOTE: You do not need to specify networks here if they have " .
                                                    "already been defined on the main server configuration.");?>
415
											</div>
416 417 418
										</td>
									</tr>
									<tr id="remote_optsv4">
419
										<td width="22%" valign="top" class="vncell"><a id="help_for_remote_network" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("IPv4 Remote Network/s"); ?></td>
420
										<td width="78%" class="vtable">
421 422 423
											<input name="remote_network" type="text" class="formfld unknown" size="40" value="<?=$pconfig['remote_network'];?>" />
											<div class="hidden" for="help_for_remote_network">
												<?=gettext("These are the IPv4 networks that will be routed " .
424 425 426 427 428
                                                "to this client specifically using iroute, so that a site-to-site " .
                                                "VPN can be established. " .
                                                "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 />
429
												<?=gettext("NOTE: Remember to add these subnets to the " .
430
                                                "IPv4 Remote Networks list on the corresponding OpenVPN server settings.");?>
431
											</div>
432 433 434
										</td>
									</tr>
									<tr id="remote_optsv6">
435
										<td width="22%" valign="top" class="vncell"><a id="help_for_remote_networkv6" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("IPv6 Remote Network/s"); ?></td>
436
										<td width="78%" class="vtable">
437 438 439
											<input name="remote_networkv6" type="text" class="formfld unknown" size="40" value="<?=$pconfig['remote_networkv6'];?>" />
											<div class="hidden" for="help_for_remote_networkv6">
												<?=gettext("These are the IPv6 networks that will be routed " .
440 441 442 443
                                                "to this client specifically using iroute, so that a site-to-site " .
                                                "VPN can be established. " .
                                                "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 " .
444
                                                "be routed."); ?><br />
445
												<?=gettext("NOTE: Remember to add these subnets to the " .
446
                                                "IPv6 Remote Networks list on the corresponding OpenVPN server settings.");?>
447
											</div>
448 449 450
										</td>
									</tr>
									<tr>
451
										<td width="22%" valign="top" class="vncell"><a id="help_for_gwredir" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Redirect Gateway"); ?></td>
452
										<td width="78%" class="vtable">
453 454 455 456
											<input name="gwredir" type="checkbox" value="yes" <?= !empty($pconfig['gwredir']) ? "checked=\"checked\"" : "";?> />
											<div class="hidden" for="help_for_gwredir">
												<?=gettext("Force all client generated traffic through the tunnel"); ?>.
											</div>
457 458 459 460 461 462 463 464 465
										</td>
									</tr>
									<tr>
										<td colspan="2" class="list" height="12"></td>
									</tr>
									<tr>
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Client Settings"); ?></td>
									</tr>
									<tr>
466
										<td width="22%" valign="top" class="vncell"><a id="help_for_push_reset" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a>  <?=gettext("Server Definitions"); ?></td>
467
										<td width="78%" class="vtable">
468 469
											<input name="push_reset" type="checkbox" value="yes" <?= !empty($pconfig['push_reset']) ? "checked=\"checked\"" : "";?> />
											<div class="hidden" for="help_for_push_reset">
470
													<?=gettext("Prevent this client from receiving any server-defined client settings."); ?>
471
											</div>
472 473 474
										</td>
									</tr>
									<tr>
475
										<td width="22%" valign="top" class="vncell"><a id="help_for_dns_domain" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("DNS Default Domain"); ?></td>
476
										<td width="78%" class="vtable">
477 478 479 480 481 482 483
											<input name="dns_domain_enable" type="checkbox" id="dns_domain_enable" value="yes" <?= !empty($pconfig['dns_domain']) ? "checked=\"checked\"" : "";?> onclick="dns_domain_change()" />
											<div id="dns_domain_data">
												<input name="dns_domain" type="text" class="formfld unknown" id="dns_domain" size="30" value="<?=$pconfig['dns_domain'];?>" />
											</div>
											<div class="hidden" for="help_for_dns_domain">
												<?=gettext("Provide a default domain name to clients"); ?><br />
											</div>
484 485 486
										</td>
									</tr>
									<tr>
487
										<td width="22%" valign="top" class="vncell"><a id="help_for_dns_server" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("DNS Servers"); ?></td>
488
										<td width="78%" class="vtable">
489 490
											<input name="dns_server_enable" type="checkbox" id="dns_server_enable" value="yes" <?=!empty($pconfig['dns_server1']) || !empty($pconfig['dns_server2']) || !empty($pconfig['dns_server3']) || !empty($pconfig['dns_server4']) ? "checked=\"checked\"" : "" ;?> onclick="dns_server_change()" />
											<div id="dns_server_data">
491
												<?=gettext("Server #1:"); ?>&nbsp;
492
												<input name="dns_server1" type="text" class="formfld unknown" id="dns_server1" size="20" value="<?=htmlspecialchars($pconfig['dns_server1']);?>" />
493
												<?=gettext("Server #2:"); ?>&nbsp;
494
												<input name="dns_server2" type="text" class="formfld unknown" id="dns_server2" size="20" value="<?=htmlspecialchars($pconfig['dns_server2']);?>" />
495
												<?=gettext("Server #3:"); ?>&nbsp;
496
												<input name="dns_server3" type="text" class="formfld unknown" id="dns_server3" size="20" value="<?=htmlspecialchars($pconfig['dns_server3']);?>" />
497
												<?=gettext("Server #4:"); ?>&nbsp;
498 499 500 501 502
												<input name="dns_server4" type="text" class="formfld unknown" id="dns_server4" size="20" value="<?=htmlspecialchars($pconfig['dns_server4']);?>" />
											</div>
											<div class="hidden" for="help_for_dns_server">
												<?=gettext("Provide a DNS server list to clients"); ?>
											</div>
503 504 505
										</td>
									</tr>
									<tr>
506
										<td width="22%" valign="top" class="vncell"><a id="help_for_ntp_server" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("NTP Servers"); ?></td>
507
										<td width="78%" class="vtable">
508 509
											<input name="ntp_server_enable" type="checkbox" id="ntp_server_enable" value="yes" <?=!empty($pconfig['ntp_server1']) || !empty($pconfig['ntp_server2']) ? "checked=\"checked\"" : "" ;?> onclick="ntp_server_change()" />
											<div id="ntp_server_data">
510
												<?=gettext("Server #1:"); ?>&nbsp;
511
												<input name="ntp_server1" type="text" class="formfld unknown" id="ntp_server1" size="20" value="<?=$pconfig['ntp_server1'];?>" />
512
												<?=gettext("Server #2:"); ?>&nbsp;
513 514 515 516 517
												<input name="ntp_server2" type="text" class="formfld unknown" id="ntp_server2" size="20" value="<?=$pconfig['ntp_server2'];?>" />
											</div>
											<div class="hidden" for="help_for_ntp_server">
												<?=gettext("Provide a NTP server list to clients"); ?>
											</div>
518 519 520
										</td>
									</tr>
									<tr>
521
										<td width="22%" valign="top" class="vncell"><a id="help_for_netbios_enable" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("NetBIOS Options"); ?></td>
522
										<td width="78%" class="vtable">
523 524 525 526 527 528 529 530 531 532
											<input name="netbios_enable" type="checkbox" id="netbios_enable" value="yes" <?=!empty($pconfig['netbios_enable']) ? "checked=\"checked\"" : "" ;?> onclick="netbios_change()" />
											<?=gettext("Enable NetBIOS over TCP/IP");?>
											<div class="hidden" for="help_for_netbios_enable">
												<?=gettext("If this option is not set, all NetBIOS-over-TCP/IP options (including WINS) will be disabled"); ?>.
											</div>

											<div id="netbios_data">
												<?=gettext("Node Type"); ?>:&nbsp;
												<select name='netbios_ntype' class="formselect">
												<?php
533 534 535 536 537 538 539
                                                foreach ($netbios_nodetypes as $type => $name) :
                                                        $selected = "";
                                                    if ($pconfig['netbios_ntype'] == $type) {
                                                            $selected = "selected=\"selected\"";
                                                    }
                                                ?>
                                                <option value="<?=$type;
540 541
?>" <?=$selected;
?>><?=$name;?></option>
542 543
<?php
                                                endforeach; ?>
544 545 546 547
												</select>

												<div class="hidden" for="help_for_netbios_enable">
													<?=gettext("Possible options: b-node (broadcasts), p-node " .
548 549
                                                    "(point-to-point name queries to a WINS server), " .
                                                    "m-node (broadcast then query name server), and " .
550
                                                    "h-node (query name server, then broadcast)."); ?>
551 552 553 554 555
												</div>
												Scope ID:&nbsp;
												<input name="netbios_scope" type="text" class="formfld unknown" id="netbios_scope" size="30" value="<?=$pconfig['netbios_scope'];?>" />
												<div class="hidden" for="help_for_netbios_enable">
													<?=gettext("A NetBIOS Scope	ID provides an extended naming " .
556 557 558
                                                    "service for	NetBIOS over TCP/IP. The NetBIOS " .
                                                    "scope ID isolates NetBIOS traffic on a single " .
                                                    "network to only those nodes with the same " .
559
                                                    "NetBIOS scope ID."); ?>
560 561
												</div>
											</div>
562 563 564
										</td>
									</tr>
									<tr id="wins_opts">
565
										<td width="22%" valign="top" class="vncell"><a id="help_for_wins_server" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("WINS Servers"); ?></td>
566
										<td width="78%" class="vtable">
567 568
											<input name="wins_server_enable" type="checkbox" id="wins_server_enable" value="yes"  <?=!empty($pconfig['wins_server1']) || !empty($pconfig['wins_server2']) ? "checked=\"checked\"" : "" ;?> onclick="wins_server_change()" />
											<div id="wins_server_data">
569
												<?=gettext("Server #1:"); ?>
570
												<input name="wins_server1" type="text" class="formfld unknown" id="wins_server1" size="20" value="<?=$pconfig['wins_server1'];?>" />
571
												<?=gettext("Server #2:"); ?>
572 573 574 575 576
												<input name="wins_server2" type="text" class="formfld unknown" id="wins_server2" size="20" value="<?=$pconfig['wins_server2'];?>" />
											</div>
											<div class="hidden" for="help_for_wins_server">
												<?=gettext("Provide a WINS server list to clients"); ?>
											</div>
577 578 579
										</td>
									</tr>
									<tr>
580
										<td width="22%" valign="top" class="vncell"><a id="help_for_custom_options" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Advanced"); ?></td>
581
										<td width="78%" class="vtable">
582 583 584 585 586
											<textarea rows="6" cols="70" name="custom_options" id="custom_options"><?=$pconfig['custom_options'];?></textarea>
											<div class="hidden" for="help_for_custom_options">
												<?=gettext("Enter any additional options you would like to add for this client specific override, separated by a semicolon"); ?><br />
												<?=gettext("EXAMPLE: push \"route 10.0.0.0 255.255.255.0\""); ?>;
											</div>
587 588 589 590
										</td>
									</tr>
									<tr>
										<td width="22%" valign="top">&nbsp;</td>
591 592
										<td width="78%">
											<input name="save" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" />
593
											<input name="act" type="hidden" value="<?=$act;?>" />
594 595
											<?php if (isset($id) && $a_csc[$id]) :
?>
596
											<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
597 598
											<?php
endif; ?>
599 600 601 602 603
										</td>
									</tr>
								</table>
							 </div>
							</form>
604

605 606 607
							<?php
else :
?>
608

609
							<div class="table-responsive">
610
								<table class="table table-striped">
611 612 613 614 615 616 617
									<tr>
										<td width="10%" class="listhdrr"><?=gettext("Disabled"); ?></td>
										<td width="40%" class="listhdrr"><?=gettext("Common Name"); ?></td>
										<td width="40%" class="listhdrr"><?=gettext("Description"); ?></td>
										<td width="10%" class="list"></td>
									</tr>
									<?php
618 619 620 621 622 623 624
                                        $i = 0;
                                    foreach ($a_csc as $csc) :
                                        $disabled = "NO";
                                        if (isset($csc['disable'])) {
                                            $disabled = "YES";
                                        }
                                    ?>
625
									<tr ondblclick="document.location='vpn_openvpn_csc.php?act=edit&amp;id=<?=$i;?>'">
626 627 628 629 630 631 632 633 634 635
                                    <td class="listlr">
                                        <?=$disabled;?>
                                    </td>
                                    <td class="listr">
                                        <?=htmlspecialchars($csc['common_name']);?>
                                    </td>
                                    <td class="listbg">
                                        <?=htmlspecialchars($csc['description']);?>
                                    </td>
                                    <td valign="middle" class="list nowrap">
636
																			<a href="vpn_openvpn_csc.php?act=edit&amp;id=<?=$i;?>" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a>
637
																			<a id="del_<?=$i;
638
?>" title="<?=gettext("delete csc"); ?>" class="act_delete btn btn-default btn-xs"><span class="fa fa-trash text-muted"></span></a>
639
                                    </td>
640 641
									</tr>
									<?php
642 643 644
                                    $i++;
                                    endforeach;
                                    ?>
645

646
									<tr>
647
										<td colspan="4">
648 649 650 651 652 653 654
											<p>
												<?=gettext("Additional OpenVPN client specific overrides can be added here.");?>
											</p>
										</td>
									</tr>
								</table>
							</div>
655 656
				    <?php
endif; ?>
657

658 659 660 661 662 663 664
					</div>
			    </section>
			</div>
		</div>
	</section>

<?php include("foot.inc"); ?>