vpn_openvpn_csc.php 36.5 KB
Newer Older
1
<?php
Ad Schellevis's avatar
Ad Schellevis committed
2
/*
3
	Copyright (C) 2014-2015 Deciso B.V.
Ad Schellevis's avatar
Ad Schellevis committed
4
	Copyright (C) 2008 Shrew Soft Inc.
5
	All rights reserved.
Ad Schellevis's avatar
Ad Schellevis committed
6 7 8

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

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

Ad Schellevis's avatar
Ad Schellevis committed
13 14 15
	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.
16

Ad Schellevis's avatar
Ad Schellevis committed
17 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
require_once("guiconfig.inc");
Ad Schellevis's avatar
Ad Schellevis committed
30 31 32 33 34
require_once("openvpn.inc");

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

35 36 37
if (!is_array($config['openvpn']['openvpn-csc'])) {
    $config['openvpn']['openvpn-csc'] = array();
}
Ad Schellevis's avatar
Ad Schellevis committed
38 39 40

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

41 42 43 44 45 46
if (is_numericint($_GET['id'])) {
    $id = $_GET['id'];
}
if (isset($_POST['id']) && is_numericint($_POST['id'])) {
    $id = $_POST['id'];
}
Ad Schellevis's avatar
Ad Schellevis committed
47 48

$act = $_GET['act'];
49 50 51
if (isset($_POST['act'])) {
    $act = $_POST['act'];
}
Ad Schellevis's avatar
Ad Schellevis committed
52 53

if ($_GET['act'] == "del") {
54 55 56 57 58 59 60 61 62
    if (!$a_csc[$id]) {
        redirectHeader("vpn_openvpn_csc.php");
        exit;
    }

    openvpn_delete_csc($a_csc[$id]);
    unset($a_csc[$id]);
    write_config();
    $savemsg = gettext("Client Specific Override successfully deleted")."<br />";
Ad Schellevis's avatar
Ad Schellevis committed
63 64
}

65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 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
if ($_GET['act']=="edit") {
    if (isset($id) && $a_csc[$id]) {
        $pconfig['custom_options'] = $a_csc[$id]['custom_options'];
        $pconfig['disable'] = isset($a_csc[$id]['disable']);
        $pconfig['common_name'] = $a_csc[$id]['common_name'];
        $pconfig['block'] = $a_csc[$id]['block'];
        $pconfig['description'] = $a_csc[$id]['description'];

        $pconfig['tunnel_network'] = $a_csc[$id]['tunnel_network'];
        $pconfig['local_network'] = $a_csc[$id]['local_network'];
        $pconfig['local_networkv6'] = $a_csc[$id]['local_networkv6'];
        $pconfig['remote_network'] = $a_csc[$id]['remote_network'];
        $pconfig['remote_networkv6'] = $a_csc[$id]['remote_networkv6'];
        $pconfig['gwredir'] = $a_csc[$id]['gwredir'];

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

        $pconfig['dns_domain'] = $a_csc[$id]['dns_domain'];
        if ($pconfig['dns_domain']) {
            $pconfig['dns_domain_enable'] = true;
        }

        $pconfig['dns_server1'] = $a_csc[$id]['dns_server1'];
        $pconfig['dns_server2'] = $a_csc[$id]['dns_server2'];
        $pconfig['dns_server3'] = $a_csc[$id]['dns_server3'];
        $pconfig['dns_server4'] = $a_csc[$id]['dns_server4'];
        if ($pconfig['dns_server1'] ||
            $pconfig['dns_server2'] ||
            $pconfig['dns_server3'] ||
            $pconfig['dns_server4']) {
            $pconfig['dns_server_enable'] = true;
        }

        $pconfig['ntp_server1'] = $a_csc[$id]['ntp_server1'];
        $pconfig['ntp_server2'] = $a_csc[$id]['ntp_server2'];
        if ($pconfig['ntp_server1'] ||
            $pconfig['ntp_server2']) {
            $pconfig['ntp_server_enable'] = true;
        }

        $pconfig['netbios_enable'] = $a_csc[$id]['netbios_enable'];
        $pconfig['netbios_ntype'] = $a_csc[$id]['netbios_ntype'];
        $pconfig['netbios_scope'] = $a_csc[$id]['netbios_scope'];

        $pconfig['wins_server1'] = $a_csc[$id]['wins_server1'];
        $pconfig['wins_server2'] = $a_csc[$id]['wins_server2'];
        if ($pconfig['wins_server1'] ||
            $pconfig['wins_server2']) {
            $pconfig['wins_server_enable'] = true;
        }

        $pconfig['nbdd_server1'] = $a_csc[$id]['nbdd_server1'];
        if ($pconfig['nbdd_server1']) {
            $pconfig['nbdd_server_enable'] = true;
        }
    }
Ad Schellevis's avatar
Ad Schellevis committed
121 122 123
}

if ($_POST) {
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
    unset($input_errors);
    $pconfig = $_POST;

    /* input validation */
    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 ($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 ($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 ($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");
            }
        }
        if ($pconfig['nbdd_server_enable']) {
            if (!empty($pconfig['nbdd_server1']) && !is_ipaddr(trim($pconfig['nbdd_server1']))) {
                $input_errors[] = gettext("The field 'NetBIOS Data Distribution Server #1' must contain a valid IP address");
            }
        }
    }

    $reqdfields[] = 'common_name';
    $reqdfieldsn[] = 'Common name';
Ad Schellevis's avatar
Ad Schellevis committed
196 197 198

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

199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 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 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
    if (!$input_errors) {
        $csc = array();

        $csc['custom_options'] = $pconfig['custom_options'];
        if ($_POST['disable'] == "yes") {
            $csc['disable'] = true;
        }
        $csc['common_name'] = $pconfig['common_name'];
        $csc['block'] = $pconfig['block'];
        $csc['description'] = $pconfig['description'];

        $csc['tunnel_network'] = $pconfig['tunnel_network'];
        $csc['local_network'] = $pconfig['local_network'];
        $csc['local_networkv6'] = $pconfig['local_networkv6'];
        $csc['remote_network'] = $pconfig['remote_network'];
        $csc['remote_networkv6'] = $pconfig['remote_networkv6'];
        $csc['gwredir'] = $pconfig['gwredir'];

        $csc['push_reset'] = $pconfig['push_reset'];

        if ($pconfig['dns_domain_enable']) {
            $csc['dns_domain'] = $pconfig['dns_domain'];
        }

        if ($pconfig['dns_server_enable']) {
            $csc['dns_server1'] = $pconfig['dns_server1'];
            $csc['dns_server2'] = $pconfig['dns_server2'];
            $csc['dns_server3'] = $pconfig['dns_server3'];
            $csc['dns_server4'] = $pconfig['dns_server4'];
        }

        if ($pconfig['ntp_server_enable']) {
            $csc['ntp_server1'] = $pconfig['ntp_server1'];
            $csc['ntp_server2'] = $pconfig['ntp_server2'];
        }

        $csc['netbios_enable'] = $pconfig['netbios_enable'];
        $csc['netbios_ntype'] = $pconfig['netbios_ntype'];
        $csc['netbios_scope'] = $pconfig['netbios_scope'];

        if ($pconfig['netbios_enable']) {
            if ($pconfig['wins_server_enable']) {
                $csc['wins_server1'] = $pconfig['wins_server1'];
                $csc['wins_server2'] = $pconfig['wins_server2'];
            }

            if ($pconfig['dns_server_enable']) {
                $csc['nbdd_server1'] = $pconfig['nbdd_server1'];
            }
        }

        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)) {
            openvpn_cleanup_csc($old_csc_cn);
        }
        openvpn_resync_csc($csc);
        write_config();

        header("Location: vpn_openvpn_csc.php");
        exit;
    }
Ad Schellevis's avatar
Ad Schellevis committed
266 267 268 269 270 271
}

include("head.inc");

?>

272 273
<body onload="<?= $jsevents["body"]["onload"] ?>">

Ad Schellevis's avatar
Ad Schellevis committed
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
<script type="text/javascript">
//<![CDATA[

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>
322 323 324

<?

325 326 327 328
if ($act!="new" && $act!="edit") {
    $main_buttons = array(
        array('href'=>'vpn_openvpn_csc.php?act=new', 'label'=>gettext("add csc")),
    );
329 330
}

Ad Schellevis's avatar
Ad Schellevis committed
331
?>
332 333 334 335

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

	<section class="page-content-main">
336
		<div class="container-fluid">
337
			<div class="row">
338

Ad Schellevis's avatar
Ad Schellevis committed
339
				<?php
340 341 342 343 344 345 346
                if ($input_errors) {
                    print_input_errors($input_errors);
                }
                if ($savemsg) {
                    print_info_box($savemsg);
                }
                ?>
347 348


349
			    <section class="col-xs-12">
350 351

				<?php
352 353 354 355 356
                        $tab_array = array();
                        $tab_array[] = array(gettext("Server"), false, "vpn_openvpn_server.php");
                        $tab_array[] = array(gettext("Client"), false, "vpn_openvpn_client.php");
                        $tab_array[] = array(gettext("Client Specific Overrides"), true, "vpn_openvpn_csc.php");
                        $tab_array[] = array(gettext("Wizards"), false, "wizard.php?xml=openvpn_wizard.xml");
357 358
                                                $tab_array[] = array(gettext("Client Export"), false, "vpn_openvpn_export.php");
                                                $tab_array[] = array(gettext("Shared Key Export"), false, "vpn_openvpn_export_shared.php");
359 360
                        display_top_tabs($tab_array);
                    ?>
361

Ad Schellevis's avatar
Ad Schellevis committed
362
					<div class="tab-content content-box col-xs-12">
363

364 365
							<?php if ($act=="new" || $act=="edit") :
?>
366 367 368
							<form action="vpn_openvpn_csc.php" method="post" name="iform" id="iform" onsubmit="presubmit()">

							 <div class="table-responsive">
369
								<table class="table table-striped table-sort">
370

371
									<tr>
372
										<td colspan="2" valign="top" class="listtopic"><?=gettext("General information"); ?></td>
373
									</tr>
374 375 376 377 378 379
									<tr>
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled"); ?></td>
										<td width="78%" class="vtable">
											<table border="0" cellpadding="0" cellspacing="0" summary="enable disable">
												<tr>
													<td>
380
														<?php set_checked($pconfig['disable'], $chk); ?>
381 382 383 384 385 386 387 388 389 390 391 392 393
														<input name="disable" type="checkbox" value="yes" <?=$chk;?> />
													</td>
													<td>
														&nbsp;
														<span class="vexpl">
															<strong><?=gettext("Disable this override"); ?></strong><br />
														</span>
													</td>
												</tr>
											</table>
											 <p class="text-muted"><em><small><?=gettext("Set this option to disable this client-specific override without removing it from the list"); ?>.</small></em></p>
										</td>
									</tr>
394
									<tr>
395
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Common name"); ?></td>
396
										<td width="78%" class="vtable">
397 398 399 400
											<input name="common_name" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['common_name']);?>" />
											 <p class="text-muted"><em><small><?=gettext("Enter the client's X.509 common name here"); ?>.</small></em></p>
										</td>
									</tr>
401
									<tr>
402
										<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
403
										<td width="78%" class="vtable">
404 405 406 407 408 409 410 411 412 413
											<input name="description" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['description']);?>" />
											 <p class="text-muted"><em><small><?=gettext("You may enter a description here for your reference (not parsed)"); ?>.</small></em></p>
										</td>
									</tr>
									<tr>
										<td width="22%" valign="top" class="vncell"><?=gettext("Connection blocking"); ?></td>
										<td width="78%" class="vtable">
											<table border="0" cellpadding="2" cellspacing="0" summary="connection blocking">
												<tr>
													<td>
414
														<?php set_checked($pconfig['block'], $chk); ?>
415 416 417 418 419 420 421 422 423 424
														<input name="block" type="checkbox" value="yes" <?=$chk;?> />
													</td>
													<td>
														<span class="vexpl">
															<?=gettext("Block this client connection based on its common name"); ?>.
														</span>
													</td>
												</tr>
											</table>
											 <p class="text-muted"><em><small><?=gettext("Don't use this option to permanently disable a " .
425 426
                                                "client due to a compromised key or password. " .
                                                "Use a CRL (certificate revocation list) instead"); ?>.</small></em></p>
427 428 429 430 431 432 433 434 435 436 437 438 439
										</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>
										<td width="22%" valign="top" class="vncell"><?=gettext("Tunnel Network"); ?></td>
										<td width="78%" class="vtable">
											<input name="tunnel_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['tunnel_network']);?>" />
											 <p class="text-muted"><em><small><?=gettext("This is the virtual network used for private " .
440 441 442 443 444 445
                                                "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"); ?>.</small></em></p>
446 447 448 449 450 451 452
										</td>
									</tr>
									<tr id="local_optsv4">
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv4 Local Network/s"); ?></td>
										<td width="78%" class="vtable">
											<input name="local_network" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['local_network']);?>" />
											 <p class="text-muted"><em><small><?=gettext("These are the IPv4 networks that will be accessible " .
453
                                                "from this particular client. Expressed as a comma-separated list of one or more CIDR ranges."); ?>
454
											<br /><?=gettext("NOTE: You do not need to specify networks here if they have " .
455
                                            "already been defined on the main server configuration.");?></small></em></p>
456 457 458 459 460 461 462
										</td>
									</tr>
									<tr id="local_optsv6">
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Local Network/s"); ?></td>
										<td width="78%" class="vtable">
											<input name="local_networkv6" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['local_networkv6']);?>" />
											 <p class="text-muted"><em><small><?=gettext("These are the IPv6 networks that will be accessible " .
463
                                                "from this particular client. Expressed as a comma-separated list of one or more IP/PREFIX networks."); ?>
464
											<br /><?=gettext("NOTE: You do not need to specify networks here if they have " .
465
                                            "already been defined on the main server configuration.");?></small></em></p>
466 467 468 469 470 471 472
										</td>
									</tr>
									<tr id="remote_optsv4">
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv4 Remote Network/s"); ?></td>
										<td width="78%" class="vtable">
											<input name="remote_network" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['remote_network']);?>" />
											 <p class="text-muted"><em><small><?=gettext("These are the IPv4 networks that will be routed " .
473 474 475 476 477
                                                "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"); ?>.
478
											<br /><?=gettext("NOTE: Remember to add these subnets to the " .
479
                                            "IPv4 Remote Networks list on the corresponding OpenVPN server settings.");?></small></em></p>
480 481 482 483 484 485 486
										</td>
									</tr>
									<tr id="remote_optsv6">
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Remote Network/s"); ?></td>
										<td width="78%" class="vtable">
											<input name="remote_networkv6" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['remote_networkv6']);?>" />
											 <p class="text-muted"><em><small><?=gettext("These are the IPv6 networks that will be routed " .
487 488 489 490 491
                                                "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 " .
                                                "be routed"); ?>.
492
											<br /><?=gettext("NOTE: Remember to add these subnets to the " .
493
                                            "IPv6 Remote Networks list on the corresponding OpenVPN server settings.");?></small></em></p>
494 495 496 497 498 499 500 501
										</td>
									</tr>
									<tr>
										<td width="22%" valign="top" class="vncell"><?=gettext("Redirect Gateway"); ?></td>
										<td width="78%" class="vtable">
											<table border="0" cellpadding="2" cellspacing="0" summary="redirect gateway">
												<tr>
													<td>
502
														<?php set_checked($pconfig['gwredir'], $chk); ?>
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525
														<input name="gwredir" type="checkbox" value="yes" <?=$chk;?> />
													</td>
													<td>
														<span class="vexpl">
															<?=gettext("Force all client generated traffic through the tunnel"); ?>.
														</span>
													</td>
												</tr>
											</table>
										</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>
										<td width="22%" valign="top" class="vncell"><?=gettext("Server Definitions"); ?></td>
										<td width="78%" class="vtable">
											<table border="0" cellpadding="2" cellspacing="0" summary="server definitions">
												<tr>
													<td>
526
														<?php set_checked($pconfig['push_reset'], $chk); ?>
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543
														<input name="push_reset" type="checkbox" value="yes" <?=$chk;?> />
													</td>
													<td>
														<span class="vexpl">
															<?=gettext("Prevent this client from receiving any server-defined client settings"); ?>.
														</span>
													</td>
												</tr>
											</table>
										</td>
									</tr>
									<tr>
										<td width="22%" valign="top" class="vncell"><?=gettext("DNS Default Domain"); ?></td>
										<td width="78%" class="vtable">
											<table border="0" cellpadding="2" cellspacing="0" summary="dns default domain">
												<tr>
													<td>
544
														<?php set_checked($pconfig['dns_domain_enable'], $chk); ?>
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568
														<input name="dns_domain_enable" type="checkbox" id="dns_domain_enable" value="yes" <?=$chk;?> onclick="dns_domain_change()" />
													</td>
													<td>
														<span class="vexpl">
					                                        <?=gettext("Provide a default domain name to clients"); ?><br />
														</span>
													</td>
												</tr>
											</table>
											<table border="0" cellpadding="2" cellspacing="0" id="dns_domain_data" summary="dns domain data">
												<tr>
													<td>
														<input name="dns_domain" type="text" class="formfld unknown" id="dns_domain" size="30" value="<?=htmlspecialchars($pconfig['dns_domain']);?>" />
													</td>
												</tr>
											</table>
										</td>
									</tr>
									<tr>
										<td width="22%" valign="top" class="vncell"><?=gettext("DNS Servers"); ?></td>
										<td width="78%" class="vtable">
											<table border="0" cellpadding="2" cellspacing="0" summary="dns servers">
												<tr>
													<td>
569
														<?php set_checked($pconfig['dns_server_enable'], $chk); ?>
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620
														<input name="dns_server_enable" type="checkbox" id="dns_server_enable" value="yes" <?=$chk;?> onclick="dns_server_change()" />
													</td>
													<td>
														<span class="vexpl">
															<?=gettext("Provide a DNS server list to clients"); ?><br />
														</span>
													</td>
												</tr>
											</table>
											<table border="0" cellpadding="2" cellspacing="0" id="dns_server_data" summary="dns server list">
												<tr>
													<td>
														<span class="vexpl">
															<?=gettext("Server"); ?> #1:&nbsp;
														</span>
														<input name="dns_server1" type="text" class="formfld unknown" id="dns_server1" size="20" value="<?=htmlspecialchars($pconfig['dns_server1']);?>" />
													</td>
												</tr>
												<tr>
													<td>
														<span class="vexpl">
															<?=gettext("Server"); ?> #2:&nbsp;
														</span>
														<input name="dns_server2" type="text" class="formfld unknown" id="dns_server2" size="20" value="<?=htmlspecialchars($pconfig['dns_server2']);?>" />
													</td>
												</tr>
												<tr>
													<td>
														<span class="vexpl">
															<?=gettext("Server"); ?> #3:&nbsp;
														</span>
														<input name="dns_server3" type="text" class="formfld unknown" id="dns_server3" size="20" value="<?=htmlspecialchars($pconfig['dns_server3']);?>" />
													</td>
												</tr>
												<tr>
													<td>
														<span class="vexpl">
															<?=gettext("Server"); ?> #4:&nbsp;
														</span>
														<input name="dns_server4" type="text" class="formfld unknown" id="dns_server4" size="20" value="<?=htmlspecialchars($pconfig['dns_server4']);?>" />
													</td>
												</tr>
											</table>
										</td>
									</tr>
									<tr>
										<td width="22%" valign="top" class="vncell"><?=gettext("NTP Servers"); ?></td>
										<td width="78%" class="vtable">
											<table border="0" cellpadding="2" cellspacing="0" summary="ntp servers">
												<tr>
													<td>
621
														<?php set_checked($pconfig['ntp_server_enable'], $chk); ?>
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656
														<input name="ntp_server_enable" type="checkbox" id="ntp_server_enable" value="yes" <?=$chk;?> onclick="ntp_server_change()" />
													</td>
													<td>
														<span class="vexpl">
															<?=gettext("Provide a NTP server list to clients"); ?><br />
														</span>
													</td>
												</tr>
											</table>
											<table border="0" cellpadding="2" cellspacing="0" id="ntp_server_data" summary="ntp server list">
												<tr>
													<td>
														<span class="vexpl">
															<?=gettext("Server"); ?> #1:&nbsp;
														</span>
														<input name="ntp_server1" type="text" class="formfld unknown" id="ntp_server1" size="20" value="<?=$pconfig['ntp_server1'];?>" />
													</td>
												</tr>
												<tr>
													<td>
														<span class="vexpl">
															<?=gettext("Server"); ?> #2:&nbsp;
														</span>
														<input name="ntp_server2" type="text" class="formfld unknown" id="ntp_server2" size="20" value="<?=$pconfig['ntp_server2'];?>" />
													</td>
												</tr>
											</table>
										</td>
									</tr>
									<tr>
										<td width="22%" valign="top" class="vncell"><?=gettext("NetBIOS Options"); ?></td>
										<td width="78%" class="vtable">
											<table border="0" cellpadding="2" cellspacing="0" summary="netbios options">
												<tr>
													<td>
657
														<?php set_checked($pconfig['netbios_enable'], $chk); ?>
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677
														<input name="netbios_enable" type="checkbox" id="netbios_enable" value="yes" <?=$chk;?> onclick="netbios_change()" />
													</td>
													<td>
														<span class="vexpl">
															<?=gettext("Enable NetBIOS over TCP/IP"); ?><br />
														</span>
													</td>
												</tr>
											</table>
											<?=gettext("If this option is not set, all NetBIOS-over-TCP/IP options (including WINS) will be disabled"); ?>.
											<br />
											<table border="0" cellpadding="2" cellspacing="0" id="netbios_data" summary="netbios options">
												<tr>
													<td>
														<br />
														<span class="vexpl">
															<?=gettext("Node Type"); ?>:&nbsp;
														</span>
														<select name='netbios_ntype' class="formselect">
														<?php
678 679 680 681 682 683 684 685 686 687 688
                                                        foreach ($netbios_nodetypes as $type => $name) :
                                                            $selected = "";
                                                            if ($pconfig['netbios_ntype'] == $type) {
                                                                $selected = "selected=\"selected\"";
                                                            }
                                                        ?>
                                                        <option value="<?=$type;
?>" <?=$selected;
?>><?=$name;?></option>
														<?php
                                                        endforeach; ?>
689 690
														</select>
														 <p class="text-muted"><em><small><?=gettext("Possible options: b-node (broadcasts), p-node " .
691 692 693
                                                            "(point-to-point name queries to a WINS server), " .
                                                            "m-node (broadcast then query name server), and " .
                                                            "h-node (query name server, then broadcast)"); ?>.</small></em></p>
694 695 696 697 698 699 700 701 702 703 704
													</td>
												</tr>
												<tr>
													<td>
														<br />
														<span class="vexpl">
															Scope ID:&nbsp;
														</span>
														<input name="netbios_scope" type="text" class="formfld unknown" id="netbios_scope" size="30" value="<?=htmlspecialchars($pconfig['netbios_scope']);?>" />
														<br />
														 <p class="text-muted"><em><small><?=gettext("A NetBIOS Scope	ID provides an extended naming " .
705 706 707 708
                                                            "service for	NetBIOS over TCP/IP. The NetBIOS " .
                                                            "scope ID isolates NetBIOS traffic on a single " .
                                                            "network to only those nodes with the same " .
                                                            "NetBIOS scope ID"); ?>.</small></em></p>
709 710 711 712 713 714 715 716 717 718 719
													</td>
												</tr>
											</table>
										</td>
									</tr>
									<tr id="wins_opts">
										<td width="22%" valign="top" class="vncell"><?=gettext("WINS Servers"); ?></td>
										<td width="78%" class="vtable">
											<table border="0" cellpadding="2" cellspacing="0" summary="wins servers">
												<tr>
													<td>
720
														<?php set_checked($pconfig['wins_server_enable'], $chk); ?>
721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755
														<input name="wins_server_enable" type="checkbox" id="wins_server_enable" value="yes" <?=$chk;?> onclick="wins_server_change()" />
													</td>
													<td>
														<span class="vexpl">
															<?=gettext("Provide a WINS server list to clients"); ?><br />
														</span>
													</td>
												</tr>
											</table>
											<table border="0" cellpadding="2" cellspacing="0" id="wins_server_data" summary="wins server list">
												<tr>
													<td>
														<span class="vexpl">
															<?=gettext("Server"); ?> #1:&nbsp;
														</span>
														<input name="wins_server1" type="text" class="formfld unknown" id="wins_server1" size="20" value="<?=$pconfig['wins_server1'];?>" />
													</td>
												</tr>
												<tr>
													<td>
														<span class="vexpl">
															<?=gettext("Server"); ?> #2:&nbsp;
														</span>
														<input name="wins_server2" type="text" class="formfld unknown" id="wins_server2" size="20" value="<?=$pconfig['wins_server2'];?>" />
													</td>
												</tr>
											</table>
										</td>
									</tr>
									<tr>
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
										<td width="78%" class="vtable">
											<table border="0" cellpadding="2" cellspacing="0" summary="advanced">
												<tr>
													<td>
756 757
														<textarea rows="6" cols="70" name="custom_options" id="custom_options"><?=$pconfig['custom_options'];
?></textarea> <p class="text-muted"><em><small><?=gettext("Enter any additional options you would like to add for this client specific override, separated by a semicolon"); ?><br />
758 759 760 761 762 763 764 765
														<?=gettext("EXAMPLE: push \"route 10.0.0.0 255.255.255.0\""); ?>;</small></em></p>
													</td>
												</tr>
											</table>
										</td>
									</tr>
									<tr>
										<td width="22%" valign="top">&nbsp;</td>
766 767
										<td width="78%">
											<input name="save" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" />
768
											<input name="act" type="hidden" value="<?=$act;?>" />
769 770
											<?php if (isset($id) && $a_csc[$id]) :
?>
771
											<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
772 773
											<?php
endif; ?>
774 775 776 777 778
										</td>
									</tr>
								</table>
							 </div>
							</form>
779

780 781 782
							<?php
else :
?>
783

784
							<div class="table-responsive">
785 786
								<table class="table table-striped table-sort">

787 788 789 790 791 792 793
									<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
794 795 796 797 798 799 800
                                        $i = 0;
                                    foreach ($a_csc as $csc) :
                                        $disabled = "NO";
                                        if (isset($csc['disable'])) {
                                            $disabled = "YES";
                                        }
                                    ?>
801
									<tr ondblclick="document.location='vpn_openvpn_csc.php?act=edit&amp;id=<?=$i;?>'">
802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822
                                    <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">
                                        <a href="vpn_openvpn_csc.php?act=edit&amp;id=<?=$i;?>">
                                            <img src="./themes/<?=$g['theme'];
?>/images/icons/icon_e.gif" title="<?=gettext("edit csc"); ?>" width="17" height="17" border="0" alt="edit" />
                                        </a>
                                        &nbsp;
                                        <a href="vpn_openvpn_csc.php?act=del&amp;id=<?=$i;
?>" onclick="return confirm('<?=gettext("Do you really want to delete this csc?"); ?>')">
                                            <img src="/themes/<?=$g['theme'];
?>/images/icons/icon_x.gif" title="<?=gettext("delete csc"); ?>" width="17" height="17" border="0" alt="delete" />
                                        </a>
                                    </td>
823 824
									</tr>
									<?php
825 826 827
                                    $i++;
                                    endforeach;
                                    ?>
828

829 830 831 832 833 834 835 836 837
									<tr>
										<td colspan="3">
											<p>
												<?=gettext("Additional OpenVPN client specific overrides can be added here.");?>
											</p>
										</td>
									</tr>
								</table>
							</div>
838 839
				    <?php
endif; ?>
840

841 842 843 844 845 846
					</div>
			    </section>
			</div>
		</div>
	</section>

Ad Schellevis's avatar
Ad Schellevis committed
847 848 849 850 851 852 853 854 855
<script type="text/javascript">
//<![CDATA[
dns_domain_change();
dns_server_change();
wins_server_change();
ntp_server_change();
netbios_change();
//]]>
</script>
856
<?php include("foot.inc"); ?>
Ad Schellevis's avatar
Ad Schellevis committed
857 858 859 860 861

<?php

/* local utility functions */

862 863 864
function set_checked($var, & $chk)
{
    if ($var) {
Ad Schellevis's avatar
Ad Schellevis committed
865
        $chk = "checked=\"checked\"";
866
    } else {
Ad Schellevis's avatar
Ad Schellevis committed
867
        $chk = "";
868
    }
Ad Schellevis's avatar
Ad Schellevis committed
869
}