4 use Friendica\Database\DBA;
7 function msearch_post(App $a)
9 $search = $_POST['s'] ?? '';
10 $perpage = intval(($_POST['n'] ?? 0) ?: 80);
11 $page = intval(($_POST['p'] ?? 0) ?: 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 `user`.`hidewall` = 0
30 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 `user`.`hidewall` = 0
45 AND MATCH(`pub_keywords`) AGAINST (?)
52 while($search_result = DBA::fetch($search_stmt)) {
54 'name' => $search_result['name'],
55 'url' => DI::baseUrl() . '/profile/' . $search_result['nickname'],
56 'photo' => DI::baseUrl() . '/photo/avatar/' . $search_result['uid'] . '.jpg',
57 'tags' => str_replace([',', ' '], [' ', ' '], $search_result['pub_keywords'])
61 $output = ['total' => $total, 'items_page' => $perpage, 'page' => $page, 'results' => $results];
63 echo json_encode($output);