X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fsearch.php;h=e2c365fd3ace99bbff38ebb5475db0411e70e265;hb=6a8b96709e13b04a0657c25b4538c160e2118131;hp=f7ce75905a80b23c6616baf39da485d2da594423;hpb=0283cbfcd35a29b5689ffbf16439d448de0c7254;p=friendica.git
diff --git a/mod/search.php b/mod/search.php
index f7ce75905a..e2c365fd3a 100644
--- a/mod/search.php
+++ b/mod/search.php
@@ -1,5 +1,63 @@
';
+ $o .= '
' . t('Saved Searches') . '
' . "\r\n";
+ $o .= '' . "\r\n";
+ }
+
+ return $o;
+
+}
+
+
+function search_init(&$a) {
+
+ $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
+
+ if(local_user()) {
+ if(x($_GET,'save') && $search) {
+ $r = q("select * from `search` where `uid` = %d and `term` = '%s' limit 1",
+ intval(local_user()),
+ dbesc($search)
+ );
+ if(! count($r)) {
+ q("insert into `search` ( `uid`,`term` ) values ( %d, '%s') ",
+ intval(local_user()),
+ dbesc($search)
+ );
+ }
+ }
+ if(x($_GET,'remove') && $search) {
+ q("delete from `search` where `uid` = %d and `term` = '%s' limit 1",
+ intval(local_user()),
+ dbesc($search)
+ );
+ }
+
+ $a->page['aside'] .= search_saved_searches();
+
+ }
+ else
+ unset($_SESSION['theme']);
+
+
+
+}
+
+
function search_post(&$a) {
if(x($_POST,'search'))
@@ -20,19 +78,16 @@ function search_content(&$a) {
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']));
else
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
- $o .= search($search);
+ $o .= search($search,'search-box','/search',((local_user()) ? true : false));
if(! $search)
return $o;
@@ -41,12 +96,15 @@ 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' ";
- if(mb_strlen($search) >= 3)
- $search_alg = $s_bool;
- else
+// $s_bool = sprintf("AND MATCH (`item`.`body`) AGAINST ( '%s' IN BOOLEAN MODE )", dbesc($search));
+ $s_regx = sprintf("AND ( `item`.`body` REGEXP '%s' OR `item`.`tag` REGEXP '%s' )",
+ dbesc($search), dbesc('\\]' . $search . '\\['));
+
+// if(mb_strlen($search) >= 3)
+// $search_alg = $s_bool;
+// else
+
$search_alg = $s_regx;
$r = q("SELECT COUNT(*) AS `total`
@@ -56,8 +114,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))
@@ -82,18 +139,16 @@ 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'])
);
-
+ $o .= 'Search results for: ' . $search . '
';
$o .= conversation($a,$r,'search',false);
$o .= paginate($a);
- $o .= cc_license();
return $o;
}