index.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. // Data
  24. if ($_SESSION['user'] == 'admin') {
  25. $q = escapeshellarg($q);
  26. exec (VESTA_CMD."v-search-object ".$q." json", $output, $return_var);
  27. $data = json_decode(implode('', $output), true);
  28. include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/list_search.html');
  29. } else {
  30. exec (VESTA_CMD."v-search-user-object ".$user." ".$q." json", $output, $return_var);
  31. $data = json_decode(implode('', $output), true);
  32. include($_SERVER['DOCUMENT_ROOT'].'/templates/user/list_search.html');
  33. }
  34. // Footer
  35. include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');