From b5f6e690d40d0e0b7e16fd4adddb92d04c402ad6 Mon Sep 17 00:00:00 2001 From: Stephen Beaver Date: Wed, 23 Sep 2015 16:59:19 -0400 Subject: File converted but not yet checked/tested --- src/usr/local/www/services_dhcp.php | 1941 +++++++++++++++++------------- src/usr/local/www/services_dhcp_edit.php | 10 +- 2 files changed, 1131 insertions(+), 820 deletions(-) (limited to 'src/usr/local/www') diff --git a/src/usr/local/www/services_dhcp.php b/src/usr/local/www/services_dhcp.php index 3061812..5a3581c 100644 --- a/src/usr/local/www/services_dhcp.php +++ b/src/usr/local/www/services_dhcp.php @@ -2,36 +2,62 @@ /* $Id$ */ /* services_dhcp.php - part of m0n0wall (http://m0n0.ch/wall) - - Copyright (C) 2003-2004 Manuel Kasper . - Copyright (C) 2013-2015 Electric Sheep Fencing, LP - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 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. - - 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. */ +/* ==================================================================== + * Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved. + * Copyright (c) 2004, 2005 Scott Ullrich + * Copyright (c) 2003-2004 Manuel Kasper + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 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. + * + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgment: + * "This product includes software developed by the pfSense Project + * for use in the pfSense software distribution. (http://www.pfsense.org/). + * + * 4. The names "pfSense" and "pfSense Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * coreteam@pfsense.org. + * + * 5. Products derived from this software may not be called "pfSense" + * nor may "pfSense" appear in their names without prior written + * permission of the Electric Sheep Fencing, LLC. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * + * "This product includes software developed by the pfSense Project + * for use in the pfSense software distribution (http://www.pfsense.org/). + * + * THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY + * EXPRESSED 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 pfSense PROJECT OR + * ITS CONTRIBUTORS 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. + * + * ==================================================================== + * + */ /* pfSense_BUILDER_BINARIES: /bin/rm - pfSense_MODULE: interfaces + pfSense_MODULE: interfaces */ ##|+PRIV @@ -71,9 +97,10 @@ if (!$if || !isset($iflist[$if])) { foreach ($iflist as $ifent => $ifname) { $oc = $config['interfaces'][$ifent]; if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddrv4($oc['ipaddr']))) || - (!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr'])))) { + (!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr'])))) { continue; } + $if = $ifent; break; } @@ -101,6 +128,7 @@ if (is_array($config['dhcpd'][$if])) { if (!is_array($config['dhcpd'][$if]['pool'])) { $config['dhcpd'][$if]['pool'] = array(); } + $a_pools = &$config['dhcpd'][$if]['pool']; if (is_numeric($pool) && $a_pools[$pool]) { @@ -117,7 +145,7 @@ if (is_array($dhcpdconf)) { $pconfig['enable'] = isset($dhcpdconf['enable']); $pconfig['staticarp'] = isset($dhcpdconf['staticarp']); // No reason to specify this per-pool, per the dhcpd.conf man page it needs to be in every - // pool and should be specified in every pool both nodes share, so we'll treat it as global + // pool and should be specified in every pool both nodes share, so we'll treat it as global $pconfig['failover_peerip'] = $dhcpdconf['failover_peerip']; // dhcpleaseinlocaltime is global to all interfaces. So if it is selected on any interface, @@ -134,6 +162,7 @@ if (is_array($dhcpdconf)) { if (!is_array($dhcpdconf['staticmap'])) { $dhcpdconf['staticmap'] = array(); } + $a_maps = &$dhcpdconf['staticmap']; } else { // Options that exist only in pools @@ -145,6 +174,7 @@ if (is_array($dhcpdconf)) { $pconfig['range_from'] = $dhcpdconf['range']['from']; $pconfig['range_to'] = $dhcpdconf['range']['to']; } + $pconfig['deftime'] = $dhcpdconf['defaultleasetime']; $pconfig['maxtime'] = $dhcpdconf['maxleasetime']; $pconfig['gateway'] = $dhcpdconf['gateway']; @@ -185,6 +215,7 @@ function validate_partial_mac_list($maclist) { return false; } } + return true; } @@ -204,6 +235,7 @@ if (isset($_POST['submit'])) { $numberoptions['item'][] = $numbervalue; } } + // Reload the new pconfig variable that the form uses. $pconfig['numberoptions'] = $numberoptions; @@ -233,6 +265,7 @@ if (isset($_POST['submit'])) { $input_errors[] = sprintf(gettext("The gateway address %s does not lie within the chosen interface's subnet."), $_POST['gateway']); } } + if (($_POST['dns1'] && !is_ipaddrv4($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddrv4($_POST['dns2'])) || ($_POST['dns3'] && !is_ipaddrv4($_POST['dns3'])) || ($_POST['dns4'] && !is_ipaddrv4($_POST['dns4']))) { $input_errors[] = gettext("A valid IP address must be specified for each of the DNS servers."); } @@ -275,7 +308,7 @@ if (isset($_POST['submit'])) { $input_errors[] = gettext("A valid primary domain name server IP address must be specified for the dynamic domain name."); } if (($_POST['ddnsdomainkey'] && !$_POST['ddnsdomainkeyname']) || - ($_POST['ddnsdomainkeyname'] && !$_POST['ddnsdomainkey'])) { + ($_POST['ddnsdomainkeyname'] && !$_POST['ddnsdomainkey'])) { $input_errors[] = gettext("You must specify both a valid domain key and key name."); } if ($_POST['domainsearchlist']) { @@ -335,6 +368,7 @@ if (isset($_POST['submit'])) { } } } + if ($_POST['staticarp'] && $noip) { $input_errors[] = "Cannot enable static ARP when you have static map entries without IP addresses. Ensure all static maps have IP addresses and try again."; } @@ -371,7 +405,7 @@ if (isset($_POST['submit'])) { $subnet_end = ip2ulong(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn)))); if ((ip2ulong($_POST['range_from']) < $subnet_start) || (ip2ulong($_POST['range_from']) > $subnet_end) || - (ip2ulong($_POST['range_to']) < $subnet_start) || (ip2ulong($_POST['range_to']) > $subnet_end)) { + (ip2ulong($_POST['range_to']) < $subnet_start) || (ip2ulong($_POST['range_to']) > $subnet_end)) { $input_errors[] = gettext("The specified range lies outside of the current subnet."); } @@ -394,7 +428,7 @@ if (isset($_POST['submit'])) { } if (is_inrange_v4($_POST['range_from'], $p['range']['from'], $p['range']['to']) || - is_inrange_v4($_POST['range_to'], $p['range']['from'], $p['range']['to'])) { + is_inrange_v4($_POST['range_to'], $p['range']['from'], $p['range']['to'])) { $input_errors[] = gettext("The specified range must not be within the range configured on a DHCP pool for this interface."); break; } @@ -413,7 +447,7 @@ if (isset($_POST['submit'])) { continue; } if ((ip2ulong($map['ipaddr']) > $dynsubnet_start) && - (ip2ulong($map['ipaddr']) < $dynsubnet_end)) { + (ip2ulong($map['ipaddr']) < $dynsubnet_end)) { $input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings.")); break; } @@ -455,12 +489,14 @@ if (isset($_POST['submit'])) { /* DHCP has been enabled or disabled. The pf ruleset will need to be rebuilt to allow or disallow DHCP. */ $dhcpd_enable_changed = true; } + $dhcpdconf['enable'] = $new_dhcpd_enable; $dhcpdconf['staticarp'] = ($_POST['staticarp']) ? true : false; $previous = $dhcpdconf['failover_peerip']; - if ($previous <> $_POST['failover_peerip']) { + if ($previous != $_POST['failover_peerip']) { mwexec("/bin/rm -rf /var/dhcpd/var/db/*"); } + $dhcpdconf['failover_peerip'] = $_POST['failover_peerip']; // dhcpleaseinlocaltime is global to all interfaces. So update the setting on all interfaces. foreach ($config['dhcpd'] as &$dhcpdifitem) { @@ -580,6 +616,7 @@ if ((isset($_POST['submit']) || isset($_POST['apply'])) && (!$input_errors)) { if ($retvaldhcp == 1 || $retvaldns == 1 || $retvalfc == 1) { $retval = 1; } + $savemsg = get_std_save_message($retval); } @@ -602,841 +639,1115 @@ if ($act == "del") { mark_subsystem_dirty('hosts'); } } + header("Location: services_dhcp.php?if={$if}"); exit; } } +// DEBUG +$a_pools = array(array('range' => array('from' => '192.168.70.70', 'to' => '192.168.70.99'), 'descr' => 'My first pool'), + array('range' => array('from' => '192.168.80.70', 'to' => '192.168.80.99'), 'descr' => 'My second pool')); + +function build_pooltable() { + global $a_pools; + + $pooltbl = '
'; + $pooltbl .= ''; + $pooltbl .= ''; + $pooltbl .= ''; + $pooltbl .= ''; + $pooltbl .= ''; + $pooltbl .= ''; + $pooltbl .= ''; + $pooltbl .= ''; + $pooltbl .= ''; + $pooltbl .= ''; + + if (is_array($a_pools)) { + $i = 0; + foreach ($a_pools as $poolent) { + if (!empty($poolent['range']['from']) && !empty($poolent['range']['to'])) { + $pooltbl .= ''; + $pooltbl .= ''; + + $pooltbl .= ''; + + $pooltbl .= ''; + + $pooltbl .= ''; + $pooltbl .= ''; + } + $i++; + } + } + + $pooltbl .= ''; + $pooltbl .= '
' . gettext("Pool Start") . '' . gettext("Pool End") . '' . gettext("Description") . '
' . + htmlspecialchars($poolent['range']['from']) . '' . + htmlspecialchars($poolent['range']['to']) . '' . + htmlspecialchars($poolent['descr']) . '' . gettext('Edit') . ''; + + $pooltbl .= '' . gettext('Delete') . '
'; + $pooltbl .= '
'; + + return($pooltbl); +} + $closehead = false; $pgtitle = array(gettext("Services"), gettext("DHCP server")); $shortcut_section = "dhcp"; include("head.inc"); -?> +if ($input_errors) + print_input_errors($input_errors); - - +if (isset($config['dhcrelay']['enable'])) { + print_info_box(gettext("DHCP Relay is currently enabled. Cannot enable the DHCP Server service while the DHCP Relay is enabled on any interface.")); + include("foot.inc"); + exit; +} - - +$section->addInput(new Form_StaticText( + 'Subnet mask', + gen_subnet_mask($ifcfgsn) +)); - - -
- - -"; - echo ""; - exit; +$range_from = ip2long(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn))); +$range_from++; + +$range_to = ip2long(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn)))); +$range_to--; + +$rangestr = long2ip32($range_from) . ' - ' . long2ip32($range_to); + +if (is_numeric($pool) || ($act == "newpool")) { + $rangestr .= '
' . 'In-use DHCP Pool Ranges:'; + if (is_array($config['dhcpd'][$if]['range'])) { + $rangestr .= '
' . $config['dhcpd'][$if]['range']['from'] . ' - ' . $config['dhcpd'][$if]['range']['to']; } -?> -
-" . gettext("You must apply the changes in order for them to take effect."));?>
- - - -
- $ifname) { - $oc = $config['interfaces'][$ifent]; - if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddrv4($oc['ipaddr']))) || - (!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr'])))) { - continue; - } - if ($ifent == $if) { - $active = true; - } else { - $active = false; + + foreach ($a_pools as $p) { + if (is_array($p['range'])) { + $rangestr .= '
' . $p['range']['from'] . ' - ' . $p['range']['to']; } - $tab_array[] = array($ifname, $active, "services_dhcp.php?if={$ifent}"); - $tabscounter++; } - if ($tabscounter == 0) { - echo "" . gettext("The DHCP Server can only be enabled on interfaces configured with a static IPv4 address. This system has none.") . "

"; - echo "
"; - include("fend.inc"); - echo ""; - echo ""; - exit; +} + +$section->addInput(new Form_StaticText( + 'Available range', + $rangestr +)); + +if ($is_olsr_enabled) { + $section->addInput(new Form_Select( + 'netmask', + 'Subnet mask', + $pconfig['netmask'], + array_combine(range(32, 1, -1), range(32, 1, -1)) + )); +} + +$group = new Form_Group('Range'); + +$group->add(new Form_IpAddress( + 'range_from', + null, + $pconfig['range_from'] +))->setHelp('From'); + +$group->add(new Form_IpAddress( + 'range_to', + null, + $pconfig['range_to'] +))->setHelp('To'); + +$section->add($group); + +$form->add($section); + +if (!is_numeric($pool) && !($act == "newpool")) { + $section = new Form_Section('Additional pools'); + + $btnaddpool = new Form_Button( + 'btnaddpool', + 'Add pool', + 'services_dhcp.php?if=' . htmlspecialchars($if) . '&act=newpool' + ); + + $section->addInput(new Form_StaticText( + 'Add', + $btnaddpool + ))->setHelp('If you need additional pools of addresses inside of this subnet outside the above Range, they may be specified here'); + + if (is_array($a_pools)) { + $section->addInput(new Form_StaticText( + null, + build_pooltable() + )); } - display_top_tabs($tab_array); + + $form->add($section); +} + +$section = new Form_Section('Servers'); + +$section->addInput(new Form_IpAddress( + 'wins1', + 'WINS servers', + $pconfig['wins1'] +))->setPattern('[.a-zA-Z0-9_]+')->setAttribute('placeholder', 'WINS Server 1'); + +$section->addInput(new Form_IpAddress( + 'wins2', + null, + $pconfig['wins2'] +))->setPattern('[.a-zA-Z0-9_]+')->setAttribute('placeholder', 'WINS Server 2'); + + +for($idx=1; $idx<=4; $idx++) { + $section->addInput(new Form_IpAddress( + 'dns' . $idx, + ($idx == 1) ? 'DNS servers':null, + $pconfig['dns' . $idx] + ))->setPattern('[.a-zA-Z0-9_]+')->setAttribute('placeholder', 'DNS Server ' . $idx)->setHelp(($idx == 4) ? 'Leave blank to use the system default DNS servers, use this interface\'s IP if DNS Forwarder or Resolver is enabled, otherwise use the servers configured on the General page':''); +} + +$form->add($section); + +$section = new Form_Section('Other options'); + +$section->addInput(new Form_IpAddress( + 'gateway', + 'Gateway', + $pconfig['gateway'] +))->setPattern('[.a-zA-Z0-9_]+') + ->setHelp('The default is to use the IP on this interface of the firewall as the gateway. Specify an alternate gateway here if this is not the correct gateway for your network. Type "none" for no gateway assignment'); + +$section->addInput(new Form_Input( + 'domain', + 'Domain name', + 'text', + $pconfig['domain'] +))->setHelp('The default is to use the domain name of this system as the default domain name provided by DHCP. You may specify an alternate domain name here'); + +$section->addInput(new Form_Input( + 'domainsearchlist', + 'Domain search list', + 'text', + $pconfig['domainsearchlist'] +))->setHelp('The DHCP server can optionally provide a domain search list. Use the semicolon character as separator'); + +$section->addInput(new Form_Input( + 'deftime', + 'Default lease time', + 'number', + $pconfig['deftime'] +))->setHelp('This is used for clients that do not ask for a specific expiration time. The default is 7200 seconds'); + +$section->addInput(new Form_Input( + 'maxtime', + 'Maximum lease time', + 'number', + $pconfig['maxtime'] +))->setHelp('This is the maximum lease time for clients that ask for a specific expiration time. The default is 86400 seconds'); + +if (!is_numeric($pool) && !($act == "newpool")) { + $section->addInput(new Form_IpAddress( + 'failover_peerip', + 'Failover peer IP', + $pconfig['failover_peerip'] + ))->setHelp('Leave blank to disable. Enter the interface IP address of the other machine. Machines must be using CARP.' . + 'Interface\'s advskew determines whether the DHCPd process is Primary or Secondary. Ensure one machine\'s advskew < 20 (and the other is > 20).'); +} + +if (!is_numeric($pool) && !($act == "newpool")) { + $section->addInput(new Form_Checkbox( + 'staticarp', + 'Static ARP', + 'Enable Static ARP entries', + $pconfig['staticarp'] + ))->setHelp('This option persists even if DHCP server is disabled. Only the machines listed below will be able to communicate with the firewall on this NIC.'); + + $section->addInput(new Form_Checkbox( + 'dhcpleaseinlocaltime', + 'Time format change', + 'Change DHCP display lease time from UTC to local time', + $pconfig['dhcpleaseinlocaltime'] + ))->setHelp('By default DHCP leases are displayed in UTC time. By checking this box DHCP lease time will be displayed in local time and set to the time zone selected.' . + ' This will be used for all DHCP interfaces lease time'); +} + +// DDNS +$btnadv = new Form_Button( + 'btnadvdns', + 'Advanced' +); + +$btnadv->removeClass('btn-primary')->addClass('btn-default btn-sm'); + +$section->addInput(new Form_StaticText( + 'Dynamic DNS', + $btnadv +)); + +$section->addInput(new Form_Checkbox( + 'ddnsupdate', + null, + 'Enable registration of DHCP client names in DNS', + $pconfig['ddnsupdate'] +)); + +$section->addInput(new Form_Input( + 'ddnsdomain', + 'DDNS Domain', + 'number', + $pconfig['ddnsdomain'] +))->setHelp('Leave blank to disable dynamic DNS registration.' . '
' . + 'Enter the dynamic DNS domain which will be used to register client names in the DNS server.'); + +$section->addInput(new Form_IpAddress( + 'ddnsdomainprimary', + 'Primary DDNS address', + $pconfig['ddnsdomainprimary'] +))->setHelp('Primary domain name server IP address for the dynamic domain name'); + +$section->addInput(new Form_Input( + 'ddnsdomainkeyname', + 'DNS Domain key', + 'text', + $pconfig['ddnsdomainkeyname'] +))->setHelp('Dynamic DNS domain key name which will be used to register client names in the DNS server'); + +$section->addInput(new Form_Input( + 'ddnsdomainkey', + 'DNS Domain key secret', + 'text', + $pconfig['ddnsdomainkey'] +))->setHelp('Dynamic DNS domain key secret which will be used to register client names in the DNS server'); + +// Advanced MAC +$btnadv = new Form_Button( + 'btnadvmac', + 'Advanced' +); + +$btnadv->removeClass('btn-primary')->addClass('btn-default btn-sm'); + +$section->addInput(new Form_StaticText( + 'MAC address control', + $btnadv +)); + +$section->addInput(new Form_Input( + 'mac_allow', + 'Allow', + 'text', + $pconfig['mac_allow'] +))->setHelp('List of partial MAC addresses to allow, comma separated, no spaces, e.g.: 00:00:00,01:E5:FF'); + +$section->addInput(new Form_Input( + 'mac_deny', + 'Deny', + 'text', + $pconfig['mac_deny'] +))->setHelp('List of partial MAC addresses to deny access, comma separated, no spaces, e.g.: 00:00:00,01:E5:FF'); + +// Advanced NTP +$btnadv = new Form_Button( + 'btnadvntp', + 'Advanced' +); + +$btnadv->removeClass('btn-primary')->addClass('btn-default btn-sm'); + +$section->addInput(new Form_StaticText( + 'NTP servers', + $btnadv +)); + +$section->addInput(new Form_IpAddress( + 'ntp1', + 'Allow', + $pconfig['ntp1'] +)); + +$section->addInput(new Form_IpAddress( + 'ntp2', + 'Deny', + $pconfig['ntp2'] +)); + +// Advanced TFTP +$btnadv = new Form_Button( + 'btnadvtftp', + 'Advanced' +); + +$btnadv->removeClass('btn-primary')->addClass('btn-default btn-sm'); + +$section->addInput(new Form_StaticText( + 'TFTP server', + $btnadv +)); + +$section->addInput(new Form_IpAddress( + 'tftp', + 'Allow', + $pconfig['tftp'] +))->setHelp('Leave blank to disable. Enter a full hostname or IP for the TFTP server')->setPattern('[.a-zA-Z0-9_]+'); + +// Advanced LDAP +$btnadv = new Form_Button( + 'btnadvldap', + 'Advanced' +); + +$btnadv->removeClass('btn-primary')->addClass('btn-default btn-sm'); + +$section->addInput(new Form_StaticText( + 'LDAP URI', + $btnadv +)); + +$section->addInput(new Form_Input( + 'ldap', + null, + 'text', + $pconfig['ldap'] +))->setHelp('Leave blank to disable. Enter a full URI for the LDAP server in the form ldap://ldap.example.com/dc=example,dc=com '); + +// Advanced NETBOOT +$btnadv = new Form_Button( + 'btnadvboot', + 'Advanced' +); + +$btnadv->removeClass('btn-primary')->addClass('btn-default btn-sm'); + +$section->addInput(new Form_StaticText( + 'Network booting', + $btnadv +)); + +$section->addInput(new Form_Checkbox( + 'netboot', + null, + 'Enables network booting', + $pconfig['netboot'] +)); + +$section->addInput(new Form_IpAddress( + 'nextserver', + 'Next Server', + $pconfig['nextserver'] +))->setHelp('Enter the IP address of hte next server'); + +$section->addInput(new Form_Input( + 'filename', + 'Default BIOS file name', + 'text', + $pconfig['filename'] +)); + +$section->addInput(new Form_Input( + 'filename32', + 'UEFI 32 bit file name', + 'text', + $pconfig['filename32'] +)); + +$section->addInput(new Form_Input( + 'filename64', + 'UEFI 64 bit file name', + 'text', + $pconfig['filename64'] +))->setHelp('You need both a filename and a boot server configured for this to work! ' . + 'You will need all three filenames and a boot server configured for UEFI to work! '); + +$section->addInput(new Form_Input( + 'rootpath', + 'Root path', + 'text', + $pconfig['rootpath'] +))->setHelp('string-format: iscsi:(servername):(protocol):(port):(LUN):targetname '); + +// Advanced Additional options +$btnadv = new Form_Button( + 'btnadvopts', + 'Advanced' +); + +$btnadv->removeClass('btn-primary')->addClass('btn-default btn-sm'); + +$section->addInput(new Form_StaticText( + 'Additional BOOTP/DHCP Options', + $btnadv +)); + +$form->add($section); + +$section = new Form_Section('Additional BOOTP/DHCP Options'); +$section->addClass('adnlopts'); + +$section->addInput(new Form_StaticText( + null, + '
' . gettext('Enter the DHCP option number and the value for each item you would like to include in the DHCP lease information. ' . + 'For a list of available options please visit this ') . '' . gettext("URL") . '
' +)); + +if(!$pconfig['numberoptions']) { + $pconfig['numberoptions']['item'] = array(array('number' => '', 'type' => 'text', 'value' => '')); +} + +$customitemtypes = array( + 'text' => gettext('Text'), 'string' => gettext('String'), 'boolean' => gettext('Boolean'), + 'unsigned integer 8' => gettext('Unsigned 8-bit integer'), 'unsigned integer 16' => gettext('Unsigned 16-bit integer'), 'unsigned integer 32' => gettext('Unsigned 32-bit integer'), + 'signed integer 8' => gettext('Signed 8-bit integer'), 'signed integer 16' => gettext('Signed 16-bit integer'), 'signed integer 32' => gettext('Signed 32-bit integer'), 'ip-address' => gettext('IP address or host') +); + +$numrows = count($item) -1; +$counter = 0; + +$numrows = count($pconfig['numberoptions']['item']) -1; + +foreach ($pconfig['numberoptions']['item'] as $item) { + $number = $item['number']; + $itemtype = $item['type']; + $value = $item['value']; + + $group = new Form_Group(($counter == 0) ? 'Option':null); + $group->addClass('repeatable'); + + $group->add(new Form_Input( + 'number' . $counter, + null, + 'text', + $number + ))->setHelp($numrows == $counter ? 'Number':null); + + + $group->add(new Form_Select( + 'itemtype' . $counter, + null, + $itemtype, + $customitemtypes + ))->setHelp($numrows == $counter ? 'Type':null); + + $group->add(new Form_Input( + 'value' . $counter, + null, + 'text', + $value + ))->setHelp($numrows == $counter ? 'Value':null); + + $group->add(new Form_Button( + 'deleterow' . $counter, + 'Delete' + ))->removeClass('btn-primary')->addClass('btn-warning'); + + $section->add($group); + + $counter++; +} + + +$section->addInput(new Form_Button( + 'addrow', + 'Add' +))->removeClass('btn-primary')->addClass('btn-success'); + + +$form->add($section); + +if ($act == "newpool") { + $form->addGlobal(new Form_Input( + 'act', + null, + 'hidden', + 'newpool' + )); +} + +if (is_numeric($pool)) { + $form->addGlobal(new Form_Input( + 'pool', + null, + 'hidden', + $pool + )); +} + +$form->addGlobal(new Form_Input( + 'if', + null, + 'hidden', + $if +)); + +print($form); + +print_info_box(sprintf(gettext('The DNS servers entered in ') . '%s' . gettext("System: General setup") . '%s' . + gettext(' (or the ') . '%s' . gettext(' DNS forwarder ') . '%s' . gettext('if enabled) ') . + gettext('will be assigned to clients by the DHCP server.') . '
' . gettext('The DHCP lease table can be viewed on the ') . '%s' . gettext('Status: DHCP leases') . + '%s' . gettext(' page'), + '', + '', + '', + '', + '', + '') + ); + +// DHCP Static Mappings table + +if (!is_numeric($pool) && !($act == "newpool")) { ?> - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
+

+
+
  - onclick="enable_change(false)" /> - -
  - /> -
- -
- -
- -
- -
- - - - -
In-use DHCP Pool Ranges: - -
- - - - - -
- - - - -
- -
- -    -
+ + + + + + + + + + - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
- - - - - - - - - - + - - - - - - + + + + + + + + - - - - -
- - - - - -
- plus -
-
- - -   - -   - - - - - - -
- edit - - ')">delete -
-
+ + + + + + + + + + + + + + +
- - - - - -
- add -
-
-
-
- -
-
-
-
-
- -
-
- -
-
- -
-
- -
- -
-
- -
- -
-
- -
+ + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- 20).");?> -
- - - - - - - - - -
- />  -
  - - - - -
-
- - - - - - - - - -
- /> - - - - -
  - - - - -
-
-
> - " /> - -
-
> - />  -
-
-
-
-
-
-
-
-
-
- -
-
-
> - " /> - -
-
> -
- 00:00:00,01:E5:FF
-
- 00:00:00,01:E5:FF -
-
-
> - " /> - -
-
> -
- -
-
-
> - " /> - -
-
> -
- -
-
-
> - " /> - -
-
> -
- -
-
-
> - " /> - -
-
> - />  - -
- - - - - - - - - - - - - - - - - -
- - -
-
- - -
-
- - -
-
- - -
-
- - - - -
- -
-
-
> - " /> - -
-
> - - - - - - - - - - - - - - - + var hide = ; + + hideInput('mac_allow', !showadvmac && !hide); + hideInput('mac_deny', !showadvmac && !hide); + + showadvmac = !showadvmac; + } + + $('#btnadvmac').prop('type', 'button'); + + $('#btnadvmac').click(function(event) { + show_advmac(); + }); + + // Show advanced NTP options ====================================================================================== + var showadvntp = false; + + function show_advntp() { - - - - - - - - -
-
- -
-
- - -
  - - - - - - - - " onclick="enable_change(true)" /> -
  -

- - -
-
-
- - - , -
- - -
-
- - - -
-
-

-
+ var hide = ; + + hideInput('ntp1', !showadvntp && !hide); + hideInput('ntp2', !showadvntp && !hide); + + showadvntp = !showadvntp; + } + + $('#btnadvntp').prop('type', 'button'); + + $('#btnadvntp').click(function(event) { + show_advntp(); + }); + + // Show advanced TFTP options ====================================================================================== + var showadvtftp = false; + + function show_advtftp() { - - - - - - - - - - - - - + var hide = ; + + hideInput('tftp', !showadvtftp && !hide); + + showadvtftp = !showadvtftp; + } + + $('#btnadvtftp').prop('type', 'button'); + + $('#btnadvtftp').click(function(event) { + show_advtftp(); + }); + + // Show advanced LDAP options ====================================================================================== + var showadvldap = false; + + function show_advldap() { - - - - - - - - + var hide = ; + + hideInput('ldap', !showadvldap && !hide); + + showadvldap = !showadvldap; + } + + $('#btnadvldap').prop('type', 'button'); + + $('#btnadvldap').click(function(event) { + show_advldap(); + }); + + // Show advanced NETBOOT options =================================================================================== + var showadvboot = false; + + function show_advboot() { - - - - -
 
- - - - - -
- add -
-
- - ARP Table Static Entry - - - - -   - -   - -   - - - - - - -
edit')">delete
-
- - - - - -
add
-
+ var hide = ; + + hideCheckbox('netboot', !showadvboot && !hide); + hideInput('nextserver', !showadvboot && !hide); + hideInput('filename', !showadvboot && !hide); + hideInput('filename32', !showadvboot && !hide); + hideInput('filename64', !showadvboot && !hide); + hideInput('rootpath', !showadvboot && !hide); + + showadvboot = !showadvboot; + } + + $('#btnadvboot').prop('type', 'button'); + + $('#btnadvboot').click(function(event) { + show_advboot(); + }); + + // Show advanced additional opts options =========================================================================== + var showadvopts = false; + + function show_advopts() { -
-
- - - - - + +addInput(new Form_IpAddress( 'If no IPv4 address is given, one will be dynamically allocated from the pool.'); $section->addInput(new Form_Input( - 'hostnme', + 'hostname', 'Hostname', 'text', $pconfig['hostname'] @@ -455,7 +455,7 @@ $section->addInput(new Form_Input( 'descr', 'Description', 'text', - $pconfig['hostname'] + $pconfig['descr'] ))->setHelp('You may enter a description here for your reference (not parsed).'); $section->addInput(new Form_Checkbox( @@ -562,7 +562,7 @@ $btndyndns = new Form_Button( 'Advanced' ); -$btndyndns->removeClass('btn-primary')->addClass('btn-success btn-sm'); +$btndyndns->removeClass('btn-primary')->addClass('btn-default btn-sm'); $section->addInput(new Form_StaticText( 'Dynamic DNS', @@ -608,7 +608,7 @@ $btnntp = new Form_Button( 'Advanced' ); -$btnntp->removeClass('btn-primary')->addClass('btn-success btn-sm'); +$btnntp->removeClass('btn-primary')->addClass('btn-default btn-sm'); $section->addInput(new Form_StaticText( 'NTP servers', @@ -642,7 +642,7 @@ $btntftp = new Form_Button( 'Advanced' ); -$btntftp->removeClass('btn-primary')->addClass('btn-success btn-sm'); +$btntftp->removeClass('btn-primary')->addClass('btn-default btn-sm'); $section->addInput(new Form_StaticText( 'TFTP servers', -- cgit v1.1