]> git.mxchange.org Git - friendica.git/blobdiff - mod/network.php
Merge branch 'master' of github.com:annando/friendica
[friendica.git] / mod / network.php
index fbfe2de4fd1775008adc2bc6506eef0db4b32b52..a94272a4290fac21307bb6a720ae402db89d3d4e 100644 (file)
@@ -402,10 +402,22 @@ function network_content(&$a, $update = 0) {
 
        if(x($_GET,'search')) {
                $search = escape_tags($_GET['search']);
-               $sql_extra .= sprintf(" AND ( `item`.`body` like '%s' OR `item`.`tag` like '%s' ) ",
-                       dbesc(protect_sprintf('%' . $search . '%')),
-                       dbesc(protect_sprintf('%]' . $search . '[%'))
-               );
+               if (get_config('system','use_fulltext_engine')) {
+                       if(strpos($search,'#') === 0)
+                               $sql_extra .= sprintf(" AND (MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode)) ",
+                                       dbesc(protect_sprintf($search))
+                               );
+                       else
+                               $sql_extra .= sprintf(" AND (MATCH(`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode)) ",
+                                       dbesc(protect_sprintf($search)),
+                                       dbesc(protect_sprintf($search))
+                               );
+               } else {
+                       $sql_extra .= sprintf(" AND ( `item`.`body` like '%s' OR `item`.`tag` like '%s' ) ",
+                                       dbesc(protect_sprintf('%' . $search . '%')),
+                                       dbesc(protect_sprintf('%]' . $search . '[%'))
+                       );
+               }
        }
        if(strlen($file)) {
                $sql_extra .= file_tag_file_query('item',unxmlify($file));
@@ -416,11 +428,19 @@ function network_content(&$a, $update = 0) {
                $myurl = substr($myurl,strpos($myurl,'://')+3);
                $myurl = str_replace('www.','',$myurl);
                $diasp_url = str_replace('/profile/','/u/',$myurl);
-               $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ",
-                       dbesc(protect_sprintf('%' . $myurl)),
-                       dbesc(protect_sprintf('%' . $myurl . ']%')),
-                       dbesc(protect_sprintf('%' . $diasp_url . ']%'))
-               );
+               if (get_config('system','use_fulltext_engine'))
+                       $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (MATCH(`author-link`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ",
+                               dbesc(protect_sprintf($myurl)),
+                               dbesc(protect_sprintf($myurl)),
+                               dbesc(protect_sprintf($diasp_url))
+                       );
+               else
+                       $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ",
+                               dbesc(protect_sprintf('%' . $myurl)),
+                               dbesc(protect_sprintf('%' . $myurl . '\\]%')),
+                               dbesc(protect_sprintf('%' . $diasp_url . '\\]%'))
+                       );
+
        }
 
        if($update) {