index.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. // Init
  3. error_reporting(NULL);
  4. session_start();
  5. $TAB = 'SEARCH';
  6. $_SESSION['back'] = $_SERVER['REQUEST_URI'];
  7. include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
  8. // Check query
  9. $q = $_GET['q'];
  10. if (empty($q)) {
  11. $back=getenv("HTTP_REFERER");
  12. if (!empty($back)) {
  13. header("Location: ".$back);
  14. exit;
  15. }
  16. header("Location: /");
  17. exit;
  18. }
  19. // Header
  20. include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
  21. // Panel
  22. top_panel($user,$TAB);
  23. $lang = 'ru_RU.utf8';
  24. //setlocale(LC_ALL, $lang);
  25. // Data
  26. if ($_SESSION['user'] == 'admin') {
  27. $q = escapeshellarg($q);
  28. exec (VESTA_CMD."v-search-object ".$q." json", $output, $return_var);
  29. $data = json_decode(implode('', $output), true);
  30. include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/list_search.html');
  31. } else {
  32. exec (VESTA_CMD."v-search-user-object ".$user." ".$q." json", $output, $return_var);
  33. $data = json_decode(implode('', $output), true);
  34. include($_SERVER['DOCUMENT_ROOT'].'/templates/user/list_search.html');
  35. }
  36. // Footer
  37. include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');