--- a/src/usr/local/www/diag_packet_capture.php +++ b/src/usr/local/www/diag_packet_capture.php @@ -277,10 +277,7 @@ $action = gettext("Start"); //delete previous packet capture if it exists - if (file_exists($fp.$fn)) { - unlink ($fp.$fn); - } - + unlink_if_exists($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)'")); @@ -297,6 +294,9 @@ } elseif ($_POST['downloadbtn'] != "") { //download file send_user_download('file', $fp.$fn); + } elseif ($_POST['clearbtn'] != "") { + //delete previous packet capture if it exists + unlink_if_exists($fp.$fn); } } } else { @@ -491,6 +491,13 @@ null, 'fa-download' ))->addClass('btn-primary'); + + $form->addGlobal(new Form_Button( + 'clearbtn', + 'Clear Capture', + null, + 'fa-undo' + ))->addClass('btn-danger restore'); if (file_exists($fp.$fns)) { $section->addInput(new Form_StaticText(