4 use Friendica\Core\System;
5 use Friendica\Database\DBA;
7 function msearch_post(App $a)
9 $search = defaults($_POST, 's', '');
10 $perpage = intval(defaults($_POST, 'n', 80));
11 $page = intval(defaults($_POST, 'p', 1));
12 $startrec = ($page - 1) * $perpage;
17 if (!strlen($search)) {
18 $output = ['total' => 0, 'items_page' => $perpage, 'page' => $page, 'results' => $results];
19 echo json_encode($output);
26 "SELECT COUNT(*) AS `total`
28 JOIN `user` ON `user`.`uid` = `profile`.`uid`
29 WHERE `is-default` = 1
30 AND `user`.`hidewall` = 0
31 AND MATCH(`pub_keywords`) AGAINST (?)",
34 if (DBA::isResult($count_stmt)) {
35 $row = DBA::fetch($count_stmt);
36 $total = $row['total'];
39 DBA::close($count_stmt);
41 $search_stmt = DBA::p(
42 "SELECT `pub_keywords`, `username`, `nickname`, `user`.`uid`
44 JOIN `profile` ON `user`.`uid` = `profile`.`uid`
45 WHERE `is-default` = 1
46 AND `user`.`hidewall` = 0
47 AND MATCH(`pub_keywords`) AGAINST (?)
54 while($search_result = DBA::fetch($search_stmt)) {
56 'name' => $search_result['name'],
57 'url' => System::baseUrl() . '/profile/' . $search_result['nickname'],
58 'photo' => System::baseUrl() . '/photo/avatar/' . $search_result['uid'] . '.jpg',
59 'tags' => str_replace([',', ' '], [' ', ' '], $search_result['pub_keywords'])
63 $output = ['total' => $total, 'items_page' => $perpage, 'page' => $page, 'results' => $results];
65 echo json_encode($output);