From 74f855fc5d392e41d49732789b831a72e4b1c5af Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Wed, 1 Jun 2022 11:35:13 -0400 Subject: [PATCH] Supporting "NOT" in search --- scripts/todays_detections.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/todays_detections.php b/scripts/todays_detections.php index 33b7e14..45f89f6 100644 --- a/scripts/todays_detections.php +++ b/scripts/todays_detections.php @@ -65,7 +65,16 @@ $home = trim($home); if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" ) { if(isset($_GET['searchterm'])) { - $searchquery = "AND (Com_name LIKE '%".$_GET['searchterm']."%' OR Sci_name LIKE '%".$_GET['searchterm']."%' OR Confidence LIKE '%".$_GET['searchterm']."%' OR File_Name LIKE '%".$_GET['searchterm']."%' OR Time LIKE '%".$_GET['searchterm']."%')"; + if(strtolower(explode(" ", $_GET['searchterm'])[0]) == "not") { + $not = "NOT "; + $operator = "AND"; + $_GET['searchterm'] = str_replace("not ", "", $_GET['searchterm']); + $_GET['searchterm'] = str_replace("NOT ", "", $_GET['searchterm']); + } else { + $not = ""; + $operator = "OR"; + } + $searchquery = "AND (Com_name ".$not."LIKE '%".$_GET['searchterm']."%' ".$operator." Sci_name ".$not."LIKE '%".$_GET['searchterm']."%' ".$operator." Confidence ".$not."LIKE '%".$_GET['searchterm']."%' ".$operator." File_Name ".$not."LIKE '%".$_GET['searchterm']."%' ".$operator." Time ".$not."LIKE '%".$_GET['searchterm']."%')"; } else { $searchquery = ""; }