search.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * @author Bart Visscher <bartv@thisnet.nl>
  4. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  5. * @author Lukas Reschke <lukas@owncloud.com>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Robin Appelman <icewind@owncloud.com>
  8. * @author Thomas Müller <thomas.mueller@tmit.eu>
  9. *
  10. * @copyright Copyright (c) 2015, ownCloud, Inc.
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. // Check if we are a user
  27. \OCP\JSON::checkLoggedIn();
  28. \OCP\JSON::callCheck();
  29. \OC::$server->getSession()->close();
  30. if (isset($_GET['query'])) {
  31. $query = $_GET['query'];
  32. } else {
  33. $query = '';
  34. }
  35. if (isset($_GET['inApps'])) {
  36. $inApps = $_GET['inApps'];
  37. if (is_string($inApps)) {
  38. $inApps = array($inApps);
  39. }
  40. } else {
  41. $inApps = array();
  42. }
  43. if (isset($_GET['page'])) {
  44. $page = (int)$_GET['page'];
  45. } else {
  46. $page = 1;
  47. }
  48. if (isset($_GET['size'])) {
  49. $size = (int)$_GET['size'];
  50. } else {
  51. $size = 30;
  52. }
  53. if($query) {
  54. $result = \OC::$server->getSearch()->searchPaged($query, $inApps, $page, $size);
  55. OC_JSON::encodedPrint($result);
  56. }
  57. else {
  58. echo 'false';
  59. }