} } include 'head.inc'; if ($input_errors) { print_input_errors($input_errors); } require_once 'classes/Form.class.php'; $form = new Form('Ping'); $section = new Form_Section('Ping'); $section->addInput(new Form_Input('host', 'Hostname', 'text', $host, ['placeholder' => 'Hostname to ping'])); $group = new Form_Group('IP Protocol'); $group->add(new Form_Checkbox('ipproto', null, 'IPv4', 'ipv6' != $ipproto, 'ipv4'))->displayAsRadio(); $group->add(new Form_Checkbox('ipproto', null, 'IPv6', 'ipv6' == $ipproto, 'ipv6'))->displayAsRadio(); $group->setHelp('Select the protocol to use'); $section->add($group); $section->addInput(new Form_Select('sourceip', 'Source address', $pconfig['source'], create_sourceaddresslist()))->setHelp('Select source address for the ping'); $section->addInput(new Form_Select('count', 'Maximum number of pings', $count, array_combine(range(1, MAX_COUNT), range(1, MAX_COUNT))))->setHelp('Select the maximum number pings'); $form->add($section); print $form; if ($do_ping && !empty($result) && !$input_errors) { ?> <div class="panel panel-default"> <div class="panel-heading"> <h2 class="panel-title">Results</h2> </div> <div class="panel-body"> <pre><?php echo $result; ?> </pre>
$ifaddr = is_ipaddr($sourceip) ? $sourceip : get_interface_ip($sourceip); } if ($ifaddr && (is_ipaddr($host) || is_hostname($host))) { $srcip = "-s " . escapeshellarg($ifaddr); } $cmd = "{$command} {$n} {$srcip} -w 2 {$useicmpparam} -m " . escapeshellarg($ttl) . " " . escapeshellarg($host); $result = shell_exec($cmd); if (!$result) { print_info_box(sprintf(gettext('Error: %s could not be traced/resolved'), $host)); } } $form = new Form('Traceroute'); $section = new Form_Section('Traceroute'); $section->addInput(new Form_Input('host', 'Hostname', 'text', $host, ['placeholder' => 'Hostname to trace.'])); $section->addInput(new Form_Select('ipproto', 'IP Protocol', $ipproto, array('ipv4' => 'IPv4', 'ipv6' => 'IPv6')))->setHelp('Select the protocol to use'); $section->addInput(new Form_Select('sourceip', 'Source Address', $sourceip, create_sourceaddresslist()))->setHelp('Select source address for the trace'); $section->addInput(new Form_Select('ttl', 'Maximum nuber of hops', $ttl, array_combine(range(1, MAX_TTL), range(1, MAX_TTL))))->setHelp('Select the maximum number of network hops to trace'); $section->addInput(new Form_Checkbox('resolve', 'Reverse Address Lookup', '', $resolve))->setHelp('When checked, traceroute will attempt to perform a PTR lookup to locate hostnames for hops along the path. This will slow down the process as it has to wait for DNS replies.'); $section->addInput(new Form_Checkbox('useicmp', gettext("Use ICMP"), '', $useicmp))->setHelp('By default, traceroute uses UDP but that may be blocked by some routers. Check this box to use ICMP instead, which may succeed. '); $form->add($section); print $form; /* Show the traceroute results */ if ($do_traceroute && $result) { ?> <div class="panel panel-default"> <div class="panel-heading"><h2 class="panel-title"><?php echo gettext('Results'); ?> </h2></div> <div class="panel-body"> <?php