From 513ef2410d9b892c8ebcb7ceac96b97023c3b5a5 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 19 May 2012 02:42:11 -0700 Subject: backend support for 'x' deliveries per process - x is configurable, more importantly any search starting with # is automatically a tag search. TODO: Need to extend this to people searches starting with @ --- mod/search.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'mod/search.php') diff --git a/mod/search.php b/mod/search.php index d467764b0..635c87b70 100644 --- a/mod/search.php +++ b/mod/search.php @@ -96,6 +96,12 @@ function search_content(&$a) { $o .= search($search,'search-box','/search',((local_user()) ? true : false)); + + if(strpos($search,'#') === 0) { + $tag = true; + $search = substr($search,1); + } + if(! $search) return $o; -- cgit v1.2.3 From f16a1199408d167bbc7c52dc408ef02b36808317 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 19 May 2012 21:53:27 -0700 Subject: search with leading @ performs directory search (# for tag search), nothing for text search --- mod/search.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'mod/search.php') diff --git a/mod/search.php b/mod/search.php index 635c87b70..3e6bf68aa 100644 --- a/mod/search.php +++ b/mod/search.php @@ -80,7 +80,7 @@ function search_content(&$a) { $o = '' . "\r\n"; - $o .= '

' . t('Search This Site') . '

'; + $o .= '

' . t('Search') . '

'; if(x($a->data,'search')) $search = notags(trim($a->data['search'])); @@ -101,6 +101,10 @@ function search_content(&$a) { $tag = true; $search = substr($search,1); } + if(strpos($search,'@') === 0) { + require_once('mod/dirfind.php'); + return dirfind_content($a); + } if(! $search) return $o; -- cgit v1.2.3 From 49512105082dde72553f4250e6284920612cc6b8 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 26 May 2012 03:21:07 +0200 Subject: Speed optimisation by enabling the posibility of the MySQL fulltext engine --- mod/search.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'mod/search.php') diff --git a/mod/search.php b/mod/search.php index 3e6bf68aa..ac5134696 100644 --- a/mod/search.php +++ b/mod/search.php @@ -109,11 +109,17 @@ function search_content(&$a) { if(! $search) return $o; - if($tag) - $sql_extra = sprintf(" AND `item`.`tag` REGEXP '%s' ", dbesc('\\]' . preg_quote($search) . '\\[')); - else - $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(preg_quote($search))); - + if (get_config('system','use_fulltext_engine')) { + if($tag) + $sql_extra = sprintf(" AND MATCH (`item`.`tag`) AGAINST ('".'"%s"'."' in boolean mode) ", '#'.preg_quote($search)); + else + $sql_extra = sprintf(" AND MATCH (`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) ", dbesc(preg_quote($search))); + } else { + if($tag) + $sql_extra = sprintf(" AND `item`.`tag` REGEXP '%s' ", dbesc('\\]' . preg_quote($search) . '\\[')); + else + $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(preg_quote($search))); + } -- cgit v1.2.3 From a5dc41ab131d4235eb947ff00d7af0593bf0e460 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 26 May 2012 11:51:48 +0200 Subject: Saved searches now can search for tags as well --- mod/search.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'mod/search.php') diff --git a/mod/search.php b/mod/search.php index ac5134696..d4cd9d967 100644 --- a/mod/search.php +++ b/mod/search.php @@ -71,7 +71,7 @@ function search_content(&$a) { notice( t('Public access denied.') . EOL); return; } - + nav_set_selected('search'); require_once("include/bbcode.php"); @@ -96,7 +96,6 @@ function search_content(&$a) { $o .= search($search,'search-box','/search',((local_user()) ? true : false)); - if(strpos($search,'#') === 0) { $tag = true; $search = substr($search,1); -- cgit v1.2.3 From 419cf91aae555f6e42767765f476b1f1cc85e5df Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 29 May 2012 16:44:02 -0700 Subject: bugfixes: private photo embeds and search for strings with % --- mod/search.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mod/search.php') diff --git a/mod/search.php b/mod/search.php index 3e6bf68aa..6d4bd07e3 100644 --- a/mod/search.php +++ b/mod/search.php @@ -110,9 +110,9 @@ function search_content(&$a) { return $o; if($tag) - $sql_extra = sprintf(" AND `item`.`tag` REGEXP '%s' ", dbesc('\\]' . preg_quote($search) . '\\[')); + $sql_extra = sprintf(" AND `item`.`tag` REGEXP '%s' ", dbesc('\\]' . protect_sprintf(preg_quote($search)) . '\\[')); else - $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(preg_quote($search))); + $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search)))); -- cgit v1.2.3 From 514c994e6a323cd8075da1442c32e65f036539ff Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 29 May 2012 17:14:35 -0700 Subject: possible sql injection in search --- mod/search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod/search.php') diff --git a/mod/search.php b/mod/search.php index 20007ada7..466ffc4c3 100644 --- a/mod/search.php +++ b/mod/search.php @@ -110,7 +110,7 @@ function search_content(&$a) { if (get_config('system','use_fulltext_engine')) { if($tag) - $sql_extra = sprintf(" AND MATCH (`item`.`tag`) AGAINST ('".'"%s"'."' in boolean mode) ", '#'.protect_sprintf($search)); + $sql_extra = sprintf(" AND MATCH (`item`.`tag`) AGAINST ('".'"%s"'."' in boolean mode) ", '#'.dbesc(protect_sprintf($search))); else $sql_extra = sprintf(" AND MATCH (`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) ", dbesc(protect_sprintf($search))); } else { -- cgit v1.2.3 From 29bdf432f012af9b1959d5b4a33b3c45d220fd64 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 2 Jun 2012 00:40:38 -0700 Subject: fewer "bob smith to bob smith via wall-to-wall". --- mod/search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod/search.php') diff --git a/mod/search.php b/mod/search.php index 466ffc4c3..320ffddce 100644 --- a/mod/search.php +++ b/mod/search.php @@ -146,7 +146,7 @@ function search_content(&$a) { } $r = q("SELECT distinct(`item`.`uri`), `item`.*, `item`.`id` AS `item_id`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, + `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`, `user`.`nickname` -- cgit v1.2.3