4 use Friendica\Core\Config;
5 use Friendica\Database\DBM;
7 function qsearch_init(App $a) {
13 $limit = (Config::get('system','qsearch_limit') ? intval(Config::get('system','qsearch_limit')) : 100);
15 $search = ((x($_GET,'s')) ? notags(trim(urldecode($_GET['s']))) : '');
22 $search = dbesc($search);
26 $r = q("SELECT * FROM `group` WHERE `name` REGEXP '$search' AND `deleted` = 0 AND `uid` = %d LIMIT 0, %d ",
31 if (DBM::is_result($r)) {
34 $results[] = array( 0, (int) $rr['id'], $rr['name'], '', '');
37 $sql_extra = ((strlen($search)) ? " AND (`name` REGEXP '$search' OR `nick` REGEXP '$search') " : "");
40 $r = q("SELECT * FROM `contact` WHERE `uid` = %d $sql_extra ORDER BY `name` ASC LIMIT 0, %d ",
46 if (DBM::is_result($r)) {
49 $results[] = array( (int) $rr['id'], 0, $rr['name'],$rr['url'],$rr['photo']);
52 echo json_encode((object) $results);