match better, so user_id=123 doesn't hit id=123
This commit is contained in:
parent
ddaa85583e
commit
2c37ce9a8d
5 changed files with 12 additions and 12 deletions
|
@ -58,7 +58,7 @@ class DanbooruApi implements Extension
|
|||
if($event instanceof SearchTermParseEvent)
|
||||
{
|
||||
$matches = array();
|
||||
if(preg_match("/md5:([0-9a-fA-F]*)/i", $event->term, $matches))
|
||||
if(preg_match("/^md5:([0-9a-fA-F]*)$/i", $event->term, $matches))
|
||||
{
|
||||
$hash = strtolower($matches[1]);
|
||||
$event->set_querylet(new Querylet("images.hash = '$hash'"));
|
||||
|
|
|
@ -77,7 +77,7 @@ class NumericScore implements Extension {
|
|||
|
||||
if($event instanceof SearchTermParseEvent) {
|
||||
$matches = array();
|
||||
if(preg_match("/score(<|<=|=|>=|>)(\d+)/", $event->term, $matches)) {
|
||||
if(preg_match("/^score(<|<=|=|>=|>)(\d+)$/", $event->term, $matches)) {
|
||||
$cmp = $matches[1];
|
||||
$score = $matches[2];
|
||||
$event->set_querylet(new Querylet("numeric_score $cmp $score"));
|
||||
|
|
|
@ -84,7 +84,7 @@ class Ratings implements Extension {
|
|||
$set = join(', ', $arr);
|
||||
$event->add_querylet(new Querylet("rating IN ($set)"));
|
||||
}
|
||||
if(preg_match("/rating=([sqe]+)/", $event->term, $matches)) {
|
||||
if(preg_match("/^rating=([sqeu]+)$/", $event->term, $matches)) {
|
||||
$sqes = $matches[1];
|
||||
$arr = array();
|
||||
for($i=0; $i<strlen($sqes); $i++) {
|
||||
|
|
|
@ -104,35 +104,35 @@ class Index implements Extension {
|
|||
|
||||
if($event instanceof SearchTermParseEvent) {
|
||||
$matches = array();
|
||||
if(preg_match("/size(<|>|<=|>=|=)(\d+)x(\d+)/", $event->term, $matches)) {
|
||||
if(preg_match("/^size(<|>|<=|>=|=)(\d+)x(\d+)$/", $event->term, $matches)) {
|
||||
$cmp = $matches[1];
|
||||
$args = array(int_escape($matches[2]), int_escape($matches[3]));
|
||||
$event->add_querylet(new Querylet("width $cmp ? AND height $cmp ?", $args));
|
||||
}
|
||||
else if(preg_match("/ratio(<|>|<=|>=|=)(\d+):(\d+)/", $event->term, $matches)) {
|
||||
else if(preg_match("/^ratio(<|>|<=|>=|=)(\d+):(\d+)$/", $event->term, $matches)) {
|
||||
$cmp = $matches[1];
|
||||
$args = array(int_escape($matches[2]), int_escape($matches[3]));
|
||||
$event->add_querylet(new Querylet("width / height $cmp ? / ?", $args));
|
||||
}
|
||||
else if(preg_match("/(filesize|id)(<|>|<=|>=|=)(\d+[kmg]?b?)/i", $event->term, $matches)) {
|
||||
else if(preg_match("/^(filesize|id)(<|>|<=|>=|=)(\d+[kmg]?b?)$/i", $event->term, $matches)) {
|
||||
$col = $matches[1];
|
||||
$cmp = $matches[2];
|
||||
$val = parse_shorthand_int($matches[3]);
|
||||
$event->add_querylet(new Querylet("images.$col $cmp ?", array($val)));
|
||||
}
|
||||
else if(preg_match("/hash=([0-9a-fA-F]*)/i", $event->term, $matches)) {
|
||||
else if(preg_match("/^hash=([0-9a-fA-F]*)$/i", $event->term, $matches)) {
|
||||
$hash = strtolower($matches[2]);
|
||||
$event->add_querylet(new Querylet("images.hash = '$hash'"));
|
||||
}
|
||||
else if(preg_match("/(filetype|ext)=([a-zA-Z0-9]*)/i", $event->term, $matches)) {
|
||||
else if(preg_match("/^(filetype|ext)=([a-zA-Z0-9]*)$/i", $event->term, $matches)) {
|
||||
$ext = strtolower($matches[2]);
|
||||
$event->add_querylet(new Querylet("images.ext = '$ext'"));
|
||||
}
|
||||
else if(preg_match("/(filename|name)=([a-zA-Z0-9]*)/i", $event->term, $matches)) {
|
||||
else if(preg_match("/^(filename|name)=([a-zA-Z0-9]*)$/i", $event->term, $matches)) {
|
||||
$filename = strtolower($matches[2]);
|
||||
$event->add_querylet(new Querylet("images.filename LIKE '%$filename%'"));
|
||||
}
|
||||
else if(preg_match("/posted=(([0-9\*]*)?(-[0-9\*]*)?(-[0-9\*]*)?)/", $event->term, $matches)) {
|
||||
else if(preg_match("/^posted=(([0-9\*]*)?(-[0-9\*]*)?(-[0-9\*]*)?)$/", $event->term, $matches)) {
|
||||
$val = str_replace("*", "%", $matches[1]);
|
||||
$img_search->append(new Querylet("images.posted LIKE '%$val%'"));
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ class UserPage implements Extension {
|
|||
|
||||
if($event instanceof SearchTermParseEvent) {
|
||||
$matches = array();
|
||||
if(preg_match("/(poster|user)=(.*)/i", $event->term, $matches)) {
|
||||
if(preg_match("/^(poster|user)=(.*)$/i", $event->term, $matches)) {
|
||||
global $config;
|
||||
global $database;
|
||||
$user = User::by_name($config, $database, $matches[2]);
|
||||
|
@ -178,7 +178,7 @@ class UserPage implements Extension {
|
|||
}
|
||||
$event->add_querylet(new Querylet("images.owner_id = $user_id"));
|
||||
}
|
||||
else if(preg_match("/(poster|user)_id=([0-9]+)/i", $event->term, $matches)) {
|
||||
else if(preg_match("/^(poster|user)_id=([0-9]+)$/i", $event->term, $matches)) {
|
||||
$user_id = int_escape($matches[2]);
|
||||
$event->add_querylet(new Querylet("images.owner_id = $user_id"));
|
||||
}
|
||||
|
|
Reference in a new issue