$section->add($group); $portlist = array("" => 'Other', 'any' => 'Any'); foreach ($wkports as $wkport => $wkportdesc) { $portlist[$wkport] = $wkportdesc; } $group = new Form_Group('Source port range'); $group->addClass('srcportrange'); $group->add(new Form_Select('srcbeginport', null, $pconfig['srcbeginport'], $portlist))->setHelp('From port'); $group->add(new Form_Input('srcbeginport_cust', null, 'text', $pconfig['srcbeginport'], ['min' => '1', 'max' => '65536']))->setHelp('Custom'); $group->add(new Form_Select('srcendport', null, $pconfig['srcendport'], $portlist))->setHelp('To port'); $group->add(new Form_Input('srcendport_cust', null, 'text', $pconfig['srcendport'], ['min' => '1', 'max' => '65536']))->setHelp('Custom'); $group->setHelp('Specify the source port or port range for this rule. This is usually random and almost never ' . 'equal to the destination port range (and should usually be \'any\'). You can leave the \'to\' field ' . 'empty if you only want to filter a single port.'); $section->add($group); $group = new Form_Group('Destination'); $group->add(new Form_Checkbox('dstnot', 'Destination not', 'Invert match.', $pconfig['dstnot']))->setWidth(2); $group->add(new Form_Select('dsttype', null, dsttype_selected(), build_dsttype_list()))->setHelp('Type'); $group->add(new Form_IpAddress('dst', null, is_specialnet($pconfig['dst']) ? '' : $pconfig['dst']))->setPattern('[.a-zA-Z0-9_]+')->addMask('dstmask', $pconfig['dstmask'], 31)->setHelp('Address/mask'); $section->add($group); $group = new Form_Group('Destination port range'); $group->addClass('dstportrange'); $group->add(new Form_Select('dstbeginport', null, $pconfig['dstbeginport'], $portlist))->setHelp('From port'); $group->add(new Form_Input('dstbeginport_cust', null, 'text', $pconfig['dstbeginport'], ['min' => '1', 'max' => '65536']))->setHelp('Custom'); $group->add(new Form_Select('dstendport', null, $pconfig['dstendport'], $portlist))->setHelp('To port'); $group->add(new Form_Input('dstendport_cust', null, 'text', $pconfig['dstendport'], ['min' => '1', 'max' => '65536']))->setHelp('Custom'); $group->setHelp('Specify the port or port range for the destination of the packet for this mapping. ' . 'You can leave the \'to\' field empty if you only want to map a single port '); $section->add($group); $section->addInput(new Form_IpAddress('localip', 'Redirect target IP', $pconfig['localip']))->setPattern('[.a-zA-Z0-9_]+')->setHelp('Enter the internal IP address of the server on which you want to map the ports.' . '<br />' . 'e.g.: 192.168.1.12'); $group = new Form_Group('Redirect target port'); $group->addClass('lclportrange'); $group->add(new Form_Select('localbeginport', null, $pconfig['localbeginport'], array('' => 'Other') + $wkports))->setHelp('Port'); $group->setHelp('Specify the port on the machine with the IP address entered above. In case of a port range, specify the ' . 'beginning port of the range (the end port will be calculated automatically).' . '<br />' . 'this is usually identical to "From port" above');
function dsttype_selected() { global $pconfig, $config; $selected = ""; if (array_key_exists($pconfig['dst'], build_dsttype_list())) { $selected = $pconfig['dst']; } else { if ($pconfig['dstmask'] == 32) { $selected = 'single'; } else { $selected = 'network'; } } return $selected; }