"; } 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['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; } } if ($_POST) { unset($input_errors); $pconfig = $_POST; /* input validation */ if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'Tunnel network')) $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'; do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); 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['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]) $a_csc[$id] = $csc; else $a_csc[] = $csc; openvpn_resync_csc($csc); write_config(); header("Location: vpn_openvpn_csc.php"); exit; } } include("head.inc"); ?>
">
|