Skip to content

Adding REGEXP support for block searching #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions HawkEye Interface/interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,27 @@
array_push($args, "`timestamp` <= '" . $data["dateTo"] . "'");
if ($data["keywords"][0] != "") {
foreach ($data["keywords"] as $key => $val)
if($data["block"] != "00") //check if dealing with a block, or an entered string
{
//In SQL syntax, %SEARCH_STRING%, % matches everything, even digits.
//regexp is needed to avoid matching 156 for a 56 search.
$data["keywords"][$key] = "'(^|[^0-9^:^~^x])" . $val . "($|[^0-9^x^-])'";
//above is negation, bellow I saved my example for inclusion
//$data["keywords"][$key] = "'( |(^|@)([+]|[-])|^|[0-9]-)" . $val . "(~|$|:)'";
//chest transaction "@(-|+)ID(:|~)"
//pick/drop item " ID(:|$)"
//place/break "(^|-)ID(:|$)"
//edit: place is in format "formerblock-currentblock"
//happy xray hunting.
}
else //if not, continue normal operation
{
$data["keywords"][$key] = "'%" . $val . "%'";
array_push($args, "`data` LIKE " . join(" OR `data` LIKE ", $data["keywords"]));
}
if($data["block"] != "00") //again, if a block, do a REGEXP
array_push($args, "`data` REGEXP " . join(" OR `data` REGEXP ", $data["keywords"]));
else //if dealing with an entered string, do a LIKE seach with the already completed %% request
array_push($args, "`data` LIKE " . join(" OR `data` LIKE ", $data["keywords"]));
}
if ($data["exclude"][0] != "") {
foreach ($data["exclude"] as $key => $val)
Expand Down Expand Up @@ -288,4 +307,4 @@ function error($message) {
echo json_encode($output);
}

?>
?>