From fb6222963426b59499fdbe88d4406f7d194a49ee Mon Sep 17 00:00:00 2001
From: shish <shish@7f39781d-f577-437e-ae19-be835c7a54ca>
Date: Wed, 6 Feb 2008 17:27:45 +0000
Subject: [PATCH] move md5: to danbooru api

git-svn-id: file:///home/shish/svn/shimmie2/trunk@714 7f39781d-f577-437e-ae19-be835c7a54ca
---
 contrib/danbooru_api/main.php | 9 +++++++++
 ext/index/main.php            | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/contrib/danbooru_api/main.php b/contrib/danbooru_api/main.php
index 8f0b6c4a..a4b27e16 100644
--- a/contrib/danbooru_api/main.php
+++ b/contrib/danbooru_api/main.php
@@ -42,6 +42,15 @@ class DanbooruApi extends Extension
 			// execute the danbooru processing code
 			$this->api_danbooru($event);
 		}
+		if(is_a($event, 'SearchTermParseEvent'))
+		{
+			$matches = array();
+			if(preg_match("/md5:([0-9a-fA-F]*)/i", $event->term, $matches))
+			{
+				$hash = strtolower($matches[2]);
+				$event->set_querylet(new Querylet("AND (images.hash = '$hash')"));
+			}
+		}
 	}
 	
 	// Danbooru API
diff --git a/ext/index/main.php b/ext/index/main.php
index 58834b33..d69b5f2c 100644
--- a/ext/index/main.php
+++ b/ext/index/main.php
@@ -109,7 +109,7 @@ class Index extends Extension {
 				}
 				$event->set_querylet(new Querylet("AND (images.owner_id = $user_id)"));
 			}
-			else if(preg_match("/(hash=|md5:)([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->set_querylet(new Querylet("AND (images.hash = '$hash')"));
 			}