Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

51 satır
1.0KB

  1. <?php
  2. function qsearch_init(App $a) {
  3. if (! local_user()) {
  4. killme();
  5. }
  6. $limit = (get_config('system','qsearch_limit') ? intval(get_config('system','qsearch_limit')) : 100);
  7. $search = ((x($_GET,'s')) ? notags(trim(urldecode($_GET['s']))) : '');
  8. if(! strlen($search))
  9. killme();
  10. if($search)
  11. $search = dbesc($search);
  12. $results = array();
  13. $r = q("SELECT * FROM `group` WHERE `name` REGEXP '$search' AND `deleted` = 0 AND `uid` = %d LIMIT 0, %d ",
  14. intval(local_user()),
  15. intval($limit)
  16. );
  17. if (dbm::is_result($r)) {
  18. foreach($r as $rr)
  19. $results[] = array( 0, (int) $rr['id'], $rr['name'], '', '');
  20. }
  21. $sql_extra = ((strlen($search)) ? " AND (`name` REGEXP '$search' OR `nick` REGEXP '$search') " : "");
  22. $r = q("SELECT * FROM `contact` WHERE `uid` = %d $sql_extra ORDER BY `name` ASC LIMIT 0, %d ",
  23. intval(local_user()),
  24. intval($limit)
  25. );
  26. if (dbm::is_result($r)) {
  27. foreach($r as $rr)
  28. $results[] = array( (int) $rr['id'], 0, $rr['name'],$rr['url'],$rr['photo']);
  29. }
  30. echo json_encode((object) $results);
  31. killme();
  32. }