X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fsearch.php;h=3f98b607f0dd92ab0a0a179eee25337fa9c37670;hb=2a3f94e4521f00142b99ba4fa5f4ec093159cbb7;hp=2ce3c8dcda9c47af2fb3c9496bc889cb9daeeffc;hpb=20d4fda22f26a99e7da930be639874f80ae7060d;p=friendica.git diff --git a/mod/search.php b/mod/search.php index 2ce3c8dcda..3f98b607f0 100644 --- a/mod/search.php +++ b/mod/search.php @@ -4,7 +4,7 @@ function search_saved_searches() { $o = ''; - $r = q("select `term` from `search` WHERE `uid` = %d", + $r = q("select `id`,`term` from `search` WHERE `uid` = %d", intval(local_user()) ); @@ -13,9 +13,9 @@ function search_saved_searches() { $o .= '

' . t('Saved Searches') . '

' . "\r\n"; $o .= '' . "\r\n"; + $o .= '
' . "\r\n"; } return $o; @@ -50,6 +50,9 @@ function search_init(&$a) { $a->page['aside'] .= search_saved_searches(); } + else + unset($_SESSION['theme']); + } @@ -68,17 +71,16 @@ function search_content(&$a) { notice( t('Public access denied.') . EOL); return; } + + nav_set_selected('search'); require_once("include/bbcode.php"); require_once('include/security.php'); require_once('include/conversation.php'); - if(x($_SESSION,'theme')) - unset($_SESSION['theme']); - $o = '' . "\r\n"; - $o .= '

' . t('Search') . '

'; + $o .= '

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

'; if(x($a->data,'search')) $search = notags(trim($a->data['search'])); @@ -94,13 +96,10 @@ function search_content(&$a) { // Only public wall posts can be shown // OR your own posts if you are a logged in member - $s_bool = "AND MATCH (`item`.`body`) AGAINST ( '%s' IN BOOLEAN MODE )"; - $s_regx = "AND `item`.`body` REGEXP '%s' "; + $s_regx = sprintf("AND ( `item`.`body` REGEXP '%s' OR `item`.`tag` REGEXP '%s' )", + dbesc(preg_quote($search)), dbesc('\\]' . preg_quote($search) . '\\[')); - if(mb_strlen($search) >= 3) - $search_alg = $s_bool; - else - $search_alg = $s_regx; + $search_alg = $s_regx; $r = q("SELECT COUNT(*) AS `total` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid` @@ -109,8 +108,7 @@ function search_content(&$a) { OR `item`.`uid` = %d ) AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 $search_alg ", - intval(local_user()), - dbesc($search) + intval(local_user()) ); if(count($r)) @@ -135,7 +133,6 @@ function search_content(&$a) { $search_alg ORDER BY `received` DESC LIMIT %d , %d ", intval(local_user()), - dbesc($search), intval($a->pager['start']), intval($a->pager['itemspage'])