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);
24 "SELECT COUNT(*) AS `total`
26 JOIN `user` ON `user`.`uid` = `profile`.`uid`
27 WHERE `is-default` = 1
28 AND `user`.`hidewall` = 0
29 AND MATCH(`pub_keywords`) AGAINST (?)",
33 if (DBA::isResult($count_stmt)) {
34 $row = DBA::fetch($count_stmt);
35 $total = $row['total'];
38 DBA::close($count_stmt);
40 $search_stmt = DBA::p(
41 "SELECT `pub_keywords`, `username`, `nickname`, `user`.`uid`
43 JOIN `profile` ON `user`.`uid` = `profile`.`uid`
44 WHERE `is-default` = 1
45 AND `user`.`hidewall` = 0
46 AND MATCH(`pub_keywords`) AGAINST (?)
53 while($search_result = DBA::fetch($search_stmt)) {
55 'name' => $search_result['name'],
56 'url' => System::baseUrl() . '/profile/' . $search_result['nickname'],
57 'photo' => System::baseUrl() . '/photo/avatar/' . $search_result['uid'] . '.jpg',
58 'tags' => str_replace([',', ' '], [' ', ' '], $search_result['pub_keywords'])
62 $output = ['total' => $total, 'items_page' => $perpage, 'page' => $page, 'results' => $results];
64 echo json_encode($output);