friendica_2021-01/mod/qsearch.php
Roland Häder ace8f753ac added much more curly braces + space between "if" and brace
Signed-off-by: Roland Häder <roland@mxchange.org>

Conflicts:
	mod/bookmarklet.php
	mod/community.php
	mod/contacts.php
	mod/crepair.php
	mod/events.php
	mod/network.php
	mod/suggest.php
	mod/uexport.php
	view/theme/duepuntozero/config.php
	view/theme/frio/config.php
	view/theme/quattro/config.php
	view/theme/vier/config.php
2016-12-20 11:59:13 +01:00

52 lines
1 KiB
PHP

<?php
function qsearch_init(&$a) {
if (! local_user()) {
killme();
}
$limit = (get_config('system','qsearch_limit') ? intval(get_config('system','qsearch_limit')) : 100);
$search = ((x($_GET,'s')) ? notags(trim(urldecode($_GET['s']))) : '');
if(! strlen($search))
killme();
if($search)
$search = dbesc($search);
$results = array();
$r = q("SELECT * FROM `group` WHERE `name` REGEXP '$search' AND `deleted` = 0 AND `uid` = %d LIMIT 0, %d ",
intval(local_user()),
intval($limit)
);
if (dbm::is_result($r)) {
foreach($r as $rr)
$results[] = array( 0, (int) $rr['id'], $rr['name'], '', '');
}
$sql_extra = ((strlen($search)) ? " AND (`name` REGEXP '$search' OR `nick` REGEXP '$search') " : "");
$r = q("SELECT * FROM `contact` WHERE `uid` = %d $sql_extra ORDER BY `name` ASC LIMIT 0, %d ",
intval(local_user()),
intval($limit)
);
if (dbm::is_result($r)) {
foreach($r as $rr)
$results[] = array( (int) $rr['id'], 0, $rr['name'],$rr['url'],$rr['photo']);
}
echo json_encode((object) $results);
killme();
}