index.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. use function Hestiacp\quoteshellarg\quoteshellarg;
  3. ob_start();
  4. include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
  5. // Check token
  6. verify_csrf($_GET);
  7. if (($_SESSION['userContext'] === 'admin') && (!empty($_GET['user']))) {
  8. $user = quoteshellarg($_GET['user']);
  9. $user_plain = $_GET['user'];
  10. }
  11. // Checks if API access is enabled
  12. $api_status = (!empty($_SESSION['API_SYSTEM']) && is_numeric($_SESSION['API_SYSTEM'])) ? $_SESSION['API_SYSTEM'] : 0;
  13. if (($user_plain == 'admin' && $api_status < 1) || ($user_plain != 'admin' && $api_status < 2)) {
  14. header("Location: /edit/user/");
  15. exit;
  16. }
  17. if (!empty($_GET['key'])) {
  18. $v_key = quoteshellarg(trim($_GET['key']));
  19. // Key data
  20. exec(HESTIA_CMD."v-list-access-key ".$v_key." json", $output, $return_var);
  21. $key_data = json_decode(implode('', $output), true);
  22. unset($output);
  23. if (empty($key_data) || $key_data['USER'] != $user_plain) {
  24. header("Location: /list/access-key/");
  25. exit;
  26. }
  27. exec(HESTIA_CMD."v-delete-access-key ".$v_key, $output, $return_var);
  28. check_return_code($return_var, $output);
  29. unset($output);
  30. }
  31. $back = $_SESSION['back'];
  32. if (!empty($back)) {
  33. header("Location: ".$back);
  34. exit;
  35. }
  36. header("Location: /list/key/");
  37. exit;