4 use Friendica\Core\System;
5 use Friendica\Database\DBM;
7 function msearch_post(App $a) {
9 $perpage = (($_POST['n']) ? $_POST['n'] : 80);
10 $page = (($_POST['p']) ? intval($_POST['p'] - 1) : 0);
11 $startrec = (($page+1) * $perpage) - $perpage;
13 $search = $_POST['s'];
17 $r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') ",
21 if (DBM::is_result($r))
22 $total = $r[0]['total'];
26 $r = q("SELECT `pub_keywords`, `username`, `nickname`, `user`.`uid` FROM `user` LEFT JOIN `profile` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') LIMIT %d , %d ",
32 if (DBM::is_result($r)) {
35 'name' => $rr['name'],
36 'url' => System::baseUrl() . '/profile/' . $rr['nickname'],
37 'photo' => System::baseUrl() . '/photo/avatar/' . $rr['uid'] . '.jpg',
38 'tags' => str_replace(array(',',' '),array(' ',' '),$rr['pub_keywords'])
42 $output = array('total' => $total, 'items_page' => $perpage, 'page' => $page + 1, 'results' => $results);
44 echo json_encode($output);