4 function search_post(&$a) {
6 $a->data['search'] = $_POST['search'];
10 function search_content(&$a) {
12 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
13 notice( t('Public access denied.') . EOL);
17 nav_set_selected('search');
19 require_once("include/bbcode.php");
20 require_once('include/security.php');
21 require_once('include/conversation.php');
23 if(x($_SESSION,'theme'))
24 unset($_SESSION['theme']);
26 $o = '<div id="live-search"></div>' . "\r\n";
28 $o .= '<h3>' . t('Search') . '</h3>';
30 if(x($a->data,'search'))
31 $search = notags(trim($a->data['search']));
33 $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
35 $o .= search($search);
40 // Here is the way permissions work in the search module...
41 // Only public wall posts can be shown
42 // OR your own posts if you are a logged in member
44 $s_bool = "AND MATCH (`item`.`body`) AGAINST ( '%s' IN BOOLEAN MODE )";
45 $s_regx = "AND `item`.`body` REGEXP '%s' ";
47 if(mb_strlen($search) >= 3)
48 $search_alg = $s_bool;
50 $search_alg = $s_regx;
52 $r = q("SELECT COUNT(*) AS `total`
53 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
54 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0
55 AND (( `wall` = 1 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `user`.`hidewall` = 0)
56 OR `item`.`uid` = %d )
57 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
64 $a->set_pager_total($r[0]['total']);
66 if(! $r[0]['total']) {
67 info( t('No results.') . EOL);
71 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
72 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
73 `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
74 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
76 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
77 LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
78 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0
79 AND (( `wall` = 1 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `user`.`hidewall` = 0 )
80 OR `item`.`uid` = %d )
81 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
83 ORDER BY `received` DESC LIMIT %d , %d ",
86 intval($a->pager['start']),
87 intval($a->pager['itemspage'])
93 $o .= conversation($a,$r,'search',false);