$interfaces['l2tp'] = 'L2TP VPN'; } if (is_pppoe_server_enabled() && have_ruleint_access("pppoe")) { $interfaces['pppoe'] = "PPPoE Server"; } // add ipsec interfaces if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable']) && have_ruleint_access("enc0")) { $interfaces["enc0"] = "IPsec"; } // add openvpn/tun interfaces if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"]) { $interfaces["openvpn"] = "OpenVPN"; } $section->addInput($input = new Form_Select('interface', 'Interface', $pconfig['interface'], $interfaces, $if == "FloatingRules" || isset($pconfig['floating'])))->setHelp('Choose on which interface packets must come in to match this ' . 'rule.'); if ($if == "FloatingRules" || isset($pconfig['floating'])) { $input->setHelp('Choose the interface(s) for this rule.'); } if ($if == "FloatingRules" || isset($pconfig['floating'])) { $section->addInput(new Form_Select('direction', 'Direction', $pconfig['direction'], array('any' => 'any', 'in' => 'in', 'out' => 'out'))); $section->addInput(new Form_Input('floating', 'Floating', 'hidden', 'floating')); } $section->addInput(new Form_Select('ipprotocol', 'TCP/IP Version', $pconfig['ipprotocol'], array('inet' => 'IPv4', 'inet6' => 'IPv6', 'inet46' => 'IPv4+IPv6')))->setHelp('Select the Internet Protocol version this rule applies to'); $section->addInput(new Form_Select('proto', 'Protocol', $pconfig['proto'], array('tcp' => 'TCP', 'udp' => 'UDP', 'tcp/udp' => 'TCP/UDP', 'icmp' => 'ICMP', 'esp' => 'ESP', 'ah' => 'AH', 'gre' => 'GRE', 'ipv6' => 'IPV6', 'igmp' => 'IGMP', 'pim' => 'PIM', 'ospf' => 'OSPF', 'sctp' => 'SCTP', 'any' => 'any', 'carp' => 'CARP', 'pfsync' => 'PFSYNC')))->setHelp('Choose which IP protocol this rule should match.'); $section->addInput(new Form_Select('icmptype', 'ICMP type', $pconfig['icmptype'], $icmptypes))->setHelp('If you selected ICMP for the protocol above, you may specify an ICMP type here.'); $section->addInput(new Form_Select('icmp6type', 'ICMPv6 type', $pconfig['icmptype'], $icmp6types))->setHelp('If you selected ICMP for the protocol above, you may specify an ICMP type here.'); $form->add($section); // Source and destination share a lot of logic. Loop over the two foreach (['src' => 'Source', 'dst' => 'Destination'] as $type => $name) { $section = new Form_Section($name); $group = new Form_Group($name); $group->add(new Form_Checkbox($type . 'not', $name . ' not', 'Invert match.', $pconfig[$type . 'not']))->setWidth(2);
function display_row($trc, $value, $fieldname, $type, $rowhelper, $description, $ewidth = null) { global $text, $group; switch ($type) { case "input": $inpt = new Form_Input($fieldname . $trc, null, 'text', $value); $inpt->setHelp($description); if ($ewidth) { $inpt->setWidth($ewidth); } $group->add($inpt); break; case "checkbox": $group->add(new Form_Checkbox($fieldname . $trc, null, null, $value, 'ON'))->setHelp($description); break; case "password": $group->add(new Form_Input($fieldname . $trc, null, 'password', $value))->setHelp($description); break; case "textarea": $group->add(new Form_Textarea($fieldname . $trc, null, $value))->setHelp($description); break; case "select": $options = array(); foreach ($rowhelper['options']['option'] as $rowopt) { $options[$rowopt['value']] = $rowopt['name']; } $grp = new Form_Select($fieldname . $trc, null, $value, $options); $grp->setHelp($description); if ($ewidth) { $grp->setWidth($ewidth); } $group->add($grp); break; case "interfaces_selection": $size = $size ? "size=\"{$size}\"" : ''; $multiple = ''; if (isset($rowhelper['multiple'])) { $multiple = "multiple"; } echo "<select style='height:22px;' id='{$fieldname}{$trc}' name='{$fieldname}{$trc}' {$size} {$multiple}>\n"; $ifaces = get_configured_interface_with_descr(); $additional_ifaces = $rowhelper['add_to_interfaces_selection']; if (!empty($additional_ifaces)) { $ifaces = array_merge($ifaces, explode(',', $additional_ifaces)); } if (is_array($value)) { $values = $value; } else { $values = explode(',', $value); } $ifaces["lo0"] = "loopback"; $options = array(); $selected = array(); foreach ($ifaces as $ifname => $iface) { $options[$ifname] = $iface; if (in_array($ifname, $values)) { array_push($selected, $ifname); } } $group->add(new Form_Select($fieldname . $trc, null, $multiple ? $selected : $selected[0], $options, $multiple))->setHelp($description); //echo "</select>\n"; break; case "select_source": $options = array(); $selected = array(); if (isset($rowhelper['show_disable_value'])) { $options[$rowhelper['show_disable_value']] = $rowhelper['show_disable_value']; } $source_url = $rowhelper['source']; eval("\$pkg_source_txt = &{$source_url};"); foreach ($pkg_source_txt as $opt) { $source_name = $rowhelper['source_name'] ? $opt[$rowhelper['source_name']] : $opt[$rowhelper['name']]; $source_value = $rowhelper['source_value'] ? $opt[$rowhelper['source_value']] : $opt[$rowhelper['value']]; $options[$source_value] = $source_name; if ($source_value == $value) { array_push($selected, $value); } } $group->add(new Form_Select($fieldname . $trc, null, $multiple ? $selected : $selected[0], $options, $multiple))->setHelp($description); break; } }
array_push($selectedlist, $opt['value']); } } if (isset($pkga['advancedfield']) && isset($advfield_count)) { $function = $grouping ? $advanced->add : $advanced->addInput; } else { $function = $grouping ? $section->add : $section->addInput; } if ($grouping) { $group->add(new Form_Select($pkga['fieldname'], strip_tags($pkga['fielddescr']), isset($pkga['multiple']) ? $selectedlist : $selectedlist[0], $optionlist, isset($pkga['multiple'])))->setHelp($pkga['description'])->setOnchange($onchange)->setAttribute('size', $pkga['size']); } else { if (isset($pkga['advancedfield']) && isset($advfield_count)) { $advanced->addInput(new Form_Select($pkga['fieldname'], $pkga['fielddescr'], isset($pkga['multiple']) ? $selectedlist : $selectedlist[0], $optionlist, isset($pkga['multiple'])))->setHelp($pkga['description'])->setOnchange($onchange)->setAttribute('size', $pkga['size']); } else { $selector = new Form_Select($pkga['fieldname'], strip_tags($pkga['fielddescr']), isset($pkga['multiple']) ? $selectedlist : $selectedlist[0], $optionlist, isset($pkga['multiple'])); $selector->setHelp($pkga['description'])->setOnchange($onchange)->setAttribute('size', $pkga['size']); if ($pkga['width']) { $selector->setWidth($pkga['width']); } $section->addInput($selector); } } break; case "select_source": if (isset($pkga['multiple'])) { $items = explode(',', $value); $fieldname .= "[]"; } else { $items = array($value); } $onchange = isset($pkga['onchange']) ? "onchange=\"{$pkga['onchange']}\"" : '';