$setting) { if (!isset($setting['disable'])) { $interfaces['ovpn' . substr($mode, 0, 1) . $setting['vpnid']] = gettext("OpenVPN") . " ".$mode.": ".htmlspecialchars($setting['description']); } } } } if ($_POST) { $host = $_POST['host']; $selectedif = $_POST['interface']; $count = $_POST['count']; $snaplen = $_POST['snaplen']; $port = $_POST['port']; $detail = $_POST['detail']; $fam = $_POST['fam']; $proto = $_POST['proto']; if (!array_key_exists($selectedif, $interfaces)) { $input_errors[] = gettext("Invalid interface."); } if ($fam !== "" && $fam !== "ip" && $fam !== "ip6") { $input_errors[] = gettext("Invalid address family."); } if ($proto !== "" && !in_array($proto, $protos)) { $input_errors[] = gettext("Invalid protocol."); } if ($host != "") { if (!is_subnet($host) && !is_ipaddr($host)) { $input_errors[] = sprintf(gettext("A valid IP address or CIDR block must be specified. [%s]"), $host); } } if ($port != "") { if (!is_port($port)) { $input_errors[] = gettext("Invalid value specified for port."); } } if ($snaplen == "") { $snaplen = 0; } else { if (!is_numeric($snaplen) || $snaplen < 0) { $input_errors[] = gettext("Invalid value specified for packet length."); } } if ($count == "") { $count = 0; } else { if (!is_numeric($count) || $count < 0) { $input_errors[] = gettext("Invalid value specified for packet count."); } } if (!count($input_errors)) { $do_tcpdump = true; conf_mount_rw(); if ($_POST['dnsquery']) { //if dns lookup is checked $disabledns = ""; } else { //if dns lookup is unchecked $disabledns = "-n"; } if ($_POST['startbtn'] != "" ) { $action = gettext("Start"); //delete previous packet capture if it exists if (file_exists($fp.$fn)) unlink ($fp.$fn); } elseif ($_POST['stopbtn']!= "") { $action = gettext("Stop"); $processes_running = trim(shell_exec("/bin/ps axw -O pid= | /usr/bin/grep tcpdump | /usr/bin/grep {$fn} | /usr/bin/egrep -v '(pflog|grep)'")); //explode processes into an array, (delimiter is new line) $processes_running_array = explode("\n", $processes_running); //kill each of the packetcapture processes foreach ($processes_running_array as $process) { $process_id_pos = strpos($process, ' '); $process_id = substr($process, 0, $process_id_pos); exec("kill $process_id"); } } elseif ($_POST['downloadbtn']!= "") { //download file $fs = filesize($fp.$fn); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=$fn"); header("Content-Length: $fs"); readfile($fp.$fn); exit; } } } else { $do_tcpdump = false; } include("head.inc"); ?>
|