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 require_once("include/bbcode.php");
18 require_once('include/security.php');
19 require_once('include/conversation.php');
21 if(x($_SESSION,'theme'))
22 unset($_SESSION['theme']);
24 $o = '<div id="live-search"></div>' . "\r\n";
26 $o .= '<h3>' . t('Search') . '</h3>';
28 if(x($a->data,'search'))
29 $search = notags(trim($a->data['search']));
31 $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
33 $o .= search($search);
38 // Here is the way permissions work in the search module...
39 // Only public wall posts can be shown
40 // OR your own posts if you are a logged in member
42 $s_bool = "AND MATCH (`item`.`body`) AGAINST ( '%s' IN BOOLEAN MODE )";
43 $s_regx = "AND `item`.`body` REGEXP '%s' ";
45 if(mb_strlen($search) >= 3)
46 $search_alg = $s_bool;
48 $search_alg = $s_regx;
50 $r = q("SELECT COUNT(*) AS `total`
51 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
52 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0
53 AND (( `wall` = 1 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `user`.`hidewall` = 0)
54 OR `item`.`uid` = %d )
55 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
62 $a->set_pager_total($r[0]['total']);
64 if(! $r[0]['total']) {
65 info( t('No results.') . EOL);
69 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
70 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
71 `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
72 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
74 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
75 LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
76 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0
77 AND (( `wall` = 1 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `user`.`hidewall` = 0 )
78 OR `item`.`uid` = %d )
79 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
81 ORDER BY `received` DESC LIMIT %d , %d ",
84 intval($a->pager['start']),
85 intval($a->pager['itemspage'])
91 $o .= conversation($a,$r,'search',false);